@proyecto-viviana/solidaria-components 0.3.1 → 0.3.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/dist/Button.d.ts.map +1 -1
- package/dist/ComboBox.d.ts +4 -1
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/Menu.d.ts.map +1 -1
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts.map +1 -1
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/TextField.d.ts +1 -0
- package/dist/TextField.d.ts.map +1 -1
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/index.js +254 -33
- package/dist/index.js.map +1 -1
- package/dist/index.jsx +254 -33
- package/dist/index.jsx.map +1 -1
- package/package.json +1 -1
- package/src/Button.tsx +69 -22
- package/src/ComboBox.tsx +77 -9
- package/src/DatePicker.tsx +60 -5
- package/src/Menu.tsx +49 -6
- package/src/NumberField.tsx +22 -2
- package/src/Popover.tsx +9 -1
- package/src/TagGroup.tsx +1 -0
- package/src/TextField.tsx +32 -7
- package/src/Tooltip.tsx +52 -7
package/dist/index.js
CHANGED
|
@@ -383,6 +383,38 @@ function createLiveCustomRootProps(getProps, getChildren, ref) {
|
|
|
383
383
|
});
|
|
384
384
|
return props;
|
|
385
385
|
}
|
|
386
|
+
const buttonAriaOverrideProps = [
|
|
387
|
+
"aria-label",
|
|
388
|
+
"aria-labelledby",
|
|
389
|
+
"aria-describedby",
|
|
390
|
+
"aria-details",
|
|
391
|
+
"aria-haspopup",
|
|
392
|
+
"aria-expanded",
|
|
393
|
+
"aria-controls",
|
|
394
|
+
"aria-pressed",
|
|
395
|
+
"aria-current",
|
|
396
|
+
"aria-disabled"
|
|
397
|
+
];
|
|
398
|
+
function createForwardedAriaButtonProps(source, overrides) {
|
|
399
|
+
const result = {};
|
|
400
|
+
for (const key in source) Object.defineProperty(result, key, {
|
|
401
|
+
enumerable: true,
|
|
402
|
+
configurable: true,
|
|
403
|
+
get() {
|
|
404
|
+
return source[key];
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
for (const key in overrides) {
|
|
408
|
+
const descriptor = Object.getOwnPropertyDescriptor(overrides, key);
|
|
409
|
+
if (!descriptor) continue;
|
|
410
|
+
Object.defineProperty(result, key, {
|
|
411
|
+
...descriptor,
|
|
412
|
+
enumerable: true,
|
|
413
|
+
configurable: true
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
return result;
|
|
417
|
+
}
|
|
386
418
|
const ButtonContext = createContext(null);
|
|
387
419
|
/**
|
|
388
420
|
* A button allows a user to perform an action.
|
|
@@ -442,8 +474,7 @@ function Button(props) {
|
|
|
442
474
|
if (isDialogTrigger()) dialogTriggerContext.state.toggle();
|
|
443
475
|
if (isPopoverTrigger()) popoverTriggerContext.state.toggle();
|
|
444
476
|
};
|
|
445
|
-
const buttonAria = createButton({
|
|
446
|
-
...ariaProps,
|
|
477
|
+
const buttonAria = createButton(createForwardedAriaButtonProps(ariaProps, {
|
|
447
478
|
onPress: handlePress,
|
|
448
479
|
get onPressStart() {
|
|
449
480
|
return resolvePending() ? void 0 : ariaProps.onPressStart;
|
|
@@ -463,7 +494,7 @@ function Button(props) {
|
|
|
463
494
|
get isDisabled() {
|
|
464
495
|
return resolveDisabled() || resolvePending();
|
|
465
496
|
}
|
|
466
|
-
});
|
|
497
|
+
}));
|
|
467
498
|
const { isFocused, isFocusVisible, focusProps } = createFocusRing();
|
|
468
499
|
const { isHovered, hoverProps } = createHover({
|
|
469
500
|
get isDisabled() {
|
|
@@ -550,6 +581,11 @@ function Button(props) {
|
|
|
550
581
|
]) if (triggerProps[name] != null) next[name] = triggerProps[name];
|
|
551
582
|
return next;
|
|
552
583
|
};
|
|
584
|
+
const directAriaProps = () => {
|
|
585
|
+
const next = {};
|
|
586
|
+
for (const name of buttonAriaOverrideProps) next[name] = ariaProps[name];
|
|
587
|
+
return next;
|
|
588
|
+
};
|
|
553
589
|
const disablePendingInteractions = (props) => {
|
|
554
590
|
if (!resolvePending()) return props;
|
|
555
591
|
const next = { ...props };
|
|
@@ -577,6 +613,7 @@ function Button(props) {
|
|
|
577
613
|
const rootProps = () => ({
|
|
578
614
|
...domProps(),
|
|
579
615
|
...disablePendingInteractions(cleanButtonProps()),
|
|
616
|
+
...directAriaProps(),
|
|
580
617
|
...triggerAriaProps(),
|
|
581
618
|
...cleanFocusProps(),
|
|
582
619
|
...cleanHoverProps(),
|
|
@@ -2606,6 +2643,12 @@ function clearDelegatedTextEntryHandlers$1(element) {
|
|
|
2606
2643
|
function Input(props) {
|
|
2607
2644
|
const context = useContext(TextFieldContext);
|
|
2608
2645
|
let inputElement;
|
|
2646
|
+
createEffect(() => {
|
|
2647
|
+
context?.setInputId?.(props.id);
|
|
2648
|
+
});
|
|
2649
|
+
onCleanup(() => {
|
|
2650
|
+
context?.setInputId?.(void 0);
|
|
2651
|
+
});
|
|
2609
2652
|
const mergedProps = () => {
|
|
2610
2653
|
if (context) {
|
|
2611
2654
|
const { ref: _ref, ...contextInputProps } = context.inputProps ?? {};
|
|
@@ -2664,6 +2707,12 @@ function Input(props) {
|
|
|
2664
2707
|
function TextArea(props) {
|
|
2665
2708
|
const context = useContext(TextFieldContext);
|
|
2666
2709
|
let textAreaElement;
|
|
2710
|
+
createEffect(() => {
|
|
2711
|
+
context?.setInputId?.(props.id);
|
|
2712
|
+
});
|
|
2713
|
+
onCleanup(() => {
|
|
2714
|
+
context?.setInputId?.(void 0);
|
|
2715
|
+
});
|
|
2667
2716
|
const mergedProps = () => {
|
|
2668
2717
|
if (context) {
|
|
2669
2718
|
const { ref: _ref, type: _type, ...contextInputProps } = context.inputProps ?? {};
|
|
@@ -2738,7 +2787,7 @@ function TextField(props) {
|
|
|
2738
2787
|
const contextSlotProps = contextProps?.slots?.[props.slot ?? "default"];
|
|
2739
2788
|
const contextBaseProps = createMemo(() => {
|
|
2740
2789
|
if (!contextProps) return {};
|
|
2741
|
-
const { labelProps: _labelProps, inputProps: _inputProps, descriptionProps: _descriptionProps, errorMessageProps: _errorMessageProps, isInvalid: _isInvalid, slots: _slots, ...rest } = contextProps;
|
|
2790
|
+
const { labelProps: _labelProps, inputProps: _inputProps, descriptionProps: _descriptionProps, errorMessageProps: _errorMessageProps, isInvalid: _isInvalid, slots: _slots, setInputId: _setInputId, ...rest } = contextProps;
|
|
2742
2791
|
return rest;
|
|
2743
2792
|
});
|
|
2744
2793
|
const [local, ariaProps] = splitProps(withFormValidationBehavior$4(contextProps ? mergeProps$2(contextBaseProps(), contextSlotProps ?? {}, props) : props, formContext), [
|
|
@@ -2773,6 +2822,7 @@ function TextField(props) {
|
|
|
2773
2822
|
const { isHovered, hoverProps } = createHover({ get isDisabled() {
|
|
2774
2823
|
return ariaProps.isDisabled;
|
|
2775
2824
|
} });
|
|
2825
|
+
const [inputIdOverride, setInputIdOverride] = createSignal();
|
|
2776
2826
|
const renderValues = createMemo(() => ({
|
|
2777
2827
|
isDisabled: ariaProps.isDisabled || false,
|
|
2778
2828
|
isInvalid: textFieldAria.isInvalid,
|
|
@@ -2858,10 +2908,13 @@ function TextField(props) {
|
|
|
2858
2908
|
return textFieldAria.isInvalid;
|
|
2859
2909
|
},
|
|
2860
2910
|
get inputId() {
|
|
2861
|
-
return textFieldAria.inputProps.id;
|
|
2911
|
+
return inputIdOverride() ?? textFieldAria.inputProps.id;
|
|
2912
|
+
},
|
|
2913
|
+
setInputId(id) {
|
|
2914
|
+
setInputIdOverride(id);
|
|
2862
2915
|
}
|
|
2863
2916
|
};
|
|
2864
|
-
const
|
|
2917
|
+
const FieldChildren = () => untrack(() => {
|
|
2865
2918
|
const children = local.children;
|
|
2866
2919
|
return typeof children === "function" ? children(childRenderValues) : children;
|
|
2867
2920
|
});
|
|
@@ -2881,7 +2934,7 @@ function TextField(props) {
|
|
|
2881
2934
|
});
|
|
2882
2935
|
const customRootProps = () => ({
|
|
2883
2936
|
...rootProps(),
|
|
2884
|
-
children:
|
|
2937
|
+
children: createComponent(FieldChildren, {})
|
|
2885
2938
|
});
|
|
2886
2939
|
return createComponent(FieldErrorContext.Provider, {
|
|
2887
2940
|
value: fieldErrorContext,
|
|
@@ -2892,7 +2945,7 @@ function TextField(props) {
|
|
|
2892
2945
|
return memo(() => !!local.render)() ? local.render(customRootProps(), renderValues()) : (() => {
|
|
2893
2946
|
var _el$4 = getNextElement(_tmpl$4$19);
|
|
2894
2947
|
spread(_el$4, mergeProps(rootProps), false, true);
|
|
2895
|
-
insert(_el$4,
|
|
2948
|
+
insert(_el$4, createComponent(FieldChildren, {}));
|
|
2896
2949
|
runHydrationEvents();
|
|
2897
2950
|
return _el$4;
|
|
2898
2951
|
})();
|
|
@@ -5713,6 +5766,7 @@ function SubmenuTrigger(props) {
|
|
|
5713
5766
|
const triggerId = createUniqueId();
|
|
5714
5767
|
const menuId = createUniqueId();
|
|
5715
5768
|
let hoverTimeout;
|
|
5769
|
+
let hasPointerHover = false;
|
|
5716
5770
|
const delay = () => props.delay ?? 200;
|
|
5717
5771
|
const clearHoverTimeout = () => {
|
|
5718
5772
|
if (hoverTimeout != null) {
|
|
@@ -5724,6 +5778,12 @@ function SubmenuTrigger(props) {
|
|
|
5724
5778
|
clearHoverTimeout();
|
|
5725
5779
|
state.open();
|
|
5726
5780
|
};
|
|
5781
|
+
const queueOpenSubmenu = () => {
|
|
5782
|
+
clearHoverTimeout();
|
|
5783
|
+
const open = () => state.open();
|
|
5784
|
+
if (typeof queueMicrotask === "function") queueMicrotask(open);
|
|
5785
|
+
else Promise.resolve().then(open);
|
|
5786
|
+
};
|
|
5727
5787
|
const scheduleOpen = () => {
|
|
5728
5788
|
clearHoverTimeout();
|
|
5729
5789
|
hoverTimeout = window.setTimeout(() => {
|
|
@@ -5731,6 +5791,19 @@ function SubmenuTrigger(props) {
|
|
|
5731
5791
|
state.open();
|
|
5732
5792
|
}, delay());
|
|
5733
5793
|
};
|
|
5794
|
+
const schedulePointerOpen = (event) => {
|
|
5795
|
+
hasPointerHover = true;
|
|
5796
|
+
if (event.isTrusted === false) {
|
|
5797
|
+
queueOpenSubmenu();
|
|
5798
|
+
return;
|
|
5799
|
+
}
|
|
5800
|
+
scheduleOpen();
|
|
5801
|
+
};
|
|
5802
|
+
const openFromMouseHover = () => {
|
|
5803
|
+
if (state.isOpen()) return;
|
|
5804
|
+
if (hasPointerHover) scheduleOpen();
|
|
5805
|
+
else queueOpenSubmenu();
|
|
5806
|
+
};
|
|
5734
5807
|
onCleanup(clearHoverTimeout);
|
|
5735
5808
|
const menuTriggerContext = createMemo(() => ({
|
|
5736
5809
|
state,
|
|
@@ -5763,17 +5836,22 @@ function SubmenuTrigger(props) {
|
|
|
5763
5836
|
props: () => ({
|
|
5764
5837
|
id: triggerId,
|
|
5765
5838
|
"aria-haspopup": "menu",
|
|
5766
|
-
"aria-expanded"
|
|
5767
|
-
|
|
5839
|
+
get "aria-expanded"() {
|
|
5840
|
+
return state.isOpen() || void 0;
|
|
5841
|
+
},
|
|
5842
|
+
get "aria-controls"() {
|
|
5843
|
+
return state.isOpen() ? menuId : void 0;
|
|
5844
|
+
},
|
|
5768
5845
|
onPointerEnter: (event) => {
|
|
5769
5846
|
if (event.pointerType === "touch") return;
|
|
5770
|
-
|
|
5847
|
+
schedulePointerOpen(event);
|
|
5771
5848
|
},
|
|
5772
5849
|
onPointerOver: (event) => {
|
|
5773
5850
|
if (event.pointerType === "touch") return;
|
|
5774
|
-
|
|
5851
|
+
schedulePointerOpen(event);
|
|
5775
5852
|
},
|
|
5776
|
-
onMouseEnter:
|
|
5853
|
+
onMouseEnter: openFromMouseHover,
|
|
5854
|
+
onMouseOver: openFromMouseHover,
|
|
5777
5855
|
onKeyDown: (event) => {
|
|
5778
5856
|
if (event.key === "ArrowRight" || event.key === "Enter" || event.key === " ") {
|
|
5779
5857
|
event.preventDefault();
|
|
@@ -6234,6 +6312,7 @@ function Menu(props) {
|
|
|
6234
6312
|
renderItem: (item) => renderDynamicItem(item),
|
|
6235
6313
|
renderDropIndicator: (index, position) => dndDropIndicator(index, position) ?? parentCollectionRenderer?.renderDropIndicator?.(index, position)
|
|
6236
6314
|
}));
|
|
6315
|
+
const menuItemContextValue = createMemo(() => local.shouldCloseOnSelect !== void 0 ? { closeOnSelect: local.shouldCloseOnSelect } : {});
|
|
6237
6316
|
const menuListChildren = () => createComponent(SharedElementTransition, { get children() {
|
|
6238
6317
|
return memo(() => !!(state.collection().size === 0 && !usesStaticChildren() && local.renderEmptyState))() ? (() => {
|
|
6239
6318
|
var _el$2 = getNextElement(_tmpl$2$28), _el$3 = _el$2.firstChild;
|
|
@@ -6347,7 +6426,7 @@ function Menu(props) {
|
|
|
6347
6426
|
get children() {
|
|
6348
6427
|
return createComponent(MenuItemContext.Provider, {
|
|
6349
6428
|
get value() {
|
|
6350
|
-
return
|
|
6429
|
+
return menuItemContextValue();
|
|
6351
6430
|
},
|
|
6352
6431
|
get children() {
|
|
6353
6432
|
return createComponent(CollectionRendererContext.Provider, {
|
|
@@ -9483,8 +9562,12 @@ function NumberFieldIncrementButton(props) {
|
|
|
9483
9562
|
const context = useContext(NumberFieldContext);
|
|
9484
9563
|
if (!context) throw new Error("NumberFieldIncrementButton must be used within a NumberField");
|
|
9485
9564
|
const isDisabled = () => context.isDisabled || !context.state.canIncrement();
|
|
9565
|
+
const pressButtonProps = () => {
|
|
9566
|
+
const { onClick: _onClick, disabled: _disabled, type: _type, tabIndex: _tabIndex, ...rest } = context.incrementButtonProps;
|
|
9567
|
+
return rest;
|
|
9568
|
+
};
|
|
9486
9569
|
const buttonAria = createButton({
|
|
9487
|
-
...
|
|
9570
|
+
...pressButtonProps(),
|
|
9488
9571
|
elementType: "div",
|
|
9489
9572
|
get isDisabled() {
|
|
9490
9573
|
return isDisabled();
|
|
@@ -9552,8 +9635,12 @@ function NumberFieldDecrementButton(props) {
|
|
|
9552
9635
|
const context = useContext(NumberFieldContext);
|
|
9553
9636
|
if (!context) throw new Error("NumberFieldDecrementButton must be used within a NumberField");
|
|
9554
9637
|
const isDisabled = () => context.isDisabled || !context.state.canDecrement();
|
|
9638
|
+
const pressButtonProps = () => {
|
|
9639
|
+
const { onClick: _onClick, disabled: _disabled, type: _type, tabIndex: _tabIndex, ...rest } = context.decrementButtonProps;
|
|
9640
|
+
return rest;
|
|
9641
|
+
};
|
|
9555
9642
|
const buttonAria = createButton({
|
|
9556
|
-
...
|
|
9643
|
+
...pressButtonProps(),
|
|
9557
9644
|
elementType: "div",
|
|
9558
9645
|
get isDisabled() {
|
|
9559
9646
|
return isDisabled();
|
|
@@ -10638,7 +10725,7 @@ Slider.Output = SliderOutput;
|
|
|
10638
10725
|
* A tooltip displays a description of an element on hover or focus.
|
|
10639
10726
|
* Port of react-aria-components/src/Tooltip.tsx
|
|
10640
10727
|
*/
|
|
10641
|
-
var _tmpl$$26 = /* @__PURE__ */ template(`<span
|
|
10728
|
+
var _tmpl$$26 = /* @__PURE__ */ template(`<span>`), _tmpl$2$21 = /* @__PURE__ */ template(`<div>`);
|
|
10642
10729
|
const TooltipTriggerContext = createContext(null);
|
|
10643
10730
|
const TooltipContext = TooltipTriggerContext;
|
|
10644
10731
|
const TooltipTriggerStateContext = createContext(null);
|
|
@@ -10732,6 +10819,30 @@ const TooltipTrigger = (props) => {
|
|
|
10732
10819
|
const TriggerWrapper = (props) => {
|
|
10733
10820
|
const child = () => props.children;
|
|
10734
10821
|
const [triggerElement, setTriggerElement] = createSignal(null);
|
|
10822
|
+
const [wrapperElement, setWrapperElement] = createSignal(null);
|
|
10823
|
+
const getWrapperEventProps = () => {
|
|
10824
|
+
const triggerProps = props.triggerProps;
|
|
10825
|
+
const wrapperProps = {};
|
|
10826
|
+
for (const propName of [
|
|
10827
|
+
"onFocus",
|
|
10828
|
+
"onBlur",
|
|
10829
|
+
"onPointerEnter",
|
|
10830
|
+
"onPointerLeave",
|
|
10831
|
+
"onPointerOver",
|
|
10832
|
+
"onPointerOut",
|
|
10833
|
+
"onMouseEnter",
|
|
10834
|
+
"onMouseLeave",
|
|
10835
|
+
"onTouchStart",
|
|
10836
|
+
"onPointerDown",
|
|
10837
|
+
"onKeyDown"
|
|
10838
|
+
]) {
|
|
10839
|
+
const handler = triggerProps[propName];
|
|
10840
|
+
if (typeof handler === "function") wrapperProps[propName] = handler;
|
|
10841
|
+
}
|
|
10842
|
+
if (!wrapperProps.onPointerEnter && typeof triggerProps.onMouseEnter === "function") wrapperProps.onPointerEnter = triggerProps.onMouseEnter;
|
|
10843
|
+
if (!wrapperProps.onPointerLeave && typeof triggerProps.onMouseLeave === "function") wrapperProps.onPointerLeave = triggerProps.onMouseLeave;
|
|
10844
|
+
return wrapperProps;
|
|
10845
|
+
};
|
|
10735
10846
|
createEffect(() => {
|
|
10736
10847
|
const element = triggerElement();
|
|
10737
10848
|
if (!element) return;
|
|
@@ -10739,6 +10850,8 @@ const TriggerWrapper = (props) => {
|
|
|
10739
10850
|
const describedBy = triggerProps["aria-describedby"];
|
|
10740
10851
|
if (describedBy) element.setAttribute("aria-describedby", describedBy);
|
|
10741
10852
|
else element.removeAttribute("aria-describedby");
|
|
10853
|
+
const wrapper = wrapperElement();
|
|
10854
|
+
const targets = Array.from(new Set([element, wrapper].filter(Boolean)));
|
|
10742
10855
|
const listeners = [];
|
|
10743
10856
|
for (const [propName, eventName] of [
|
|
10744
10857
|
["onFocus", "focus"],
|
|
@@ -10753,19 +10866,28 @@ const TriggerWrapper = (props) => {
|
|
|
10753
10866
|
["onPointerDown", "pointerdown"],
|
|
10754
10867
|
["onKeyDown", "keydown"]
|
|
10755
10868
|
]) {
|
|
10756
|
-
|
|
10869
|
+
let handler = triggerProps[propName];
|
|
10870
|
+
if (!handler && propName === "onPointerEnter") handler = triggerProps.onMouseEnter;
|
|
10871
|
+
else if (!handler && propName === "onPointerLeave") handler = triggerProps.onMouseLeave;
|
|
10757
10872
|
if (typeof handler === "function") {
|
|
10758
10873
|
const listener = handler;
|
|
10759
|
-
|
|
10760
|
-
|
|
10874
|
+
for (const target of targets) {
|
|
10875
|
+
target.addEventListener(eventName, listener);
|
|
10876
|
+
listeners.push([
|
|
10877
|
+
target,
|
|
10878
|
+
eventName,
|
|
10879
|
+
listener
|
|
10880
|
+
]);
|
|
10881
|
+
}
|
|
10761
10882
|
}
|
|
10762
10883
|
}
|
|
10763
10884
|
onCleanup(() => {
|
|
10764
|
-
for (const [eventName, listener] of listeners)
|
|
10885
|
+
for (const [target, eventName, listener] of listeners) target.removeEventListener(eventName, listener);
|
|
10765
10886
|
if (describedBy && element.getAttribute("aria-describedby") === describedBy) element.removeAttribute("aria-describedby");
|
|
10766
10887
|
});
|
|
10767
10888
|
});
|
|
10768
10889
|
const handleRef = (span) => {
|
|
10890
|
+
setWrapperElement(span);
|
|
10769
10891
|
const findElementChild = (el) => {
|
|
10770
10892
|
for (const child of el.children) {
|
|
10771
10893
|
if (child instanceof HTMLElement) return child;
|
|
@@ -10802,7 +10924,9 @@ const TriggerWrapper = (props) => {
|
|
|
10802
10924
|
return (() => {
|
|
10803
10925
|
var _el$ = getNextElement(_tmpl$$26);
|
|
10804
10926
|
use(handleRef, _el$);
|
|
10927
|
+
spread(_el$, mergeProps(getWrapperEventProps, { "style": { display: "contents" } }), false, true);
|
|
10805
10928
|
insert(_el$, child);
|
|
10929
|
+
runHydrationEvents();
|
|
10806
10930
|
return _el$;
|
|
10807
10931
|
})();
|
|
10808
10932
|
};
|
|
@@ -11139,6 +11263,10 @@ function assignRef$7(ref, el) {
|
|
|
11139
11263
|
const ComboBoxContext = createContext(null);
|
|
11140
11264
|
const ComboBoxStateContext = createContext(null);
|
|
11141
11265
|
const ComboBoxValueContext = ComboBoxContext;
|
|
11266
|
+
function callInputKeyDown(handler, event) {
|
|
11267
|
+
if (typeof handler === "function") handler(event);
|
|
11268
|
+
else if (handler) handler[0](handler[1], event);
|
|
11269
|
+
}
|
|
11142
11270
|
/**
|
|
11143
11271
|
* A combobox combines a text input with a listbox, allowing users to filter a list of options.
|
|
11144
11272
|
*/
|
|
@@ -11183,6 +11311,10 @@ function ComboBox(props) {
|
|
|
11183
11311
|
let buttonRef = null;
|
|
11184
11312
|
let triggerRef = null;
|
|
11185
11313
|
let listBoxRef = null;
|
|
11314
|
+
const optionActions = /* @__PURE__ */ new Map();
|
|
11315
|
+
const runOptionAction = (key) => {
|
|
11316
|
+
optionActions.get(key)?.();
|
|
11317
|
+
};
|
|
11186
11318
|
const state = createComboBoxState({
|
|
11187
11319
|
get items() {
|
|
11188
11320
|
return stateProps.items;
|
|
@@ -11263,6 +11395,7 @@ function ComboBox(props) {
|
|
|
11263
11395
|
return ariaProps.isRequired;
|
|
11264
11396
|
}
|
|
11265
11397
|
});
|
|
11398
|
+
const listState = createComboBoxListStateAdapter(state);
|
|
11266
11399
|
const effectiveFormValue = createMemo(() => {
|
|
11267
11400
|
if (stateProps.allowsCustomValue) return "text";
|
|
11268
11401
|
return stateProps.formValue ?? "key";
|
|
@@ -11278,6 +11411,19 @@ function ComboBox(props) {
|
|
|
11278
11411
|
return effectiveFormValue() === "text" ? stateProps.name : void 0;
|
|
11279
11412
|
}
|
|
11280
11413
|
}), state, () => inputRef, () => buttonRef, () => listBoxRef);
|
|
11414
|
+
const getInputProps = () => {
|
|
11415
|
+
const inputProps = comboBoxAria.inputProps;
|
|
11416
|
+
const originalOnKeyDown = inputProps.onKeyDown;
|
|
11417
|
+
return {
|
|
11418
|
+
...inputProps,
|
|
11419
|
+
onKeyDown: (event) => {
|
|
11420
|
+
const focusedKey = state.focusedKey();
|
|
11421
|
+
const optionAction = event.key === "Enter" && state.isOpen() && focusedKey != null && !state.isKeyDisabled(focusedKey) ? optionActions.get(focusedKey) : void 0;
|
|
11422
|
+
callInputKeyDown(originalOnKeyDown, event);
|
|
11423
|
+
optionAction?.();
|
|
11424
|
+
}
|
|
11425
|
+
};
|
|
11426
|
+
};
|
|
11281
11427
|
const { isHovered, hoverProps } = createHover({ get isDisabled() {
|
|
11282
11428
|
return ariaProps.isDisabled;
|
|
11283
11429
|
} });
|
|
@@ -11309,9 +11455,13 @@ function ComboBox(props) {
|
|
|
11309
11455
|
get value() {
|
|
11310
11456
|
return {
|
|
11311
11457
|
state,
|
|
11312
|
-
|
|
11458
|
+
listState,
|
|
11459
|
+
inputProps: getInputProps,
|
|
11313
11460
|
buttonProps: () => comboBoxAria.buttonProps,
|
|
11314
|
-
listBoxProps: () =>
|
|
11461
|
+
listBoxProps: () => ({
|
|
11462
|
+
...comboBoxAria.listBoxProps,
|
|
11463
|
+
onAction: runOptionAction
|
|
11464
|
+
}),
|
|
11315
11465
|
labelProps: () => comboBoxAria.labelProps,
|
|
11316
11466
|
descriptionProps: () => comboBoxAria.descriptionProps,
|
|
11317
11467
|
errorMessageProps: () => comboBoxAria.errorMessageProps,
|
|
@@ -11335,6 +11485,11 @@ function ComboBox(props) {
|
|
|
11335
11485
|
setListBoxRef: (el) => {
|
|
11336
11486
|
listBoxRef = el;
|
|
11337
11487
|
},
|
|
11488
|
+
registerOptionAction: (key, action) => {
|
|
11489
|
+
if (action) optionActions.set(key, action);
|
|
11490
|
+
else optionActions.delete(key);
|
|
11491
|
+
},
|
|
11492
|
+
runOptionAction,
|
|
11338
11493
|
slots: local.slots
|
|
11339
11494
|
};
|
|
11340
11495
|
},
|
|
@@ -11703,7 +11858,7 @@ function ComboBoxListBox(props) {
|
|
|
11703
11858
|
const rawContext = useContext(ComboBoxContext);
|
|
11704
11859
|
if (!rawContext) throw new Error("ComboBoxListBox must be used within a ComboBox");
|
|
11705
11860
|
const context = rawContext;
|
|
11706
|
-
const { state: comboBoxState, isOpen, inputRef, buttonRef, setListBoxRef } = context;
|
|
11861
|
+
const { state: comboBoxState, listState, isOpen, inputRef, buttonRef, setListBoxRef } = context;
|
|
11707
11862
|
const state = comboBoxState;
|
|
11708
11863
|
let listBoxRef;
|
|
11709
11864
|
createInteractOutside({
|
|
@@ -11720,7 +11875,7 @@ function ComboBoxListBox(props) {
|
|
|
11720
11875
|
return !isOpen();
|
|
11721
11876
|
}
|
|
11722
11877
|
});
|
|
11723
|
-
const { listBoxProps } = createListBox(context.listBoxProps,
|
|
11878
|
+
const { listBoxProps } = createListBox(context.listBoxProps, listState);
|
|
11724
11879
|
const renderValues = createMemo(() => ({ isFocused: state.isFocused() }));
|
|
11725
11880
|
const renderProps = useRenderProps({
|
|
11726
11881
|
class: local.class,
|
|
@@ -11819,12 +11974,20 @@ function ComboBoxOption(props) {
|
|
|
11819
11974
|
]);
|
|
11820
11975
|
const stateContext = useContext(ComboBoxStateContext);
|
|
11821
11976
|
const comboBoxContext = useContext(ComboBoxContext);
|
|
11822
|
-
if (!stateContext) throw new Error("ComboBoxOption must be used within a ComboBox");
|
|
11977
|
+
if (!stateContext || !comboBoxContext) throw new Error("ComboBoxOption must be used within a ComboBox");
|
|
11823
11978
|
const state = stateContext;
|
|
11979
|
+
const listState = comboBoxContext.listState;
|
|
11824
11980
|
const optionId = () => {
|
|
11825
11981
|
const listBoxId = getComboBoxData(state)?.listBoxId;
|
|
11826
11982
|
return listBoxId ? `${listBoxId}-option-${local.id}` : String(local.id);
|
|
11827
11983
|
};
|
|
11984
|
+
createEffect(() => {
|
|
11985
|
+
const key = local.id;
|
|
11986
|
+
comboBoxContext?.registerOptionAction(key, local.onAction);
|
|
11987
|
+
onCleanup(() => {
|
|
11988
|
+
comboBoxContext?.registerOptionAction(key, void 0);
|
|
11989
|
+
});
|
|
11990
|
+
});
|
|
11828
11991
|
const optionAria = createOption({
|
|
11829
11992
|
key: local.id,
|
|
11830
11993
|
get optionId() {
|
|
@@ -11836,9 +11999,6 @@ function ComboBoxOption(props) {
|
|
|
11836
11999
|
get "aria-label"() {
|
|
11837
12000
|
return ariaProps["aria-label"];
|
|
11838
12001
|
},
|
|
11839
|
-
get onAction() {
|
|
11840
|
-
return local.onAction;
|
|
11841
|
-
},
|
|
11842
12002
|
shouldSelectOnPressUp: true,
|
|
11843
12003
|
shouldFocusOnHover: true,
|
|
11844
12004
|
shouldUseVirtualFocus: true,
|
|
@@ -11851,8 +12011,11 @@ function ComboBoxOption(props) {
|
|
|
11851
12011
|
},
|
|
11852
12012
|
get onHoverChange() {
|
|
11853
12013
|
return ariaProps.onHoverChange;
|
|
12014
|
+
},
|
|
12015
|
+
get onAction() {
|
|
12016
|
+
return local.onAction;
|
|
11854
12017
|
}
|
|
11855
|
-
},
|
|
12018
|
+
}, listState);
|
|
11856
12019
|
const isOptionFocusVisible = () => optionAria.isFocusVisible() || optionAria.isFocused() && (comboBoxContext?.isFocusVisible() ?? false);
|
|
11857
12020
|
const renderValues = createMemo(() => ({
|
|
11858
12021
|
isSelected: optionAria.isSelected(),
|
|
@@ -12956,6 +13119,11 @@ function Popover(props) {
|
|
|
12956
13119
|
};
|
|
12957
13120
|
};
|
|
12958
13121
|
const shouldBeDialog = () => !local.isNonModal || resolvedTrigger() === "SubmenuTrigger";
|
|
13122
|
+
const shouldContainFocus = () => {
|
|
13123
|
+
if (!shouldBeDialog()) return false;
|
|
13124
|
+
const trigger = resolvedTrigger();
|
|
13125
|
+
return trigger !== "MenuTrigger" && trigger !== "SubmenuTrigger";
|
|
13126
|
+
};
|
|
12959
13127
|
const portalContext = useUNSAFE_PortalContext();
|
|
12960
13128
|
const portalContainer = () => {
|
|
12961
13129
|
if (isSubPopover()) return popoverGroupContext?.() ?? portalContext.getContainer?.() ?? void 0;
|
|
@@ -13005,7 +13173,7 @@ function Popover(props) {
|
|
|
13005
13173
|
get children() {
|
|
13006
13174
|
return createComponent(FocusScope, {
|
|
13007
13175
|
get contain() {
|
|
13008
|
-
return
|
|
13176
|
+
return shouldContainFocus();
|
|
13009
13177
|
},
|
|
13010
13178
|
restoreFocus: true,
|
|
13011
13179
|
get children() {
|
|
@@ -14301,6 +14469,7 @@ function Tag(props) {
|
|
|
14301
14469
|
get key() {
|
|
14302
14470
|
return local.id;
|
|
14303
14471
|
},
|
|
14472
|
+
role: "row",
|
|
14304
14473
|
get isDisabled() {
|
|
14305
14474
|
return local.isDisabled || groupContext?.isDisabled;
|
|
14306
14475
|
},
|
|
@@ -16412,8 +16581,60 @@ function DatePickerInner(props) {
|
|
|
16412
16581
|
const [triggerRef, setTriggerRef] = createSignal(null);
|
|
16413
16582
|
const [fieldRef, setFieldRef] = createSignal(null);
|
|
16414
16583
|
const datePickerState = createDatePickerState({
|
|
16415
|
-
|
|
16416
|
-
|
|
16584
|
+
get value() {
|
|
16585
|
+
return stateProps.value;
|
|
16586
|
+
},
|
|
16587
|
+
get defaultValue() {
|
|
16588
|
+
return stateProps.defaultValue;
|
|
16589
|
+
},
|
|
16590
|
+
get onChange() {
|
|
16591
|
+
return stateProps.onChange;
|
|
16592
|
+
},
|
|
16593
|
+
get minValue() {
|
|
16594
|
+
return stateProps.minValue;
|
|
16595
|
+
},
|
|
16596
|
+
get maxValue() {
|
|
16597
|
+
return stateProps.maxValue;
|
|
16598
|
+
},
|
|
16599
|
+
get isDisabled() {
|
|
16600
|
+
return stateProps.isDisabled;
|
|
16601
|
+
},
|
|
16602
|
+
get isReadOnly() {
|
|
16603
|
+
return stateProps.isReadOnly;
|
|
16604
|
+
},
|
|
16605
|
+
get isRequired() {
|
|
16606
|
+
return stateProps.isRequired;
|
|
16607
|
+
},
|
|
16608
|
+
get granularity() {
|
|
16609
|
+
return stateProps.granularity;
|
|
16610
|
+
},
|
|
16611
|
+
get hourCycle() {
|
|
16612
|
+
return stateProps.hourCycle;
|
|
16613
|
+
},
|
|
16614
|
+
get hideTimeZone() {
|
|
16615
|
+
return stateProps.hideTimeZone;
|
|
16616
|
+
},
|
|
16617
|
+
get placeholderValue() {
|
|
16618
|
+
return stateProps.placeholderValue;
|
|
16619
|
+
},
|
|
16620
|
+
get shouldCloseOnSelect() {
|
|
16621
|
+
return local.shouldCloseOnSelect;
|
|
16622
|
+
},
|
|
16623
|
+
get defaultOpen() {
|
|
16624
|
+
return stateProps.defaultOpen;
|
|
16625
|
+
},
|
|
16626
|
+
get isOpen() {
|
|
16627
|
+
return stateProps.isOpen;
|
|
16628
|
+
},
|
|
16629
|
+
get onOpenChange() {
|
|
16630
|
+
return stateProps.onOpenChange;
|
|
16631
|
+
},
|
|
16632
|
+
get isDateUnavailable() {
|
|
16633
|
+
return stateProps.isDateUnavailable;
|
|
16634
|
+
},
|
|
16635
|
+
get validationState() {
|
|
16636
|
+
return stateProps.validationState;
|
|
16637
|
+
}
|
|
16417
16638
|
});
|
|
16418
16639
|
const overlayState = {
|
|
16419
16640
|
get isOpen() {
|