@alfalab/core-components-list 3.1.2 → 3.2.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.
Files changed (61) hide show
  1. package/Component-0887e7cb.d.ts +72 -0
  2. package/Component-71bc37e9.d.ts +15 -0
  3. package/Component-71bc37e9.js +66 -0
  4. package/Component.d.ts +0 -29
  5. package/Component.js +8 -32
  6. package/components/item/Component.d.ts +0 -0
  7. package/components/item/Component.js +12 -0
  8. package/components/item/index.css +49 -0
  9. package/components/item/index.d.ts +1 -0
  10. package/components/item/index.js +12 -0
  11. package/cssm/Component-0887e7cb.d.ts +72 -0
  12. package/cssm/Component-7cc47e0b.d.ts +15 -0
  13. package/cssm/Component-7cc47e0b.js +64 -0
  14. package/cssm/Component.d.ts +0 -29
  15. package/cssm/Component.js +10 -31
  16. package/cssm/components/item/Component.d.ts +0 -0
  17. package/cssm/components/item/Component.js +14 -0
  18. package/cssm/components/item/index.d.ts +1 -0
  19. package/cssm/components/item/index.js +14 -0
  20. package/cssm/components/item/index.module.css +48 -0
  21. package/cssm/index.d.ts +1 -1
  22. package/cssm/index.js +6 -2
  23. package/cssm/index.module.css +8 -21
  24. package/cssm/utils.d.ts +5 -0
  25. package/cssm/utils.js +13 -0
  26. package/esm/Component-0887e7cb.d.ts +72 -0
  27. package/esm/Component-5084b3b8.d.ts +15 -0
  28. package/esm/Component-5084b3b8.js +57 -0
  29. package/esm/Component.d.ts +0 -29
  30. package/esm/Component.js +6 -30
  31. package/esm/components/item/Component.d.ts +0 -0
  32. package/esm/components/item/Component.js +6 -0
  33. package/esm/components/item/index.css +49 -0
  34. package/esm/components/item/index.d.ts +1 -0
  35. package/esm/components/item/index.js +6 -0
  36. package/esm/index.css +12 -25
  37. package/esm/index.d.ts +1 -1
  38. package/esm/index.js +3 -1
  39. package/esm/utils.d.ts +5 -0
  40. package/esm/utils.js +10 -0
  41. package/index.css +12 -25
  42. package/index.d.ts +1 -1
  43. package/index.js +5 -2
  44. package/modern/Component-0887e7cb.d.ts +72 -0
  45. package/modern/Component-368bf140.d.ts +15 -0
  46. package/modern/Component-368bf140.js +52 -0
  47. package/modern/Component.d.ts +0 -29
  48. package/modern/Component.js +5 -27
  49. package/modern/components/item/Component.d.ts +0 -0
  50. package/modern/components/item/Component.js +5 -0
  51. package/modern/components/item/index.css +49 -0
  52. package/modern/components/item/index.d.ts +1 -0
  53. package/modern/components/item/index.js +5 -0
  54. package/modern/index.css +12 -25
  55. package/modern/index.d.ts +1 -1
  56. package/modern/index.js +3 -1
  57. package/modern/utils.d.ts +5 -0
  58. package/modern/utils.js +6 -0
  59. package/package.json +2 -1
  60. package/utils.d.ts +5 -0
  61. package/utils.js +13 -0
@@ -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_opye0","reversed":"list__reversed_opye0","unorderedItem":"list__unorderedItem_opye0","slot":"list__slot_opye0","defaultColor":"list__defaultColor_opye0","disc":"list__disc_opye0","caption":"list__caption_opye0"};
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_1ngae","lowerAlpha":"list__lowerAlpha_1ngae","decimal":"list__decimal_1ngae","reversed":"list__reversed_1ngae"};
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 };
@@ -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 };
@@ -1,27 +1,5 @@
1
- import React, { Children } from 'react';
2
- import cn from 'classnames';
3
-
4
- const styles = {"list":"list__list_h12ja","orderedList":"list__orderedList_h12ja","lowerAlpha":"list__lowerAlpha_h12ja","decimal":"list__decimal_h12ja","item":"list__item_h12ja","unorderedItem":"list__unorderedItem_h12ja","orderedItem":"list__orderedItem_h12ja","slot":"list__slot_h12ja"};
5
- require('./index.css')
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-368bf140.js';
4
+ import './utils.js';
5
+ import '@alfalab/core-components-typography/modern';
File without changes
@@ -0,0 +1,5 @@
1
+ import 'react';
2
+ import 'classnames';
3
+ import '@alfalab/core-components-typography/modern';
4
+ export { I as Item } from '../../Component-368bf140.js';
5
+ import '../../utils.js';
@@ -0,0 +1,49 @@
1
+ /* hash: vfky2 */
2
+ :root {
3
+ } /* deprecated */ :root {
4
+ --color-light-text-primary: #0b1f35; /* 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_opye0 {
25
+ margin-top: var(--list-item-margin);
26
+ display: flex
27
+ } .list__item_opye0:first-child {
28
+ margin-top: 0;
29
+ } .list__item_opye0.list__reversed_opye0:first-child {
30
+ margin-top: var(--list-item-margin);
31
+ } .list__item_opye0.list__reversed_opye0:last-child {
32
+ margin-top: 0;
33
+ } .list__item_opye0.list__unorderedItem_opye0 {
34
+ display: list-item;
35
+ } .list__slot_opye0 {
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_opye0.list__defaultColor_opye0 {
43
+ color: var(--list-marker-color);
44
+ } .list__slot_opye0.list__disc_opye0 {
45
+ justify-content: center;
46
+ padding: 0 var(--gap-2xs);
47
+ } .list__caption_opye0 {
48
+ margin-top: var(--gap-3xs);
49
+ }
@@ -0,0 +1 @@
1
+ export * from "../../Component-368bf140";
@@ -0,0 +1,5 @@
1
+ export { I as Item } from '../../Component-368bf140.js';
2
+ import 'react';
3
+ import 'classnames';
4
+ import '@alfalab/core-components-typography/modern';
5
+ import '../../utils.js';
package/modern/index.css CHANGED
@@ -1,8 +1,8 @@
1
- /* hash: 5j49g */
1
+ /* hash: 19no9 */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
- --color-light-text-primary: #0b1f35;
5
- } :root {
4
+ --color-light-text-primary: #0b1f35; /* 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
- } :root {
23
- --list-marker-color: var(--color-light-text-primary);
24
- --list-item-margin: var(--gap-s);
25
- } .list__list_h12ja {
19
+ } .list__list_1ngae {
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
- } .list__orderedList_h12ja {
36
- padding-left: var(--gap-l);
37
- } .list__lowerAlpha_h12ja {
29
+ } .list__lowerAlpha_1ngae {
38
30
  list-style-type: lower-alpha;
39
- } .list__decimal_h12ja {
31
+ padding-left: var(--gap-l);
32
+ } .list__decimal_1ngae {
40
33
  list-style-type: decimal;
41
- } .list__item_h12ja {
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_1ngae {
46
35
  display: flex;
47
- } .list__orderedItem_h12ja {
48
- padding-left: var(--gap-2xs);
49
- } .list__slot_h12ja {
50
- margin-right: var(--gap-xs);
51
- color: var(--list-marker-color);
52
- }
36
+ flex-direction: column
37
+ } ol.list__list_1ngae.list__reversed_1ngae {
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-368bf140.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';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { ReactNode } from 'react';
3
+ declare const isItemElement: (obj: JSX.Element, name?: string) => boolean;
4
+ declare const isItem: (child: ReactNode) => boolean;
5
+ export { isItemElement, isItem };
@@ -0,0 +1,6 @@
1
+ import { isValidElement } from 'react';
2
+
3
+ const isItemElement = (obj, name) => typeof obj === 'object' && obj.type.displayName === name;
4
+ const isItem = (child) => isValidElement(child) && isItemElement(child, 'ListItem');
5
+
6
+ export { isItem, isItemElement };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-list",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
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.1.1",
20
21
  "classnames": "^2.3.1",
21
22
  "tslib": "^2.4.0"
22
23
  }
package/utils.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { ReactNode } from 'react';
3
+ declare const isItemElement: (obj: JSX.Element, name?: string) => boolean;
4
+ declare const isItem: (child: ReactNode) => boolean;
5
+ export { isItemElement, isItem };
package/utils.js ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ var isItemElement = function (obj, name) {
6
+ return typeof obj === 'object' && obj.type.displayName === name;
7
+ };
8
+ var isItem = function (child) {
9
+ return React.isValidElement(child) && isItemElement(child, 'ListItem');
10
+ };
11
+
12
+ exports.isItem = isItem;
13
+ exports.isItemElement = isItemElement;