@manakind/ui-core 0.26.0 → 0.26.1

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 +1 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/tooltip/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAEtE,OAAO,eAAe,CAAC;AAEvB,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,OAAO,EAAE,SAAS,CAAC;IACnB,iEAAiE;IACjE,QAAQ,EAAE,YAAY,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;IAC/B,uEAAuE;IACvE,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,IAAoB,EACpB,SAAiB,GAClB,EAAE,YAAY,2CAuCd"}
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/tooltip/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAmC,MAAM,OAAO,CAAC;AAE3F,OAAO,eAAe,CAAC;AAEvB,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,OAAO,EAAE,SAAS,CAAC;IACnB,iEAAiE;IACjE,QAAQ,EAAE,YAAY,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;IAC/B,uEAAuE;IACvE,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,IAAoB,EACpB,SAAiB,GAClB,EAAE,YAAY,2CA0Dd"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Portal } from '@ark-ui/react/portal';
3
3
  import { Tooltip as ArkTooltip } from '@ark-ui/react/tooltip';
4
- import { useContext } from 'react';
4
+ import { useContext, useEffect, useState } from 'react';
5
5
  import { PortalContainerContext } from '../portal-container';
6
6
  import './tooltip.css';
7
7
  /**
@@ -36,6 +36,23 @@ export function Tooltip({ content, children, kind = 'description', placement = '
36
36
  * with keeps the lookup on the real element.
37
37
  */
38
38
  const triggerId = children.props.id;
39
- return (_jsxs(ArkTooltip.Root, { lazyMount: true, unmountOnExit: true, positioning: { placement, gutter: 6 }, ids: triggerId ? { trigger: triggerId } : undefined, children: [_jsx(ArkTooltip.Trigger, { asChild: true, "aria-describedby": triggerDescription, children: children }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkTooltip.Positioner, { children: _jsx(ArkTooltip.Content, { className: "ds-tooltip__content", "aria-hidden": kind === 'label' ? true : undefined, children: content }) }) })] }));
39
+ const [open, setOpen] = useState(false);
40
+ /*
41
+ * Escape hides the caption and goes on to whatever else it means: Zag's
42
+ * own Escape handling stops the key at the document, so a keyboard drag
43
+ * could not be cancelled and a dialog would not close while a caption
44
+ * showed.
45
+ */
46
+ useEffect(() => {
47
+ if (!open)
48
+ return;
49
+ const hide = (event) => {
50
+ if (event.key === 'Escape')
51
+ setOpen(false);
52
+ };
53
+ document.addEventListener('keydown', hide);
54
+ return () => document.removeEventListener('keydown', hide);
55
+ }, [open]);
56
+ return (_jsxs(ArkTooltip.Root, { lazyMount: true, unmountOnExit: true, positioning: { placement, gutter: 6 }, ids: triggerId ? { trigger: triggerId } : undefined, open: open, onOpenChange: (details) => setOpen(details.open), closeOnEscape: false, children: [_jsx(ArkTooltip.Trigger, { asChild: true, "aria-describedby": triggerDescription, children: children }), _jsx(Portal, { container: portalContainer, children: _jsx(ArkTooltip.Positioner, { children: _jsx(ArkTooltip.Content, { className: "ds-tooltip__content", "aria-hidden": kind === 'label' ? true : undefined, children: content }) }) })] }));
40
57
  }
41
58
  //# sourceMappingURL=tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../src/tooltip/tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAqC,UAAU,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,eAAe,CAAC;AAoBvB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,IAAI,GAAG,aAAa,EACpB,SAAS,GAAG,KAAK,GACJ;IACb,MAAM,eAAe,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAC3D;;;;OAIG;IACH,MAAM,kBAAkB,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7D;;;;;;OAMG;IACH,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IAEpC,OAAO,CACL,MAAC,UAAU,CAAC,IAAI,IACd,SAAS,QACT,aAAa,QACb,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,EACrC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,aAEnD,KAAC,UAAU,CAAC,OAAO,IAAC,OAAO,4BAAmB,kBAAkB,YAC7D,QAAQ,GACU,EACrB,KAAC,MAAM,IAAC,SAAS,EAAE,eAAe,YAChC,KAAC,UAAU,CAAC,UAAU,cACpB,KAAC,UAAU,CAAC,OAAO,IACjB,SAAS,EAAC,qBAAqB,iBAClB,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,YAE/C,OAAO,GACW,GACC,GACjB,IACO,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { Portal } from '@ark-ui/react/portal';\nimport { Tooltip as ArkTooltip } from '@ark-ui/react/tooltip';\nimport { type ReactElement, type ReactNode, useContext } from 'react';\nimport { PortalContainerContext } from '../portal-container';\nimport './tooltip.css';\n\nexport type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right';\n\nexport interface TooltipProps {\n /** The caption: a few words, never a control. */\n content: ReactNode;\n /** The element it captions. It keeps its own accessible name. */\n children: ReactElement<{ id?: string }>;\n /**\n * What the caption is to assistive tech. `description` (default) adds it\n * to the trigger's description while it shows. `label` says it repeats the\n * trigger's accessible name, as an icon-only button's caption does, so it\n * is left out and the name is announced once.\n */\n kind?: 'description' | 'label';\n /** Side of the trigger it opens on, flipping when there is no room. */\n placement?: TooltipPlacement;\n}\n\n/**\n * A caption that shows while the pointer rests on its trigger or the\n * keyboard focuses it, built on Ark UI's Tooltip. Esc and moving away hide\n * it; it never takes focus and holds nothing to click.\n *\n * ```tsx\n * <Tooltip content=\"Archive\">\n * <button type=\"button\" aria-label=\"Archive Run 10k\">…</button>\n * </Tooltip>\n * ```\n *\n * `IconButton` shows one with its label by default. Reach for it directly\n * for another control whose meaning its glyph alone does not say. Anything\n * a user must read to act belongs on the page, not in a tooltip: touch\n * screens never show one.\n */\nexport function Tooltip({\n content,\n children,\n kind = 'description',\n placement = 'top',\n}: TooltipProps) {\n const portalContainer = useContext(PortalContainerContext);\n /*\n * Zag points the trigger's description at the caption while it shows, and\n * only a defined value overrides it, so a label caption passes an empty\n * one. A description the trigger sets itself still wins.\n */\n const triggerDescription = kind === 'label' ? '' : undefined;\n /*\n * A trigger that is itself another part's asChild trigger (a Menu's, a\n * Dialog's close button, a Calendar arrow) takes that part's id, and the\n * child's props win the merge, so Zag would look for its own id and find\n * nothing to place the caption against. Naming the id the trigger ends up\n * with keeps the lookup on the real element.\n */\n const triggerId = children.props.id;\n\n return (\n <ArkTooltip.Root\n lazyMount\n unmountOnExit\n positioning={{ placement, gutter: 6 }}\n ids={triggerId ? { trigger: triggerId } : undefined}\n >\n <ArkTooltip.Trigger asChild aria-describedby={triggerDescription}>\n {children}\n </ArkTooltip.Trigger>\n <Portal container={portalContainer}>\n <ArkTooltip.Positioner>\n <ArkTooltip.Content\n className=\"ds-tooltip__content\"\n aria-hidden={kind === 'label' ? true : undefined}\n >\n {content}\n </ArkTooltip.Content>\n </ArkTooltip.Positioner>\n </Portal>\n </ArkTooltip.Root>\n );\n}\n"]}
1
+ {"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../src/tooltip/tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAqC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,eAAe,CAAC;AAoBvB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,IAAI,GAAG,aAAa,EACpB,SAAS,GAAG,KAAK,GACJ;IACb,MAAM,eAAe,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAC3D;;;;OAIG;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AC,qBAAqB,iBAClB,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,YAE/C,OAAO,GACW,GACC,GACjB,IACO,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { Portal } from '@ark-ui/react/portal';\nimport { Tooltip as ArkTooltip } from '@ark-ui/react/tooltip';\nimport { type ReactElement, type ReactNode, useContext, useEffect, useState } from 'react';\nimport { PortalContainerContext } from '../portal-container';\nimport './tooltip.css';\n\nexport type TooltipPlacement = 'top' | 'bottom' | 'left' | 'right';\n\nexport interface TooltipProps {\n /** The caption: a few words, never a control. */\n content: ReactNode;\n /** The element it captions. It keeps its own accessible name. */\n children: ReactElement<{ id?: string }>;\n /**\n * What the caption is to assistive tech. `description` (default) adds it\n * to the trigger's description while it shows. `label` says it repeats the\n * trigger's accessible name, as an icon-only button's caption does, so it\n * is left out and the name is announced once.\n */\n kind?: 'description' | 'label';\n /** Side of the trigger it opens on, flipping when there is no room. */\n placement?: TooltipPlacement;\n}\n\n/**\n * A caption that shows while the pointer rests on its trigger or the\n * keyboard focuses it, built on Ark UI's Tooltip. Esc and moving away hide\n * it; it never takes focus and holds nothing to click.\n *\n * ```tsx\n * <Tooltip content=\"Archive\">\n * <button type=\"button\" aria-label=\"Archive Run 10k\">…</button>\n * </Tooltip>\n * ```\n *\n * `IconButton` shows one with its label by default. Reach for it directly\n * for another control whose meaning its glyph alone does not say. Anything\n * a user must read to act belongs on the page, not in a tooltip: touch\n * screens never show one.\n */\nexport function Tooltip({\n content,\n children,\n kind = 'description',\n placement = 'top',\n}: TooltipProps) {\n const portalContainer = useContext(PortalContainerContext);\n /*\n * Zag points the trigger's description at the caption while it shows, and\n * only a defined value overrides it, so a label caption passes an empty\n * one. A description the trigger sets itself still wins.\n */\n const triggerDescription = kind === 'label' ? '' : undefined;\n /*\n * A trigger that is itself another part's asChild trigger (a Menu's, a\n * Dialog's close button, a Calendar arrow) takes that part's id, and the\n * child's props win the merge, so Zag would look for its own id and find\n * nothing to place the caption against. Naming the id the trigger ends up\n * with keeps the lookup on the real element.\n */\n const triggerId = children.props.id;\n const [open, setOpen] = useState(false);\n\n /*\n * Escape hides the caption and goes on to whatever else it means: Zag's\n * own Escape handling stops the key at the document, so a keyboard drag\n * could not be cancelled and a dialog would not close while a caption\n * showed.\n */\n useEffect(() => {\n if (!open) return;\n const hide = (event: KeyboardEvent) => {\n if (event.key === 'Escape') setOpen(false);\n };\n document.addEventListener('keydown', hide);\n return () => document.removeEventListener('keydown', hide);\n }, [open]);\n\n return (\n <ArkTooltip.Root\n lazyMount\n unmountOnExit\n positioning={{ placement, gutter: 6 }}\n ids={triggerId ? { trigger: triggerId } : undefined}\n open={open}\n onOpenChange={(details) => setOpen(details.open)}\n closeOnEscape={false}\n >\n <ArkTooltip.Trigger asChild aria-describedby={triggerDescription}>\n {children}\n </ArkTooltip.Trigger>\n <Portal container={portalContainer}>\n <ArkTooltip.Positioner>\n <ArkTooltip.Content\n className=\"ds-tooltip__content\"\n aria-hidden={kind === 'label' ? true : undefined}\n >\n {content}\n </ArkTooltip.Content>\n </ArkTooltip.Positioner>\n </Portal>\n </ArkTooltip.Root>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {