@koslibs/components 1.0.0 → 1.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.
- package/CHANGELOG.md +36 -0
- package/README.md +37 -3
- package/dist/components/Button/index_module.css +2 -1
- package/dist/components/Popover/components/popover-surface/index.d.ts +4 -0
- package/dist/components/Popover/components/popover-surface/index.js +106 -0
- package/dist/components/Popover/create-size-modifier.d.ts +8 -0
- package/dist/components/Popover/create-size-modifier.js +26 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/index.js +1 -0
- package/dist/components/Popover/index.module.js +5 -0
- package/dist/components/Popover/index_module.css +15 -0
- package/dist/components/Popover/popover.d.ts +21 -0
- package/dist/components/Popover/popover.js +15 -0
- package/dist/components/Popover/types.d.ts +86 -0
- package/dist/components/Popover/types.js +0 -0
- package/dist/components/Popover/use-popover-position.d.ts +8 -0
- package/dist/components/Popover/use-popover-position.js +78 -0
- package/dist/components/Popover/vars.css +5 -0
- package/dist/components/Typography/colors.module.js +10 -0
- package/dist/components/Typography/colors_module.css +26 -0
- package/dist/components/Typography/index.d.ts +34 -0
- package/dist/components/Typography/index.js +7 -0
- package/dist/components/Typography/index.module.js +18 -0
- package/dist/components/Typography/index_module.css +57 -0
- package/dist/components/Typography/preset.module.js +30 -0
- package/dist/components/Typography/preset_module.css +54 -0
- package/dist/components/Typography/shared.d.ts +63 -0
- package/dist/components/Typography/shared.js +10 -0
- package/dist/components/Typography/text.d.ts +15 -0
- package/dist/components/Typography/text.js +18 -0
- package/dist/components/Typography/title.d.ts +15 -0
- package/dist/components/Typography/title.js +18 -0
- package/dist/components/Typography/vars.css +27 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/static/font/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/static/font/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/static/font/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/static/font/inter-greek-wght-normal.woff2 +0 -0
- package/dist/static/font/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/static/font/inter-latin-wght-normal.woff2 +0 -0
- package/dist/static/font/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/inter/LICENSE.txt +93 -0
- package/dist/styles/fonts.css +63 -0
- package/dist/styles/theme.css +8 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @koslibs/components
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3](https://github.com/koslibs/components/pull/3) [`a618f52`](https://github.com/koslibs/components/commit/a618f526010adc6203a708e73fac3906b555ac78) Thanks [@holypower777](https://github.com/holypower777)! - Перенесён Popover из GullEye с отдельным импортом `@koslibs/components/Popover`,
|
|
8
|
+
стилями, Docs и Playground. Сохранены управляемая видимость, позиционирование,
|
|
9
|
+
ограничение размеров и способы закрытия. Портал и позиционирование адаптированы
|
|
10
|
+
для самостоятельного использования в React 18 и 19.
|
|
11
|
+
|
|
12
|
+
Popover управляет позицией и размерами и рендерит children напрямую. Оформление
|
|
13
|
+
и прокрутка содержимого задаются вызывающим компонентом; colors и contentClassName
|
|
14
|
+
не входят в API. Прежнее оформление Storybook-примеров сохранено в их содержимом.
|
|
15
|
+
Тень задаёт сам Popover через CSS-переменную --popover-shadow.
|
|
16
|
+
Offset по умолчанию равен `[0, 0]`, без смещения и зазора между якорем и содержимым.
|
|
17
|
+
|
|
18
|
+
Документация каждого компонента собрана в его папке docs: stories, страницы Docs
|
|
19
|
+
и стили примеров. Папки документации исключены из JS-сборки и деклараций npm-пакета.
|
|
20
|
+
|
|
21
|
+
## 1.1.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- [#2](https://github.com/koslibs/components/pull/2) [`b09aeff`](https://github.com/koslibs/components/commit/b09aeffe06d9267aad1f689deb91a19412ff8448) Thanks [@holypower777](https://github.com/holypower777)! - Добавлен публичный Typography из GullEye: Text и Title, типы, CSS Modules,
|
|
26
|
+
Docs и Playground. Импорт из `@koslibs/components/Typography` подключает
|
|
27
|
+
только Typography и его стили.
|
|
28
|
+
|
|
29
|
+
Исправлены отступы содержимого вкладок Docs и сдвиг страницы при появлении
|
|
30
|
+
или исчезновении полосы прокрутки.
|
|
31
|
+
|
|
32
|
+
Закреплены правила историй компонентов: запись добавляется только для изменённого
|
|
33
|
+
компонента; общие изменения инфраструктуры и Storybook описываются в истории пакета.
|
|
34
|
+
|
|
35
|
+
Добавлена общая тема с `--font-primary: 'Inter', sans-serif` и локальными
|
|
36
|
+
WOFF2-файлами Inter. Typography и подпись Button подключают её автоматически;
|
|
37
|
+
приложение может переопределить семейство шрифта через CSS.
|
|
38
|
+
|
|
3
39
|
## 1.0.0
|
|
4
40
|
|
|
5
41
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
Демо: <https://koslibs.github.io/components/>
|
|
2
2
|
|
|
3
|
+
## Основной шрифт
|
|
4
|
+
|
|
5
|
+
Библиотека задаёт `--font-primary: 'Inter', sans-serif` в общей теме. Компоненты,
|
|
6
|
+
использующие эту переменную, автоматически подключают тему и локальные WOFF2-файлы
|
|
7
|
+
Inter. Поддерживаются веса 100–900, латиница и кириллица; внешние CDN не используются.
|
|
8
|
+
Браузер загружает нужные языковые поднаборы по `unicode-range`, используется
|
|
9
|
+
`font-display: swap`. Лицензия Inter включена в npm-пакет.
|
|
10
|
+
|
|
11
|
+
Для использования темы в собственных элементах можно подключить её отдельно:
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import '@koslibs/components/theme.css';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Значение по умолчанию находится в CSS-слое `koslibs`, поэтому обычные стили приложения
|
|
18
|
+
переопределяют его независимо от порядка подключения. Например:
|
|
19
|
+
|
|
20
|
+
```css
|
|
21
|
+
:root {
|
|
22
|
+
--font-primary: 'My App Font', sans-serif;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.alternate-font {
|
|
26
|
+
--font-primary: Georgia, serif;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Файлы своего шрифта подключите в приложении. Тема задаёт только переменную и
|
|
31
|
+
`@font-face`; она не изменяет шрифт `body` или элементов, которые её не используют.
|
|
32
|
+
|
|
3
33
|
## Добавление компонента
|
|
4
34
|
|
|
5
35
|
Рекомендуемая структура:
|
|
@@ -9,9 +39,11 @@ src/components/Button/
|
|
|
9
39
|
index.ts
|
|
10
40
|
button.tsx
|
|
11
41
|
button.module.css
|
|
12
|
-
button.stories.tsx
|
|
13
|
-
button.docs.tsx
|
|
14
42
|
CHANGELOG.md
|
|
43
|
+
docs/
|
|
44
|
+
button.stories.tsx
|
|
45
|
+
button.docs.tsx
|
|
46
|
+
examples.module.css
|
|
15
47
|
```
|
|
16
48
|
|
|
17
49
|
1. Перенесите компонент в `src/components/<Name>`; имя папки — PascalCase, например `Button`.
|
|
@@ -29,7 +61,9 @@ src/components/Button/
|
|
|
29
61
|
}
|
|
30
62
|
```
|
|
31
63
|
|
|
32
|
-
4. Добавьте Docs
|
|
64
|
+
4. Добавьте Docs и Playground в папку компонента `docs`, а `CHANGELOG.md` оставьте
|
|
65
|
+
рядом с реализацией, по [примеру документации](https://github.com/koslibs/components/blob/main/docs/component-changelogs.md).
|
|
66
|
+
Папки `src/**/docs` исключены из npm-сборки. Общие блоки Storybook находятся в `src/docs`.
|
|
33
67
|
5. Добавьте тесты поведения. `npm run test:unit` запускает unit-тесты через
|
|
34
68
|
`koslibs-builder lib:test`; `npm test` также проверяет отдельные импорты.
|
|
35
69
|
6. Выполните сборку и проверьте реальные пути JS, деклараций и CSS в `dist`.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@import "../../styles/theme.css";
|
|
1
2
|
@import "./vars.css";
|
|
2
3
|
|
|
3
4
|
.component-vxc0gC {
|
|
@@ -224,7 +225,7 @@
|
|
|
224
225
|
font-size: 14px;
|
|
225
226
|
font-weight: 400;
|
|
226
227
|
line-height: 18px;
|
|
227
|
-
font-family: var(--font-primary
|
|
228
|
+
font-family: var(--font-primary);
|
|
228
229
|
color: var(--button-hint-color);
|
|
229
230
|
display: block;
|
|
230
231
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PopoverProps } from '../../types.js';
|
|
2
|
+
export declare const PopoverSurface: import("react").ForwardRefExoticComponent<Omit<PopoverProps, "open" | "getPortalContainer" | "anchorElement"> & {
|
|
3
|
+
anchorElement: HTMLElement;
|
|
4
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from "react";
|
|
4
|
+
import { createSizeModifier } from "../../create-size-modifier.js";
|
|
5
|
+
import { usePopoverPosition } from "../../use-popover-position.js";
|
|
6
|
+
import index_module from "../../index.module.js";
|
|
7
|
+
const DEFAULT_OFFSET = [
|
|
8
|
+
0,
|
|
9
|
+
0
|
|
10
|
+
];
|
|
11
|
+
const PopoverSurface = /*#__PURE__*/ forwardRef(({ anchorElement, position = 'bottom-start', offset = DEFAULT_OFFSET, useAnchorWidth = false, preventFlip = false, fallbackPlacements, preventOverflow = true, availableHeight = true, viewportPadding = 8, onClose, outsideClick = true, escapeKeyDown = true, className, style, children, dataTestId, ...restProps }, ref)=>{
|
|
12
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
13
|
+
useImperativeHandle(ref, ()=>popperElement, [
|
|
14
|
+
popperElement
|
|
15
|
+
]);
|
|
16
|
+
const padding = Math.max(0, viewportPadding);
|
|
17
|
+
const modifiers = useMemo(()=>[
|
|
18
|
+
{
|
|
19
|
+
name: 'offset',
|
|
20
|
+
options: {
|
|
21
|
+
offset
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'flip',
|
|
26
|
+
enabled: !preventFlip,
|
|
27
|
+
options: {
|
|
28
|
+
fallbackPlacements,
|
|
29
|
+
boundary: [],
|
|
30
|
+
padding
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'preventOverflow',
|
|
35
|
+
enabled: preventOverflow,
|
|
36
|
+
options: {
|
|
37
|
+
boundary: [],
|
|
38
|
+
padding
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
createSizeModifier({
|
|
42
|
+
availableHeight,
|
|
43
|
+
useAnchorWidth,
|
|
44
|
+
viewportPadding: padding
|
|
45
|
+
})
|
|
46
|
+
], [
|
|
47
|
+
offset,
|
|
48
|
+
preventFlip,
|
|
49
|
+
fallbackPlacements,
|
|
50
|
+
preventOverflow,
|
|
51
|
+
availableHeight,
|
|
52
|
+
useAnchorWidth,
|
|
53
|
+
padding
|
|
54
|
+
]);
|
|
55
|
+
const { styles: popperStyles, attributes, update } = usePopoverPosition(anchorElement, popperElement, position, modifiers);
|
|
56
|
+
useEffect(()=>{
|
|
57
|
+
if (update) update();
|
|
58
|
+
}, [
|
|
59
|
+
children,
|
|
60
|
+
style,
|
|
61
|
+
update
|
|
62
|
+
]);
|
|
63
|
+
useEffect(()=>{
|
|
64
|
+
if (!onClose) return;
|
|
65
|
+
const ownerDocument = anchorElement.ownerDocument;
|
|
66
|
+
const handlePointerDown = (event)=>{
|
|
67
|
+
if (event.defaultPrevented) return;
|
|
68
|
+
const path = event.composedPath();
|
|
69
|
+
if (path.includes(anchorElement) || popperElement && path.includes(popperElement)) return;
|
|
70
|
+
onClose();
|
|
71
|
+
};
|
|
72
|
+
const handleKeyDown = (event)=>{
|
|
73
|
+
if ('Escape' !== event.key || event.defaultPrevented) return;
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
event.stopPropagation();
|
|
76
|
+
onClose();
|
|
77
|
+
};
|
|
78
|
+
if (outsideClick) ownerDocument.addEventListener('pointerdown', handlePointerDown);
|
|
79
|
+
if (escapeKeyDown) ownerDocument.addEventListener('keydown', handleKeyDown);
|
|
80
|
+
return ()=>{
|
|
81
|
+
ownerDocument.removeEventListener('pointerdown', handlePointerDown);
|
|
82
|
+
ownerDocument.removeEventListener('keydown', handleKeyDown);
|
|
83
|
+
};
|
|
84
|
+
}, [
|
|
85
|
+
anchorElement,
|
|
86
|
+
popperElement,
|
|
87
|
+
onClose,
|
|
88
|
+
outsideClick,
|
|
89
|
+
escapeKeyDown
|
|
90
|
+
]);
|
|
91
|
+
return /*#__PURE__*/ jsx("div", {
|
|
92
|
+
...restProps,
|
|
93
|
+
...attributes,
|
|
94
|
+
ref: setPopperElement,
|
|
95
|
+
className: classnames(index_module.component, className),
|
|
96
|
+
style: {
|
|
97
|
+
...style,
|
|
98
|
+
...popperStyles,
|
|
99
|
+
visibility: popperStyles?.transform ? style?.visibility : 'hidden'
|
|
100
|
+
},
|
|
101
|
+
"data-test-id": dataTestId,
|
|
102
|
+
children: children
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
PopoverSurface.displayName = 'PopoverSurface';
|
|
106
|
+
export { PopoverSurface };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Modifier } from '@popperjs/core';
|
|
2
|
+
type Options = {
|
|
3
|
+
availableHeight: boolean;
|
|
4
|
+
useAnchorWidth: boolean;
|
|
5
|
+
viewportPadding: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const createSizeModifier: (options: Options) => Modifier<"availableSize", Options>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { detectOverflow } from "@popperjs/core";
|
|
2
|
+
const createSizeModifier = (options)=>({
|
|
3
|
+
name: 'availableSize',
|
|
4
|
+
enabled: true,
|
|
5
|
+
phase: 'beforeWrite',
|
|
6
|
+
requires: [
|
|
7
|
+
'computeStyles'
|
|
8
|
+
],
|
|
9
|
+
options,
|
|
10
|
+
fn ({ state }) {
|
|
11
|
+
const { availableHeight, useAnchorWidth, viewportPadding } = options;
|
|
12
|
+
const documentElement = state.elements.popper.ownerDocument.documentElement;
|
|
13
|
+
const overflow = detectOverflow(state, {
|
|
14
|
+
boundary: [],
|
|
15
|
+
padding: viewportPadding
|
|
16
|
+
});
|
|
17
|
+
const side = state.placement.split('-')[0];
|
|
18
|
+
const height = 'top' === side || 'bottom' === side ? state.rects.popper.height - overflow[side] : documentElement.clientHeight - 2 * viewportPadding;
|
|
19
|
+
Object.assign(state.styles.popper, {
|
|
20
|
+
'--popover-viewport-padding': `${viewportPadding}px`,
|
|
21
|
+
'--popover-available-height': availableHeight ? `${Math.max(0, height)}px` : 'none'
|
|
22
|
+
});
|
|
23
|
+
if (useAnchorWidth) state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export { createSizeModifier };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover } from "./popover.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@import "./vars.css";
|
|
2
|
+
|
|
3
|
+
.component-wBbNPp {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
z-index: var(--popover-z-index);
|
|
6
|
+
max-width: calc(100vw - var(--popover-viewport-padding, 8px) * 2);
|
|
7
|
+
min-width: 0;
|
|
8
|
+
min-height: 0;
|
|
9
|
+
max-height: var(--popover-available-height, none);
|
|
10
|
+
box-shadow: var(--popover-shadow);
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
display: flex;
|
|
13
|
+
position: fixed;
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type { PopoverProps, PopoverPosition } from './types.js';
|
|
2
|
+
export declare const Popover: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLDivElement>, "className" | "style" | "children"> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: import("react").CSSProperties;
|
|
6
|
+
open: boolean;
|
|
7
|
+
anchorElement: HTMLElement | null;
|
|
8
|
+
position?: import("./types.js").PopoverPosition;
|
|
9
|
+
offset?: [number, number];
|
|
10
|
+
useAnchorWidth?: boolean;
|
|
11
|
+
preventFlip?: boolean;
|
|
12
|
+
fallbackPlacements?: import("./types.js").PopoverPosition[];
|
|
13
|
+
preventOverflow?: boolean;
|
|
14
|
+
availableHeight?: boolean;
|
|
15
|
+
viewportPadding?: number;
|
|
16
|
+
onClose?: VoidFunction;
|
|
17
|
+
outsideClick?: boolean;
|
|
18
|
+
escapeKeyDown?: boolean;
|
|
19
|
+
getPortalContainer?: () => Element | null;
|
|
20
|
+
dataTestId?: string;
|
|
21
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { PopoverSurface } from "./components/popover-surface/index.js";
|
|
5
|
+
const Popover = /*#__PURE__*/ forwardRef(({ open, anchorElement, getPortalContainer, ...restProps }, ref)=>{
|
|
6
|
+
if (!open || !anchorElement) return null;
|
|
7
|
+
const container = getPortalContainer ? getPortalContainer() : anchorElement.ownerDocument.body;
|
|
8
|
+
return container ? /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(PopoverSurface, {
|
|
9
|
+
...restProps,
|
|
10
|
+
anchorElement: anchorElement,
|
|
11
|
+
ref: ref
|
|
12
|
+
}), container) : null;
|
|
13
|
+
});
|
|
14
|
+
Popover.displayName = 'Popover';
|
|
15
|
+
export { Popover };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Placement } from '@popperjs/core';
|
|
2
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
export type PopoverPosition = Exclude<Placement, 'auto' | 'auto-start' | 'auto-end'>;
|
|
4
|
+
export type PopoverProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'style'> & {
|
|
5
|
+
/** Содержимое поповера. Оформление и прокрутка задаются вызывающим компонентом. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Дополнительный класс внешнего контейнера.
|
|
9
|
+
*/
|
|
10
|
+
className?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Стили внешнего контейнера, включая ширину.
|
|
13
|
+
*/
|
|
14
|
+
style?: CSSProperties;
|
|
15
|
+
/**
|
|
16
|
+
* Видимость поповера.
|
|
17
|
+
*/
|
|
18
|
+
open: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Элемент, относительно которого открывается поповер.
|
|
21
|
+
*/
|
|
22
|
+
anchorElement: HTMLElement | null;
|
|
23
|
+
/**
|
|
24
|
+
* Предпочтительная позиция относительно элемента.
|
|
25
|
+
* @default 'bottom-start'
|
|
26
|
+
*/
|
|
27
|
+
position?: PopoverPosition;
|
|
28
|
+
/**
|
|
29
|
+
* Смещение вдоль элемента и расстояние от него, в пикселях.
|
|
30
|
+
* @default [0, 0]
|
|
31
|
+
*/
|
|
32
|
+
offset?: [number, number];
|
|
33
|
+
/**
|
|
34
|
+
* Использовать ширину элемента, относительно которого открыт поповер.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
useAnchorWidth?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Запретить смену стороны при недостатке места.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
preventFlip?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Позиции, которые проверяются при недостатке места.
|
|
45
|
+
*/
|
|
46
|
+
fallbackPlacements?: PopoverPosition[];
|
|
47
|
+
/**
|
|
48
|
+
* Удерживать поповер в пределах видимой области.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
preventOverflow?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Ограничивать высоту доступным местом.
|
|
54
|
+
* Для прокрутки задайте содержимому min-height: 0 и overflow: auto.
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
availableHeight?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Минимальный отступ от границ видимой области, в пикселях.
|
|
60
|
+
* @default 8
|
|
61
|
+
*/
|
|
62
|
+
viewportPadding?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Обработчик запроса закрытия. Обновите open в вызывающем компоненте.
|
|
65
|
+
*/
|
|
66
|
+
onClose?: VoidFunction;
|
|
67
|
+
/**
|
|
68
|
+
* Разрешить закрытие по нажатию вне поповера и его элемента.
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
outsideClick?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Разрешить закрытие по Escape.
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
escapeKeyDown?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Контейнер портала. По умолчанию — body документа anchorElement.
|
|
79
|
+
* Если функция возвращает null, поповер не рендерится.
|
|
80
|
+
*/
|
|
81
|
+
getPortalContainer?: () => Element | null;
|
|
82
|
+
/**
|
|
83
|
+
* Идентификатор для автоматизированных тестов.
|
|
84
|
+
*/
|
|
85
|
+
dataTestId?: string;
|
|
86
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Modifier } from '@popperjs/core';
|
|
2
|
+
import { type CSSProperties } from 'react';
|
|
3
|
+
import type { PopoverPosition } from './types.js';
|
|
4
|
+
export declare function usePopoverPosition(anchorElement: HTMLElement, popperElement: HTMLDivElement | null, position: PopoverPosition, modifiers: Partial<Modifier<string, object>>[]): {
|
|
5
|
+
update: () => Promise<Partial<import("@popperjs/core").State>> | undefined;
|
|
6
|
+
styles: CSSProperties;
|
|
7
|
+
attributes: Record<string, string | boolean>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createPopper } from "@popperjs/core";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
const initialState = {
|
|
4
|
+
styles: {
|
|
5
|
+
position: 'fixed',
|
|
6
|
+
left: 0,
|
|
7
|
+
top: 0,
|
|
8
|
+
visibility: 'hidden'
|
|
9
|
+
},
|
|
10
|
+
attributes: {}
|
|
11
|
+
};
|
|
12
|
+
function usePopoverPosition(anchorElement, popperElement, position, modifiers) {
|
|
13
|
+
const [state, setState] = useState(initialState);
|
|
14
|
+
const instanceRef = useRef(null);
|
|
15
|
+
const updateState = useMemo(()=>({
|
|
16
|
+
name: 'reactStyles',
|
|
17
|
+
enabled: true,
|
|
18
|
+
phase: 'write',
|
|
19
|
+
requires: [
|
|
20
|
+
'computeStyles'
|
|
21
|
+
],
|
|
22
|
+
fn: ({ state: popperState })=>{
|
|
23
|
+
setState({
|
|
24
|
+
styles: {
|
|
25
|
+
...popperState.styles.popper
|
|
26
|
+
},
|
|
27
|
+
attributes: {
|
|
28
|
+
...popperState.attributes.popper
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}), []);
|
|
33
|
+
useEffect(()=>{
|
|
34
|
+
if (!popperElement) return;
|
|
35
|
+
let active = true;
|
|
36
|
+
setState(initialState);
|
|
37
|
+
const instance = createPopper(anchorElement, popperElement, {
|
|
38
|
+
placement: position,
|
|
39
|
+
strategy: 'fixed',
|
|
40
|
+
modifiers: [
|
|
41
|
+
...modifiers,
|
|
42
|
+
{
|
|
43
|
+
...updateState,
|
|
44
|
+
fn: (args)=>{
|
|
45
|
+
if (active) updateState.fn(args);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'applyStyles',
|
|
50
|
+
enabled: false
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
instanceRef.current = instance;
|
|
55
|
+
const ResizeObserverClass = anchorElement.ownerDocument.defaultView?.ResizeObserver;
|
|
56
|
+
const observer = ResizeObserverClass ? new ResizeObserverClass(()=>void instance.update()) : void 0;
|
|
57
|
+
observer?.observe(anchorElement);
|
|
58
|
+
observer?.observe(popperElement);
|
|
59
|
+
return ()=>{
|
|
60
|
+
active = false;
|
|
61
|
+
observer?.disconnect();
|
|
62
|
+
instance.destroy();
|
|
63
|
+
instanceRef.current = null;
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
anchorElement,
|
|
67
|
+
popperElement,
|
|
68
|
+
position,
|
|
69
|
+
modifiers,
|
|
70
|
+
updateState
|
|
71
|
+
]);
|
|
72
|
+
const update = useCallback(()=>instanceRef.current?.update(), []);
|
|
73
|
+
return {
|
|
74
|
+
...state,
|
|
75
|
+
update
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export { usePopoverPosition };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./colors_module.css";
|
|
2
|
+
const colors_module = {
|
|
3
|
+
inherit: "inherit-D2kX96",
|
|
4
|
+
primary: "primary-LVKi8J",
|
|
5
|
+
secondary: "secondary-eTdE4v",
|
|
6
|
+
inverse: "inverse-PTiWqH",
|
|
7
|
+
positive: "positive-a1clfd",
|
|
8
|
+
negative: "negative-IhTMOW"
|
|
9
|
+
};
|
|
10
|
+
export default colors_module;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@import "./vars.css";
|
|
2
|
+
|
|
3
|
+
.inherit-D2kX96 {
|
|
4
|
+
color: inherit;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.primary-LVKi8J {
|
|
8
|
+
color: var(--typography-primary-color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.secondary-eTdE4v {
|
|
12
|
+
color: var(--typography-secondary-color);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.inverse-PTiWqH {
|
|
16
|
+
color: var(--typography-inverse-color);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.positive-a1clfd {
|
|
20
|
+
color: var(--typography-positive-color);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.negative-IhTMOW {
|
|
24
|
+
color: var(--typography-negative-color);
|
|
25
|
+
}
|
|
26
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TypographyText } from './text.js';
|
|
2
|
+
import { TypographyTitle } from './title.js';
|
|
3
|
+
export { TypographyText, TypographyText as Text, TypographyTitle, TypographyTitle as Title };
|
|
4
|
+
export type { TextProps, TitleProps, TypographyColor, TypographyWeight } from './shared.js';
|
|
5
|
+
export declare const Typography: {
|
|
6
|
+
Text: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement>, "className" | "style" | "color" | "children"> & {
|
|
7
|
+
children?: import("react").ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: import("react").CSSProperties;
|
|
10
|
+
color?: import("./shared.js").TypographyColor;
|
|
11
|
+
weight?: import("./shared.js").TypographyWeight;
|
|
12
|
+
caps?: boolean;
|
|
13
|
+
monospaceNumbers?: boolean;
|
|
14
|
+
rowLimit?: 1 | 2 | 3;
|
|
15
|
+
dataTestId?: string;
|
|
16
|
+
} & {
|
|
17
|
+
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20;
|
|
18
|
+
tag?: "span" | "p" | "div" | "li";
|
|
19
|
+
} & import("react").RefAttributes<import("./shared.js").TextElement>>;
|
|
20
|
+
Title: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement>, "className" | "style" | "color" | "children"> & {
|
|
21
|
+
children?: import("react").ReactNode;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: import("react").CSSProperties;
|
|
24
|
+
color?: import("./shared.js").TypographyColor;
|
|
25
|
+
weight?: import("./shared.js").TypographyWeight;
|
|
26
|
+
caps?: boolean;
|
|
27
|
+
monospaceNumbers?: boolean;
|
|
28
|
+
rowLimit?: 1 | 2 | 3;
|
|
29
|
+
dataTestId?: string;
|
|
30
|
+
} & {
|
|
31
|
+
size?: 13 | 14 | 16 | 20 | 24 | 28 | 32;
|
|
32
|
+
tag: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div";
|
|
33
|
+
} & import("react").RefAttributes<import("./shared.js").TitleElement>>;
|
|
34
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TypographyText } from "./text.js";
|
|
2
|
+
import { TypographyTitle } from "./title.js";
|
|
3
|
+
const Typography = {
|
|
4
|
+
Text: TypographyText,
|
|
5
|
+
Title: TypographyTitle
|
|
6
|
+
};
|
|
7
|
+
export { Typography, TypographyText as Text, TypographyText, TypographyTitle as Title, TypographyTitle };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./index_module.css";
|
|
2
|
+
const index_module = {
|
|
3
|
+
component: "component-niqWjh",
|
|
4
|
+
"weight-regular": "weight-regular-cOlAcy",
|
|
5
|
+
weightRegular: "weight-regular-cOlAcy",
|
|
6
|
+
"weight-medium": "weight-medium-kDVEGI",
|
|
7
|
+
weightMedium: "weight-medium-kDVEGI",
|
|
8
|
+
"weight-semibold": "weight-semibold-euRksF",
|
|
9
|
+
weightSemibold: "weight-semibold-euRksF",
|
|
10
|
+
"weight-bold": "weight-bold-ZxTUEF",
|
|
11
|
+
weightBold: "weight-bold-ZxTUEF",
|
|
12
|
+
caps: "caps-AWFyAh",
|
|
13
|
+
monospaceNumbers: "monospaceNumbers-wR2ApQ",
|
|
14
|
+
rowLimit1: "rowLimit1-Es_q51",
|
|
15
|
+
rowLimit2: "rowLimit2-gODO9s",
|
|
16
|
+
rowLimit3: "rowLimit3-LvJseL"
|
|
17
|
+
};
|
|
18
|
+
export default index_module;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@import "../../styles/theme.css";
|
|
2
|
+
@import "./vars.css";
|
|
3
|
+
|
|
4
|
+
.component-niqWjh {
|
|
5
|
+
margin: var(--size-0, 0px);
|
|
6
|
+
padding: var(--size-0, 0px);
|
|
7
|
+
font-family: var(--font-primary);
|
|
8
|
+
font-style: normal;
|
|
9
|
+
line-height: var(--typography-line-height);
|
|
10
|
+
letter-spacing: var(--typography-letter-spacing);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.weight-regular-cOlAcy {
|
|
14
|
+
font-weight: var(--typography-regular-font-weight);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.weight-medium-kDVEGI {
|
|
18
|
+
font-weight: var(--typography-medium-font-weight);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.weight-semibold-euRksF {
|
|
22
|
+
font-weight: var(--typography-semibold-font-weight);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.weight-bold-ZxTUEF {
|
|
26
|
+
font-weight: var(--typography-bold-font-weight);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.caps-AWFyAh {
|
|
30
|
+
text-transform: uppercase;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.monospaceNumbers-wR2ApQ {
|
|
34
|
+
font-variant-numeric: tabular-nums lining-nums;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.rowLimit1-Es_q51 {
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
text-overflow: ellipsis;
|
|
40
|
+
display: block;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.rowLimit2-gODO9s, .rowLimit3-LvJseL {
|
|
45
|
+
-webkit-box-orient: vertical;
|
|
46
|
+
display: -webkit-box;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.rowLimit2-gODO9s {
|
|
51
|
+
-webkit-line-clamp: 2;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.rowLimit3-LvJseL {
|
|
55
|
+
-webkit-line-clamp: 3;
|
|
56
|
+
}
|
|
57
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "./preset_module.css";
|
|
2
|
+
const preset_module = {
|
|
3
|
+
"size-8": "size-8-NlI2Hs",
|
|
4
|
+
size8: "size-8-NlI2Hs",
|
|
5
|
+
"size-9": "size-9-j9FL3_",
|
|
6
|
+
size9: "size-9-j9FL3_",
|
|
7
|
+
"size-10": "size-10-GUrD5L",
|
|
8
|
+
size10: "size-10-GUrD5L",
|
|
9
|
+
"size-11": "size-11-foLp7Q",
|
|
10
|
+
size11: "size-11-foLp7Q",
|
|
11
|
+
"size-12": "size-12-E_PVmd",
|
|
12
|
+
size12: "size-12-E_PVmd",
|
|
13
|
+
"size-13": "size-13-Eu2_On",
|
|
14
|
+
size13: "size-13-Eu2_On",
|
|
15
|
+
"size-14": "size-14-OpEM1B",
|
|
16
|
+
size14: "size-14-OpEM1B",
|
|
17
|
+
"size-15": "size-15-DxWyW2",
|
|
18
|
+
size15: "size-15-DxWyW2",
|
|
19
|
+
"size-16": "size-16-OgafBi",
|
|
20
|
+
size16: "size-16-OgafBi",
|
|
21
|
+
"size-20": "size-20-eTO0D7",
|
|
22
|
+
size20: "size-20-eTO0D7",
|
|
23
|
+
"size-24": "size-24-lZpjdx",
|
|
24
|
+
size24: "size-24-lZpjdx",
|
|
25
|
+
"size-28": "size-28-CY10Yo",
|
|
26
|
+
size28: "size-28-CY10Yo",
|
|
27
|
+
"size-32": "size-32-QPCTWV",
|
|
28
|
+
size32: "size-32-QPCTWV"
|
|
29
|
+
};
|
|
30
|
+
export default preset_module;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@import "./vars.css";
|
|
2
|
+
|
|
3
|
+
.size-8-NlI2Hs {
|
|
4
|
+
font-size: var(--typography-font-size-8);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.size-9-j9FL3_ {
|
|
8
|
+
font-size: var(--typography-font-size-9);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.size-10-GUrD5L {
|
|
12
|
+
font-size: var(--typography-font-size-10);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.size-11-foLp7Q {
|
|
16
|
+
font-size: var(--typography-font-size-11);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.size-12-E_PVmd {
|
|
20
|
+
font-size: var(--typography-font-size-12);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.size-13-Eu2_On {
|
|
24
|
+
font-size: var(--typography-font-size-13);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.size-14-OpEM1B {
|
|
28
|
+
font-size: var(--typography-font-size-14);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.size-15-DxWyW2 {
|
|
32
|
+
font-size: var(--typography-font-size-15);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.size-16-OgafBi {
|
|
36
|
+
font-size: var(--typography-font-size-16);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.size-20-eTO0D7 {
|
|
40
|
+
font-size: var(--typography-font-size-20);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.size-24-lZpjdx {
|
|
44
|
+
font-size: var(--typography-font-size-24);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.size-28-CY10Yo {
|
|
48
|
+
font-size: var(--typography-font-size-28);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.size-32-QPCTWV {
|
|
52
|
+
font-size: var(--typography-font-size-32);
|
|
53
|
+
}
|
|
54
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type TypographyWeight = 'regular' | 'medium' | 'semibold' | 'bold';
|
|
3
|
+
export type TypographyColor = 'inherit' | 'primary' | 'secondary' | 'inverse' | 'positive' | 'negative';
|
|
4
|
+
export type BaseProps = Omit<HTMLAttributes<HTMLElement>, 'color' | 'children' | 'className' | 'style'> & {
|
|
5
|
+
/** Содержимое текста или заголовка. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** Дополнительный CSS-класс корневого элемента. */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Инлайн-стили корневого элемента. */
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
/**
|
|
12
|
+
* Цвет текста. По умолчанию наследуется от родителя.
|
|
13
|
+
*/
|
|
14
|
+
color?: TypographyColor;
|
|
15
|
+
/**
|
|
16
|
+
* Толщина шрифта.
|
|
17
|
+
*/
|
|
18
|
+
weight?: TypographyWeight;
|
|
19
|
+
/**
|
|
20
|
+
* Преобразовать текст в верхний регистр.
|
|
21
|
+
*/
|
|
22
|
+
caps?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Сделать цифры одинаковой ширины для таблиц и показателей.
|
|
25
|
+
*/
|
|
26
|
+
monospaceNumbers?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Ограничить число видимых строк, сохранив полный текст в DOM.
|
|
29
|
+
*/
|
|
30
|
+
rowLimit?: 1 | 2 | 3;
|
|
31
|
+
/**
|
|
32
|
+
* Идентификатор для автоматизированных тестов.
|
|
33
|
+
*/
|
|
34
|
+
dataTestId?: string;
|
|
35
|
+
};
|
|
36
|
+
export type TextProps = BaseProps & {
|
|
37
|
+
/**
|
|
38
|
+
* Размер шрифта в пикселях.
|
|
39
|
+
* @default 13
|
|
40
|
+
*/
|
|
41
|
+
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20;
|
|
42
|
+
/**
|
|
43
|
+
* HTML-тег, определяющий семантику текста.
|
|
44
|
+
* @default span
|
|
45
|
+
*/
|
|
46
|
+
tag?: 'span' | 'p' | 'div' | 'li';
|
|
47
|
+
};
|
|
48
|
+
export type TitleProps = BaseProps & {
|
|
49
|
+
/**
|
|
50
|
+
* Размер шрифта в пикселях.
|
|
51
|
+
* @default 28
|
|
52
|
+
*/
|
|
53
|
+
size?: 13 | 14 | 16 | 20 | 24 | 28 | 32;
|
|
54
|
+
/**
|
|
55
|
+
* Уровень заголовка выбирается независимо от визуального размера.
|
|
56
|
+
*/
|
|
57
|
+
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'div';
|
|
58
|
+
};
|
|
59
|
+
export type TextElement = HTMLSpanElement | HTMLParagraphElement | HTMLDivElement | HTMLLIElement;
|
|
60
|
+
export type TitleElement = HTMLHeadingElement | HTMLDivElement;
|
|
61
|
+
export declare const getClassName: ({ size, weight, color, caps, monospaceNumbers, rowLimit, className, }: BaseProps & {
|
|
62
|
+
size: number;
|
|
63
|
+
}) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import classnames from "classnames";
|
|
2
|
+
import colors_module from "./colors.module.js";
|
|
3
|
+
import index_module from "./index.module.js";
|
|
4
|
+
import preset_module from "./preset.module.js";
|
|
5
|
+
const getClassName = ({ size, weight, color, caps, monospaceNumbers, rowLimit, className })=>classnames(index_module.component, preset_module[`size-${size}`], weight && index_module[`weight-${weight}`], color && colors_module[color], {
|
|
6
|
+
[index_module.caps]: caps,
|
|
7
|
+
[index_module.monospaceNumbers]: monospaceNumbers,
|
|
8
|
+
[index_module[`rowLimit${rowLimit}`]]: rowLimit
|
|
9
|
+
}, className);
|
|
10
|
+
export { getClassName };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TextElement } from './shared.js';
|
|
2
|
+
export declare const TypographyText: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement>, "className" | "style" | "color" | "children"> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: import("react").CSSProperties;
|
|
6
|
+
color?: import("./shared.js").TypographyColor;
|
|
7
|
+
weight?: import("./shared.js").TypographyWeight;
|
|
8
|
+
caps?: boolean;
|
|
9
|
+
monospaceNumbers?: boolean;
|
|
10
|
+
rowLimit?: 1 | 2 | 3;
|
|
11
|
+
dataTestId?: string;
|
|
12
|
+
} & {
|
|
13
|
+
size?: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20;
|
|
14
|
+
tag?: "span" | "p" | "div" | "li";
|
|
15
|
+
} & import("react").RefAttributes<TextElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createElement, forwardRef } from "react";
|
|
2
|
+
import { getClassName } from "./shared.js";
|
|
3
|
+
const TypographyText = /*#__PURE__*/ forwardRef(({ size = 13, tag = 'span', weight = 'regular', color = 'inherit', caps = false, monospaceNumbers = false, rowLimit, className, dataTestId, children, ...restProps }, ref)=>/*#__PURE__*/ createElement(tag, {
|
|
4
|
+
...restProps,
|
|
5
|
+
ref,
|
|
6
|
+
className: getClassName({
|
|
7
|
+
size,
|
|
8
|
+
weight,
|
|
9
|
+
color,
|
|
10
|
+
caps,
|
|
11
|
+
monospaceNumbers,
|
|
12
|
+
rowLimit,
|
|
13
|
+
className
|
|
14
|
+
}),
|
|
15
|
+
'data-test-id': dataTestId
|
|
16
|
+
}, children));
|
|
17
|
+
TypographyText.displayName = 'TypographyText';
|
|
18
|
+
export { TypographyText };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TitleElement } from './shared.js';
|
|
2
|
+
export declare const TypographyTitle: import("react").ForwardRefExoticComponent<Omit<import("react").HTMLAttributes<HTMLElement>, "className" | "style" | "color" | "children"> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: import("react").CSSProperties;
|
|
6
|
+
color?: import("./shared.js").TypographyColor;
|
|
7
|
+
weight?: import("./shared.js").TypographyWeight;
|
|
8
|
+
caps?: boolean;
|
|
9
|
+
monospaceNumbers?: boolean;
|
|
10
|
+
rowLimit?: 1 | 2 | 3;
|
|
11
|
+
dataTestId?: string;
|
|
12
|
+
} & {
|
|
13
|
+
size?: 13 | 14 | 16 | 20 | 24 | 28 | 32;
|
|
14
|
+
tag: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div";
|
|
15
|
+
} & import("react").RefAttributes<TitleElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createElement, forwardRef } from "react";
|
|
2
|
+
import { getClassName } from "./shared.js";
|
|
3
|
+
const TypographyTitle = /*#__PURE__*/ forwardRef(({ size = 28, tag, weight = 'bold', color = 'inherit', caps = false, monospaceNumbers = false, rowLimit, className, dataTestId, children, ...restProps }, ref)=>/*#__PURE__*/ createElement(tag, {
|
|
4
|
+
...restProps,
|
|
5
|
+
ref,
|
|
6
|
+
className: getClassName({
|
|
7
|
+
size,
|
|
8
|
+
weight,
|
|
9
|
+
color,
|
|
10
|
+
caps,
|
|
11
|
+
monospaceNumbers,
|
|
12
|
+
rowLimit,
|
|
13
|
+
className
|
|
14
|
+
}),
|
|
15
|
+
'data-test-id': dataTestId
|
|
16
|
+
}, children));
|
|
17
|
+
TypographyTitle.displayName = 'TypographyTitle';
|
|
18
|
+
export { TypographyTitle };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--typography-line-height: normal;
|
|
3
|
+
--typography-letter-spacing: 0;
|
|
4
|
+
--typography-regular-font-weight: 400;
|
|
5
|
+
--typography-medium-font-weight: 500;
|
|
6
|
+
--typography-semibold-font-weight: 600;
|
|
7
|
+
--typography-bold-font-weight: 700;
|
|
8
|
+
--typography-primary-color: #1c1a18;
|
|
9
|
+
--typography-secondary-color: #736554;
|
|
10
|
+
--typography-inverse-color: #f5f3ec;
|
|
11
|
+
--typography-positive-color: #4caf50;
|
|
12
|
+
--typography-negative-color: #ef5350;
|
|
13
|
+
--typography-font-size-8: 8px;
|
|
14
|
+
--typography-font-size-9: 9px;
|
|
15
|
+
--typography-font-size-10: 10px;
|
|
16
|
+
--typography-font-size-11: 11px;
|
|
17
|
+
--typography-font-size-12: 12px;
|
|
18
|
+
--typography-font-size-13: 13px;
|
|
19
|
+
--typography-font-size-14: 14px;
|
|
20
|
+
--typography-font-size-15: 15px;
|
|
21
|
+
--typography-font-size-16: 16px;
|
|
22
|
+
--typography-font-size-20: 20px;
|
|
23
|
+
--typography-font-size-24: 24px;
|
|
24
|
+
--typography-font-size-28: 28px;
|
|
25
|
+
--typography-font-size-32: 32px;
|
|
26
|
+
}
|
|
27
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,7 @@ export { Button } from './components/Button/index.js';
|
|
|
2
2
|
export type { ButtonProps } from './components/Button/index.js';
|
|
3
3
|
export { Spinner } from './components/Spinner/index.js';
|
|
4
4
|
export type { SpinnerProps } from './components/Spinner/index.js';
|
|
5
|
+
export { Typography, TypographyText, TypographyTitle, Text, Title } from './components/Typography/index.js';
|
|
6
|
+
export type { TextProps, TitleProps, TypographyColor, TypographyWeight, } from './components/Typography/index.js';
|
|
7
|
+
export { Popover } from './components/Popover/index.js';
|
|
8
|
+
export type { PopoverProps, PopoverPosition } from './components/Popover/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { Button } from "./components/Button/index.js";
|
|
2
2
|
export { Spinner } from "./components/Spinner/index.js";
|
|
3
|
+
export { Text, Title, Typography, TypographyText, TypographyTitle } from "./components/Typography/index.js";
|
|
4
|
+
export { Popover } from "./components/Popover/index.js";
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: Inter;
|
|
3
|
+
font-style: normal;
|
|
4
|
+
font-display: swap;
|
|
5
|
+
font-weight: 100 900;
|
|
6
|
+
src: url(../static/font/inter-cyrillic-ext-wght-normal.woff2) format("woff2");
|
|
7
|
+
unicode-range: U+460-52F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@font-face {
|
|
11
|
+
font-family: Inter;
|
|
12
|
+
font-style: normal;
|
|
13
|
+
font-display: swap;
|
|
14
|
+
font-weight: 100 900;
|
|
15
|
+
src: url(../static/font/inter-cyrillic-wght-normal.woff2) format("woff2");
|
|
16
|
+
unicode-range: U+301, U+400-45F, U+490-491, U+4B0-4B1, U+2116;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@font-face {
|
|
20
|
+
font-family: Inter;
|
|
21
|
+
font-style: normal;
|
|
22
|
+
font-display: swap;
|
|
23
|
+
font-weight: 100 900;
|
|
24
|
+
src: url(../static/font/inter-greek-ext-wght-normal.woff2) format("woff2");
|
|
25
|
+
unicode-range: U+1F??;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@font-face {
|
|
29
|
+
font-family: Inter;
|
|
30
|
+
font-style: normal;
|
|
31
|
+
font-display: swap;
|
|
32
|
+
font-weight: 100 900;
|
|
33
|
+
src: url(../static/font/inter-greek-wght-normal.woff2) format("woff2");
|
|
34
|
+
unicode-range: U+370-377, U+37A-37F, U+384-38A, U+38C, U+38E-3A1, U+3A3-3FF;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@font-face {
|
|
38
|
+
font-family: Inter;
|
|
39
|
+
font-style: normal;
|
|
40
|
+
font-display: swap;
|
|
41
|
+
font-weight: 100 900;
|
|
42
|
+
src: url(../static/font/inter-vietnamese-wght-normal.woff2) format("woff2");
|
|
43
|
+
unicode-range: U+102-103, U+110-111, U+128-129, U+168-169, U+1A0-1A1, U+1AF-1B0, U+300-301, U+303-304, U+308-309, U+323, U+329, U+1EA0-1EF9, U+20AB;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@font-face {
|
|
47
|
+
font-family: Inter;
|
|
48
|
+
font-style: normal;
|
|
49
|
+
font-display: swap;
|
|
50
|
+
font-weight: 100 900;
|
|
51
|
+
src: url(../static/font/inter-latin-ext-wght-normal.woff2) format("woff2");
|
|
52
|
+
unicode-range: U+100-2BA, U+2BD-2C5, U+2C7-2CC, U+2CE-2D7, U+2DD-2FF, U+304, U+308, U+329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@font-face {
|
|
56
|
+
font-family: Inter;
|
|
57
|
+
font-style: normal;
|
|
58
|
+
font-display: swap;
|
|
59
|
+
font-weight: 100 900;
|
|
60
|
+
src: url(../static/font/inter-latin-wght-normal.woff2) format("woff2");
|
|
61
|
+
unicode-range: U+??, U+131, U+152-153, U+2BB-2BC, U+2C6, U+2DA, U+2DC, U+304, U+308, U+329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
62
|
+
}
|
|
63
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koslibs/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Shared React components for koslibs projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
+
"./theme.css": "./dist/styles/theme.css",
|
|
13
14
|
"./*": {
|
|
14
15
|
"types": "./dist/components/*/index.d.ts",
|
|
15
16
|
"import": "./dist/components/*/index.js"
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
"react-dom": "^18.3.1 || ^19.0.0"
|
|
80
81
|
},
|
|
81
82
|
"dependencies": {
|
|
83
|
+
"@popperjs/core": "2.11.8",
|
|
82
84
|
"classnames": "2.5.1"
|
|
83
85
|
}
|
|
84
86
|
}
|