@faststore/ui 1.11.20 → 1.12.5
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/CHANGELOG.md +18 -0
- package/dist/molecules/Accordion/AccordionItem.d.ts +12 -3
- package/dist/molecules/Accordion/AccordionItem.js +9 -2
- package/dist/molecules/Accordion/AccordionItem.js.map +1 -1
- package/dist/molecules/Table/Table.d.ts +3 -3
- package/package.json +2 -2
- package/src/molecules/Accordion/AccordionItem.tsx +28 -8
- package/src/molecules/Accordion/stories/Accordion.mdx +2 -2
- package/src/molecules/Table/Table.tsx +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.12.5](https://github.com/vtex/faststore/compare/v1.12.4...v1.12.5) (2022-09-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fixes tsconfig.json to exclude storybook types inside .d.ts file ([#1472](https://github.com/vtex/faststore/issues/1472)) ([97274b5](https://github.com/vtex/faststore/commit/97274b58b79849cb670e87052130b2ed00bb53f4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.12.4](https://github.com/vtex/faststore/compare/v1.12.3...v1.12.4) (2022-09-21)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **ui:** improve extensibility of table and accordion molecules ([#1470](https://github.com/vtex/faststore/issues/1470)) ([2abf78c](https://github.com/vtex/faststore/commit/2abf78c36ce446f6e5b213738a359fb1b37e98a5))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [1.11.20](https://github.com/vtex/faststore/compare/v1.11.19...v1.11.20) (2022-09-12)
|
|
7
25
|
|
|
8
26
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { HTMLAttributes } from 'react';
|
|
2
1
|
import React from 'react';
|
|
2
|
+
import type { ElementType, HTMLAttributes, ReactElement } from 'react';
|
|
3
|
+
import type { PolymorphicComponentPropsWithRef } from '../../typings';
|
|
3
4
|
interface AccordionItemContext {
|
|
4
5
|
index: number;
|
|
5
6
|
panel: string;
|
|
@@ -7,7 +8,7 @@ interface AccordionItemContext {
|
|
|
7
8
|
prefixId: string;
|
|
8
9
|
}
|
|
9
10
|
declare const AccordionItemContext: React.Context<AccordionItemContext | undefined>;
|
|
10
|
-
|
|
11
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
11
12
|
/**
|
|
12
13
|
* ID to find this component in testing tools (e.g.: cypress,
|
|
13
14
|
* testing-library, and jest).
|
|
@@ -23,6 +24,14 @@ export interface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
23
24
|
*/
|
|
24
25
|
prefixId?: string;
|
|
25
26
|
}
|
|
26
|
-
declare
|
|
27
|
+
export declare type AccordionItemProps<C extends ElementType> = PolymorphicComponentPropsWithRef<C, Props>;
|
|
28
|
+
declare type AccordionItemComponent = <C extends ElementType = 'div'>(props: AccordionItemProps<C>) => ReactElement | null;
|
|
29
|
+
declare const AccordionItem: AccordionItemComponent;
|
|
27
30
|
export declare function useAccordionItem(): AccordionItemContext;
|
|
31
|
+
/**
|
|
32
|
+
* This is only being exported to make it easier to use in Storybook.
|
|
33
|
+
* **DON'T** import this directly to use this component, use the default export
|
|
34
|
+
* instead.
|
|
35
|
+
*/
|
|
36
|
+
export declare const StorybookAccordionItem: React.FC<Props>;
|
|
28
37
|
export default AccordionItem;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useContext, forwardRef, createContext } from 'react';
|
|
2
2
|
const AccordionItemContext = createContext(undefined);
|
|
3
|
-
const AccordionItem = forwardRef(function AccordionItem({ testId = 'store-accordion-item', children, prefixId = '', index = 0, ...otherProps }, ref) {
|
|
3
|
+
const AccordionItem = forwardRef(function AccordionItem({ testId = 'store-accordion-item', children, prefixId = '', index = 0, as: MaybeComponent, ...otherProps }, ref) {
|
|
4
|
+
const Component = MaybeComponent ?? 'div';
|
|
4
5
|
const context = {
|
|
5
6
|
index,
|
|
6
7
|
prefixId,
|
|
@@ -8,7 +9,7 @@ const AccordionItem = forwardRef(function AccordionItem({ testId = 'store-accord
|
|
|
8
9
|
button: `${prefixId && `${prefixId}-`}button--${index}`,
|
|
9
10
|
};
|
|
10
11
|
return (React.createElement(AccordionItemContext.Provider, { value: context },
|
|
11
|
-
React.createElement(
|
|
12
|
+
React.createElement(Component, Object.assign({ ref: ref, "data-accordion-item": true, "data-testid": testId }, otherProps), children)));
|
|
12
13
|
});
|
|
13
14
|
export function useAccordionItem() {
|
|
14
15
|
const context = useContext(AccordionItemContext);
|
|
@@ -17,5 +18,11 @@ export function useAccordionItem() {
|
|
|
17
18
|
}
|
|
18
19
|
return context;
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* This is only being exported to make it easier to use in Storybook.
|
|
23
|
+
* **DON'T** import this directly to use this component, use the default export
|
|
24
|
+
* instead.
|
|
25
|
+
*/
|
|
26
|
+
export const StorybookAccordionItem = AccordionItem;
|
|
20
27
|
export default AccordionItem;
|
|
21
28
|
//# sourceMappingURL=AccordionItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionItem.js","sourceRoot":"","sources":["../../../src/molecules/Accordion/AccordionItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccordionItem.js","sourceRoot":"","sources":["../../../src/molecules/Accordion/AccordionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAWpE,MAAM,oBAAoB,GAAG,aAAa,CACxC,SAAS,CACV,CAAA;AA4BD,MAAM,aAAa,GAA2B,UAAU,CACtD,SAAS,aAAa,CACpB,EACE,MAAM,GAAG,sBAAsB,EAC/B,QAAQ,EACR,QAAQ,GAAG,EAAE,EACb,KAAK,GAAG,CAAC,EACT,EAAE,EAAE,cAAc,EAClB,GAAG,UAAU,EACS,EACxB,GAAsB;IAEtB,MAAM,SAAS,GAAG,cAAc,IAAI,KAAK,CAAA;IAEzC,MAAM,OAAO,GAAG;QACd,KAAK;QACL,QAAQ;QACR,KAAK,EAAE,GAAG,QAAQ,IAAI,GAAG,QAAQ,GAAG,UAAU,KAAK,EAAE;QACrD,MAAM,EAAE,GAAG,QAAQ,IAAI,GAAG,QAAQ,GAAG,WAAW,KAAK,EAAE;KACxD,CAAA;IAED,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO;QAC3C,oBAAC,SAAS,kBAAC,GAAG,EAAE,GAAG,8CAAmC,MAAM,IAAM,UAAU,GACzE,QAAQ,CACC,CACkB,CACjC,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAEhD,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAA;KACF;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAA0B,CAAA;AAEhE,eAAe,aAAa,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DetailedHTMLProps, TableHTMLAttributes } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export interface TableProps extends
|
|
3
|
+
export interface TableProps extends DetailedHTMLProps<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement> {
|
|
4
4
|
/**
|
|
5
5
|
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
6
6
|
*/
|
|
7
7
|
testId?: string;
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
}
|
|
10
|
-
declare const Table: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<HTMLTableElement>>;
|
|
10
|
+
declare const Table: React.ForwardRefExoticComponent<Pick<TableProps, "slot" | "style" | "summary" | "title" | "className" | "color" | "id" | "lang" | "width" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "cellPadding" | "cellSpacing" | "testId"> & React.RefAttributes<HTMLTableElement>>;
|
|
11
11
|
export default Table;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.5",
|
|
4
4
|
"description": "A lightweight, framework agnostic component library for React",
|
|
5
5
|
"author": "emersonlaurentino",
|
|
6
6
|
"license": "MIT",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"tsdx": "^0.14.1",
|
|
86
86
|
"typescript": "^4.2.4"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "5178a18d0dfa7e510c6db1e40d98d67fa53cc581"
|
|
89
89
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { HTMLAttributes } from 'react'
|
|
2
1
|
import React, { useContext, forwardRef, createContext } from 'react'
|
|
2
|
+
import type { ElementType, FC, HTMLAttributes, ReactElement } from 'react'
|
|
3
|
+
import type { PolymorphicComponentPropsWithRef, PolymorphicRef } from '../../typings'
|
|
3
4
|
|
|
4
5
|
interface AccordionItemContext {
|
|
5
6
|
index: number
|
|
@@ -12,7 +13,7 @@ const AccordionItemContext = createContext<AccordionItemContext | undefined>(
|
|
|
12
13
|
undefined
|
|
13
14
|
)
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
16
17
|
/**
|
|
17
18
|
* ID to find this component in testing tools (e.g.: cypress,
|
|
18
19
|
* testing-library, and jest).
|
|
@@ -29,17 +30,29 @@ export interface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
29
30
|
prefixId?: string
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
export type AccordionItemProps<C extends ElementType> = PolymorphicComponentPropsWithRef<
|
|
34
|
+
C,
|
|
35
|
+
Props
|
|
36
|
+
>
|
|
37
|
+
|
|
38
|
+
type AccordionItemComponent = <C extends ElementType = 'div'>(
|
|
39
|
+
props: AccordionItemProps<C>
|
|
40
|
+
) => ReactElement | null
|
|
41
|
+
|
|
42
|
+
const AccordionItem: AccordionItemComponent = forwardRef(
|
|
43
|
+
function AccordionItem<C extends ElementType = 'div'>(
|
|
34
44
|
{
|
|
35
45
|
testId = 'store-accordion-item',
|
|
36
46
|
children,
|
|
37
47
|
prefixId = '',
|
|
38
48
|
index = 0,
|
|
49
|
+
as: MaybeComponent,
|
|
39
50
|
...otherProps
|
|
40
|
-
}
|
|
41
|
-
ref
|
|
51
|
+
}: AccordionItemProps<C>,
|
|
52
|
+
ref: PolymorphicRef<C>
|
|
42
53
|
) {
|
|
54
|
+
const Component = MaybeComponent ?? 'div'
|
|
55
|
+
|
|
43
56
|
const context = {
|
|
44
57
|
index,
|
|
45
58
|
prefixId,
|
|
@@ -49,9 +62,9 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
|
|
|
49
62
|
|
|
50
63
|
return (
|
|
51
64
|
<AccordionItemContext.Provider value={context}>
|
|
52
|
-
<
|
|
65
|
+
<Component ref={ref} data-accordion-item data-testid={testId} {...otherProps}>
|
|
53
66
|
{children}
|
|
54
|
-
</
|
|
67
|
+
</Component>
|
|
55
68
|
</AccordionItemContext.Provider>
|
|
56
69
|
)
|
|
57
70
|
}
|
|
@@ -69,4 +82,11 @@ export function useAccordionItem() {
|
|
|
69
82
|
return context
|
|
70
83
|
}
|
|
71
84
|
|
|
85
|
+
/**
|
|
86
|
+
* This is only being exported to make it easier to use in Storybook.
|
|
87
|
+
* **DON'T** import this directly to use this component, use the default export
|
|
88
|
+
* instead.
|
|
89
|
+
*/
|
|
90
|
+
export const StorybookAccordionItem = AccordionItem as FC<Props>
|
|
91
|
+
|
|
72
92
|
export default AccordionItem
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Canvas, Props, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
2
|
|
|
3
3
|
import Accordion from '../Accordion'
|
|
4
|
-
import
|
|
4
|
+
import { StorybookAccordionItem } from '../AccordionItem'
|
|
5
5
|
import AccordionButton from '../AccordionButton'
|
|
6
6
|
import AccordionPanel from '../AccordionPanel'
|
|
7
7
|
|
|
@@ -40,7 +40,7 @@ Besides those attributes, the following props are also supported:
|
|
|
40
40
|
|
|
41
41
|
### `AccordionItem`
|
|
42
42
|
|
|
43
|
-
<ArgsTable of={
|
|
43
|
+
<ArgsTable of={StorybookAccordionItem} />
|
|
44
44
|
|
|
45
45
|
### `AccordionButton`
|
|
46
46
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DetailedHTMLProps, TableHTMLAttributes } from 'react'
|
|
2
2
|
import React, { forwardRef } from 'react'
|
|
3
3
|
|
|
4
|
-
export interface TableProps extends
|
|
4
|
+
export interface TableProps extends DetailedHTMLProps<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement> {
|
|
5
5
|
/**
|
|
6
6
|
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
7
7
|
*/
|