@phreshos/react-ui 0.1.25 → 0.1.26
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/README.md +74 -23
- package/dist/alert-dialog.d.ts +23 -0
- package/dist/alert-dialog.js +25 -0
- package/dist/button.d.ts +2 -1
- package/dist/button.js +2 -2
- package/dist/checkbox.d.ts +2 -1
- package/dist/checkbox.js +2 -2
- package/dist/color.js +1 -1
- package/dist/context-menu.d.ts +21 -0
- package/dist/context-menu.js +18 -0
- package/dist/control-surface.d.ts +6 -7
- package/dist/control-surface.js +4 -4
- package/dist/control.js +1 -1
- package/dist/dialog.d.ts +46 -0
- package/dist/dialog.js +91 -0
- package/dist/direction.d.ts +9 -0
- package/dist/direction.js +31 -0
- package/dist/dropdown-menu.d.ts +21 -0
- package/dist/dropdown-menu.js +19 -0
- package/dist/flex.js +1 -1
- package/dist/grid.js +1 -1
- package/dist/input.js +2 -2
- package/dist/main.d.ts +11 -3
- package/dist/main.js +9 -2
- package/dist/material-options.d.ts +2 -1
- package/dist/material-options.js +1 -1
- package/dist/menu.d.ts +35 -0
- package/dist/menu.js +85 -0
- package/dist/motion-style.d.ts +1 -0
- package/dist/motion-style.js +15 -7
- package/dist/overlay-placement.d.ts +4 -0
- package/dist/overlay-placement.js +6 -0
- package/dist/panel.d.ts +17 -8
- package/dist/panel.js +36 -21
- package/dist/popover.d.ts +30 -0
- package/dist/popover.js +46 -0
- package/dist/radio.d.ts +14 -7
- package/dist/radio.js +36 -11
- package/dist/radius.d.ts +2 -2
- package/dist/radius.js +3 -1
- package/dist/scroll-area.js +6 -2
- package/dist/select.d.ts +2 -1
- package/dist/select.js +21 -3
- package/dist/shadow-options.d.ts +25 -0
- package/dist/shadow-options.js +25 -0
- package/dist/slider.d.ts +13 -3
- package/dist/slider.js +62 -30
- package/dist/spacing.js +1 -1
- package/dist/surface-edge.d.ts +0 -1
- package/dist/surface-edge.js +46 -49
- package/dist/surface.d.ts +5 -1
- package/dist/surface.js +11 -6
- package/dist/switch.d.ts +2 -1
- package/dist/switch.js +4 -2
- package/dist/text-control.d.ts +2 -1
- package/dist/textarea.js +2 -2
- package/dist/toggle-indicator.d.ts +6 -4
- package/dist/toggle-indicator.js +3 -5
- package/dist/tooltip.d.ts +21 -0
- package/dist/tooltip.js +38 -0
- package/dist/ui-provider.d.ts +14 -0
- package/dist/ui-provider.js +18 -0
- package/package.json +1 -1
- package/dist/appearance-provider.d.ts +0 -10
- package/dist/appearance-provider.js +0 -13
package/dist/tooltip.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { Tooltip as AriaTooltip, TooltipTrigger as AriaTooltipTrigger } from "react-aria-components";
|
|
4
|
+
import { useAppearance } from "./ui-provider.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { controlFontSizes } from "./control.js";
|
|
7
|
+
import { overlayMotionClass, useOverlayTransition } from "./motion-style.js";
|
|
8
|
+
import { scale } from "./scale.js";
|
|
9
|
+
import { Surface } from "./surface.js";
|
|
10
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
11
|
+
import { resolveDirectionalPlacement } from "./overlay-placement.js";
|
|
12
|
+
export function TooltipRoot(properties) {
|
|
13
|
+
return _jsx(AriaTooltipTrigger, { ...properties });
|
|
14
|
+
}
|
|
15
|
+
export const TooltipTrigger = forwardRef(function TooltipTrigger(properties, ref) {
|
|
16
|
+
return _jsx(Button, { ...properties, ref: ref });
|
|
17
|
+
});
|
|
18
|
+
export const TooltipContent = forwardRef(function TooltipContent({ children, className, color, material, radius, shadow, style, offset, placement = "top", ...properties }, ref) {
|
|
19
|
+
const inset = scale(useAppearance().spacing, "small");
|
|
20
|
+
const transition = useOverlayTransition();
|
|
21
|
+
const direction = resolveDirection(properties.dir, useDirection());
|
|
22
|
+
return _jsx(AriaTooltip, { ...properties, ref: ref, dir: direction, offset: offset ?? inset, placement: resolveDirectionalPlacement(placement, direction), className: overlayMotionClass, style: transition, children: _jsx(Surface, { dir: direction, className: className, color: color, material: material, radius: radius, shadow: shadow, style: {
|
|
23
|
+
boxSizing: "border-box",
|
|
24
|
+
maxWidth: 280,
|
|
25
|
+
paddingBlock: inset,
|
|
26
|
+
paddingInline: inset * 1.5,
|
|
27
|
+
outline: "none",
|
|
28
|
+
fontSize: controlFontSizes.small,
|
|
29
|
+
lineHeight: 1.4,
|
|
30
|
+
...style
|
|
31
|
+
}, children: children }) });
|
|
32
|
+
});
|
|
33
|
+
/** A description shown from the focus and hover state of its trigger. */
|
|
34
|
+
export const Tooltip = Object.assign(TooltipRoot, {
|
|
35
|
+
Root: TooltipRoot,
|
|
36
|
+
Trigger: TooltipTrigger,
|
|
37
|
+
Content: TooltipContent
|
|
38
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type Appearance, type DesktopPreferences as Preferences } from "@phreshos/core";
|
|
3
|
+
import { type Direction } from "./direction.js";
|
|
4
|
+
export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
|
|
5
|
+
export { useDirection, useDocumentDirection } from "./direction.js";
|
|
6
|
+
/** Supplies the complete shared environment of a React UI subtree. */
|
|
7
|
+
export declare function UIProvider({ appearance, children, direction, preferences }: UIProviderProps): import("react").JSX.Element;
|
|
8
|
+
export interface UIProviderProps {
|
|
9
|
+
readonly appearance?: Appearance;
|
|
10
|
+
readonly children: ReactNode;
|
|
11
|
+
/** Establishes the concrete direction inherited by the provider subtree. */
|
|
12
|
+
readonly direction?: Direction;
|
|
13
|
+
readonly preferences?: Preferences;
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {} from "@phreshos/core";
|
|
3
|
+
import MotionStyle from "./motion-style.js";
|
|
4
|
+
import { AppearanceContext, PreferencesContext, useAppearance, usePreferences } from "./appearance-context.js";
|
|
5
|
+
import { DirectionContext, useDocumentDirection } from "./direction.js";
|
|
6
|
+
export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
|
|
7
|
+
export { useDirection, useDocumentDirection } from "./direction.js";
|
|
8
|
+
const directionBoundaryStyle = { display: "contents" };
|
|
9
|
+
/** Supplies the complete shared environment of a React UI subtree. */
|
|
10
|
+
export function UIProvider({ appearance, children, direction, preferences }) {
|
|
11
|
+
const inheritedAppearance = useAppearance();
|
|
12
|
+
const inheritedPreferences = usePreferences();
|
|
13
|
+
const documentDirection = useDocumentDirection();
|
|
14
|
+
const resolvedAppearance = appearance ?? inheritedAppearance;
|
|
15
|
+
const resolvedDirection = direction ?? documentDirection;
|
|
16
|
+
const resolvedPreferences = preferences ?? inheritedPreferences;
|
|
17
|
+
return _jsx(DirectionContext.Provider, { value: resolvedDirection, children: _jsx("div", { dir: resolvedDirection, style: directionBoundaryStyle, children: _jsx(AppearanceContext.Provider, { value: resolvedAppearance, children: _jsxs(PreferencesContext.Provider, { value: resolvedPreferences, children: [_jsx(MotionStyle, {}), children] }) }) }) });
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import { type Appearance, type DesktopPreferences as Preferences } from "@phreshos/core";
|
|
3
|
-
export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
|
|
4
|
-
/** Optionally overrides Appearance and complete visual Preferences for a React subtree. */
|
|
5
|
-
export declare function AppearanceProvider({ appearance, children, preferences }: AppearanceProviderProps): import("react").JSX.Element;
|
|
6
|
-
export interface AppearanceProviderProps {
|
|
7
|
-
readonly appearance?: Appearance;
|
|
8
|
-
readonly children: ReactNode;
|
|
9
|
-
readonly preferences?: Preferences;
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {} from "@phreshos/core";
|
|
3
|
-
import MotionStyle from "./motion-style.js";
|
|
4
|
-
import { AppearanceContext, PreferencesContext, useAppearance, usePreferences } from "./appearance-context.js";
|
|
5
|
-
export { useAppearance, useBrowserPreferences, usePreferences, useThemedValue } from "./appearance-context.js";
|
|
6
|
-
/** Optionally overrides Appearance and complete visual Preferences for a React subtree. */
|
|
7
|
-
export function AppearanceProvider({ appearance, children, preferences }) {
|
|
8
|
-
const inheritedAppearance = useAppearance();
|
|
9
|
-
const inheritedPreferences = usePreferences();
|
|
10
|
-
const resolvedAppearance = appearance ?? inheritedAppearance;
|
|
11
|
-
const resolvedPreferences = preferences ?? inheritedPreferences;
|
|
12
|
-
return _jsx(AppearanceContext.Provider, { value: resolvedAppearance, children: _jsxs(PreferencesContext.Provider, { value: resolvedPreferences, children: [_jsx(MotionStyle, {}), children] }) });
|
|
13
|
-
}
|