@snack-uikit/breadcrumbs 0.10.15 → 0.10.16-preview-a3bb0dea.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/cjs/components/Collapse/Collapse.js +10 -2
- package/dist/cjs/components/Collapse/styles.module.css +4 -0
- package/dist/esm/components/Collapse/Collapse.js +7 -4
- package/dist/esm/components/Collapse/styles.module.css +4 -0
- package/package.json +2 -2
- package/src/components/Collapse/Collapse.tsx +13 -3
- package/src/components/Collapse/styles.module.scss +11 -2
|
@@ -32,10 +32,18 @@ function Collapse(_ref) {
|
|
|
32
32
|
const collapsedItems = currentConfig.filter(node => node.element === constants_1.ELEMENT_TYPE.Item && node.item.renderMode === constants_1.ITEM_RENDER_MODE.Collapsed).map(
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34
34
|
// @ts-ignore
|
|
35
|
-
node => ({
|
|
35
|
+
node => Object.assign({
|
|
36
36
|
content: {
|
|
37
37
|
option: node.item.label
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
|
+
}, node.item.href ? {
|
|
40
|
+
itemWrapRender: crumb => (0, jsx_runtime_1.jsx)("a", {
|
|
41
|
+
href: node.item.href,
|
|
42
|
+
onClick: node.item.onClick,
|
|
43
|
+
className: styles_module_scss_1.default.a,
|
|
44
|
+
children: crumb
|
|
45
|
+
})
|
|
46
|
+
} : {
|
|
39
47
|
onClick: node.item.onClick
|
|
40
48
|
}));
|
|
41
49
|
return (0, jsx_runtime_1.jsx)("div", {
|
|
@@ -15,9 +15,12 @@ export function Collapse({ currentConfig, className }) {
|
|
|
15
15
|
.map(
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
17
17
|
// @ts-ignore
|
|
18
|
-
(node) => ({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
(node) => (Object.assign({ content: { option: node.item.label } }, (node.item.href
|
|
19
|
+
? {
|
|
20
|
+
itemWrapRender: crumb => (_jsx("a", { href: node.item.href, onClick: node.item.onClick, className: styles.a, children: crumb })),
|
|
21
|
+
}
|
|
22
|
+
: {
|
|
23
|
+
onClick: node.item.onClick,
|
|
24
|
+
}))));
|
|
22
25
|
return (_jsx("div", { className: className, "data-test-id": getTestId('collapse', testId), "data-element-type": ELEMENT_TYPE.Collapse, children: _jsx(BreadcrumbsContext.Provider, { value: Object.assign(Object.assign({}, ctx), { testId: `${testId}-collapsed` }), children: _jsx(Droplist, { trigger: 'hoverAndFocusVisible', size: 's', scroll: true, triggerElemRef: buttonRef, items: collapsedItems, children: _jsx("button", { type: 'button', ref: buttonRef, className: styles.collapse, tabIndex: hidden ? -1 : 0, children: _jsx(CrumbsTypography, { size: size, children: "..." }) }) }) }) }));
|
|
23
26
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Breadcrumbs",
|
|
7
|
-
"version": "0.10.
|
|
7
|
+
"version": "0.10.16-preview-a3bb0dea.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"classnames": "2.5.1",
|
|
43
43
|
"lodash.debounce": "4.0.8"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8b0b9ad383b7999c2cc9ef43e8d12e3f67df7010"
|
|
46
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext, useRef } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Droplist } from '@snack-uikit/list';
|
|
3
|
+
import { Droplist, DroplistProps } from '@snack-uikit/list';
|
|
4
4
|
|
|
5
5
|
import { ELEMENT_TYPE, ITEM_RENDER_MODE } from '../../constants';
|
|
6
6
|
import { BreadcrumbsContext } from '../../context';
|
|
@@ -19,14 +19,24 @@ export function Collapse({ currentConfig, className }: CollapseProps) {
|
|
|
19
19
|
const { hidden, size, testId } = ctx;
|
|
20
20
|
const buttonRef = useRef(null);
|
|
21
21
|
|
|
22
|
-
const collapsedItems = currentConfig
|
|
22
|
+
const collapsedItems: DroplistProps['items'] = currentConfig
|
|
23
23
|
.filter(node => node.element === ELEMENT_TYPE.Item && node.item.renderMode === ITEM_RENDER_MODE.Collapsed)
|
|
24
24
|
.map(
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
(node: { element: typeof ELEMENT_TYPE.Item; width: number; item: InnerItem }) => ({
|
|
28
28
|
content: { option: node.item.label },
|
|
29
|
-
|
|
29
|
+
...(node.item.href
|
|
30
|
+
? {
|
|
31
|
+
itemWrapRender: crumb => (
|
|
32
|
+
<a href={node.item.href} onClick={node.item.onClick} className={styles.a}>
|
|
33
|
+
{crumb}
|
|
34
|
+
</a>
|
|
35
|
+
),
|
|
36
|
+
}
|
|
37
|
+
: {
|
|
38
|
+
onClick: node.item.onClick,
|
|
39
|
+
}),
|
|
30
40
|
}),
|
|
31
41
|
);
|
|
32
42
|
|
|
@@ -13,10 +13,19 @@
|
|
|
13
13
|
&:focus-visible {
|
|
14
14
|
@include styles-tokens-element.outline-var(styles-tokens-element.$container-focused-s);
|
|
15
15
|
|
|
16
|
-
outline-color: styles-tokens-element.simple-var(
|
|
16
|
+
outline-color: styles-tokens-element.simple-var(
|
|
17
|
+
styles-tokens-element.$theme-variables,
|
|
18
|
+
'sys',
|
|
19
|
+
'available',
|
|
20
|
+
'complementary'
|
|
21
|
+
);
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
.collapsedRow {
|
|
21
26
|
display: flex;
|
|
22
|
-
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.a {
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
}
|