@openedx/paragon 23.15.0 → 23.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Menu/MenuItem.d.ts +4 -4
- package/dist/Menu/MenuItem.js.map +1 -1
- package/dist/Menu/index.d.ts +4 -4
- package/dist/Menu/index.js.map +1 -1
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Stack/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Menu/MenuItem.tsx +12 -6
- package/src/Menu/index.tsx +12 -6
- package/src/Stack/index.tsx +2 -2
package/dist/Menu/MenuItem.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { ReactElement, ReactNode, ElementType } from 'react';
|
|
2
|
-
interface MenuItemProps {
|
|
1
|
+
import React, { type ReactElement, type ReactNode, type ElementType, type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
interface MenuItemProps<As extends ElementType> {
|
|
3
3
|
/** Specifies that this `MenuItem` is selected inside the `SelectMenu` */
|
|
4
4
|
defaultSelected?: boolean;
|
|
5
5
|
/** Specifies class name to append to the base element */
|
|
@@ -7,11 +7,11 @@ interface MenuItemProps {
|
|
|
7
7
|
/** Specifies the content of the `MenuItem` */
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
/** Specifies the base element */
|
|
10
|
-
as?:
|
|
10
|
+
as?: As;
|
|
11
11
|
/** Specifies the jsx before the content of the `MenuItem` */
|
|
12
12
|
iconBefore?: ReactElement | ElementType;
|
|
13
13
|
/** Specifies the jsx after the content of the `MenuItem` */
|
|
14
14
|
iconAfter?: ReactElement | ElementType;
|
|
15
15
|
}
|
|
16
|
-
declare function MenuItem({ as, children, defaultSelected, iconAfter, iconBefore, ...props }: MenuItemProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
16
|
+
declare function MenuItem<As extends ElementType = 'button'>({ as, children, defaultSelected, iconAfter, iconBefore, ...props }: MenuItemProps<As> & ComponentPropsWithoutRef<As>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
17
17
|
export default MenuItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.js","names":["React","createElement","classNames","Icon","MenuItem","as","children","defaultSelected","iconAfter","iconBefore","props","className","Fragment","src"],"sources":["../../src/Menu/MenuItem.tsx"],"sourcesContent":["import React, {\n ReactElement
|
|
1
|
+
{"version":3,"file":"MenuItem.js","names":["React","createElement","classNames","Icon","MenuItem","as","children","defaultSelected","iconAfter","iconBefore","props","className","Fragment","src"],"sources":["../../src/Menu/MenuItem.tsx"],"sourcesContent":["import React, {\n type ReactElement,\n type ReactNode,\n type ElementType,\n createElement,\n type ComponentType,\n type ComponentPropsWithoutRef,\n} from 'react';\nimport classNames from 'classnames';\nimport Icon from '../Icon';\n\ninterface MenuItemProps<As extends ElementType> {\n /** Specifies that this `MenuItem` is selected inside the `SelectMenu` */\n defaultSelected?: boolean;\n /** Specifies class name to append to the base element */\n className?: string;\n /** Specifies the content of the `MenuItem` */\n children: ReactNode;\n /** Specifies the base element */\n as?: As;\n /** Specifies the jsx before the content of the `MenuItem` */\n iconBefore?: ReactElement | ElementType;\n /** Specifies the jsx after the content of the `MenuItem` */\n iconAfter?: ReactElement | ElementType;\n}\n\nfunction MenuItem<As extends ElementType = 'button'>({\n as = 'button' as As,\n children,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n defaultSelected = false,\n iconAfter,\n iconBefore,\n ...props\n}: MenuItemProps<As> & ComponentPropsWithoutRef<As>) {\n const className = classNames(props.className, 'pgn__menu-item');\n\n return createElement(\n as,\n {\n ...props,\n className,\n },\n (\n <>\n {iconBefore && <Icon className=\"btn-icon-before\" src={iconBefore as ComponentType} />}\n <span className=\"pgn__menu-item-text\">{children}</span>\n <span className=\"pgn__menu-item-content-spacer\" />\n {iconAfter && <Icon className=\"btn-icon-after\" src={iconAfter as ComponentType} />}\n </>\n ),\n );\n}\n\nexport default MenuItem;\n"],"mappings":"AAAA,OAAOA,KAAK,IAIVC,aAAa,QAGR,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,IAAI,MAAM,SAAS;AAiB1B,SAASC,QAAQA,CAAoC;EACnDC,EAAE,GAAG,QAAc;EACnBC,QAAQ;EACR;EACAC,eAAe,GAAG,KAAK;EACvBC,SAAS;EACTC,UAAU;EACV,GAAGC;AAC6C,CAAC,EAAE;EACnD,MAAMC,SAAS,GAAGT,UAAU,CAACQ,KAAK,CAACC,SAAS,EAAE,gBAAgB,CAAC;EAE/D,oBAAOV,aAAa,CAClBI,EAAE,EACF;IACE,GAAGK,KAAK;IACRC;EACF,CAAC,eAECX,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAY,QAAA,QACGH,UAAU,iBAAIT,KAAA,CAAAC,aAAA,CAACE,IAAI;IAACQ,SAAS,EAAC,iBAAiB;IAACE,GAAG,EAAEJ;EAA4B,CAAE,CAAC,eACrFT,KAAA,CAAAC,aAAA;IAAMU,SAAS,EAAC;EAAqB,GAAEL,QAAe,CAAC,eACvDN,KAAA,CAAAC,aAAA;IAAMU,SAAS,EAAC;EAA+B,CAAE,CAAC,EACjDH,SAAS,iBAAIR,KAAA,CAAAC,aAAA,CAACE,IAAI;IAACQ,SAAS,EAAC,gBAAgB;IAACE,GAAG,EAAEL;EAA2B,CAAE,CACjF,CAEN,CAAC;AACH;AAEA,eAAeJ,QAAQ","ignoreList":[]}
|
package/dist/Menu/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { ElementType, ReactNode } from 'react';
|
|
2
|
-
interface MenuProps {
|
|
1
|
+
import React, { type ElementType, type ReactNode, type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
interface MenuProps<As extends ElementType> {
|
|
3
3
|
/** Specifies class name to append to the base element */
|
|
4
4
|
className?: string;
|
|
5
5
|
/**
|
|
@@ -8,9 +8,9 @@ interface MenuProps {
|
|
|
8
8
|
*/
|
|
9
9
|
arrowKeyNavigationSelector?: string;
|
|
10
10
|
/** Specifies the base element */
|
|
11
|
-
as?:
|
|
11
|
+
as?: As;
|
|
12
12
|
/** Specifies the content of the menu */
|
|
13
13
|
children?: ReactNode;
|
|
14
14
|
}
|
|
15
|
-
declare function Menu({ as, arrowKeyNavigationSelector, children, ...props }: MenuProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
15
|
+
declare function Menu<As extends ElementType = 'div'>({ as, arrowKeyNavigationSelector, children, ...props }: MenuProps<As> & ComponentPropsWithoutRef<As>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
16
16
|
export default Menu;
|
package/dist/Menu/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","createElement","classNames","useArrowKeyNavigation","Menu","as","arrowKeyNavigationSelector","children","props","parentRef","selectors","className","ref","Fragment"],"sources":["../../src/Menu/index.tsx"],"sourcesContent":["import React, { ElementType
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","createElement","classNames","useArrowKeyNavigation","Menu","as","arrowKeyNavigationSelector","children","props","parentRef","selectors","className","ref","Fragment"],"sources":["../../src/Menu/index.tsx"],"sourcesContent":["import React, {\n createElement,\n type ElementType,\n type ReactNode,\n type ComponentPropsWithoutRef,\n} from 'react';\nimport classNames from 'classnames';\nimport useArrowKeyNavigation from '../hooks/useArrowKeyNavigationHook';\n\ninterface MenuProps<As extends ElementType> {\n /** Specifies class name to append to the base element */\n className?: string;\n /**\n * Specifies the CSS selector string that indicates to which elements\n * the user can navigate using the arrow keys\n */\n arrowKeyNavigationSelector?: string;\n /** Specifies the base element */\n as?: As;\n /** Specifies the content of the menu */\n children?: ReactNode;\n}\n\nfunction Menu<As extends ElementType = 'div'>({\n as = 'div' as As,\n arrowKeyNavigationSelector = 'a:not(:disabled),button:not(:disabled),input:not(:disabled)',\n children,\n ...props\n}: MenuProps<As> & ComponentPropsWithoutRef<As>) {\n const parentRef = useArrowKeyNavigation({ selectors: arrowKeyNavigationSelector });\n const className = classNames(props.className, 'pgn__menu');\n\n return createElement(\n as,\n {\n ...props,\n ref: parentRef,\n className,\n },\n (\n // eslint-disable-next-line react/jsx-no-useless-fragment\n <>\n {children}\n </>\n ),\n );\n}\n\nexport default Menu;\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,aAAa,QAIR,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,qBAAqB,MAAM,oCAAoC;AAgBtE,SAASC,IAAIA,CAAiC;EAC5CC,EAAE,GAAG,KAAW;EAChBC,0BAA0B,GAAG,6DAA6D;EAC1FC,QAAQ;EACR,GAAGC;AACyC,CAAC,EAAE;EAC/C,MAAMC,SAAS,GAAGN,qBAAqB,CAAC;IAAEO,SAAS,EAAEJ;EAA2B,CAAC,CAAC;EAClF,MAAMK,SAAS,GAAGT,UAAU,CAACM,KAAK,CAACG,SAAS,EAAE,WAAW,CAAC;EAE1D,oBAAOV,aAAa,CAClBI,EAAE,EACF;IACE,GAAGG,KAAK;IACRI,GAAG,EAAEH,SAAS;IACdE;EACF,CAAC;EAAA;EAEC;EACAX,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAa,QAAA,QACGN,QACD,CAEN,CAAC;AACH;AAEA,eAAeH,IAAI","ignoreList":[]}
|
package/dist/Stack/index.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ interface StackProps {
|
|
|
16
16
|
/** Specifies an additional `className` to add to the base element. */
|
|
17
17
|
className?: string;
|
|
18
18
|
}
|
|
19
|
-
declare const Stack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<HTMLDivElement>>;
|
|
19
|
+
declare const Stack: React.ForwardRefExoticComponent<Omit<StackProps & React.HTMLProps<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
20
20
|
export default Stack;
|
package/dist/Stack/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","forwardRef","classNames","Stack","direction","gap","reversed","children","className","rest","ref","createElement"],"sources":["../../src/Stack/index.tsx"],"sourcesContent":["import React, { forwardRef, ForwardedRef } from 'react';\nimport classNames from 'classnames';\n\ninterface StackProps {\n /** Specifies the content of the `Stack`. */\n children: React.ReactNode;\n /** Specifies direction of the children blocks (column/row). */\n direction?: 'horizontal' | 'vertical';\n /**\n * Specifies inner space between children blocks.\n *\n * Valid values are based on `the spacing classes`:\n * `0, 0.5, ... 6`.\n */\n gap?: number;\n /** Specifies the order of the children. */\n reversed?: boolean;\n /** Specifies an additional `className` to add to the base element. */\n className?: string;\n}\n\nconst Stack = forwardRef(({\n direction = 'vertical',\n gap = 0,\n reversed = false,\n children,\n className,\n ...rest\n}: StackProps
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","forwardRef","classNames","Stack","direction","gap","reversed","children","className","rest","ref","createElement"],"sources":["../../src/Stack/index.tsx"],"sourcesContent":["import React, { forwardRef, ForwardedRef, HTMLProps } from 'react';\nimport classNames from 'classnames';\n\ninterface StackProps {\n /** Specifies the content of the `Stack`. */\n children: React.ReactNode;\n /** Specifies direction of the children blocks (column/row). */\n direction?: 'horizontal' | 'vertical';\n /**\n * Specifies inner space between children blocks.\n *\n * Valid values are based on `the spacing classes`:\n * `0, 0.5, ... 6`.\n */\n gap?: number;\n /** Specifies the order of the children. */\n reversed?: boolean;\n /** Specifies an additional `className` to add to the base element. */\n className?: string;\n}\n\nconst Stack = forwardRef(({\n direction = 'vertical',\n gap = 0,\n reversed = false,\n children,\n className,\n ...rest\n}: StackProps & HTMLProps<HTMLDivElement>, ref: ForwardedRef<HTMLDivElement>) => (\n <div\n ref={ref}\n className={classNames(\n direction === 'horizontal' ? 'pgn__hstack' : 'pgn__vstack',\n gap ? `pgn__stack-gap--${gap}` : '',\n reversed ? 'pgn__stack-reversed' : '',\n className,\n )}\n {...rest}\n >\n {children}\n </div>\n));\n\nexport default Stack;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAiC,OAAO;AAClE,OAAOC,UAAU,MAAM,YAAY;AAoBnC,MAAMC,KAAK,gBAAGF,UAAU,CAAC,CAAC;EACxBG,SAAS,GAAG,UAAU;EACtBC,GAAG,GAAG,CAAC;EACPC,QAAQ,GAAG,KAAK;EAChBC,QAAQ;EACRC,SAAS;EACT,GAAGC;AACmC,CAAC,EAAEC,GAAiC,kBAC1EV,KAAA,CAAAW,aAAA;EACED,GAAG,EAAEA,GAAI;EACTF,SAAS,EAAEN,UAAU,CACnBE,SAAS,KAAK,YAAY,GAAG,aAAa,GAAG,aAAa,EAC1DC,GAAG,GAAG,mBAAmBA,GAAG,EAAE,GAAG,EAAE,EACnCC,QAAQ,GAAG,qBAAqB,GAAG,EAAE,EACrCE,SACF,CAAE;EAAA,GACEC;AAAI,GAEPF,QACE,CACN,CAAC;AAEF,eAAeJ,KAAK","ignoreList":[]}
|
package/package.json
CHANGED
package/src/Menu/MenuItem.tsx
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React, {
|
|
2
|
-
ReactElement,
|
|
2
|
+
type ReactElement,
|
|
3
|
+
type ReactNode,
|
|
4
|
+
type ElementType,
|
|
5
|
+
createElement,
|
|
6
|
+
type ComponentType,
|
|
7
|
+
type ComponentPropsWithoutRef,
|
|
3
8
|
} from 'react';
|
|
4
9
|
import classNames from 'classnames';
|
|
5
10
|
import Icon from '../Icon';
|
|
6
11
|
|
|
7
|
-
interface MenuItemProps {
|
|
12
|
+
interface MenuItemProps<As extends ElementType> {
|
|
8
13
|
/** Specifies that this `MenuItem` is selected inside the `SelectMenu` */
|
|
9
14
|
defaultSelected?: boolean;
|
|
10
15
|
/** Specifies class name to append to the base element */
|
|
@@ -12,21 +17,22 @@ interface MenuItemProps {
|
|
|
12
17
|
/** Specifies the content of the `MenuItem` */
|
|
13
18
|
children: ReactNode;
|
|
14
19
|
/** Specifies the base element */
|
|
15
|
-
as?:
|
|
20
|
+
as?: As;
|
|
16
21
|
/** Specifies the jsx before the content of the `MenuItem` */
|
|
17
22
|
iconBefore?: ReactElement | ElementType;
|
|
18
23
|
/** Specifies the jsx after the content of the `MenuItem` */
|
|
19
24
|
iconAfter?: ReactElement | ElementType;
|
|
20
25
|
}
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
|
|
27
|
+
function MenuItem<As extends ElementType = 'button'>({
|
|
28
|
+
as = 'button' as As,
|
|
23
29
|
children,
|
|
24
30
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
31
|
defaultSelected = false,
|
|
26
32
|
iconAfter,
|
|
27
33
|
iconBefore,
|
|
28
34
|
...props
|
|
29
|
-
}: MenuItemProps) {
|
|
35
|
+
}: MenuItemProps<As> & ComponentPropsWithoutRef<As>) {
|
|
30
36
|
const className = classNames(props.className, 'pgn__menu-item');
|
|
31
37
|
|
|
32
38
|
return createElement(
|
package/src/Menu/index.tsx
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
createElement,
|
|
3
|
+
type ElementType,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
type ComponentPropsWithoutRef,
|
|
6
|
+
} from 'react';
|
|
2
7
|
import classNames from 'classnames';
|
|
3
8
|
import useArrowKeyNavigation from '../hooks/useArrowKeyNavigationHook';
|
|
4
9
|
|
|
5
|
-
interface MenuProps {
|
|
10
|
+
interface MenuProps<As extends ElementType> {
|
|
6
11
|
/** Specifies class name to append to the base element */
|
|
7
12
|
className?: string;
|
|
8
13
|
/**
|
|
@@ -11,16 +16,17 @@ interface MenuProps {
|
|
|
11
16
|
*/
|
|
12
17
|
arrowKeyNavigationSelector?: string;
|
|
13
18
|
/** Specifies the base element */
|
|
14
|
-
as?:
|
|
19
|
+
as?: As;
|
|
15
20
|
/** Specifies the content of the menu */
|
|
16
21
|
children?: ReactNode;
|
|
17
22
|
}
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
|
|
24
|
+
function Menu<As extends ElementType = 'div'>({
|
|
25
|
+
as = 'div' as As,
|
|
20
26
|
arrowKeyNavigationSelector = 'a:not(:disabled),button:not(:disabled),input:not(:disabled)',
|
|
21
27
|
children,
|
|
22
28
|
...props
|
|
23
|
-
}: MenuProps) {
|
|
29
|
+
}: MenuProps<As> & ComponentPropsWithoutRef<As>) {
|
|
24
30
|
const parentRef = useArrowKeyNavigation({ selectors: arrowKeyNavigationSelector });
|
|
25
31
|
const className = classNames(props.className, 'pgn__menu');
|
|
26
32
|
|
package/src/Stack/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, ForwardedRef } from 'react';
|
|
1
|
+
import React, { forwardRef, ForwardedRef, HTMLProps } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
|
|
4
4
|
interface StackProps {
|
|
@@ -26,7 +26,7 @@ const Stack = forwardRef(({
|
|
|
26
26
|
children,
|
|
27
27
|
className,
|
|
28
28
|
...rest
|
|
29
|
-
}: StackProps
|
|
29
|
+
}: StackProps & HTMLProps<HTMLDivElement>, ref: ForwardedRef<HTMLDivElement>) => (
|
|
30
30
|
<div
|
|
31
31
|
ref={ref}
|
|
32
32
|
className={classNames(
|