@snack-uikit/breadcrumbs 0.8.62 → 0.8.63-preview-ba12ca94.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/Breadcrumbs/Breadcrumbs.js +90 -0
- package/dist/cjs/components/Breadcrumbs/index.js +25 -0
- package/dist/cjs/components/Collapse/Collapse.js +68 -0
- package/dist/cjs/components/Collapse/index.js +25 -0
- package/dist/cjs/components/Crumb/Crumb.js +118 -0
- package/dist/cjs/components/Crumb/index.js +25 -0
- package/dist/cjs/components/CrumbsTypography/CrumbsTypography.js +24 -0
- package/dist/cjs/components/CrumbsTypography/index.js +25 -0
- package/dist/cjs/components/HiddenChain/HiddenChain.js +57 -0
- package/dist/cjs/components/HiddenChain/hooks.js +42 -0
- package/dist/cjs/components/HiddenChain/index.js +25 -0
- package/dist/cjs/components/Separator/Separator.js +36 -0
- package/dist/cjs/components/Separator/index.js +25 -0
- package/dist/cjs/components/Wrapper/Wrapper.js +57 -0
- package/dist/cjs/components/Wrapper/index.js +25 -0
- package/dist/cjs/components/index.js +25 -0
- package/dist/cjs/constants.js +22 -0
- package/dist/cjs/context.js +13 -0
- package/dist/cjs/hooks.js +97 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/types.js +6 -0
- package/dist/cjs/utils/buildBreadcrumbsConfigs.js +136 -0
- package/dist/cjs/utils/buildSizeMap.js +32 -0
- package/dist/cjs/utils/getMaxPossibleWidth.js +27 -0
- package/dist/cjs/utils/getTestId.js +8 -0
- package/dist/cjs/utils/index.js +28 -0
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.d.ts +33 -0
- package/dist/esm/components/Collapse/Collapse.d.ts +6 -0
- package/dist/esm/components/Collapse/index.js +1 -0
- package/dist/esm/components/Collapse/styles.module.css +18 -0
- package/dist/esm/components/Crumb/Crumb.d.ts +11 -0
- package/dist/esm/components/Crumb/index.js +1 -0
- package/dist/esm/components/Crumb/styles.module.css +55 -0
- package/dist/esm/components/CrumbsTypography/CrumbsTypography.d.ts +7 -0
- package/dist/esm/components/CrumbsTypography/index.js +1 -0
- package/dist/esm/components/HiddenChain/HiddenChain.d.ts +10 -0
- package/dist/esm/components/HiddenChain/hooks.d.ts +6 -0
- package/dist/esm/components/HiddenChain/index.js +1 -0
- package/dist/esm/components/Separator/Separator.d.ts +1 -0
- package/dist/esm/components/Separator/index.js +1 -0
- package/dist/esm/components/Separator/styles.module.css +15 -0
- package/dist/esm/components/Wrapper/Wrapper.d.ts +19 -0
- package/dist/esm/components/Wrapper/index.js +1 -0
- package/dist/esm/components/Wrapper/styles.module.css +19 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/styles.module.css +3 -0
- package/dist/esm/constants.d.ts +16 -0
- package/dist/esm/context.d.ts +9 -0
- package/dist/esm/hooks.d.ts +21 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/types.d.ts +54 -0
- package/dist/esm/utils/buildBreadcrumbsConfigs.d.ts +2 -0
- package/dist/esm/utils/buildSizeMap.d.ts +2 -0
- package/dist/esm/utils/getMaxPossibleWidth.d.ts +6 -0
- package/dist/esm/utils/getTestId.d.ts +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/package.json +12 -8
- /package/dist/{components → cjs/components}/Breadcrumbs/Breadcrumbs.d.ts +0 -0
- /package/dist/{components → cjs/components}/Breadcrumbs/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/Collapse/Collapse.d.ts +0 -0
- /package/dist/{components → cjs/components}/Collapse/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/Collapse/styles.module.css +0 -0
- /package/dist/{components → cjs/components}/Crumb/Crumb.d.ts +0 -0
- /package/dist/{components → cjs/components}/Crumb/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/Crumb/styles.module.css +0 -0
- /package/dist/{components → cjs/components}/CrumbsTypography/CrumbsTypography.d.ts +0 -0
- /package/dist/{components → cjs/components}/CrumbsTypography/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/HiddenChain/HiddenChain.d.ts +0 -0
- /package/dist/{components → cjs/components}/HiddenChain/hooks.d.ts +0 -0
- /package/dist/{components → cjs/components}/HiddenChain/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/Separator/Separator.d.ts +0 -0
- /package/dist/{components → cjs/components}/Separator/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/Separator/styles.module.css +0 -0
- /package/dist/{components → cjs/components}/Wrapper/Wrapper.d.ts +0 -0
- /package/dist/{components → cjs/components}/Wrapper/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/Wrapper/styles.module.css +0 -0
- /package/dist/{components → cjs/components}/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/styles.module.css +0 -0
- /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
- /package/dist/{context.d.ts → cjs/context.d.ts} +0 -0
- /package/dist/{hooks.d.ts → cjs/hooks.d.ts} +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{types.d.ts → cjs/types.d.ts} +0 -0
- /package/dist/{utils → cjs/utils}/buildBreadcrumbsConfigs.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/buildSizeMap.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/getMaxPossibleWidth.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/getTestId.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/index.d.ts +0 -0
- /package/dist/{components → esm/components}/Breadcrumbs/Breadcrumbs.js +0 -0
- /package/dist/{components/Breadcrumbs/index.js → esm/components/Breadcrumbs/index.d.ts} +0 -0
- /package/dist/{components → esm/components/Breadcrumbs}/index.js +0 -0
- /package/dist/{components → esm/components}/Collapse/Collapse.js +0 -0
- /package/dist/{components/Collapse/index.js → esm/components/Collapse/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/Crumb/Crumb.js +0 -0
- /package/dist/{components/Crumb/index.js → esm/components/Crumb/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/CrumbsTypography/CrumbsTypography.js +0 -0
- /package/dist/{components/CrumbsTypography/index.js → esm/components/CrumbsTypography/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/HiddenChain/HiddenChain.js +0 -0
- /package/dist/{components → esm/components}/HiddenChain/hooks.js +0 -0
- /package/dist/{components/HiddenChain/index.js → esm/components/HiddenChain/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/Separator/Separator.js +0 -0
- /package/dist/{components/Separator/index.js → esm/components/Separator/index.d.ts} +0 -0
- /package/dist/{components → esm/components}/Wrapper/Wrapper.js +0 -0
- /package/dist/{components/Wrapper/index.js → esm/components/Wrapper/index.d.ts} +0 -0
- /package/dist/{constants.js → esm/constants.js} +0 -0
- /package/dist/{context.js → esm/context.js} +0 -0
- /package/dist/{hooks.js → esm/hooks.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{types.js → esm/types.js} +0 -0
- /package/dist/{utils → esm/utils}/buildBreadcrumbsConfigs.js +0 -0
- /package/dist/{utils → esm/utils}/buildSizeMap.js +0 -0
- /package/dist/{utils → esm/utils}/getMaxPossibleWidth.js +0 -0
- /package/dist/{utils → esm/utils}/getTestId.js +0 -0
- /package/dist/{utils/index.js → esm/utils/index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Breadcrumbs';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const SEPARATOR = "\u203A";
|
|
2
|
+
export declare const ITEM_RENDER_MODE: {
|
|
3
|
+
readonly Full: "full";
|
|
4
|
+
readonly ShortLabel: "shortLabel";
|
|
5
|
+
readonly Ellipsis: "ellipsis";
|
|
6
|
+
readonly Collapsed: "collapsed";
|
|
7
|
+
};
|
|
8
|
+
export declare const ELEMENT_TYPE: {
|
|
9
|
+
readonly Separator: "separator";
|
|
10
|
+
readonly Collapse: "collapse";
|
|
11
|
+
readonly Item: "item";
|
|
12
|
+
};
|
|
13
|
+
export declare const SIZE: {
|
|
14
|
+
readonly Xs: "xs";
|
|
15
|
+
readonly S: "s";
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { BreadcrumbsConfig, CurrentConfigState } from './types';
|
|
3
|
+
export type BreadcrumbsLayout = {
|
|
4
|
+
setConfigs: (configs: BreadcrumbsConfig[]) => void;
|
|
5
|
+
currentConfig?: CurrentConfigState;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Расчет способа отображения breadcrumbs работает следующим образом:
|
|
9
|
+
* Каждый item может быть отображен в одном из режимов:
|
|
10
|
+
* full - целиком
|
|
11
|
+
* shortLabel - с использованием укороченного лейбла
|
|
12
|
+
* ellipsis - cо скруглением текста в ...
|
|
13
|
+
* collapse - спрятан в специальный узел "..." с тултипом.
|
|
14
|
+
* Для того чтоб эффективно распределить свободное по ширине пространство между айтемами в компоненте создается скрытый контейнер (HiddenChain),
|
|
15
|
+
* в котором рендерятся все айтемы во всех возможных способах отображения. Замеряется размер каждого из айтемов и записывается в sizeMap.
|
|
16
|
+
* Далее перебираются все возможные варианты отображения всей цепочки - конфиги (buildBreadcrumbsConfigs). У такого конфига есть два атрибута:
|
|
17
|
+
* width - суммарная ширина
|
|
18
|
+
* weight - вес, отображает общее количество сокращений, примененных к цепочке (например, отображение в режиме full - 0, сокращение shortLabel - +1, а ellipsis - +100 и тд)
|
|
19
|
+
* Для того чтоб отобразить breadcrumbs, нужно подобрать конфиг, максимальный по ширине, влезающий в контейнер, но с минимальным весом (наименьшим количеством сокращений).
|
|
20
|
+
*/
|
|
21
|
+
export declare function useBreadcrumbsLayout(containerRef: RefObject<HTMLElement>): BreadcrumbsLayout;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { JSXElementConstructor, MouseEventHandler } from 'react';
|
|
2
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
3
|
+
import { ELEMENT_TYPE, ITEM_RENDER_MODE, SIZE } from './constants';
|
|
4
|
+
export type Size = ValueOf<typeof SIZE>;
|
|
5
|
+
export type ElementType = ValueOf<typeof ELEMENT_TYPE>;
|
|
6
|
+
export type ItemRenderMode = ValueOf<typeof ITEM_RENDER_MODE>;
|
|
7
|
+
export type Item = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
icon?: JSXElementConstructor<{
|
|
11
|
+
size: number;
|
|
12
|
+
}>;
|
|
13
|
+
href?: string;
|
|
14
|
+
shortLabel?: string;
|
|
15
|
+
onClick?: MouseEventHandler<HTMLAnchorElement | HTMLButtonElement>;
|
|
16
|
+
};
|
|
17
|
+
export type InnerItem = Item & {
|
|
18
|
+
renderMode: ItemRenderMode;
|
|
19
|
+
};
|
|
20
|
+
export type ItemSizeMap = {
|
|
21
|
+
[ITEM_RENDER_MODE.ShortLabel]: number;
|
|
22
|
+
[ITEM_RENDER_MODE.Collapsed]: number;
|
|
23
|
+
[ITEM_RENDER_MODE.Ellipsis]: number;
|
|
24
|
+
[ITEM_RENDER_MODE.Full]: number;
|
|
25
|
+
};
|
|
26
|
+
export type SizeMap = {
|
|
27
|
+
separator: number;
|
|
28
|
+
collapse: number;
|
|
29
|
+
items: {
|
|
30
|
+
[key: string]: ItemSizeMap;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type BreadcrumbsConfigChain = Array<{
|
|
34
|
+
element: typeof ELEMENT_TYPE.Collapse;
|
|
35
|
+
width: number;
|
|
36
|
+
} | {
|
|
37
|
+
element: typeof ELEMENT_TYPE.Separator;
|
|
38
|
+
width: number;
|
|
39
|
+
} | {
|
|
40
|
+
element: typeof ELEMENT_TYPE.Item;
|
|
41
|
+
width: number;
|
|
42
|
+
item: InnerItem;
|
|
43
|
+
}>;
|
|
44
|
+
export type CurrentConfigState = {
|
|
45
|
+
chain: BreadcrumbsConfigChain;
|
|
46
|
+
chainWidth: number;
|
|
47
|
+
containerWidth: number;
|
|
48
|
+
};
|
|
49
|
+
export type BreadcrumbsConfig = {
|
|
50
|
+
chain: BreadcrumbsConfigChain;
|
|
51
|
+
hasCollapsed: boolean;
|
|
52
|
+
weight: number;
|
|
53
|
+
width: number;
|
|
54
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Функция предназначена для измерения максимально возможной ширины контейнера
|
|
3
|
+
* она вставляет широкую распорку, замеряет ширину и удаляет ее
|
|
4
|
+
* это происходит в одном обороте eventLoop, поэтому новый кадр с распоркой не рендерится браузером.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getMaxPossibleWidth: (element: HTMLElement) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTestId: (prefix: string, testId?: string) => string;
|
package/package.json
CHANGED
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Breadcrumbs",
|
|
7
|
-
"version": "0.8.
|
|
7
|
+
"version": "0.8.63-preview-ba12ca94.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
11
11
|
"*.woff2"
|
|
12
12
|
],
|
|
13
13
|
"description": "",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"types": "./dist/esm/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"import": "./dist/esm/index.js",
|
|
17
|
+
"require": "./dist/cjs/index.js"
|
|
18
|
+
},
|
|
16
19
|
"homepage": "https://github.com/cloud-ru-tech/snack-uikit/tree/master/packages/breadcrumbs",
|
|
17
20
|
"repository": {
|
|
18
21
|
"type": "git",
|
|
@@ -24,7 +27,8 @@
|
|
|
24
27
|
"Сергей Хлупин <svhlupin@cloud.ru>"
|
|
25
28
|
],
|
|
26
29
|
"files": [
|
|
27
|
-
"dist",
|
|
30
|
+
"dist/cjs",
|
|
31
|
+
"dist/esm",
|
|
28
32
|
"src",
|
|
29
33
|
"./CHANGELOG.md",
|
|
30
34
|
"./LICENSE"
|
|
@@ -32,11 +36,11 @@
|
|
|
32
36
|
"license": "Apache-2.0",
|
|
33
37
|
"scripts": {},
|
|
34
38
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/list": "0.18.0",
|
|
36
|
-
"@snack-uikit/typography": "0.6.
|
|
37
|
-
"@snack-uikit/utils": "3.4.0",
|
|
39
|
+
"@snack-uikit/list": "0.18.1-preview-ba12ca94.0",
|
|
40
|
+
"@snack-uikit/typography": "0.6.4-preview-ba12ca94.0",
|
|
41
|
+
"@snack-uikit/utils": "3.4.1-preview-ba12ca94.0",
|
|
38
42
|
"classnames": "2.3.2",
|
|
39
43
|
"lodash.debounce": "4.0.8"
|
|
40
44
|
},
|
|
41
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9ac0a3e5e530c09fa4dc050f9bc08d1849962129"
|
|
42
46
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{components/CrumbsTypography/index.js → esm/components/CrumbsTypography/index.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|