@alfalab/core-components-list 3.1.2 → 3.2.1
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/Component-0887e7cb.d.ts +72 -0
- package/Component-6858e395.d.ts +15 -0
- package/Component-6858e395.js +66 -0
- package/Component.d.ts +0 -29
- package/Component.js +9 -31
- package/components/item/Component.d.ts +0 -0
- package/components/item/Component.js +14 -0
- package/components/item/index.css +49 -0
- package/components/item/index.d.ts +1 -0
- package/components/item/index.js +14 -0
- package/cssm/Component-0887e7cb.d.ts +72 -0
- package/cssm/Component-7cc47e0b.d.ts +15 -0
- package/cssm/Component-7cc47e0b.js +64 -0
- package/cssm/Component.d.ts +0 -29
- package/cssm/Component.js +11 -30
- package/cssm/components/item/Component.d.ts +0 -0
- package/cssm/components/item/Component.js +16 -0
- package/cssm/components/item/index.d.ts +1 -0
- package/cssm/components/item/index.js +16 -0
- package/cssm/components/item/index.module.css +48 -0
- package/cssm/index.d.ts +1 -1
- package/cssm/index.js +8 -2
- package/cssm/index.module.css +8 -21
- package/cssm/presets.js +2 -0
- package/cssm/utils.d.ts +5 -0
- package/cssm/utils.js +15 -0
- package/esm/Component-0887e7cb.d.ts +72 -0
- package/esm/Component-bb93aa74.d.ts +15 -0
- package/esm/Component-bb93aa74.js +57 -0
- package/esm/Component.d.ts +0 -29
- package/esm/Component.js +6 -30
- package/esm/components/item/Component.d.ts +0 -0
- package/esm/components/item/Component.js +6 -0
- package/esm/components/item/index.css +49 -0
- package/esm/components/item/index.d.ts +1 -0
- package/esm/components/item/index.js +6 -0
- package/esm/index.css +12 -25
- package/esm/index.d.ts +1 -1
- package/esm/index.js +3 -1
- package/esm/utils.d.ts +5 -0
- package/esm/utils.js +10 -0
- package/index.css +12 -25
- package/index.d.ts +1 -1
- package/index.js +7 -2
- package/modern/Component-0887e7cb.d.ts +72 -0
- package/modern/Component-cfeaa92e.d.ts +15 -0
- package/modern/Component-cfeaa92e.js +52 -0
- package/modern/Component.d.ts +0 -29
- package/modern/Component.js +5 -27
- package/modern/components/item/Component.d.ts +0 -0
- package/modern/components/item/Component.js +5 -0
- package/modern/components/item/index.css +49 -0
- package/modern/components/item/index.d.ts +1 -0
- package/modern/components/item/index.js +5 -0
- package/modern/index.css +12 -25
- package/modern/index.d.ts +1 -1
- package/modern/index.js +3 -1
- package/modern/utils.d.ts +5 -0
- package/modern/utils.js +6 -0
- package/package.json +2 -1
- package/presets.js +2 -0
- package/utils.d.ts +5 -0
- package/utils.js +15 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
type ItemProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Дополнительный текст
|
|
7
|
+
*/
|
|
8
|
+
caption?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Дочерние элементы.
|
|
11
|
+
*/
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
declare const Item: React.FC<ItemProps>;
|
|
15
|
+
export { ItemProps, Item };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { useContext, Children } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Typography } from '@alfalab/core-components-typography/modern';
|
|
4
|
+
import { isItem } from './utils.js';
|
|
5
|
+
|
|
6
|
+
const styles$1 = {"item":"list__item_1hiip","reversed":"list__reversed_1hiip","unorderedItem":"list__unorderedItem_1hiip","slot":"list__slot_1hiip","defaultColor":"list__defaultColor_1hiip","disc":"list__disc_1hiip","caption":"list__caption_1hiip"};
|
|
7
|
+
require('./components/item/index.css')
|
|
8
|
+
|
|
9
|
+
const Item = ({ caption, children }) => {
|
|
10
|
+
const { orderedList, markerType, colorMarker, reversed, index = 0, start = 0, } = useContext(ListContext);
|
|
11
|
+
const markerLowerAlpha = markerType === 'lower-alpha';
|
|
12
|
+
const itemClassNames = cn(styles$1.item, {
|
|
13
|
+
[styles$1.unorderedItem]: markerLowerAlpha,
|
|
14
|
+
[styles$1.reversed]: reversed,
|
|
15
|
+
});
|
|
16
|
+
const isDisc = markerType === '•';
|
|
17
|
+
const count = start === 0 ? index + 1 : start + index;
|
|
18
|
+
const marker = orderedList || markerType === 'decimal' ? `${count}.` : markerType;
|
|
19
|
+
return (React.createElement("li", { className: cn(itemClassNames) },
|
|
20
|
+
!markerLowerAlpha && (React.createElement(Typography.Text, { tag: 'div', color: colorMarker, monospaceNumbers: true, view: 'primary-medium', className: cn(styles$1.slot, {
|
|
21
|
+
[styles$1.disc]: isDisc && !orderedList,
|
|
22
|
+
[styles$1.defaultColor]: !colorMarker,
|
|
23
|
+
}) }, marker)),
|
|
24
|
+
React.createElement("div", null,
|
|
25
|
+
React.createElement(Typography.Text, { tag: 'div', view: 'primary-medium' }, children),
|
|
26
|
+
caption && (React.createElement(Typography.Text, { tag: 'div', view: 'primary-small', color: 'secondary', className: styles$1.caption }, caption)))));
|
|
27
|
+
};
|
|
28
|
+
Item.displayName = 'ListItem';
|
|
29
|
+
|
|
30
|
+
const styles = {"list":"list__list_1o0md","lowerAlpha":"list__lowerAlpha_1o0md","decimal":"list__decimal_1o0md","reversed":"list__reversed_1o0md"};
|
|
31
|
+
require('./index.css')
|
|
32
|
+
|
|
33
|
+
const ListContext = React.createContext({});
|
|
34
|
+
const ListComponent = ({ tag = 'ul', marker, className, dataTestId, colorMarker, children, reversed, start, ...restProps }) => {
|
|
35
|
+
const markerType = marker || (tag === 'ul' ? '—' : 'decimal');
|
|
36
|
+
const alphaMarker = markerType === 'lower-alpha';
|
|
37
|
+
const decimalMarker = markerType === 'decimal';
|
|
38
|
+
const Component = tag === 'ul' || alphaMarker ? 'ul' : 'ol';
|
|
39
|
+
const orderedList = Component === 'ol';
|
|
40
|
+
const listClassNames = cn(styles.list, {
|
|
41
|
+
[styles.lowerAlpha]: alphaMarker,
|
|
42
|
+
[styles.decimal]: decimalMarker,
|
|
43
|
+
[styles.reversed]: reversed,
|
|
44
|
+
}, className);
|
|
45
|
+
/* eslint-disable react/jsx-no-constructed-context-values */
|
|
46
|
+
return (React.createElement(Component, { className: listClassNames, "data-test-id": dataTestId, ...restProps }, Children.map(children, (child, index) => (React.createElement(ListContext.Provider, { value: { orderedList, markerType, colorMarker, reversed, index, start } }, isItem(child) ? child : React.createElement(Item, null, child))))));
|
|
47
|
+
};
|
|
48
|
+
const List = Object.assign(ListComponent, {
|
|
49
|
+
Item,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export { Item as I, ListContext as L, List as a };
|
package/modern/Component.d.ts
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
type ListProps = {
|
|
5
|
-
/**
|
|
6
|
-
* HTML тег
|
|
7
|
-
* @default 'ul'
|
|
8
|
-
*/
|
|
9
|
-
tag?: 'ul' | 'ol';
|
|
10
|
-
/**
|
|
11
|
-
* Маркер
|
|
12
|
-
* @default '—' for ul and 'decimal' for ol
|
|
13
|
-
*/
|
|
14
|
-
marker?: 'lower-alpha' | 'decimal' | string | ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
* Css-класс для стилизации
|
|
17
|
-
*/
|
|
18
|
-
className?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Id компонента для тестов
|
|
21
|
-
*/
|
|
22
|
-
dataTestId?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Дочерние элементы.
|
|
25
|
-
*/
|
|
26
|
-
children?: ReactNode;
|
|
27
|
-
} & Omit<React.OlHTMLAttributes<HTMLOListElement>, 'type'>;
|
|
28
|
-
declare const List: React.FC<ListProps>;
|
|
29
|
-
export { ListProps, List };
|
package/modern/Component.js
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const List = ({ tag = 'ul', marker, className, dataTestId, children, ...restProps }) => {
|
|
8
|
-
const markerType = marker || (tag === 'ul' ? '—' : 'decimal');
|
|
9
|
-
const orderedMarker = markerType === 'decimal' || markerType === 'lower-alpha';
|
|
10
|
-
const Component = tag === 'ol' || orderedMarker ? 'ol' : 'ul';
|
|
11
|
-
const unorderedList = Component === 'ul';
|
|
12
|
-
const orderedList = Component === 'ol';
|
|
13
|
-
const listClassNames = cn(styles.list, {
|
|
14
|
-
[styles.lowerAlpha]: markerType === 'lower-alpha',
|
|
15
|
-
[styles.decimal]: markerType === 'decimal',
|
|
16
|
-
[styles.orderedList]: orderedList,
|
|
17
|
-
}, className);
|
|
18
|
-
const itemClassNames = cn(styles.item, {
|
|
19
|
-
[styles.unorderedItem]: unorderedList,
|
|
20
|
-
[styles.orderedItem]: orderedList,
|
|
21
|
-
});
|
|
22
|
-
return (React.createElement(Component, { className: listClassNames, "data-test-id": dataTestId, ...restProps }, Children.map(children, (child) => (React.createElement("li", { className: itemClassNames },
|
|
23
|
-
unorderedList && React.createElement("div", { className: styles.slot }, markerType),
|
|
24
|
-
child)))));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { List };
|
|
1
|
+
import 'react';
|
|
2
|
+
import 'classnames';
|
|
3
|
+
export { a as List, L as ListContext } from './Component-cfeaa92e.js';
|
|
4
|
+
import './utils.js';
|
|
5
|
+
import '@alfalab/core-components-typography/modern';
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* hash: 128f6 */
|
|
2
|
+
:root {
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-text-primary: #0e0e0e; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
5
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
6
|
+
} :root {
|
|
7
|
+
} :root {
|
|
8
|
+
|
|
9
|
+
/* Hard */
|
|
10
|
+
|
|
11
|
+
/* Up */
|
|
12
|
+
|
|
13
|
+
/* Hard up */
|
|
14
|
+
} :root {
|
|
15
|
+
} :root {
|
|
16
|
+
--gap-3xs: 2px;
|
|
17
|
+
--gap-2xs: 4px;
|
|
18
|
+
--gap-s: 12px;
|
|
19
|
+
} :root {
|
|
20
|
+
} :root {
|
|
21
|
+
} :root {
|
|
22
|
+
--list-marker-color: var(--color-light-text-primary);
|
|
23
|
+
--list-item-margin: var(--gap-s);
|
|
24
|
+
} .list__item_1hiip {
|
|
25
|
+
margin-top: var(--list-item-margin);
|
|
26
|
+
display: flex
|
|
27
|
+
} .list__item_1hiip:first-child {
|
|
28
|
+
margin-top: 0;
|
|
29
|
+
} .list__item_1hiip.list__reversed_1hiip:first-child {
|
|
30
|
+
margin-top: var(--list-item-margin);
|
|
31
|
+
} .list__item_1hiip.list__reversed_1hiip:last-child {
|
|
32
|
+
margin-top: 0;
|
|
33
|
+
} .list__item_1hiip.list__unorderedItem_1hiip {
|
|
34
|
+
display: list-item;
|
|
35
|
+
} .list__slot_1hiip {
|
|
36
|
+
min-width: 20px;
|
|
37
|
+
display: flex;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
justify-content: start;
|
|
40
|
+
padding-right: var(--gap-2xs);
|
|
41
|
+
flex-shrink: 0
|
|
42
|
+
} .list__slot_1hiip.list__defaultColor_1hiip {
|
|
43
|
+
color: var(--list-marker-color);
|
|
44
|
+
} .list__slot_1hiip.list__disc_1hiip {
|
|
45
|
+
justify-content: center;
|
|
46
|
+
padding: 0 var(--gap-2xs);
|
|
47
|
+
} .list__caption_1hiip {
|
|
48
|
+
margin-top: var(--gap-3xs);
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../Component-cfeaa92e";
|
package/modern/index.css
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1fkvi */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
|
-
--color-light-text-primary: #
|
|
5
|
-
} :root {
|
|
4
|
+
--color-light-text-primary: #0e0e0e; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
5
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
6
6
|
} :root {
|
|
7
7
|
} :root {
|
|
8
8
|
|
|
@@ -13,16 +13,10 @@
|
|
|
13
13
|
/* Hard up */
|
|
14
14
|
} :root {
|
|
15
15
|
} :root {
|
|
16
|
-
--gap-2xs: 4px;
|
|
17
|
-
--gap-xs: 8px;
|
|
18
|
-
--gap-s: 12px;
|
|
19
16
|
--gap-l: 20px;
|
|
20
17
|
} :root {
|
|
21
18
|
} :root {
|
|
22
|
-
}
|
|
23
|
-
--list-marker-color: var(--color-light-text-primary);
|
|
24
|
-
--list-item-margin: var(--gap-s);
|
|
25
|
-
} .list__list_h12ja {
|
|
19
|
+
} .list__list_1o0md {
|
|
26
20
|
margin: 0;
|
|
27
21
|
padding: 0;
|
|
28
22
|
color: var(--color-light-text-primary);
|
|
@@ -32,21 +26,14 @@
|
|
|
32
26
|
line-height: 24px;
|
|
33
27
|
|
|
34
28
|
font-weight: 400;
|
|
35
|
-
} .
|
|
36
|
-
padding-left: var(--gap-l);
|
|
37
|
-
} .list__lowerAlpha_h12ja {
|
|
29
|
+
} .list__lowerAlpha_1o0md {
|
|
38
30
|
list-style-type: lower-alpha;
|
|
39
|
-
|
|
31
|
+
padding-left: var(--gap-l);
|
|
32
|
+
} .list__decimal_1o0md {
|
|
40
33
|
list-style-type: decimal;
|
|
41
|
-
} .
|
|
42
|
-
margin-top: var(--list-item-margin)
|
|
43
|
-
} .list__item_h12ja:first-child {
|
|
44
|
-
margin-top: 0;
|
|
45
|
-
} .list__unorderedItem_h12ja {
|
|
34
|
+
} ol.list__list_1o0md {
|
|
46
35
|
display: flex;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
color: var(--list-marker-color);
|
|
52
|
-
}
|
|
36
|
+
flex-direction: column
|
|
37
|
+
} ol.list__list_1o0md.list__reversed_1o0md {
|
|
38
|
+
flex-direction: column-reverse;
|
|
39
|
+
}
|
package/modern/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Component";
|
|
1
|
+
export * from "./Component-0887e7cb";
|
|
2
2
|
export * from "./presets";
|
package/modern/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { List } from './Component.js';
|
|
1
|
+
export { a as List, L as ListContext } from './Component-cfeaa92e.js';
|
|
2
2
|
export { listPresets } from './presets.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'classnames';
|
|
5
|
+
import '@alfalab/core-components-typography/modern';
|
|
6
|
+
import './utils.js';
|
package/modern/utils.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-list",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@alfalab/core-components-typography": "^3.2.1",
|
|
20
21
|
"classnames": "^2.3.1",
|
|
21
22
|
"tslib": "^2.4.0"
|
|
22
23
|
}
|
package/presets.js
CHANGED
package/utils.d.ts
ADDED
package/utils.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
var isItemElement = function (obj, name) {
|
|
8
|
+
return typeof obj === 'object' && obj.type.displayName === name;
|
|
9
|
+
};
|
|
10
|
+
var isItem = function (child) {
|
|
11
|
+
return React.isValidElement(child) && isItemElement(child, 'ListItem');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.isItem = isItem;
|
|
15
|
+
exports.isItemElement = isItemElement;
|