@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/tabs.tsx
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import {
|
|
24
|
+
cells,
|
|
24
25
|
type Accessor,
|
|
25
26
|
type Child,
|
|
26
27
|
createEffect,
|
|
@@ -44,7 +45,11 @@ import {
|
|
|
44
45
|
} from "./collections.ts";
|
|
45
46
|
import { focusableWalker } from "./focus.ts";
|
|
46
47
|
import { focusRing } from "./focus.ts";
|
|
48
|
+
import { presence } from "./presence.ts";
|
|
49
|
+
import { SelectionIndicatorProvider } from "./selection-indicator.tsx";
|
|
50
|
+
import { SharedElementTransition } from "./shared-element-transition.tsx";
|
|
47
51
|
import { hover } from "./interactions/hover.ts";
|
|
52
|
+
import { router } from "./interactions/open-link.ts";
|
|
48
53
|
import type { ElementRef } from "./interactions/press.ts";
|
|
49
54
|
import { provideDirection, useDirection, useLocale, type ReadingDirection } from "./i18n.ts";
|
|
50
55
|
import {
|
|
@@ -56,6 +61,7 @@ import {
|
|
|
56
61
|
} from "./selection.ts";
|
|
57
62
|
import {
|
|
58
63
|
access,
|
|
64
|
+
callback,
|
|
59
65
|
controllable,
|
|
60
66
|
type DOMProps,
|
|
61
67
|
filterDOMProps,
|
|
@@ -506,14 +512,14 @@ export interface TabsComponentProps<T> extends StyleProps, ItemAccessors<T> {
|
|
|
506
512
|
* page, so the element is the same element throughout and its id and its
|
|
507
513
|
* labelling follow the selection.
|
|
508
514
|
*/
|
|
509
|
-
export function Tabs<T>(props:
|
|
510
|
-
const options = fromProps(props as unknown as Incoming<Record<string, unknown>>);
|
|
515
|
+
export function Tabs<T>(props: TabsComponentProps<T>) {
|
|
516
|
+
const options = fromProps(cells(props) as unknown as Incoming<Record<string, unknown>>);
|
|
511
517
|
const state = tabListState<T>({
|
|
512
518
|
...(options as TabListStateOptions<T>),
|
|
513
|
-
onSelectionChange: (key) => props.onSelectionChange?.(
|
|
519
|
+
onSelectionChange: (key) => props.onSelectionChange?.(key),
|
|
514
520
|
});
|
|
515
521
|
|
|
516
|
-
declareDirection(props.dir);
|
|
522
|
+
declareDirection(cells(props).dir);
|
|
517
523
|
|
|
518
524
|
const baseId = id();
|
|
519
525
|
const owner = getOwner();
|
|
@@ -521,18 +527,18 @@ export function Tabs<T>(props: Incoming<TabsComponentProps<T>>) {
|
|
|
521
527
|
const value: TabsContextValue = {
|
|
522
528
|
state: state,
|
|
523
529
|
baseId,
|
|
524
|
-
orientation: () => props.orientation
|
|
525
|
-
keyboardActivation: () => props.keyboardActivation
|
|
530
|
+
orientation: () => props.orientation ?? "horizontal",
|
|
531
|
+
keyboardActivation: () => props.keyboardActivation ?? "automatic",
|
|
526
532
|
};
|
|
527
533
|
install(owner, TabsContext, () => value);
|
|
528
534
|
}
|
|
529
535
|
|
|
530
536
|
const elementProps = mergeProps(
|
|
531
|
-
filterDOMProps(fromProps(props), { global: true }),
|
|
532
|
-
styleProps(props),
|
|
537
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
538
|
+
styleProps(cells(props)),
|
|
533
539
|
{
|
|
534
|
-
"data-orientation": () => props.orientation
|
|
535
|
-
"data-testid": () => props["data-testid"]
|
|
540
|
+
"data-orientation": () => props.orientation ?? "horizontal",
|
|
541
|
+
"data-testid": () => props["data-testid"],
|
|
536
542
|
},
|
|
537
543
|
);
|
|
538
544
|
|
|
@@ -547,7 +553,7 @@ export interface TabListComponentProps<T> extends StyleProps {
|
|
|
547
553
|
ref?: RefTarget<HTMLDivElement>;
|
|
548
554
|
}
|
|
549
555
|
|
|
550
|
-
export function TabList<T>(props:
|
|
556
|
+
export function TabList<T>(props: TabListComponentProps<T>) {
|
|
551
557
|
const domRef = makeRef<HTMLDivElement>();
|
|
552
558
|
const tabs = useTabs();
|
|
553
559
|
|
|
@@ -556,33 +562,35 @@ export function TabList<T>(props: Incoming<TabListComponentProps<T>>) {
|
|
|
556
562
|
ref: domRef,
|
|
557
563
|
orientation: tabs.orientation,
|
|
558
564
|
keyboardActivation: tabs.keyboardActivation,
|
|
559
|
-
"aria-label": () => props["aria-label"]
|
|
560
|
-
"aria-labelledby": () => props["aria-labelledby"]
|
|
565
|
+
"aria-label": () => props["aria-label"],
|
|
566
|
+
"aria-labelledby": () => props["aria-labelledby"],
|
|
561
567
|
},
|
|
562
568
|
tabs.state,
|
|
563
569
|
);
|
|
564
570
|
|
|
565
571
|
const elementProps = mergeProps(
|
|
566
572
|
tabListProps,
|
|
567
|
-
filterDOMProps(fromProps(props), { global: true }),
|
|
568
|
-
styleProps(props),
|
|
573
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
574
|
+
styleProps(cells(props)),
|
|
569
575
|
{
|
|
570
576
|
"data-orientation": tabs.orientation,
|
|
571
|
-
"data-testid": () => props["data-testid"]
|
|
577
|
+
"data-testid": () => props["data-testid"],
|
|
572
578
|
},
|
|
573
579
|
);
|
|
574
580
|
|
|
575
581
|
const render = props.children;
|
|
576
582
|
|
|
577
583
|
return (
|
|
578
|
-
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref
|
|
579
|
-
<
|
|
580
|
-
{(
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
584
|
+
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref)}>
|
|
585
|
+
<SharedElementTransition>
|
|
586
|
+
<For each={() => [...tabs.state.collection()]}>
|
|
587
|
+
{(node: Node<unknown>) => {
|
|
588
|
+
const rowOwner = getOwner();
|
|
589
|
+
if (rowOwner !== null) install(rowOwner, TabNodeContext, () => node);
|
|
590
|
+
return render(node.value as T);
|
|
591
|
+
}}
|
|
592
|
+
</For>
|
|
593
|
+
</SharedElementTransition>
|
|
586
594
|
</div>
|
|
587
595
|
);
|
|
588
596
|
}
|
|
@@ -597,8 +605,8 @@ export interface TabComponentProps extends StyleProps {
|
|
|
597
605
|
* One tab. Its key and disabled state come from the collection node the
|
|
598
606
|
* enclosing {@link TabList} is rendering.
|
|
599
607
|
*/
|
|
600
|
-
export function Tab(props:
|
|
601
|
-
const domRef = makeRef<
|
|
608
|
+
export function Tab(props: TabComponentProps) {
|
|
609
|
+
const domRef = makeRef<HTMLElement>();
|
|
602
610
|
const tabs = useTabs();
|
|
603
611
|
const node = useTabNode();
|
|
604
612
|
|
|
@@ -607,7 +615,7 @@ export function Tab(props: Incoming<TabComponentProps>) {
|
|
|
607
615
|
key: node.key,
|
|
608
616
|
ref: domRef,
|
|
609
617
|
baseId: tabs.baseId,
|
|
610
|
-
"aria-label": () => props["aria-label"]
|
|
618
|
+
"aria-label": () => props["aria-label"],
|
|
611
619
|
isDisabled: () => node.props?.isDisabled === true,
|
|
612
620
|
},
|
|
613
621
|
tabs.state,
|
|
@@ -620,8 +628,8 @@ export function Tab(props: Incoming<TabComponentProps>) {
|
|
|
620
628
|
tabProps,
|
|
621
629
|
hoverProps,
|
|
622
630
|
focusProps,
|
|
623
|
-
filterDOMProps(fromProps(props), { global: true }),
|
|
624
|
-
styleProps(props),
|
|
631
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
632
|
+
styleProps(cells(props)),
|
|
625
633
|
{
|
|
626
634
|
type: "button",
|
|
627
635
|
"data-selected": isSelected,
|
|
@@ -632,13 +640,37 @@ export function Tab(props: Incoming<TabComponentProps>) {
|
|
|
632
640
|
"data-disabled": isDisabled,
|
|
633
641
|
"data-state": () => (isSelected() ? "active" : "inactive"),
|
|
634
642
|
"data-orientation": tabs.orientation,
|
|
635
|
-
"data-testid": () => props["data-testid"]
|
|
643
|
+
"data-testid": () => props["data-testid"],
|
|
636
644
|
},
|
|
637
645
|
);
|
|
638
646
|
|
|
647
|
+
// A tab with an href is a real link, so a middle click and "copy link
|
|
648
|
+
// address" mean what they mean anywhere else. Choosing it still selects it,
|
|
649
|
+
// and the router follows it with the modifiers the press carried.
|
|
650
|
+
const href = node.props?.href;
|
|
651
|
+
if (typeof href === "string") {
|
|
652
|
+
const toHref = router().href;
|
|
653
|
+
const linkProps = mergeProps(elementProps, {
|
|
654
|
+
type: undefined,
|
|
655
|
+
href: () => (isDisabled() ? undefined : toHref(href)),
|
|
656
|
+
target: node.props?.target,
|
|
657
|
+
rel: node.props?.rel,
|
|
658
|
+
download: node.props?.download,
|
|
659
|
+
});
|
|
660
|
+
return (
|
|
661
|
+
<a {...linkProps} ref={mergeRefs(domRef.set, props.ref as RefTarget<HTMLElement>)}>
|
|
662
|
+
<SelectionIndicatorProvider isSelected={isSelected()}>
|
|
663
|
+
{props.children}
|
|
664
|
+
</SelectionIndicatorProvider>
|
|
665
|
+
</a>
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
|
|
639
669
|
return (
|
|
640
|
-
<button {...elementProps} ref={mergeRefs(domRef.set, props.ref
|
|
641
|
-
{
|
|
670
|
+
<button {...elementProps} ref={mergeRefs(domRef.set, props.ref)}>
|
|
671
|
+
<SelectionIndicatorProvider isSelected={isSelected()}>
|
|
672
|
+
{props.children}
|
|
673
|
+
</SelectionIndicatorProvider>
|
|
642
674
|
</button>
|
|
643
675
|
);
|
|
644
676
|
}
|
|
@@ -647,51 +679,128 @@ export interface TabPanelComponentProps<T> extends StyleProps {
|
|
|
647
679
|
/** What the selected tab shows. Given the selected item. */
|
|
648
680
|
children: ((item: T) => Child) | Child;
|
|
649
681
|
"aria-label"?: string;
|
|
682
|
+
/**
|
|
683
|
+
* Keep every tab's panel in the document, the unselected ones `hidden` and
|
|
684
|
+
* `inert`, so their state survives switching away and back.
|
|
685
|
+
*/
|
|
686
|
+
shouldForceMount?: boolean;
|
|
650
687
|
ref?: RefTarget<HTMLDivElement>;
|
|
651
688
|
}
|
|
652
689
|
|
|
653
|
-
|
|
690
|
+
/**
|
|
691
|
+
* A panel per tab, of which the selected one is shown.
|
|
692
|
+
*
|
|
693
|
+
* Each tab's panel is its own element, so a panel that is leaving can stay in
|
|
694
|
+
* the document, marked `data-exiting`, for as long as its exit animation runs
|
|
695
|
+
* while the new one comes in marked `data-entering`. With no animation the
|
|
696
|
+
* old panel is gone in the same tick and there is only ever one.
|
|
697
|
+
*/
|
|
698
|
+
export function TabPanel<T>(props: TabPanelComponentProps<T>) {
|
|
699
|
+
const tabs = useTabs();
|
|
700
|
+
return (
|
|
701
|
+
<For each={[...tabs.state.collection()]}>
|
|
702
|
+
{(node: Node<unknown>) => <OnePanel node={node} of={cells(props)} />}
|
|
703
|
+
</For>
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** Wait out the enter animations a stylesheet started on `element`. */
|
|
708
|
+
function afterEnterAnimations(element: Element, done: () => void): () => void {
|
|
709
|
+
let cancelled = false;
|
|
710
|
+
const frame = requestAnimationFrame(() => {
|
|
711
|
+
const source = element as Element & { getAnimations?: () => Animation[] };
|
|
712
|
+
const running = typeof source.getAnimations === "function" ? source.getAnimations() : [];
|
|
713
|
+
let left = running.length;
|
|
714
|
+
if (left === 0) {
|
|
715
|
+
if (!cancelled) done();
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
// Finished or cancelled, each one counts once.
|
|
719
|
+
const settle = (): void => {
|
|
720
|
+
left--;
|
|
721
|
+
if (left === 0 && !cancelled) done();
|
|
722
|
+
};
|
|
723
|
+
for (const animation of running) {
|
|
724
|
+
animation.addEventListener("finish", settle, { once: true });
|
|
725
|
+
animation.addEventListener("cancel", settle, { once: true });
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
return () => {
|
|
729
|
+
cancelled = true;
|
|
730
|
+
cancelAnimationFrame(frame);
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function OnePanel<T>(panel: { node: Node<unknown>; of: Incoming<TabPanelComponentProps<T>> }) {
|
|
735
|
+
const props = panel.of;
|
|
736
|
+
const key = panel.node.key;
|
|
654
737
|
const domRef = makeRef<HTMLDivElement>();
|
|
655
738
|
const tabs = useTabs();
|
|
656
739
|
|
|
740
|
+
const isSelected = (): boolean => tabs.state.selectedKey() === key;
|
|
741
|
+
const isMounted = (): boolean => isSelected() || props.shouldForceMount?.() === true;
|
|
742
|
+
const gate = presence({ isOpen: isSelected, ref: domRef });
|
|
743
|
+
const [isEntering, setEntering] = createSignal(false);
|
|
744
|
+
|
|
745
|
+
if (!isServer) {
|
|
746
|
+
createEffect(
|
|
747
|
+
() => [isSelected(), domRef()] as const,
|
|
748
|
+
([selected, element]) => {
|
|
749
|
+
if (!selected || element === null) return undefined;
|
|
750
|
+
setEntering(true);
|
|
751
|
+
return afterEnterAnimations(element, () => setEntering(false));
|
|
752
|
+
},
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
|
|
657
756
|
const { tabPanelProps } = tabPanel(
|
|
658
757
|
{
|
|
659
758
|
ref: domRef,
|
|
660
759
|
baseId: tabs.baseId,
|
|
760
|
+
key,
|
|
661
761
|
"aria-label": () => props["aria-label"]?.(),
|
|
662
762
|
},
|
|
663
763
|
tabs.state,
|
|
664
764
|
);
|
|
765
|
+
const { focusProps, isFocused, isFocusVisible } = focusRing();
|
|
665
766
|
|
|
666
767
|
const elementProps = mergeProps(
|
|
667
768
|
tabPanelProps,
|
|
769
|
+
focusProps,
|
|
668
770
|
filterDOMProps(fromProps(props), { global: true }),
|
|
669
771
|
styleProps(props),
|
|
670
772
|
{
|
|
671
|
-
|
|
773
|
+
// Kept for its state but not shown, and nothing in it reachable.
|
|
774
|
+
hidden: () => !isSelected() && !gate.isExiting(),
|
|
775
|
+
inert: () => !isSelected(),
|
|
776
|
+
"data-inert": () => (isSelected() ? undefined : "true"),
|
|
777
|
+
"data-state": () => (isSelected() ? "active" : "inactive"),
|
|
672
778
|
"data-orientation": tabs.orientation,
|
|
779
|
+
"data-focused": isFocused,
|
|
780
|
+
"data-focus-visible": isFocusVisible,
|
|
781
|
+
"data-entering": isEntering,
|
|
782
|
+
"data-exiting": gate.isExiting,
|
|
673
783
|
"data-testid": () => props["data-testid"]?.(),
|
|
674
784
|
},
|
|
675
785
|
);
|
|
676
786
|
|
|
677
|
-
//
|
|
678
|
-
//
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
787
|
+
// Either a render function, which `callback` hands back as it is, or the
|
|
788
|
+
// content itself, which it reads out of its Cell.
|
|
789
|
+
const renderPanel = (item: T | undefined): Child => {
|
|
790
|
+
const content = callback(
|
|
791
|
+
props.children as unknown as MaybeAccessor<((item: T | undefined) => Child) | undefined>,
|
|
792
|
+
) as unknown;
|
|
793
|
+
return typeof content === "function"
|
|
794
|
+
? (content as (item: T | undefined) => Child)(item)
|
|
795
|
+
: (content as Child);
|
|
796
|
+
};
|
|
682
797
|
|
|
683
798
|
return (
|
|
684
|
-
<
|
|
685
|
-
<
|
|
686
|
-
{(
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
// alone, so an item mutated in place does not discard the panel.
|
|
690
|
-
const selected = untrack(() => tabs.state.selectedItem());
|
|
691
|
-
return renderPanel(selected === null ? undefined : (selected.value as T));
|
|
692
|
-
}}
|
|
693
|
-
</Show>
|
|
694
|
-
</div>
|
|
799
|
+
<Show when={isMounted() || gate.isPresent()}>
|
|
800
|
+
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref?.())}>
|
|
801
|
+
{renderPanel(panel.node.value as T)}
|
|
802
|
+
</div>
|
|
803
|
+
</Show>
|
|
695
804
|
);
|
|
696
805
|
}
|
|
697
806
|
|
|
@@ -783,12 +892,12 @@ export interface ValueTabsComponentProps extends StyleProps {
|
|
|
783
892
|
* - **A disabled tab stays focusable by pointer and is skipped by the arrows**,
|
|
784
893
|
* as in {@link Tabs}, so it can still be announced as disabled.
|
|
785
894
|
*/
|
|
786
|
-
export function ValueTabs(props:
|
|
895
|
+
export function ValueTabs(props: ValueTabsComponentProps) {
|
|
787
896
|
const [chosen, setChosen] = controllable<string | null>(
|
|
788
|
-
() => props.value
|
|
789
|
-
() => props.defaultValue
|
|
897
|
+
() => props.value,
|
|
898
|
+
() => props.defaultValue ?? null,
|
|
790
899
|
(next) => {
|
|
791
|
-
if (next !== null) props.onValueChange?.(
|
|
900
|
+
if (next !== null) props.onValueChange?.(next);
|
|
792
901
|
},
|
|
793
902
|
);
|
|
794
903
|
|
|
@@ -799,9 +908,9 @@ export function ValueTabs(props: Incoming<ValueTabsComponentProps>) {
|
|
|
799
908
|
const [adopted, setAdopted] = createSignal<string | null>(null, { ownedWrite: true });
|
|
800
909
|
|
|
801
910
|
const value = (): string | null => chosen() ?? adopted();
|
|
802
|
-
const orientation = (): Orientation => props.orientation
|
|
911
|
+
const orientation = (): Orientation => props.orientation ?? "horizontal";
|
|
803
912
|
|
|
804
|
-
declareDirection(props.dir);
|
|
913
|
+
declareDirection(cells(props).dir);
|
|
805
914
|
|
|
806
915
|
const owner = getOwner();
|
|
807
916
|
if (owner !== null) {
|
|
@@ -817,18 +926,18 @@ export function ValueTabs(props: Incoming<ValueTabsComponentProps>) {
|
|
|
817
926
|
},
|
|
818
927
|
baseId: id(),
|
|
819
928
|
orientation,
|
|
820
|
-
activationMode: () => props.activationMode
|
|
821
|
-
isDisabled: () => props.isDisabled
|
|
929
|
+
activationMode: () => props.activationMode ?? "automatic",
|
|
930
|
+
isDisabled: () => props.isDisabled === true,
|
|
822
931
|
};
|
|
823
932
|
install(owner, ValueTabsContext, () => context);
|
|
824
933
|
}
|
|
825
934
|
|
|
826
935
|
const elementProps = mergeProps(
|
|
827
|
-
filterDOMProps(fromProps(props), { global: true }),
|
|
828
|
-
styleProps(props),
|
|
936
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
937
|
+
styleProps(cells(props)),
|
|
829
938
|
{
|
|
830
939
|
"data-orientation": orientation,
|
|
831
|
-
"data-testid": () => props["data-testid"]
|
|
940
|
+
"data-testid": () => props["data-testid"],
|
|
832
941
|
},
|
|
833
942
|
);
|
|
834
943
|
|
|
@@ -844,7 +953,7 @@ export interface ValueTabListComponentProps extends StyleProps {
|
|
|
844
953
|
ref?: RefTarget<HTMLDivElement>;
|
|
845
954
|
}
|
|
846
955
|
|
|
847
|
-
export function ValueTabList(props:
|
|
956
|
+
export function ValueTabList(props: ValueTabListComponentProps) {
|
|
848
957
|
const tabs = requireValueTabs();
|
|
849
958
|
const direction = useDirection();
|
|
850
959
|
|
|
@@ -871,7 +980,7 @@ export function ValueTabList(props: Incoming<ValueTabListComponentProps>) {
|
|
|
871
980
|
const step = (by: 1 | -1): HTMLElement | undefined => {
|
|
872
981
|
const next = at + by;
|
|
873
982
|
if (next >= 0 && next < stops.length) return stops[next];
|
|
874
|
-
if (props.loop
|
|
983
|
+
if (props.loop === false) return undefined;
|
|
875
984
|
return by === 1 ? stops[0] : stops[stops.length - 1];
|
|
876
985
|
};
|
|
877
986
|
|
|
@@ -892,19 +1001,19 @@ export function ValueTabList(props: Incoming<ValueTabListComponentProps>) {
|
|
|
892
1001
|
};
|
|
893
1002
|
|
|
894
1003
|
const elementProps = mergeProps(
|
|
895
|
-
filterDOMProps(fromProps(props), { global: true, labelable: true }),
|
|
896
|
-
styleProps(props),
|
|
1004
|
+
filterDOMProps(fromProps(cells(props)), { global: true, labelable: true }),
|
|
1005
|
+
styleProps(cells(props)),
|
|
897
1006
|
{
|
|
898
1007
|
role: "tablist",
|
|
899
1008
|
"aria-orientation": tabs.orientation,
|
|
900
1009
|
"data-orientation": tabs.orientation,
|
|
901
|
-
"data-testid": () => props["data-testid"]
|
|
1010
|
+
"data-testid": () => props["data-testid"],
|
|
902
1011
|
onKeyDown,
|
|
903
1012
|
},
|
|
904
1013
|
);
|
|
905
1014
|
|
|
906
1015
|
return (
|
|
907
|
-
<div {...elementProps} ref={mergeRefs(props.ref
|
|
1016
|
+
<div {...elementProps} ref={mergeRefs(props.ref)}>
|
|
908
1017
|
{props.children}
|
|
909
1018
|
</div>
|
|
910
1019
|
);
|
|
@@ -918,36 +1027,36 @@ export interface ValueTabComponentProps extends StyleProps {
|
|
|
918
1027
|
ref?: RefTarget<HTMLButtonElement>;
|
|
919
1028
|
}
|
|
920
1029
|
|
|
921
|
-
export function ValueTab(props:
|
|
1030
|
+
export function ValueTab(props: ValueTabComponentProps) {
|
|
922
1031
|
const tabs = requireValueTabs();
|
|
923
1032
|
|
|
924
|
-
const isSelected = (): boolean => tabs.value() === props.value
|
|
925
|
-
const isDisabled = (): boolean => tabs.isDisabled() || props.isDisabled
|
|
1033
|
+
const isSelected = (): boolean => tabs.value() === props.value;
|
|
1034
|
+
const isDisabled = (): boolean => tabs.isDisabled() || props.isDisabled === true;
|
|
926
1035
|
|
|
927
|
-
if (!untrack(isDisabled)) tabs.adopt(untrack(() => props.value
|
|
1036
|
+
if (!untrack(isDisabled)) tabs.adopt(untrack(() => props.value));
|
|
928
1037
|
|
|
929
1038
|
const { hoverProps, isHovered } = hover({ isDisabled });
|
|
930
1039
|
const { focusProps, isFocused, isFocusVisible } = focusRing();
|
|
931
1040
|
|
|
932
1041
|
const select = (): void => {
|
|
933
|
-
if (!isDisabled()) tabs.select(props.value
|
|
1042
|
+
if (!isDisabled()) tabs.select(props.value);
|
|
934
1043
|
};
|
|
935
1044
|
|
|
936
1045
|
const elementProps = mergeProps(
|
|
937
1046
|
hoverProps,
|
|
938
1047
|
focusProps,
|
|
939
|
-
filterDOMProps(fromProps(props), { global: true, labelable: true }),
|
|
940
|
-
styleProps(props),
|
|
1048
|
+
filterDOMProps(fromProps(cells(props)), { global: true, labelable: true }),
|
|
1049
|
+
styleProps(cells(props)),
|
|
941
1050
|
{
|
|
942
1051
|
type: "button",
|
|
943
1052
|
role: "tab",
|
|
944
|
-
id: () => valuePartId(tabs.baseId(), props.value
|
|
1053
|
+
id: () => valuePartId(tabs.baseId(), props.value, "tab"),
|
|
945
1054
|
"aria-selected": isSelected,
|
|
946
1055
|
"aria-disabled": () => isDisabled() || undefined,
|
|
947
1056
|
// Only the SELECTED tab controls a panel: the others control nothing
|
|
948
1057
|
// that is on the page.
|
|
949
1058
|
"aria-controls": () =>
|
|
950
|
-
isSelected() ? valuePartId(tabs.baseId(), props.value
|
|
1059
|
+
isSelected() ? valuePartId(tabs.baseId(), props.value, "tabpanel") : undefined,
|
|
951
1060
|
tabIndex: () => (isSelected() ? 0 : -1),
|
|
952
1061
|
"data-selected": isSelected,
|
|
953
1062
|
"data-focused": isFocused,
|
|
@@ -956,7 +1065,7 @@ export function ValueTab(props: Incoming<ValueTabComponentProps>) {
|
|
|
956
1065
|
"data-disabled": isDisabled,
|
|
957
1066
|
"data-state": () => (isSelected() ? "active" : "inactive"),
|
|
958
1067
|
"data-orientation": tabs.orientation,
|
|
959
|
-
"data-testid": () => props["data-testid"]
|
|
1068
|
+
"data-testid": () => props["data-testid"],
|
|
960
1069
|
onClick: select,
|
|
961
1070
|
onKeyDown: (event: KeyboardEvent) => {
|
|
962
1071
|
if (event.key === "Enter" || event.key === " ") select();
|
|
@@ -968,7 +1077,7 @@ export function ValueTab(props: Incoming<ValueTabComponentProps>) {
|
|
|
968
1077
|
);
|
|
969
1078
|
|
|
970
1079
|
return (
|
|
971
|
-
<button {...elementProps} ref={mergeRefs(props.ref
|
|
1080
|
+
<button {...elementProps} ref={mergeRefs(props.ref)}>
|
|
972
1081
|
{props.children}
|
|
973
1082
|
</button>
|
|
974
1083
|
);
|
|
@@ -983,34 +1092,34 @@ export interface ValueTabPanelComponentProps extends StyleProps {
|
|
|
983
1092
|
ref?: RefTarget<HTMLDivElement>;
|
|
984
1093
|
}
|
|
985
1094
|
|
|
986
|
-
export function ValueTabPanel(props:
|
|
1095
|
+
export function ValueTabPanel(props: ValueTabPanelComponentProps) {
|
|
987
1096
|
const domRef = makeRef<HTMLDivElement>();
|
|
988
1097
|
const tabs = requireValueTabs();
|
|
989
1098
|
|
|
990
|
-
const isSelected = (): boolean => tabs.value() === props.value
|
|
991
|
-
const focusable = hasTabbableChild(domRef, () => (isSelected() ? props.value
|
|
1099
|
+
const isSelected = (): boolean => tabs.value() === props.value;
|
|
1100
|
+
const focusable = hasTabbableChild(domRef, () => (isSelected() ? props.value : null));
|
|
992
1101
|
|
|
993
1102
|
const elementProps = mergeProps(
|
|
994
|
-
filterDOMProps(fromProps(props), { global: true, labelable: true }),
|
|
995
|
-
styleProps(props),
|
|
1103
|
+
filterDOMProps(fromProps(cells(props)), { global: true, labelable: true }),
|
|
1104
|
+
styleProps(cells(props)),
|
|
996
1105
|
{
|
|
997
1106
|
role: "tabpanel",
|
|
998
|
-
id: () => valuePartId(tabs.baseId(), props.value
|
|
1107
|
+
id: () => valuePartId(tabs.baseId(), props.value, "tabpanel"),
|
|
999
1108
|
"aria-labelledby": () =>
|
|
1000
|
-
props["aria-label"]
|
|
1001
|
-
? valuePartId(tabs.baseId(), props.value
|
|
1109
|
+
props["aria-label"] === undefined
|
|
1110
|
+
? valuePartId(tabs.baseId(), props.value, "tab")
|
|
1002
1111
|
: undefined,
|
|
1003
1112
|
tabIndex: () => (focusable() ? undefined : 0),
|
|
1004
1113
|
hidden: () => !isSelected(),
|
|
1005
1114
|
"data-state": () => (isSelected() ? "active" : "inactive"),
|
|
1006
1115
|
"data-orientation": tabs.orientation,
|
|
1007
|
-
"data-testid": () => props["data-testid"]
|
|
1116
|
+
"data-testid": () => props["data-testid"],
|
|
1008
1117
|
},
|
|
1009
1118
|
);
|
|
1010
1119
|
|
|
1011
1120
|
return (
|
|
1012
|
-
<Show when={isSelected() || props.forceMount
|
|
1013
|
-
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref
|
|
1121
|
+
<Show when={isSelected() || props.forceMount === true}>
|
|
1122
|
+
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref)}>
|
|
1014
1123
|
{props.children}
|
|
1015
1124
|
</div>
|
|
1016
1125
|
</Show>
|