@wix/editor-react-components 1.2485.0 → 1.2487.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/BoxContainer/manifest.js +2 -0
- package/dist/site/components/Menu/component.js +1 -1
- package/dist/site/components/Menu/sdk.js +1 -1
- package/dist/site/components/ProgressBar/component.js +1 -1
- package/dist/site/components/ProgressBar/sdk.js +1 -1
- package/dist/site/components/SocialPlayerFacebook/SocialPlayerFacebook.types.d.ts +1 -1
- package/dist/site/components/SocialPlayerFacebook/component.js +4 -3
- package/dist/site/components/SocialPlayerInstagram/SocialPlayerInstagram.types.d.ts +1 -1
- package/dist/site/components/SocialPlayerInstagram/component.js +4 -3
- package/dist/site/components/SocialPlayerShared/SocialPlayersShared.types.d.ts +3 -0
- package/dist/site/components/SocialPlayerShared/utils.d.ts +6 -0
- package/dist/site/components/SocialPlayerSnapchat/SocialPlayerSnapchat.types.d.ts +1 -1
- package/dist/site/components/SocialPlayerSnapchat/component.js +8 -7
- package/dist/site/components/SocialPlayerTikTok/SocialPlayerTikTok.types.d.ts +1 -1
- package/dist/site/components/SocialPlayerTikTok/component.js +3 -2
- package/dist/site/components/SocialPlayerVimeo/SocialPlayerVimeo.types.d.ts +1 -1
- package/dist/site/components/SocialPlayerVimeo/component.js +5 -5
- package/dist/site/components/SocialPlayerYoutube/component.js +5 -4
- package/dist/site/components/chunks/utils.js +4 -9
- package/dist/site/components/chunks/utils2.js +7 -298
- package/dist/site/components/chunks/utils3.js +302 -0
- package/package.json +3 -3
|
@@ -43,6 +43,8 @@ const manifest = {
|
|
|
43
43
|
DATA.A11Y_ATTRIBUTES.ariaLive,
|
|
44
44
|
DATA.A11Y_ATTRIBUTES.ariaRoledescription,
|
|
45
45
|
DATA.A11Y_ATTRIBUTES.ariaLevel,
|
|
46
|
+
// Existing sites persist this value, so it must remain schema-valid.
|
|
47
|
+
DATA.A11Y_ATTRIBUTES.ariaHidden,
|
|
46
48
|
DATA.A11Y_ATTRIBUTES.ariaAtomic,
|
|
47
49
|
DATA.A11Y_ATTRIBUTES.ariaCurrent,
|
|
48
50
|
DATA.A11Y_ATTRIBUTES.ariaRelevant
|
|
@@ -7,7 +7,7 @@ import { T as TranslationsDefinition } from "../chunks/index6.js";
|
|
|
7
7
|
import { M as MenuAnimationName, d as defaultTranslations, a as MenuOrientation, A as AnimationPhase, V as VerticalDropdownDisplay, D as DropdownAnimationName, H as HamburgerMenuAnimationName, b as MenuParts, s as selectors, c as DesignStates, u as useAnimationState, e as ARIA_LABEL_NAMESPACE, t as translationsKeys } from "../chunks/constants27.js";
|
|
8
8
|
import React__default, { createContext, useContext, useRef, useCallback, useMemo, useState, useEffect, useLayoutEffect } from "react";
|
|
9
9
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
10
|
-
import { g as getItemDepthSelector, r as rootItemDepthLevel, s as subItemDepthLevel, a as subSubItemDepthLevel } from "../chunks/
|
|
10
|
+
import { g as getItemDepthSelector, r as rootItemDepthLevel, s as subItemDepthLevel, a as subSubItemDepthLevel } from "../chunks/utils3.js";
|
|
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";
|
|
@@ -2,7 +2,7 @@ import { c as createA11ySdk } from "../chunks/a11ySdk.js";
|
|
|
2
2
|
import { i as isNil, h as isDate, l as isObject, k as isArray } from "../chunks/assert.js";
|
|
3
3
|
import { b as registerCorvidMouseEvent } from "../chunks/corvidEvents.js";
|
|
4
4
|
import { c as composeSDKFactories } from "../chunks/composeSDKFactories.js";
|
|
5
|
-
import { v as validateMenuItems, c as createMenuDataItem } from "../chunks/
|
|
5
|
+
import { v as validateMenuItems, c as createMenuDataItem } from "../chunks/utils3.js";
|
|
6
6
|
import { L as LinkUtilsDefinition } from "../chunks/index.js";
|
|
7
7
|
const sanitizeItem = (item) => Object.entries(item).reduce((acc, [key, value]) => {
|
|
8
8
|
if (isNil(value)) {
|
|
@@ -4,7 +4,7 @@ import { c as clsx } from "../chunks/clsx.js";
|
|
|
4
4
|
import { g as getAccessibilityAttributesSpread, r as removeAriaPrefix } from "../chunks/a11y.js";
|
|
5
5
|
import { F as FULL_PROGRESS, N as NO_PROGRESS, T as TestIDs } from "../chunks/constants25.js";
|
|
6
6
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
7
|
-
import { g as getProgressValue } from "../chunks/
|
|
7
|
+
import { g as getProgressValue } from "../chunks/utils2.js";
|
|
8
8
|
const progressbar = "progressbar__A8aSK";
|
|
9
9
|
const barContainer = "barContainer__oNMgY";
|
|
10
10
|
const label = "label__tasBy";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as createA11ySdk } from "../chunks/a11ySdk.js";
|
|
2
2
|
import { c as composeSDKFactories } from "../chunks/composeSDKFactories.js";
|
|
3
3
|
import { F as FULL_PROGRESS, N as NO_PROGRESS } from "../chunks/constants25.js";
|
|
4
|
-
import { g as getProgressValue } from "../chunks/
|
|
4
|
+
import { g as getProgressValue } from "../chunks/utils2.js";
|
|
5
5
|
const PROGRESS_BAR_SDK_TYPE = "$w.ProgressBar";
|
|
6
6
|
const createProgressBarSdk = (api) => {
|
|
7
7
|
const { props, setProps } = api;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SocialPlayerSharedData, SocialPlayerSharedProps } from '../SocialPlayerShared/SocialPlayersShared.types';
|
|
2
|
-
export type SocialPlayerFacebookData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'autoPlay' | 'enabledCaptions'>;
|
|
2
|
+
export type SocialPlayerFacebookData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'a11y' | 'autoPlay' | 'enabledCaptions'>;
|
|
3
3
|
export type SocialPlayerFacebookProps = SocialPlayerSharedProps & SocialPlayerFacebookData;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { g as getAriaLabelAttribute } from "../chunks/utils.js";
|
|
3
|
+
import { c as clsx } from "../chunks/clsx.js";
|
|
2
4
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
3
5
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
4
|
-
import { c as clsx } from "../chunks/clsx.js";
|
|
5
6
|
const semanticClassNames = {
|
|
6
7
|
root: "social-player-facebook",
|
|
7
8
|
iFrame: "social-player-facebook__iframe"
|
|
@@ -26,7 +27,7 @@ const SocialPlayerFacebook = (props) => {
|
|
|
26
27
|
className,
|
|
27
28
|
customClassNames = [],
|
|
28
29
|
url,
|
|
29
|
-
|
|
30
|
+
a11y,
|
|
30
31
|
autoPlay = false,
|
|
31
32
|
enabledCaptions = false,
|
|
32
33
|
onMouseEnter,
|
|
@@ -51,7 +52,7 @@ const SocialPlayerFacebook = (props) => {
|
|
|
51
52
|
classes.iFrame,
|
|
52
53
|
formatClassNames(semanticClassNames.iFrame)
|
|
53
54
|
),
|
|
54
|
-
|
|
55
|
+
...getAriaLabelAttribute(a11y),
|
|
55
56
|
src: toEmbedUrl(url, { autoPlay, enabledCaptions }),
|
|
56
57
|
allow: "autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share",
|
|
57
58
|
allowFullScreen: true,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SocialPlayerSharedData, SocialPlayerSharedProps } from '../SocialPlayerShared/SocialPlayersShared.types';
|
|
2
|
-
export type SocialPlayerInstagramData = Pick<SocialPlayerSharedData, 'url' | 'description'>;
|
|
2
|
+
export type SocialPlayerInstagramData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'a11y'>;
|
|
3
3
|
export type SocialPlayerInstagramProps = SocialPlayerSharedProps & SocialPlayerInstagramData;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { g as getAriaLabelAttribute } from "../chunks/utils.js";
|
|
3
|
+
import { c as clsx } from "../chunks/clsx.js";
|
|
2
4
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
3
5
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
4
|
-
import { c as clsx } from "../chunks/clsx.js";
|
|
5
6
|
const semanticClassNames = {
|
|
6
7
|
root: "social-player-instagram",
|
|
7
8
|
iFrame: "social-player-instagram__iframe"
|
|
@@ -25,7 +26,7 @@ const SocialPlayerInstagram = (props) => {
|
|
|
25
26
|
className,
|
|
26
27
|
customClassNames = [],
|
|
27
28
|
url,
|
|
28
|
-
|
|
29
|
+
a11y,
|
|
29
30
|
onMouseEnter,
|
|
30
31
|
onMouseLeave
|
|
31
32
|
} = props;
|
|
@@ -48,7 +49,7 @@ const SocialPlayerInstagram = (props) => {
|
|
|
48
49
|
classes.iFrame,
|
|
49
50
|
formatClassNames(semanticClassNames.iFrame)
|
|
50
51
|
),
|
|
51
|
-
|
|
52
|
+
...getAriaLabelAttribute(a11y),
|
|
52
53
|
src: toEmbedUrl(url),
|
|
53
54
|
allow: "autoplay",
|
|
54
55
|
allowFullScreen: true,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { A11y } from '@wix/editor-react-types';
|
|
1
2
|
import { MouseEventHandler } from 'react';
|
|
3
|
+
export type SocialPlayerSharedA11y = Pick<A11y, 'ariaLabel'>;
|
|
2
4
|
export type SocialPlayerSharedData = {
|
|
3
5
|
url?: string;
|
|
4
6
|
description?: string;
|
|
7
|
+
a11y?: SocialPlayerSharedA11y;
|
|
5
8
|
autoPlay?: boolean;
|
|
6
9
|
loop?: boolean;
|
|
7
10
|
mute?: boolean;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { SocialPlayerSharedA11y } from './SocialPlayersShared.types';
|
|
1
2
|
export { formatClassNames } from '../../../utils/classNames';
|
|
2
3
|
export { getDataAttributes } from '../../../utils/dataUtils';
|
|
4
|
+
export declare const getAriaLabelAttribute: (a11y?: SocialPlayerSharedA11y | null) => {
|
|
5
|
+
'aria-label': string;
|
|
6
|
+
} | {
|
|
7
|
+
'aria-label'?: undefined;
|
|
8
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SocialPlayerSharedData, SocialPlayerSharedProps } from '../SocialPlayerShared/SocialPlayersShared.types';
|
|
2
|
-
export type SocialPlayerSnapchatData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'autoPlay'>;
|
|
2
|
+
export type SocialPlayerSnapchatData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'a11y' | 'autoPlay'>;
|
|
3
3
|
export type SocialPlayerSnapchatProps = SocialPlayerSharedProps & SocialPlayerSnapchatData;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { g as getAriaLabelAttribute } from "../chunks/utils.js";
|
|
4
3
|
import { c as clsx } from "../chunks/clsx.js";
|
|
5
4
|
import { useMemo } from "react";
|
|
5
|
+
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
6
|
+
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
6
7
|
const semanticClassNames = {
|
|
7
8
|
root: "social-player-snapchat"
|
|
8
9
|
};
|
|
@@ -39,7 +40,7 @@ const SocialPlayerSnapchat = (props) => {
|
|
|
39
40
|
url,
|
|
40
41
|
onMouseEnter,
|
|
41
42
|
onMouseLeave,
|
|
42
|
-
|
|
43
|
+
a11y,
|
|
43
44
|
autoPlay
|
|
44
45
|
} = props;
|
|
45
46
|
const embedUrl = useMemo(() => {
|
|
@@ -58,10 +59,10 @@ const SocialPlayerSnapchat = (props) => {
|
|
|
58
59
|
onMouseEnter,
|
|
59
60
|
onMouseLeave,
|
|
60
61
|
...getDataAttributes(props),
|
|
61
|
-
children: !embedUrl ? null : /* @__PURE__ */ jsx("div", { className: classes.alignmentWrapper, children: autoPlay ? /* @__PURE__ */ jsx(
|
|
62
|
+
children: !embedUrl ? null : /* @__PURE__ */ jsx("div", { className: classes.alignmentWrapper, children: autoPlay ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
62
63
|
"iframe",
|
|
63
64
|
{
|
|
64
|
-
|
|
65
|
+
...getAriaLabelAttribute(a11y),
|
|
65
66
|
src: embedUrl,
|
|
66
67
|
allow: "autoplay; camera; microphone; clipboard-write;",
|
|
67
68
|
width: "100%",
|
|
@@ -70,7 +71,7 @@ const SocialPlayerSnapchat = (props) => {
|
|
|
70
71
|
allowFullScreen: true,
|
|
71
72
|
allowTransparency: true
|
|
72
73
|
}
|
|
73
|
-
) : /* @__PURE__ */ jsx(
|
|
74
|
+
) }) : /* @__PURE__ */ jsx(
|
|
74
75
|
"div",
|
|
75
76
|
{
|
|
76
77
|
style: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SocialPlayerSharedData, SocialPlayerSharedProps } from '../SocialPlayerShared/SocialPlayersShared.types';
|
|
2
|
-
export type SocialPlayerTikTokData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'autoPlay' | 'enabledControls' | 'enabledTitle' | 'loop' | 'mute' | 'startTime' | 'endTime'>;
|
|
2
|
+
export type SocialPlayerTikTokData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'a11y' | 'autoPlay' | 'enabledControls' | 'enabledTitle' | 'loop' | 'mute' | 'startTime' | 'endTime'>;
|
|
3
3
|
export type ISocialPlayerTikTokProps = SocialPlayerSharedProps & SocialPlayerTikTokData;
|
|
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import React__default from "react";
|
|
4
4
|
import { c as clsx } from "../chunks/clsx.js";
|
|
5
|
+
import { g as getAriaLabelAttribute } from "../chunks/utils.js";
|
|
5
6
|
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
6
7
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
7
8
|
const isTikTokMessage = (message) => typeof message.data === "object" && Boolean(message.data["x-tiktok-player"]);
|
|
@@ -134,7 +135,7 @@ const SocialPlayerTikTok = ({
|
|
|
134
135
|
className,
|
|
135
136
|
customClassNames = [],
|
|
136
137
|
url,
|
|
137
|
-
|
|
138
|
+
a11y,
|
|
138
139
|
autoPlay = true,
|
|
139
140
|
loop = false,
|
|
140
141
|
mute = true,
|
|
@@ -175,9 +176,9 @@ const SocialPlayerTikTok = ({
|
|
|
175
176
|
"iframe",
|
|
176
177
|
{
|
|
177
178
|
"data-testid": TestIds.viewer.iframe,
|
|
179
|
+
...getAriaLabelAttribute(a11y),
|
|
178
180
|
loading: "lazy",
|
|
179
181
|
ref: setPlayerRef,
|
|
180
|
-
title: description,
|
|
181
182
|
width: "100%",
|
|
182
183
|
height: "100%",
|
|
183
184
|
src: generateVideoUrl({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SocialPlayerSharedData, SocialPlayerSharedProps } from '../SocialPlayerShared/SocialPlayersShared.types';
|
|
2
|
-
export type SocialPlayerVimeoData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'autoPlay' | 'enabledTitle' | 'loop' | 'mute' | 'startTime' | 'endTime'>;
|
|
2
|
+
export type SocialPlayerVimeoData = Pick<SocialPlayerSharedData, 'url' | 'description' | 'a11y' | 'autoPlay' | 'enabledTitle' | 'loop' | 'mute' | 'startTime' | 'endTime'>;
|
|
3
3
|
export type ISocialPlayerVimeoProps = SocialPlayerSharedProps & SocialPlayerVimeoData;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
2
|
+
import { g as getAriaLabelAttribute } from "../chunks/utils.js";
|
|
4
3
|
import { c as clsx } from "../chunks/clsx.js";
|
|
5
4
|
import { useCallback, useEffect, useRef } from "react";
|
|
5
|
+
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
6
|
+
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
6
7
|
const semanticClassNames = {
|
|
7
8
|
root: "social-player-vimeo"
|
|
8
9
|
};
|
|
@@ -3165,7 +3166,7 @@ const SocialPlayerVimeo = ({
|
|
|
3165
3166
|
className,
|
|
3166
3167
|
customClassNames = [],
|
|
3167
3168
|
url,
|
|
3168
|
-
|
|
3169
|
+
a11y,
|
|
3169
3170
|
autoPlay = false,
|
|
3170
3171
|
loop = false,
|
|
3171
3172
|
mute = false,
|
|
@@ -3196,11 +3197,10 @@ const SocialPlayerVimeo = ({
|
|
|
3196
3197
|
className,
|
|
3197
3198
|
formatClassNames(semanticClassNames.root, ...customClassNames)
|
|
3198
3199
|
),
|
|
3199
|
-
"aria-label": description,
|
|
3200
3200
|
onMouseEnter,
|
|
3201
3201
|
onMouseLeave,
|
|
3202
3202
|
...getDataAttributes(props),
|
|
3203
|
-
children: /* @__PURE__ */ jsx("div", { className: styles.playerWrapper, children: /* @__PURE__ */ jsx("div", { ref, className: styles.alignmentWrapper }) })
|
|
3203
|
+
children: /* @__PURE__ */ jsx("div", { className: styles.playerWrapper, ...getAriaLabelAttribute(a11y), children: /* @__PURE__ */ jsx("div", { ref, className: styles.alignmentWrapper }) })
|
|
3204
3204
|
}
|
|
3205
3205
|
);
|
|
3206
3206
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
2
|
+
import { g as getAriaLabelAttribute } from "../chunks/utils.js";
|
|
4
3
|
import { c as clsx } from "../chunks/clsx.js";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import { useMemo } from "react";
|
|
6
|
+
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
7
|
+
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
7
8
|
const semanticClassNames = {
|
|
8
9
|
root: "social-player-youtube"
|
|
9
10
|
};
|
|
@@ -146,7 +147,7 @@ const SocialPlayerYoutube = (props) => {
|
|
|
146
147
|
id,
|
|
147
148
|
className,
|
|
148
149
|
customClassNames = [],
|
|
149
|
-
|
|
150
|
+
a11y,
|
|
150
151
|
url,
|
|
151
152
|
mute = false,
|
|
152
153
|
autoPlay = false,
|
|
@@ -181,7 +182,7 @@ const SocialPlayerYoutube = (props) => {
|
|
|
181
182
|
"iframe",
|
|
182
183
|
{
|
|
183
184
|
"data-testid": TestIds.viewer.iframe,
|
|
184
|
-
|
|
185
|
+
...getAriaLabelAttribute(a11y),
|
|
185
186
|
style: aspectRatioStyles,
|
|
186
187
|
src: iframeUrl,
|
|
187
188
|
ref: playerElement,
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return NO_PROGRESS;
|
|
5
|
-
}
|
|
6
|
-
const relativeValue = Math.min(value / targetValue * 100, FULL_PROGRESS);
|
|
7
|
-
return +relativeValue.toFixed(2);
|
|
8
|
-
}
|
|
1
|
+
const getAriaLabelAttribute = (a11y) => {
|
|
2
|
+
return (a11y == null ? void 0 : a11y.ariaLabel) ? { "aria-label": a11y.ariaLabel } : {};
|
|
3
|
+
};
|
|
9
4
|
export {
|
|
10
|
-
|
|
5
|
+
getAriaLabelAttribute as g
|
|
11
6
|
};
|
|
@@ -1,302 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(params) {
|
|
6
|
-
const message = nilAssignmentMessage(params);
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = "NilAssignmentError";
|
|
9
|
-
this.message = message;
|
|
1
|
+
import { N as NO_PROGRESS, F as FULL_PROGRESS } from "./constants25.js";
|
|
2
|
+
function getProgressValue(value = NO_PROGRESS, targetValue = FULL_PROGRESS) {
|
|
3
|
+
if (targetValue === 0) {
|
|
4
|
+
return NO_PROGRESS;
|
|
10
5
|
}
|
|
6
|
+
const relativeValue = Math.min(value / targetValue * 100, FULL_PROGRESS);
|
|
7
|
+
return +relativeValue.toFixed(2);
|
|
11
8
|
}
|
|
12
|
-
class UnsupportedLinkTypeError extends Error {
|
|
13
|
-
constructor(params) {
|
|
14
|
-
const message = unsupportedLinkType(params);
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = "UnsupportedLinkTypeError";
|
|
17
|
-
this.message = message;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
class InvalidLabelError extends NilAssignmentError {
|
|
21
|
-
constructor(index) {
|
|
22
|
-
super({
|
|
23
|
-
functionName: "menuItems",
|
|
24
|
-
propertyName: "label",
|
|
25
|
-
index
|
|
26
|
-
});
|
|
27
|
-
this.name = "InvalidLabelError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
class InvalidIdPatternError extends Error {
|
|
31
|
-
constructor({
|
|
32
|
-
index,
|
|
33
|
-
label,
|
|
34
|
-
id
|
|
35
|
-
}) {
|
|
36
|
-
super(
|
|
37
|
-
templates.error_menu_items_id_pattern({
|
|
38
|
-
index,
|
|
39
|
-
label,
|
|
40
|
-
id
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
this.name = "InvalidIdPatternError";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
class NonUniqueIdError extends Error {
|
|
47
|
-
constructor({ id }) {
|
|
48
|
-
super(templates.error_menu_items_id_uniqueness({ id }));
|
|
49
|
-
this.name = "NonUniqueIdError";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
class InvalidTargetError extends Error {
|
|
53
|
-
constructor({
|
|
54
|
-
index,
|
|
55
|
-
label,
|
|
56
|
-
target
|
|
57
|
-
}) {
|
|
58
|
-
super(
|
|
59
|
-
templates.error_menu_items_target({
|
|
60
|
-
index,
|
|
61
|
-
label,
|
|
62
|
-
target
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
this.name = "InvalidTargetError";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
class InvalidMenuDepthError extends Error {
|
|
69
|
-
constructor(maxLevels, labelValue) {
|
|
70
|
-
super(
|
|
71
|
-
templates.error_menu_items_depth({
|
|
72
|
-
labelValue,
|
|
73
|
-
maxLevels
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
this.name = "InvalidMenuDepth";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
class LinkTypeError extends UnsupportedLinkTypeError {
|
|
80
|
-
constructor(wrongValue, index) {
|
|
81
|
-
super({
|
|
82
|
-
functionName: "menuItems",
|
|
83
|
-
propertyName: "link",
|
|
84
|
-
wrongValue,
|
|
85
|
-
index
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const idPattern = /^[a-zA-Z\d-]*$/;
|
|
90
|
-
const validateIdPattern = (items, parentIndex) => {
|
|
91
|
-
items == null ? void 0 : items.every(({ id, link = "", label = link, menuItems }, index) => {
|
|
92
|
-
if (id && !idPattern.test(id)) {
|
|
93
|
-
throw new InvalidIdPatternError({
|
|
94
|
-
index: parentIndex === void 0 ? index : parentIndex,
|
|
95
|
-
label,
|
|
96
|
-
id
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return validateIdPattern(menuItems, index);
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
const validateIdUniqueness = (items) => {
|
|
103
|
-
const ids = getItemIds(items || []);
|
|
104
|
-
const duplicatedId = findDuplicate(ids);
|
|
105
|
-
if (duplicatedId !== void 0) {
|
|
106
|
-
throw new NonUniqueIdError({ id: duplicatedId });
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const getItemIds = (menuItems) => {
|
|
110
|
-
return menuItems.reduce(
|
|
111
|
-
(agg, curr) => {
|
|
112
|
-
return [
|
|
113
|
-
...agg,
|
|
114
|
-
...isString(curr.id) ? [curr.id] : [],
|
|
115
|
-
...curr.menuItems ? getItemIds(curr.menuItems) : []
|
|
116
|
-
];
|
|
117
|
-
},
|
|
118
|
-
[]
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
const findDuplicate = (arr) => {
|
|
122
|
-
return arr.find((value, idx) => {
|
|
123
|
-
return idx !== arr.lastIndexOf(value);
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
const validateMenuItemsId = (menuItems) => {
|
|
127
|
-
try {
|
|
128
|
-
validateIdUniqueness(menuItems);
|
|
129
|
-
validateIdPattern(menuItems);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
reportError(error.message);
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
return true;
|
|
135
|
-
};
|
|
136
|
-
const validateMenuItemsTarget = (value) => {
|
|
137
|
-
if (!value) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
const checkMenuItemsTarget = (items, parentIndex) => (items == null ? void 0 : items.every(({ target, link = "", label = link, menuItems }, index) => {
|
|
141
|
-
if (target != null && target !== "_blank" && target !== "_self") {
|
|
142
|
-
throw new InvalidTargetError({
|
|
143
|
-
index: parentIndex === void 0 ? index : parentIndex,
|
|
144
|
-
label,
|
|
145
|
-
target
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
return checkMenuItemsTarget(menuItems, index);
|
|
149
|
-
})) ?? true;
|
|
150
|
-
try {
|
|
151
|
-
return checkMenuItemsTarget(value);
|
|
152
|
-
} catch (error) {
|
|
153
|
-
reportError(error.message);
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
const validateMenuItemsDepth = (maxLevels) => (value) => {
|
|
158
|
-
if (!value) {
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
const checkMenuItemsLevel = ({
|
|
162
|
-
currentLevel,
|
|
163
|
-
items
|
|
164
|
-
}) => {
|
|
165
|
-
if (!items) {
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
if (items.length === 0) {
|
|
169
|
-
return true;
|
|
170
|
-
} else if (currentLevel < 0) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
return items.every(({ menuItems, label, link }) => {
|
|
174
|
-
const hasMenuItems = typeof menuItems !== "undefined";
|
|
175
|
-
if (!hasMenuItems) {
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
const isValidMenuItems = checkMenuItemsLevel({
|
|
179
|
-
items: menuItems,
|
|
180
|
-
currentLevel: currentLevel - 1
|
|
181
|
-
});
|
|
182
|
-
if (!isValidMenuItems) {
|
|
183
|
-
throw new InvalidMenuDepthError(maxLevels + 1, label || link || "");
|
|
184
|
-
}
|
|
185
|
-
return isValidMenuItems;
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
return value.every(({ menuItems, label, link }) => {
|
|
189
|
-
try {
|
|
190
|
-
const result = checkMenuItemsLevel({
|
|
191
|
-
items: menuItems,
|
|
192
|
-
currentLevel: maxLevels - 1
|
|
193
|
-
});
|
|
194
|
-
if (result === false) {
|
|
195
|
-
throw new InvalidMenuDepthError(maxLevels + 1, label || link || "");
|
|
196
|
-
}
|
|
197
|
-
} catch (error) {
|
|
198
|
-
reportError(error.message);
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
return true;
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
const pageUrlRegex = /^\/([^ ?#]*)[?]?(.*)/;
|
|
205
|
-
const isPageUrl = (url) => pageUrlRegex.test(url);
|
|
206
|
-
const getLink = ({
|
|
207
|
-
link,
|
|
208
|
-
target,
|
|
209
|
-
linkUtils
|
|
210
|
-
}) => {
|
|
211
|
-
if (!isNil(link)) {
|
|
212
|
-
const passedTarget = target;
|
|
213
|
-
return linkUtils.getLinkProps(link, passedTarget);
|
|
214
|
-
}
|
|
215
|
-
return {};
|
|
216
|
-
};
|
|
217
|
-
const getPageTitleFromUrl = (url, pageList) => {
|
|
218
|
-
var _a;
|
|
219
|
-
const key = url.slice(1);
|
|
220
|
-
if (pageList.hasOwnProperty(key)) {
|
|
221
|
-
return (_a = pageList[key]) == null ? void 0 : _a.title;
|
|
222
|
-
}
|
|
223
|
-
return void 0;
|
|
224
|
-
};
|
|
225
|
-
const getLabel = ({
|
|
226
|
-
link,
|
|
227
|
-
label,
|
|
228
|
-
pageList
|
|
229
|
-
}) => {
|
|
230
|
-
if (!isNil(label)) {
|
|
231
|
-
return label;
|
|
232
|
-
}
|
|
233
|
-
if (!isNil(link) && isPageUrl(link)) {
|
|
234
|
-
return getPageTitleFromUrl(link, pageList);
|
|
235
|
-
}
|
|
236
|
-
return void 0;
|
|
237
|
-
};
|
|
238
|
-
const validators = [
|
|
239
|
-
validateMenuItemsDepth(1),
|
|
240
|
-
validateMenuItemsTarget,
|
|
241
|
-
validateMenuItemsId
|
|
242
|
-
];
|
|
243
|
-
const validateMenuItems = (menuItems) => {
|
|
244
|
-
let isValid = true;
|
|
245
|
-
isValid = validators.every((validator) => validator(menuItems));
|
|
246
|
-
return isValid;
|
|
247
|
-
};
|
|
248
|
-
const getMenuItems = (linkUtils, pageList, items) => {
|
|
249
|
-
if (isArray(items)) {
|
|
250
|
-
return items.map(
|
|
251
|
-
(menuItem, i) => createMenuDataItem(menuItem, i, linkUtils, pageList)
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
return [];
|
|
255
|
-
};
|
|
256
|
-
const createMenuDataItem = (menuDataItem, index, linkUtils, pageList) => {
|
|
257
|
-
const menuSdkItem = {};
|
|
258
|
-
try {
|
|
259
|
-
const linkData = getLink({
|
|
260
|
-
linkUtils,
|
|
261
|
-
link: menuDataItem.link,
|
|
262
|
-
target: menuDataItem.target || "_self"
|
|
263
|
-
});
|
|
264
|
-
if (linkData.href) {
|
|
265
|
-
menuSdkItem.link = linkData.href;
|
|
266
|
-
menuSdkItem.target = linkData.target || "_self";
|
|
267
|
-
}
|
|
268
|
-
} catch (error) {
|
|
269
|
-
throw new LinkTypeError(menuDataItem.link || "", index);
|
|
270
|
-
}
|
|
271
|
-
const label = getLabel({
|
|
272
|
-
label: menuDataItem.label,
|
|
273
|
-
link: menuDataItem.link,
|
|
274
|
-
pageList
|
|
275
|
-
});
|
|
276
|
-
if (isNil(label)) {
|
|
277
|
-
throw new InvalidLabelError(index);
|
|
278
|
-
}
|
|
279
|
-
if (!isNil(menuDataItem.id)) {
|
|
280
|
-
menuSdkItem.id = menuDataItem.id;
|
|
281
|
-
}
|
|
282
|
-
menuSdkItem.label = label;
|
|
283
|
-
if (!isNil(menuDataItem.selected)) {
|
|
284
|
-
menuSdkItem.selected = menuDataItem.selected;
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
...menuSdkItem,
|
|
288
|
-
menuItems: getMenuItems(linkUtils, pageList, menuDataItem.menuItems)
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
const rootItemDepthLevel = 0;
|
|
292
|
-
const subItemDepthLevel = 1;
|
|
293
|
-
const subSubItemDepthLevel = 2;
|
|
294
|
-
const getItemDepthSelector = (depth) => `[data-item-depth="${depth}"]`;
|
|
295
9
|
export {
|
|
296
|
-
|
|
297
|
-
createMenuDataItem as c,
|
|
298
|
-
getItemDepthSelector as g,
|
|
299
|
-
rootItemDepthLevel as r,
|
|
300
|
-
subItemDepthLevel as s,
|
|
301
|
-
validateMenuItems as v
|
|
10
|
+
getProgressValue as g
|
|
302
11
|
};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { r as reportError } from "./reporters.js";
|
|
2
|
+
import { f as isString, i as isNil, k as isArray } from "./assert.js";
|
|
3
|
+
import { d as unsupportedLinkType, n as nilAssignmentMessage, t as templates } from "./messages.js";
|
|
4
|
+
class NilAssignmentError extends Error {
|
|
5
|
+
constructor(params) {
|
|
6
|
+
const message = nilAssignmentMessage(params);
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "NilAssignmentError";
|
|
9
|
+
this.message = message;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class UnsupportedLinkTypeError extends Error {
|
|
13
|
+
constructor(params) {
|
|
14
|
+
const message = unsupportedLinkType(params);
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "UnsupportedLinkTypeError";
|
|
17
|
+
this.message = message;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
class InvalidLabelError extends NilAssignmentError {
|
|
21
|
+
constructor(index) {
|
|
22
|
+
super({
|
|
23
|
+
functionName: "menuItems",
|
|
24
|
+
propertyName: "label",
|
|
25
|
+
index
|
|
26
|
+
});
|
|
27
|
+
this.name = "InvalidLabelError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class InvalidIdPatternError extends Error {
|
|
31
|
+
constructor({
|
|
32
|
+
index,
|
|
33
|
+
label,
|
|
34
|
+
id
|
|
35
|
+
}) {
|
|
36
|
+
super(
|
|
37
|
+
templates.error_menu_items_id_pattern({
|
|
38
|
+
index,
|
|
39
|
+
label,
|
|
40
|
+
id
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
this.name = "InvalidIdPatternError";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class NonUniqueIdError extends Error {
|
|
47
|
+
constructor({ id }) {
|
|
48
|
+
super(templates.error_menu_items_id_uniqueness({ id }));
|
|
49
|
+
this.name = "NonUniqueIdError";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class InvalidTargetError extends Error {
|
|
53
|
+
constructor({
|
|
54
|
+
index,
|
|
55
|
+
label,
|
|
56
|
+
target
|
|
57
|
+
}) {
|
|
58
|
+
super(
|
|
59
|
+
templates.error_menu_items_target({
|
|
60
|
+
index,
|
|
61
|
+
label,
|
|
62
|
+
target
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
this.name = "InvalidTargetError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class InvalidMenuDepthError extends Error {
|
|
69
|
+
constructor(maxLevels, labelValue) {
|
|
70
|
+
super(
|
|
71
|
+
templates.error_menu_items_depth({
|
|
72
|
+
labelValue,
|
|
73
|
+
maxLevels
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
this.name = "InvalidMenuDepth";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class LinkTypeError extends UnsupportedLinkTypeError {
|
|
80
|
+
constructor(wrongValue, index) {
|
|
81
|
+
super({
|
|
82
|
+
functionName: "menuItems",
|
|
83
|
+
propertyName: "link",
|
|
84
|
+
wrongValue,
|
|
85
|
+
index
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const idPattern = /^[a-zA-Z\d-]*$/;
|
|
90
|
+
const validateIdPattern = (items, parentIndex) => {
|
|
91
|
+
items == null ? void 0 : items.every(({ id, link = "", label = link, menuItems }, index) => {
|
|
92
|
+
if (id && !idPattern.test(id)) {
|
|
93
|
+
throw new InvalidIdPatternError({
|
|
94
|
+
index: parentIndex === void 0 ? index : parentIndex,
|
|
95
|
+
label,
|
|
96
|
+
id
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return validateIdPattern(menuItems, index);
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const validateIdUniqueness = (items) => {
|
|
103
|
+
const ids = getItemIds(items || []);
|
|
104
|
+
const duplicatedId = findDuplicate(ids);
|
|
105
|
+
if (duplicatedId !== void 0) {
|
|
106
|
+
throw new NonUniqueIdError({ id: duplicatedId });
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const getItemIds = (menuItems) => {
|
|
110
|
+
return menuItems.reduce(
|
|
111
|
+
(agg, curr) => {
|
|
112
|
+
return [
|
|
113
|
+
...agg,
|
|
114
|
+
...isString(curr.id) ? [curr.id] : [],
|
|
115
|
+
...curr.menuItems ? getItemIds(curr.menuItems) : []
|
|
116
|
+
];
|
|
117
|
+
},
|
|
118
|
+
[]
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
const findDuplicate = (arr) => {
|
|
122
|
+
return arr.find((value, idx) => {
|
|
123
|
+
return idx !== arr.lastIndexOf(value);
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const validateMenuItemsId = (menuItems) => {
|
|
127
|
+
try {
|
|
128
|
+
validateIdUniqueness(menuItems);
|
|
129
|
+
validateIdPattern(menuItems);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
reportError(error.message);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
};
|
|
136
|
+
const validateMenuItemsTarget = (value) => {
|
|
137
|
+
if (!value) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
const checkMenuItemsTarget = (items, parentIndex) => (items == null ? void 0 : items.every(({ target, link = "", label = link, menuItems }, index) => {
|
|
141
|
+
if (target != null && target !== "_blank" && target !== "_self") {
|
|
142
|
+
throw new InvalidTargetError({
|
|
143
|
+
index: parentIndex === void 0 ? index : parentIndex,
|
|
144
|
+
label,
|
|
145
|
+
target
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return checkMenuItemsTarget(menuItems, index);
|
|
149
|
+
})) ?? true;
|
|
150
|
+
try {
|
|
151
|
+
return checkMenuItemsTarget(value);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
reportError(error.message);
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const validateMenuItemsDepth = (maxLevels) => (value) => {
|
|
158
|
+
if (!value) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
const checkMenuItemsLevel = ({
|
|
162
|
+
currentLevel,
|
|
163
|
+
items
|
|
164
|
+
}) => {
|
|
165
|
+
if (!items) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (items.length === 0) {
|
|
169
|
+
return true;
|
|
170
|
+
} else if (currentLevel < 0) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return items.every(({ menuItems, label, link }) => {
|
|
174
|
+
const hasMenuItems = typeof menuItems !== "undefined";
|
|
175
|
+
if (!hasMenuItems) {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
const isValidMenuItems = checkMenuItemsLevel({
|
|
179
|
+
items: menuItems,
|
|
180
|
+
currentLevel: currentLevel - 1
|
|
181
|
+
});
|
|
182
|
+
if (!isValidMenuItems) {
|
|
183
|
+
throw new InvalidMenuDepthError(maxLevels + 1, label || link || "");
|
|
184
|
+
}
|
|
185
|
+
return isValidMenuItems;
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
return value.every(({ menuItems, label, link }) => {
|
|
189
|
+
try {
|
|
190
|
+
const result = checkMenuItemsLevel({
|
|
191
|
+
items: menuItems,
|
|
192
|
+
currentLevel: maxLevels - 1
|
|
193
|
+
});
|
|
194
|
+
if (result === false) {
|
|
195
|
+
throw new InvalidMenuDepthError(maxLevels + 1, label || link || "");
|
|
196
|
+
}
|
|
197
|
+
} catch (error) {
|
|
198
|
+
reportError(error.message);
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
const pageUrlRegex = /^\/([^ ?#]*)[?]?(.*)/;
|
|
205
|
+
const isPageUrl = (url) => pageUrlRegex.test(url);
|
|
206
|
+
const getLink = ({
|
|
207
|
+
link,
|
|
208
|
+
target,
|
|
209
|
+
linkUtils
|
|
210
|
+
}) => {
|
|
211
|
+
if (!isNil(link)) {
|
|
212
|
+
const passedTarget = target;
|
|
213
|
+
return linkUtils.getLinkProps(link, passedTarget);
|
|
214
|
+
}
|
|
215
|
+
return {};
|
|
216
|
+
};
|
|
217
|
+
const getPageTitleFromUrl = (url, pageList) => {
|
|
218
|
+
var _a;
|
|
219
|
+
const key = url.slice(1);
|
|
220
|
+
if (pageList.hasOwnProperty(key)) {
|
|
221
|
+
return (_a = pageList[key]) == null ? void 0 : _a.title;
|
|
222
|
+
}
|
|
223
|
+
return void 0;
|
|
224
|
+
};
|
|
225
|
+
const getLabel = ({
|
|
226
|
+
link,
|
|
227
|
+
label,
|
|
228
|
+
pageList
|
|
229
|
+
}) => {
|
|
230
|
+
if (!isNil(label)) {
|
|
231
|
+
return label;
|
|
232
|
+
}
|
|
233
|
+
if (!isNil(link) && isPageUrl(link)) {
|
|
234
|
+
return getPageTitleFromUrl(link, pageList);
|
|
235
|
+
}
|
|
236
|
+
return void 0;
|
|
237
|
+
};
|
|
238
|
+
const validators = [
|
|
239
|
+
validateMenuItemsDepth(1),
|
|
240
|
+
validateMenuItemsTarget,
|
|
241
|
+
validateMenuItemsId
|
|
242
|
+
];
|
|
243
|
+
const validateMenuItems = (menuItems) => {
|
|
244
|
+
let isValid = true;
|
|
245
|
+
isValid = validators.every((validator) => validator(menuItems));
|
|
246
|
+
return isValid;
|
|
247
|
+
};
|
|
248
|
+
const getMenuItems = (linkUtils, pageList, items) => {
|
|
249
|
+
if (isArray(items)) {
|
|
250
|
+
return items.map(
|
|
251
|
+
(menuItem, i) => createMenuDataItem(menuItem, i, linkUtils, pageList)
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
return [];
|
|
255
|
+
};
|
|
256
|
+
const createMenuDataItem = (menuDataItem, index, linkUtils, pageList) => {
|
|
257
|
+
const menuSdkItem = {};
|
|
258
|
+
try {
|
|
259
|
+
const linkData = getLink({
|
|
260
|
+
linkUtils,
|
|
261
|
+
link: menuDataItem.link,
|
|
262
|
+
target: menuDataItem.target || "_self"
|
|
263
|
+
});
|
|
264
|
+
if (linkData.href) {
|
|
265
|
+
menuSdkItem.link = linkData.href;
|
|
266
|
+
menuSdkItem.target = linkData.target || "_self";
|
|
267
|
+
}
|
|
268
|
+
} catch (error) {
|
|
269
|
+
throw new LinkTypeError(menuDataItem.link || "", index);
|
|
270
|
+
}
|
|
271
|
+
const label = getLabel({
|
|
272
|
+
label: menuDataItem.label,
|
|
273
|
+
link: menuDataItem.link,
|
|
274
|
+
pageList
|
|
275
|
+
});
|
|
276
|
+
if (isNil(label)) {
|
|
277
|
+
throw new InvalidLabelError(index);
|
|
278
|
+
}
|
|
279
|
+
if (!isNil(menuDataItem.id)) {
|
|
280
|
+
menuSdkItem.id = menuDataItem.id;
|
|
281
|
+
}
|
|
282
|
+
menuSdkItem.label = label;
|
|
283
|
+
if (!isNil(menuDataItem.selected)) {
|
|
284
|
+
menuSdkItem.selected = menuDataItem.selected;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
...menuSdkItem,
|
|
288
|
+
menuItems: getMenuItems(linkUtils, pageList, menuDataItem.menuItems)
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
const rootItemDepthLevel = 0;
|
|
292
|
+
const subItemDepthLevel = 1;
|
|
293
|
+
const subSubItemDepthLevel = 2;
|
|
294
|
+
const getItemDepthSelector = (depth) => `[data-item-depth="${depth}"]`;
|
|
295
|
+
export {
|
|
296
|
+
subSubItemDepthLevel as a,
|
|
297
|
+
createMenuDataItem as c,
|
|
298
|
+
getItemDepthSelector as g,
|
|
299
|
+
rootItemDepthLevel as r,
|
|
300
|
+
subItemDepthLevel as s,
|
|
301
|
+
validateMenuItems as v
|
|
302
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/editor-react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2487.0",
|
|
4
4
|
"description": "React components for the Wix Editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@wix/sdk": "^1.21.14",
|
|
83
83
|
"@wix/services-manager-react": "^0.1.27",
|
|
84
84
|
"@wix/site-service-rendering-context": "^1.0.1",
|
|
85
|
-
"@wix/site-ui": "1.
|
|
85
|
+
"@wix/site-ui": "1.215.0",
|
|
86
86
|
"@wix/video": "^1.85.0",
|
|
87
87
|
"@wix/viewer-service-consent-policy": "^1.0.101",
|
|
88
88
|
"@wix/web-bi-logger": "^2.1.29",
|
|
@@ -197,5 +197,5 @@
|
|
|
197
197
|
"registry": "https://registry.npmjs.org/",
|
|
198
198
|
"access": "public"
|
|
199
199
|
},
|
|
200
|
-
"falconPackageHash": "
|
|
200
|
+
"falconPackageHash": "5a699110253634320fa858383a7288b23e44a7cde57f3cb6a53ee227"
|
|
201
201
|
}
|