@elliemae/ds-accordion 3.4.2 → 3.4.3
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/cjs/DSAccordion.js +9 -5
- package/dist/cjs/DSAccordion.js.map +1 -1
- package/dist/cjs/DSAccordionCTX.js +4 -1
- package/dist/cjs/DSAccordionCTX.js.map +1 -1
- package/dist/cjs/config/useAccordion.js +32 -23
- package/dist/cjs/config/useAccordion.js.map +1 -1
- package/dist/cjs/config/useAccordionRefs.js +4 -1
- package/dist/cjs/config/useAccordionRefs.js.map +2 -2
- package/dist/cjs/defaultProps.js +22 -14
- package/dist/cjs/defaultProps.js.map +1 -1
- package/dist/cjs/exported-related/DSAccordionDatatestid.js +4 -1
- package/dist/cjs/exported-related/DSAccordionDatatestid.js.map +1 -1
- package/dist/cjs/exported-related/index.js +4 -1
- package/dist/cjs/exported-related/index.js.map +1 -1
- package/dist/cjs/exported-related/theming.js +4 -1
- package/dist/cjs/exported-related/theming.js.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/parts/accordionContent/AccordionContent.js +17 -7
- package/dist/cjs/parts/accordionContent/AccordionContent.js.map +2 -2
- package/dist/cjs/parts/accordionContent/styles.js +4 -1
- package/dist/cjs/parts/accordionContent/styles.js.map +1 -1
- package/dist/cjs/parts/accordionItem/DSAccordionItem.js +150 -93
- package/dist/cjs/parts/accordionItem/DSAccordionItem.js.map +1 -1
- package/dist/cjs/parts/accordionItem/styles.js +4 -1
- package/dist/cjs/parts/accordionItem/styles.js.map +1 -1
- package/dist/cjs/parts/accordionItem/useAccordionItem.js +30 -21
- package/dist/cjs/parts/accordionItem/useAccordionItem.js.map +1 -1
- package/dist/cjs/propTypes.js +10 -3
- package/dist/cjs/propTypes.js.map +1 -1
- package/dist/cjs/react-desc-prop-types.js +10 -3
- package/dist/cjs/react-desc-prop-types.js.map +1 -1
- package/dist/cjs/sharedTypes.js +4 -1
- package/dist/cjs/sharedTypes.js.map +1 -1
- package/dist/esm/DSAccordion.js +5 -4
- package/dist/esm/DSAccordion.js.map +1 -1
- package/dist/esm/DSAccordionCTX.js.map +1 -1
- package/dist/esm/config/useAccordion.js +28 -22
- package/dist/esm/config/useAccordion.js.map +1 -1
- package/dist/esm/config/useAccordionRefs.js.map +2 -2
- package/dist/esm/defaultProps.js +18 -13
- package/dist/esm/defaultProps.js.map +1 -1
- package/dist/esm/exported-related/DSAccordionDatatestid.js.map +1 -1
- package/dist/esm/exported-related/index.js.map +1 -1
- package/dist/esm/exported-related/theming.js.map +1 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/parts/accordionContent/AccordionContent.js +13 -6
- package/dist/esm/parts/accordionContent/AccordionContent.js.map +2 -2
- package/dist/esm/parts/accordionContent/styles.js.map +1 -1
- package/dist/esm/parts/accordionItem/DSAccordionItem.js +146 -92
- package/dist/esm/parts/accordionItem/DSAccordionItem.js.map +1 -1
- package/dist/esm/parts/accordionItem/styles.js.map +1 -1
- package/dist/esm/parts/accordionItem/useAccordionItem.js +26 -20
- package/dist/esm/parts/accordionItem/useAccordionItem.js.map +1 -1
- package/dist/esm/propTypes.js +6 -2
- package/dist/esm/propTypes.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js +6 -2
- package/dist/esm/react-desc-prop-types.js.map +1 -1
- package/dist/esm/sharedTypes.js.map +1 -1
- package/package.json +6 -6
package/dist/esm/DSAccordion.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { describe } from "@elliemae/ds-utilities";
|
|
4
4
|
import { AccordionContent } from "./parts/accordionContent/AccordionContent";
|
|
5
5
|
import { useAccordion } from "./config/useAccordion";
|
|
@@ -8,9 +8,10 @@ import { accordionPropTypes } from "./react-desc-prop-types";
|
|
|
8
8
|
import { DSAccordionName } from "./exported-related/theming";
|
|
9
9
|
const DSAccordion = (props) => {
|
|
10
10
|
const ctx = useAccordion(props);
|
|
11
|
-
return /* @__PURE__ */
|
|
12
|
-
value: ctx
|
|
13
|
-
|
|
11
|
+
return /* @__PURE__ */ jsx(DSAccordionContext.Provider, {
|
|
12
|
+
value: ctx,
|
|
13
|
+
children: /* @__PURE__ */ jsx(AccordionContent, {})
|
|
14
|
+
});
|
|
14
15
|
};
|
|
15
16
|
DSAccordion.displayName = DSAccordionName;
|
|
16
17
|
const DSAccordionWithSchema = describe(DSAccordion);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSAccordion.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { WeakValidationMap } from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport { AccordionContent } from './parts/accordionContent/AccordionContent';\nimport { useAccordion } from './config/useAccordion';\nimport { DSAccordionContext } from './DSAccordionCTX';\nimport { accordionPropTypes } from './react-desc-prop-types';\nimport type { DSAccordionT } from './react-desc-prop-types';\nimport { DSAccordionName } from './exported-related/theming';\n\nconst DSAccordion = (props: DSAccordionT.Props): JSX.Element => {\n const ctx = useAccordion(props);\n\n return (\n <DSAccordionContext.Provider value={ctx}>\n <AccordionContent />\n </DSAccordionContext.Provider>\n );\n};\n\nDSAccordion.displayName = DSAccordionName;\nconst DSAccordionWithSchema = describe(DSAccordion);\nDSAccordionWithSchema.propTypes = accordionPropTypes as WeakValidationMap<unknown>;\n\nexport { DSAccordion, DSAccordionWithSchema };\n\nexport default DSAccordion;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB;AAEhC,MAAM,cAAc,CAAC,UAA2C;AAC9D,QAAM,MAAM,aAAa,KAAK;AAE9B,SACE,oBAAC,mBAAmB,UAAnB;AAAA,IAA4B,OAAO;AAAA,IAClC,8BAAC,oBAAiB;AAAA,GACpB;AAEJ;AAEA,YAAY,cAAc;AAC1B,MAAM,wBAAwB,SAAS,WAAW;AAClD,sBAAsB,YAAY;AAIlC,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSAccordionCTX.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext } from 'react';\nimport type { DSAccordionT } from './react-desc-prop-types';\nimport type { DSAccordionInternalsT } from './sharedTypes';\n\ninterface DSAccordionContextT {\n props: DSAccordionT.InternalProps;\n actualActiveValue: DSAccordionInternalsT.InternalActiveValue;\n setActiveValues: (value: string | number, e: React.MouseEvent | React.KeyboardEvent) => void;\n focusableChildrenReferences: DSAccordionInternalsT.FocusableChildrenReferences[];\n allChildrenReferences: DSAccordionInternalsT.AllChildrenReferences;\n}\n\nconst defaultContext = {} as DSAccordionContextT;\n\nexport const DSAccordionContext = createContext<DSAccordionContextT>(defaultContext);\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB;AAY9B,MAAM,iBAAiB,CAAC;AAEjB,MAAM,qBAAqB,cAAmC,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -13,29 +13,35 @@ const useAccordion = (props) => {
|
|
|
13
13
|
return internalActiveValue;
|
|
14
14
|
return activeValue;
|
|
15
15
|
}, [activeValue, internalActiveValue]);
|
|
16
|
-
const setActiveValues = useCallback(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
16
|
+
const setActiveValues = useCallback(
|
|
17
|
+
(value, e) => {
|
|
18
|
+
let newState;
|
|
19
|
+
if (allowMultipleOpen && (actualActiveValue === void 0 || actualActiveValue === null))
|
|
20
|
+
newState = [value];
|
|
21
|
+
else if (allowMultipleOpen && Array.isArray(actualActiveValue))
|
|
22
|
+
if (!actualActiveValue.some((currentValues) => currentValues === value))
|
|
23
|
+
newState = [...actualActiveValue, value];
|
|
24
|
+
else
|
|
25
|
+
newState = actualActiveValue.filter((currentValues) => currentValues !== value);
|
|
26
|
+
else if (actualActiveValue === value)
|
|
27
|
+
newState = null;
|
|
23
28
|
else
|
|
24
|
-
newState =
|
|
25
|
-
|
|
26
|
-
newState
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
newState = value;
|
|
30
|
+
setInternalActiveValue(newState);
|
|
31
|
+
return onChange(newState, e);
|
|
32
|
+
},
|
|
33
|
+
[actualActiveValue, allowMultipleOpen, onChange]
|
|
34
|
+
);
|
|
35
|
+
const ctx = useMemo(
|
|
36
|
+
() => ({
|
|
37
|
+
props: propsWithDefaults,
|
|
38
|
+
actualActiveValue,
|
|
39
|
+
setActiveValues,
|
|
40
|
+
focusableChildrenReferences,
|
|
41
|
+
allChildrenReferences
|
|
42
|
+
}),
|
|
43
|
+
[actualActiveValue, allChildrenReferences, focusableChildrenReferences, propsWithDefaults, setActiveValues]
|
|
44
|
+
);
|
|
39
45
|
return ctx;
|
|
40
46
|
};
|
|
41
47
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useAccordion.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo, useState, useCallback } from 'react';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-utilities';\nimport { useAccordionRefs } from './useAccordionRefs';\nimport { defaultProps } from '../defaultProps';\nimport type { DSAccordionT } from '../react-desc-prop-types';\nimport type { DSAccordionInternalsT } from '../sharedTypes';\n\ninterface DSAccordionUseAccordionContextT {\n props: DSAccordionT.InternalProps;\n actualActiveValue: DSAccordionInternalsT.InternalActiveValue;\n setActiveValues: (value: string | number, e: React.MouseEvent | React.KeyboardEvent) => void;\n focusableChildrenReferences: DSAccordionInternalsT.FocusableChildrenReferences[];\n allChildrenReferences: DSAccordionInternalsT.AllChildrenReferences;\n}\n\nexport const useAccordion = (props: DSAccordionT.Props): DSAccordionUseAccordionContextT => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps) as DSAccordionT.InternalProps;\n\n const { activeValue, allowMultipleOpen, onChange } = propsWithDefaults;\n\n const { focusableChildrenReferences, allChildrenReferences } = useAccordionRefs(propsWithDefaults);\n\n const [internalActiveValue, setInternalActiveValue] =\n useState<DSAccordionInternalsT.InternalActiveValue>(activeValue);\n\n const actualActiveValue = useMemo(() => {\n if (activeValue === undefined) return internalActiveValue;\n return activeValue;\n }, [activeValue, internalActiveValue]);\n\n const setActiveValues = useCallback(\n (value: string | number, e: React.MouseEvent | React.KeyboardEvent) => {\n let newState: DSAccordionInternalsT.InternalActiveValue;\n if (allowMultipleOpen && (actualActiveValue === undefined || actualActiveValue === null)) newState = [value];\n else if (allowMultipleOpen && Array.isArray(actualActiveValue))\n if (!actualActiveValue.some((currentValues: string | number) => currentValues === value))\n newState = [...actualActiveValue, value];\n else newState = actualActiveValue.filter((currentValues: string | number) => currentValues !== value);\n else if (actualActiveValue === value) newState = null;\n else newState = value;\n setInternalActiveValue(newState);\n return onChange(newState, e);\n },\n [actualActiveValue, allowMultipleOpen, onChange],\n );\n\n const ctx = useMemo(\n () => ({\n props: propsWithDefaults,\n actualActiveValue,\n setActiveValues,\n focusableChildrenReferences,\n allChildrenReferences,\n }),\n [actualActiveValue, allCh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AuB,6BAA6B,mBAAmB,eAAe;AAAA,EAC5G;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useAccordionRefs.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo } from 'react';\nimport type { DSAccordionT } from '../react-desc-prop-types';\nimport type { DSAccordionInternalsT } from '../sharedTypes';\n\ninterface UseAccordionRefsPropsT {\n children: React.ReactElement<DSAccordionT.InternalItemProps>[];\n}\n\ninterface UseAccordionRefsReturnTypeT {\n focusableChildrenReferences: DSAccordionInternalsT.FocusableChildrenReferences[];\n allChildrenReferences: DSAccordionInternalsT.AllChildrenReferences;\n}\n\nexport const useAccordionRefs = ({ children }: UseAccordionRefsPropsT): UseAccordionRefsReturnTypeT =>\n useMemo(() => {\n const focusableChildrenReferences: DSAccordionInternalsT.FocusableChildrenReferences[] = [];\n const allChildrenReferences: DSAccordionInternalsT.AllChildrenReferences = {};\n\n React.Children.map(children, (child: React.ReactElement<DSAccordionT.InternalItemProps>, index) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { value, disabled } = child.props;\n const currentRef = React.createRef<HTMLButtonElement>();\n allChildrenReferences[index] = currentRef;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n if (!disabled) focusableChildrenReferences.push({ index, value, ref: currentRef });\n });\n return { focusableChildrenReferences, allChildrenReferences };\n }, [children]);\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,UAAS,eAAe;AAaxB,MAAM,mBAAmB,CAAC,EAAE,SAAS,MAC1C,QAAQ,MAAM;AACZ,QAAM,8BAAmF,CAAC;AAC1F,QAAM,wBAAqE,CAAC;AAE5E,EAAAA,OAAM,SAAS,IAAI,UAAU,CAAC,OAA2D,UAAU;AAEjG,UAAM,EAAE,OAAO,SAAS,IAAI,MAAM;AAClC,UAAM,aAAaA,OAAM,UAA6B;AACtD,0BAAsB,SAAS;AAE/B,QAAI,CAAC;AAAU,kCAA4B,KAAK,EAAE,OAAO,OAAO,KAAK,WAAW,CAAC;AAAA,EACnF,CAAC;AACD,SAAO,EAAE,6BAA6B,sBAAsB;AAC9D,GAAG,CAAC,QAAQ,CAAC;",
|
|
6
|
+
"names": ["React"]
|
|
7
7
|
}
|
package/dist/esm/defaultProps.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { memo } from "react";
|
|
3
4
|
import { ArrowheadRight, ArrowheadDown, ChevronRight, ChevronDown } from "@elliemae/ds-icons";
|
|
4
|
-
const DefaultIconClosed = memo(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
const DefaultIconClosed = memo(
|
|
6
|
+
({ isDSMobile = false }) => isDSMobile ? /* @__PURE__ */ jsx(ChevronRight, {
|
|
7
|
+
width: "20px",
|
|
8
|
+
color: ["brand", "800"]
|
|
9
|
+
}) : /* @__PURE__ */ jsx(ArrowheadRight, {
|
|
10
|
+
width: "20px"
|
|
11
|
+
})
|
|
12
|
+
);
|
|
13
|
+
const DefaultIconOpen = memo(
|
|
14
|
+
({ isDSMobile = false }) => isDSMobile ? /* @__PURE__ */ jsx(ChevronDown, {
|
|
15
|
+
width: "20px",
|
|
16
|
+
color: ["brand", "800"]
|
|
17
|
+
}) : /* @__PURE__ */ jsx(ArrowheadDown, {
|
|
18
|
+
width: "20px"
|
|
19
|
+
})
|
|
20
|
+
);
|
|
16
21
|
const noop = () => {
|
|
17
22
|
};
|
|
18
23
|
const defaultProps = {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/defaultProps.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { memo } from 'react';\nimport { ArrowheadRight, ArrowheadDown, ChevronRight, ChevronDown } from '@elliemae/ds-icons';\nimport type { DSAccordionInternalsT } from './sharedTypes';\nimport type { DSAccordionT } from './react-desc-prop-types';\n\nconst DefaultIconClosed = memo(({ isDSMobile = false }: DSAccordionInternalsT.DefaultIconProps) =>\n isDSMobile ? <ChevronRight width=\"20px\" color={['brand', '800']} /> : <ArrowheadRight width=\"20px\" />,\n);\n\nconst DefaultIconOpen = memo(({ isDSMobile = false }: DSAccordionInternalsT.DefaultIconProps) =>\n isDSMobile ? <ChevronDown width=\"20px\" color={['brand', '800']} /> : <ArrowheadDown width=\"20px\" />,\n);\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = (): void => {};\n\nexport const defaultProps: DSAccordionT.DefaultProps = {\n containerProps: {},\n allowMultipleOpen: false,\n onChange: noop,\n children: [],\n isDSMobile: false,\n};\n\nexport const accordionItemDefaultProps: DSAccordionT.ItemDefaultProps = {\n iconClosed: DefaultIconClosed,\n iconOpened: DefaultIconOpen,\n title: '',\n customActions: [],\n disabled: false,\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY;AAC5B,SAAS,gBAAgB,eAAe,cAAc,mBAAmB;AAIzE,MAAM,oBAAoB;AAAA,EAAK,CAAC,EAAE,aAAa,MAAM,MACnD,aAAa,oBAAC;AAAA,IAAa,OAAM;AAAA,IAAO,OAAO,CAAC,SAAS,KAAK;AAAA,GAAG,IAAK,oBAAC;AAAA,IAAe,OAAM;AAAA,GAAO;AACrG;AAEA,MAAM,kBAAkB;AAAA,EAAK,CAAC,EAAE,aAAa,MAAM,MACjD,aAAa,oBAAC;AAAA,IAAY,OAAM;AAAA,IAAO,OAAO,CAAC,SAAS,KAAK;AAAA,GAAG,IAAK,oBAAC;AAAA,IAAc,OAAM;AAAA,GAAO;AACnG;AAGA,MAAM,OAAO,MAAY;AAAC;AAEnB,MAAM,eAA0C;AAAA,EACrD,gBAAgB,CAAC;AAAA,EACjB,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,UAAU,CAAC;AAAA,EACX,YAAY;AACd;AAEO,MAAM,4BAA2D;AAAA,EACtE,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,eAAe,CAAC;AAAA,EAChB,UAAU;AACZ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/exported-related/DSAccordionDatatestid.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSAccordionDataTestid = {\n ITEM: {\n CONTENT: 'ds-accordion_item-content',\n HEADER: 'ds-accordion_item-header',\n CONTAINER: 'ds-accordion_item',\n },\n GROUP: 'ds-accordion_group',\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,wBAAwB;AAAA,EACnC,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAAA,EACA,OAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/exported-related/index.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSAccordionDatatestid';\nexport * from './theming';\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/exported-related/theming.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSAccordionName = 'DSAccordion';\n\nexport const DSAccordionSlots = {\n CONTAINER: 'root',\n ITEM: {\n CONTAINER: 'item-container',\n HEADER: {\n CONTAINER: 'item-header-container',\n ADDON: 'item-header-addon',\n TITLE_CONTAINER: 'item-header-titles-container',\n PRIMARY_TITLE: 'item-header-primary-title',\n SECONDARY_TITLE: 'item-header-secondary-title',\n CUSTOM_ACTIONS_CONTAINER: 'item-header-custom-actions-container',\n TOOLTIP: 'item-header-tooltip',\n },\n CONTENT: {\n CONTAINER: 'item-content-container',\n },\n },\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,kBAAkB;AAExB,MAAM,mBAAmB;AAAA,EAC9B,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,QAAQ;AAAA,MACN,WAAW;AAAA,MACX,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,0BAA0B;AAAA,MAC1B,SAAS;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACP,WAAW;AAAA,IACb;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSAccordion';\nexport * from './parts/accordionItem/DSAccordionItem';\nexport * from './exported-related';\n\nexport { default } from './DSAccordion';\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,WAAAA,gBAAe;",
|
|
6
|
+
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
import React2, { useContext } from "react";
|
|
3
4
|
import { useGetGlobalAttributes, useGetXstyledProps } from "@elliemae/ds-utilities";
|
|
4
5
|
import { DSAccordionContext } from "../../DSAccordionCTX";
|
|
@@ -11,15 +12,21 @@ const AccordionContent = () => {
|
|
|
11
12
|
const childrenWithIndex = [];
|
|
12
13
|
const xstyledAttrs = useGetXstyledProps(rest);
|
|
13
14
|
const globalAttrs = useGetGlobalAttributes(rest);
|
|
14
|
-
React2.Children.forEach(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
React2.Children.forEach(
|
|
16
|
+
children,
|
|
17
|
+
(child, index) => childrenWithIndex.push(
|
|
18
|
+
React2.cloneElement(child, {
|
|
19
|
+
dsIndex: index
|
|
20
|
+
})
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ jsx(StyledContainer, {
|
|
18
24
|
"data-testid": DSAccordionDataTestid.GROUP,
|
|
19
25
|
...containerProps,
|
|
20
26
|
...globalAttrs,
|
|
21
|
-
...xstyledAttrs
|
|
22
|
-
|
|
27
|
+
...xstyledAttrs,
|
|
28
|
+
children: childrenWithIndex
|
|
29
|
+
});
|
|
23
30
|
};
|
|
24
31
|
export {
|
|
25
32
|
AccordionContent
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/accordionContent/AccordionContent.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-utilities';\nimport { DSAccordionContext } from '../../DSAccordionCTX';\nimport { DSAccordionDataTestid } from '../../exported-related/DSAccordionDatatestid';\nimport { StyledContainer } from './styles';\nimport type { DSAccordionT } from '../../react-desc-prop-types';\n\nexport const AccordionContent = (): JSX.Element => {\n const {\n props: { containerProps, children, ...rest },\n } = useContext(DSAccordionContext);\n\n const childrenWithIndex: React.ReactElement<DSAccordionT.InternalItemProps>[] = [];\n\n const xstyledAttrs = useGetXstyledProps(rest);\n\n const globalAttrs = useGetGlobalAttributes(rest);\n\n React.Children.forEach(children, (child, index) =>\n childrenWithIndex.push(\n React.cloneElement(child, {\n dsIndex: index,\n }),\n ),\n );\n\n return (\n <StyledContainer data-testid={DSAccordionDataTestid.GROUP} {...containerProps} {...globalAttrs} {...xstyledAttrs}>\n {childrenWithIndex}\n </StyledContainer>\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,OAAOA,UAAS,kBAAkB;AAClC,SAAS,wBAAwB,0BAA0B;AAC3D,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAGzB,MAAM,mBAAmB,MAAmB;AACjD,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB,aAAa,KAAK;AAAA,EAC7C,IAAI,WAAW,kBAAkB;AAEjC,QAAM,oBAA0E,CAAC;AAEjF,QAAM,eAAe,mBAAmB,IAAI;AAE5C,QAAM,cAAc,uBAAuB,IAAI;AAE/C,EAAAA,OAAM,SAAS;AAAA,IAAQ;AAAA,IAAU,CAAC,OAAO,UACvC,kBAAkB;AAAA,MAChBA,OAAM,aAAa,OAAO;AAAA,QACxB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SACE,oBAAC;AAAA,IAAgB,eAAa,sBAAsB;AAAA,IAAQ,GAAG;AAAA,IAAiB,GAAG;AAAA,IAAc,GAAG;AAAA,IACjG;AAAA,GACH;AAEJ;",
|
|
6
|
+
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/accordionContent/styles.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled, sizing, space, layout } from '@elliemae/ds-system';\nimport { DSAccordionName, DSAccordionSlots } from '../../exported-related';\n\nexport const StyledContainer = styled('div', {\n name: DSAccordionName,\n slot: DSAccordionSlots.CONTAINER,\n})`\n ${sizing}\n ${space}\n ${layout}\n`;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,QAAQ,QAAQ,OAAO,cAAc;AAC9C,SAAS,iBAAiB,wBAAwB;AAE3C,MAAM,kBAAkB,OAAO,OAAO;AAAA,EAC3C,MAAM;AAAA,EACN,MAAM,iBAAiB;AACzB,CAAC;AAAA,IACG;AAAA,IACA;AAAA,IACA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useContext, useCallback, useMemo } from "react";
|
|
3
4
|
import {
|
|
4
5
|
useMemoMergePropsWithDefault,
|
|
5
6
|
describe,
|
|
@@ -27,7 +28,10 @@ import { DSAccordionContext } from "../../DSAccordionCTX";
|
|
|
27
28
|
import { DSAccordionDataTestid } from "../../exported-related/DSAccordionDatatestid";
|
|
28
29
|
import { accordionItemPropTypes } from "../../react-desc-prop-types";
|
|
29
30
|
const DSAccordionItem = (props) => {
|
|
30
|
-
const propsWithDefaults = useMemoMergePropsWithDefault(
|
|
31
|
+
const propsWithDefaults = useMemoMergePropsWithDefault(
|
|
32
|
+
props,
|
|
33
|
+
accordionItemDefaultProps
|
|
34
|
+
);
|
|
31
35
|
const {
|
|
32
36
|
children,
|
|
33
37
|
title,
|
|
@@ -49,64 +53,99 @@ const DSAccordionItem = (props) => {
|
|
|
49
53
|
actualActiveValue,
|
|
50
54
|
props: { isDSMobile }
|
|
51
55
|
} = useContext(DSAccordionContext);
|
|
52
|
-
const onKeyDownWithIndex = useCallback(
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const onKeyDownWithIndex = useCallback(
|
|
57
|
+
(e) => {
|
|
58
|
+
handleOnKeyDown(e, dsIndex);
|
|
59
|
+
},
|
|
60
|
+
[dsIndex, handleOnKeyDown]
|
|
61
|
+
);
|
|
55
62
|
const [showPopover, setShowPopover] = useState(false);
|
|
56
63
|
const [referenceElement, setReferenceElement] = useState();
|
|
57
64
|
const CustomActionsContent = useMemo(() => {
|
|
58
65
|
if (!isDSMobile && customActions?.length > 0)
|
|
59
|
-
return /* @__PURE__ */
|
|
60
|
-
isDSMobile
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})
|
|
66
|
+
return /* @__PURE__ */ jsx(StyledItemCustomActions, {
|
|
67
|
+
isDSMobile,
|
|
68
|
+
children: customActions?.map(({ onClick, id, ...otherProps }) => /* @__PURE__ */ jsx(DSButton, {
|
|
69
|
+
onClick: (e) => {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
if (onClick)
|
|
72
|
+
onClick(e);
|
|
73
|
+
},
|
|
74
|
+
...otherProps,
|
|
75
|
+
buttonType: BUTTON_TYPE.SECONDARY
|
|
76
|
+
}, id))
|
|
77
|
+
});
|
|
71
78
|
if (!isDSMobile && renderCustomActions)
|
|
72
|
-
return /* @__PURE__ */
|
|
73
|
-
isDSMobile
|
|
74
|
-
|
|
79
|
+
return /* @__PURE__ */ jsx(StyledItemCustomActions, {
|
|
80
|
+
isDSMobile,
|
|
81
|
+
children: renderCustomActions({ allRefs: allChildrenReferences, actualActiveValue })
|
|
82
|
+
});
|
|
75
83
|
return null;
|
|
76
84
|
}, [actualActiveValue, allChildrenReferences, customActions, isDSMobile, renderCustomActions]);
|
|
77
85
|
const { isShowingEllipsis: isPrimaryShowingEllipsis, setElement: setPrimaryElement } = useIsShowingEllipsis();
|
|
78
86
|
const { isShowingEllipsis: isSecondaryShowingEllipsis, setElement: setSecondaryElement } = useIsShowingEllipsis();
|
|
79
|
-
const handleOnFocus = useCallback(
|
|
87
|
+
const handleOnFocus = useCallback(
|
|
88
|
+
() => setShowPopover(isPrimaryShowingEllipsis || isSecondaryShowingEllipsis),
|
|
89
|
+
[isPrimaryShowingEllipsis, isSecondaryShowingEllipsis]
|
|
90
|
+
);
|
|
80
91
|
const handleOnBlur = useCallback(() => setShowPopover(false), []);
|
|
81
92
|
const Titles = useMemo(() => {
|
|
82
93
|
if ((isPrimaryShowingEllipsis || isSecondaryShowingEllipsis) && !isDSMobile)
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx(StyledPrimaryTitle, {
|
|
97
|
+
ref: setPrimaryElement,
|
|
98
|
+
...title ? { id: `accordion_${title || ""}id` } : void 0,
|
|
99
|
+
disabled,
|
|
100
|
+
isDSMobile,
|
|
101
|
+
selected,
|
|
102
|
+
withSecondaryTitle: secondaryTitle,
|
|
103
|
+
children: title
|
|
104
|
+
}),
|
|
105
|
+
!isDSMobile && secondaryTitle && /* @__PURE__ */ jsx(StyledSecondaryTitle, {
|
|
106
|
+
ref: setSecondaryElement,
|
|
107
|
+
disabled,
|
|
108
|
+
selected,
|
|
109
|
+
children: secondaryTitle
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx(DSPopperJS, {
|
|
112
|
+
referenceElement,
|
|
113
|
+
showPopover,
|
|
114
|
+
children: /* @__PURE__ */ jsxs(StyledTooltipContent, {
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsx("p", {
|
|
117
|
+
children: title
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsxs("p", {
|
|
120
|
+
children: [
|
|
121
|
+
" ",
|
|
122
|
+
secondaryTitle
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsx(StyledPrimaryTitle, {
|
|
133
|
+
ref: setPrimaryElement,
|
|
134
|
+
...title ? { id: `accordion_${title || ""}id` } : void 0,
|
|
135
|
+
disabled,
|
|
136
|
+
isDSMobile,
|
|
137
|
+
selected,
|
|
138
|
+
withSecondaryTitle: secondaryTitle,
|
|
139
|
+
children: title
|
|
140
|
+
}),
|
|
141
|
+
!isDSMobile && secondaryTitle && /* @__PURE__ */ jsx(StyledSecondaryTitle, {
|
|
142
|
+
ref: setSecondaryElement,
|
|
143
|
+
disabled,
|
|
144
|
+
selected,
|
|
145
|
+
children: secondaryTitle
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
});
|
|
110
149
|
}, [
|
|
111
150
|
disabled,
|
|
112
151
|
isDSMobile,
|
|
@@ -120,52 +159,67 @@ const DSAccordionItem = (props) => {
|
|
|
120
159
|
selected,
|
|
121
160
|
title
|
|
122
161
|
]);
|
|
123
|
-
return /* @__PURE__ */
|
|
162
|
+
return /* @__PURE__ */ jsxs(StyledItemContainer, {
|
|
124
163
|
"data-testid": DSAccordionDataTestid.ITEM.CONTAINER,
|
|
125
164
|
className,
|
|
126
|
-
...xstyledAttrs
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
...xstyledAttrs,
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsxs(StyledItemHeaderContainer, {
|
|
168
|
+
disabled,
|
|
169
|
+
ref: setReferenceElement,
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ jsxs(StyledItemHeader, {
|
|
172
|
+
type: "button",
|
|
173
|
+
withCustomActions: (customActions?.length > 0 || renderCustomActions !== void 0) && !isDSMobile,
|
|
174
|
+
withSecondaryTitle: secondaryTitle,
|
|
175
|
+
onClick: handleOnClick,
|
|
176
|
+
tabIndex: !disabled ? 0 : void 0,
|
|
177
|
+
disabled,
|
|
178
|
+
"data-disabled": disabled,
|
|
179
|
+
ref: allChildrenReferences[dsIndex],
|
|
180
|
+
onKeyDown: onKeyDownWithIndex,
|
|
181
|
+
isDSMobile,
|
|
182
|
+
"data-testid": DSAccordionDataTestid.ITEM.HEADER,
|
|
183
|
+
id: `ds-accordion-header-${value}`,
|
|
184
|
+
"aria-expanded": selected,
|
|
185
|
+
"aria-disabled": disabled,
|
|
186
|
+
"aria-controls": `ds-accordion-content-${value}`,
|
|
187
|
+
onFocus: handleOnFocus,
|
|
188
|
+
onBlur: handleOnBlur,
|
|
189
|
+
...globalAttrs,
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ jsx(StyledItemAddon, {
|
|
192
|
+
disabled,
|
|
193
|
+
isDSMobile,
|
|
194
|
+
children: selected ? /* @__PURE__ */ jsx(IconOpened, {
|
|
195
|
+
isDSMobile
|
|
196
|
+
}) : /* @__PURE__ */ jsx(IconClosed, {
|
|
197
|
+
isDSMobile
|
|
198
|
+
})
|
|
199
|
+
}),
|
|
200
|
+
/* @__PURE__ */ jsx(StyledItemTitles, {
|
|
201
|
+
onMouseEnter: handleOnFocus,
|
|
202
|
+
onMouseLeave: handleOnBlur,
|
|
203
|
+
isDSMobile,
|
|
204
|
+
withSecondaryTitle: secondaryTitle,
|
|
205
|
+
selected,
|
|
206
|
+
children: Titles
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
}),
|
|
210
|
+
CustomActionsContent
|
|
211
|
+
]
|
|
212
|
+
}),
|
|
213
|
+
selected && /* @__PURE__ */ jsx(StyledItemContent, {
|
|
214
|
+
"data-testid": DSAccordionDataTestid.ITEM.CONTENT,
|
|
215
|
+
"aria-labelledby": `ds-accordion-header-${value}`,
|
|
216
|
+
role: "region",
|
|
217
|
+
isDSMobile,
|
|
218
|
+
id: `ds-accordion-content-${value}`,
|
|
219
|
+
children
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
});
|
|
169
223
|
};
|
|
170
224
|
DSAccordionItem.displayName = "DSAccordionItem";
|
|
171
225
|
const DSAccordionItemWithSchema = describe(DSAccordionItem);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/accordionItem/DSAccordionItem.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useState, useContext, useCallback, useMemo, WeakValidationMap } from 'react';\nimport {\n useMemoMergePropsWithDefault,\n describe,\n useIsShowingEllipsis,\n useGetGlobalAttributes,\n useGetXstyledProps,\n} from '@elliemae/ds-utilities';\nimport { DSButton, BUTTON_TYPE } from '@elliemae/ds-button';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { accordionItemDefaultProps } from '../../defaultProps';\nimport {\n StyledItemAddon,\n StyledItemContainer,\n StyledItemContent,\n StyledItemCustomActions,\n StyledItemHeader,\n StyledItemHeaderContainer,\n StyledItemTitles,\n StyledPrimaryTitle,\n StyledSecondaryTitle,\n StyledTooltipContent,\n} from './styles';\nimport { useAccordionItem } from './useAccordionItem';\nimport { DSAccordionContext } from '../../DSAccordionCTX';\nimport { DSAccordionDataTestid } from '../../exported-related/DSAccordionDatatestid';\nimport { accordionItemPropTypes } from '../../react-desc-prop-types';\nimport type { DSAccordionT } from '../../react-desc-prop-types';\n\nconst DSAccordionItem = (props: DSAccordionT.ItemProps): JSX.Element => {\n const propsWithDefaults = useMemoMergePropsWithDefault(\n props,\n accordionItemDefaultProps,\n ) as DSAccordionT.InternalItemProps;\n\n const {\n children,\n title,\n secondaryTitle,\n customActions,\n iconOpened: IconOpened,\n iconClosed: IconClosed,\n value,\n disabled,\n dsIndex,\n renderCustomActions,\n ...rest\n } = propsWithDefaults;\n\n const { className, ...globalAttrs } = useGetGlobalAttributes(rest);\n const xstyledAttrs = useGetXstyledProps(rest);\n\n const { handleOnClick, handleOnKeyDown, selected } = useAccordionItem({ value, disabled });\n const {\n allChildrenReferences,\n actualActiveValue,\n props: { isDSMobile },\n } = useContext(DSAccordionContext);\n\n const onKeyDownWithIndex = useCallback(\n (e: React.KeyboardEvent) => {\n handleOnKeyDown(e, dsIndex);\n },\n [dsIndex, handleOnKeyDown],\n );\n\n const [showPopover, setShowPopover] = useState(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>();\n\n const CustomActionsContent = useMemo(() => {\n if (!isDSMobile && customActions?.length > 0)\n return (\n <StyledItemCustomActions isDSMobile={isDSMobile}>\n {customActions?.map(({ onClick, id, ...otherProps }) => (\n <DSButton\n key={id}\n onClick={(e: React.MouseEvent<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement>): void => {\n e.stopPropagation();\n if (onClick) onClick(e as React.MouseEvent<HTMLElement, MouseEvent>);\n }}\n {...otherProps}\n buttonType={BUTTON_TYPE.SECONDARY}\n />\n ))}\n </StyledItemCustomActions>\n );\n\n if (!isDSMobile && renderCustomActions)\n return (\n <StyledItemCustomActions isDSMobile={isDSMobile}>\n {renderCustomActions({ allRefs: allChildrenReferences, actualActiveValue })}\n </StyledItemCustomActions>\n );\n return null;\n }, [actualActiveValue, allChildrenReferences, customActions, isDSMobile, renderCustomActions]);\n\n const { isShowingEllipsis: isPrimaryShowingEllipsis, setElement: setPrimaryElement } = useIsShowingEllipsis();\n\n const { isShowingEllipsis: isSecondaryShowingEllipsis, setElement: setSecondaryElement } = useIsShowingEllipsis();\n\n const handleOnFocus = useCallback(\n () => setShowPopover(isPrimaryShowingEllipsis || isSecondaryShowingEllipsis),\n [isPrimaryShowingEllipsis, isSecondaryShowingEllipsis],\n );\n\n const handleOnBlur = useCallback(() => setShowPopover(false), []);\n\n // eslint-disable-next-line complexity\n const Titles = useMemo(() => {\n if ((isPrimaryShowingEllipsis || isSecondaryShowingEllipsis) && !isDSMobile)\n return (\n <>\n <StyledPrimaryTitle\n ref={setPrimaryElement}\n {...(title ? { id: `accordion_${title || ''}id` } : undefined)}\n disabled={disabled}\n isDSMobile={isDSMobile}\n selected={selected}\n withSecondaryTitle={secondaryTitle}\n >\n {title}\n </StyledPrimaryTitle>\n {!isDSMobile && secondaryTitle && (\n <StyledSecondaryTitle ref={setSecondaryElement} disabled={disabled} selected={selected}>\n {secondaryTitle}\n </StyledSecondaryTitle>\n )}\n <DSPopperJS referenceElement={referenceElement} showPopover={showPopover}>\n <StyledTooltipContent>\n <p>{title}</p>\n <p> {secondaryTitle}</p>\n </StyledTooltipContent>\n </DSPopperJS>\n </>\n );\n\n return (\n <>\n <StyledPrimaryTitle\n ref={setPrimaryElement}\n {...(title ? { id: `accordion_${title || ''}id` } : undefined)}\n disabled={disabled}\n isDSMobile={isDSMobile}\n selected={selected}\n withSecondaryTitle={secondaryTitle}\n >\n {title}\n </StyledPrimaryTitle>\n {!isDSMobile && secondaryTitle && (\n <StyledSecondaryTitle ref={setSecondaryElement} disabled={disabled} selected={selected}>\n {secondaryTitle}\n </StyledSecondaryTitle>\n )}\n </>\n );\n }, [\n disabled,\n isDSMobile,\n isPrimaryShowingEllipsis,\n isSecondaryShowingEllipsis,\n referenceElement,\n secondaryTitle,\n setPrimaryElement,\n setSecondaryElement,\n showPopover,\n selected,\n title,\n ]);\n\n return (\n <StyledItemContainer data-testid={DSAccordionDataTestid.ITEM.CONTAINER} className={className} {...xstyledAttrs}>\n <StyledItemHeaderContainer disabled={disabled} ref={setReferenceElement}>\n <StyledItemHeader\n type=\"button\"\n withCustomActions={(customActions?.length > 0 || renderCustomActions !== undefined) && !isDSMobile}\n withSecondaryTitle={secondaryTitle}\n onClick={handleOnClick}\n tabIndex={!disabled ? 0 : undefined}\n disabled={disabled}\n data-disabled={disabled}\n ref={allChildrenReferences[dsIndex]}\n onKeyDown={onKeyDownWithIndex}\n isDSMobile={isDSMobile}\n data-testid={DSAccordionDataTestid.ITEM.HEADER}\n id={`ds-accordion-header-${value}`}\n aria-expanded={selected}\n aria-disabled={disabled}\n aria-controls={`ds-accordion-content-${value}`}\n onFocus={handleOnFocus}\n onBlur={handleOnBlur}\n {...globalAttrs}\n >\n <StyledItemAddon disabled={disabled} isDSMobile={isDSMobile}>\n {selected ? <IconOpened isDSMobile={isDSMobile} /> : <IconClosed isDSMobile={isDSMobile} />}\n </StyledItemAddon>\n <StyledItemTitles\n onMouseEnter={handleOnFocus}\n onMouseLeave={handleOnBlur}\n isDSMobile={isDSMobile}\n withSecondaryTitle={secondaryTitle}\n selected={selected}\n >\n {Titles}\n </StyledItemTitles>\n </StyledItemHeader>\n {CustomActionsContent}\n </StyledItemHeaderContainer>\n {selected && (\n <StyledItemContent\n data-testid={DSAccordionDataTestid.ITEM.CONTENT}\n aria-labelledby={`ds-accordion-header-${value}`}\n role=\"region\"\n isDSMobile={isDSMobile}\n id={`ds-accordion-content-${value}`}\n >\n {children}\n </StyledItemContent>\n )}\n </StyledItemContainer>\n );\n};\n\nDSAccordionItem.displayName = 'DSAccordionItem';\nconst DSAccordionItemWithSchema = describe(DSAccordionItem);\nDSAccordionItemWithSchema.propTypes = accordionItemPropTypes as WeakValidationMap<unknown>;\n\nexport { DSAccordionItem, DSAccordionItemWithSchema };\nexport default DSAccordionItem;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,UAAU,YAAY,aAAa,eAAkC;AACrF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,mBAAmB;AACtC,SAAS,kBAAkB;AAC3B,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AAGvC,MAAM,kBAAkB,CAAC,UAA+C;AACtE,QAAM,oBAAoB;AAAA,IACxB;AAAA,IACA;AAAA,EACF;AAEA,QAAM;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