@wix/editor-react-components 1.2768.0 → 1.2769.0
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/site/components/AccordionComponent/AccordionItem.d.ts +1 -0
- package/dist/site/components/AccordionComponent/component.js +58 -4
- package/dist/site/components/AccordionComponent/css.css +1 -0
- package/dist/site/components/AccordionComponent/hooks.d.ts +5 -0
- package/dist/site/components/AccordionComponent/manifest.js +6 -2
- package/dist/site/components/Menu/component.js +1 -4
- package/dist/site/components/Menu/components/MenuContent/MenuItem/updateDropdownDomStyles.d.ts +0 -1
- package/dist/site/components/chunks/getWixBannerHeight.js +7 -0
- package/package.json +3 -3
|
@@ -7,6 +7,7 @@ export interface AccordionItemProps {
|
|
|
7
7
|
isOpen?: boolean;
|
|
8
8
|
titleHtmlTag?: string;
|
|
9
9
|
elementProps?: AccordionElementProps;
|
|
10
|
+
triggerRef?: React.Ref<HTMLButtonElement>;
|
|
10
11
|
}
|
|
11
12
|
declare const AccordionItem: React.FC<AccordionItemProps>;
|
|
12
13
|
export default AccordionItem;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import React__default, { useRef, useEffect, useMemo, useState, useCallback } from "react";
|
|
3
|
+
import React__default, { useRef, useEffect, useMemo, useState, useCallback, useLayoutEffect } from "react";
|
|
4
4
|
import "react-dom";
|
|
5
5
|
import { c as clsx } from "../chunks/clsx.js";
|
|
6
6
|
import AnimatedIconWithReducedMotion from "../AnimatedIcon/component.js";
|
|
7
7
|
import { D as DesignStates, a as DEFAULT_PROPS } from "../chunks/constants43.js";
|
|
8
8
|
import { g as getDefaultExportFromCjs } from "../chunks/_commonjsHelpers.js";
|
|
9
9
|
import { r as require_baseGetTag, d as require_root, b as require_Symbol, c as requireIsArray, a as requireIsObjectLike, e as require_freeGlobal } from "../chunks/isObjectLike.js";
|
|
10
|
+
import { useService } from "@wix/services-manager-react";
|
|
11
|
+
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
12
|
+
import { g as getWixBannerHeight } from "../chunks/getWixBannerHeight.js";
|
|
10
13
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
11
14
|
var isObject_1;
|
|
12
15
|
var hasRequiredIsObject;
|
|
@@ -2515,7 +2518,7 @@ const styles = {
|
|
|
2515
2518
|
};
|
|
2516
2519
|
const AccordionItem = (props) => {
|
|
2517
2520
|
var _a, _b, _c, _d, _e;
|
|
2518
|
-
const { item, isOpen, titleHtmlTag, elementProps } = props;
|
|
2521
|
+
const { item, isOpen, titleHtmlTag, elementProps, triggerRef } = props;
|
|
2519
2522
|
const { animatedIcon: animatedIconProps } = elementProps ?? {};
|
|
2520
2523
|
const animatedIconRef = useRef(null);
|
|
2521
2524
|
const isInitialRender = useRef(true);
|
|
@@ -2548,6 +2551,7 @@ const AccordionItem = (props) => {
|
|
|
2548
2551
|
/* @__PURE__ */ jsx(Header, { asChild: true, children: /* @__PURE__ */ jsx(HeaderTag, { children: /* @__PURE__ */ jsxs(
|
|
2549
2552
|
Trigger2,
|
|
2550
2553
|
{
|
|
2554
|
+
ref: triggerRef,
|
|
2551
2555
|
className: clsx(
|
|
2552
2556
|
"item-title",
|
|
2553
2557
|
styles["accordion-header"],
|
|
@@ -2687,6 +2691,51 @@ function useAccordionState(items, defaultOpen = "none", allowMultipleOpen = fals
|
|
|
2687
2691
|
handleValueChange
|
|
2688
2692
|
};
|
|
2689
2693
|
}
|
|
2694
|
+
function useScrollToClickedItem(openedItems, onValueChange) {
|
|
2695
|
+
const itemTriggersRef = useRef([]);
|
|
2696
|
+
const itemTriggerRefCallbacksRef = useRef(
|
|
2697
|
+
/* @__PURE__ */ new Map()
|
|
2698
|
+
);
|
|
2699
|
+
const clickedItemIdRef = useRef(void 0);
|
|
2700
|
+
const { reducedMotion } = useService(EnvironmentDefinition);
|
|
2701
|
+
useLayoutEffect(() => {
|
|
2702
|
+
const clickedItemId = clickedItemIdRef.current;
|
|
2703
|
+
clickedItemIdRef.current = void 0;
|
|
2704
|
+
if (clickedItemId === void 0) {
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
const clickedItemTrigger = itemTriggersRef.current[parseInt(clickedItemId, 10)];
|
|
2708
|
+
if (!clickedItemTrigger) {
|
|
2709
|
+
return;
|
|
2710
|
+
}
|
|
2711
|
+
const isTriggerHiddenAboveViewport = clickedItemTrigger.getBoundingClientRect().top < getWixBannerHeight();
|
|
2712
|
+
if (isTriggerHiddenAboveViewport) {
|
|
2713
|
+
clickedItemTrigger.scrollIntoView({
|
|
2714
|
+
block: "start",
|
|
2715
|
+
behavior: reducedMotion ? "instant" : "smooth"
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2718
|
+
}, [openedItems, reducedMotion]);
|
|
2719
|
+
const handleClickValueChange = useCallback(
|
|
2720
|
+
(value) => {
|
|
2721
|
+
clickedItemIdRef.current = normalizeAccordionValue(value).find(
|
|
2722
|
+
(id) => !openedItems.includes(id)
|
|
2723
|
+
);
|
|
2724
|
+
onValueChange(value);
|
|
2725
|
+
},
|
|
2726
|
+
[openedItems, onValueChange]
|
|
2727
|
+
);
|
|
2728
|
+
const getItemTriggerRef = useCallback((index) => {
|
|
2729
|
+
const refCallbacks = itemTriggerRefCallbacksRef.current;
|
|
2730
|
+
if (!refCallbacks.has(index)) {
|
|
2731
|
+
refCallbacks.set(index, (element) => {
|
|
2732
|
+
itemTriggersRef.current[index] = element;
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
return refCallbacks.get(index);
|
|
2736
|
+
}, []);
|
|
2737
|
+
return { handleClickValueChange, getItemTriggerRef };
|
|
2738
|
+
}
|
|
2690
2739
|
const AccordionContainer = (props) => {
|
|
2691
2740
|
var _a, _b;
|
|
2692
2741
|
const {
|
|
@@ -2715,6 +2764,10 @@ const AccordionContainer = (props) => {
|
|
|
2715
2764
|
activeItem,
|
|
2716
2765
|
previewItemContent
|
|
2717
2766
|
);
|
|
2767
|
+
const { handleClickValueChange, getItemTriggerRef } = useScrollToClickedItem(
|
|
2768
|
+
openedItems,
|
|
2769
|
+
handleValueChange
|
|
2770
|
+
);
|
|
2718
2771
|
const isMultipleMode = shouldUseMultipleMode(allowMultipleOpen, defaultOpen);
|
|
2719
2772
|
const conditionalProps = isMultipleMode ? {
|
|
2720
2773
|
type: "multiple",
|
|
@@ -2730,7 +2783,8 @@ const AccordionContainer = (props) => {
|
|
|
2730
2783
|
item: { ...item, id: index.toString() },
|
|
2731
2784
|
isOpen: openedItems.includes(index.toString()),
|
|
2732
2785
|
titleHtmlTag,
|
|
2733
|
-
elementProps
|
|
2786
|
+
elementProps,
|
|
2787
|
+
triggerRef: getItemTriggerRef(index)
|
|
2734
2788
|
},
|
|
2735
2789
|
index
|
|
2736
2790
|
));
|
|
@@ -2755,7 +2809,7 @@ const AccordionContainer = (props) => {
|
|
|
2755
2809
|
children: /* @__PURE__ */ jsx(
|
|
2756
2810
|
Root2,
|
|
2757
2811
|
{
|
|
2758
|
-
onValueChange:
|
|
2812
|
+
onValueChange: handleClickValueChange,
|
|
2759
2813
|
...conditionalProps,
|
|
2760
2814
|
className: styles["accordion-root"],
|
|
2761
2815
|
children: accordionChildren
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
justify-content: space-between;
|
|
19
19
|
text-align: start;
|
|
20
20
|
border-color: #000000;
|
|
21
|
+
scroll-margin-top: var(--wix-ads-height, 0px);
|
|
21
22
|
}
|
|
22
23
|
.accordion-header__eNiKz:hover .accordion-item-label__w-z9o, .accordion-header__eNiKz[data-state=open] .accordion-item-label__w-z9o, .accordion-header__eNiKz.accordion-component__item-title--hover .accordion-item-label__w-z9o, .accordion-header__eNiKz.accordion-component__item-title--selected .accordion-item-label__w-z9o {
|
|
23
24
|
text-decoration: underline;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { RefCallback } from 'react';
|
|
1
2
|
import { AccordionItem, AccordionContainerProps } from './types';
|
|
2
3
|
export declare function useAccordionState(items: Array<AccordionItem>, defaultOpen?: AccordionContainerProps['defaultOpen'], allowMultipleOpen?: boolean, activeItem?: number, previewItemContent?: boolean): {
|
|
3
4
|
openedItems: string[];
|
|
4
5
|
handleValueChange: (value: Array<string> | string) => void;
|
|
5
6
|
};
|
|
7
|
+
export declare function useScrollToClickedItem(openedItems: Array<string>, onValueChange: (value: Array<string> | string) => void): {
|
|
8
|
+
handleClickValueChange: (value: Array<string> | string) => void;
|
|
9
|
+
getItemTriggerRef: (index: number) => RefCallback<HTMLElement> | undefined;
|
|
10
|
+
};
|
|
@@ -354,11 +354,15 @@ const manifest = {
|
|
|
354
354
|
componentUrl: "./site/components/AccordionComponent/component.tsx",
|
|
355
355
|
moduleSpecifier: "@wix/editor-react-components/AccordionComponent",
|
|
356
356
|
dependencies: {
|
|
357
|
-
componentDependencies: ["@wix/editor-react-components/AnimatedIcon"]
|
|
357
|
+
componentDependencies: ["@wix/editor-react-components/AnimatedIcon"],
|
|
358
|
+
serviceDependencies: ["@wix/viewer-service-environment"]
|
|
358
359
|
}
|
|
359
360
|
},
|
|
360
361
|
editor: {
|
|
361
|
-
componentUrl: "./site/components/AccordionComponent/component.preview.tsx"
|
|
362
|
+
componentUrl: "./site/components/AccordionComponent/component.preview.tsx",
|
|
363
|
+
dependencies: {
|
|
364
|
+
serviceDependencies: ["@wix/viewer-service-environment"]
|
|
365
|
+
}
|
|
362
366
|
}
|
|
363
367
|
},
|
|
364
368
|
moduleConfiguration: {
|
|
@@ -11,6 +11,7 @@ import { g as getItemDepthSelector, r as rootItemDepthLevel, s as subItemDepthLe
|
|
|
11
11
|
import { d as debounce } from "../chunks/performanceUtils.js";
|
|
12
12
|
import { L as Link } from "../chunks/Link.js";
|
|
13
13
|
import { i as isEmptyObject, a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
14
|
+
import { g as getWixBannerHeight } from "../chunks/getWixBannerHeight.js";
|
|
14
15
|
import { u as useResizeObserver } from "../chunks/useResizeObserver.js";
|
|
15
16
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
16
17
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
@@ -1050,10 +1051,6 @@ const toBoxShadowLayers = (shadow) => {
|
|
|
1050
1051
|
}
|
|
1051
1052
|
return layers.length ? { layers } : void 0;
|
|
1052
1053
|
};
|
|
1053
|
-
const getWixBannerHeight = () => {
|
|
1054
|
-
const cssVarHeight = window.getComputedStyle(document.documentElement).getPropertyValue("--wix-ads-height");
|
|
1055
|
-
return Number.parseInt(cssVarHeight, 10) || 0;
|
|
1056
|
-
};
|
|
1057
1054
|
const getLeftForItemAnchor = ({ align, itemEl, dropdownEl }) => {
|
|
1058
1055
|
switch (align) {
|
|
1059
1056
|
case "start":
|
package/dist/site/components/Menu/components/MenuContent/MenuItem/updateDropdownDomStyles.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const getWixBannerHeight: () => number;
|
|
2
1
|
export declare const calculateShadowMargin: (dropdownEl: HTMLElement) => number;
|
|
3
2
|
export declare const updateDropdownDomStyles: (itemEl: HTMLElement | null, wasHiddenBefore?: boolean) => void;
|
|
4
3
|
export declare const resetDropdownDomStyles: (itemEl?: HTMLElement) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/editor-react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2769.0",
|
|
4
4
|
"description": "React components for the Wix Editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"@wix/component-protocol": "^1.253.0",
|
|
122
122
|
"@wix/components-infra": "^1.0.0",
|
|
123
123
|
"@wix/design-system": "^1.297.0",
|
|
124
|
-
"@wix/design-system-illustrations": "^2.
|
|
124
|
+
"@wix/design-system-illustrations": "^2.40.1",
|
|
125
125
|
"@wix/editor": "^1.726.0",
|
|
126
126
|
"@wix/editor-elements-scripts": "^1.0.0",
|
|
127
127
|
"@wix/editor-elements-test-utils": "^1.0.0",
|
|
@@ -222,5 +222,5 @@
|
|
|
222
222
|
"registry": "https://registry.npmjs.org/",
|
|
223
223
|
"access": "public"
|
|
224
224
|
},
|
|
225
|
-
"falconPackageHash": "
|
|
225
|
+
"falconPackageHash": "5f1e5a2e8246711fdb37f09376220b4ba9ba5f1657a69cef283203ea"
|
|
226
226
|
}
|