@milktop/react-ui 0.3.24 → 0.3.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/dist/date-range-filter/DateRangeFilter.d.ts +3 -1
- package/dist/date-range-filter/DateRangeFilter.js +3 -2
- package/dist/dialog/Dialog.js +2 -1
- package/dist/layer.d.ts +1 -0
- package/dist/layer.js +4 -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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ButtonProps } from '../button/Button.js';
|
|
1
2
|
import { type PopoverProps } from '../popover/Popover.js';
|
|
2
3
|
import { type Classes } from '../utils.js';
|
|
3
4
|
import '../theme.css';
|
|
@@ -14,6 +15,7 @@ export type DateRangeFilterProps = {
|
|
|
14
15
|
presets?: (DateRangeKey | DateRangePreset)[];
|
|
15
16
|
placeholder?: string | null;
|
|
16
17
|
placement?: PopoverProps['placement'];
|
|
18
|
+
size?: ButtonProps['size'];
|
|
17
19
|
locale?: string | null;
|
|
18
20
|
className?: string;
|
|
19
21
|
classes?: Classes<'trigger' | 'panel' | 'presets' | 'preset' | 'clear' | 'calendar'>;
|
|
@@ -37,6 +39,6 @@ export declare const dateRanges: {
|
|
|
37
39
|
thisYear: () => Date[];
|
|
38
40
|
lastYear: () => Date[];
|
|
39
41
|
};
|
|
40
|
-
declare function DateRangeFilterShortcut({ value, defaultValue, onValueChange, presets, placeholder, placement, locale: localeProp, className, classes, }: DateRangeFilterProps): import("react").JSX.Element;
|
|
42
|
+
declare function DateRangeFilterShortcut({ value, defaultValue, onValueChange, presets, placeholder, placement, size, locale: localeProp, className, classes, }: DateRangeFilterProps): import("react").JSX.Element;
|
|
41
43
|
export declare const DateRangeFilter: typeof DateRangeFilterShortcut;
|
|
42
44
|
export {};
|
|
@@ -12,6 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
* your own (below), mixed in any order
|
|
13
13
|
* - `placeholder`: the button's text with no dates ("All dates")
|
|
14
14
|
* - `placement`: where the panel opens ('bottom-end')
|
|
15
|
+
* - `size`: the button's, to sit beside other controls ('sm', 'md' or 'lg')
|
|
15
16
|
* - `locale`: for the dates on the button and the calendar (the
|
|
16
17
|
* LocaleProvider's, or 'en-GB')
|
|
17
18
|
*
|
|
@@ -91,7 +92,7 @@ function firstDayOf(locale) {
|
|
|
91
92
|
return 1;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
function DateRangeFilterShortcut({ value, defaultValue, onValueChange, presets = ['today', 'last7', 'last30', 'thisMonth', 'lastMonth', 'thisQuarter', 'lastQuarter', 'thisYear', 'lastYear'], placeholder = null, placement = 'bottom-end', locale: localeProp = null, className, classes, }) {
|
|
95
|
+
function DateRangeFilterShortcut({ value, defaultValue, onValueChange, presets = ['today', 'last7', 'last30', 'thisMonth', 'lastMonth', 'thisQuarter', 'lastQuarter', 'thisYear', 'lastYear'], placeholder = null, placement = 'bottom-end', size = 'md', locale: localeProp = null, className, classes, }) {
|
|
95
96
|
const t = useMessages();
|
|
96
97
|
const app = useLocale();
|
|
97
98
|
const locale = localeProp ?? app ?? 'en-GB';
|
|
@@ -130,6 +131,6 @@ function DateRangeFilterShortcut({ value, defaultValue, onValueChange, presets =
|
|
|
130
131
|
return (_jsx(Popover, { placement: placement, "data-date-range-filter": "", onOpenChange: (open) => { if (open) {
|
|
131
132
|
setPicking(dates);
|
|
132
133
|
setShown((n) => n + 1);
|
|
133
|
-
} }, trigger: _jsx(Button, { icon: "lucide:calendar", iconEnd: "lucide:chevron-down", className: cx(className, classes?.trigger), children: label }), children: _jsxs("div", { ...part('panel'), children: [_jsxs("div", { ...part('presets'), children: [items.map((item, i) => (_jsx(Button, { block: true, size: "sm", variant: "ghost", className: classes?.preset, "aria-pressed": matches(item), onClick: () => change(datesOf(item)), children: item.label }, i))), _jsx(Button, { block: true, size: "sm", icon: "lucide:x", className: classes?.clear, "data-clear": "", disabled: !dates.length, onClick: () => change([]), children: t.dateRangeFilter.clear })] }), _jsx(DatePicker, { inline: true, range: true, locale: locale, value: picking, onValueChange: picked, className: classes?.calendar }, shown)] }) }));
|
|
134
|
+
} }, trigger: _jsx(Button, { size: size, icon: "lucide:calendar", iconEnd: "lucide:chevron-down", className: cx(className, classes?.trigger), children: label }), children: _jsxs("div", { ...part('panel'), children: [_jsxs("div", { ...part('presets'), children: [items.map((item, i) => (_jsx(Button, { block: true, size: "sm", variant: "ghost", className: classes?.preset, "aria-pressed": matches(item), onClick: () => change(datesOf(item)), children: item.label }, i))), _jsx(Button, { block: true, size: "sm", icon: "lucide:x", className: classes?.clear, "data-clear": "", disabled: !dates.length, onClick: () => change([]), children: t.dateRangeFilter.clear })] }), _jsx(DatePicker, { inline: true, range: true, locale: locale, value: picking, onValueChange: picked, className: classes?.calendar }, shown)] }) }));
|
|
134
135
|
}
|
|
135
136
|
export const DateRangeFilter = DateRangeFilterShortcut;
|
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);
|
|
@@ -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,
|