@proyecto-viviana/solidaria-components 0.3.0 → 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/Modal.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/Toast.d.ts.map +1 -1
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/index.js +264 -37
- package/dist/index.js.map +1 -1
- package/dist/index.jsx +264 -37
- package/dist/index.jsx.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -3
- 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/Modal.tsx +8 -1
- package/src/NumberField.tsx +22 -2
- package/src/Popover.tsx +19 -2
- package/src/TagGroup.tsx +1 -0
- package/src/TextField.tsx +32 -7
- package/src/Toast.tsx +7 -1
- package/src/Tooltip.tsx +52 -7
- package/src/utils.tsx +9 -5
package/dist/index.jsx
CHANGED
|
@@ -138,7 +138,7 @@ function filterDOMProps(props, options = {}) {
|
|
|
138
138
|
function useIsHydrated() {
|
|
139
139
|
if (isServer) return () => false;
|
|
140
140
|
const [isHydrated, setIsHydrated] = createSignal(false);
|
|
141
|
-
|
|
141
|
+
onMount(() => {
|
|
142
142
|
setIsHydrated(true);
|
|
143
143
|
});
|
|
144
144
|
return isHydrated;
|
|
@@ -360,6 +360,38 @@ function createLiveCustomRootProps(getProps, getChildren, ref) {
|
|
|
360
360
|
});
|
|
361
361
|
return props;
|
|
362
362
|
}
|
|
363
|
+
const buttonAriaOverrideProps = [
|
|
364
|
+
"aria-label",
|
|
365
|
+
"aria-labelledby",
|
|
366
|
+
"aria-describedby",
|
|
367
|
+
"aria-details",
|
|
368
|
+
"aria-haspopup",
|
|
369
|
+
"aria-expanded",
|
|
370
|
+
"aria-controls",
|
|
371
|
+
"aria-pressed",
|
|
372
|
+
"aria-current",
|
|
373
|
+
"aria-disabled"
|
|
374
|
+
];
|
|
375
|
+
function createForwardedAriaButtonProps(source, overrides) {
|
|
376
|
+
const result = {};
|
|
377
|
+
for (const key in source) Object.defineProperty(result, key, {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
configurable: true,
|
|
380
|
+
get() {
|
|
381
|
+
return source[key];
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
for (const key in overrides) {
|
|
385
|
+
const descriptor = Object.getOwnPropertyDescriptor(overrides, key);
|
|
386
|
+
if (!descriptor) continue;
|
|
387
|
+
Object.defineProperty(result, key, {
|
|
388
|
+
...descriptor,
|
|
389
|
+
enumerable: true,
|
|
390
|
+
configurable: true
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
363
395
|
const ButtonContext = createContext(null);
|
|
364
396
|
/**
|
|
365
397
|
* A button allows a user to perform an action.
|
|
@@ -419,8 +451,7 @@ function Button(props) {
|
|
|
419
451
|
if (isDialogTrigger()) dialogTriggerContext.state.toggle();
|
|
420
452
|
if (isPopoverTrigger()) popoverTriggerContext.state.toggle();
|
|
421
453
|
};
|
|
422
|
-
const buttonAria = createButton({
|
|
423
|
-
...ariaProps,
|
|
454
|
+
const buttonAria = createButton(createForwardedAriaButtonProps(ariaProps, {
|
|
424
455
|
onPress: handlePress,
|
|
425
456
|
get onPressStart() {
|
|
426
457
|
return resolvePending() ? void 0 : ariaProps.onPressStart;
|
|
@@ -440,7 +471,7 @@ function Button(props) {
|
|
|
440
471
|
get isDisabled() {
|
|
441
472
|
return resolveDisabled() || resolvePending();
|
|
442
473
|
}
|
|
443
|
-
});
|
|
474
|
+
}));
|
|
444
475
|
const { isFocused, isFocusVisible, focusProps } = createFocusRing();
|
|
445
476
|
const { isHovered, hoverProps } = createHover({
|
|
446
477
|
get isDisabled() {
|
|
@@ -527,6 +558,11 @@ function Button(props) {
|
|
|
527
558
|
]) if (triggerProps[name] != null) next[name] = triggerProps[name];
|
|
528
559
|
return next;
|
|
529
560
|
};
|
|
561
|
+
const directAriaProps = () => {
|
|
562
|
+
const next = {};
|
|
563
|
+
for (const name of buttonAriaOverrideProps) next[name] = ariaProps[name];
|
|
564
|
+
return next;
|
|
565
|
+
};
|
|
530
566
|
const disablePendingInteractions = (props) => {
|
|
531
567
|
if (!resolvePending()) return props;
|
|
532
568
|
const next = { ...props };
|
|
@@ -551,6 +587,7 @@ function Button(props) {
|
|
|
551
587
|
const rootProps = () => ({
|
|
552
588
|
...domProps(),
|
|
553
589
|
...disablePendingInteractions(cleanButtonProps()),
|
|
590
|
+
...directAriaProps(),
|
|
554
591
|
...triggerAriaProps(),
|
|
555
592
|
...cleanFocusProps(),
|
|
556
593
|
...cleanHoverProps(),
|
|
@@ -2084,6 +2121,12 @@ function clearDelegatedTextEntryHandlers$1(element) {
|
|
|
2084
2121
|
function Input(props) {
|
|
2085
2122
|
const context = useContext(TextFieldContext);
|
|
2086
2123
|
let inputElement;
|
|
2124
|
+
createEffect(() => {
|
|
2125
|
+
context?.setInputId?.(props.id);
|
|
2126
|
+
});
|
|
2127
|
+
onCleanup(() => {
|
|
2128
|
+
context?.setInputId?.(void 0);
|
|
2129
|
+
});
|
|
2087
2130
|
const mergedProps = () => {
|
|
2088
2131
|
if (context) {
|
|
2089
2132
|
const { ref: _ref, ...contextInputProps } = context.inputProps ?? {};
|
|
@@ -2136,6 +2179,12 @@ function Input(props) {
|
|
|
2136
2179
|
function TextArea(props) {
|
|
2137
2180
|
const context = useContext(TextFieldContext);
|
|
2138
2181
|
let textAreaElement;
|
|
2182
|
+
createEffect(() => {
|
|
2183
|
+
context?.setInputId?.(props.id);
|
|
2184
|
+
});
|
|
2185
|
+
onCleanup(() => {
|
|
2186
|
+
context?.setInputId?.(void 0);
|
|
2187
|
+
});
|
|
2139
2188
|
const mergedProps = () => {
|
|
2140
2189
|
if (context) {
|
|
2141
2190
|
const { ref: _ref, type: _type, ...contextInputProps } = context.inputProps ?? {};
|
|
@@ -2204,7 +2253,7 @@ function TextField(props) {
|
|
|
2204
2253
|
const contextSlotProps = contextProps?.slots?.[props.slot ?? "default"];
|
|
2205
2254
|
const contextBaseProps = createMemo(() => {
|
|
2206
2255
|
if (!contextProps) return {};
|
|
2207
|
-
const { labelProps: _labelProps, inputProps: _inputProps, descriptionProps: _descriptionProps, errorMessageProps: _errorMessageProps, isInvalid: _isInvalid, slots: _slots, ...rest } = contextProps;
|
|
2256
|
+
const { labelProps: _labelProps, inputProps: _inputProps, descriptionProps: _descriptionProps, errorMessageProps: _errorMessageProps, isInvalid: _isInvalid, slots: _slots, setInputId: _setInputId, ...rest } = contextProps;
|
|
2208
2257
|
return rest;
|
|
2209
2258
|
});
|
|
2210
2259
|
const [local, ariaProps] = splitProps(withFormValidationBehavior$4(contextProps ? mergeProps$1(contextBaseProps(), contextSlotProps ?? {}, props) : props, formContext), [
|
|
@@ -2239,6 +2288,7 @@ function TextField(props) {
|
|
|
2239
2288
|
const { isHovered, hoverProps } = createHover({ get isDisabled() {
|
|
2240
2289
|
return ariaProps.isDisabled;
|
|
2241
2290
|
} });
|
|
2291
|
+
const [inputIdOverride, setInputIdOverride] = createSignal();
|
|
2242
2292
|
const renderValues = createMemo(() => ({
|
|
2243
2293
|
isDisabled: ariaProps.isDisabled || false,
|
|
2244
2294
|
isInvalid: textFieldAria.isInvalid,
|
|
@@ -2324,10 +2374,13 @@ function TextField(props) {
|
|
|
2324
2374
|
return textFieldAria.isInvalid;
|
|
2325
2375
|
},
|
|
2326
2376
|
get inputId() {
|
|
2327
|
-
return textFieldAria.inputProps.id;
|
|
2377
|
+
return inputIdOverride() ?? textFieldAria.inputProps.id;
|
|
2378
|
+
},
|
|
2379
|
+
setInputId(id) {
|
|
2380
|
+
setInputIdOverride(id);
|
|
2328
2381
|
}
|
|
2329
2382
|
};
|
|
2330
|
-
const
|
|
2383
|
+
const FieldChildren = () => untrack(() => {
|
|
2331
2384
|
const children = local.children;
|
|
2332
2385
|
return typeof children === "function" ? children(childRenderValues) : children;
|
|
2333
2386
|
});
|
|
@@ -2347,11 +2400,13 @@ function TextField(props) {
|
|
|
2347
2400
|
});
|
|
2348
2401
|
const customRootProps = () => ({
|
|
2349
2402
|
...rootProps(),
|
|
2350
|
-
children:
|
|
2403
|
+
children: <FieldChildren />
|
|
2351
2404
|
});
|
|
2352
2405
|
return <FieldErrorContext.Provider value={fieldErrorContext}>
|
|
2353
2406
|
<TextFieldContext.Provider value={contextValue}>
|
|
2354
|
-
{local.render ? local.render(customRootProps(), renderValues()) : <div {...rootProps()}>
|
|
2407
|
+
{local.render ? local.render(customRootProps(), renderValues()) : <div {...rootProps()}>
|
|
2408
|
+
<FieldChildren />
|
|
2409
|
+
</div>}
|
|
2355
2410
|
</TextFieldContext.Provider>
|
|
2356
2411
|
</FieldErrorContext.Provider>;
|
|
2357
2412
|
}
|
|
@@ -4743,6 +4798,7 @@ function SubmenuTrigger(props) {
|
|
|
4743
4798
|
const triggerId = createUniqueId();
|
|
4744
4799
|
const menuId = createUniqueId();
|
|
4745
4800
|
let hoverTimeout;
|
|
4801
|
+
let hasPointerHover = false;
|
|
4746
4802
|
const delay = () => props.delay ?? 200;
|
|
4747
4803
|
const clearHoverTimeout = () => {
|
|
4748
4804
|
if (hoverTimeout != null) {
|
|
@@ -4754,6 +4810,12 @@ function SubmenuTrigger(props) {
|
|
|
4754
4810
|
clearHoverTimeout();
|
|
4755
4811
|
state.open();
|
|
4756
4812
|
};
|
|
4813
|
+
const queueOpenSubmenu = () => {
|
|
4814
|
+
clearHoverTimeout();
|
|
4815
|
+
const open = () => state.open();
|
|
4816
|
+
if (typeof queueMicrotask === "function") queueMicrotask(open);
|
|
4817
|
+
else Promise.resolve().then(open);
|
|
4818
|
+
};
|
|
4757
4819
|
const scheduleOpen = () => {
|
|
4758
4820
|
clearHoverTimeout();
|
|
4759
4821
|
hoverTimeout = window.setTimeout(() => {
|
|
@@ -4761,6 +4823,19 @@ function SubmenuTrigger(props) {
|
|
|
4761
4823
|
state.open();
|
|
4762
4824
|
}, delay());
|
|
4763
4825
|
};
|
|
4826
|
+
const schedulePointerOpen = (event) => {
|
|
4827
|
+
hasPointerHover = true;
|
|
4828
|
+
if (event.isTrusted === false) {
|
|
4829
|
+
queueOpenSubmenu();
|
|
4830
|
+
return;
|
|
4831
|
+
}
|
|
4832
|
+
scheduleOpen();
|
|
4833
|
+
};
|
|
4834
|
+
const openFromMouseHover = () => {
|
|
4835
|
+
if (state.isOpen()) return;
|
|
4836
|
+
if (hasPointerHover) scheduleOpen();
|
|
4837
|
+
else queueOpenSubmenu();
|
|
4838
|
+
};
|
|
4764
4839
|
onCleanup(clearHoverTimeout);
|
|
4765
4840
|
const menuTriggerContext = createMemo(() => ({
|
|
4766
4841
|
state,
|
|
@@ -4793,17 +4868,22 @@ function SubmenuTrigger(props) {
|
|
|
4793
4868
|
props: () => ({
|
|
4794
4869
|
id: triggerId,
|
|
4795
4870
|
"aria-haspopup": "menu",
|
|
4796
|
-
"aria-expanded"
|
|
4797
|
-
|
|
4871
|
+
get "aria-expanded"() {
|
|
4872
|
+
return state.isOpen() || void 0;
|
|
4873
|
+
},
|
|
4874
|
+
get "aria-controls"() {
|
|
4875
|
+
return state.isOpen() ? menuId : void 0;
|
|
4876
|
+
},
|
|
4798
4877
|
onPointerEnter: (event) => {
|
|
4799
4878
|
if (event.pointerType === "touch") return;
|
|
4800
|
-
|
|
4879
|
+
schedulePointerOpen(event);
|
|
4801
4880
|
},
|
|
4802
4881
|
onPointerOver: (event) => {
|
|
4803
4882
|
if (event.pointerType === "touch") return;
|
|
4804
|
-
|
|
4883
|
+
schedulePointerOpen(event);
|
|
4805
4884
|
},
|
|
4806
|
-
onMouseEnter:
|
|
4885
|
+
onMouseEnter: openFromMouseHover,
|
|
4886
|
+
onMouseOver: openFromMouseHover,
|
|
4807
4887
|
onKeyDown: (event) => {
|
|
4808
4888
|
if (event.key === "ArrowRight" || event.key === "Enter" || event.key === " ") {
|
|
4809
4889
|
event.preventDefault();
|
|
@@ -5208,6 +5288,7 @@ function Menu(props) {
|
|
|
5208
5288
|
renderItem: (item) => renderDynamicItem(item),
|
|
5209
5289
|
renderDropIndicator: (index, position) => dndDropIndicator(index, position) ?? parentCollectionRenderer?.renderDropIndicator?.(index, position)
|
|
5210
5290
|
}));
|
|
5291
|
+
const menuItemContextValue = createMemo(() => local.shouldCloseOnSelect !== void 0 ? { closeOnSelect: local.shouldCloseOnSelect } : {});
|
|
5211
5292
|
const menuListChildren = () => <SharedElementTransition>
|
|
5212
5293
|
{state.collection().size === 0 && !usesStaticChildren() && local.renderEmptyState ? <li role="presentation" data-empty-state>
|
|
5213
5294
|
<div role="menuitem" style={{ display: "contents" }}>
|
|
@@ -5277,7 +5358,7 @@ function Menu(props) {
|
|
|
5277
5358
|
<MenuStateContext.Provider value={state}>
|
|
5278
5359
|
<MenuSectionSelectionRegistryContext.Provider value={sectionSelectionRegistry}>
|
|
5279
5360
|
<StaticMenuCollectionContext.Provider value={usesStaticChildren() ? staticCollectionContext : null}>
|
|
5280
|
-
<MenuItemContext.Provider value={
|
|
5361
|
+
<MenuItemContext.Provider value={menuItemContextValue()}>
|
|
5281
5362
|
<CollectionRendererContext.Provider value={collectionRenderer()}>
|
|
5282
5363
|
<>
|
|
5283
5364
|
<Show when={ariaProps.label}>
|
|
@@ -7652,8 +7733,12 @@ function NumberFieldIncrementButton(props) {
|
|
|
7652
7733
|
const context = useContext(NumberFieldContext);
|
|
7653
7734
|
if (!context) throw new Error("NumberFieldIncrementButton must be used within a NumberField");
|
|
7654
7735
|
const isDisabled = () => context.isDisabled || !context.state.canIncrement();
|
|
7736
|
+
const pressButtonProps = () => {
|
|
7737
|
+
const { onClick: _onClick, disabled: _disabled, type: _type, tabIndex: _tabIndex, ...rest } = context.incrementButtonProps;
|
|
7738
|
+
return rest;
|
|
7739
|
+
};
|
|
7655
7740
|
const buttonAria = createButton({
|
|
7656
|
-
...
|
|
7741
|
+
...pressButtonProps(),
|
|
7657
7742
|
elementType: "div",
|
|
7658
7743
|
get isDisabled() {
|
|
7659
7744
|
return isDisabled();
|
|
@@ -7698,8 +7783,12 @@ function NumberFieldDecrementButton(props) {
|
|
|
7698
7783
|
const context = useContext(NumberFieldContext);
|
|
7699
7784
|
if (!context) throw new Error("NumberFieldDecrementButton must be used within a NumberField");
|
|
7700
7785
|
const isDisabled = () => context.isDisabled || !context.state.canDecrement();
|
|
7786
|
+
const pressButtonProps = () => {
|
|
7787
|
+
const { onClick: _onClick, disabled: _disabled, type: _type, tabIndex: _tabIndex, ...rest } = context.decrementButtonProps;
|
|
7788
|
+
return rest;
|
|
7789
|
+
};
|
|
7701
7790
|
const buttonAria = createButton({
|
|
7702
|
-
...
|
|
7791
|
+
...pressButtonProps(),
|
|
7703
7792
|
elementType: "div",
|
|
7704
7793
|
get isDisabled() {
|
|
7705
7794
|
return isDisabled();
|
|
@@ -8642,6 +8731,30 @@ const TooltipTrigger = (props) => {
|
|
|
8642
8731
|
const TriggerWrapper = (props) => {
|
|
8643
8732
|
const child = () => props.children;
|
|
8644
8733
|
const [triggerElement, setTriggerElement] = createSignal(null);
|
|
8734
|
+
const [wrapperElement, setWrapperElement] = createSignal(null);
|
|
8735
|
+
const getWrapperEventProps = () => {
|
|
8736
|
+
const triggerProps = props.triggerProps;
|
|
8737
|
+
const wrapperProps = {};
|
|
8738
|
+
for (const propName of [
|
|
8739
|
+
"onFocus",
|
|
8740
|
+
"onBlur",
|
|
8741
|
+
"onPointerEnter",
|
|
8742
|
+
"onPointerLeave",
|
|
8743
|
+
"onPointerOver",
|
|
8744
|
+
"onPointerOut",
|
|
8745
|
+
"onMouseEnter",
|
|
8746
|
+
"onMouseLeave",
|
|
8747
|
+
"onTouchStart",
|
|
8748
|
+
"onPointerDown",
|
|
8749
|
+
"onKeyDown"
|
|
8750
|
+
]) {
|
|
8751
|
+
const handler = triggerProps[propName];
|
|
8752
|
+
if (typeof handler === "function") wrapperProps[propName] = handler;
|
|
8753
|
+
}
|
|
8754
|
+
if (!wrapperProps.onPointerEnter && typeof triggerProps.onMouseEnter === "function") wrapperProps.onPointerEnter = triggerProps.onMouseEnter;
|
|
8755
|
+
if (!wrapperProps.onPointerLeave && typeof triggerProps.onMouseLeave === "function") wrapperProps.onPointerLeave = triggerProps.onMouseLeave;
|
|
8756
|
+
return wrapperProps;
|
|
8757
|
+
};
|
|
8645
8758
|
createEffect(() => {
|
|
8646
8759
|
const element = triggerElement();
|
|
8647
8760
|
if (!element) return;
|
|
@@ -8649,6 +8762,8 @@ const TriggerWrapper = (props) => {
|
|
|
8649
8762
|
const describedBy = triggerProps["aria-describedby"];
|
|
8650
8763
|
if (describedBy) element.setAttribute("aria-describedby", describedBy);
|
|
8651
8764
|
else element.removeAttribute("aria-describedby");
|
|
8765
|
+
const wrapper = wrapperElement();
|
|
8766
|
+
const targets = Array.from(new Set([element, wrapper].filter(Boolean)));
|
|
8652
8767
|
const listeners = [];
|
|
8653
8768
|
for (const [propName, eventName] of [
|
|
8654
8769
|
["onFocus", "focus"],
|
|
@@ -8663,19 +8778,28 @@ const TriggerWrapper = (props) => {
|
|
|
8663
8778
|
["onPointerDown", "pointerdown"],
|
|
8664
8779
|
["onKeyDown", "keydown"]
|
|
8665
8780
|
]) {
|
|
8666
|
-
|
|
8781
|
+
let handler = triggerProps[propName];
|
|
8782
|
+
if (!handler && propName === "onPointerEnter") handler = triggerProps.onMouseEnter;
|
|
8783
|
+
else if (!handler && propName === "onPointerLeave") handler = triggerProps.onMouseLeave;
|
|
8667
8784
|
if (typeof handler === "function") {
|
|
8668
8785
|
const listener = handler;
|
|
8669
|
-
|
|
8670
|
-
|
|
8786
|
+
for (const target of targets) {
|
|
8787
|
+
target.addEventListener(eventName, listener);
|
|
8788
|
+
listeners.push([
|
|
8789
|
+
target,
|
|
8790
|
+
eventName,
|
|
8791
|
+
listener
|
|
8792
|
+
]);
|
|
8793
|
+
}
|
|
8671
8794
|
}
|
|
8672
8795
|
}
|
|
8673
8796
|
onCleanup(() => {
|
|
8674
|
-
for (const [eventName, listener] of listeners)
|
|
8797
|
+
for (const [target, eventName, listener] of listeners) target.removeEventListener(eventName, listener);
|
|
8675
8798
|
if (describedBy && element.getAttribute("aria-describedby") === describedBy) element.removeAttribute("aria-describedby");
|
|
8676
8799
|
});
|
|
8677
8800
|
});
|
|
8678
8801
|
const handleRef = (span) => {
|
|
8802
|
+
setWrapperElement(span);
|
|
8679
8803
|
const findElementChild = (el) => {
|
|
8680
8804
|
for (const child of el.children) {
|
|
8681
8805
|
if (child instanceof HTMLElement) return child;
|
|
@@ -8709,7 +8833,7 @@ const TriggerWrapper = (props) => {
|
|
|
8709
8833
|
props.ref(immediateChild);
|
|
8710
8834
|
} else requestAnimationFrame(resolveRef);
|
|
8711
8835
|
};
|
|
8712
|
-
return <span ref={handleRef} style={{ display: "contents" }}>
|
|
8836
|
+
return <span {...getWrapperEventProps()} ref={handleRef} style={{ display: "contents" }}>
|
|
8713
8837
|
{child()}
|
|
8714
8838
|
</span>;
|
|
8715
8839
|
};
|
|
@@ -8982,6 +9106,10 @@ function assignRef$7(ref, el) {
|
|
|
8982
9106
|
const ComboBoxContext = createContext(null);
|
|
8983
9107
|
const ComboBoxStateContext = createContext(null);
|
|
8984
9108
|
const ComboBoxValueContext = ComboBoxContext;
|
|
9109
|
+
function callInputKeyDown(handler, event) {
|
|
9110
|
+
if (typeof handler === "function") handler(event);
|
|
9111
|
+
else if (handler) handler[0](handler[1], event);
|
|
9112
|
+
}
|
|
8985
9113
|
/**
|
|
8986
9114
|
* A combobox combines a text input with a listbox, allowing users to filter a list of options.
|
|
8987
9115
|
*/
|
|
@@ -9026,6 +9154,10 @@ function ComboBox(props) {
|
|
|
9026
9154
|
let buttonRef = null;
|
|
9027
9155
|
let triggerRef = null;
|
|
9028
9156
|
let listBoxRef = null;
|
|
9157
|
+
const optionActions = /* @__PURE__ */ new Map();
|
|
9158
|
+
const runOptionAction = (key) => {
|
|
9159
|
+
optionActions.get(key)?.();
|
|
9160
|
+
};
|
|
9029
9161
|
const state = createComboBoxState({
|
|
9030
9162
|
get items() {
|
|
9031
9163
|
return stateProps.items;
|
|
@@ -9106,6 +9238,7 @@ function ComboBox(props) {
|
|
|
9106
9238
|
return ariaProps.isRequired;
|
|
9107
9239
|
}
|
|
9108
9240
|
});
|
|
9241
|
+
const listState = createComboBoxListStateAdapter(state);
|
|
9109
9242
|
const effectiveFormValue = createMemo(() => {
|
|
9110
9243
|
if (stateProps.allowsCustomValue) return "text";
|
|
9111
9244
|
return stateProps.formValue ?? "key";
|
|
@@ -9121,6 +9254,19 @@ function ComboBox(props) {
|
|
|
9121
9254
|
return effectiveFormValue() === "text" ? stateProps.name : void 0;
|
|
9122
9255
|
}
|
|
9123
9256
|
}), state, () => inputRef, () => buttonRef, () => listBoxRef);
|
|
9257
|
+
const getInputProps = () => {
|
|
9258
|
+
const inputProps = comboBoxAria.inputProps;
|
|
9259
|
+
const originalOnKeyDown = inputProps.onKeyDown;
|
|
9260
|
+
return {
|
|
9261
|
+
...inputProps,
|
|
9262
|
+
onKeyDown: (event) => {
|
|
9263
|
+
const focusedKey = state.focusedKey();
|
|
9264
|
+
const optionAction = event.key === "Enter" && state.isOpen() && focusedKey != null && !state.isKeyDisabled(focusedKey) ? optionActions.get(focusedKey) : void 0;
|
|
9265
|
+
callInputKeyDown(originalOnKeyDown, event);
|
|
9266
|
+
optionAction?.();
|
|
9267
|
+
}
|
|
9268
|
+
};
|
|
9269
|
+
};
|
|
9124
9270
|
const { isHovered, hoverProps } = createHover({ get isDisabled() {
|
|
9125
9271
|
return ariaProps.isDisabled;
|
|
9126
9272
|
} });
|
|
@@ -9150,9 +9296,13 @@ function ComboBox(props) {
|
|
|
9150
9296
|
const ComboBoxChildren = () => typeof local.children === "function" ? local.children(renderValues()) : local.children;
|
|
9151
9297
|
return <ComboBoxContext.Provider value={{
|
|
9152
9298
|
state,
|
|
9153
|
-
|
|
9299
|
+
listState,
|
|
9300
|
+
inputProps: getInputProps,
|
|
9154
9301
|
buttonProps: () => comboBoxAria.buttonProps,
|
|
9155
|
-
listBoxProps: () =>
|
|
9302
|
+
listBoxProps: () => ({
|
|
9303
|
+
...comboBoxAria.listBoxProps,
|
|
9304
|
+
onAction: runOptionAction
|
|
9305
|
+
}),
|
|
9156
9306
|
labelProps: () => comboBoxAria.labelProps,
|
|
9157
9307
|
descriptionProps: () => comboBoxAria.descriptionProps,
|
|
9158
9308
|
errorMessageProps: () => comboBoxAria.errorMessageProps,
|
|
@@ -9176,6 +9326,11 @@ function ComboBox(props) {
|
|
|
9176
9326
|
setListBoxRef: (el) => {
|
|
9177
9327
|
listBoxRef = el;
|
|
9178
9328
|
},
|
|
9329
|
+
registerOptionAction: (key, action) => {
|
|
9330
|
+
if (action) optionActions.set(key, action);
|
|
9331
|
+
else optionActions.delete(key);
|
|
9332
|
+
},
|
|
9333
|
+
runOptionAction,
|
|
9179
9334
|
slots: local.slots
|
|
9180
9335
|
}}>
|
|
9181
9336
|
<ComboBoxStateContext.Provider value={state}>
|
|
@@ -9379,7 +9534,7 @@ function ComboBoxListBox(props) {
|
|
|
9379
9534
|
const rawContext = useContext(ComboBoxContext);
|
|
9380
9535
|
if (!rawContext) throw new Error("ComboBoxListBox must be used within a ComboBox");
|
|
9381
9536
|
const context = rawContext;
|
|
9382
|
-
const { state: comboBoxState, isOpen, inputRef, buttonRef, setListBoxRef } = context;
|
|
9537
|
+
const { state: comboBoxState, listState, isOpen, inputRef, buttonRef, setListBoxRef } = context;
|
|
9383
9538
|
const state = comboBoxState;
|
|
9384
9539
|
let listBoxRef;
|
|
9385
9540
|
createInteractOutside({
|
|
@@ -9396,7 +9551,7 @@ function ComboBoxListBox(props) {
|
|
|
9396
9551
|
return !isOpen();
|
|
9397
9552
|
}
|
|
9398
9553
|
});
|
|
9399
|
-
const { listBoxProps } = createListBox(context.listBoxProps,
|
|
9554
|
+
const { listBoxProps } = createListBox(context.listBoxProps, listState);
|
|
9400
9555
|
const renderValues = createMemo(() => ({ isFocused: state.isFocused() }));
|
|
9401
9556
|
const renderProps = useRenderProps({
|
|
9402
9557
|
class: local.class,
|
|
@@ -9456,12 +9611,20 @@ function ComboBoxOption(props) {
|
|
|
9456
9611
|
]);
|
|
9457
9612
|
const stateContext = useContext(ComboBoxStateContext);
|
|
9458
9613
|
const comboBoxContext = useContext(ComboBoxContext);
|
|
9459
|
-
if (!stateContext) throw new Error("ComboBoxOption must be used within a ComboBox");
|
|
9614
|
+
if (!stateContext || !comboBoxContext) throw new Error("ComboBoxOption must be used within a ComboBox");
|
|
9460
9615
|
const state = stateContext;
|
|
9616
|
+
const listState = comboBoxContext.listState;
|
|
9461
9617
|
const optionId = () => {
|
|
9462
9618
|
const listBoxId = getComboBoxData(state)?.listBoxId;
|
|
9463
9619
|
return listBoxId ? `${listBoxId}-option-${local.id}` : String(local.id);
|
|
9464
9620
|
};
|
|
9621
|
+
createEffect(() => {
|
|
9622
|
+
const key = local.id;
|
|
9623
|
+
comboBoxContext?.registerOptionAction(key, local.onAction);
|
|
9624
|
+
onCleanup(() => {
|
|
9625
|
+
comboBoxContext?.registerOptionAction(key, void 0);
|
|
9626
|
+
});
|
|
9627
|
+
});
|
|
9465
9628
|
const optionAria = createOption({
|
|
9466
9629
|
key: local.id,
|
|
9467
9630
|
get optionId() {
|
|
@@ -9473,9 +9636,6 @@ function ComboBoxOption(props) {
|
|
|
9473
9636
|
get "aria-label"() {
|
|
9474
9637
|
return ariaProps["aria-label"];
|
|
9475
9638
|
},
|
|
9476
|
-
get onAction() {
|
|
9477
|
-
return local.onAction;
|
|
9478
|
-
},
|
|
9479
9639
|
shouldSelectOnPressUp: true,
|
|
9480
9640
|
shouldFocusOnHover: true,
|
|
9481
9641
|
shouldUseVirtualFocus: true,
|
|
@@ -9488,8 +9648,11 @@ function ComboBoxOption(props) {
|
|
|
9488
9648
|
},
|
|
9489
9649
|
get onHoverChange() {
|
|
9490
9650
|
return ariaProps.onHoverChange;
|
|
9651
|
+
},
|
|
9652
|
+
get onAction() {
|
|
9653
|
+
return local.onAction;
|
|
9491
9654
|
}
|
|
9492
|
-
},
|
|
9655
|
+
}, listState);
|
|
9493
9656
|
const isOptionFocusVisible = () => optionAria.isFocusVisible() || optionAria.isFocused() && (comboBoxContext?.isFocusVisible() ?? false);
|
|
9494
9657
|
const renderValues = createMemo(() => ({
|
|
9495
9658
|
isSelected: optionAria.isSelected(),
|
|
@@ -10047,7 +10210,9 @@ function ModalContent(props) {
|
|
|
10047
10210
|
isExiting: local.isExiting ?? false
|
|
10048
10211
|
}));
|
|
10049
10212
|
const renderProps = useRenderProps({
|
|
10050
|
-
children
|
|
10213
|
+
get children() {
|
|
10214
|
+
return props.children;
|
|
10215
|
+
},
|
|
10051
10216
|
class: local.class,
|
|
10052
10217
|
style: local.style,
|
|
10053
10218
|
defaultClassName: "solidaria-Modal"
|
|
@@ -10267,7 +10432,9 @@ function Popover(props) {
|
|
|
10267
10432
|
isExiting: local.isExiting ?? false
|
|
10268
10433
|
}));
|
|
10269
10434
|
const renderProps = useRenderProps({
|
|
10270
|
-
children
|
|
10435
|
+
get children() {
|
|
10436
|
+
return props.children;
|
|
10437
|
+
},
|
|
10271
10438
|
class: local.class,
|
|
10272
10439
|
style: local.style,
|
|
10273
10440
|
defaultClassName: "solidaria-Popover"
|
|
@@ -10308,6 +10475,11 @@ function Popover(props) {
|
|
|
10308
10475
|
};
|
|
10309
10476
|
};
|
|
10310
10477
|
const shouldBeDialog = () => !local.isNonModal || resolvedTrigger() === "SubmenuTrigger";
|
|
10478
|
+
const shouldContainFocus = () => {
|
|
10479
|
+
if (!shouldBeDialog()) return false;
|
|
10480
|
+
const trigger = resolvedTrigger();
|
|
10481
|
+
return trigger !== "MenuTrigger" && trigger !== "SubmenuTrigger";
|
|
10482
|
+
};
|
|
10311
10483
|
const portalContext = useUNSAFE_PortalContext();
|
|
10312
10484
|
const portalContainer = () => {
|
|
10313
10485
|
if (isSubPopover()) return popoverGroupContext?.() ?? portalContext.getContainer?.() ?? void 0;
|
|
@@ -10332,7 +10504,7 @@ function Popover(props) {
|
|
|
10332
10504
|
placement: popoverAria.placement,
|
|
10333
10505
|
arrowProps: () => popoverAria.arrowProps
|
|
10334
10506
|
}}>
|
|
10335
|
-
<FocusScope contain={
|
|
10507
|
+
<FocusScope contain={shouldContainFocus()} restoreFocus>
|
|
10336
10508
|
<div {...domProps()} {...cleanPopoverProps()} ref={popoverRef} id={overlayId()} role={shouldBeDialog() ? "dialog" : void 0} tabIndex={shouldBeDialog() ? -1 : void 0} class={renderProps.class()} style={mergedStyle()} data-trigger={resolvedTrigger()} data-placement={popoverAria.placement()} data-entering={dataAttr(local.isEntering)} data-exiting={dataAttr(local.isExiting)}>
|
|
10337
10509
|
<Show when={!local.isNonModal}>
|
|
10338
10510
|
<PopoverDismissButton onDismiss={close} />
|
|
@@ -10475,7 +10647,9 @@ function ToastRegion(props) {
|
|
|
10475
10647
|
});
|
|
10476
10648
|
const renderValues = createMemo(() => ({ visibleToasts: () => state()?.visibleToasts() ?? [] }));
|
|
10477
10649
|
const renderProps = useRenderProps({
|
|
10478
|
-
children
|
|
10650
|
+
get children() {
|
|
10651
|
+
return props.children;
|
|
10652
|
+
},
|
|
10479
10653
|
class: local.class,
|
|
10480
10654
|
style: local.style,
|
|
10481
10655
|
defaultClassName: "solidaria-ToastRegion"
|
|
@@ -11206,6 +11380,7 @@ function Tag(props) {
|
|
|
11206
11380
|
get key() {
|
|
11207
11381
|
return local.id;
|
|
11208
11382
|
},
|
|
11383
|
+
role: "row",
|
|
11209
11384
|
get isDisabled() {
|
|
11210
11385
|
return local.isDisabled || groupContext?.isDisabled;
|
|
11211
11386
|
},
|
|
@@ -12537,8 +12712,60 @@ function DatePickerInner(props) {
|
|
|
12537
12712
|
const [triggerRef, setTriggerRef] = createSignal(null);
|
|
12538
12713
|
const [fieldRef, setFieldRef] = createSignal(null);
|
|
12539
12714
|
const datePickerState = createDatePickerState({
|
|
12540
|
-
|
|
12541
|
-
|
|
12715
|
+
get value() {
|
|
12716
|
+
return stateProps.value;
|
|
12717
|
+
},
|
|
12718
|
+
get defaultValue() {
|
|
12719
|
+
return stateProps.defaultValue;
|
|
12720
|
+
},
|
|
12721
|
+
get onChange() {
|
|
12722
|
+
return stateProps.onChange;
|
|
12723
|
+
},
|
|
12724
|
+
get minValue() {
|
|
12725
|
+
return stateProps.minValue;
|
|
12726
|
+
},
|
|
12727
|
+
get maxValue() {
|
|
12728
|
+
return stateProps.maxValue;
|
|
12729
|
+
},
|
|
12730
|
+
get isDisabled() {
|
|
12731
|
+
return stateProps.isDisabled;
|
|
12732
|
+
},
|
|
12733
|
+
get isReadOnly() {
|
|
12734
|
+
return stateProps.isReadOnly;
|
|
12735
|
+
},
|
|
12736
|
+
get isRequired() {
|
|
12737
|
+
return stateProps.isRequired;
|
|
12738
|
+
},
|
|
12739
|
+
get granularity() {
|
|
12740
|
+
return stateProps.granularity;
|
|
12741
|
+
},
|
|
12742
|
+
get hourCycle() {
|
|
12743
|
+
return stateProps.hourCycle;
|
|
12744
|
+
},
|
|
12745
|
+
get hideTimeZone() {
|
|
12746
|
+
return stateProps.hideTimeZone;
|
|
12747
|
+
},
|
|
12748
|
+
get placeholderValue() {
|
|
12749
|
+
return stateProps.placeholderValue;
|
|
12750
|
+
},
|
|
12751
|
+
get shouldCloseOnSelect() {
|
|
12752
|
+
return local.shouldCloseOnSelect;
|
|
12753
|
+
},
|
|
12754
|
+
get defaultOpen() {
|
|
12755
|
+
return stateProps.defaultOpen;
|
|
12756
|
+
},
|
|
12757
|
+
get isOpen() {
|
|
12758
|
+
return stateProps.isOpen;
|
|
12759
|
+
},
|
|
12760
|
+
get onOpenChange() {
|
|
12761
|
+
return stateProps.onOpenChange;
|
|
12762
|
+
},
|
|
12763
|
+
get isDateUnavailable() {
|
|
12764
|
+
return stateProps.isDateUnavailable;
|
|
12765
|
+
},
|
|
12766
|
+
get validationState() {
|
|
12767
|
+
return stateProps.validationState;
|
|
12768
|
+
}
|
|
12542
12769
|
});
|
|
12543
12770
|
const overlayState = {
|
|
12544
12771
|
get isOpen() {
|