@barqjs/aria 0.2.0-next.0 → 0.2.0-next.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.
- package/README.md +24 -13
- package/package.json +127 -37
- package/src/autocomplete.tsx +581 -0
- package/src/breadcrumbs.tsx +21 -20
- package/src/button.tsx +151 -25
- package/src/calendar.tsx +1019 -92
- package/src/checkbox.tsx +214 -52
- package/src/collections.ts +88 -5
- package/src/color.ts +1580 -23
- package/src/colorpicker.tsx +698 -153
- package/src/colorswatchpicker.tsx +240 -0
- package/src/combobox.tsx +635 -113
- package/src/command.tsx +78 -59
- package/src/date.ts +31 -9
- package/src/datefield.tsx +1451 -336
- package/src/datepicker.tsx +465 -114
- package/src/dialog.tsx +302 -115
- package/src/disclosure.tsx +81 -29
- package/src/dnd/clipboard.ts +125 -0
- package/src/dnd/collection.ts +1265 -0
- package/src/dnd/data.ts +409 -0
- package/src/dnd/drag-drop.ts +801 -0
- package/src/dnd/index.ts +133 -0
- package/src/dnd/manager.ts +639 -0
- package/src/dnd/strings.ts +1279 -0
- package/src/dnd/targets.ts +726 -0
- package/src/dnd/types.ts +212 -0
- package/src/dom.ts +3 -6
- package/src/drag-and-drop.tsx +669 -0
- package/src/dropzone.tsx +208 -0
- package/src/file-trigger.tsx +103 -0
- package/src/form.tsx +18 -18
- package/src/gridlist.tsx +912 -121
- package/src/group.tsx +146 -0
- package/src/index.ts +402 -0
- package/src/interactions/focus-events.ts +13 -5
- package/src/interactions/keyboard.ts +195 -2
- package/src/interactions/modality.ts +18 -6
- package/src/interactions/open-link.ts +46 -13
- package/src/interactions/press.ts +35 -18
- package/src/label.ts +18 -6
- package/src/link.tsx +146 -50
- package/src/listbox.tsx +615 -89
- package/src/live.ts +4 -0
- package/src/menu.tsx +182 -89
- package/src/menubar.tsx +21 -17
- package/src/navigation-tree.tsx +357 -0
- package/src/numberfield.tsx +164 -60
- package/src/overlay-arrow.tsx +157 -0
- package/src/overlays.ts +364 -62
- package/src/platform.ts +2 -1
- package/src/preview-trigger.tsx +582 -0
- package/src/progress-bar-context.ts +15 -0
- package/src/questionnaire.tsx +109 -104
- package/src/radio.tsx +101 -27
- package/src/select.tsx +225 -145
- package/src/selection-indicator.tsx +74 -0
- package/src/selection.ts +73 -16
- package/src/shared-element-transition.tsx +316 -0
- package/src/sheet.tsx +1461 -0
- package/src/slider.tsx +139 -44
- package/src/switch.tsx +47 -21
- package/src/table.tsx +0 -0
- package/src/tabs.tsx +198 -89
- package/src/tag.tsx +217 -32
- package/src/textarea.tsx +186 -0
- package/src/textfield.tsx +103 -37
- package/src/toast-components.tsx +589 -0
- package/src/toggle-button-group.tsx +175 -0
- package/src/toggle-input.tsx +38 -0
- package/src/toggle.ts +68 -5
- package/src/tokenfield.tsx +1673 -0
- package/src/toolbar.tsx +15 -10
- package/src/tooltip.tsx +46 -29
- package/src/tree.tsx +2075 -0
- package/src/utils.ts +30 -1
- package/src/validation.ts +79 -22
- package/src/virtualizer.tsx +186 -23
package/src/toolbar.tsx
CHANGED
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
* already handling them, and two handlers on one keypress move focus twice.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import { type Child, createEffect,
|
|
22
|
+
import { cells, type Child, createEffect, createSignal } from "@barqjs/core";
|
|
23
23
|
import { isServer } from "@barqjs/web";
|
|
24
24
|
import { ref as makeRef, mergeRefs, type RefTarget } from "@barqjs/primitives/refs";
|
|
25
25
|
import { contains, targetElement } from "./dom.ts";
|
|
26
26
|
import { createFocusManager } from "./focus.ts";
|
|
27
27
|
import { useLocale } from "./i18n.ts";
|
|
28
|
+
import { getInteractionModality } from "./interactions/modality.ts";
|
|
28
29
|
import type { ElementRef } from "./interactions/press.ts";
|
|
29
30
|
import type { Orientation } from "./selection.ts";
|
|
30
31
|
import {
|
|
@@ -118,14 +119,18 @@ export function toolbar(options: ToolbarOptions): ToolbarResult {
|
|
|
118
119
|
// is the roving focus doing its job.
|
|
119
120
|
if (contains(current, event.relatedTarget as Element | null)) return;
|
|
120
121
|
if (!contains(current, targetElement(event))) return;
|
|
121
|
-
//
|
|
122
|
-
|
|
122
|
+
// Only for the keyboard: a pointer landed on the control it meant, and
|
|
123
|
+
// moving focus off it would take the press with it. Gone from the document
|
|
124
|
+
// since: whatever the browser landed on stands.
|
|
125
|
+
if (getInteractionModality() === "keyboard" && lastFocused.isConnected) lastFocused.focus();
|
|
123
126
|
lastFocused = null;
|
|
124
127
|
};
|
|
125
128
|
|
|
126
129
|
return {
|
|
127
130
|
toolbarProps: mergeProps(filterDOMProps(options, { labelable: true }), {
|
|
128
|
-
|
|
131
|
+
// A toolbar inside another is a group of the outer one's controls: the
|
|
132
|
+
// outer toolbar is the one stop in the Tab order.
|
|
133
|
+
role: () => (nested() ? "group" : "toolbar"),
|
|
129
134
|
"aria-orientation": orientation,
|
|
130
135
|
onKeyDown,
|
|
131
136
|
onFocusIn: onFocus,
|
|
@@ -155,24 +160,24 @@ export interface ToolbarComponentProps extends StyleProps {
|
|
|
155
160
|
* </Toolbar>
|
|
156
161
|
* ```
|
|
157
162
|
*/
|
|
158
|
-
export function Toolbar(props:
|
|
163
|
+
export function Toolbar(props: ToolbarComponentProps) {
|
|
159
164
|
const domRef = makeRef<HTMLDivElement>();
|
|
160
|
-
const options = fromProps(props);
|
|
165
|
+
const options = fromProps(cells(props));
|
|
161
166
|
|
|
162
167
|
const { toolbarProps } = toolbar({ ...(options as unknown as ToolbarOptions), ref: domRef });
|
|
163
168
|
|
|
164
169
|
const elementProps = mergeProps(
|
|
165
170
|
toolbarProps,
|
|
166
171
|
filterDOMProps(options, { global: true }),
|
|
167
|
-
styleProps(props),
|
|
172
|
+
styleProps(cells(props)),
|
|
168
173
|
{
|
|
169
|
-
"data-orientation": () => props.orientation
|
|
170
|
-
"data-testid": () => props["data-testid"]
|
|
174
|
+
"data-orientation": () => props.orientation ?? "horizontal",
|
|
175
|
+
"data-testid": () => props["data-testid"],
|
|
171
176
|
},
|
|
172
177
|
);
|
|
173
178
|
|
|
174
179
|
return (
|
|
175
|
-
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref
|
|
180
|
+
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref)}>
|
|
176
181
|
{props.children}
|
|
177
182
|
</div>
|
|
178
183
|
);
|
package/src/tooltip.tsx
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
+
cells,
|
|
25
26
|
type Accessor,
|
|
26
27
|
type Child,
|
|
27
28
|
createContext,
|
|
@@ -42,6 +43,7 @@ import { focusable } from "./interactions/focusable.ts";
|
|
|
42
43
|
import { hover } from "./interactions/hover.ts";
|
|
43
44
|
import { getInteractionModality, isFocusVisible, trackModality } from "./interactions/modality.ts";
|
|
44
45
|
import type { ElementRef } from "./interactions/press.ts";
|
|
46
|
+
import { OverlayArrowProvider } from "./overlay-arrow.tsx";
|
|
45
47
|
import {
|
|
46
48
|
alignOf,
|
|
47
49
|
followOpen,
|
|
@@ -60,6 +62,7 @@ import {
|
|
|
60
62
|
fromProps,
|
|
61
63
|
id,
|
|
62
64
|
type MaybeAccessor,
|
|
65
|
+
clearTriggerSlot,
|
|
63
66
|
mergeProps,
|
|
64
67
|
provideTriggerSlot,
|
|
65
68
|
type StyleProps,
|
|
@@ -81,7 +84,7 @@ const COOL_DOWN = 500;
|
|
|
81
84
|
* Two tooltips on screen at once is always a bug: the pointer is over one
|
|
82
85
|
* trigger, and the other is a leftover from the one it just left.
|
|
83
86
|
*/
|
|
84
|
-
const openTooltips = new Map<number, (immediate?: boolean
|
|
87
|
+
const openTooltips = new Map<number, (immediate?: boolean) => void>();
|
|
85
88
|
let nextTooltip = 0;
|
|
86
89
|
let warm = false;
|
|
87
90
|
let warmUpTimer: ReturnType<typeof setTimeout> | null = null;
|
|
@@ -124,10 +127,12 @@ export interface TooltipTriggerStateOptions extends OverlayTriggerStateOptions {
|
|
|
124
127
|
|
|
125
128
|
export interface TooltipTriggerState extends Omit<OverlayTriggerState, "open" | "close"> {
|
|
126
129
|
/**
|
|
127
|
-
* Whether
|
|
130
|
+
* Whether the tooltip showing now skipped its entrance animation.
|
|
128
131
|
*
|
|
129
|
-
* True while the group
|
|
130
|
-
* tooltip moving, not one fading
|
|
132
|
+
* True when it opened while the group was warm: swapping between two
|
|
133
|
+
* triggers is one tooltip moving, not one fading in after another. Never
|
|
134
|
+
* true once it is closing, since the exit plays either way, as Base UI's
|
|
135
|
+
* under shadcn's classes does.
|
|
131
136
|
*/
|
|
132
137
|
shouldSkipAnimation: Accessor<boolean>;
|
|
133
138
|
/**
|
|
@@ -154,7 +159,7 @@ export function tooltipTriggerState(options: TooltipTriggerStateOptions = {}): T
|
|
|
154
159
|
const closeOthers = (): void => {
|
|
155
160
|
for (const [other, hide] of openTooltips) {
|
|
156
161
|
if (other === key) continue;
|
|
157
|
-
hide(true
|
|
162
|
+
hide(true);
|
|
158
163
|
openTooltips.delete(other);
|
|
159
164
|
}
|
|
160
165
|
};
|
|
@@ -170,9 +175,7 @@ export function tooltipTriggerState(options: TooltipTriggerStateOptions = {}): T
|
|
|
170
175
|
coolDownTimer = clearTimer(coolDownTimer);
|
|
171
176
|
};
|
|
172
177
|
|
|
173
|
-
const hide = (immediate?: boolean
|
|
174
|
-
setSkipAnimation(instant === true);
|
|
175
|
-
|
|
178
|
+
const hide = (immediate?: boolean): void => {
|
|
176
179
|
if (immediate === true || closeDelay() <= 0) {
|
|
177
180
|
closeTimer = clearTimer(closeTimer);
|
|
178
181
|
overlay.close();
|
|
@@ -235,7 +238,7 @@ export function tooltipTriggerState(options: TooltipTriggerStateOptions = {}): T
|
|
|
235
238
|
isOpen: overlay.isOpen,
|
|
236
239
|
setOpen: overlay.setOpen,
|
|
237
240
|
toggle: overlay.toggle,
|
|
238
|
-
shouldSkipAnimation: skipAnimation,
|
|
241
|
+
shouldSkipAnimation: () => overlay.isOpen() && skipAnimation(),
|
|
239
242
|
isInstant,
|
|
240
243
|
open(immediate?: boolean) {
|
|
241
244
|
if (immediate !== true && delay() > 0 && closeTimer === null) {
|
|
@@ -541,20 +544,20 @@ export interface TooltipTriggerComponentProps {
|
|
|
541
544
|
* around it hears neither focus nor a description. A control this package does
|
|
542
545
|
* not provide spreads `useTooltipTrigger().triggerProps` by hand.
|
|
543
546
|
*/
|
|
544
|
-
export function TooltipTrigger(props:
|
|
547
|
+
export function TooltipTrigger(props: TooltipTriggerComponentProps) {
|
|
545
548
|
const triggerRef = makeRef<HTMLElement>();
|
|
546
|
-
const options = fromProps(props);
|
|
549
|
+
const options = fromProps(cells(props));
|
|
547
550
|
const group = useTooltipGroup();
|
|
548
551
|
const isContentHoverable = (): boolean =>
|
|
549
|
-
(props.isContentHoverable
|
|
552
|
+
(props.isContentHoverable ?? group?.isContentHoverable()) !== false;
|
|
550
553
|
const state = tooltipTriggerState({
|
|
551
554
|
...options,
|
|
552
|
-
delay: () => props.delay
|
|
553
|
-
skipDelay: () => props.skipDelay
|
|
555
|
+
delay: () => props.delay ?? group?.delay(),
|
|
556
|
+
skipDelay: () => props.skipDelay ?? group?.skipDelay(),
|
|
554
557
|
// The close delay is the time a pointer has to travel from the trigger to
|
|
555
558
|
// the tooltip, and with nothing to travel to it is only a tooltip that
|
|
556
559
|
// will not go away.
|
|
557
|
-
closeDelay: () => props.closeDelay
|
|
560
|
+
closeDelay: () => props.closeDelay ?? (isContentHoverable() ? undefined : 0),
|
|
558
561
|
});
|
|
559
562
|
|
|
560
563
|
const { triggerProps, tooltipProps } = tooltipTrigger(
|
|
@@ -599,31 +602,37 @@ export interface TooltipComponentProps extends StyleProps {
|
|
|
599
602
|
crossOffset?: number;
|
|
600
603
|
shouldFlip?: boolean;
|
|
601
604
|
containerPadding?: number;
|
|
605
|
+
/** The least distance between an arrow and the tooltip's ends. @default 0 */
|
|
606
|
+
arrowBoundaryOffset?: number;
|
|
602
607
|
ref?: RefTarget<HTMLDivElement>;
|
|
603
608
|
}
|
|
604
609
|
|
|
605
610
|
/**
|
|
606
611
|
* The tooltip, mounted only while it is showing.
|
|
607
612
|
*
|
|
608
|
-
* `data-skip-animation` marks the
|
|
609
|
-
*
|
|
610
|
-
*
|
|
613
|
+
* `data-skip-animation` marks the entrance a warm group makes: moving between
|
|
614
|
+
* two triggers is one tooltip changing place, and fading it in again reads as
|
|
615
|
+
* a flicker.
|
|
611
616
|
*/
|
|
612
|
-
export function Tooltip(props:
|
|
617
|
+
export function Tooltip(props: TooltipComponentProps) {
|
|
618
|
+
clearTriggerSlot();
|
|
613
619
|
const target = usePortalTarget();
|
|
614
620
|
const domRef = makeRef<HTMLDivElement>();
|
|
615
621
|
const trigger = useTooltipTrigger();
|
|
616
622
|
const locale = useLocale();
|
|
617
|
-
const placement = (): Placement => props.placement
|
|
623
|
+
const placement = (): Placement => props.placement ?? "top";
|
|
618
624
|
|
|
625
|
+
const arrowRef = makeRef<Element>();
|
|
619
626
|
const position = overlayPosition({
|
|
620
627
|
targetRef: trigger.triggerRef,
|
|
621
628
|
overlayRef: domRef,
|
|
629
|
+
arrowRef,
|
|
630
|
+
arrowBoundaryOffset: () => props.arrowBoundaryOffset,
|
|
622
631
|
placement,
|
|
623
|
-
offset: () => props.offset
|
|
624
|
-
crossOffset: () => props.crossOffset
|
|
625
|
-
shouldFlip: () => props.shouldFlip
|
|
626
|
-
containerPadding: () => props.containerPadding
|
|
632
|
+
offset: () => props.offset ?? 8,
|
|
633
|
+
crossOffset: () => props.crossOffset,
|
|
634
|
+
shouldFlip: () => props.shouldFlip,
|
|
635
|
+
containerPadding: () => props.containerPadding,
|
|
627
636
|
isOpen: trigger.state.isOpen,
|
|
628
637
|
direction: () => locale().direction,
|
|
629
638
|
});
|
|
@@ -634,22 +643,30 @@ export function Tooltip(props: Incoming<TooltipComponentProps>) {
|
|
|
634
643
|
tooltipProps,
|
|
635
644
|
trigger.tooltipProps,
|
|
636
645
|
position.overlayProps,
|
|
637
|
-
filterDOMProps(fromProps(props), { global: true }),
|
|
638
|
-
styleProps(props),
|
|
646
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
647
|
+
styleProps(cells(props)),
|
|
639
648
|
{
|
|
640
649
|
"data-placement": position.placement,
|
|
641
650
|
"data-side": position.placement,
|
|
642
651
|
"data-align": () => alignOf(placement()),
|
|
643
652
|
"data-skip-animation": trigger.state.shouldSkipAnimation,
|
|
644
|
-
"data-testid": () => props["data-testid"]
|
|
653
|
+
"data-testid": () => props["data-testid"],
|
|
645
654
|
},
|
|
646
655
|
);
|
|
647
656
|
|
|
648
657
|
return (
|
|
649
658
|
<Show when={trigger.state.isOpen()}>
|
|
650
659
|
<Portal mount={portalContainer(target)}>
|
|
651
|
-
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref
|
|
652
|
-
|
|
660
|
+
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref)}>
|
|
661
|
+
<OverlayArrowProvider
|
|
662
|
+
value={{
|
|
663
|
+
placement: position.placement,
|
|
664
|
+
arrowProps: position.arrowProps,
|
|
665
|
+
ref: arrowRef.set,
|
|
666
|
+
}}
|
|
667
|
+
>
|
|
668
|
+
{props.children}
|
|
669
|
+
</OverlayArrowProvider>
|
|
653
670
|
</div>
|
|
654
671
|
</Portal>
|
|
655
672
|
</Show>
|