@faststore/ui 1.4.23 → 1.4.27
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 +32 -0
- package/dist/molecules/Accordion/AccordionItem.d.ts +6 -0
- package/dist/ui.cjs.development.js +8 -5
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +8 -5
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/molecules/Accordion/Accordion.test.tsx +32 -0
- package/src/molecules/Accordion/AccordionButton.tsx +7 -3
- package/src/molecules/Accordion/AccordionItem.tsx +16 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
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.4.27 (2022-02-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @faststore/ui
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.4.26 (2022-02-02)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @faststore/ui
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.4.25 (2022-02-02)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @faststore/ui
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 1.4.24 (2022-02-02)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @faststore/ui
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## 1.4.23 (2022-02-01)
|
|
7
39
|
|
|
8
40
|
|
|
@@ -4,6 +4,7 @@ interface AccordionItemContext {
|
|
|
4
4
|
index: number;
|
|
5
5
|
panel: string;
|
|
6
6
|
button: string;
|
|
7
|
+
prefixId: string;
|
|
7
8
|
}
|
|
8
9
|
declare const AccordionItemContext: React.Context<AccordionItemContext | undefined>;
|
|
9
10
|
export interface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -16,6 +17,11 @@ export interface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
17
|
* Index of the current accordion item within the accordion.
|
|
17
18
|
*/
|
|
18
19
|
index?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Namespace ID prefix for the current Accordion item's panel and button
|
|
22
|
+
* to avoid ID duplication when multiple instances are on the same page.
|
|
23
|
+
*/
|
|
24
|
+
prefixId?: string;
|
|
19
25
|
}
|
|
20
26
|
declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
27
|
export declare function useAccordionItem(): AccordionItemContext;
|
|
@@ -1317,13 +1317,15 @@ const AccordionItemContext = /*#__PURE__*/React.createContext(undefined);
|
|
|
1317
1317
|
const AccordionItem = /*#__PURE__*/React.forwardRef(function AccordionItem({
|
|
1318
1318
|
testId = 'store-accordion-item',
|
|
1319
1319
|
children,
|
|
1320
|
+
prefixId = '',
|
|
1320
1321
|
index = 0,
|
|
1321
1322
|
...otherProps
|
|
1322
1323
|
}, ref) {
|
|
1323
1324
|
const context = {
|
|
1324
1325
|
index,
|
|
1325
|
-
|
|
1326
|
-
|
|
1326
|
+
prefixId,
|
|
1327
|
+
panel: `${prefixId && `${prefixId}-`}panel--${index}`,
|
|
1328
|
+
button: `${prefixId && `${prefixId}-`}button--${index}`
|
|
1327
1329
|
};
|
|
1328
1330
|
return React__default.createElement(AccordionItemContext.Provider, {
|
|
1329
1331
|
value: context
|
|
@@ -1356,7 +1358,8 @@ const AccordionButton = /*#__PURE__*/React.forwardRef(function AccordionButton({
|
|
|
1356
1358
|
const {
|
|
1357
1359
|
index,
|
|
1358
1360
|
panel,
|
|
1359
|
-
button
|
|
1361
|
+
button,
|
|
1362
|
+
prefixId
|
|
1360
1363
|
} = useAccordionItem();
|
|
1361
1364
|
|
|
1362
1365
|
const onKeyDown = event => {
|
|
@@ -1368,12 +1371,12 @@ const AccordionButton = /*#__PURE__*/React.forwardRef(function AccordionButton({
|
|
|
1368
1371
|
|
|
1369
1372
|
const getNext = () => {
|
|
1370
1373
|
const next = Number(index) + 1 === numberOfItems ? 0 : Number(index) + 1;
|
|
1371
|
-
return document.getElementById(
|
|
1374
|
+
return document.getElementById(`${prefixId && `${prefixId}-`}button--${next}`);
|
|
1372
1375
|
};
|
|
1373
1376
|
|
|
1374
1377
|
const getPrevious = () => {
|
|
1375
1378
|
const previous = Number(index) - 1 < 0 ? numberOfItems - 1 : Number(index) - 1;
|
|
1376
|
-
return document.getElementById(
|
|
1379
|
+
return document.getElementById(`${prefixId && `${prefixId}-`}button--${previous}`);
|
|
1377
1380
|
};
|
|
1378
1381
|
|
|
1379
1382
|
switch (event.key) {
|