@cladd-ui/react 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.md +1 -1
- package/components/Backdrop.d.ts +8 -0
- package/components/Backdrop.d.ts.map +1 -0
- package/components/Backdrop.js +7 -0
- package/components/Backdrop.js.map +1 -0
- package/components/BlockTitle.d.ts +10 -0
- package/components/BlockTitle.d.ts.map +1 -0
- package/components/BlockTitle.js +7 -0
- package/components/BlockTitle.js.map +1 -0
- package/components/Button.d.ts +61 -0
- package/components/Button.d.ts.map +1 -0
- package/components/Button.js +83 -0
- package/components/Button.js.map +1 -0
- package/components/Checkbox.d.ts +57 -0
- package/components/Checkbox.d.ts.map +1 -0
- package/components/Checkbox.js +48 -0
- package/components/Checkbox.js.map +1 -0
- package/components/Chip.d.ts +47 -0
- package/components/Chip.d.ts.map +1 -0
- package/components/Chip.js +55 -0
- package/components/Chip.js.map +1 -0
- package/components/Dialog.d.ts +118 -0
- package/components/Dialog.d.ts.map +1 -0
- package/components/Dialog.js +178 -0
- package/components/Dialog.js.map +1 -0
- package/components/DialogsPortal.d.ts +2 -0
- package/components/DialogsPortal.d.ts.map +1 -0
- package/components/DialogsPortal.js +17 -0
- package/components/DialogsPortal.js.map +1 -0
- package/components/DialogsPortalContext.d.ts +49 -0
- package/components/DialogsPortalContext.d.ts.map +1 -0
- package/components/DialogsPortalContext.js +17 -0
- package/components/DialogsPortalContext.js.map +1 -0
- package/components/FocusableLayer.d.ts +25 -0
- package/components/FocusableLayer.d.ts.map +1 -0
- package/components/FocusableLayer.js +18 -0
- package/components/FocusableLayer.js.map +1 -0
- package/components/Input.d.ts +87 -0
- package/components/Input.d.ts.map +1 -0
- package/components/Input.js +93 -0
- package/components/Input.js.map +1 -0
- package/components/Link.d.ts +28 -0
- package/components/Link.d.ts.map +1 -0
- package/components/Link.js +21 -0
- package/components/Link.js.map +1 -0
- package/components/List.d.ts +8 -0
- package/components/List.d.ts.map +1 -0
- package/components/List.js +7 -0
- package/components/List.js.map +1 -0
- package/components/ListButton.d.ts +61 -0
- package/components/ListButton.d.ts.map +1 -0
- package/components/ListButton.js +9 -0
- package/components/ListButton.js.map +1 -0
- package/components/ListItem.d.ts +8 -0
- package/components/ListItem.d.ts.map +1 -0
- package/components/ListItem.js +7 -0
- package/components/ListItem.js.map +1 -0
- package/components/ListSeparator.d.ts +8 -0
- package/components/ListSeparator.d.ts.map +1 -0
- package/components/ListSeparator.js +7 -0
- package/components/ListSeparator.js.map +1 -0
- package/components/ModalController.d.ts +26 -0
- package/components/ModalController.d.ts.map +1 -0
- package/components/ModalController.js +52 -0
- package/components/ModalController.js.map +1 -0
- package/components/NumberField.d.ts +49 -0
- package/components/NumberField.d.ts.map +1 -0
- package/components/NumberField.js +34 -0
- package/components/NumberField.js.map +1 -0
- package/components/Popover.d.ts +137 -0
- package/components/Popover.d.ts.map +1 -0
- package/components/Popover.js +366 -0
- package/components/Popover.js.map +1 -0
- package/components/Popup.d.ts +120 -0
- package/components/Popup.d.ts.map +1 -0
- package/components/Popup.js +235 -0
- package/components/Popup.js.map +1 -0
- package/components/PopupContent.d.ts +19 -0
- package/components/PopupContent.d.ts.map +1 -0
- package/components/PopupContent.js +8 -0
- package/components/PopupContent.js.map +1 -0
- package/components/Preloader.d.ts +12 -0
- package/components/Preloader.d.ts.map +1 -0
- package/components/Preloader.js +30 -0
- package/components/Preloader.js.map +1 -0
- package/components/Radio.d.ts +53 -0
- package/components/Radio.d.ts.map +1 -0
- package/components/Radio.js +46 -0
- package/components/Radio.js.map +1 -0
- package/components/Range.d.ts +35 -0
- package/components/Range.d.ts.map +1 -0
- package/components/Range.js +76 -0
- package/components/Range.js.map +1 -0
- package/components/Searchbar.d.ts +29 -0
- package/components/Searchbar.d.ts.map +1 -0
- package/components/Searchbar.js +10 -0
- package/components/Searchbar.js.map +1 -0
- package/components/Segmented.d.ts +39 -0
- package/components/Segmented.d.ts.map +1 -0
- package/components/Segmented.js +26 -0
- package/components/Segmented.js.map +1 -0
- package/components/SegmentedButton.d.ts +13 -0
- package/components/SegmentedButton.d.ts.map +1 -0
- package/components/SegmentedButton.js +10 -0
- package/components/SegmentedButton.js.map +1 -0
- package/components/SegmentedContext.d.ts +36 -0
- package/components/SegmentedContext.d.ts.map +1 -0
- package/components/SegmentedContext.js +10 -0
- package/components/SegmentedContext.js.map +1 -0
- package/components/Select.d.ts +145 -0
- package/components/Select.d.ts.map +1 -0
- package/components/Select.js +316 -0
- package/components/Select.js.map +1 -0
- package/components/Surface.d.ts +67 -0
- package/components/Surface.d.ts.map +1 -0
- package/components/Surface.js +36 -0
- package/components/Surface.js.map +1 -0
- package/components/SurfaceContent.d.ts +8 -0
- package/components/SurfaceContent.d.ts.map +1 -0
- package/components/SurfaceContent.js +7 -0
- package/components/SurfaceContent.js.map +1 -0
- package/components/SurfaceContext.d.ts +19 -0
- package/components/SurfaceContext.d.ts.map +1 -0
- package/components/SurfaceContext.js +9 -0
- package/components/SurfaceContext.js.map +1 -0
- package/components/SurfaceCut.d.ts +33 -0
- package/components/SurfaceCut.d.ts.map +1 -0
- package/components/SurfaceCut.js +17 -0
- package/components/SurfaceCut.js.map +1 -0
- package/components/SurfaceCutContent.d.ts +16 -0
- package/components/SurfaceCutContent.d.ts.map +1 -0
- package/components/SurfaceCutContent.js +8 -0
- package/components/SurfaceCutContent.js.map +1 -0
- package/components/TextArea.d.ts +61 -0
- package/components/TextArea.d.ts.map +1 -0
- package/components/TextArea.js +102 -0
- package/components/TextArea.js.map +1 -0
- package/components/ThemeContext.d.ts +23 -0
- package/components/ThemeContext.d.ts.map +1 -0
- package/components/ThemeContext.js +18 -0
- package/components/ThemeContext.js.map +1 -0
- package/components/Toast.d.ts +89 -0
- package/components/Toast.d.ts.map +1 -0
- package/components/Toast.js +129 -0
- package/components/Toast.js.map +1 -0
- package/components/ToastsPortal.d.ts +2 -0
- package/components/ToastsPortal.d.ts.map +1 -0
- package/components/ToastsPortal.js +17 -0
- package/components/ToastsPortal.js.map +1 -0
- package/components/ToastsPortalContext.d.ts +45 -0
- package/components/ToastsPortalContext.d.ts.map +1 -0
- package/components/ToastsPortalContext.js +17 -0
- package/components/ToastsPortalContext.js.map +1 -0
- package/components/Toggle.d.ts +69 -0
- package/components/Toggle.d.ts.map +1 -0
- package/components/Toggle.js +48 -0
- package/components/Toggle.js.map +1 -0
- package/components/Tooltip.d.ts +48 -0
- package/components/Tooltip.d.ts.map +1 -0
- package/components/Tooltip.js +90 -0
- package/components/Tooltip.js.map +1 -0
- package/components/UIProvider.d.ts +16 -0
- package/components/UIProvider.d.ts.map +1 -0
- package/components/UIProvider.js +11 -0
- package/components/UIProvider.js.map +1 -0
- package/components/WithTooltip.d.ts +36 -0
- package/components/WithTooltip.d.ts.map +1 -0
- package/components/WithTooltip.js +138 -0
- package/components/WithTooltip.js.map +1 -0
- package/components/icons/CheckIcon.d.ts +2 -0
- package/components/icons/CheckIcon.d.ts.map +1 -0
- package/components/icons/CheckIcon.js +5 -0
- package/components/icons/CheckIcon.js.map +1 -0
- package/components/icons/CloseIcon.d.ts +2 -0
- package/components/icons/CloseIcon.d.ts.map +1 -0
- package/components/icons/CloseIcon.js +3 -0
- package/components/icons/CloseIcon.js.map +1 -0
- package/components/icons/DropdownIcon.d.ts +2 -0
- package/components/icons/DropdownIcon.d.ts.map +1 -0
- package/components/icons/DropdownIcon.js +3 -0
- package/components/icons/DropdownIcon.js.map +1 -0
- package/components/icons/SearchIcon.d.ts +2 -0
- package/components/icons/SearchIcon.d.ts.map +1 -0
- package/components/icons/SearchIcon.js +5 -0
- package/components/icons/SearchIcon.js.map +1 -0
- package/hooks/use-accent-color.d.ts +2 -0
- package/hooks/use-accent-color.d.ts.map +1 -0
- package/hooks/use-accent-color.js +6 -0
- package/hooks/use-accent-color.js.map +1 -0
- package/hooks/use-device.d.ts +14 -0
- package/hooks/use-device.d.ts.map +1 -0
- package/hooks/use-device.js +68 -0
- package/hooks/use-device.js.map +1 -0
- package/hooks/use-dialog.d.ts +8 -0
- package/hooks/use-dialog.d.ts.map +1 -0
- package/hooks/use-dialog.js +38 -0
- package/hooks/use-dialog.js.map +1 -0
- package/hooks/use-focus-trap.d.ts +9 -0
- package/hooks/use-focus-trap.d.ts.map +1 -0
- package/hooks/use-focus-trap.js +106 -0
- package/hooks/use-focus-trap.js.map +1 -0
- package/hooks/use-modal-utils.d.ts +17 -0
- package/hooks/use-modal-utils.d.ts.map +1 -0
- package/hooks/use-modal-utils.js +110 -0
- package/hooks/use-modal-utils.js.map +1 -0
- package/hooks/use-surface.d.ts +2 -0
- package/hooks/use-surface.d.ts.map +1 -0
- package/hooks/use-surface.js +6 -0
- package/hooks/use-surface.js.map +1 -0
- package/hooks/use-theme.d.ts +2 -0
- package/hooks/use-theme.d.ts.map +1 -0
- package/hooks/use-theme.js +6 -0
- package/hooks/use-theme.js.map +1 -0
- package/hooks/use-toast.d.ts +3 -0
- package/hooks/use-toast.d.ts.map +1 -0
- package/hooks/use-toast.js +21 -0
- package/hooks/use-toast.js.map +1 -0
- package/index.d.ts +42 -0
- package/index.d.ts.map +1 -0
- package/index.js +42 -0
- package/index.js.map +1 -0
- package/package.json +27 -9
- package/shared/cn.d.ts +3 -0
- package/shared/cn.d.ts.map +1 -0
- package/shared/cn.js +6 -0
- package/shared/cn.js.map +1 -0
- package/shared/next-tick.d.ts +2 -0
- package/shared/next-tick.d.ts.map +1 -0
- package/shared/next-tick.js +6 -0
- package/shared/next-tick.js.map +1 -0
- package/styles/colors.css +403 -0
- package/styles/popup.css +14 -0
- package/styles/preloader.css +71 -0
- package/styles/range.css +17 -0
- package/styles/safe-areas.css +192 -0
- package/types.d.ts +2 -0
- package/types.d.ts.map +1 -0
- package/types.js +2 -0
- package/types.js.map +1 -0
- package/ui.css +10 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ElementType, ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { Color } from '../types';
|
|
3
|
+
import { SurfaceVariant } from './Surface';
|
|
4
|
+
export type ToggleSize = 'sm' | 'md';
|
|
5
|
+
interface ToggleOwnProps<C extends ElementType = 'label'> {
|
|
6
|
+
/** Controlled checked state. Default `false`. */
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
/** Visually dim the toggle and disable interaction. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Block toggling without the disabled visual treatment. */
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
/** Fires when the user toggles. First arg is the new checked state, second is the raw event. */
|
|
13
|
+
onChange?: (checked: boolean, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
14
|
+
/** Accent color for the checked state knob fill. Default: theme accent. */
|
|
15
|
+
color?: Color;
|
|
16
|
+
/**
|
|
17
|
+
* Polymorphic root element. Defaults to `'label'` so a wrapping `<label>` activates the hidden
|
|
18
|
+
* input on click. Use a non-label container when nesting inside an existing label —
|
|
19
|
+
* see `hoverable`/`focusable` for how this changes interactivity.
|
|
20
|
+
*/
|
|
21
|
+
component?: C;
|
|
22
|
+
/**
|
|
23
|
+
* Icon rendered inside the knob. Pass either a static `ReactNode`, or a function
|
|
24
|
+
* `(checked) => ReactNode` to render different content based on the toggle state.
|
|
25
|
+
* If omitted, the built-in animated cross/check glyph is used.
|
|
26
|
+
*/
|
|
27
|
+
icon?: ReactNode | ((checked: boolean) => ReactNode);
|
|
28
|
+
size?: ToggleSize;
|
|
29
|
+
/** Extra classes for the outer label/element. */
|
|
30
|
+
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* When `true` (default), renders a hidden native `<input type="checkbox" role="switch">`
|
|
33
|
+
* for form submission and accessibility. When `false`, falls back to ARIA roles
|
|
34
|
+
* (`role="switch"`, `aria-checked`, keyboard `Space`/`Enter` toggling).
|
|
35
|
+
*/
|
|
36
|
+
input?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Auto-computed when omitted: `true` if `component === 'label'`, otherwise `false`.
|
|
39
|
+
* Override explicitly for custom containers that should still show hover affordances.
|
|
40
|
+
*/
|
|
41
|
+
hoverable?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Auto-computed when omitted: `true` if `component === 'label'` OR `input` is `true`.
|
|
44
|
+
* Drives whether the focus ring (`FocusableLayer`) is rendered on the knob.
|
|
45
|
+
*/
|
|
46
|
+
focusable?: boolean;
|
|
47
|
+
/** Outline ring on the **track** (background surface). Default `true`. */
|
|
48
|
+
outline?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Surface level for the **track**. Default `'+1'` - one level deeper than the parent surface.
|
|
51
|
+
* Accepts the same absolute / relative (`"+1"`/`"-1"`) syntax as `Surface.level`.
|
|
52
|
+
*/
|
|
53
|
+
surfaceLevel?: string | number;
|
|
54
|
+
/** Surface variant for the **track**. Default `'solid'`. */
|
|
55
|
+
variant?: SurfaceVariant;
|
|
56
|
+
/** Outline ring on the **knob**. Default `true`. */
|
|
57
|
+
knobOutline?: boolean;
|
|
58
|
+
/** Surface variant for the **knob**. Default `'gradient'`. */
|
|
59
|
+
knobVariant?: SurfaceVariant;
|
|
60
|
+
/**
|
|
61
|
+
* Surface level for the **knob**. Default `'+2'` - two levels deeper than the parent surface,
|
|
62
|
+
* so the knob reads as a raised piece on top of the track.
|
|
63
|
+
*/
|
|
64
|
+
knobSurfaceLevel?: string | number;
|
|
65
|
+
}
|
|
66
|
+
export type ToggleProps<C extends ElementType = 'label'> = ToggleOwnProps<C> & Omit<ComponentPropsWithoutRef<C>, keyof ToggleOwnProps<C>>;
|
|
67
|
+
export declare function Toggle<C extends ElementType = 'label'>(props: ToggleProps<C>): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=Toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EAET,wBAAwB,EACzB,M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C7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,OAAO,IAAI,cAAc,CAAC,CAAC,CAAC,GAC1E,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7D,wBAAgB,MAAM,CAAC,CAAC,SAAS,WAAW,GAAG,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,2CAsK5E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, } from 'react';
|
|
3
|
+
import { useAccentColor } from '../hooks/use-accent-color';
|
|
4
|
+
import { cn } from '../shared/cn';
|
|
5
|
+
import { FocusableLayer } from './FocusableLayer';
|
|
6
|
+
import { Surface } from './Surface';
|
|
7
|
+
export function Toggle(props) {
|
|
8
|
+
const accentColor = useAccentColor();
|
|
9
|
+
const { checked = false, disabled = false, readOnly, onChange = () => { }, color = accentColor, component = 'label', icon, size = 'md', className, input = true, hoverable, focusable, outline = true, variant = 'solid', surfaceLevel = '+1', knobOutline = true, knobVariant = 'gradient', knobSurfaceLevel = '+2', } = props;
|
|
10
|
+
const elRef = useRef(null);
|
|
11
|
+
let hoverableComputed = hoverable;
|
|
12
|
+
let focusableComputed = focusable;
|
|
13
|
+
if (typeof hoverableComputed === 'undefined') {
|
|
14
|
+
hoverableComputed = component === 'label';
|
|
15
|
+
}
|
|
16
|
+
if (typeof focusableComputed === 'undefined') {
|
|
17
|
+
focusableComputed = component === 'label' || input;
|
|
18
|
+
}
|
|
19
|
+
const Component = component;
|
|
20
|
+
const ariaFallback = !input
|
|
21
|
+
? {
|
|
22
|
+
role: 'switch',
|
|
23
|
+
'aria-checked': checked,
|
|
24
|
+
'aria-disabled': disabled || undefined,
|
|
25
|
+
'aria-readonly': readOnly || undefined,
|
|
26
|
+
tabIndex: disabled ? -1 : 0,
|
|
27
|
+
onKeyDown: (e) => {
|
|
28
|
+
if (disabled || readOnly)
|
|
29
|
+
return;
|
|
30
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
onChange(!checked);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
onClick: () => {
|
|
36
|
+
if (disabled || readOnly)
|
|
37
|
+
return;
|
|
38
|
+
onChange(!checked);
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: {};
|
|
42
|
+
return (_jsxs(Component, { className: cn('toggle group/toggle relative flex shrink-0 rounded-full select-none', size === 'sm' && 'w-10 p-1', size === 'md' && 'w-12 p-1', className), onContextMenuCapture: (e) => e.preventDefault(), ref: elRef, ...ariaFallback, children: [input && (_jsx("input", { checked: checked, type: "checkbox", role: "switch", "aria-checked": checked, disabled: disabled || readOnly, readOnly: readOnly, className: "pointer-events-none absolute inset-0 z-10 opacity-0", onChange: (e) => onChange(!checked, e) })), _jsx(Surface, { level: surfaceLevel, className: "absolute inset-0 rounded-full", outline: outline, variant: variant, wrapContent: false }), _jsxs(Surface, { className: cn('z-10 rounded-full duration-300', size === 'sm' && 'size-4', size === 'md' && 'size-5', checked && size === 'sm' && `translate-x-4`, checked && size === 'md' && `translate-x-5`, disabled && 'opacity-50'), contentClassName: "flex items-center justify-center", variant: knobVariant, outline: knobOutline, level: knobSurfaceLevel, clickable: !disabled && !readOnly, hoverable: !disabled && !readOnly, beforeContent: _jsx(Surface, { className: cn('absolute inset-0 size-full shrink-0 rounded-full duration-200', !checked && 'scale-0', checked ? 'opacity-100' : 'opacity-0'), color: color, outline: true, level: '+0', variant: 'gradient-fill', clickable: !disabled && !readOnly, hoverable: !disabled && !readOnly }), children: [icon && typeof icon === 'function' && icon(checked), icon && typeof icon !== 'function' && icon, !icon && (_jsx("span", { className: cn('absolute inset-0', checked && `color-${color}`, size === 'sm' && 'scale-80'), children: _jsxs("span", { className: cn('absolute inset-0 duration-300 group-active/toggle:scale-90', checked && 'rotate-180', !checked && size === 'sm' && 'rotate-90'), children: [_jsx("span", { className: cn('absolute top-1/2 left-1/2 -mt-px -ml-2 h-0.5 w-4 rotate-45 rounded-full duration-300', checked ? 'bg-on-primary' : 'bg-on-surface-dark', checked
|
|
43
|
+
? 'translate-x-0.5 -translate-y-[1.75px] scale-x-40'
|
|
44
|
+
: 'scale-x-75') }), _jsx("span", { className: cn('absolute top-1/2 left-1/2 -mt-px -ml-2 h-0.5 w-4 -rotate-45 rounded-full duration-300', checked ? 'bg-on-primary' : 'bg-on-surface-dark', checked
|
|
45
|
+
? '-translate-x-[1.5px] scale-x-60 -rotate-60'
|
|
46
|
+
: 'scale-x-75') })] }) })), focusableComputed && !disabled && !readOnly && (_jsx(FocusableLayer, { className: "rounded-full", group: "toggle" }))] })] }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=Toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.js","sourceRoot":"","sources":["../../../src/components/Toggle.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,GAKP,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAwEpD,MAAM,UAAU,MAAM,CAAkC,KAAqB;IAC3E,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,MAAM,EACJ,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,EACnB,KAAK,GAAG,WAAW,EACnB,SAAS,GAAG,OAAO,EACnB,IAAI,EACJ,IA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IAAI,CAAC,QAAQ,IAAI,CAC9C,KAAC,cAAc,IAAC,SAAS,EAAC,cAAc,EAAC,KAAK,EAAC,QAAQ,GAAG,CAC3D,IACO,IACA,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
import { Color } from '../types';
|
|
3
|
+
import { SurfaceProps } from './Surface';
|
|
4
|
+
type OffsetValue = number | string;
|
|
5
|
+
export type TooltipPosition = 'top' | 'bottom';
|
|
6
|
+
interface TooltipOwnProps {
|
|
7
|
+
/** Controlled open state. Default `false`. Pair with `onOpenChange`. */
|
|
8
|
+
open?: boolean;
|
|
9
|
+
/** Fires whenever the open state should change. */
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
/** Tailwind z-index utility for the tooltip surface. Default `'z-50'`. */
|
|
12
|
+
zIndex?: string;
|
|
13
|
+
/** Extra classes applied to the tooltip root `Surface`. */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Extra classes applied to the inner content area. Default includes `px-2 py-1`. */
|
|
16
|
+
contentClassName?: string;
|
|
17
|
+
/** Ref to the element the tooltip should anchor against (CSS anchor positioning). */
|
|
18
|
+
anchorRef?: React.RefObject<HTMLElement | null>;
|
|
19
|
+
/** Portal target selector. Default `'#app, #__next, #root'`. */
|
|
20
|
+
root?: string;
|
|
21
|
+
/** Anchor side. Default `'top'`. */
|
|
22
|
+
position?: TooltipPosition;
|
|
23
|
+
/**
|
|
24
|
+
* Forwarded to the underlying `Surface` as `level`. Default depends on theme:
|
|
25
|
+
* `1` for light theme, `5` for dark theme - so the tooltip pops on top of any surface.
|
|
26
|
+
*/
|
|
27
|
+
surfaceLevel?: number;
|
|
28
|
+
/** Distance from anchor in pixels (number) or any CSS length (`'8px'`, `'50%'`). Default `4`. */
|
|
29
|
+
offset?: OffsetValue;
|
|
30
|
+
/** Accent color token. Sets the tooltip's `color-{name}` class. */
|
|
31
|
+
color?: Color;
|
|
32
|
+
/** Tooltip content. */
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
/** Fires when the open transition begins. */
|
|
35
|
+
onOpen?: () => void;
|
|
36
|
+
/** Fires after the open transition completes. */
|
|
37
|
+
onOpened?: () => void;
|
|
38
|
+
/** Fires when the close transition begins. */
|
|
39
|
+
onClose?: () => void;
|
|
40
|
+
/** Fires after the close transition completes. */
|
|
41
|
+
onClosed?: () => void;
|
|
42
|
+
/** Forwarded to the tooltip surface root. */
|
|
43
|
+
ref?: Ref<HTMLDivElement>;
|
|
44
|
+
}
|
|
45
|
+
export type TooltipProps = TooltipOwnProps & Omit<SurfaceProps, keyof TooltipOwnProps>;
|
|
46
|
+
export declare const Tooltip: ({ open, onOpenChange, ...rest }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAM1D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AAElD,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnC,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,CAAC;AAW/C,UAAU,eAAe;IACvB,wEAAwE;IACxE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mDAAmD;IACnD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qFAAqF;IACrF,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iGAAiG;IACjG,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,mEAAmE;IACnE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,uBAAuB;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,MAAM,MAAM,YAAY,GAAG,eAAe,GACxC,IAAI,CAAC,YAAY,EAAE,MAAM,eAAe,CAAC,CAAC;AAqI5C,eAAO,MAAM,OAAO,GAAI,iCAIrB,YAAY,4CAId,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { useModalUtils } from '../hooks/use-modal-utils';
|
|
5
|
+
import { useTheme } from '../hooks/use-theme';
|
|
6
|
+
import { cn } from '../shared/cn';
|
|
7
|
+
import { ModalController } from './ModalController';
|
|
8
|
+
import { Surface } from './Surface';
|
|
9
|
+
const resolveOffset = (value) => {
|
|
10
|
+
if (typeof value === 'number')
|
|
11
|
+
return `${value}px`;
|
|
12
|
+
if (value.endsWith('%')) {
|
|
13
|
+
const fraction = parseFloat(value) / 100;
|
|
14
|
+
return `calc(anchor-size(height) * ${fraction})`;
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
};
|
|
18
|
+
const TooltipRoot = (props) => {
|
|
19
|
+
const theme = useTheme();
|
|
20
|
+
const { phase = 'closed', onPhaseChange = () => { }, zIndex = 'z-50', className = '', contentClassName = '', anchorRef, root = '#app, #__next, #root', position = 'top', offset = 4, surfaceLevel = theme === 'light' ? 1 : 5, color, children, onOpen = () => { }, onOpened = () => { }, onClose = () => { }, onClosed = () => { }, ref, ...rest } = props;
|
|
21
|
+
const anchorNameRef = useRef('');
|
|
22
|
+
// Reuse existing anchor-name if target already has one (e.g. from Popover),
|
|
23
|
+
// otherwise generate a shared one
|
|
24
|
+
if (anchorRef?.current) {
|
|
25
|
+
const existing = anchorRef.current.style.getPropertyValue('anchor-name');
|
|
26
|
+
if (existing) {
|
|
27
|
+
anchorNameRef.current = existing;
|
|
28
|
+
}
|
|
29
|
+
else if (!anchorNameRef.current) {
|
|
30
|
+
anchorNameRef.current = `--anchor-${Math.random().toString(36).slice(2, 8)}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const anchorName = anchorNameRef.current;
|
|
34
|
+
const elRef = useRef(null);
|
|
35
|
+
const containerElRef = useRef(null);
|
|
36
|
+
const { opened, open, close } = useModalUtils({
|
|
37
|
+
phase,
|
|
38
|
+
onPhaseChange,
|
|
39
|
+
onOpen,
|
|
40
|
+
onOpened,
|
|
41
|
+
onClose,
|
|
42
|
+
onClosed,
|
|
43
|
+
transitionEndElRef: elRef,
|
|
44
|
+
closeOnEscape() {
|
|
45
|
+
if (containerElRef.current && containerElRef.current.nextElementSibling) {
|
|
46
|
+
const nextEl = containerElRef.current.nextElementSibling;
|
|
47
|
+
if (nextEl.matches('.popover, .dialog')) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
// Set anchor-name on target element if not already set
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const anchorEl = anchorRef?.current;
|
|
57
|
+
if (!anchorEl || !anchorName)
|
|
58
|
+
return;
|
|
59
|
+
if (!anchorEl.style.getPropertyValue('anchor-name')) {
|
|
60
|
+
anchorEl.style.setProperty('anchor-name', anchorName);
|
|
61
|
+
}
|
|
62
|
+
}, [anchorRef, anchorName]);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
requestAnimationFrame(() => {
|
|
65
|
+
open();
|
|
66
|
+
});
|
|
67
|
+
}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (containerElRef.current) {
|
|
70
|
+
containerElRef.current.__Tooltip = { close };
|
|
71
|
+
}
|
|
72
|
+
}, []);
|
|
73
|
+
const isTop = position === 'top';
|
|
74
|
+
const tooltipStyle = {
|
|
75
|
+
positionAnchor: anchorName,
|
|
76
|
+
positionArea: isTop ? 'top center' : 'bottom center',
|
|
77
|
+
positionTryFallbacks: 'flip-block',
|
|
78
|
+
...(offset
|
|
79
|
+
? { [isTop ? 'marginBottom' : 'marginTop']: resolveOffset(offset) }
|
|
80
|
+
: {}),
|
|
81
|
+
};
|
|
82
|
+
const content = (_jsx("div", { className: "tooltip pointer-events-none", ref: containerElRef, children: _jsx(Surface, { ref: (el) => {
|
|
83
|
+
elRef.current = el;
|
|
84
|
+
if (ref)
|
|
85
|
+
ref.current = el;
|
|
86
|
+
}, style: tooltipStyle, level: surfaceLevel, outline: true, variant: "gradient", contentClassName: cn('px-2 py-1', contentClassName), className: cn('pointer-events-none fixed max-h-[50vh] w-max max-w-50 overflow-auto rounded-xl text-xs leading-normal font-medium transition-[opacity,transform,scale]', color && `color-` + color, opened ? 'scale-100 opacity-100' : '', phase === 'opened' && 'duration-200', phase === 'closing' && 'duration-200', (phase === 'closing' || !opened) && 'scale-50 opacity-0', zIndex, isTop ? 'origin-bottom' : 'origin-top', className), ...rest, children: children }) }));
|
|
87
|
+
return root ? createPortal(content, document.querySelector(root)) : content;
|
|
88
|
+
};
|
|
89
|
+
export const Tooltip = ({ open = false, onOpenChange = () => { }, ...rest }) => (_jsx(ModalController, { open: open, onOpenChange: onOpenChange, children: _jsx(TooltipRoot, { ...rest }) }));
|
|
90
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,EAAc,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAgB,MAAM,WAAW,CAAC;AAMlD,MAAM,aAAa,GAAG,CAAC,KAAkB,EAAU,EAAE;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACnD,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;QACzC,OAAO,8BAA8B,QAAQ,GAAG,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAkDF,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IAC9C,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,EACJ,KAAK,GAAG,QAAQ,EAChB,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,EAC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AAC/E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EACtB,IAAI,GAAG,KAAK,EACZ,YAAY,GAAG,GAAG,EAAE,GAAE,CAAC,EACvB,GAAG,IAAI,EACM,EAAE,EAAE,CAAC,CAClB,KAAC,eAAe,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,YACrD,KAAC,WAAW,OAAK,IAAI,GAAI,GACT,CACnB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Color } from '../types';
|
|
2
|
+
export interface UIProviderProps {
|
|
3
|
+
/**
|
|
4
|
+
* Color scheme. Default `'dark'`. Read by `useTheme` and used to switch surface defaults
|
|
5
|
+
* (e.g. Popover/Dialog/Tooltip pick different `variant`, `outline`, and `surfaceLevel` per theme).
|
|
6
|
+
*/
|
|
7
|
+
theme?: 'dark' | 'light';
|
|
8
|
+
/**
|
|
9
|
+
* App-wide accent color. Default `'brand'`. Read by `useAccentColor` and used as the default
|
|
10
|
+
* `color` for interactive components (Button, Toggle, Checkbox, Radio, etc.).
|
|
11
|
+
*/
|
|
12
|
+
accentColor?: Color;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const UIProvider: (props: UIProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=UIProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UIProvider.d.ts","sourceRoot":"","sources":["../../../src/components/UIProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAOjC,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,4CAchD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DialogsPortal } from './DialogsPortal';
|
|
3
|
+
import { DialogsPortalProvider } from './DialogsPortalContext';
|
|
4
|
+
import { ThemeProvider } from './ThemeContext';
|
|
5
|
+
import { ToastsPortal } from './ToastsPortal';
|
|
6
|
+
import { ToastsPortalProvider } from './ToastsPortalContext';
|
|
7
|
+
export const UIProvider = (props) => {
|
|
8
|
+
const { theme = 'dark', accentColor = 'brand', children } = props;
|
|
9
|
+
return (_jsx(ThemeProvider, { theme: theme, accentColor: accentColor, children: _jsx(DialogsPortalProvider, { children: _jsxs(ToastsPortalProvider, { children: [children, _jsx(DialogsPortal, {}), _jsx(ToastsPortal, {})] }) }) }));
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=UIProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UIProvider.js","sourceRoot":"","sources":["../../../src/components/UIProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAgB7D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IACnD,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,WAAW,GAAG,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAElE,OAAO,CACL,KAAC,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,YACnD,KAAC,qBAAqB,cACpB,MAAC,oBAAoB,eAClB,QAAQ,EACT,KAAC,aAAa,KAAG,EACjB,KAAC,YAAY,KAAG,IACK,GACD,GACV,CACjB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Color } from '../types';
|
|
2
|
+
import { TooltipPosition, TooltipProps } from './Tooltip';
|
|
3
|
+
export interface WithTooltipProps {
|
|
4
|
+
/** Single React element to attach the tooltip to. The tooltip anchors to this child's DOM element. */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Tooltip content. When falsy, no tooltip is rendered or wired up - `WithTooltip` becomes a transparent wrapper. */
|
|
7
|
+
tooltip?: React.ReactNode;
|
|
8
|
+
/** Extra classes forwarded to the inner `Tooltip`'s root surface. */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Forwarded to `Tooltip.position`. */
|
|
11
|
+
position?: TooltipPosition;
|
|
12
|
+
/** Forwarded to `Tooltip.offset`. */
|
|
13
|
+
offset?: TooltipProps['offset'];
|
|
14
|
+
/** Accent color token, forwarded to `Tooltip.color`. */
|
|
15
|
+
color?: Color;
|
|
16
|
+
/**
|
|
17
|
+
* When `true` (default), delays showing the tooltip (500ms on touch, 1000ms on mouse) and
|
|
18
|
+
* uses a shared global timer so successive hovers feel snappier - same UX as system tooltips.
|
|
19
|
+
* When `false`, the tooltip appears immediately on pointer enter.
|
|
20
|
+
*/
|
|
21
|
+
timeout?: boolean;
|
|
22
|
+
/** Fires when the tooltip's open transition begins. */
|
|
23
|
+
onOpen?: () => void;
|
|
24
|
+
/** Fires after the open transition completes. */
|
|
25
|
+
onOpened?: () => void;
|
|
26
|
+
/** Fires when the tooltip's close transition begins. */
|
|
27
|
+
onClose?: () => void;
|
|
28
|
+
/** Fires after the close transition completes. */
|
|
29
|
+
onClosed?: () => void;
|
|
30
|
+
/** Composed onto the child element's `ref` (alongside the internal anchor ref). */
|
|
31
|
+
ref?: React.Ref<HTMLElement>;
|
|
32
|
+
/** Composed onto the child element's `onClick` (called before the child's own handler, if any). */
|
|
33
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare const WithTooltip: ({ children: originalChild, tooltip, className, position, offset, color, timeout, onOpen, onOpened, onClose, onClosed, ref: forwardedRef, onClick: forwardedOnClick, }: WithTooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
//# sourceMappingURL=WithTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithTooltip.d.ts","sourceRoot":"","sources":["../../../src/components/WithTooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAW,eAAe,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAiBnE,MAAM,WAAW,gBAAgB;IAC/B,sGAAsG;IACtG,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,qHAAqH;IACrH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,qCAAqC;IACrC,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,wDAAwD;IACxD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,mFAAmF;IACnF,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7B,mGAAmG;IACnG,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,WAAW,GAAI,uKAczB,gBAAgB,4CAwJlB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useDevice } from '../hooks/use-device';
|
|
4
|
+
import { Tooltip } from './Tooltip';
|
|
5
|
+
let tooltipGlobalTimeout = 0;
|
|
6
|
+
let tooltipGlobalTimeoutId = 0;
|
|
7
|
+
const resetGlobalTimeout = () => {
|
|
8
|
+
const device = useDevice();
|
|
9
|
+
tooltipGlobalTimeout = device.mobile ? 500 : 1000;
|
|
10
|
+
};
|
|
11
|
+
const getGlobalTimeout = () => {
|
|
12
|
+
if (tooltipGlobalTimeout === null) {
|
|
13
|
+
resetGlobalTimeout();
|
|
14
|
+
}
|
|
15
|
+
return tooltipGlobalTimeout;
|
|
16
|
+
};
|
|
17
|
+
export const WithTooltip = ({ children: originalChild, tooltip = '', className, position, offset, color, timeout = true, onOpen, onOpened, onClose, onClosed, ref: forwardedRef, onClick: forwardedOnClick, }) => {
|
|
18
|
+
const [modalState, setModalState] = useState(false);
|
|
19
|
+
const elRef = useRef(null);
|
|
20
|
+
const tooltipVisibleRef = useRef(false);
|
|
21
|
+
const preventContextMenuRef = useRef(false);
|
|
22
|
+
const pointerTimeoutRef = useRef(null);
|
|
23
|
+
const newRef = (el) => {
|
|
24
|
+
elRef.current = el;
|
|
25
|
+
const originalChildRef = originalChild?.props?.ref;
|
|
26
|
+
if (originalChildRef && typeof originalChildRef === 'function')
|
|
27
|
+
originalChildRef(el);
|
|
28
|
+
else if (originalChildRef &&
|
|
29
|
+
Object.keys(originalChildRef).includes('current')) {
|
|
30
|
+
originalChildRef.current = el;
|
|
31
|
+
}
|
|
32
|
+
if (typeof forwardedRef === 'function')
|
|
33
|
+
forwardedRef(el);
|
|
34
|
+
else if (forwardedRef &&
|
|
35
|
+
typeof forwardedRef === 'object' &&
|
|
36
|
+
'current' in forwardedRef) {
|
|
37
|
+
forwardedRef.current = el;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const showTooltip = () => {
|
|
41
|
+
if (!tooltip)
|
|
42
|
+
return;
|
|
43
|
+
clearTimeout(tooltipGlobalTimeoutId);
|
|
44
|
+
pointerTimeoutRef.current = setTimeout(() => {
|
|
45
|
+
tooltipVisibleRef.current = true;
|
|
46
|
+
setModalState(true);
|
|
47
|
+
if (timeout) {
|
|
48
|
+
tooltipGlobalTimeout = 0;
|
|
49
|
+
}
|
|
50
|
+
}, timeout ? getGlobalTimeout() : 0);
|
|
51
|
+
};
|
|
52
|
+
const hideTooltip = () => {
|
|
53
|
+
if (!tooltip)
|
|
54
|
+
return;
|
|
55
|
+
tooltipVisibleRef.current = false;
|
|
56
|
+
setModalState(false);
|
|
57
|
+
clearTimeout(pointerTimeoutRef.current);
|
|
58
|
+
if (timeout) {
|
|
59
|
+
tooltipGlobalTimeoutId = setTimeout(() => {
|
|
60
|
+
resetGlobalTimeout();
|
|
61
|
+
}, 1000);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const onContextMenu = (e) => {
|
|
65
|
+
if (!tooltip)
|
|
66
|
+
return;
|
|
67
|
+
if (preventContextMenuRef.current) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const onClick = (_e) => {
|
|
72
|
+
if (!tooltip)
|
|
73
|
+
return;
|
|
74
|
+
if (tooltipVisibleRef.current) {
|
|
75
|
+
hideTooltip();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const onPointer = (e) => {
|
|
79
|
+
if (!tooltip)
|
|
80
|
+
return;
|
|
81
|
+
const mouseEvents = ['pointerenter', 'pointerleave', 'pointercancel'];
|
|
82
|
+
const touchEvents = ['pointerdown', 'pointerup', 'pointercancel'];
|
|
83
|
+
if ((e.pointerType === 'mouse' && !mouseEvents.includes(e.type)) ||
|
|
84
|
+
(e.pointerType === 'touch' && !touchEvents.includes(e.type))) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (e.type === 'pointerenter') {
|
|
88
|
+
showTooltip();
|
|
89
|
+
}
|
|
90
|
+
if (e.type === 'pointerleave' || e.type === 'pointercancel') {
|
|
91
|
+
preventContextMenuRef.current = false;
|
|
92
|
+
hideTooltip();
|
|
93
|
+
}
|
|
94
|
+
if (e.type === 'pointerdown' && !tooltipVisibleRef.current) {
|
|
95
|
+
preventContextMenuRef.current = true;
|
|
96
|
+
showTooltip();
|
|
97
|
+
}
|
|
98
|
+
if (e.type === 'pointerup') {
|
|
99
|
+
preventContextMenuRef.current = false;
|
|
100
|
+
hideTooltip();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const el = elRef.current;
|
|
105
|
+
if (el) {
|
|
106
|
+
el.addEventListener('click', onClick);
|
|
107
|
+
el.addEventListener('contextmenu', onContextMenu);
|
|
108
|
+
el.addEventListener('pointerenter', onPointer);
|
|
109
|
+
el.addEventListener('pointerdown', onPointer);
|
|
110
|
+
document.addEventListener('pointerup', onPointer);
|
|
111
|
+
document.addEventListener('pointercancel', onPointer);
|
|
112
|
+
el.addEventListener('pointerleave', onPointer);
|
|
113
|
+
}
|
|
114
|
+
return () => {
|
|
115
|
+
if (el) {
|
|
116
|
+
el.removeEventListener('click', onClick);
|
|
117
|
+
el.removeEventListener('contextmenu', onContextMenu);
|
|
118
|
+
el.removeEventListener('pointerenter', onPointer);
|
|
119
|
+
el.removeEventListener('pointerdown', onPointer);
|
|
120
|
+
document.removeEventListener('pointerup', onPointer);
|
|
121
|
+
document.removeEventListener('pointercancel', onPointer);
|
|
122
|
+
el.removeEventListener('pointerleave', onPointer);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
const cloneProps = { ref: newRef };
|
|
127
|
+
if (forwardedOnClick) {
|
|
128
|
+
const originalOnClick = originalChild?.props?.onClick;
|
|
129
|
+
cloneProps.onClick = (e) => {
|
|
130
|
+
forwardedOnClick(e);
|
|
131
|
+
if (originalOnClick)
|
|
132
|
+
originalOnClick(e);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const newChild = cloneElement(originalChild, cloneProps);
|
|
136
|
+
return (_jsxs(_Fragment, { children: [newChild, tooltip && (_jsx(Tooltip, { open: modalState, onOpenChange: setModalState, anchorRef: elRef, className: className, position: position, offset: offset, color: color, onOpen: onOpen, onOpened: onOpened, onClose: onClose, onClosed: onClosed, children: tooltip }))] }));
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=WithTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithTooltip.js","sourceRoot":"","sources":["../../../src/components/WithTooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAiC,MAAM,WAAW,CAAC;AAEnE,IAAI,oBAAoB,GAAW,CAAC,CAAC;AACrC,IAAI,sBAAsB,GAAW,CAAC,CAAC;AAEvC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,IAAI,oBAAoB,KAAK,IAAI,EAAE,CAAC;QAClC,kBAAkB,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B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CAAC;IACD,MAAM,QAAQ,GAAG,YAAY,CAC3B,aAAwC,EACxC,UAAU,CACX,CAAC;IAEF,OAAO,CACL,8BACG,QAAQ,EACR,OAAO,IAAI,CACV,KAAC,OAAO,IACN,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,aAAa,EAC3B,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,YAEjB,OAAO,GACA,CACX,IACA,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/icons/CheckIcon.tsx"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,2CAqB7D"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function CheckIcon(props) {
|
|
3
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", ...props, children: _jsx("g", { fill: "currentColor", children: _jsx("polyline", { points: "2.75 9.25 6.75 14.25 15.25 3.75", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.5" }) }) }));
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=CheckIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckIcon.js","sourceRoot":"","sources":["../../../../src/components/icons/CheckIcon.tsx"],"names":[],"mappings":";AAAA,MAAM,UAAU,SAAS,CAAC,KAAoC;IAC5D,OAAO,CACL,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,KACf,KAAK,YAET,YAAG,IAAI,EAAC,cAAc,YACpB,mBACE,MAAM,EAAC,iCAAiC,EACxC,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,WAAW,EAAC,KAAK,GACP,GACV,GACA,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloseIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/icons/CloseIcon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,OAAO,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,4CAa7D,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const CloseIcon = (props) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", ...props, children: _jsxs("g", { fill: "currentColor", children: [_jsx("path", { d: "M4,14.75c-.192,0-.384-.073-.53-.22-.293-.293-.293-.768,0-1.061L13.47,3.47c.293-.293,.768-.293,1.061,0s.293,.768,0,1.061L4.53,14.53c-.146,.146-.338,.22-.53,.22Z" }), _jsx("path", { d: "M14,14.75c-.192,0-.384-.073-.53-.22L3.47,4.53c-.293-.293-.293-.768,0-1.061s.768-.293,1.061,0L14.53,13.47c.293,.293,.293,.768,0,1.061-.146,.146-.338,.22-.53,.22Z" })] }) }));
|
|
3
|
+
//# sourceMappingURL=CloseIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloseIcon.js","sourceRoot":"","sources":["../../../../src/components/icons/CloseIcon.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CACjE,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,KACf,KAAK,YAET,aAAG,IAAI,EAAC,cAAc,aACpB,eAAM,CAAC,EAAC,iKAAiK,GAAQ,EACjL,eAAM,CAAC,EAAC,kKAAkK,GAAQ,IAChL,GACA,CACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/icons/DropdownIcon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,4CAahE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const DropdownIcon = (props) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", ...props, children: _jsxs("g", { fill: "currentColor", children: [_jsx("path", { d: "M9.53,2.22c-.293-.293-.768-.293-1.061,0l-3.5,3.5c-.293,.293-.293,.768,0,1.061s.768,.293,1.061,0l2.97-2.97,2.97,2.97c.146,.146,.338,.22,.53,.22s.384-.073,.53-.22c.293-.293,.293-.768,0-1.061l-3.5-3.5Z" }), _jsx("path", { d: "M11.97,11.22l-2.97,2.97-2.97-2.97c-.293-.293-.768-.293-1.061,0s-.293,.768,0,1.061l3.5,3.5c.146,.146,.338,.22,.53,.22s.384-.073,.53-.22l3.5-3.5c.293-.293,.293-.768,0-1.061s-.768-.293-1.061,0Z" })] }) }));
|
|
3
|
+
//# sourceMappingURL=DropdownIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownIcon.js","sourceRoot":"","sources":["../../../../src/components/icons/DropdownIcon.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CACpE,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,KACf,KAAK,YAET,aAAG,IAAI,EAAC,cAAc,aACpB,eAAM,CAAC,EAAC,wMAAwM,GAAQ,EACxN,eAAM,CAAC,EAAC,gMAAgM,GAAQ,IAC9M,GACA,CACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/icons/SearchIcon.tsx"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,2CAuB9D"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function SearchIcon(props) {
|
|
3
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", ...props, children: _jsxs("g", { fill: "currentColor", children: [_jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M11.1083 11.1083C11.4012 10.8154 11.876 10.8154 12.1689 11.1083L16.2803 15.2197C16.5732 15.5126 16.5732 15.9874 16.2803 16.2803C15.9874 16.5732 15.5126 16.5732 15.2197 16.2803L11.1083 12.1689C10.8154 11.876 10.8154 11.4012 11.1083 11.1083Z" }), ' ', _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M1.5 7.75C1.5 4.29829 4.29829 1.5 7.75 1.5C11.2017 1.5 14 4.29829 14 7.75C14 11.2017 11.2017 14 7.75 14C4.29829 14 1.5 11.2017 1.5 7.75ZM7.75 3C5.12671 3 3 5.12671 3 7.75C3 10.3733 5.12671 12.5 7.75 12.5C10.3733 12.5 12.5 10.3733 12.5 7.75C12.5 5.12671 10.3733 3 7.75 3Z" })] }) }));
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=SearchIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchIcon.js","sourceRoot":"","sources":["../../../../src/components/icons/SearchIcon.tsx"],"names":[],"mappings":";AAAA,MAAM,UAAU,UAAU,CAAC,KAAoC;IAC7D,OAAO,CACL,cACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,KACf,KAAK,YAET,aAAG,IAAI,EAAC,cAAc,aACpB,eACE,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,iPAAiP,GAC7O,EAAC,GAAG,EACZ,eACE,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,gRAAgR,GAC5Q,IACN,GACA,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-accent-color.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-accent-color.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,gCAE1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-accent-color.js","sourceRoot":"","sources":["../../../src/hooks/use-accent-color.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC;AAC9C,CAAC,CAAC"}
|