@milktop/react-ui 0.3.21 → 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.
@@ -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';
@@ -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,
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milktop/react-ui",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "React components on Ark UI (Zag state machines), with imba-ui's API and design",
5
5
  "license": "MIT",
6
6
  "author": "André Goldstein",