@zvk/ui 0.1.3 → 0.1.5
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/alert-dialog/alert-dialog.d.ts +8 -5
- package/dist/components/alert-dialog/alert-dialog.js +21 -8
- package/dist/components/button/button.d.ts +3 -2
- package/dist/components/button/button.js +5 -1
- package/dist/components/calendar/calendar.d.ts +40 -5
- package/dist/components/calendar/calendar.js +17 -5
- package/dist/components/calendar/index.d.ts +1 -1
- package/dist/components/collapsible/collapsible.d.ts +3 -2
- package/dist/components/collapsible/collapsible.js +5 -1
- package/dist/components/command/command.d.ts +11 -4
- package/dist/components/command/command.js +27 -16
- package/dist/components/command/index.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +17 -6
- package/dist/components/context-menu/context-menu.js +139 -36
- package/dist/components/dialog/dialog.d.ts +6 -4
- package/dist/components/dialog/dialog.js +14 -4
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -7
- package/dist/components/dropdown-menu/dropdown-menu.js +127 -72
- package/dist/components/hover-card/hover-card.d.ts +8 -2
- package/dist/components/hover-card/hover-card.js +8 -5
- package/dist/components/index.d.ts +7 -7
- package/dist/components/index.js +1 -1
- package/dist/components/menubar/menubar.d.ts +24 -5
- package/dist/components/menubar/menubar.js +182 -33
- package/dist/components/popover/popover.d.ts +8 -3
- package/dist/components/popover/popover.js +14 -5
- package/dist/components/sheet/sheet.d.ts +6 -4
- package/dist/components/sheet/sheet.js +21 -8
- package/dist/components/toast/index.d.ts +2 -2
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toast/toast.d.ts +16 -2
- package/dist/components/toast/toast.js +44 -2
- package/dist/components/tooltip/tooltip.d.ts +8 -2
- package/dist/components/tooltip/tooltip.js +8 -5
- package/dist/internal/floating/placement-aliases.d.ts +7 -0
- package/dist/internal/floating/placement-aliases.js +13 -0
- package/dist/internal/slot/index.d.ts +2 -0
- package/dist/internal/slot/index.js +1 -0
- package/dist/internal/slot/slot.d.ts +6 -0
- package/dist/internal/slot/slot.js +53 -0
- package/dist/styles.css +21 -1
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Portal } from "../../internal/portal/index.js";
|
|
5
5
|
import { useFloatingPosition } from "../../internal/floating/index.js";
|
|
6
|
+
import { placementFromSideAlign } from "../../internal/floating/placement-aliases.js";
|
|
6
7
|
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
7
8
|
import { composeEventHandlers } from "../../utils/compose-event-handlers.js";
|
|
8
9
|
import { cn } from "../../utils/cn.js";
|
|
@@ -27,7 +28,7 @@ function composeRefs(...refs) {
|
|
|
27
28
|
if (typeof ref === "function") {
|
|
28
29
|
ref(node);
|
|
29
30
|
}
|
|
30
|
-
else if (ref !== undefined) {
|
|
31
|
+
else if (ref !== undefined && ref !== null) {
|
|
31
32
|
ref.current = node;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -59,7 +60,7 @@ function TooltipRoot({ children, defaultOpen = false, delay, disabled = false, o
|
|
|
59
60
|
const openTimeoutRef = React.useRef(null);
|
|
60
61
|
const { floatingRef, floatingStyle, placement: resolvedPlacement, referenceRef, updatePosition } = useFloatingPosition({
|
|
61
62
|
open,
|
|
62
|
-
placement,
|
|
63
|
+
placement: contentPositioning.placement ?? placement,
|
|
63
64
|
offset: contentPositioning.sideOffset,
|
|
64
65
|
collisionPadding: contentPositioning.collisionPadding,
|
|
65
66
|
flip: true,
|
|
@@ -137,7 +138,7 @@ function TooltipRoot({ children, defaultOpen = false, delay, disabled = false, o
|
|
|
137
138
|
]);
|
|
138
139
|
return (_jsx(TooltipRootContext.Provider, { value: contextValue, children: children }));
|
|
139
140
|
}
|
|
140
|
-
function TooltipTrigger({ children }) {
|
|
141
|
+
function TooltipTrigger({ children, asChild: _asChild = false }) {
|
|
141
142
|
const context = useTooltipRootContext("Tooltip.Trigger");
|
|
142
143
|
if (!React.isValidElement(children) || context.disabled) {
|
|
143
144
|
return children;
|
|
@@ -164,15 +165,17 @@ function TooltipTrigger({ children }) {
|
|
|
164
165
|
}, { checkDefaultPrevented: false })
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
|
-
function TooltipContent({ children, className, collisionPadding = defaultContentPositioning.collisionPadding, container, forceMount = false, ref, sideOffset = defaultContentPositioning.sideOffset, style, ...props }) {
|
|
168
|
+
function TooltipContent({ align, alignOffset: _alignOffset, children, className, collisionPadding = defaultContentPositioning.collisionPadding, container, forceMount = false, placement, ref, side, sideOffset = defaultContentPositioning.sideOffset, style, ...props }) {
|
|
168
169
|
const context = useTooltipRootContext("Tooltip.Content");
|
|
169
170
|
React.useEffect(() => {
|
|
171
|
+
const resolvedPlacement = side === undefined ? placement : placementFromSideAlign(side, align, placement ?? "bottom");
|
|
170
172
|
context.setContentPositioning({
|
|
173
|
+
...(resolvedPlacement === undefined ? {} : { placement: resolvedPlacement }),
|
|
171
174
|
sideOffset,
|
|
172
175
|
collisionPadding
|
|
173
176
|
});
|
|
174
177
|
return () => context.setContentPositioning(defaultContentPositioning);
|
|
175
|
-
}, [collisionPadding, context, sideOffset]);
|
|
178
|
+
}, [align, collisionPadding, context, placement, side, sideOffset]);
|
|
176
179
|
if (!context.open && !forceMount) {
|
|
177
180
|
return null;
|
|
178
181
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FloatingAlign, FloatingPlacement, FloatingSide } from "./floating-types.js";
|
|
2
|
+
export type { FloatingAlign, FloatingSide } from "./floating-types.js";
|
|
3
|
+
export declare function placementFromSideAlign(side: FloatingSide | undefined, align: FloatingAlign | undefined, fallback: FloatingPlacement): FloatingPlacement;
|
|
4
|
+
export declare function placementParts(placement: FloatingPlacement): {
|
|
5
|
+
side: FloatingSide;
|
|
6
|
+
align: FloatingAlign;
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function placementFromSideAlign(side, align, fallback) {
|
|
2
|
+
if (side === undefined) {
|
|
3
|
+
return fallback;
|
|
4
|
+
}
|
|
5
|
+
if (align === undefined || align === "center") {
|
|
6
|
+
return side;
|
|
7
|
+
}
|
|
8
|
+
return `${side}-${align}`;
|
|
9
|
+
}
|
|
10
|
+
export function placementParts(placement) {
|
|
11
|
+
const [side, align = "center"] = placement.split("-");
|
|
12
|
+
return { side, align };
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slot } from "./slot.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
function composeRefs(...refs) {
|
|
4
|
+
return (node) => {
|
|
5
|
+
for (const ref of refs) {
|
|
6
|
+
if (typeof ref === "function") {
|
|
7
|
+
ref(node);
|
|
8
|
+
}
|
|
9
|
+
else if (ref !== undefined && ref !== null) {
|
|
10
|
+
ref.current = node;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function isEventHandler(key, value) {
|
|
16
|
+
return /^on[A-Z]/.test(key) && typeof value === "function";
|
|
17
|
+
}
|
|
18
|
+
function mergeProps(slotProps, childProps) {
|
|
19
|
+
const merged = { ...slotProps, ...childProps };
|
|
20
|
+
for (const key of Object.keys(slotProps)) {
|
|
21
|
+
const slotValue = slotProps[key];
|
|
22
|
+
const childValue = childProps[key];
|
|
23
|
+
if (key === "className") {
|
|
24
|
+
merged[key] = cn(slotValue, childValue);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (key === "style" && typeof slotValue === "object" && typeof childValue === "object") {
|
|
28
|
+
merged[key] = { ...slotValue, ...childValue };
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (isEventHandler(key, slotValue) && isEventHandler(key, childValue)) {
|
|
32
|
+
merged[key] = (event) => {
|
|
33
|
+
childValue(event);
|
|
34
|
+
if (!event.defaultPrevented) {
|
|
35
|
+
slotValue(event);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return merged;
|
|
41
|
+
}
|
|
42
|
+
export function Slot({ children, ref, ...props }) {
|
|
43
|
+
if (!React.isValidElement(children)) {
|
|
44
|
+
throw new Error("Slot requires a single valid React element child.");
|
|
45
|
+
}
|
|
46
|
+
const child = children;
|
|
47
|
+
const childRef = child.props.ref;
|
|
48
|
+
const mergedProps = mergeProps(props, child.props);
|
|
49
|
+
return React.cloneElement(child, {
|
|
50
|
+
...mergedProps,
|
|
51
|
+
ref: composeRefs(childRef, ref)
|
|
52
|
+
});
|
|
53
|
+
}
|
package/dist/styles.css
CHANGED
|
@@ -3350,6 +3350,12 @@
|
|
|
3350
3350
|
margin: var(--liano-space-1) 0;
|
|
3351
3351
|
}
|
|
3352
3352
|
|
|
3353
|
+
.liano-command__shortcut {
|
|
3354
|
+
color: var(--liano-color-muted-foreground);
|
|
3355
|
+
font-size: var(--liano-font-size-xs);
|
|
3356
|
+
margin-inline-start: auto;
|
|
3357
|
+
}
|
|
3358
|
+
|
|
3353
3359
|
.liano-command-dialog {
|
|
3354
3360
|
font-family: var(--liano-font-family-sans);
|
|
3355
3361
|
padding: var(--liano-space-4);
|
|
@@ -3556,7 +3562,7 @@
|
|
|
3556
3562
|
padding: var(--liano-space-1) var(--liano-space-3);
|
|
3557
3563
|
}
|
|
3558
3564
|
|
|
3559
|
-
.liano-context-menu__checkbox-item {
|
|
3565
|
+
:where(.liano-context-menu__checkbox-item, .liano-context-menu__radio-item) {
|
|
3560
3566
|
justify-content: start;
|
|
3561
3567
|
}
|
|
3562
3568
|
|
|
@@ -3629,6 +3635,20 @@
|
|
|
3629
3635
|
text-align: start;
|
|
3630
3636
|
}
|
|
3631
3637
|
|
|
3638
|
+
:where(.liano-menubar__checkbox-item, .liano-menubar__radio-item) {
|
|
3639
|
+
justify-content: start;
|
|
3640
|
+
}
|
|
3641
|
+
|
|
3642
|
+
.liano-menubar__item-indicator {
|
|
3643
|
+
color: var(--liano-color-primary);
|
|
3644
|
+
inline-size: 1rem;
|
|
3645
|
+
text-align: center;
|
|
3646
|
+
}
|
|
3647
|
+
|
|
3648
|
+
.liano-menubar__item-label {
|
|
3649
|
+
min-width: 0;
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3632
3652
|
.liano-menubar__item:focus-visible {
|
|
3633
3653
|
background: var(--liano-color-muted);
|
|
3634
3654
|
outline: 0;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zvk/ui",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A polished, zero-runtime-dependency React component library for
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "A polished, zero-runtime-dependency React component library for ZvkUi applications.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE.md",
|