@dashforge/tw 0.3.0-beta → 0.4.0-beta
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/CHANGELOG.md +123 -0
- package/PARITY.md +483 -0
- package/PERFORMANCE.md +169 -0
- package/dist/index.esm.js +493 -2
- package/dist/src/components/Accordion/Accordion.d.ts +21 -0
- package/dist/src/components/Accordion/Accordion.d.ts.map +1 -0
- package/dist/src/components/Accordion/accordion.types.d.ts +74 -0
- package/dist/src/components/Accordion/accordion.types.d.ts.map +1 -0
- package/dist/src/components/Accordion/accordion.variants.d.ts +58 -0
- package/dist/src/components/Accordion/accordion.variants.d.ts.map +1 -0
- package/dist/src/components/Dialog/Dialog.d.ts +17 -0
- package/dist/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/src/components/Dialog/dialog.types.d.ts +75 -0
- package/dist/src/components/Dialog/dialog.types.d.ts.map +1 -0
- package/dist/src/components/Dialog/dialog.variants.d.ts +80 -0
- package/dist/src/components/Dialog/dialog.variants.d.ts.map +1 -0
- package/dist/src/components/Popover/Popover.d.ts +15 -0
- package/dist/src/components/Popover/Popover.d.ts.map +1 -0
- package/dist/src/components/Popover/popover.types.d.ts +45 -0
- package/dist/src/components/Popover/popover.types.d.ts.map +1 -0
- package/dist/src/components/Popover/popover.variants.d.ts +34 -0
- package/dist/src/components/Popover/popover.variants.d.ts.map +1 -0
- package/dist/src/components/Tabs/Tabs.d.ts +15 -0
- package/dist/src/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/src/components/Tabs/tabs.types.d.ts +55 -0
- package/dist/src/components/Tabs/tabs.types.d.ts.map +1 -0
- package/dist/src/components/Tabs/tabs.variants.d.ts +82 -0
- package/dist/src/components/Tabs/tabs.variants.d.ts.map +1 -0
- package/dist/src/components/Tooltip/Tooltip.d.ts +29 -0
- package/dist/src/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/src/components/Tooltip/tooltip.types.d.ts +47 -0
- package/dist/src/components/Tooltip/tooltip.types.d.ts.map +1 -0
- package/dist/src/components/Tooltip/tooltip.variants.d.ts +34 -0
- package/dist/src/components/Tooltip/tooltip.variants.d.ts.map +1 -0
- package/dist/src/index.d.ts +16 -1
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/components/Accordion/Accordion.test.tsx +95 -0
- package/src/components/Accordion/Accordion.tsx +97 -0
- package/src/components/Accordion/accordion.types.ts +66 -0
- package/src/components/Accordion/accordion.variants.ts +30 -0
- package/src/components/Dialog/Dialog.test.tsx +96 -0
- package/src/components/Dialog/Dialog.tsx +93 -0
- package/src/components/Dialog/dialog.types.ts +62 -0
- package/src/components/Dialog/dialog.variants.ts +62 -0
- package/src/components/Popover/Popover.test.tsx +72 -0
- package/src/components/Popover/Popover.tsx +55 -0
- package/src/components/Popover/popover.types.ts +42 -0
- package/src/components/Popover/popover.variants.ts +18 -0
- package/src/components/Tabs/Tabs.test.tsx +74 -0
- package/src/components/Tabs/Tabs.tsx +66 -0
- package/src/components/Tabs/tabs.types.ts +49 -0
- package/src/components/Tabs/tabs.variants.ts +58 -0
- package/src/components/Tooltip/Tooltip.test.tsx +73 -0
- package/src/components/Tooltip/Tooltip.tsx +70 -0
- package/src/components/Tooltip/tooltip.types.ts +44 -0
- package/src/components/Tooltip/tooltip.variants.ts +18 -0
- package/src/index.ts +40 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as RadixTooltip from '@radix-ui/react-tooltip';
|
|
2
|
+
import { cn } from '../../utils/cn.js';
|
|
3
|
+
import { tooltipVariants } from './tooltip.variants.js';
|
|
4
|
+
import type { TooltipProps } from './tooltip.types.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Dashforge TW `<Tooltip>` — hoverable / focusable tooltip.
|
|
8
|
+
*
|
|
9
|
+
* Built on `@radix-ui/react-tooltip`:
|
|
10
|
+
* - APG tooltip pattern: `role="tooltip"`, `aria-describedby` wired
|
|
11
|
+
* to the trigger automatically (Radix manages the id linkage).
|
|
12
|
+
* - Shows on hover OR keyboard focus.
|
|
13
|
+
* - Dismissed on Escape or pointer leave.
|
|
14
|
+
*
|
|
15
|
+
* Wrap any single React node — it becomes the trigger via Radix's
|
|
16
|
+
* `asChild` slot. The trigger inherits `aria-describedby` so screen
|
|
17
|
+
* readers announce the tooltip content along with the trigger.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Tooltip content="Delete this item">
|
|
22
|
+
* <Button variant="ghost">
|
|
23
|
+
* <TrashIcon />
|
|
24
|
+
* </Button>
|
|
25
|
+
* </Tooltip>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Each consumer can also wrap the entire app once in
|
|
29
|
+
* `<RadixTooltip.Provider>` to share delay/skip configuration; we
|
|
30
|
+
* include a per-component provider here for ease-of-use.
|
|
31
|
+
*/
|
|
32
|
+
export function Tooltip(props: TooltipProps) {
|
|
33
|
+
const {
|
|
34
|
+
children,
|
|
35
|
+
content,
|
|
36
|
+
side = 'top',
|
|
37
|
+
align = 'center',
|
|
38
|
+
hideArrow = false,
|
|
39
|
+
delayDuration = 200,
|
|
40
|
+
open,
|
|
41
|
+
onOpenChange,
|
|
42
|
+
sideOffset = 4,
|
|
43
|
+
slotProps,
|
|
44
|
+
} = props;
|
|
45
|
+
|
|
46
|
+
const v = tooltipVariants();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<RadixTooltip.Provider delayDuration={delayDuration}>
|
|
50
|
+
<RadixTooltip.Root open={open} onOpenChange={onOpenChange}>
|
|
51
|
+
<RadixTooltip.Trigger asChild>{children}</RadixTooltip.Trigger>
|
|
52
|
+
<RadixTooltip.Portal>
|
|
53
|
+
<RadixTooltip.Content
|
|
54
|
+
side={side}
|
|
55
|
+
align={align}
|
|
56
|
+
sideOffset={sideOffset}
|
|
57
|
+
className={cn(v.content(), slotProps?.content?.className)}
|
|
58
|
+
>
|
|
59
|
+
{content}
|
|
60
|
+
{!hideArrow && (
|
|
61
|
+
<RadixTooltip.Arrow
|
|
62
|
+
className={cn(v.arrow(), slotProps?.arrow?.className)}
|
|
63
|
+
/>
|
|
64
|
+
)}
|
|
65
|
+
</RadixTooltip.Content>
|
|
66
|
+
</RadixTooltip.Portal>
|
|
67
|
+
</RadixTooltip.Root>
|
|
68
|
+
</RadixTooltip.Provider>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface TooltipSlotProps {
|
|
4
|
+
content?: { className?: string };
|
|
5
|
+
arrow?: { className?: string };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for `<Tooltip>`.
|
|
10
|
+
*
|
|
11
|
+
* Built on `@radix-ui/react-tooltip`. Wrap any element with a tooltip
|
|
12
|
+
* that follows APG semantics (`role="tooltip"`, `aria-describedby`
|
|
13
|
+
* wired to the trigger).
|
|
14
|
+
*
|
|
15
|
+
* Renders an arrow by default. Three side options
|
|
16
|
+
* (top / right / bottom / left) with 'top' as default. Delay
|
|
17
|
+
* configurable via `delayDuration` (forwarded to Radix Provider).
|
|
18
|
+
*/
|
|
19
|
+
export interface TooltipProps {
|
|
20
|
+
/** The element that, when hovered/focused, shows the tooltip. */
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
/** Tooltip body content. */
|
|
23
|
+
content: ReactNode;
|
|
24
|
+
/** Side of the trigger to show the tooltip on. @default 'top' */
|
|
25
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
26
|
+
/** Alignment along the perpendicular axis. @default 'center' */
|
|
27
|
+
align?: 'start' | 'center' | 'end';
|
|
28
|
+
/** Hide the arrow indicator. @default false (arrow shown) */
|
|
29
|
+
hideArrow?: boolean;
|
|
30
|
+
/** Delay before the tooltip shows on hover (ms). @default 200 */
|
|
31
|
+
delayDuration?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Controlled open state. Use when the tooltip should be programmatic
|
|
34
|
+
* (e.g. revealed on a manual button press). Omit for default
|
|
35
|
+
* hover / focus behavior.
|
|
36
|
+
*/
|
|
37
|
+
open?: boolean;
|
|
38
|
+
/** Called when the tooltip's open state changes. */
|
|
39
|
+
onOpenChange?: (open: boolean) => void;
|
|
40
|
+
/** Side offset in pixels from the trigger. @default 4 */
|
|
41
|
+
sideOffset?: number;
|
|
42
|
+
/** Per-slot overrides. */
|
|
43
|
+
slotProps?: TooltipSlotProps;
|
|
44
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tv, type VariantProps } from 'tailwind-variants';
|
|
2
|
+
|
|
3
|
+
export const tooltipVariants = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
content: [
|
|
6
|
+
'z-50 max-w-xs rounded-md px-3 py-1.5 text-xs font-medium',
|
|
7
|
+
'bg-neutral-900 text-neutral-50',
|
|
8
|
+
'dark:bg-neutral-50 dark:text-neutral-900',
|
|
9
|
+
'shadow-md',
|
|
10
|
+
'data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95',
|
|
11
|
+
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',
|
|
12
|
+
'motion-reduce:transition-none motion-reduce:duration-0',
|
|
13
|
+
],
|
|
14
|
+
arrow: 'fill-neutral-900 dark:fill-neutral-50',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type TooltipVariants = VariantProps<typeof tooltipVariants>;
|
package/src/index.ts
CHANGED
|
@@ -223,6 +223,45 @@ export type { AspectRatioProps } from './components/AspectRatio/aspectRatio.type
|
|
|
223
223
|
export { VisuallyHidden } from './components/VisuallyHidden/VisuallyHidden.js';
|
|
224
224
|
export type { VisuallyHiddenProps } from './components/VisuallyHidden/visuallyHidden.types.js';
|
|
225
225
|
|
|
226
|
+
// F11 tier-4: overlay + disclosure primitives.
|
|
227
|
+
|
|
228
|
+
export { Dialog } from './components/Dialog/Dialog.js';
|
|
229
|
+
export type {
|
|
230
|
+
DialogProps,
|
|
231
|
+
DialogSlotProps,
|
|
232
|
+
} from './components/Dialog/dialog.types.js';
|
|
233
|
+
export { dialogVariants } from './components/Dialog/dialog.variants.js';
|
|
234
|
+
|
|
235
|
+
export { Tabs } from './components/Tabs/Tabs.js';
|
|
236
|
+
export type {
|
|
237
|
+
TabsProps,
|
|
238
|
+
TabsSlotProps,
|
|
239
|
+
TabItem,
|
|
240
|
+
} from './components/Tabs/tabs.types.js';
|
|
241
|
+
export { tabsVariants } from './components/Tabs/tabs.variants.js';
|
|
242
|
+
|
|
243
|
+
export { Tooltip } from './components/Tooltip/Tooltip.js';
|
|
244
|
+
export type {
|
|
245
|
+
TooltipProps,
|
|
246
|
+
TooltipSlotProps,
|
|
247
|
+
} from './components/Tooltip/tooltip.types.js';
|
|
248
|
+
export { tooltipVariants } from './components/Tooltip/tooltip.variants.js';
|
|
249
|
+
|
|
250
|
+
export { Popover } from './components/Popover/Popover.js';
|
|
251
|
+
export type {
|
|
252
|
+
PopoverProps,
|
|
253
|
+
PopoverSlotProps,
|
|
254
|
+
} from './components/Popover/popover.types.js';
|
|
255
|
+
export { popoverVariants } from './components/Popover/popover.variants.js';
|
|
256
|
+
|
|
257
|
+
export { Accordion } from './components/Accordion/Accordion.js';
|
|
258
|
+
export type {
|
|
259
|
+
AccordionProps,
|
|
260
|
+
AccordionSlotProps,
|
|
261
|
+
AccordionItem,
|
|
262
|
+
} from './components/Accordion/accordion.types.js';
|
|
263
|
+
export { accordionVariants } from './components/Accordion/accordion.variants.js';
|
|
264
|
+
|
|
226
265
|
// ───── Hooks ─────
|
|
227
266
|
export { useAccessState } from './hooks/useAccessState.js';
|
|
228
267
|
|
|
@@ -237,4 +276,4 @@ export type { VariantProps } from 'tailwind-variants';
|
|
|
237
276
|
/**
|
|
238
277
|
* Package version (synced with `package.json` at publish time).
|
|
239
278
|
*/
|
|
240
|
-
export const VERSION = '0.
|
|
279
|
+
export const VERSION = '0.4.0-beta';
|