@milktop/react-ui 0.3.25 → 0.3.27
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/dialog/Dialog.js +2 -1
- package/dist/layer.d.ts +1 -0
- package/dist/layer.js +4 -0
- package/dist/menu/Menu.js +5 -1
- package/dist/menu/menu.css +5 -0
- package/dist/popover/Popover.d.ts +1 -1
- package/dist/popover/Popover.js +4 -1
- package/dist/popover/popover.css +3 -0
- package/dist/sheet/Sheet.js +2 -1
- package/package.json +1 -1
package/dist/dialog/Dialog.js
CHANGED
|
@@ -55,6 +55,7 @@ import { Portal } from '@ark-ui/react/portal';
|
|
|
55
55
|
import '../icons.js';
|
|
56
56
|
import { cx, on, partOf, partsOf, withParts } from '../utils.js';
|
|
57
57
|
import { useMessages } from '../format/LocaleProvider.js';
|
|
58
|
+
import { InLayer } from '../layer.js';
|
|
58
59
|
import '../theme.css';
|
|
59
60
|
import './dialog.css';
|
|
60
61
|
function Header({ heading = null, description = null, children, ...rest }) {
|
|
@@ -74,7 +75,7 @@ function DialogShortcut({ open, defaultOpen, onOpenChange, onExitComplete, headi
|
|
|
74
75
|
const content = composed ? nodes.filter((node) => !triggers.includes(node)) : children;
|
|
75
76
|
// Left out when not given: Zag reads undefined as a value.
|
|
76
77
|
const state = { ...(open !== undefined && { open }), ...(defaultOpen !== undefined && { defaultOpen }) };
|
|
77
|
-
return (_jsxs(Ark.Root, { ...state, ...on('onOpenChange', onOpenChange, (details) => details.open), ...(onExitComplete && { onExitComplete }), role: alert ? 'alertdialog' : 'dialog', closeOnInteractOutside: !alert, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(Ark.Trigger, { asChild: true, children: trigger }), composed && triggers, _jsxs(Portal, { children: [_jsx(Ark.Backdrop, { ...part('backdrop') }), _jsx(Ark.Positioner, { ...part('positioner'), children: _jsxs(Ark.Content, { ...rest, ...part('content'), className: cx(className, classes?.content), "data-size": size, children: [closable && _jsx(Ark.CloseTrigger, { ...part('close-trigger'), "aria-label": t.common.close, children: _jsx("iconify-icon", { icon: "lucide:x" }) }), (heading || description) && (_jsxs("div", { ...part('header'), children: [heading && _jsx(Ark.Title, { ...part('title'), children: heading }), description && _jsx(Ark.Description, { ...part('description'), children: description })] })), composed ? content : children != null && _jsx("div", { ...part('body'), children: children }), footer && _jsx("div", { ...part('footer'), children: footer })] }) })] })] }));
|
|
78
|
+
return (_jsxs(Ark.Root, { ...state, ...on('onOpenChange', onOpenChange, (details) => details.open), ...(onExitComplete && { onExitComplete }), role: alert ? 'alertdialog' : 'dialog', closeOnInteractOutside: !alert, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(Ark.Trigger, { asChild: true, children: trigger }), composed && triggers, _jsx(InLayer.Provider, { value: true, children: _jsxs(Portal, { children: [_jsx(Ark.Backdrop, { ...part('backdrop') }), _jsx(Ark.Positioner, { ...part('positioner'), children: _jsxs(Ark.Content, { ...rest, ...part('content'), className: cx(className, classes?.content), "data-size": size, children: [closable && _jsx(Ark.CloseTrigger, { ...part('close-trigger'), "aria-label": t.common.close, children: _jsx("iconify-icon", { icon: "lucide:x" }) }), (heading || description) && (_jsxs("div", { ...part('header'), children: [heading && _jsx(Ark.Title, { ...part('title'), children: heading }), description && _jsx(Ark.Description, { ...part('description'), children: description })] })), composed ? content : children != null && _jsx("div", { ...part('body'), children: children }), footer && _jsx("div", { ...part('footer'), children: footer })] }) })] }) })] }));
|
|
78
79
|
}
|
|
79
80
|
export const Dialog = withParts(DialogShortcut, {
|
|
80
81
|
Root: Ark.Root,
|
package/dist/layer.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InLayer: import("react").Context<boolean>;
|
package/dist/layer.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
// True inside a Dialog or Sheet (z-index 100). A Popover there opens on top of it: its portal lands
|
|
3
|
+
// before the dialog's in the page (children mount first), so an equal z-index would leave it behind.
|
|
4
|
+
export const InLayer = createContext(false);
|
package/dist/menu/Menu.js
CHANGED
|
@@ -48,8 +48,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
48
48
|
*/
|
|
49
49
|
import { createContext, useContext, useId, useRef, useState } from 'react';
|
|
50
50
|
import { Menu as Ark, useMenuContext } from '@ark-ui/react/menu';
|
|
51
|
+
import { Portal } from '@ark-ui/react/portal';
|
|
51
52
|
import '../icons.js';
|
|
52
53
|
import { cx, partsOf, withParts } from '../utils.js';
|
|
54
|
+
import { InLayer } from '../layer.js';
|
|
53
55
|
import '../theme.css';
|
|
54
56
|
import './menu.css';
|
|
55
57
|
const MenuContext = createContext(null);
|
|
@@ -244,10 +246,12 @@ function MenuShortcut({ items = [], labelKey = 'label', valueKey = 'value', disa
|
|
|
244
246
|
},
|
|
245
247
|
};
|
|
246
248
|
const Trigger = context ? Ark.ContextTrigger : Ark.Trigger;
|
|
249
|
+
// Opened from a dialog or sheet, it shows on top of it (as Popover does)
|
|
250
|
+
const layered = useContext(InLayer) ? { 'data-layered': '' } : {};
|
|
247
251
|
return (_jsxs(Ark.Root, { closeOnSelect: !keepOpen, positioning: { placement, strategy: 'fixed', gutter: 4 }, ...(open !== undefined && { open }), ...(defaultOpen !== undefined && { defaultOpen }), ...(onOpenChange && { onOpenChange: (details) => onOpenChange(details.open) }),
|
|
248
252
|
// Enter on a link: Zag's own click doesn't bubble, so routers listening
|
|
249
253
|
// on the document would miss it.
|
|
250
|
-
navigate: (details) => details.node.click(), onSelect: (details) => shared.select(details.value), children: [trigger && _jsx(Trigger, { asChild: true, children: trigger }), _jsx(Ark.Positioner, { ...part('positioner'), children: _jsx(Ark.Content, { ...rest, ...part('content'), className: cx(className, classes?.content), children: _jsxs(MenuContext.Provider, { value: shared, children: [label && _jsx("div", { ...part('menu-label'), children: label }), _jsx(Entries, { items: items }), children] }) }) })] }));
|
|
254
|
+
navigate: (details) => details.node.click(), onSelect: (details) => shared.select(details.value), children: [trigger && _jsx(Trigger, { asChild: true, children: trigger }), _jsx(Portal, { children: _jsx(Ark.Positioner, { ...part('positioner'), ...layered, children: _jsx(Ark.Content, { ...rest, ...part('content'), ...layered, className: cx(className, classes?.content), children: _jsxs(MenuContext.Provider, { value: shared, children: [label && _jsx("div", { ...part('menu-label'), children: label }), _jsx(Entries, { items: items }), children] }) }) }) })] }));
|
|
251
255
|
}
|
|
252
256
|
export const Menu = withParts(MenuShortcut, {
|
|
253
257
|
Item, Separator, Group, Checkbox, RadioGroup, Radio, Submenu,
|
package/dist/menu/menu.css
CHANGED
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
/* The positioner carries the z-index itself. Zag sets it inline as
|
|
5
5
|
var(--z-index) but doesn't always fill in the variable, so set both. */
|
|
6
6
|
[data-scope=menu][data-part=positioner] { z-index: 50; --z-index: 50; }
|
|
7
|
+
/* Opened from a dialog or sheet (100): above it, below tooltips (110). Zag copies the content's
|
|
8
|
+
z-index inline when it opens, so the content carries it too. */
|
|
9
|
+
[data-scope=menu]:is([data-part=positioner], [data-part=content])[data-layered] { z-index: 105; --z-index: 105; }
|
|
7
10
|
[data-scope=menu][data-part=content] {
|
|
8
11
|
z-index: 50; font-weight: 400; min-width: 12rem; padding: 0.5rem 0.25rem; box-sizing: border-box; text-align: left; outline: none;
|
|
9
12
|
background: var(--ui-surface); color: var(--ui-text); font-family: var(--ui-font); font-size: 14px;
|
|
10
13
|
border: 1px solid var(--ui-border); border-radius: calc(var(--ui-radius) + 2px); box-shadow: var(--ui-shadow);
|
|
11
14
|
transform-origin: var(--transform-origin);
|
|
15
|
+
/* No taller than the room it has, scrolling inside */
|
|
16
|
+
max-height: var(--available-height); overflow-y: auto;
|
|
12
17
|
&[data-state=open] { animation: ui-menu-in 120ms ease-out; }
|
|
13
18
|
&[data-state=closed] { animation: ui-menu-out 100ms ease-in forwards; }
|
|
14
19
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
import { Popover as Ark, type PopoverOpenChangeDetails } from '@ark-ui/react/popover';
|
|
3
3
|
import '../icons.js';
|
|
4
4
|
import { type Classes } from '../utils.js';
|
package/dist/popover/Popover.js
CHANGED
|
@@ -26,16 +26,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
26
26
|
* </Popover.Root>
|
|
27
27
|
*/
|
|
28
28
|
import { Portal } from '@ark-ui/react/portal';
|
|
29
|
+
import { useContext } from 'react';
|
|
29
30
|
import { Popover as Ark } from '@ark-ui/react/popover';
|
|
30
31
|
import '../icons.js';
|
|
31
32
|
import { cx, on, partOf, partsOf, withParts } from '../utils.js';
|
|
32
33
|
import { useMessages } from '../format/LocaleProvider.js';
|
|
34
|
+
import { InLayer } from '../layer.js';
|
|
33
35
|
import '../theme.css';
|
|
34
36
|
import './popover.css';
|
|
35
37
|
function PopoverShortcut({ trigger = null, heading = null, description = null, closable = false, arrow = false, modal = false, open, defaultOpen, onOpenChange, placement = 'bottom', className, classes, children, ...rest }) {
|
|
36
38
|
const t = useMessages();
|
|
37
39
|
const part = partsOf('popover', classes);
|
|
38
|
-
|
|
40
|
+
const layered = useContext(InLayer) ? { 'data-layered': '' } : {};
|
|
41
|
+
return (_jsxs(Ark.Root, { modal: modal, positioning: { placement, strategy: 'fixed' }, ...(open !== undefined && { open }), ...(defaultOpen !== undefined && { defaultOpen }), ...on('onOpenChange', onOpenChange, (details) => details.open), children: [trigger && _jsx(Ark.Trigger, { asChild: true, children: trigger }), _jsx(Portal, { children: _jsx(Ark.Positioner, { ...part('positioner'), ...layered, children: _jsxs(Ark.Content, { ...rest, ...part('content'), ...layered, className: cx(className, classes?.content), children: [arrow && _jsx(Ark.Arrow, { ...part('arrow'), children: _jsx(Ark.ArrowTip, { ...part('arrow-tip') }) }), (heading || description) && (_jsxs("div", { ...part('header'), children: [heading && _jsx(Ark.Title, { ...part('title'), children: heading }), description && _jsx(Ark.Description, { ...part('description'), children: description })] })), children, closable && _jsx(Ark.CloseTrigger, { ...part('close-trigger'), "aria-label": t.common.close, children: _jsx("iconify-icon", { icon: "lucide:x" }) })] }) }) })] }));
|
|
39
42
|
}
|
|
40
43
|
export const Popover = withParts(PopoverShortcut, {
|
|
41
44
|
Root: Ark.Root,
|
package/dist/popover/popover.css
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
/* The positioner carries the z-index itself. Zag sets it inline as
|
|
3
3
|
var(--z-index) but doesn't always fill in the variable, so set both. */
|
|
4
4
|
[data-scope=popover][data-part=positioner] { z-index: 50; --z-index: 50; }
|
|
5
|
+
/* Opened from a dialog or sheet (100): above it, below tooltips (110). Zag copies the content's
|
|
6
|
+
z-index inline when it opens, so the content carries it too. */
|
|
7
|
+
[data-scope=popover]:is([data-part=positioner], [data-part=content])[data-layered] { z-index: 105; --z-index: 105; }
|
|
5
8
|
[data-scope=popover][data-part=content] { z-index: 50; position: relative; width: 18rem; max-width: calc(100vw - 32px);
|
|
6
9
|
padding: 1rem; box-sizing: border-box; outline: none; font-weight: 400;
|
|
7
10
|
background: var(--ui-surface); color: var(--ui-text); font-family: var(--ui-font); font-size: 14px;
|
package/dist/sheet/Sheet.js
CHANGED
|
@@ -30,6 +30,7 @@ import { Portal } from '@ark-ui/react/portal';
|
|
|
30
30
|
import '../icons.js';
|
|
31
31
|
import { cx, on, partOf, partsOf, withParts } from '../utils.js';
|
|
32
32
|
import { useMessages } from '../format/LocaleProvider.js';
|
|
33
|
+
import { InLayer } from '../layer.js';
|
|
33
34
|
import '../theme.css';
|
|
34
35
|
import './sheet.css';
|
|
35
36
|
// Ark's dialog stamps data-scope="dialog"; ours wins, so Dialog's CSS stays off.
|
|
@@ -53,7 +54,7 @@ function SheetShortcut({ open, defaultOpen, onOpenChange, side = 'right', size =
|
|
|
53
54
|
const composed = nodes.some((node) => isValidElement(node) && layout.includes(node.type));
|
|
54
55
|
const triggers = nodes.filter((node) => isValidElement(node) && node.type === Ark.Trigger);
|
|
55
56
|
const content = composed ? nodes.filter((node) => !triggers.includes(node)) : children;
|
|
56
|
-
return (_jsxs(Ark.Root, { ...(open !== undefined && { open }), ...(defaultOpen !== undefined && { defaultOpen }), ...on('onOpenChange', onOpenChange, (details) => details.open), role: alert ? 'alertdialog' : 'dialog', modal: modal, trapFocus: modal, preventScroll: modal, closeOnInteractOutside: modal && !alert, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(Ark.Trigger, { asChild: true, children: trigger }), composed && triggers, _jsxs(Portal, { children: [modal && _jsx(Ark.Backdrop, { ...part('backdrop') }), _jsx(Ark.Positioner, { ...part('positioner'), "data-side": side, children: _jsxs(Ark.Content, { ...rest, ...part('content'), className: cx(className, classes?.content), "data-side": side, "data-size": size, children: [closable && _jsx(Ark.CloseTrigger, { ...part('close-trigger'), "aria-label": t.common.close, children: _jsx("iconify-icon", { icon: "lucide:x" }) }), composed ? content : _jsxs(_Fragment, { children: [(heading || description) && (_jsxs("div", { ...part('header'), children: [heading && _jsx(Ark.Title, { ...part('title'), children: heading }), description && _jsx(Ark.Description, { ...part('description'), children: description })] })), _jsx("div", { ...part('body'), children: children }), footer && _jsx("div", { ...part('footer'), children: footer })] })] }) })] })] }));
|
|
57
|
+
return (_jsxs(Ark.Root, { ...(open !== undefined && { open }), ...(defaultOpen !== undefined && { defaultOpen }), ...on('onOpenChange', onOpenChange, (details) => details.open), role: alert ? 'alertdialog' : 'dialog', modal: modal, trapFocus: modal, preventScroll: modal, closeOnInteractOutside: modal && !alert, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(Ark.Trigger, { asChild: true, children: trigger }), composed && triggers, _jsx(InLayer.Provider, { value: true, children: _jsxs(Portal, { children: [modal && _jsx(Ark.Backdrop, { ...part('backdrop') }), _jsx(Ark.Positioner, { ...part('positioner'), "data-side": side, children: _jsxs(Ark.Content, { ...rest, ...part('content'), className: cx(className, classes?.content), "data-side": side, "data-size": size, children: [closable && _jsx(Ark.CloseTrigger, { ...part('close-trigger'), "aria-label": t.common.close, children: _jsx("iconify-icon", { icon: "lucide:x" }) }), composed ? content : _jsxs(_Fragment, { children: [(heading || description) && (_jsxs("div", { ...part('header'), children: [heading && _jsx(Ark.Title, { ...part('title'), children: heading }), description && _jsx(Ark.Description, { ...part('description'), children: description })] })), _jsx("div", { ...part('body'), children: children }), footer && _jsx("div", { ...part('footer'), children: footer })] })] }) })] }) })] }));
|
|
57
58
|
}
|
|
58
59
|
export const Sheet = withParts(SheetShortcut, {
|
|
59
60
|
Header, Body, Footer,
|