@choco-vanille/components 0.1.0-dev.1 → 0.1.0-dev.2
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/README.md +19 -5
- package/dist/components/{navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.cjs → _common/utils/get-label-slot-child/getLabelSlotChild.utils.cjs} +2 -2
- package/dist/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils.cjs.map +1 -0
- package/dist/components/{navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.js → _common/utils/get-label-slot-child/getLabelSlotChild.utils.js} +3 -3
- package/dist/components/_common/utils/get-label-slot-child/getLabelSlotChild.utils.js.map +1 -0
- package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.cjs +1 -1
- package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.cjs.map +1 -1
- package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.js +17 -11
- package/dist/components/actions/_common/button-base/utils/getButtonBaseProps.utils.js.map +1 -1
- package/dist/components/actions/button/Button.cjs +1 -1
- package/dist/components/actions/button/Button.cjs.map +1 -1
- package/dist/components/actions/button/Button.js +32 -28
- package/dist/components/actions/button/Button.js.map +1 -1
- package/dist/components/actions/button/utils/getButtonParts.utils.cjs +2 -0
- package/dist/components/actions/button/utils/getButtonParts.utils.cjs.map +1 -0
- package/dist/components/actions/button/utils/getButtonParts.utils.js +31 -0
- package/dist/components/actions/button/utils/getButtonParts.utils.js.map +1 -0
- package/dist/components/actions/icon-button/IconButton.cjs.map +1 -1
- package/dist/components/actions/icon-button/IconButton.js.map +1 -1
- package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.cjs +1 -1
- package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.cjs.map +1 -1
- package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.js +6 -6
- package/dist/components/navigation/_common/link-base/utils/getLinkBaseParts.utils.js.map +1 -1
- package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.cjs +1 -1
- package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.cjs.map +1 -1
- package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.css.cjs +1 -1
- package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.css.js +3 -3
- package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.js +12 -12
- package/dist/components/navigation/drawer/components/drawer-item/DrawerItem.js.map +1 -1
- package/dist/components/navigation/drawer/components/drawer-item/utils/getDrawerItemParts.utils.cjs.map +1 -1
- package/dist/components/navigation/drawer/components/drawer-item/utils/getDrawerItemParts.utils.js.map +1 -1
- package/dist/components/navigation/drawer/constants/index.cjs.map +1 -1
- package/dist/components/navigation/drawer/constants/index.js.map +1 -1
- package/dist/components/navigation/link/Link.cjs +1 -1
- package/dist/components/navigation/link/Link.cjs.map +1 -1
- package/dist/components/navigation/link/Link.js +9 -9
- package/dist/components/navigation/link/Link.js.map +1 -1
- package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.cjs +1 -1
- package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.cjs.map +1 -1
- package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.js +4 -4
- package/dist/components/navigation/tabs/components/tabs-tab/utils/getTabsTabParts.utils.js.map +1 -1
- package/dist/components/overlays/dropdown-menu/components/dropdown-menu-content/DropdownMenuContent.cjs +1 -1
- package/dist/components/overlays/dropdown-menu/components/dropdown-menu-content/DropdownMenuContent.cjs.map +1 -1
- package/dist/components/overlays/dropdown-menu/components/dropdown-menu-content/DropdownMenuContent.js +10 -10
- package/dist/components/overlays/tooltip/Tooltip.cjs +1 -1
- package/dist/components/overlays/tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/tooltip/Tooltip.js +9 -9
- package/dist/index.d.cts +69 -20
- package/dist/index.d.ts +69 -20
- package/dist/styles.css +1 -1
- package/package.json +5 -5
- package/dist/components/navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.cjs.map +0 -1
- package/dist/components/navigation/_common/link-base/utils/getLinkBaseSlotChild.utils.js.map +0 -1
|
@@ -7,30 +7,30 @@ import { dropdownMenuPartNames as a } from "../../constants/index.js";
|
|
|
7
7
|
import { DropdownMenuSubMenuContext as o } from "../../contexts/DropdownMenuSubMenuContext.js";
|
|
8
8
|
import { useAssertInsideDropdownMenu as s } from "../../hooks/useAssertInsideDropdownMenu.hook.js";
|
|
9
9
|
import { Box as c } from "@choco-vanille/primitives";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { use as l } from "react";
|
|
11
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
12
12
|
import { Menu as f } from "@base-ui/react/menu";
|
|
13
13
|
// src/components/overlays/dropdown-menu/components/dropdown-menu-content/DropdownMenuContent.tsx
|
|
14
14
|
var p = ({ children: p, ...m }) => {
|
|
15
15
|
s(a.content);
|
|
16
|
-
let h =
|
|
16
|
+
let h = l(o), { boxProps: g, hasArrow: _, popupProps: v, portalProps: y, positionerProps: b } = r({
|
|
17
17
|
...m,
|
|
18
18
|
layer: "dropdown",
|
|
19
19
|
transitionClassName: h ? i.subMenuEnter : n.fade
|
|
20
20
|
});
|
|
21
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ u(f.Portal, {
|
|
22
22
|
...y,
|
|
23
|
-
children: /* @__PURE__ */
|
|
23
|
+
children: /* @__PURE__ */ u(f.Positioner, {
|
|
24
24
|
...b,
|
|
25
|
-
children: /* @__PURE__ */
|
|
25
|
+
children: /* @__PURE__ */ d(f.Popup, {
|
|
26
26
|
...v,
|
|
27
|
-
render: /* @__PURE__ */
|
|
28
|
-
children: [_ ? /* @__PURE__ */
|
|
27
|
+
render: /* @__PURE__ */ u(c, { ...g }),
|
|
28
|
+
children: [_ ? /* @__PURE__ */ u(f.Arrow, { className: n.arrow }) : null, /* @__PURE__ */ u(e, {
|
|
29
29
|
className: n.scrollArea,
|
|
30
30
|
tabIndex: void 0,
|
|
31
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ u(c, {
|
|
32
32
|
padding: t.padding,
|
|
33
|
-
children: /* @__PURE__ */
|
|
33
|
+
children: /* @__PURE__ */ u(o, {
|
|
34
34
|
value: !1,
|
|
35
35
|
children: p
|
|
36
36
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../_common/utils/mergeClassNames.utils.cjs"),t=require("../_common/popup-base/constants/index.cjs"),n=require("../_common/popup-base/popupBase.css.cjs"),r=require("./constants/index.cjs"),i=require("./contexts/TooltipProviderContext.cjs"),a=require("./hooks/use-tooltip/useTooltip.hook.cjs"),o=require("./Tooltip.css.cjs"),s=require("./utils/getTooltipTriggerElement.utils.cjs");let c=require("react
|
|
1
|
+
const e=require("../../_common/utils/mergeClassNames.utils.cjs"),t=require("../_common/popup-base/constants/index.cjs"),n=require("../_common/popup-base/popupBase.css.cjs"),r=require("./constants/index.cjs"),i=require("./contexts/TooltipProviderContext.cjs"),a=require("./hooks/use-tooltip/useTooltip.hook.cjs"),o=require("./Tooltip.css.cjs"),s=require("./utils/getTooltipTriggerElement.utils.cjs");let c=require("react"),l=require("react/jsx-runtime"),u=require("@base-ui/react/tooltip");var d=({align:d=r.tooltipDefaults.align,alignOffset:f=r.tooltipDefaults.alignOffset,arrow:p=r.tooltipDefaults.arrow,children:m,className:h,closeDelay:g,collisionPadding:_,container:v,defaultOpen:y,delay:b,disabled:x,fontSize:S,fontWeight:C,interactive:w=r.tooltipDefaults.interactive,label:T,onOpenChange:E,open:D,side:O=r.tooltipDefaults.side,sideOffset:k=p?t.popupBaseArrowPlacement.sideOffset:r.tooltipDefaults.sideOffset,variant:A=r.tooltipDefaults.variant,...j})=>{let M=(0,c.use)(i.TooltipProviderContext),{contentId:N,handleOpenChange:P,isOpen:F}=a.useTooltip({defaultOpen:y,onOpenChange:E,open:D});return(0,l.jsxs)(u.Tooltip.Root,{defaultOpen:y,disabled:x,disableHoverablePopup:!w,onOpenChange:P,open:D,children:[(0,l.jsx)(u.Tooltip.Trigger,{closeDelay:g,delay:b??(M?void 0:r.tooltipDefaults.delay),render:s.getTooltipTriggerElement(m,F?N:void 0)}),(0,l.jsx)(u.Tooltip.Portal,{container:v,children:(0,l.jsx)(u.Tooltip.Positioner,{align:d,alignOffset:f,arrowPadding:t.popupBaseArrowPlacement.arrowPadding,className:n.popupBaseStyles.positioners.tooltip,collisionPadding:_,side:O,sideOffset:k,children:(0,l.jsxs)(u.Tooltip.Popup,{...j,className:e.mergeClassNames(o.tooltipStyles.root,o.tooltipStyles.variants[A],S!==void 0&&o.tooltipStyles.fontSizes[S],C!==void 0&&o.tooltipStyles.fontWeights[C],p&&A===`outlined`&&o.tooltipStyles.outlinedArrowed,n.popupBaseStyles.fade,h),id:N,role:`tooltip`,children:[p?(0,l.jsx)(u.Tooltip.Arrow,{className:e.mergeClassNames(n.popupBaseStyles.arrow,A===`contained`&&o.tooltipStyles.arrow)}):null,T]})})})]})};exports.default=d;
|
|
2
2
|
//# sourceMappingURL=Tooltip.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.cjs","names":["tooltipDefaults","popupBaseArrowPlacement","use","TooltipProviderContext","useTooltip","BaseTooltip","getTooltipTriggerElement","popupBaseStyles","mergeClassNames","tooltipStyles","require_mergeClassNames_utils","require_index","require_popupBase_css","require_index$1","require_TooltipProviderContext","require_useTooltip_hook","require_Tooltip_css","require_getTooltipTriggerElement_utils","react_jsx_runtime","react","_base_ui_react_tooltip","Tooltip","arrow","props","isInProvider","interactive","handleOpenChange","delay","children","isOpen","contentId","variant","fontSize","fontWeight","className","label"],"sources":["../../../../src/components/overlays/tooltip/Tooltip.tsx"],"sourcesContent":["import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';\nimport type { FC } from 'react';\nimport { use } from 'react';\n\nimport { mergeClassNames } from '@components/components/_common/utils/mergeClassNames.utils';\nimport { popupBaseArrowPlacement } from '@components/components/overlays/_common/popup-base/constants';\nimport { popupBaseStyles } from '@components/components/overlays/_common/popup-base/popupBase.css';\nimport { tooltipDefaults } from '@components/components/overlays/tooltip/constants';\nimport { TooltipProviderContext } from '@components/components/overlays/tooltip/contexts/TooltipProviderContext';\nimport { useTooltip } from '@components/components/overlays/tooltip/hooks/use-tooltip/useTooltip.hook';\nimport { tooltipStyles } from '@components/components/overlays/tooltip/Tooltip.css';\nimport type { TooltipProps } from '@components/components/overlays/tooltip/types';\nimport { getTooltipTriggerElement } from '@components/components/overlays/tooltip/utils/getTooltipTriggerElement.utils';\n\n/**\n * Wraps a control, the trigger, and shows a short text describing it while\n * it is hovered or focused, such as the action of an icon button; use a\n * `Popover` for content to interact with. It renders no element of its own:\n * its single child, which must render a native `button`, such as a `Button`\n * or an `IconButton`, receives the props of the trigger as Base UI merges\n * them: the child keeps its own value for any prop both give, its classes\n * come first, inline styles are merged, event handlers both run, the\n * child's first, and refs are composed. The tooltip only adds a\n * description: the trigger keeps its own name, which an icon alone needs,\n * such as the `aria-label` of an `IconButton`. A disabled `button` receives\n * no pointer events and no focus, so its tooltip never opens.\n *\n * Hovering the trigger opens the tooltip after `delay`, focusing it from\n * the keyboard at once; leaving it, after `closeDelay`, blurring it,\n * pressing it or Escape closes it. Within a `TooltipProvider`, the delays\n * the tooltip does not set are those of the provider, and moving from one\n * trigger of the group to another opens the next tooltip at once. While open, the tooltip describes the trigger through\n * `aria-describedby`, after the identifiers the child already holds. The\n * state is uncontrolled from `defaultOpen`, or controlled by `open` and\n * `onOpenChange`, whose details can `cancel()` the change; `disabled` keeps\n * it closed.\n *\n * The open tooltip is rendered in a portal at the end of the `body`, or in\n * `container`, unmounted once closed: a `div` with the `tooltip` role, in\n * small text on the inverse surface of the theme, or with `variant` set to\n * `outlined` on the elevated one, outlined and shadowed, fading in and out\n * unless reduced motion is preferred. It is placed against the trigger by\n * `side`, `align`, `alignOffset` and `sideOffset`, kept `collisionPadding`\n * away from the edges of the viewport, on the tooltip layer, and wraps\n * beyond `20rem` or the space left in the viewport; `arrow` points it to\n * the trigger, hidden from assistive technologies and kept off the rounded\n * corners. `fontSize` and `fontWeight` take the steps of the theme scales,\n * as those of a `Typography`.\n *\n * The pointer can move onto it without closing it, so it stays readable\n * while hovered, unless `interactive` is `false`; Escape dismisses it. Being in a portal, it takes the theme\n * of the document, not that of a nested `ThemeProvider`, unless `container`\n * lies inside it. Every other prop (attributes, events, `ref`) goes to the\n * popup, but its `id` and `role`, set by the tooltip; `className` comes\n * after the generated classes, in the `cv.components` cascade layers.\n *\n * @param props Trigger, text, open state, presentation, placement and\n * native props of the popup.\n * @param props.align Alignment along the side of the trigger; `center` when\n * absent.\n * @param props.alignOffset Shift along the side of the trigger, in pixels,\n * from the alignment; `0` when absent.\n * @param props.arrow Whether an arrow points to the trigger; `false` when\n * absent.\n * @param props.children The trigger: a single element rendering a native\n * `button`.\n * @param props.className Classes added after the generated ones.\n * @param props.closeDelay Time before the tooltip closes once the pointer\n * leaves the trigger, in milliseconds; `0` when absent, or that of the\n * enclosing `TooltipProvider`.\n * @param props.collisionPadding Space kept from the edges of the viewport,\n * in pixels, one number or one per side; `5` when absent, as in Base UI.\n * @param props.container Element, shadow root or ref to one the portal is\n * rendered into; the `body` when absent.\n * @param props.defaultOpen Initial open state of an uncontrolled tooltip;\n * `false` when absent.\n * @param props.delay Time the pointer hovers the trigger before the tooltip\n * opens, in milliseconds; `50` when absent, or that of the enclosing\n * `TooltipProvider`.\n * @param props.disabled Whether the tooltip stays closed; `false` when\n * absent.\n * @param props.fontSize Font size of the text, a step of the theme scale as\n * the `fontSize` of a `Typography`; `12` when absent.\n * @param props.fontWeight Font weight of the text, a step of the theme\n * scale as the `fontWeight` of a `Typography`; `regular` when absent.\n * @param props.interactive Whether the tooltip stays open while the pointer\n * moves onto it; `true` when absent.\n * @param props.label Text of the tooltip, which describes the trigger.\n * @param props.onOpenChange Called with the requested open state and the\n * details of the change.\n * @param props.open Controlled open state.\n * @param props.side Side of the trigger; `top` when absent.\n * @param props.sideOffset Distance from the trigger, in pixels; `4` when\n * absent, `10` with an arrow, whose tip then stands 4 pixels away.\n * @param props.variant Look of the tooltip: `contained`, the inverse\n * surface, or `outlined`, the elevated surface with an outline and a\n * shadow, as a `Popover.Content`; `contained` when absent.\n * @returns The trigger, and the tooltip in a portal while it is open.\n * @throws {Error} When the child is not a single element, or is a fragment.\n */\nconst Tooltip: FC<TooltipProps> = ({\n align = tooltipDefaults.align,\n alignOffset = tooltipDefaults.alignOffset,\n arrow = tooltipDefaults.arrow,\n children,\n className,\n closeDelay,\n collisionPadding,\n container,\n defaultOpen,\n delay,\n disabled,\n fontSize,\n fontWeight,\n interactive = tooltipDefaults.interactive,\n label,\n onOpenChange,\n open,\n side = tooltipDefaults.side,\n sideOffset = arrow\n ? popupBaseArrowPlacement.sideOffset\n : tooltipDefaults.sideOffset,\n variant = tooltipDefaults.variant,\n ...props\n}) => {\n const isInProvider = use(TooltipProviderContext);\n const { contentId, handleOpenChange, isOpen } = useTooltip({\n defaultOpen,\n onOpenChange,\n open,\n });\n\n return (\n <BaseTooltip.Root\n defaultOpen={defaultOpen}\n disabled={disabled}\n disableHoverablePopup={!interactive}\n onOpenChange={handleOpenChange}\n open={open}\n >\n <BaseTooltip.Trigger\n closeDelay={closeDelay}\n // Left to the provider within one, which applies its own.\n delay={\n delay ?? (isInProvider ? undefined : tooltipDefaults.delay)\n }\n render={getTooltipTriggerElement(\n children,\n isOpen ? contentId : undefined,\n )}\n />\n <BaseTooltip.Portal container={container}>\n <BaseTooltip.Positioner\n align={align}\n alignOffset={alignOffset}\n arrowPadding={popupBaseArrowPlacement.arrowPadding}\n className={popupBaseStyles.positioners.tooltip}\n collisionPadding={collisionPadding}\n side={side}\n sideOffset={sideOffset}\n >\n <BaseTooltip.Popup\n {...props}\n className={mergeClassNames(\n tooltipStyles.root,\n tooltipStyles.variants[variant],\n fontSize !== undefined &&\n tooltipStyles.fontSizes[fontSize],\n fontWeight !== undefined &&\n tooltipStyles.fontWeights[fontWeight],\n arrow &&\n variant === 'outlined' &&\n tooltipStyles.outlinedArrowed,\n popupBaseStyles.fade,\n className,\n )}\n id={contentId}\n role={'tooltip'}\n >\n {arrow ? (\n <BaseTooltip.Arrow\n className={mergeClassNames(\n popupBaseStyles.arrow,\n variant === 'contained' &&\n tooltipStyles.arrow,\n )}\n />\n ) : null}\n {label}\n </BaseTooltip.Popup>\n </BaseTooltip.Positioner>\n </BaseTooltip.Portal>\n </BaseTooltip.Root>\n );\n};\n\nexport default Tooltip;\n"],"mappings":"A,yeAoGA,IAAMqB,GAA6B,CAC/B,QAAQrB,EAAAA,gBAAgB,MACxB,cAAcA,EAAAA,gBAAgB,YAC9B,QAAQA,EAAAA,gBAAgB,MACxB,WACA,YACA,aACA,mBACA,YACA,cACA,QACA,WACA,WACA,aACA,cAAcA,EAAAA,gBAAgB,YAC9B,QACA,eACA,OACA,OAAOA,EAAAA,gBAAgB,KACvB,aAAasB,EACPrB,EAAAA,wBAAwB,WACxBD,EAAAA,gBAAgB,WACtB,UAAUA,EAAAA,gBAAgB,QAC1B,GAAGuB,KACD,CACF,IAAMC,GAAA,EAAetB,EAAAA,IAAAA,CAAIC,EAAAA,sBAAsB,EACzC,CAAE,YAAW,mBAAkB,UAAWC,EAAAA,WAAW,CACvD,cACA,eACA,MACJ,CAAC,EAED,OACI,EAAAc,EAAA,KAAA,CAACb,EAAAA,QAAY,KAAb,CACiB,cACH,WACV,sBAAuB,CAACoB,EACxB,aAAcC,EACR,OALV,SAAA,EAOI,EAAAR,EAAA,IAAA,CAACb,EAAAA,QAAY,QAAb,CACgB,aAEZ,MACIsB,IAAUH,EAAe,IAAA,GAAYxB,EAAAA,gBAAgB,OAEzD,OAAQM,EAAAA,yBACJsB,EACAC,EAASC,EAAY,IAAA,EACzB,CACH,CAAA,GACD,EAAAZ,EAAA,IAAA,CAACb,EAAAA,QAAY,OAAb,CAA+B,YAC3B,UAAA,EAAAa,EAAA,IAAA,CAACb,EAAAA,QAAY,WAAb,CACW,QACM,cACb,aAAcJ,EAAAA,wBAAwB,aACtC,UAAWM,EAAAA,gBAAgB,YAAY,QACrB,mBACZ,OACM,aAEZ,UAAA,EAAAW,EAAA,KAAA,CAACb,EAAAA,QAAY,MAAb,CACI,GAAIkB,EACJ,UAAWf,EAAAA,gBACPC,EAAAA,cAAc,KACdA,EAAAA,cAAc,SAASsB,GACvBC,IAAa,IAAA,IACTvB,EAAAA,cAAc,UAAUuB,GAC5BC,IAAe,IAAA,IACXxB,EAAAA,cAAc,YAAYwB,GAC9BX,GACIS,IAAY,YACZtB,EAAAA,cAAc,gBAClBF,EAAAA,gBAAgB,KAChB2B,CACJ,EACA,GAAIJ,EACJ,KAAM,UAhBV,SAAA,CAkBKR,GACG,EAAAJ,EAAA,IAAA,CAACb,EAAAA,QAAY,MAAb,CACI,UAAWG,EAAAA,gBACPD,EAAAA,gBAAgB,MAChBwB,IAAY,aACRtB,EAAAA,cAAc,KACtB,CACH,CAAA,EACD,KACH0B,CACc,C,EACC,CAAA,CACR,CAAA,CACN,C,EAE1B,E"}
|
|
1
|
+
{"version":3,"file":"Tooltip.cjs","names":["tooltipDefaults","popupBaseArrowPlacement","use","TooltipProviderContext","useTooltip","BaseTooltip","getTooltipTriggerElement","popupBaseStyles","mergeClassNames","tooltipStyles","require_mergeClassNames_utils","require_index","require_popupBase_css","require_index$1","require_TooltipProviderContext","require_useTooltip_hook","require_Tooltip_css","require_getTooltipTriggerElement_utils","react","react_jsx_runtime","_base_ui_react_tooltip","Tooltip","arrow","props","isInProvider","interactive","handleOpenChange","delay","children","isOpen","contentId","variant","fontSize","fontWeight","className","label"],"sources":["../../../../src/components/overlays/tooltip/Tooltip.tsx"],"sourcesContent":["import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';\nimport type { FC } from 'react';\nimport { use } from 'react';\n\nimport { mergeClassNames } from '@components/components/_common/utils/mergeClassNames.utils';\nimport { popupBaseArrowPlacement } from '@components/components/overlays/_common/popup-base/constants';\nimport { popupBaseStyles } from '@components/components/overlays/_common/popup-base/popupBase.css';\nimport { tooltipDefaults } from '@components/components/overlays/tooltip/constants';\nimport { TooltipProviderContext } from '@components/components/overlays/tooltip/contexts/TooltipProviderContext';\nimport { useTooltip } from '@components/components/overlays/tooltip/hooks/use-tooltip/useTooltip.hook';\nimport { tooltipStyles } from '@components/components/overlays/tooltip/Tooltip.css';\nimport type { TooltipProps } from '@components/components/overlays/tooltip/types';\nimport { getTooltipTriggerElement } from '@components/components/overlays/tooltip/utils/getTooltipTriggerElement.utils';\n\n/**\n * Wraps a control, the trigger, and shows a short text describing it while\n * it is hovered or focused, such as the action of an icon button; use a\n * `Popover` for content to interact with. It renders no element of its own:\n * its single child, which must render a native `button`, such as a `Button`\n * or an `IconButton`, receives the props of the trigger as Base UI merges\n * them: the child keeps its own value for any prop both give, its classes\n * come first, inline styles are merged, event handlers both run, the\n * child's first, and refs are composed. The tooltip only adds a\n * description: the trigger keeps its own name, which an icon alone needs,\n * such as the `aria-label` of an `IconButton`. A disabled `button` receives\n * no pointer events and no focus, so its tooltip never opens.\n *\n * Hovering the trigger opens the tooltip after `delay`, focusing it from\n * the keyboard at once; leaving it, after `closeDelay`, blurring it,\n * pressing it or Escape closes it. Within a `TooltipProvider`, the delays\n * the tooltip does not set are those of the provider, and moving from one\n * trigger of the group to another opens the next tooltip at once. While open, the tooltip describes the trigger through\n * `aria-describedby`, after the identifiers the child already holds. The\n * state is uncontrolled from `defaultOpen`, or controlled by `open` and\n * `onOpenChange`, whose details can `cancel()` the change; `disabled` keeps\n * it closed.\n *\n * The open tooltip is rendered in a portal at the end of the `body`, or in\n * `container`, unmounted once closed: a `div` with the `tooltip` role, in\n * small text on the inverse surface of the theme, or with `variant` set to\n * `outlined` on the elevated one, outlined and shadowed, fading in and out\n * unless reduced motion is preferred. It is placed against the trigger by\n * `side`, `align`, `alignOffset` and `sideOffset`, kept `collisionPadding`\n * away from the edges of the viewport, on the tooltip layer, and wraps\n * beyond `20rem` or the space left in the viewport; `arrow` points it to\n * the trigger, hidden from assistive technologies and kept off the rounded\n * corners. `fontSize` and `fontWeight` take the steps of the theme scales,\n * as those of a `Typography`.\n *\n * The pointer can move onto it without closing it, so it stays readable\n * while hovered, unless `interactive` is `false`; Escape dismisses it. Being in a portal, it takes the theme\n * of the document, not that of a nested `ThemeProvider`, unless `container`\n * lies inside it. Every other prop (attributes, events, `ref`) goes to the\n * popup, but its `id` and `role`, set by the tooltip; `className` comes\n * after the generated classes, in the `cv.components` cascade layers.\n *\n * @param props Trigger, text, open state, presentation, placement and\n * native props of the popup.\n * @param props.align Alignment along the side of the trigger; `center` when\n * absent.\n * @param props.alignOffset Shift along the side of the trigger, in pixels,\n * from the alignment; `0` when absent.\n * @param props.arrow Whether an arrow points to the trigger; `false` when\n * absent.\n * @param props.children The trigger: a single element rendering a native\n * `button`.\n * @param props.className Classes added after the generated ones.\n * @param props.closeDelay Time before the tooltip closes once the pointer\n * leaves the trigger, in milliseconds; `0` when absent, or that of the\n * enclosing `TooltipProvider`.\n * @param props.collisionPadding Space kept from the edges of the viewport,\n * in pixels, one number or one per side; `5` when absent, as in Base UI.\n * @param props.container Element, shadow root or ref to one the portal is\n * rendered into; the `body` when absent.\n * @param props.defaultOpen Initial open state of an uncontrolled tooltip;\n * `false` when absent.\n * @param props.delay Time the pointer hovers the trigger before the tooltip\n * opens, in milliseconds; `50` when absent, or that of the enclosing\n * `TooltipProvider`.\n * @param props.disabled Whether the tooltip stays closed; `false` when\n * absent.\n * @param props.fontSize Font size of the text, a step of the theme scale as\n * the `fontSize` of a `Typography`; `12` when absent.\n * @param props.fontWeight Font weight of the text, a step of the theme\n * scale as the `fontWeight` of a `Typography`; `regular` when absent.\n * @param props.interactive Whether the tooltip stays open while the pointer\n * moves onto it; `true` when absent.\n * @param props.label Text of the tooltip, which describes the trigger.\n * @param props.onOpenChange Called with the requested open state and the\n * details of the change.\n * @param props.open Controlled open state.\n * @param props.side Side of the trigger; `top` when absent.\n * @param props.sideOffset Distance from the trigger, in pixels; `4` when\n * absent, `10` with an arrow, whose tip then stands 4 pixels away.\n * @param props.variant Look of the tooltip: `contained`, the inverse\n * surface, or `outlined`, the elevated surface with an outline and a\n * shadow, as a `Popover.Content`; `contained` when absent.\n * @returns The trigger, and the tooltip in a portal while it is open.\n * @throws {Error} When the child is not a single element, or is a fragment.\n */\nconst Tooltip: FC<TooltipProps> = ({\n align = tooltipDefaults.align,\n alignOffset = tooltipDefaults.alignOffset,\n arrow = tooltipDefaults.arrow,\n children,\n className,\n closeDelay,\n collisionPadding,\n container,\n defaultOpen,\n delay,\n disabled,\n fontSize,\n fontWeight,\n interactive = tooltipDefaults.interactive,\n label,\n onOpenChange,\n open,\n side = tooltipDefaults.side,\n sideOffset = arrow\n ? popupBaseArrowPlacement.sideOffset\n : tooltipDefaults.sideOffset,\n variant = tooltipDefaults.variant,\n ...props\n}) => {\n const isInProvider = use(TooltipProviderContext);\n const { contentId, handleOpenChange, isOpen } = useTooltip({\n defaultOpen,\n onOpenChange,\n open,\n });\n\n return (\n <BaseTooltip.Root\n defaultOpen={defaultOpen}\n disabled={disabled}\n disableHoverablePopup={!interactive}\n onOpenChange={handleOpenChange}\n open={open}\n >\n <BaseTooltip.Trigger\n closeDelay={closeDelay}\n // Left to the provider within one, which applies its own.\n delay={\n delay ?? (isInProvider ? undefined : tooltipDefaults.delay)\n }\n render={getTooltipTriggerElement(\n children,\n isOpen ? contentId : undefined,\n )}\n />\n <BaseTooltip.Portal container={container}>\n <BaseTooltip.Positioner\n align={align}\n alignOffset={alignOffset}\n arrowPadding={popupBaseArrowPlacement.arrowPadding}\n className={popupBaseStyles.positioners.tooltip}\n collisionPadding={collisionPadding}\n side={side}\n sideOffset={sideOffset}\n >\n <BaseTooltip.Popup\n {...props}\n className={mergeClassNames(\n tooltipStyles.root,\n tooltipStyles.variants[variant],\n fontSize !== undefined &&\n tooltipStyles.fontSizes[fontSize],\n fontWeight !== undefined &&\n tooltipStyles.fontWeights[fontWeight],\n arrow &&\n variant === 'outlined' &&\n tooltipStyles.outlinedArrowed,\n popupBaseStyles.fade,\n className,\n )}\n id={contentId}\n role={'tooltip'}\n >\n {arrow ? (\n <BaseTooltip.Arrow\n className={mergeClassNames(\n popupBaseStyles.arrow,\n variant === 'contained' &&\n tooltipStyles.arrow,\n )}\n />\n ) : null}\n {label}\n </BaseTooltip.Popup>\n </BaseTooltip.Positioner>\n </BaseTooltip.Portal>\n </BaseTooltip.Root>\n );\n};\n\nexport default Tooltip;\n"],"mappings":"A,yeAoGA,IAAMqB,GAA6B,CAC/B,QAAQrB,EAAAA,gBAAgB,MACxB,cAAcA,EAAAA,gBAAgB,YAC9B,QAAQA,EAAAA,gBAAgB,MACxB,WACA,YACA,aACA,mBACA,YACA,cACA,QACA,WACA,WACA,aACA,cAAcA,EAAAA,gBAAgB,YAC9B,QACA,eACA,OACA,OAAOA,EAAAA,gBAAgB,KACvB,aAAasB,EACPrB,EAAAA,wBAAwB,WACxBD,EAAAA,gBAAgB,WACtB,UAAUA,EAAAA,gBAAgB,QAC1B,GAAGuB,KACD,CACF,IAAMC,GAAA,EAAetB,EAAAA,IAAAA,CAAIC,EAAAA,sBAAsB,EACzC,CAAE,YAAW,mBAAkB,UAAWC,EAAAA,WAAW,CACvD,cACA,eACA,MACJ,CAAC,EAED,OACI,EAAAe,EAAA,KAAA,CAACd,EAAAA,QAAY,KAAb,CACiB,cACH,WACV,sBAAuB,CAACoB,EACxB,aAAcC,EACR,OALV,SAAA,EAOI,EAAAP,EAAA,IAAA,CAACd,EAAAA,QAAY,QAAb,CACgB,aAEZ,MACIsB,IAAUH,EAAe,IAAA,GAAYxB,EAAAA,gBAAgB,OAEzD,OAAQM,EAAAA,yBACJsB,EACAC,EAASC,EAAY,IAAA,EACzB,CACH,CAAA,GACD,EAAAX,EAAA,IAAA,CAACd,EAAAA,QAAY,OAAb,CAA+B,YAC3B,UAAA,EAAAc,EAAA,IAAA,CAACd,EAAAA,QAAY,WAAb,CACW,QACM,cACb,aAAcJ,EAAAA,wBAAwB,aACtC,UAAWM,EAAAA,gBAAgB,YAAY,QACrB,mBACZ,OACM,aAEZ,UAAA,EAAAY,EAAA,KAAA,CAACd,EAAAA,QAAY,MAAb,CACI,GAAIkB,EACJ,UAAWf,EAAAA,gBACPC,EAAAA,cAAc,KACdA,EAAAA,cAAc,SAASsB,GACvBC,IAAa,IAAA,IACTvB,EAAAA,cAAc,UAAUuB,GAC5BC,IAAe,IAAA,IACXxB,EAAAA,cAAc,YAAYwB,GAC9BX,GACIS,IAAY,YACZtB,EAAAA,cAAc,gBAClBF,EAAAA,gBAAgB,KAChB2B,CACJ,EACA,GAAIJ,EACJ,KAAM,UAhBV,SAAA,CAkBKR,GACG,EAAAH,EAAA,IAAA,CAACd,EAAAA,QAAY,MAAb,CACI,UAAWG,EAAAA,gBACPD,EAAAA,gBAAgB,MAChBwB,IAAY,aACRtB,EAAAA,cAAc,KACtB,CACH,CAAA,EACD,KACH0B,CACc,C,EACC,CAAA,CACR,CAAA,CACN,C,EAE1B,E"}
|
|
@@ -6,29 +6,29 @@ import { TooltipProviderContext as i } from "./contexts/TooltipProviderContext.j
|
|
|
6
6
|
import { useTooltip as a } from "./hooks/use-tooltip/useTooltip.hook.js";
|
|
7
7
|
import { tooltipStyles as o } from "./Tooltip.css.js";
|
|
8
8
|
import { getTooltipTriggerElement as s } from "./utils/getTooltipTriggerElement.utils.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { use as c } from "react";
|
|
10
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
11
11
|
import { Tooltip as d } from "@base-ui/react/tooltip";
|
|
12
12
|
// src/components/overlays/tooltip/Tooltip.tsx
|
|
13
13
|
var f = ({ align: f = r.align, alignOffset: p = r.alignOffset, arrow: m = r.arrow, children: h, className: g, closeDelay: _, collisionPadding: v, container: y, defaultOpen: b, delay: x, disabled: S, fontSize: C, fontWeight: w, interactive: T = r.interactive, label: E, onOpenChange: D, open: O, side: k = r.side, sideOffset: A = m ? t.sideOffset : r.sideOffset, variant: j = r.variant, ...M }) => {
|
|
14
|
-
let N =
|
|
14
|
+
let N = c(i), { contentId: P, handleOpenChange: F, isOpen: I } = a({
|
|
15
15
|
defaultOpen: b,
|
|
16
16
|
onOpenChange: D,
|
|
17
17
|
open: O
|
|
18
18
|
});
|
|
19
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ u(d.Root, {
|
|
20
20
|
defaultOpen: b,
|
|
21
21
|
disabled: S,
|
|
22
22
|
disableHoverablePopup: !T,
|
|
23
23
|
onOpenChange: F,
|
|
24
24
|
open: O,
|
|
25
|
-
children: [/* @__PURE__ */
|
|
25
|
+
children: [/* @__PURE__ */ l(d.Trigger, {
|
|
26
26
|
closeDelay: _,
|
|
27
27
|
delay: x ?? (N ? void 0 : r.delay),
|
|
28
28
|
render: s(h, I ? P : void 0)
|
|
29
|
-
}), /* @__PURE__ */
|
|
29
|
+
}), /* @__PURE__ */ l(d.Portal, {
|
|
30
30
|
container: y,
|
|
31
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ l(d.Positioner, {
|
|
32
32
|
align: f,
|
|
33
33
|
alignOffset: p,
|
|
34
34
|
arrowPadding: t.arrowPadding,
|
|
@@ -36,12 +36,12 @@ var f = ({ align: f = r.align, alignOffset: p = r.alignOffset, arrow: m = r.arro
|
|
|
36
36
|
collisionPadding: v,
|
|
37
37
|
side: k,
|
|
38
38
|
sideOffset: A,
|
|
39
|
-
children: /* @__PURE__ */
|
|
39
|
+
children: /* @__PURE__ */ u(d.Popup, {
|
|
40
40
|
...M,
|
|
41
41
|
className: e(o.root, o.variants[j], C !== void 0 && o.fontSizes[C], w !== void 0 && o.fontWeights[w], m && j === "outlined" && o.outlinedArrowed, n.fade, g),
|
|
42
42
|
id: P,
|
|
43
43
|
role: "tooltip",
|
|
44
|
-
children: [m ? /* @__PURE__ */
|
|
44
|
+
children: [m ? /* @__PURE__ */ l(d.Arrow, { className: e(n.arrow, j === "contained" && o.arrow) }) : null, E]
|
|
45
45
|
})
|
|
46
46
|
})
|
|
47
47
|
})]
|
package/dist/index.d.cts
CHANGED
|
@@ -417,6 +417,9 @@ declare type BoxMarginStyleProps = Pick<BoxStyleProps, (typeof boxMarginStylePro
|
|
|
417
417
|
* name of the button, flags it with `data-loading`, `aria-busy` and
|
|
418
418
|
* `aria-disabled`, and cancels its clicks: `onClick` is not called and no
|
|
419
419
|
* form is submitted, but other handlers run and the button stays focusable.
|
|
420
|
+
* A given `selected` makes it a toggle button: `aria-pressed` exposes its
|
|
421
|
+
* state, and while `true` it keeps its pressed colors, hovered or loading,
|
|
422
|
+
* and is flagged with `data-selected`; disabled, it takes the disabled colors.
|
|
420
423
|
*
|
|
421
424
|
* The label names the button, or `aria-label` when the label is empty; the
|
|
422
425
|
* icons, given as icon data and drawn by `Icon`s at the icon size of the
|
|
@@ -424,15 +427,24 @@ declare type BoxMarginStyleProps = Pick<BoxStyleProps, (typeof boxMarginStylePro
|
|
|
424
427
|
* given. `disabled` disables it natively and flags it with `data-disabled`.
|
|
425
428
|
* The focus ring shows on keyboard focus only.
|
|
426
429
|
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
430
|
+
* With `asChild`, it renders its single child instead, an element without
|
|
431
|
+
* content such as a router link, which carries the destination and keeps
|
|
432
|
+
* its own role: the classes, props, `ref` and handlers of the button are
|
|
433
|
+
* merged onto it, the child's handlers running first and its own values
|
|
434
|
+
* prevailing for any other prop, and the label and icons become its
|
|
435
|
+
* content. It then takes neither `type`, `disabled`, `loading` nor
|
|
436
|
+
* `selected`.
|
|
431
437
|
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
438
|
+
* The margin and width props of `Box` space and size it. Every other prop
|
|
439
|
+
* (attributes, events, `ref`) goes to the `button` or the child; `className`
|
|
440
|
+
* comes after the generated classes and `style` after the generated
|
|
441
|
+
* variables. Its styles sit in the `cv.components` cascade layers, below any
|
|
442
|
+
* unlayered style of the consumer.
|
|
443
|
+
*
|
|
444
|
+
* @param props Label, single child with `asChild`, presentation, icons,
|
|
445
|
+
* loading and selected states, margin and width props and native props of
|
|
446
|
+
* the `button`.
|
|
434
447
|
* @param props.label Visible text of the button, which names it.
|
|
435
|
-
* @param props.loading Whether the button is loading; `false` when absent.
|
|
436
448
|
* @param props.maxLines Lines after which the label is truncated; it wraps
|
|
437
449
|
* freely when absent.
|
|
438
450
|
* @param props.size Height, padding and font sizes; `md` when absent.
|
|
@@ -440,9 +452,36 @@ declare type BoxMarginStyleProps = Pick<BoxStyleProps, (typeof boxMarginStylePro
|
|
|
440
452
|
* when absent.
|
|
441
453
|
* @param props.endIcon Data of the decorative icon after the label; none
|
|
442
454
|
* when absent.
|
|
443
|
-
* @returns The button
|
|
455
|
+
* @returns The button, or its child with `asChild`.
|
|
456
|
+
* @throws {Error} With `asChild`, when the children are not a single
|
|
457
|
+
* element, or have content of their own.
|
|
444
458
|
*/
|
|
445
|
-
export declare const Button: FC<ButtonProps>;
|
|
459
|
+
export declare const Button: FC<ButtonAsChildProps | ButtonProps>;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Props of a `Button` rendering its single child (`asChild`), such as the
|
|
463
|
+
* link of a router, which renders the `a` and carries the destination: its
|
|
464
|
+
* own props, `label` included, the margin and width props of `Box`, then
|
|
465
|
+
* the global attributes, events and `ref` merged onto the child. It takes
|
|
466
|
+
* neither `type`, `disabled`, `loading` nor `selected`, which only a
|
|
467
|
+
* `button` honors.
|
|
468
|
+
*/
|
|
469
|
+
export declare type ButtonAsChildProps = ButtonOwnProps & ButtonBoxStyleProps & Readonly<{
|
|
470
|
+
/** Renders the single child, with the props, styles, label and icons of the button merged onto it. */
|
|
471
|
+
asChild: true;
|
|
472
|
+
/** Single element without content rendering an `a`, such as a router link, which receives the label and the icons. */
|
|
473
|
+
children: ReactElement;
|
|
474
|
+
/** Not accepted: a link has no disabled state; render a disabled `Button` without `asChild` instead. */
|
|
475
|
+
disabled?: never;
|
|
476
|
+
/** Not accepted: a link has no loading state. */
|
|
477
|
+
loading?: never;
|
|
478
|
+
/** Not accepted: `aria-pressed` makes a toggle button, which a link is not; mark the current link with `aria-current` instead. */
|
|
479
|
+
selected?: never;
|
|
480
|
+
/** Not accepted: the type of a `button` does not apply to its child. */
|
|
481
|
+
type?: never;
|
|
482
|
+
/** Ref composed with the ref of the child, receiving its element. */
|
|
483
|
+
ref?: Ref<HTMLAnchorElement> | undefined;
|
|
484
|
+
}> & Readonly<Omit<HTMLAttributes<HTMLAnchorElement>, keyof ButtonOwnProps | keyof ButtonBoxStyleProps | BoxComponentExcludedAttribute>>;
|
|
446
485
|
|
|
447
486
|
/** Size shared by `Button` and `IconButton`, from the smallest to the largest, on the height scale of the controls. */
|
|
448
487
|
declare type ButtonBaseSize = (typeof buttonBaseSizes)[number];
|
|
@@ -485,7 +524,7 @@ declare const buttonBoxStylePropNames: readonly ["margin", "marginBottom", "marg
|
|
|
485
524
|
*/
|
|
486
525
|
declare type ButtonBoxStyleProps = Pick<BoxStyleProps, ButtonBoxStylePropName>;
|
|
487
526
|
|
|
488
|
-
/** Props a `Button` handles itself. */
|
|
527
|
+
/** Props a `Button` handles itself, whether it renders its own `button` or its child. */
|
|
489
528
|
declare type ButtonOwnProps = Readonly<{
|
|
490
529
|
/** Visible text of the button, which names it, rendered in a `Typography` `span`. */
|
|
491
530
|
label: string;
|
|
@@ -501,8 +540,6 @@ declare type ButtonOwnProps = Readonly<{
|
|
|
501
540
|
startIcon?: IconData | undefined;
|
|
502
541
|
/** Data of the decorative icon after the label, drawn by an `Icon` at the icon size and hidden from assistive technologies; none when absent. */
|
|
503
542
|
endIcon?: IconData | undefined;
|
|
504
|
-
/** Shows a spinner over the hidden content and ignores clicks, the button staying focusable; `false` when absent. */
|
|
505
|
-
loading?: boolean | undefined;
|
|
506
543
|
/** Classes added after the generated ones. */
|
|
507
544
|
className?: string | undefined;
|
|
508
545
|
/** Inline styles, merged after the generated variables, so they prevail. */
|
|
@@ -510,12 +547,19 @@ declare type ButtonOwnProps = Readonly<{
|
|
|
510
547
|
}>;
|
|
511
548
|
|
|
512
549
|
/**
|
|
513
|
-
* Props of a `Button
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* text color.
|
|
550
|
+
* Props of a `Button` rendering its own `button`: its own props, its loading
|
|
551
|
+
* and selected states and the margin and width props of `Box`, then the attributes, events
|
|
552
|
+
* and `ref` of the `button`, but its content (`label`) and the legacy
|
|
553
|
+
* `color` attribute, which `Box` would read as its text color.
|
|
517
554
|
*/
|
|
518
|
-
export declare type ButtonProps = ButtonOwnProps & ButtonBoxStyleProps & Readonly<
|
|
555
|
+
export declare type ButtonProps = ButtonOwnProps & ButtonBoxStyleProps & Readonly<{
|
|
556
|
+
/** Renders the single child instead of a `button` when true; absent or false here. */
|
|
557
|
+
asChild?: false | undefined;
|
|
558
|
+
/** Shows a spinner over the hidden content and ignores clicks, the button staying focusable; `false` when absent. */
|
|
559
|
+
loading?: boolean | undefined;
|
|
560
|
+
/** Makes it a toggle button, kept in its pressed colors while `true` and exposed by `aria-pressed`, which it overrides; `false` when absent, without `aria-pressed`. */
|
|
561
|
+
selected?: boolean | undefined;
|
|
562
|
+
}> & Readonly<Omit<ComponentPropsWithRef<'button'>, keyof ButtonOwnProps | keyof ButtonBoxStyleProps | BoxComponentExcludedAttribute>>;
|
|
519
563
|
|
|
520
564
|
/**
|
|
521
565
|
* Size of a `Button`, from the smallest to the largest: its height, on the
|
|
@@ -1091,7 +1135,7 @@ export declare type DrawerItemLinkProps = DrawerItemOwnProps & LinkBaseExternalP
|
|
|
1091
1135
|
declare type DrawerItemOwnProps = Readonly<{
|
|
1092
1136
|
/** Visible text of the item, which names it, and stays its name, faded out, in a collapsed drawer; kept on one line, truncated with an ellipsis. */
|
|
1093
1137
|
label: string;
|
|
1094
|
-
/** Data of the decorative icon before the label, `1rem` high, in the icon column that a collapsed drawer shows alone,
|
|
1138
|
+
/** Data of the decorative icon before the label, `1rem` high, in the icon column that a collapsed drawer shows alone; when absent, a dot in a `mini` drawer, expanded or collapsed, and no column in any other drawer. */
|
|
1095
1139
|
startIcon?: IconData | undefined;
|
|
1096
1140
|
/** Data of the decorative icon after the label, `1rem` high, hidden in a collapsed drawer; the external icon for an external link, none otherwise, when absent. */
|
|
1097
1141
|
endIcon?: IconData | undefined;
|
|
@@ -1724,6 +1768,9 @@ export declare type HoverCardTriggerProps = HoverCardTriggerOwnProps & TriggerBa
|
|
|
1724
1768
|
* of the same size, flags the button with `data-loading`, `aria-busy` and
|
|
1725
1769
|
* `aria-disabled`, and cancels its clicks: `onClick` is not called and no
|
|
1726
1770
|
* form is submitted, but other handlers run and the button stays focusable.
|
|
1771
|
+
* A given `selected` makes it a toggle button: `aria-pressed` exposes its
|
|
1772
|
+
* state, and while `true` it keeps its pressed colors, hovered or loading,
|
|
1773
|
+
* and is flagged with `data-selected`; disabled, it takes the disabled colors.
|
|
1727
1774
|
*
|
|
1728
1775
|
* The required `aria-label` names the button. `type` is `button` unless
|
|
1729
1776
|
* given. `disabled` disables it natively and flags it with `data-disabled`. The focus ring shows on keyboard
|
|
@@ -1734,8 +1781,8 @@ export declare type HoverCardTriggerProps = HoverCardTriggerOwnProps & TriggerBa
|
|
|
1734
1781
|
* the generated classes. Its styles sit in the `cv.components` cascade
|
|
1735
1782
|
* layers, below any unlayered style of the consumer.
|
|
1736
1783
|
*
|
|
1737
|
-
* @param props Icon, accessible name, presentation, loading
|
|
1738
|
-
* props and native props of the `button`.
|
|
1784
|
+
* @param props Icon, accessible name, presentation, loading and selected
|
|
1785
|
+
* states, margin props and native props of the `button`.
|
|
1739
1786
|
* @param props.icon Data of the decorative icon shown in the button.
|
|
1740
1787
|
* @param props.loading Whether the button is loading; `false` when absent.
|
|
1741
1788
|
* @param props.size Side and icon size; `md` when absent.
|
|
@@ -1757,6 +1804,8 @@ declare type IconButtonOwnProps = Readonly<{
|
|
|
1757
1804
|
size?: IconButtonSize | undefined;
|
|
1758
1805
|
/** Shows a spinner over the hidden icon and ignores clicks, the button staying focusable; `false` when absent. */
|
|
1759
1806
|
loading?: boolean | undefined;
|
|
1807
|
+
/** Makes it a toggle button, kept in its pressed colors while `true` and exposed by `aria-pressed`, which it overrides; `false` when absent, without `aria-pressed`. */
|
|
1808
|
+
selected?: boolean | undefined;
|
|
1760
1809
|
/** Classes added after the generated ones. */
|
|
1761
1810
|
className?: string | undefined;
|
|
1762
1811
|
/** Inline styles of the `button`, as given. */
|
package/dist/index.d.ts
CHANGED
|
@@ -417,6 +417,9 @@ declare type BoxMarginStyleProps = Pick<BoxStyleProps, (typeof boxMarginStylePro
|
|
|
417
417
|
* name of the button, flags it with `data-loading`, `aria-busy` and
|
|
418
418
|
* `aria-disabled`, and cancels its clicks: `onClick` is not called and no
|
|
419
419
|
* form is submitted, but other handlers run and the button stays focusable.
|
|
420
|
+
* A given `selected` makes it a toggle button: `aria-pressed` exposes its
|
|
421
|
+
* state, and while `true` it keeps its pressed colors, hovered or loading,
|
|
422
|
+
* and is flagged with `data-selected`; disabled, it takes the disabled colors.
|
|
420
423
|
*
|
|
421
424
|
* The label names the button, or `aria-label` when the label is empty; the
|
|
422
425
|
* icons, given as icon data and drawn by `Icon`s at the icon size of the
|
|
@@ -424,15 +427,24 @@ declare type BoxMarginStyleProps = Pick<BoxStyleProps, (typeof boxMarginStylePro
|
|
|
424
427
|
* given. `disabled` disables it natively and flags it with `data-disabled`.
|
|
425
428
|
* The focus ring shows on keyboard focus only.
|
|
426
429
|
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
430
|
+
* With `asChild`, it renders its single child instead, an element without
|
|
431
|
+
* content such as a router link, which carries the destination and keeps
|
|
432
|
+
* its own role: the classes, props, `ref` and handlers of the button are
|
|
433
|
+
* merged onto it, the child's handlers running first and its own values
|
|
434
|
+
* prevailing for any other prop, and the label and icons become its
|
|
435
|
+
* content. It then takes neither `type`, `disabled`, `loading` nor
|
|
436
|
+
* `selected`.
|
|
431
437
|
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
438
|
+
* The margin and width props of `Box` space and size it. Every other prop
|
|
439
|
+
* (attributes, events, `ref`) goes to the `button` or the child; `className`
|
|
440
|
+
* comes after the generated classes and `style` after the generated
|
|
441
|
+
* variables. Its styles sit in the `cv.components` cascade layers, below any
|
|
442
|
+
* unlayered style of the consumer.
|
|
443
|
+
*
|
|
444
|
+
* @param props Label, single child with `asChild`, presentation, icons,
|
|
445
|
+
* loading and selected states, margin and width props and native props of
|
|
446
|
+
* the `button`.
|
|
434
447
|
* @param props.label Visible text of the button, which names it.
|
|
435
|
-
* @param props.loading Whether the button is loading; `false` when absent.
|
|
436
448
|
* @param props.maxLines Lines after which the label is truncated; it wraps
|
|
437
449
|
* freely when absent.
|
|
438
450
|
* @param props.size Height, padding and font sizes; `md` when absent.
|
|
@@ -440,9 +452,36 @@ declare type BoxMarginStyleProps = Pick<BoxStyleProps, (typeof boxMarginStylePro
|
|
|
440
452
|
* when absent.
|
|
441
453
|
* @param props.endIcon Data of the decorative icon after the label; none
|
|
442
454
|
* when absent.
|
|
443
|
-
* @returns The button
|
|
455
|
+
* @returns The button, or its child with `asChild`.
|
|
456
|
+
* @throws {Error} With `asChild`, when the children are not a single
|
|
457
|
+
* element, or have content of their own.
|
|
444
458
|
*/
|
|
445
|
-
export declare const Button: FC<ButtonProps>;
|
|
459
|
+
export declare const Button: FC<ButtonAsChildProps | ButtonProps>;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Props of a `Button` rendering its single child (`asChild`), such as the
|
|
463
|
+
* link of a router, which renders the `a` and carries the destination: its
|
|
464
|
+
* own props, `label` included, the margin and width props of `Box`, then
|
|
465
|
+
* the global attributes, events and `ref` merged onto the child. It takes
|
|
466
|
+
* neither `type`, `disabled`, `loading` nor `selected`, which only a
|
|
467
|
+
* `button` honors.
|
|
468
|
+
*/
|
|
469
|
+
export declare type ButtonAsChildProps = ButtonOwnProps & ButtonBoxStyleProps & Readonly<{
|
|
470
|
+
/** Renders the single child, with the props, styles, label and icons of the button merged onto it. */
|
|
471
|
+
asChild: true;
|
|
472
|
+
/** Single element without content rendering an `a`, such as a router link, which receives the label and the icons. */
|
|
473
|
+
children: ReactElement;
|
|
474
|
+
/** Not accepted: a link has no disabled state; render a disabled `Button` without `asChild` instead. */
|
|
475
|
+
disabled?: never;
|
|
476
|
+
/** Not accepted: a link has no loading state. */
|
|
477
|
+
loading?: never;
|
|
478
|
+
/** Not accepted: `aria-pressed` makes a toggle button, which a link is not; mark the current link with `aria-current` instead. */
|
|
479
|
+
selected?: never;
|
|
480
|
+
/** Not accepted: the type of a `button` does not apply to its child. */
|
|
481
|
+
type?: never;
|
|
482
|
+
/** Ref composed with the ref of the child, receiving its element. */
|
|
483
|
+
ref?: Ref<HTMLAnchorElement> | undefined;
|
|
484
|
+
}> & Readonly<Omit<HTMLAttributes<HTMLAnchorElement>, keyof ButtonOwnProps | keyof ButtonBoxStyleProps | BoxComponentExcludedAttribute>>;
|
|
446
485
|
|
|
447
486
|
/** Size shared by `Button` and `IconButton`, from the smallest to the largest, on the height scale of the controls. */
|
|
448
487
|
declare type ButtonBaseSize = (typeof buttonBaseSizes)[number];
|
|
@@ -485,7 +524,7 @@ declare const buttonBoxStylePropNames: readonly ["margin", "marginBottom", "marg
|
|
|
485
524
|
*/
|
|
486
525
|
declare type ButtonBoxStyleProps = Pick<BoxStyleProps, ButtonBoxStylePropName>;
|
|
487
526
|
|
|
488
|
-
/** Props a `Button` handles itself. */
|
|
527
|
+
/** Props a `Button` handles itself, whether it renders its own `button` or its child. */
|
|
489
528
|
declare type ButtonOwnProps = Readonly<{
|
|
490
529
|
/** Visible text of the button, which names it, rendered in a `Typography` `span`. */
|
|
491
530
|
label: string;
|
|
@@ -501,8 +540,6 @@ declare type ButtonOwnProps = Readonly<{
|
|
|
501
540
|
startIcon?: IconData | undefined;
|
|
502
541
|
/** Data of the decorative icon after the label, drawn by an `Icon` at the icon size and hidden from assistive technologies; none when absent. */
|
|
503
542
|
endIcon?: IconData | undefined;
|
|
504
|
-
/** Shows a spinner over the hidden content and ignores clicks, the button staying focusable; `false` when absent. */
|
|
505
|
-
loading?: boolean | undefined;
|
|
506
543
|
/** Classes added after the generated ones. */
|
|
507
544
|
className?: string | undefined;
|
|
508
545
|
/** Inline styles, merged after the generated variables, so they prevail. */
|
|
@@ -510,12 +547,19 @@ declare type ButtonOwnProps = Readonly<{
|
|
|
510
547
|
}>;
|
|
511
548
|
|
|
512
549
|
/**
|
|
513
|
-
* Props of a `Button
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* text color.
|
|
550
|
+
* Props of a `Button` rendering its own `button`: its own props, its loading
|
|
551
|
+
* and selected states and the margin and width props of `Box`, then the attributes, events
|
|
552
|
+
* and `ref` of the `button`, but its content (`label`) and the legacy
|
|
553
|
+
* `color` attribute, which `Box` would read as its text color.
|
|
517
554
|
*/
|
|
518
|
-
export declare type ButtonProps = ButtonOwnProps & ButtonBoxStyleProps & Readonly<
|
|
555
|
+
export declare type ButtonProps = ButtonOwnProps & ButtonBoxStyleProps & Readonly<{
|
|
556
|
+
/** Renders the single child instead of a `button` when true; absent or false here. */
|
|
557
|
+
asChild?: false | undefined;
|
|
558
|
+
/** Shows a spinner over the hidden content and ignores clicks, the button staying focusable; `false` when absent. */
|
|
559
|
+
loading?: boolean | undefined;
|
|
560
|
+
/** Makes it a toggle button, kept in its pressed colors while `true` and exposed by `aria-pressed`, which it overrides; `false` when absent, without `aria-pressed`. */
|
|
561
|
+
selected?: boolean | undefined;
|
|
562
|
+
}> & Readonly<Omit<ComponentPropsWithRef<'button'>, keyof ButtonOwnProps | keyof ButtonBoxStyleProps | BoxComponentExcludedAttribute>>;
|
|
519
563
|
|
|
520
564
|
/**
|
|
521
565
|
* Size of a `Button`, from the smallest to the largest: its height, on the
|
|
@@ -1091,7 +1135,7 @@ export declare type DrawerItemLinkProps = DrawerItemOwnProps & LinkBaseExternalP
|
|
|
1091
1135
|
declare type DrawerItemOwnProps = Readonly<{
|
|
1092
1136
|
/** Visible text of the item, which names it, and stays its name, faded out, in a collapsed drawer; kept on one line, truncated with an ellipsis. */
|
|
1093
1137
|
label: string;
|
|
1094
|
-
/** Data of the decorative icon before the label, `1rem` high, in the icon column that a collapsed drawer shows alone,
|
|
1138
|
+
/** Data of the decorative icon before the label, `1rem` high, in the icon column that a collapsed drawer shows alone; when absent, a dot in a `mini` drawer, expanded or collapsed, and no column in any other drawer. */
|
|
1095
1139
|
startIcon?: IconData | undefined;
|
|
1096
1140
|
/** Data of the decorative icon after the label, `1rem` high, hidden in a collapsed drawer; the external icon for an external link, none otherwise, when absent. */
|
|
1097
1141
|
endIcon?: IconData | undefined;
|
|
@@ -1724,6 +1768,9 @@ export declare type HoverCardTriggerProps = HoverCardTriggerOwnProps & TriggerBa
|
|
|
1724
1768
|
* of the same size, flags the button with `data-loading`, `aria-busy` and
|
|
1725
1769
|
* `aria-disabled`, and cancels its clicks: `onClick` is not called and no
|
|
1726
1770
|
* form is submitted, but other handlers run and the button stays focusable.
|
|
1771
|
+
* A given `selected` makes it a toggle button: `aria-pressed` exposes its
|
|
1772
|
+
* state, and while `true` it keeps its pressed colors, hovered or loading,
|
|
1773
|
+
* and is flagged with `data-selected`; disabled, it takes the disabled colors.
|
|
1727
1774
|
*
|
|
1728
1775
|
* The required `aria-label` names the button. `type` is `button` unless
|
|
1729
1776
|
* given. `disabled` disables it natively and flags it with `data-disabled`. The focus ring shows on keyboard
|
|
@@ -1734,8 +1781,8 @@ export declare type HoverCardTriggerProps = HoverCardTriggerOwnProps & TriggerBa
|
|
|
1734
1781
|
* the generated classes. Its styles sit in the `cv.components` cascade
|
|
1735
1782
|
* layers, below any unlayered style of the consumer.
|
|
1736
1783
|
*
|
|
1737
|
-
* @param props Icon, accessible name, presentation, loading
|
|
1738
|
-
* props and native props of the `button`.
|
|
1784
|
+
* @param props Icon, accessible name, presentation, loading and selected
|
|
1785
|
+
* states, margin props and native props of the `button`.
|
|
1739
1786
|
* @param props.icon Data of the decorative icon shown in the button.
|
|
1740
1787
|
* @param props.loading Whether the button is loading; `false` when absent.
|
|
1741
1788
|
* @param props.size Side and icon size; `md` when absent.
|
|
@@ -1757,6 +1804,8 @@ declare type IconButtonOwnProps = Readonly<{
|
|
|
1757
1804
|
size?: IconButtonSize | undefined;
|
|
1758
1805
|
/** Shows a spinner over the hidden icon and ignores clicks, the button staying focusable; `false` when absent. */
|
|
1759
1806
|
loading?: boolean | undefined;
|
|
1807
|
+
/** Makes it a toggle button, kept in its pressed colors while `true` and exposed by `aria-pressed`, which it overrides; `false` when absent, without `aria-pressed`. */
|
|
1808
|
+
selected?: boolean | undefined;
|
|
1760
1809
|
/** Classes added after the generated ones. */
|
|
1761
1810
|
className?: string | undefined;
|
|
1762
1811
|
/** Inline styles of the `button`, as given. */
|