@alfalab/core-components-list 4.0.1-snapshot-c2c8d5a → 4.0.2

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 (110) hide show
  1. package/Component.d.ts +4 -31
  2. package/Component.js +3 -3
  3. package/Component.js.map +1 -1
  4. package/components/item/Component.d.ts +1 -1
  5. package/components/item/Component.js +2 -2
  6. package/components/item/Component.js.map +1 -1
  7. package/components/item/index.css +11 -11
  8. package/components/item/index.module.css.js +1 -1
  9. package/components/item/index.module.css.js.map +1 -1
  10. package/context.d.ts +30 -0
  11. package/context.js +10 -0
  12. package/context.js.map +1 -0
  13. package/cssm/Component.d.ts +4 -31
  14. package/cssm/Component.js +3 -3
  15. package/cssm/Component.js.map +1 -1
  16. package/cssm/components/item/Component.d.ts +1 -1
  17. package/cssm/components/item/Component.js +2 -2
  18. package/cssm/components/item/Component.js.map +1 -1
  19. package/cssm/components/item/index.module.css +2 -2
  20. package/cssm/context.d.ts +30 -0
  21. package/cssm/context.js +10 -0
  22. package/cssm/context.js.map +1 -0
  23. package/cssm/index.js +2 -1
  24. package/cssm/index.js.map +1 -1
  25. package/cssm/index.module.css +1 -1
  26. package/cssm/types.d.ts +1 -0
  27. package/cssm/types.js +3 -0
  28. package/cssm/types.js.map +1 -0
  29. package/cssm/utils.d.ts +1 -1
  30. package/cssm/utils.js.map +1 -1
  31. package/esm/Component.d.ts +4 -31
  32. package/esm/Component.js +1 -1
  33. package/esm/Component.js.map +1 -1
  34. package/esm/components/item/Component.d.ts +1 -1
  35. package/esm/components/item/Component.js +1 -1
  36. package/esm/components/item/Component.js.map +1 -1
  37. package/esm/components/item/index.css +11 -11
  38. package/esm/components/item/index.module.css.js +1 -1
  39. package/esm/components/item/index.module.css.js.map +1 -1
  40. package/esm/context.d.ts +30 -0
  41. package/esm/context.js +6 -0
  42. package/esm/context.js.map +1 -0
  43. package/esm/index.css +6 -6
  44. package/esm/index.js +2 -1
  45. package/esm/index.js.map +1 -1
  46. package/esm/index.module.css.js +1 -1
  47. package/esm/index.module.css.js.map +1 -1
  48. package/esm/types.d.ts +1 -0
  49. package/esm/types.js +2 -0
  50. package/esm/types.js.map +1 -0
  51. package/esm/utils.d.ts +1 -1
  52. package/esm/utils.js.map +1 -1
  53. package/index.css +6 -6
  54. package/index.js +2 -1
  55. package/index.js.map +1 -1
  56. package/index.module.css.js +1 -1
  57. package/index.module.css.js.map +1 -1
  58. package/modern/Component.d.ts +4 -31
  59. package/modern/Component.js +1 -1
  60. package/modern/Component.js.map +1 -1
  61. package/modern/components/item/Component.d.ts +1 -1
  62. package/modern/components/item/Component.js +1 -1
  63. package/modern/components/item/Component.js.map +1 -1
  64. package/modern/components/item/index.css +11 -11
  65. package/modern/components/item/index.module.css.js +1 -1
  66. package/modern/components/item/index.module.css.js.map +1 -1
  67. package/modern/context.d.ts +30 -0
  68. package/modern/context.js +6 -0
  69. package/modern/context.js.map +1 -0
  70. package/modern/index.css +6 -6
  71. package/modern/index.js +2 -1
  72. package/modern/index.js.map +1 -1
  73. package/modern/index.module.css.js +1 -1
  74. package/modern/index.module.css.js.map +1 -1
  75. package/modern/types.d.ts +1 -0
  76. package/modern/types.js +2 -0
  77. package/modern/types.js.map +1 -0
  78. package/modern/utils.d.ts +1 -1
  79. package/modern/utils.js.map +1 -1
  80. package/moderncssm/Component.d.ts +4 -31
  81. package/moderncssm/Component.js +1 -1
  82. package/moderncssm/Component.js.map +1 -1
  83. package/moderncssm/components/item/Component.d.ts +1 -1
  84. package/moderncssm/components/item/Component.js +1 -1
  85. package/moderncssm/components/item/Component.js.map +1 -1
  86. package/moderncssm/components/item/index.module.css +4 -2
  87. package/moderncssm/context.d.ts +30 -0
  88. package/moderncssm/context.js +6 -0
  89. package/moderncssm/context.js.map +1 -0
  90. package/moderncssm/index.js +2 -1
  91. package/moderncssm/index.js.map +1 -1
  92. package/moderncssm/index.module.css +3 -1
  93. package/moderncssm/types.d.ts +1 -0
  94. package/moderncssm/types.js +2 -0
  95. package/moderncssm/types.js.map +1 -0
  96. package/moderncssm/utils.d.ts +1 -1
  97. package/moderncssm/utils.js.map +1 -1
  98. package/package.json +4 -4
  99. package/src/Component.tsx +4 -48
  100. package/src/components/item/Component.tsx +2 -2
  101. package/src/components/item/index.module.css +1 -1
  102. package/src/context.ts +38 -0
  103. package/src/index.module.css +1 -1
  104. package/src/types.ts +12 -0
  105. package/src/utils.ts +1 -1
  106. package/types.d.ts +1 -0
  107. package/types.js +3 -0
  108. package/types.js.map +1 -0
  109. package/utils.d.ts +1 -1
  110. package/utils.js.map +1 -1
@@ -0,0 +1 @@
1
+ export declare type ColorMarkerType = 'tertiary' | 'accent' | 'primary' | 'attention' | 'positive' | 'secondary' | 'tertiary-inverted' | 'primary-inverted' | 'secondary-inverted' | 'link' | 'negative';
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/modern/utils.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  export declare const isItemElement: (obj: JSX.Element, name?: string) => boolean;
3
3
  export declare const isItem: (child: ReactNode) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { isValidElement, ReactNode } from 'react';\n\nexport const isItemElement = (obj: JSX.Element, name?: string): boolean =>\n typeof obj === 'object' && obj.type.displayName === name;\n\nexport const isItem = (child: ReactNode) =>\n isValidElement(child) && isItemElement(child, 'ListItem');\n"],"names":[],"mappings":";;MAEa,aAAa,GAAG,CAAC,GAAgB,EAAE,IAAa,KACzD,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK;MAE3C,MAAM,GAAG,CAAC,KAAgB,KACnC,cAAc,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { isValidElement, type ReactNode } from 'react';\n\nexport const isItemElement = (obj: JSX.Element, name?: string): boolean =>\n typeof obj === 'object' && obj.type.displayName === name;\n\nexport const isItem = (child: ReactNode) =>\n isValidElement(child) && isItemElement(child, 'ListItem');\n"],"names":[],"mappings":";;MAEa,aAAa,GAAG,CAAC,GAAgB,EAAE,IAAa,KACzD,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK;MAE3C,MAAM,GAAG,CAAC,KAAgB,KACnC,cAAc,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU;;;;"}
@@ -1,33 +1,7 @@
1
- import React, { ReactNode } from 'react';
2
- export declare type TListContext = {
3
- /**
4
- * Упорядоченный список
5
- */
6
- orderedList?: boolean;
7
- /**
8
- * Маркер
9
- * @default '–' for ul and 'decimal' for ol
10
- */
11
- markerType?: 'lower-alpha' | 'decimal' | string | ReactNode;
12
- /**
13
- * Цвет маркера
14
- */
15
- colorMarker?: ColorMarkerType;
16
- /**
17
- * Список обратного счета
18
- */
19
- reversed?: boolean;
20
- /**
21
- * Номер пункта
22
- */
23
- index?: number;
24
- /**
25
- * Начало отсчета элементов списка
26
- */
27
- start?: number;
28
- };
29
- export declare const ListContext: React.Context<TListContext>;
30
- declare type ColorMarkerType = 'tertiary' | 'accent' | 'primary' | 'attention' | 'positive' | 'secondary' | 'tertiary-inverted' | 'primary-inverted' | 'secondary-inverted' | 'link' | 'negative';
1
+ import React, { type ReactNode } from 'react';
2
+ import { ListContext, type TListContext } from './context';
3
+ import { type ColorMarkerType } from './types';
4
+ export { ListContext, type TListContext };
31
5
  export declare type ListProps = {
32
6
  /**
33
7
  * HTML тег
@@ -67,4 +41,3 @@ export declare type ListProps = {
67
41
  export declare const List: React.FC<ListProps> & {
68
42
  Item: React.FC<import("./components/item").ItemProps>;
69
43
  };
70
- export {};
@@ -1,10 +1,10 @@
1
1
  import React, { Children } from 'react';
2
2
  import cn from 'classnames';
3
3
  import { Item } from './components/item/Component.js';
4
+ import { ListContext } from './context.js';
4
5
  import { isItem } from './utils.js';
5
6
  import styles from './index.module.css';
6
7
 
7
- const ListContext = React.createContext({});
8
8
  const ListComponent = ({ tag = 'ul', marker, className, dataTestId, colorMarker, children, reversed, start, ...restProps }) => {
9
9
  const markerType = marker || (tag === 'ul' ? '–' : 'decimal');
10
10
  const alphaMarker = markerType === 'lower-alpha';
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, { Children, ReactNode } from 'react';\nimport cn from 'classnames';\n\nimport { Item } from './components/item';\nimport { isItem } from './utils';\n\nimport styles from './index.module.css';\n\nexport type TListContext = {\n /**\n * Упорядоченный список\n */\n orderedList?: boolean;\n\n /**\n * Маркер\n * @default '–' for ul and 'decimal' for ol\n */\n markerType?: 'lower-alpha' | 'decimal' | string | ReactNode;\n\n /**\n * Цвет маркера\n */\n colorMarker?: ColorMarkerType;\n\n /**\n * Список обратного счета\n */\n reversed?: boolean;\n\n /**\n * Номер пункта\n */\n index?: number;\n\n /**\n * Начало отсчета элементов списка\n */\n start?: number;\n};\n\nexport const ListContext = React.createContext<TListContext>({});\n\ntype ColorMarkerType =\n | 'tertiary'\n | 'accent'\n | 'primary'\n | 'attention'\n | 'positive'\n | 'secondary'\n | 'tertiary-inverted'\n | 'primary-inverted'\n | 'secondary-inverted'\n | 'link'\n | 'negative';\n\nexport type ListProps = {\n /**\n * HTML тег\n * @default 'ul'\n */\n tag?: 'ul' | 'ol';\n\n /**\n * Маркер\n * @default '–' for ul and 'decimal' for ol\n */\n marker?: 'lower-alpha' | 'decimal' | string | ReactNode;\n\n /**\n * Css-класс для стилизации\n */\n className?: string;\n\n /**\n * Цвет маркера\n */\n colorMarker?: ColorMarkerType;\n\n /**\n * Список обратного счета\n */\n reversed?: boolean;\n\n /**\n * Начало отсчета элементов списка\n */\n start?: number;\n\n /**\n * Id компонента для тестов\n */\n dataTestId?: string;\n\n /**\n * Дочерние элементы\n */\n children?: ReactNode;\n} & Omit<React.OlHTMLAttributes<HTMLOListElement>, 'type'>;\n\nconst ListComponent: React.FC<ListProps> = ({\n tag = 'ul',\n marker,\n className,\n dataTestId,\n colorMarker,\n children,\n reversed,\n start,\n ...restProps\n}) => {\n const markerType = marker || (tag === 'ul' ? '–' : 'decimal');\n const alphaMarker = markerType === 'lower-alpha';\n const decimalMarker = markerType === 'decimal';\n const Component = tag === 'ul' || alphaMarker ? 'ul' : 'ol';\n\n const orderedList = Component === 'ol';\n\n const listClassNames = cn(\n styles.list,\n {\n [styles.lowerAlpha]: alphaMarker,\n [styles.decimal]: decimalMarker,\n [styles.reversed]: reversed,\n },\n className,\n );\n\n /* eslint-disable react/jsx-no-constructed-context-values */\n return (\n <Component className={listClassNames} data-test-id={dataTestId} {...restProps}>\n {Children.map(children, (child, index) => (\n <ListContext.Provider\n value={{ orderedList, markerType, colorMarker, reversed, index, start }}\n >\n {isItem(child) ? child : <Item>{child}</Item>}\n </ListContext.Provider>\n ))}\n </Component>\n );\n};\n\nexport const List = Object.assign(ListComponent, {\n Item,\n});\n"],"names":[],"mappings":";;;;;;AAyCa,MAAA,WAAW,GAAG,KAAK,CAAC,aAAa,CAAe,EAAE;AA2D/D,MAAM,aAAa,GAAwB,CAAC,EACxC,GAAG,GAAG,IAAI,EACV,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,GAAG,SAAS,EACf,KAAI;AACD,IAAA,MAAM,UAAU,GAAG,MAAM,KAAK,GAAG,KAAK,IAAI,GAAG,GAAG,GAAG,SAAS,CAAC;AAC7D,IAAA,MAAM,WAAW,GAAG,UAAU,KAAK,aAAa;AAChD,IAAA,MAAM,aAAa,GAAG,UAAU,KAAK,SAAS;AAC9C,IAAA,MAAM,SAAS,GAAG,GAAG,KAAK,IAAI,IAAI,WAAW,GAAG,IAAI,GAAG,IAAI;AAE3D,IAAA,MAAM,WAAW,GAAG,SAAS,KAAK,IAAI;AAEtC,IAAA,MAAM,cAAc,GAAG,EAAE,CACrB,MAAM,CAAC,IAAI,EACX;AACI,QAAA,CAAC,MAAM,CAAC,UAAU,GAAG,WAAW;AAChC,QAAA,CAAC,MAAM,CAAC,OAAO,GAAG,aAAa;AAC/B,QAAA,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ;KAC9B,EACD,SAAS,CACZ;;AAGD,IAAA,QACI,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAE,cAAc,EAAgB,cAAA,EAAA,UAAU,EAAM,GAAA,SAAS,EACxE,EAAA,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,MACjC,KAAA,CAAA,aAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EACjB,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAA,EAEtE,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,oBAAC,IAAI,EAAA,IAAA,EAAE,KAAK,CAAQ,CAC1B,CAC1B,CAAC,CACM;AAEpB,CAAC;MAEY,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE;IAC7C,IAAI;AACP,CAAA;;;;"}
1
+ {"version":3,"file":"Component.js","sources":["../src/Component.tsx"],"sourcesContent":["import React, { Children, type ReactNode } from 'react';\nimport cn from 'classnames';\n\nimport { Item } from './components/item';\nimport { ListContext, type TListContext } from './context';\nimport { type ColorMarkerType } from './types';\nimport { isItem } from './utils';\n\nimport styles from './index.module.css';\n\nexport { ListContext, type TListContext };\n\nexport type ListProps = {\n /**\n * HTML тег\n * @default 'ul'\n */\n tag?: 'ul' | 'ol';\n\n /**\n * Маркер\n * @default '–' for ul and 'decimal' for ol\n */\n marker?: 'lower-alpha' | 'decimal' | string | ReactNode;\n\n /**\n * Css-класс для стилизации\n */\n className?: string;\n\n /**\n * Цвет маркера\n */\n colorMarker?: ColorMarkerType;\n\n /**\n * Список обратного счета\n */\n reversed?: boolean;\n\n /**\n * Начало отсчета элементов списка\n */\n start?: number;\n\n /**\n * Id компонента для тестов\n */\n dataTestId?: string;\n\n /**\n * Дочерние элементы\n */\n children?: ReactNode;\n} & Omit<React.OlHTMLAttributes<HTMLOListElement>, 'type'>;\n\nconst ListComponent: React.FC<ListProps> = ({\n tag = 'ul',\n marker,\n className,\n dataTestId,\n colorMarker,\n children,\n reversed,\n start,\n ...restProps\n}) => {\n const markerType = marker || (tag === 'ul' ? '–' : 'decimal');\n const alphaMarker = markerType === 'lower-alpha';\n const decimalMarker = markerType === 'decimal';\n const Component = tag === 'ul' || alphaMarker ? 'ul' : 'ol';\n\n const orderedList = Component === 'ol';\n\n const listClassNames = cn(\n styles.list,\n {\n [styles.lowerAlpha]: alphaMarker,\n [styles.decimal]: decimalMarker,\n [styles.reversed]: reversed,\n },\n className,\n );\n\n /* eslint-disable react/jsx-no-constructed-context-values */\n return (\n <Component className={listClassNames} data-test-id={dataTestId} {...restProps}>\n {Children.map(children, (child, index) => (\n <ListContext.Provider\n value={{ orderedList, markerType, colorMarker, reversed, index, start }}\n >\n {isItem(child) ? child : <Item>{child}</Item>}\n </ListContext.Provider>\n ))}\n </Component>\n );\n};\n\nexport const List = Object.assign(ListComponent, {\n Item,\n});\n"],"names":[],"mappings":";;;;;;;AAwDA,MAAM,aAAa,GAAwB,CAAC,EACxC,GAAG,GAAG,IAAI,EACV,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,GAAG,SAAS,EACf,KAAI;AACD,IAAA,MAAM,UAAU,GAAG,MAAM,KAAK,GAAG,KAAK,IAAI,GAAG,GAAG,GAAG,SAAS,CAAC;AAC7D,IAAA,MAAM,WAAW,GAAG,UAAU,KAAK,aAAa;AAChD,IAAA,MAAM,aAAa,GAAG,UAAU,KAAK,SAAS;AAC9C,IAAA,MAAM,SAAS,GAAG,GAAG,KAAK,IAAI,IAAI,WAAW,GAAG,IAAI,GAAG,IAAI;AAE3D,IAAA,MAAM,WAAW,GAAG,SAAS,KAAK,IAAI;AAEtC,IAAA,MAAM,cAAc,GAAG,EAAE,CACrB,MAAM,CAAC,IAAI,EACX;AACI,QAAA,CAAC,MAAM,CAAC,UAAU,GAAG,WAAW;AAChC,QAAA,CAAC,MAAM,CAAC,OAAO,GAAG,aAAa;AAC/B,QAAA,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ;KAC9B,EACD,SAAS,CACZ;;AAGD,IAAA,QACI,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAE,cAAc,EAAgB,cAAA,EAAA,UAAU,EAAM,GAAA,SAAS,EACxE,EAAA,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,MACjC,KAAA,CAAA,aAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EACjB,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAA,EAEtE,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,oBAAC,IAAI,EAAA,IAAA,EAAE,KAAK,CAAQ,CAC1B,CAC1B,CAAC,CACM;AAEpB,CAAC;MAEY,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE;IAC7C,IAAI;AACP,CAAA;;;;"}
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { type ReactNode } from 'react';
2
2
  export declare type ItemProps = {
3
3
  /**
4
4
  * Дополнительный текст
@@ -1,7 +1,7 @@
1
1
  import React, { useContext } from 'react';
2
2
  import cn from 'classnames';
3
3
  import { Text } from '@alfalab/core-components-typography/moderncssm';
4
- import { ListContext } from '../../Component.js';
4
+ import { ListContext } from '../../context.js';
5
5
  import styles from './index.module.css';
6
6
 
7
7
  const Item = ({ caption, children, className, markerClassName, dataTestId, }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","sources":["../../../src/components/item/Component.tsx"],"sourcesContent":["import React, { ReactNode, useContext } from 'react';\nimport cn from 'classnames';\n\nimport { Text } from '@alfalab/core-components-typography';\n\nimport { ListContext } from '../../Component';\n\nimport styles from './index.module.css';\n\nexport type ItemProps = {\n /**\n * Дополнительный текст\n */\n caption?: string;\n\n /**\n * Дочерние элементы.\n */\n children?: ReactNode;\n\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для маркера\n */\n markerClassName?: string;\n\n /**\n * Дополнительный класс для маркера\n */\n dataTestId?: string;\n};\n\nexport const Item: React.FC<ItemProps> = ({\n caption,\n children,\n className,\n markerClassName,\n dataTestId,\n}) => {\n const {\n orderedList,\n markerType,\n colorMarker,\n reversed,\n index = 0,\n start = 0,\n } = useContext(ListContext);\n\n const markerLowerAlpha = markerType === 'lower-alpha';\n\n const itemClassNames = cn(styles.item, className, {\n [styles.unorderedItem]: markerLowerAlpha,\n [styles.reversed]: reversed,\n });\n\n const isDisc = markerType === '•';\n\n const count = start === 0 ? index + 1 : start + index;\n const marker = orderedList || markerType === 'decimal' ? `${count}.` : markerType;\n\n return (\n <li className={cn(itemClassNames)} data-test-id={dataTestId}>\n {!markerLowerAlpha && (\n <Text\n tag='div'\n color={colorMarker}\n monospaceNumbers={true}\n view='primary-medium'\n className={cn(styles.slot, markerClassName, {\n [styles.disc]: isDisc && !orderedList,\n [styles.defaultColor]: !colorMarker,\n })}\n >\n {marker}\n </Text>\n )}\n <div>\n <Text tag='div' view='primary-medium'>\n {children}\n </Text>\n {caption && (\n <Text\n tag='div'\n view='primary-small'\n color='secondary'\n className={styles.caption}\n >\n {caption}\n </Text>\n )}\n </div>\n </li>\n );\n};\n\nItem.displayName = 'ListItem';\n"],"names":[],"mappings":";;;;;;AAoCa,MAAA,IAAI,GAAwB,CAAC,EACtC,OAAO,EACP,QAAQ,EACR,SAAS,EACT,eAAe,EACf,UAAU,GACb,KAAI;IACD,MAAM,EACF,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,GAAG,CAAC,EACT,KAAK,GAAG,CAAC,GACZ,GAAG,UAAU,CAAC,WAAW,CAAC;AAE3B,IAAA,MAAM,gBAAgB,GAAG,UAAU,KAAK,aAAa;IAErD,MAAM,cAAc,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE;AAC9C,QAAA,CAAC,MAAM,CAAC,aAAa,GAAG,gBAAgB;AACxC,QAAA,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ;AAC9B,KAAA,CAAC;AAEF,IAAA,MAAM,MAAM,GAAG,UAAU,KAAK,GAAG;AAEjC,IAAA,MAAM,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,KAAK;AACrD,IAAA,MAAM,MAAM,GAAG,WAAW,IAAI,UAAU,KAAK,SAAS,GAAG,GAAG,KAAK,CAAA,CAAA,CAAG,GAAG,UAAU;IAEjF,QACI,4BAAI,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,EAAA,cAAA,EAAgB,UAAU,EAAA;AACtD,QAAA,CAAC,gBAAgB,KACd,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EACD,GAAG,EAAC,KAAK,EACT,KAAK,EAAE,WAAW,EAClB,gBAAgB,EAAE,IAAI,EACtB,IAAI,EAAC,gBAAgB,EACrB,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE;gBACxC,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW;AACrC,gBAAA,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,WAAW;aACtC,CAAC,EAAA,EAED,MAAM,CACJ,CACV;AACD,QAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA;YACI,KAAC,CAAA,aAAA,CAAA,IAAI,EAAC,EAAA,GAAG,EAAC,KAAK,EAAC,IAAI,EAAC,gBAAgB,EAChC,EAAA,QAAQ,CACN;AACN,YAAA,OAAO,KACJ,KAAC,CAAA,aAAA,CAAA,IAAI,EACD,EAAA,GAAG,EAAC,KAAK,EACT,IAAI,EAAC,eAAe,EACpB,KAAK,EAAC,WAAW,EACjB,SAAS,EAAE,MAAM,CAAC,OAAO,EAExB,EAAA,OAAO,CACL,CACV,CACC,CACL;AAEb;AAEA,IAAI,CAAC,WAAW,GAAG,UAAU;;;;"}
1
+ {"version":3,"file":"Component.js","sources":["../../../src/components/item/Component.tsx"],"sourcesContent":["import React, { type ReactNode, useContext } from 'react';\nimport cn from 'classnames';\n\nimport { Text } from '@alfalab/core-components-typography';\n\nimport { ListContext } from '../../context';\n\nimport styles from './index.module.css';\n\nexport type ItemProps = {\n /**\n * Дополнительный текст\n */\n caption?: string;\n\n /**\n * Дочерние элементы.\n */\n children?: ReactNode;\n\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для маркера\n */\n markerClassName?: string;\n\n /**\n * Дополнительный класс для маркера\n */\n dataTestId?: string;\n};\n\nexport const Item: React.FC<ItemProps> = ({\n caption,\n children,\n className,\n markerClassName,\n dataTestId,\n}) => {\n const {\n orderedList,\n markerType,\n colorMarker,\n reversed,\n index = 0,\n start = 0,\n } = useContext(ListContext);\n\n const markerLowerAlpha = markerType === 'lower-alpha';\n\n const itemClassNames = cn(styles.item, className, {\n [styles.unorderedItem]: markerLowerAlpha,\n [styles.reversed]: reversed,\n });\n\n const isDisc = markerType === '•';\n\n const count = start === 0 ? index + 1 : start + index;\n const marker = orderedList || markerType === 'decimal' ? `${count}.` : markerType;\n\n return (\n <li className={cn(itemClassNames)} data-test-id={dataTestId}>\n {!markerLowerAlpha && (\n <Text\n tag='div'\n color={colorMarker}\n monospaceNumbers={true}\n view='primary-medium'\n className={cn(styles.slot, markerClassName, {\n [styles.disc]: isDisc && !orderedList,\n [styles.defaultColor]: !colorMarker,\n })}\n >\n {marker}\n </Text>\n )}\n <div>\n <Text tag='div' view='primary-medium'>\n {children}\n </Text>\n {caption && (\n <Text\n tag='div'\n view='primary-small'\n color='secondary'\n className={styles.caption}\n >\n {caption}\n </Text>\n )}\n </div>\n </li>\n );\n};\n\nItem.displayName = 'ListItem';\n"],"names":[],"mappings":";;;;;;AAoCa,MAAA,IAAI,GAAwB,CAAC,EACtC,OAAO,EACP,QAAQ,EACR,SAAS,EACT,eAAe,EACf,UAAU,GACb,KAAI;IACD,MAAM,EACF,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAK,GAAG,CAAC,EACT,KAAK,GAAG,CAAC,GACZ,GAAG,UAAU,CAAC,WAAW,CAAC;AAE3B,IAAA,MAAM,gBAAgB,GAAG,UAAU,KAAK,aAAa;IAErD,MAAM,cAAc,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE;AAC9C,QAAA,CAAC,MAAM,CAAC,aAAa,GAAG,gBAAgB;AACxC,QAAA,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ;AAC9B,KAAA,CAAC;AAEF,IAAA,MAAM,MAAM,GAAG,UAAU,KAAK,GAAG;AAEjC,IAAA,MAAM,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,KAAK;AACrD,IAAA,MAAM,MAAM,GAAG,WAAW,IAAI,UAAU,KAAK,SAAS,GAAG,GAAG,KAAK,CAAA,CAAA,CAAG,GAAG,UAAU;IAEjF,QACI,4BAAI,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,EAAA,cAAA,EAAgB,UAAU,EAAA;AACtD,QAAA,CAAC,gBAAgB,KACd,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EACD,GAAG,EAAC,KAAK,EACT,KAAK,EAAE,WAAW,EAClB,gBAAgB,EAAE,IAAI,EACtB,IAAI,EAAC,gBAAgB,EACrB,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE;gBACxC,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW;AACrC,gBAAA,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,WAAW;aACtC,CAAC,EAAA,EAED,MAAM,CACJ,CACV;AACD,QAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA;YACI,KAAC,CAAA,aAAA,CAAA,IAAI,EAAC,EAAA,GAAG,EAAC,KAAK,EAAC,IAAI,EAAC,gBAAgB,EAChC,EAAA,QAAQ,CACN;AACN,YAAA,OAAO,KACJ,KAAC,CAAA,aAAA,CAAA,IAAI,EACD,EAAA,GAAG,EAAC,KAAK,EACT,IAAI,EAAC,eAAe,EACpB,KAAK,EAAC,WAAW,EACjB,SAAS,EAAE,MAAM,CAAC,OAAO,EAExB,EAAA,OAAO,CACL,CACV,CACC,CACL;AAEb;AAEA,IAAI,CAAC,WAAW,GAAG,UAAU;;;;"}
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  :root {
2
4
  --list-marker-color: var(--color-light-text-primary);
3
5
  --list-item-margin: var(--gap-12);
@@ -5,7 +7,7 @@
5
7
 
6
8
  .item {
7
9
  margin-top: var(--list-item-margin);
8
- display: flex
10
+ display: flex;
9
11
  }
10
12
 
11
13
  .item:first-child {
@@ -30,7 +32,7 @@
30
32
  box-sizing: border-box;
31
33
  justify-content: flex-start;
32
34
  padding-right: var(--gap-4);
33
- flex-shrink: 0
35
+ flex-shrink: 0;
34
36
  }
35
37
 
36
38
  .slot.defaultColor {
@@ -0,0 +1,30 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type ColorMarkerType } from './types';
3
+ export declare type TListContext = {
4
+ /**
5
+ * Упорядоченный список
6
+ */
7
+ orderedList?: boolean;
8
+ /**
9
+ * Маркер
10
+ * @default '–' for ul and 'decimal' for ol
11
+ */
12
+ markerType?: 'lower-alpha' | 'decimal' | string | ReactNode;
13
+ /**
14
+ * Цвет маркера
15
+ */
16
+ colorMarker?: ColorMarkerType;
17
+ /**
18
+ * Список обратного счета
19
+ */
20
+ reversed?: boolean;
21
+ /**
22
+ * Номер пункта
23
+ */
24
+ index?: number;
25
+ /**
26
+ * Начало отсчета элементов списка
27
+ */
28
+ start?: number;
29
+ };
30
+ export declare const ListContext: import("react").Context<TListContext>;
@@ -0,0 +1,6 @@
1
+ import { createContext } from 'react';
2
+
3
+ const ListContext = createContext({});
4
+
5
+ export { ListContext };
6
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../src/context.ts"],"sourcesContent":["import { createContext, type ReactNode } from 'react';\n\nimport { type ColorMarkerType } from './types';\n\nexport type TListContext = {\n /**\n * Упорядоченный список\n */\n orderedList?: boolean;\n\n /**\n * Маркер\n * @default '–' for ul and 'decimal' for ol\n */\n markerType?: 'lower-alpha' | 'decimal' | string | ReactNode;\n\n /**\n * Цвет маркера\n */\n colorMarker?: ColorMarkerType;\n\n /**\n * Список обратного счета\n */\n reversed?: boolean;\n\n /**\n * Номер пункта\n */\n index?: number;\n\n /**\n * Начало отсчета элементов списка\n */\n start?: number;\n};\n\nexport const ListContext = createContext<TListContext>({});\n"],"names":[],"mappings":";;MAqCa,WAAW,GAAG,aAAa,CAAe,EAAE;;;;"}
@@ -1,3 +1,4 @@
1
- export { List, ListContext } from './Component.js';
1
+ export { List } from './Component.js';
2
2
  export { listPresets } from './presets.js';
3
+ export { ListContext } from './context.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  .list {
2
4
  margin: var(--gap-0);
3
5
  padding: var(--gap-0);
@@ -21,7 +23,7 @@
21
23
 
22
24
  ol.list {
23
25
  display: flex;
24
- flex-direction: column
26
+ flex-direction: column;
25
27
  }
26
28
 
27
29
  ol.list.reversed {
@@ -0,0 +1 @@
1
+ export declare type ColorMarkerType = 'tertiary' | 'accent' | 'primary' | 'attention' | 'positive' | 'secondary' | 'tertiary-inverted' | 'primary-inverted' | 'secondary-inverted' | 'link' | 'negative';
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,3 +1,3 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  export declare const isItemElement: (obj: JSX.Element, name?: string) => boolean;
3
3
  export declare const isItem: (child: ReactNode) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { isValidElement, ReactNode } from 'react';\n\nexport const isItemElement = (obj: JSX.Element, name?: string): boolean =>\n typeof obj === 'object' && obj.type.displayName === name;\n\nexport const isItem = (child: ReactNode) =>\n isValidElement(child) && isItemElement(child, 'ListItem');\n"],"names":[],"mappings":";;MAEa,aAAa,GAAG,CAAC,GAAgB,EAAE,IAAa,KACzD,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK;MAE3C,MAAM,GAAG,CAAC,KAAgB,KACnC,cAAc,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { isValidElement, type ReactNode } from 'react';\n\nexport const isItemElement = (obj: JSX.Element, name?: string): boolean =>\n typeof obj === 'object' && obj.type.displayName === name;\n\nexport const isItem = (child: ReactNode) =>\n isValidElement(child) && isItemElement(child, 'ListItem');\n"],"names":[],"mappings":";;MAEa,aAAa,GAAG,CAAC,GAAgB,EAAE,IAAa,KACzD,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK;MAE3C,MAAM,GAAG,CAAC,KAAgB,KACnC,cAAc,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-list",
3
- "version": "4.0.1-snapshot-c2c8d5a",
3
+ "version": "4.0.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "main": "index.js",
11
11
  "module": "./esm/index.js",
12
12
  "dependencies": {
13
- "@alfalab/core-components-typography": "5.0.1-snapshot-c2c8d5a",
13
+ "@alfalab/core-components-typography": "^5.0.2",
14
14
  "classnames": "^2.5.1",
15
15
  "tslib": "^2.4.0"
16
16
  },
@@ -22,6 +22,6 @@
22
22
  "access": "public",
23
23
  "directory": "dist"
24
24
  },
25
- "themesVersion": "14.0.0",
26
- "varsVersion": "10.0.1-snapshot-c2c8d5a"
25
+ "themesVersion": "14.1.2",
26
+ "varsVersion": "10.1.0"
27
27
  }
package/src/Component.tsx CHANGED
@@ -1,58 +1,14 @@
1
- import React, { Children, ReactNode } from 'react';
1
+ import React, { Children, type ReactNode } from 'react';
2
2
  import cn from 'classnames';
3
3
 
4
4
  import { Item } from './components/item';
5
+ import { ListContext, type TListContext } from './context';
6
+ import { type ColorMarkerType } from './types';
5
7
  import { isItem } from './utils';
6
8
 
7
9
  import styles from './index.module.css';
8
10
 
9
- export type TListContext = {
10
- /**
11
- * Упорядоченный список
12
- */
13
- orderedList?: boolean;
14
-
15
- /**
16
- * Маркер
17
- * @default '–' for ul and 'decimal' for ol
18
- */
19
- markerType?: 'lower-alpha' | 'decimal' | string | ReactNode;
20
-
21
- /**
22
- * Цвет маркера
23
- */
24
- colorMarker?: ColorMarkerType;
25
-
26
- /**
27
- * Список обратного счета
28
- */
29
- reversed?: boolean;
30
-
31
- /**
32
- * Номер пункта
33
- */
34
- index?: number;
35
-
36
- /**
37
- * Начало отсчета элементов списка
38
- */
39
- start?: number;
40
- };
41
-
42
- export const ListContext = React.createContext<TListContext>({});
43
-
44
- type ColorMarkerType =
45
- | 'tertiary'
46
- | 'accent'
47
- | 'primary'
48
- | 'attention'
49
- | 'positive'
50
- | 'secondary'
51
- | 'tertiary-inverted'
52
- | 'primary-inverted'
53
- | 'secondary-inverted'
54
- | 'link'
55
- | 'negative';
11
+ export { ListContext, type TListContext };
56
12
 
57
13
  export type ListProps = {
58
14
  /**
@@ -1,9 +1,9 @@
1
- import React, { ReactNode, useContext } from 'react';
1
+ import React, { type ReactNode, useContext } from 'react';
2
2
  import cn from 'classnames';
3
3
 
4
4
  import { Text } from '@alfalab/core-components-typography';
5
5
 
6
- import { ListContext } from '../../Component';
6
+ import { ListContext } from '../../context';
7
7
 
8
8
  import styles from './index.module.css';
9
9
 
@@ -1,4 +1,4 @@
1
- @import '@alfalab/core-components-vars/src/index.css';
1
+ @import '@alfalab/core-components-vars/src/no-typography-index.css';
2
2
 
3
3
  :root {
4
4
  --list-marker-color: var(--color-light-text-primary);
package/src/context.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { createContext, type ReactNode } from 'react';
2
+
3
+ import { type ColorMarkerType } from './types';
4
+
5
+ export type TListContext = {
6
+ /**
7
+ * Упорядоченный список
8
+ */
9
+ orderedList?: boolean;
10
+
11
+ /**
12
+ * Маркер
13
+ * @default '–' for ul and 'decimal' for ol
14
+ */
15
+ markerType?: 'lower-alpha' | 'decimal' | string | ReactNode;
16
+
17
+ /**
18
+ * Цвет маркера
19
+ */
20
+ colorMarker?: ColorMarkerType;
21
+
22
+ /**
23
+ * Список обратного счета
24
+ */
25
+ reversed?: boolean;
26
+
27
+ /**
28
+ * Номер пункта
29
+ */
30
+ index?: number;
31
+
32
+ /**
33
+ * Начало отсчета элементов списка
34
+ */
35
+ start?: number;
36
+ };
37
+
38
+ export const ListContext = createContext<TListContext>({});
@@ -1,4 +1,4 @@
1
- @import '@alfalab/core-components-vars/src/index.css';
1
+ @import '@alfalab/core-components-vars/src/no-typography-index.css';
2
2
 
3
3
  .list {
4
4
  margin: var(--gap-0);
package/src/types.ts ADDED
@@ -0,0 +1,12 @@
1
+ export type ColorMarkerType =
2
+ | 'tertiary'
3
+ | 'accent'
4
+ | 'primary'
5
+ | 'attention'
6
+ | 'positive'
7
+ | 'secondary'
8
+ | 'tertiary-inverted'
9
+ | 'primary-inverted'
10
+ | 'secondary-inverted'
11
+ | 'link'
12
+ | 'negative';
package/src/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { isValidElement, ReactNode } from 'react';
1
+ import { isValidElement, type ReactNode } from 'react';
2
2
 
3
3
  export const isItemElement = (obj: JSX.Element, name?: string): boolean =>
4
4
  typeof obj === 'object' && obj.type.displayName === name;
package/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare type ColorMarkerType = 'tertiary' | 'accent' | 'primary' | 'attention' | 'positive' | 'secondary' | 'tertiary-inverted' | 'primary-inverted' | 'secondary-inverted' | 'link' | 'negative';
package/types.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/utils.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  export declare const isItemElement: (obj: JSX.Element, name?: string) => boolean;
3
3
  export declare const isItem: (child: ReactNode) => boolean;
package/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["src/utils.ts"],"sourcesContent":["import { isValidElement, ReactNode } from 'react';\n\nexport const isItemElement = (obj: JSX.Element, name?: string): boolean =>\n typeof obj === 'object' && obj.type.displayName === name;\n\nexport const isItem = (child: ReactNode) =>\n isValidElement(child) && isItemElement(child, 'ListItem');\n"],"names":["isValidElement"],"mappings":";;;;;;AAEa,IAAA,aAAa,GAAG,UAAC,GAAgB,EAAE,IAAa,EAAA;IACzD,OAAA,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI;AAAxD;AAEG,IAAM,MAAM,GAAG,UAAC,KAAgB,EAAA;IACnC,OAAAA,oBAAc,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC;AAAzD;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["src/utils.ts"],"sourcesContent":["import { isValidElement, type ReactNode } from 'react';\n\nexport const isItemElement = (obj: JSX.Element, name?: string): boolean =>\n typeof obj === 'object' && obj.type.displayName === name;\n\nexport const isItem = (child: ReactNode) =>\n isValidElement(child) && isItemElement(child, 'ListItem');\n"],"names":["isValidElement"],"mappings":";;;;;;AAEa,IAAA,aAAa,GAAG,UAAC,GAAgB,EAAE,IAAa,EAAA;IACzD,OAAA,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI;AAAxD;AAEG,IAAM,MAAM,GAAG,UAAC,KAAgB,EAAA;IACnC,OAAAA,oBAAc,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC;AAAzD;;;;;"}