@milktop/react-ui 0.3.20 → 0.3.22
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/popover/Popover.d.ts +0 -26
- package/dist/popover/Popover.js +28 -1
- package/dist/popover/popover.css +2 -0
- package/dist/tabs/tabs.css +3 -2
- package/package.json +1 -1
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A popover: a panel that opens from a trigger, for settings or details.
|
|
3
|
-
*
|
|
4
|
-
* <Popover heading="Appearance" closable placement="bottom-end"
|
|
5
|
-
* trigger={<Button icon="lucide:palette" aria-label="Appearance" />}>
|
|
6
|
-
* …content…
|
|
7
|
-
* </Popover>
|
|
8
|
-
*
|
|
9
|
-
* - `trigger`: the element that opens it (it gets the trigger's props, so a
|
|
10
|
-
* component must pass them on, as Button does)
|
|
11
|
-
* - `heading`, `description`: a header for the panel
|
|
12
|
-
* - `closable`: a close button in the corner
|
|
13
|
-
* - `arrow`: points the panel at its trigger
|
|
14
|
-
* - `modal`: traps focus and blocks the page behind it
|
|
15
|
-
* - `open`, `defaultOpen`; `onOpenChange`
|
|
16
|
-
* - `placement`: where it opens ('bottom')
|
|
17
|
-
*
|
|
18
|
-
* By hand, with Ark's parts:
|
|
19
|
-
*
|
|
20
|
-
* <Popover.Root>
|
|
21
|
-
* <Popover.Trigger asChild><Button>Filters</Button></Popover.Trigger>
|
|
22
|
-
* <Popover.Positioner>
|
|
23
|
-
* <Popover.Content><Popover.Title>Filters</Popover.Title>…<Popover.CloseTrigger>×</Popover.CloseTrigger></Popover.Content>
|
|
24
|
-
* </Popover.Positioner>
|
|
25
|
-
* </Popover.Root>
|
|
26
|
-
*/
|
|
27
1
|
import type { ReactElement, ReactNode } from 'react';
|
|
28
2
|
import { Popover as Ark, type PopoverOpenChangeDetails } from '@ark-ui/react/popover';
|
|
29
3
|
import '../icons.js';
|
package/dist/popover/Popover.js
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A popover: a panel that opens from a trigger, for settings or details.
|
|
4
|
+
*
|
|
5
|
+
* <Popover heading="Appearance" closable placement="bottom-end"
|
|
6
|
+
* trigger={<Button icon="lucide:palette" aria-label="Appearance" />}>
|
|
7
|
+
* …content…
|
|
8
|
+
* </Popover>
|
|
9
|
+
*
|
|
10
|
+
* - `trigger`: the element that opens it (it gets the trigger's props, so a
|
|
11
|
+
* component must pass them on, as Button does)
|
|
12
|
+
* - `heading`, `description`: a header for the panel
|
|
13
|
+
* - `closable`: a close button in the corner
|
|
14
|
+
* - `arrow`: points the panel at its trigger
|
|
15
|
+
* - `modal`: traps focus and blocks the page behind it
|
|
16
|
+
* - `open`, `defaultOpen`; `onOpenChange`
|
|
17
|
+
* - `placement`: where it opens ('bottom')
|
|
18
|
+
*
|
|
19
|
+
* By hand, with Ark's parts:
|
|
20
|
+
*
|
|
21
|
+
* <Popover.Root>
|
|
22
|
+
* <Popover.Trigger asChild><Button>Filters</Button></Popover.Trigger>
|
|
23
|
+
* <Popover.Positioner>
|
|
24
|
+
* <Popover.Content><Popover.Title>Filters</Popover.Title>…<Popover.CloseTrigger>×</Popover.CloseTrigger></Popover.Content>
|
|
25
|
+
* </Popover.Positioner>
|
|
26
|
+
* </Popover.Root>
|
|
27
|
+
*/
|
|
28
|
+
import { Portal } from '@ark-ui/react/portal';
|
|
2
29
|
import { Popover as Ark } from '@ark-ui/react/popover';
|
|
3
30
|
import '../icons.js';
|
|
4
31
|
import { cx, on, partOf, partsOf, withParts } from '../utils.js';
|
|
@@ -8,7 +35,7 @@ import './popover.css';
|
|
|
8
35
|
function PopoverShortcut({ trigger = null, heading = null, description = null, closable = false, arrow = false, modal = false, open, defaultOpen, onOpenChange, placement = 'bottom', className, classes, children, ...rest }) {
|
|
9
36
|
const t = useMessages();
|
|
10
37
|
const part = partsOf('popover', classes);
|
|
11
|
-
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(Ark.Positioner, { ...part('positioner'), children: _jsxs(Ark.Content, { ...rest, ...part('content'), 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" }) })] }) })] }));
|
|
38
|
+
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'), children: _jsxs(Ark.Content, { ...rest, ...part('content'), 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" }) })] }) }) })] }));
|
|
12
39
|
}
|
|
13
40
|
export const Popover = withParts(PopoverShortcut, {
|
|
14
41
|
Root: Ark.Root,
|
package/dist/popover/popover.css
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
background: var(--ui-surface); color: var(--ui-text); font-family: var(--ui-font); font-size: 14px;
|
|
8
8
|
border: 1px solid var(--ui-border); border-radius: calc(var(--ui-radius) + 2px); box-shadow: var(--ui-shadow);
|
|
9
9
|
--arrow-size: 12px; --arrow-background: var(--ui-surface); }
|
|
10
|
+
/* No taller than the room it has, scrolling inside; one with an arrow is left alone, as the scroll would clip it */
|
|
11
|
+
[data-scope=popover][data-part=content]:not(:has(> [data-part=arrow])) { max-height: var(--available-height); overflow-y: auto; }
|
|
10
12
|
[data-scope=popover][data-part=arrow-tip] { border-top: 1px solid var(--ui-border); border-left: 1px solid var(--ui-border); }
|
|
11
13
|
[data-scope=popover][data-part=header] { padding-right: 1.5rem; margin-bottom: 0.75rem;
|
|
12
14
|
&:last-child { margin-bottom: 0; } }
|
package/dist/tabs/tabs.css
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
@layer ui {
|
|
2
2
|
[data-scope=tabs][data-part=root] { display: block; width: 100%; color: var(--ui-text); font-family: var(--ui-font); }
|
|
3
3
|
[data-scope=tabs][data-part=list] { position: relative; display: flex; gap: 0.25rem; overflow-x: auto;
|
|
4
|
-
|
|
4
|
+
/* A shadow, not a border: the list scrolls sideways, and the underline over a border would add a pixel of vertical scroll. */
|
|
5
|
+
[data-variant=line] > & { box-shadow: inset 0 -1px var(--ui-border); }
|
|
5
6
|
/* Pills: a raised pill behind the selected tab, like Segmented. */
|
|
6
7
|
[data-variant=pills] > & { display: inline-flex; padding: 0.25rem; background: var(--ui-hover); border-radius: var(--ui-radius); } }
|
|
7
8
|
[data-scope=tabs][data-part=trigger] {
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
@keyframes ui-ping { from { scale: 1; opacity: 0.7; } 75%, to { scale: 2.2; opacity: 0; } }
|
|
50
51
|
@media (prefers-reduced-motion: reduce) { [data-scope=tabs][data-part=count]::after { animation: none; } }
|
|
51
52
|
[data-scope=tabs][data-part=indicator] { transition-property: var(--transition-property); transition-duration: 200ms;
|
|
52
|
-
[data-variant=line] & { position: absolute; bottom:
|
|
53
|
+
[data-variant=line] & { position: absolute; bottom: 0; left: var(--left); width: var(--width); height: 2px; background: var(--ui-accent); }
|
|
53
54
|
[data-variant=pills] & { position: absolute; z-index: 0; top: var(--top); left: var(--left); width: var(--width); height: var(--height);
|
|
54
55
|
background: var(--ui-surface); border-radius: calc(var(--ui-radius) - 2px); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); } }
|
|
55
56
|
[data-scope=tabs][data-part=panels] { padding-top: 1rem; }
|