@shmidko61/lc-ui-kit 0.12.0 → 0.15.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/README.md +65 -0
- package/dist/alert/alert.d.ts +5 -0
- package/dist/alert/helpers/alert.helpers.d.ts +27 -0
- package/dist/alert/helpers/index.d.ts +1 -0
- package/dist/alert/index.d.ts +2 -0
- package/dist/alert/types/alert.types.d.ts +25 -0
- package/dist/alert/types/index.d.ts +1 -0
- package/dist/alert-CTIWpkmD.js +128 -0
- package/dist/alert-DTc0Usg-.cjs +1 -0
- package/dist/alert.cjs +1 -0
- package/dist/alert.js +4 -0
- package/dist/box/box.d.ts +1 -1
- package/dist/box/box.types.d.ts +2 -2
- package/dist/box/helpers/box-animation.helpers.d.ts +8 -0
- package/dist/box/helpers/index.d.ts +1 -0
- package/dist/box/index.d.ts +1 -0
- package/dist/box/types/box-animation.types.d.ts +3 -0
- package/dist/box/types/index.d.ts +1 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +436 -312
- package/dist/button/button.helpers.d.ts +1 -1
- package/dist/button/index.d.ts +1 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +163 -156
- package/dist/flex/flex.d.ts +1 -1
- package/dist/flex/flex.types.d.ts +1 -1
- package/dist/flex/index.d.ts +1 -0
- package/dist/icons/icons.d.ts +8 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons.cjs +1 -1
- package/dist/icons.js +40 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +111 -92
- package/dist/input/input.types.d.ts +1 -1
- package/dist/loader/helpers/index.d.ts +1 -0
- package/dist/loader/helpers/loader.helpers.d.ts +2 -0
- package/dist/loader/index.d.ts +2 -0
- package/dist/loader/loader.d.ts +5 -0
- package/dist/loader/types/index.d.ts +1 -0
- package/dist/loader/types/loader.types.d.ts +28 -0
- package/dist/loader-Daam055i.js +104 -0
- package/dist/loader-ODTCTLKE.cjs +1 -0
- package/dist/loader.cjs +1 -0
- package/dist/loader.js +4 -0
- package/dist/media-gallery.cjs +1 -1
- package/dist/media-gallery.js +42 -30
- package/dist/notification-provider/helpers/index.d.ts +1 -0
- package/dist/notification-provider/helpers/notification-provider.helpers.d.ts +8 -0
- package/dist/notification-provider/hooks/index.d.ts +1 -0
- package/dist/notification-provider/hooks/notification-provider.hooks.d.ts +5 -0
- package/dist/notification-provider/index.d.ts +3 -0
- package/dist/notification-provider/notification-provider.d.ts +4 -0
- package/dist/notification-provider/types/index.d.ts +1 -0
- package/dist/notification-provider/types/notification-provider.types.d.ts +61 -0
- package/dist/notification-provider-C2ypXy2W.cjs +1 -0
- package/dist/notification-provider-WLUaZyMB.js +113 -0
- package/dist/notification-provider.cjs +1 -0
- package/dist/notification-provider.js +6 -0
- package/dist/progress-bar/helpers/index.d.ts +1 -0
- package/dist/progress-bar/helpers/progress-bar.helpers.d.ts +6 -0
- package/dist/progress-bar/index.d.ts +2 -0
- package/dist/progress-bar/progress-bar.d.ts +5 -0
- package/dist/progress-bar/types/index.d.ts +1 -0
- package/dist/progress-bar/types/progress-bar.types.d.ts +80 -0
- package/dist/progress-bar-D4CL9r42.js +236 -0
- package/dist/progress-bar-XIJDb_UM.cjs +1 -0
- package/dist/progress-bar.cjs +1 -0
- package/dist/progress-bar.js +4 -0
- package/dist/shared/responsive-style/index.d.ts +1 -0
- package/dist/shared/responsive-style/responsive-style.types.d.ts +1 -1
- package/dist/styles.css +1 -1
- package/dist/tabs/helpers/index.d.ts +1 -0
- package/dist/tabs/helpers/tabs.helpers.d.ts +7 -0
- package/dist/tabs/hooks/index.d.ts +1 -0
- package/dist/tabs/hooks/tabs.hooks.d.ts +5 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/tabs.d.ts +4 -0
- package/dist/tabs/types/index.d.ts +1 -0
- package/dist/tabs/types/tabs.types.d.ts +95 -0
- package/dist/tabs-BNZDJRz_.cjs +1 -0
- package/dist/tabs-DIPSJX1z.js +264 -0
- package/dist/tabs.cjs +1 -0
- package/dist/tabs.js +5 -0
- package/dist/toast/index.d.ts +2 -0
- package/dist/toast/toast.d.ts +5 -0
- package/dist/toast/types/index.d.ts +1 -0
- package/dist/toast/types/toast.types.d.ts +10 -0
- package/dist/toast-CH8VqvLC.cjs +1 -0
- package/dist/toast-DpjugQ8H.js +49 -0
- package/dist/toast.cjs +1 -0
- package/dist/toast.js +4 -0
- package/dist/tooltip/helpers/index.d.ts +1 -0
- package/dist/tooltip/helpers/tooltip.helpers.d.ts +7 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/tooltip.d.ts +5 -0
- package/dist/tooltip/types/index.d.ts +1 -0
- package/dist/tooltip/types/tooltip.types.d.ts +51 -0
- package/dist/tooltip-0RbTCYn_.cjs +1 -0
- package/dist/tooltip-CWnHAfbI.js +166 -0
- package/dist/tooltip.cjs +1 -0
- package/dist/tooltip.js +4 -0
- package/dist/types/animation.types.d.ts +35 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/typography/index.d.ts +1 -0
- package/dist/typography/typography.helpers.d.ts +1 -1
- package/package.json +68 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AlertProps } from '../../alert/index';
|
|
3
|
+
import { FlexBreakpointProps, FlexProps } from '../../flex/index';
|
|
4
|
+
import { ToastProps } from '../../toast/index';
|
|
5
|
+
/** Позиции стека. top/bottom — синонимы top-middle/bottom-middle; center — центр экрана. */
|
|
6
|
+
export type NotificationPlacement = 'top-left' | 'top' | 'top-middle' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-middle' | 'bottom-right' | 'center';
|
|
7
|
+
/** Настройки положения на одном брейкпоинте; null сбрасывает placement к top-right.
|
|
8
|
+
* position/transform из Flex имеют приоритет над пресетом и допускают auto/none для сброса.
|
|
9
|
+
*/
|
|
10
|
+
export type NotificationViewportBreakpoint = Pick<FlexBreakpointProps, 'position' | 'transform' | 'width' | 'maxWidth' | 'maxHeight' | 'gap' | 'p' | 'align'> & {
|
|
11
|
+
/** Пресет положения; пропущенный наследуется, null возвращает top-right. */
|
|
12
|
+
placement?: NotificationPlacement | null;
|
|
13
|
+
};
|
|
14
|
+
/** Стек на base/md/lg/xl: пропущенные значения наследуются от меньшего экрана.
|
|
15
|
+
* Явный style приоритетнее пресетов и responsive props; className передаётся в Flex.
|
|
16
|
+
*/
|
|
17
|
+
export type NotificationViewportProps = NotificationViewportBreakpoint & Pick<FlexProps, 'style' | 'className'> & {
|
|
18
|
+
/** Переопределения от 768 px. */
|
|
19
|
+
md?: NotificationViewportBreakpoint;
|
|
20
|
+
/** Переопределения от 1024 px. */
|
|
21
|
+
lg?: NotificationViewportBreakpoint;
|
|
22
|
+
/** Переопределения от 1440 px. */
|
|
23
|
+
xl?: NotificationViewportBreakpoint;
|
|
24
|
+
};
|
|
25
|
+
/** Дополнительные параметры вызова уведомления. */
|
|
26
|
+
export type NotificationOptions = {
|
|
27
|
+
/** Необязательный стабильный ID; повторный вызов заменяет уведомление с тем же ID. */
|
|
28
|
+
id?: string;
|
|
29
|
+
/** Локальное положение стека поверх настроек провайдера, со слиянием md/lg/xl. */
|
|
30
|
+
viewport?: NotificationViewportProps;
|
|
31
|
+
};
|
|
32
|
+
/** Все ReactNode-слоты и style props Alert доступны при вызове. */
|
|
33
|
+
export type ShowAlertOptions = AlertProps & NotificationOptions;
|
|
34
|
+
/** Все ReactNode-слоты и style props Toast доступны при вызове; duration по умолчанию 0. */
|
|
35
|
+
export type ShowToastOptions = Omit<ToastProps, 'open'> & NotificationOptions;
|
|
36
|
+
/** API ближайшего провайдера; методы стабильны между рендерами. */
|
|
37
|
+
export type NotificationsApi = {
|
|
38
|
+
/** Показывает Alert и возвращает ID для закрытия или обновления. */
|
|
39
|
+
showAlert: (options: ShowAlertOptions) => string;
|
|
40
|
+
/** Показывает Toast и возвращает ID; duration включает автозакрытие. */
|
|
41
|
+
showToast: (options: ShowToastOptions) => string;
|
|
42
|
+
/** Закрывает уведомление; неизвестный ID игнорируется. */
|
|
43
|
+
dismiss: (id: string) => void;
|
|
44
|
+
/** Закрывает все уведомления текущего провайдера. */
|
|
45
|
+
dismissAll: () => void;
|
|
46
|
+
/** Обновляет props и положение существующего уведомления без изменения его вида. */
|
|
47
|
+
update: (id: string, options: Omit<ShowToastOptions, 'id'>) => void;
|
|
48
|
+
};
|
|
49
|
+
/** Провайдер вызовов и стеков; без портала, сохраняет CSS-токены окружающей темы. */
|
|
50
|
+
export type NotificationProviderProps = {
|
|
51
|
+
/** Приложение, использующее useNotifications. */
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
/** Общие настройки стеков; по умолчанию top-right, отступ 16 px, gap 12 px, z-index 1000. */
|
|
54
|
+
viewport?: NotificationViewportProps;
|
|
55
|
+
};
|
|
56
|
+
/** Внутренняя запись уведомления; kind определяет компонент при рендере. */
|
|
57
|
+
export type NotificationEntry = {
|
|
58
|
+
id: string;
|
|
59
|
+
kind: 'alert' | 'toast';
|
|
60
|
+
options: ShowToastOptions;
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";const l=require("react/jsx-runtime"),u=require("react"),j=require("./alert-DTc0Usg-.cjs"),y=require("./toast-CH8VqvLC.cjs"),k=require("./responsive-style.config-B2m9jVlX.cjs"),N=require("./flex.cjs"),P=u.createContext(null);function C(){const t=u.useContext(P);if(!t)throw new Error("useNotifications requires NotificationProvider");return t}function w(t){const e=t==="top"||t==="top-middle"||t==="bottom"||t==="bottom-middle"||t==="center",p=t.startsWith("bottom");return{position:{type:"fixed",zIndex:1e3,top:t==="center"?"50%":p?"auto":16,bottom:p?16:"auto",left:t==="center"||e?"50%":t.endsWith("left")?16:"auto",right:e||t.endsWith("left")?"auto":16},transform:t==="center"?"translate(-50%, -50%)":e?"translateX(-50%)":"none",align:e?"center":t.endsWith("left")?"start":"end"}}function q(t={},e={}){const p={...t,...e,style:{...t.style,...e.style},position:{...t.position,...e.position}};for(const r of k.responsiveBreakpoints)p[r]={...t[r],...e[r],position:{...t[r]?.position,...e[r]?.position}};return p}function W(t){const{placement:e,md:p,lg:r,xl:v,...x}=t,a={flexDirection:"column",gap:12,width:"fit-content",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100dvh - 32px)",overflowY:"auto",pointerEvents:"none",...w(e??"top-right"),...x,position:{...w(e??"top-right").position,...x.position}},f={md:p,lg:r,xl:v};for(const c of k.responsiveBreakpoints){const o=f[c];if(!o)continue;const{placement:i,...s}=o,n=i!==void 0?w(i??"top-right"):{};a[c]={...n,...s,position:{...n.position,...s.position}}}return a}function b({children:t,viewport:e}){const[p,r]=u.useState([]),v=u.useId(),x=u.useRef(0),a=u.useMemo(()=>{const c=(o,i)=>{const s=i.id??v+"-"+String(++x.current);return r(n=>{const h={id:s,kind:o,options:i};return n.some(d=>d.id===s)?n.map(d=>d.id===s?h:d):[...n,h]}),s};return{showAlert:o=>c("alert",o),showToast:o=>c("toast",o),dismiss:o=>r(i=>i.filter(s=>s.id!==o)),dismissAll:()=>r([]),update:(o,i)=>r(s=>s.map(n=>n.id===o?{...n,options:{...n.options,...i,viewport:q(n.options.viewport,i.viewport)}}:n))}},[v]),f=new Map;for(const c of p){const o=q(e,c.options.viewport),i=JSON.stringify(o),s=f.get(i);s?s.entries.push(c):f.set(i,{viewport:o,entries:[c]})}return l.jsxs(P.Provider,{value:a,children:[t,[...f.entries()].map(([c,o])=>l.jsx(N.Flex,{...W(o.viewport),children:o.entries.map(i=>{const{id:s,viewport:n,duration:h,onClose:d,...g}=i.options,m=()=>{a.dismiss(i.id),d?.()};return l.jsx(N.Flex,{pointerEvents:"auto",shrink:0,maxWidth:"100%",children:i.kind==="toast"?l.jsx(y.Toast,{...g,duration:h,onClose:m}):l.jsx(j.Alert,{...g,onClose:m})},i.id)})},c))]})}exports.NotificationProvider=b;exports.useNotifications=C;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as P, jsx as h } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as W, createContext as b, useState as y, useId as A, useRef as E, useMemo as S } from "react";
|
|
4
|
+
import { A as T } from "./alert-CTIWpkmD.js";
|
|
5
|
+
import { T as j } from "./toast-DpjugQ8H.js";
|
|
6
|
+
import { a as k } from "./responsive-style.config-DFuATrIM.js";
|
|
7
|
+
import { Flex as g } from "./flex.js";
|
|
8
|
+
const C = b(null);
|
|
9
|
+
function D() {
|
|
10
|
+
const t = W(C);
|
|
11
|
+
if (!t) throw new Error("useNotifications requires NotificationProvider");
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function v(t) {
|
|
15
|
+
const e = t === "top" || t === "top-middle" || t === "bottom" || t === "bottom-middle" || t === "center", c = t.startsWith("bottom");
|
|
16
|
+
return {
|
|
17
|
+
position: {
|
|
18
|
+
type: "fixed",
|
|
19
|
+
zIndex: 1e3,
|
|
20
|
+
top: t === "center" ? "50%" : c ? "auto" : 16,
|
|
21
|
+
bottom: c ? 16 : "auto",
|
|
22
|
+
left: t === "center" || e ? "50%" : t.endsWith("left") ? 16 : "auto",
|
|
23
|
+
right: e || t.endsWith("left") ? "auto" : 16
|
|
24
|
+
},
|
|
25
|
+
transform: t === "center" ? "translate(-50%, -50%)" : e ? "translateX(-50%)" : "none",
|
|
26
|
+
align: e ? "center" : t.endsWith("left") ? "start" : "end"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function N(t = {}, e = {}) {
|
|
30
|
+
const c = {
|
|
31
|
+
...t,
|
|
32
|
+
...e,
|
|
33
|
+
style: { ...t.style, ...e.style },
|
|
34
|
+
position: { ...t.position, ...e.position }
|
|
35
|
+
};
|
|
36
|
+
for (const r of k)
|
|
37
|
+
c[r] = {
|
|
38
|
+
...t[r],
|
|
39
|
+
...e[r],
|
|
40
|
+
position: { ...t[r]?.position, ...e[r]?.position }
|
|
41
|
+
};
|
|
42
|
+
return c;
|
|
43
|
+
}
|
|
44
|
+
function q(t) {
|
|
45
|
+
const { placement: e, md: c, lg: r, xl: a, ...m } = t, f = {
|
|
46
|
+
flexDirection: "column",
|
|
47
|
+
gap: 12,
|
|
48
|
+
width: "fit-content",
|
|
49
|
+
maxWidth: "calc(100vw - 32px)",
|
|
50
|
+
maxHeight: "calc(100dvh - 32px)",
|
|
51
|
+
overflowY: "auto",
|
|
52
|
+
pointerEvents: "none",
|
|
53
|
+
...v(e ?? "top-right"),
|
|
54
|
+
...m,
|
|
55
|
+
position: { ...v(e ?? "top-right").position, ...m.position }
|
|
56
|
+
}, u = { md: c, lg: r, xl: a };
|
|
57
|
+
for (const p of k) {
|
|
58
|
+
const o = u[p];
|
|
59
|
+
if (!o) continue;
|
|
60
|
+
const { placement: i, ...n } = o, s = i !== void 0 ? v(i ?? "top-right") : {};
|
|
61
|
+
f[p] = { ...s, ...n, position: { ...s.position, ...n.position } };
|
|
62
|
+
}
|
|
63
|
+
return f;
|
|
64
|
+
}
|
|
65
|
+
function F({
|
|
66
|
+
children: t,
|
|
67
|
+
viewport: e
|
|
68
|
+
}) {
|
|
69
|
+
const [c, r] = y([]), a = A(), m = E(0), f = S(() => {
|
|
70
|
+
const p = (o, i) => {
|
|
71
|
+
const n = i.id ?? a + "-" + String(++m.current);
|
|
72
|
+
return r((s) => {
|
|
73
|
+
const l = { id: n, kind: o, options: i };
|
|
74
|
+
return s.some((d) => d.id === n) ? s.map((d) => d.id === n ? l : d) : [...s, l];
|
|
75
|
+
}), n;
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
showAlert: (o) => p("alert", o),
|
|
79
|
+
showToast: (o) => p("toast", o),
|
|
80
|
+
dismiss: (o) => r((i) => i.filter((n) => n.id !== o)),
|
|
81
|
+
dismissAll: () => r([]),
|
|
82
|
+
update: (o, i) => r(
|
|
83
|
+
(n) => n.map(
|
|
84
|
+
(s) => s.id === o ? {
|
|
85
|
+
...s,
|
|
86
|
+
options: {
|
|
87
|
+
...s.options,
|
|
88
|
+
...i,
|
|
89
|
+
viewport: N(s.options.viewport, i.viewport)
|
|
90
|
+
}
|
|
91
|
+
} : s
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
};
|
|
95
|
+
}, [a]), u = /* @__PURE__ */ new Map();
|
|
96
|
+
for (const p of c) {
|
|
97
|
+
const o = N(e, p.options.viewport), i = JSON.stringify(o), n = u.get(i);
|
|
98
|
+
n ? n.entries.push(p) : u.set(i, { viewport: o, entries: [p] });
|
|
99
|
+
}
|
|
100
|
+
return /* @__PURE__ */ P(C.Provider, { value: f, children: [
|
|
101
|
+
t,
|
|
102
|
+
[...u.entries()].map(([p, o]) => /* @__PURE__ */ h(g, { ...q(o.viewport), children: o.entries.map((i) => {
|
|
103
|
+
const { id: n, viewport: s, duration: l, onClose: d, ...w } = i.options, x = () => {
|
|
104
|
+
f.dismiss(i.id), d?.();
|
|
105
|
+
};
|
|
106
|
+
return /* @__PURE__ */ h(g, { pointerEvents: "auto", shrink: 0, maxWidth: "100%", children: i.kind === "toast" ? /* @__PURE__ */ h(j, { ...w, duration: l, onClose: x }) : /* @__PURE__ */ h(T, { ...w, onClose: x }) }, i.id);
|
|
107
|
+
}) }, p))
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
F as N,
|
|
112
|
+
D as u
|
|
113
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./notification-provider-C2ypXy2W.cjs");exports.NotificationProvider=i.NotificationProvider;exports.useNotifications=i.useNotifications;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { normalizeProgressBarRange, renderProgressBarView } from './progress-bar.helpers';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { ProgressBarRange, ProgressBarViewProps } from '../types/index';
|
|
3
|
+
/** Нормализует диапазон и конечное значение; процент всегда лежит в 0..100. */
|
|
4
|
+
export declare function normalizeProgressBarRange(value: number, min?: number, max?: number): ProgressBarRange;
|
|
5
|
+
/** Единая отрисовка дорожки, подписей и информационных отметок для готовых вариантов. */
|
|
6
|
+
export declare function renderProgressBarView({ range, variant, valuePlacement, marks, valueLabel, trackProps, fillProps, markerProps, renderMark, }: ProgressBarViewProps): JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { ProgressBarProps } from './types/index';
|
|
3
|
+
/** Линейный прогресс с четырьмя вариантами; адаптивные представления переключаются CSS без определения ширины в JS. */
|
|
4
|
+
export declare function ProgressBar({ value, min, max, variant, valuePlacement, label, ariaLabel, marks, valueLabel, trackProps, fillProps, markerProps, renderMark, md, lg, xl, ...props }: ProgressBarProps): JSX.Element;
|
|
5
|
+
export type { ProgressBarBreakpointProps, ProgressBarMark, ProgressBarMarkContext, ProgressBarOwnStyleProps, ProgressBarPartProps, ProgressBarProps, ProgressBarValuePlacement, ProgressBarVariant, } from './types/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ProgressBarBreakpointProps, ProgressBarMark, ProgressBarMarkContext, ProgressBarOwnStyleProps, ProgressBarPartProps, ProgressBarProps, ProgressBarRange, ProgressBarValuePlacement, ProgressBarVariant, ProgressBarViewProps, } from './progress-bar.types';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BoxProps } from '../../box/index';
|
|
3
|
+
import { FlexBreakpointProps, FlexProps } from '../../flex/index';
|
|
4
|
+
/** Готовое оформление: полоса, шаги, текущее значение на полосе или крупные контрольные точки. */
|
|
5
|
+
export type ProgressBarVariant = 'line' | 'steps' | 'marker' | 'checkpoints';
|
|
6
|
+
/** Место подписи значения; none явно скрывает её, в том числе на следующем breakpoint. */
|
|
7
|
+
export type ProgressBarValuePlacement = 'start' | 'end' | 'marker' | 'none';
|
|
8
|
+
/** Информационная отметка в диапазоне min–max; не является интерактивной кнопкой. */
|
|
9
|
+
export type ProgressBarMark = {
|
|
10
|
+
/** Числовое положение отметки; ограничивается диапазоном. */
|
|
11
|
+
value: number;
|
|
12
|
+
/** Произвольная подпись над отметкой. */
|
|
13
|
+
label?: ReactNode;
|
|
14
|
+
/** Содержимое точки; по умолчанию число для checkpoints и пустой круг для steps. */
|
|
15
|
+
content?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/** Контекст renderMark: состояния рассчитываются по положению относительно текущего значения. */
|
|
18
|
+
export type ProgressBarMarkContext = {
|
|
19
|
+
/** Исходная отметка. */
|
|
20
|
+
mark: ProgressBarMark;
|
|
21
|
+
/** Индекс в переданном массиве. */
|
|
22
|
+
index: number;
|
|
23
|
+
/** completed — позади текущего значения, current — совпадает, pending — впереди. */
|
|
24
|
+
state: 'completed' | 'current' | 'pending';
|
|
25
|
+
};
|
|
26
|
+
/** Стандартные props Box для части компонента; style имеет итоговый приоритет. */
|
|
27
|
+
export type ProgressBarPartProps = Omit<BoxProps, 'as' | 'children'>;
|
|
28
|
+
/** Визуальные настройки, доступные в base и responsive overrides. */
|
|
29
|
+
export type ProgressBarOwnStyleProps = {
|
|
30
|
+
/** Вариант оформления, по умолчанию line. */
|
|
31
|
+
variant?: ProgressBarVariant;
|
|
32
|
+
/** Положение значения; line по умолчанию start, marker — marker, steps/checkpoints — none. */
|
|
33
|
+
valuePlacement?: ProgressBarValuePlacement;
|
|
34
|
+
};
|
|
35
|
+
/** Переопределения от одного breakpoint: стандартные Flex props и настройки варианта. */
|
|
36
|
+
export type ProgressBarBreakpointProps = FlexBreakpointProps & ProgressBarOwnStyleProps;
|
|
37
|
+
/** Прогресс на базе Flex; md/lg/xl наследуются, явный style приоритетнее style props. */
|
|
38
|
+
export type ProgressBarProps = Omit<FlexProps, 'children' | 'md' | 'lg' | 'xl'> & ProgressBarOwnStyleProps & {
|
|
39
|
+
/** Текущее значение, ограничивается диапазоном; нечисловое конечное значение трактуется как min. */
|
|
40
|
+
value: number;
|
|
41
|
+
/** Начало диапазона, по умолчанию 0; нечисловое значение заменяется на 0. */
|
|
42
|
+
min?: number;
|
|
43
|
+
/** Конец диапазона, по умолчанию 100. Некорректный диапазон заменяется на min..min+100, а если он непредставим — на 0..100. */
|
|
44
|
+
max?: number;
|
|
45
|
+
/** Общая подпись над компонентом, принимает ReactNode. */
|
|
46
|
+
label?: ReactNode;
|
|
47
|
+
/** Доступное имя, по умолчанию «Прогресс». */
|
|
48
|
+
ariaLabel?: string;
|
|
49
|
+
/** Отметки; для steps/checkpoints по умолчанию min, середина и max. */
|
|
50
|
+
marks?: ReadonlyArray<ProgressBarMark>;
|
|
51
|
+
/** Собственная подпись вместо процента; null явно скрывает текст. */
|
|
52
|
+
valueLabel?: ReactNode;
|
|
53
|
+
/** Props дорожки, включая responsive размеры, className, style. */
|
|
54
|
+
trackProps?: ProgressBarPartProps;
|
|
55
|
+
/** Props заполнения; фон по умолчанию currentColor, ширина следует value. */
|
|
56
|
+
fillProps?: ProgressBarPartProps;
|
|
57
|
+
/** Props текущего маркера и точек, включая responsive размеры и style. */
|
|
58
|
+
markerProps?: ProgressBarPartProps;
|
|
59
|
+
/** Содержимое отдельной точки; не заменяет её позиционирующую обёртку. */
|
|
60
|
+
renderMark?: (context: ProgressBarMarkContext) => ReactNode;
|
|
61
|
+
/** Overrides от 768 px. */
|
|
62
|
+
md?: ProgressBarBreakpointProps;
|
|
63
|
+
/** Overrides от 1024 px; пропущенные значения наследуются от md. */
|
|
64
|
+
lg?: ProgressBarBreakpointProps;
|
|
65
|
+
/** Overrides от 1440 px; пропущенные значения наследуются от lg. */
|
|
66
|
+
xl?: ProgressBarBreakpointProps;
|
|
67
|
+
};
|
|
68
|
+
/** Внутренние нормализованные числовые параметры. */
|
|
69
|
+
export type ProgressBarRange = {
|
|
70
|
+
min: number;
|
|
71
|
+
max: number;
|
|
72
|
+
value: number;
|
|
73
|
+
percent: number;
|
|
74
|
+
};
|
|
75
|
+
/** Внутренний контекст отрисовки одного из адаптивных представлений. */
|
|
76
|
+
export type ProgressBarViewProps = Pick<ProgressBarProps, 'marks' | 'valueLabel' | 'trackProps' | 'fillProps' | 'markerProps' | 'renderMark'> & {
|
|
77
|
+
range: ProgressBarRange;
|
|
78
|
+
variant: ProgressBarVariant;
|
|
79
|
+
valuePlacement: ProgressBarValuePlacement;
|
|
80
|
+
};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { jsxs as F, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { a as O } from "./responsive-style.config-DFuATrIM.js";
|
|
3
|
+
import { Flex as p } from "./flex.js";
|
|
4
|
+
import { Box as c } from "./box.js";
|
|
5
|
+
function z(e, i = 0, l = 100) {
|
|
6
|
+
let r = Number.isFinite(i) ? i : 0, t = Number.isFinite(l) && l > r ? l : r + 100;
|
|
7
|
+
(!Number.isFinite(t) || t <= r) && (r = 0, t = 100);
|
|
8
|
+
const d = Number.isFinite(e) ? Math.min(t, Math.max(r, e)) : r;
|
|
9
|
+
return {
|
|
10
|
+
min: r,
|
|
11
|
+
max: t,
|
|
12
|
+
value: d,
|
|
13
|
+
percent: (Number.isFinite(t - r) ? (d - r) / (t - r) : (d / 2 - r / 2) / (t / 2 - r / 2)) * 100
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function W({
|
|
17
|
+
range: e,
|
|
18
|
+
variant: i,
|
|
19
|
+
valuePlacement: l,
|
|
20
|
+
marks: r,
|
|
21
|
+
valueLabel: t,
|
|
22
|
+
trackProps: d,
|
|
23
|
+
fillProps: P,
|
|
24
|
+
markerProps: f,
|
|
25
|
+
renderMark: x
|
|
26
|
+
}) {
|
|
27
|
+
const v = i === "steps", n = i === "checkpoints", g = v || n, h = t === void 0 ? Math.round(e.percent) + "%" : t, k = r ?? [
|
|
28
|
+
{ value: e.min },
|
|
29
|
+
{ value: e.min / 2 + e.max / 2 },
|
|
30
|
+
{ value: e.max }
|
|
31
|
+
], N = i === "marker" && t === void 0 ? e.value : h;
|
|
32
|
+
return /* @__PURE__ */ F(p, { gap: 12, align: "center", width: "100%", children: [
|
|
33
|
+
i === "marker" && /* @__PURE__ */ o(c, { color: "--color-text-secondary", children: e.min }),
|
|
34
|
+
l === "start" && /* @__PURE__ */ o(p, { shrink: 0, children: h }),
|
|
35
|
+
/* @__PURE__ */ o(
|
|
36
|
+
p,
|
|
37
|
+
{
|
|
38
|
+
flexDirection: "column",
|
|
39
|
+
position: { type: "relative" },
|
|
40
|
+
grow: 1,
|
|
41
|
+
minWidth: 0,
|
|
42
|
+
p: g ? {
|
|
43
|
+
px: n ? 20 : 10,
|
|
44
|
+
pt: v || k.some((a) => a.label != null) ? 40 : n ? 14 : 0,
|
|
45
|
+
pb: n ? 14 : 4
|
|
46
|
+
} : l === "marker" ? { py: 6 } : 0,
|
|
47
|
+
children: /* @__PURE__ */ F(
|
|
48
|
+
c,
|
|
49
|
+
{
|
|
50
|
+
position: { type: "relative" },
|
|
51
|
+
height: 12,
|
|
52
|
+
bg: "--color-background-subtle",
|
|
53
|
+
border: { radius: "999px" },
|
|
54
|
+
...d,
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ o(
|
|
57
|
+
c,
|
|
58
|
+
{
|
|
59
|
+
height: "100%",
|
|
60
|
+
width: e.percent + "%",
|
|
61
|
+
bg: "currentColor",
|
|
62
|
+
border: { radius: "inherit" },
|
|
63
|
+
...P
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
l === "marker" && /* @__PURE__ */ o(
|
|
67
|
+
p,
|
|
68
|
+
{
|
|
69
|
+
position: { type: "absolute", top: "50%", left: e.percent + "%" },
|
|
70
|
+
transform: "translate(-50%, -50%)",
|
|
71
|
+
align: "center",
|
|
72
|
+
justify: "center",
|
|
73
|
+
minWidth: 40,
|
|
74
|
+
height: 24,
|
|
75
|
+
p: { px: 8 },
|
|
76
|
+
bg: "currentColor",
|
|
77
|
+
border: { radius: "999px", width: "2px", color: "--color-background-default" },
|
|
78
|
+
...f,
|
|
79
|
+
children: /* @__PURE__ */ o(c, { color: "--color-background-default", children: N })
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
g && k.map((a, y) => {
|
|
83
|
+
const u = z(a.value, e.min, e.max), b = u.value === e.value ? "current" : u.value < e.value ? "completed" : "pending";
|
|
84
|
+
return /* @__PURE__ */ F(
|
|
85
|
+
p,
|
|
86
|
+
{
|
|
87
|
+
position: { type: "absolute", top: "50%", left: u.percent + "%" },
|
|
88
|
+
transform: "translate(-50%, -50%)",
|
|
89
|
+
align: "center",
|
|
90
|
+
justify: "center",
|
|
91
|
+
children: [
|
|
92
|
+
a.label != null && /* @__PURE__ */ o(
|
|
93
|
+
c,
|
|
94
|
+
{
|
|
95
|
+
position: { type: "absolute", bottom: "calc(100% + 10px)", left: "50%" },
|
|
96
|
+
transform: "translateX(-50%)",
|
|
97
|
+
bg: "--color-background-default",
|
|
98
|
+
color: "--color-text-primary",
|
|
99
|
+
p: { px: 8, py: 4 },
|
|
100
|
+
border: { radius: "4px" },
|
|
101
|
+
style: { whiteSpace: "nowrap", fontSize: 14 },
|
|
102
|
+
children: a.label
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ o(
|
|
106
|
+
p,
|
|
107
|
+
{
|
|
108
|
+
align: "center",
|
|
109
|
+
justify: "center",
|
|
110
|
+
width: n ? 40 : 20,
|
|
111
|
+
height: n ? 40 : 20,
|
|
112
|
+
bg: b === "pending" && n ? "--color-background-subtle" : "currentColor",
|
|
113
|
+
border: { radius: "50%", width: "2px", color: "--color-background-default" },
|
|
114
|
+
...f,
|
|
115
|
+
children: /* @__PURE__ */ o(
|
|
116
|
+
c,
|
|
117
|
+
{
|
|
118
|
+
color: b === "pending" && n ? "--color-text-secondary" : "--color-background-default",
|
|
119
|
+
children: x ? x({ mark: a, index: y, state: b }) : a.content ?? (n ? a.value : /* @__PURE__ */ o(
|
|
120
|
+
c,
|
|
121
|
+
{
|
|
122
|
+
width: 12,
|
|
123
|
+
height: 12,
|
|
124
|
+
border: {
|
|
125
|
+
radius: "50%",
|
|
126
|
+
width: "1px",
|
|
127
|
+
color: "--color-background-default"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
))
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
y
|
|
138
|
+
);
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
l === "end" && /* @__PURE__ */ o(p, { shrink: 0, children: h }),
|
|
146
|
+
i === "marker" && /* @__PURE__ */ o(c, { color: "--color-text-secondary", children: e.max })
|
|
147
|
+
] });
|
|
148
|
+
}
|
|
149
|
+
function q({
|
|
150
|
+
value: e,
|
|
151
|
+
min: i,
|
|
152
|
+
max: l,
|
|
153
|
+
variant: r = "line",
|
|
154
|
+
valuePlacement: t,
|
|
155
|
+
label: d,
|
|
156
|
+
ariaLabel: P = "Прогресс",
|
|
157
|
+
marks: f,
|
|
158
|
+
valueLabel: x,
|
|
159
|
+
trackProps: v,
|
|
160
|
+
fillProps: n,
|
|
161
|
+
markerProps: g,
|
|
162
|
+
renderMark: h,
|
|
163
|
+
md: k,
|
|
164
|
+
lg: N,
|
|
165
|
+
xl: a,
|
|
166
|
+
...y
|
|
167
|
+
}) {
|
|
168
|
+
const u = z(e, i, l), b = ["line", "steps", "marker", "checkpoints"], D = ["start", "end", "marker", "none"], C = { md: k, lg: N, xl: a }, w = [{ variant: r, valuePlacement: t }];
|
|
169
|
+
for (const s of O)
|
|
170
|
+
w.push({
|
|
171
|
+
variant: C[s]?.variant ?? w.at(-1)?.variant ?? r,
|
|
172
|
+
valuePlacement: C[s]?.valuePlacement ?? w.at(-1)?.valuePlacement
|
|
173
|
+
});
|
|
174
|
+
const E = Object.fromEntries(
|
|
175
|
+
O.map((s) => {
|
|
176
|
+
const { variant: j, valuePlacement: B, ...M } = C[s] ?? {};
|
|
177
|
+
return [s, M];
|
|
178
|
+
})
|
|
179
|
+
);
|
|
180
|
+
return /* @__PURE__ */ F(
|
|
181
|
+
p,
|
|
182
|
+
{
|
|
183
|
+
flexDirection: "column",
|
|
184
|
+
gap: 12,
|
|
185
|
+
width: "100%",
|
|
186
|
+
color: "--color-primary-accent",
|
|
187
|
+
role: "progressbar",
|
|
188
|
+
"aria-label": P,
|
|
189
|
+
"aria-valuemin": u.min,
|
|
190
|
+
"aria-valuemax": u.max,
|
|
191
|
+
"aria-valuenow": u.value,
|
|
192
|
+
...E,
|
|
193
|
+
...y,
|
|
194
|
+
children: [
|
|
195
|
+
d != null && /* @__PURE__ */ o(c, { children: d }),
|
|
196
|
+
b.flatMap(
|
|
197
|
+
(s) => D.map((j) => {
|
|
198
|
+
const B = w.map(
|
|
199
|
+
(m) => m.variant === s && (m.valuePlacement ?? (m.variant === "line" ? "start" : m.variant === "marker" ? "marker" : "none")) === j
|
|
200
|
+
);
|
|
201
|
+
if (!B.some(Boolean)) return null;
|
|
202
|
+
const M = Object.fromEntries(
|
|
203
|
+
O.map((m, S) => [
|
|
204
|
+
m,
|
|
205
|
+
{ display: B[S + 1] ? "flex" : "hidden" }
|
|
206
|
+
])
|
|
207
|
+
);
|
|
208
|
+
return /* @__PURE__ */ o(
|
|
209
|
+
c,
|
|
210
|
+
{
|
|
211
|
+
width: "100%",
|
|
212
|
+
display: B[0] ? "flex" : "hidden",
|
|
213
|
+
...M,
|
|
214
|
+
children: W({
|
|
215
|
+
range: u,
|
|
216
|
+
variant: s,
|
|
217
|
+
valuePlacement: j,
|
|
218
|
+
marks: f,
|
|
219
|
+
valueLabel: x,
|
|
220
|
+
trackProps: v,
|
|
221
|
+
fillProps: n,
|
|
222
|
+
markerProps: g,
|
|
223
|
+
renderMark: h
|
|
224
|
+
})
|
|
225
|
+
},
|
|
226
|
+
s + j
|
|
227
|
+
);
|
|
228
|
+
})
|
|
229
|
+
)
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
export {
|
|
235
|
+
q as P
|
|
236
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),C=require("./responsive-style.config-B2m9jVlX.cjs"),p=require("./flex.cjs"),c=require("./box.cjs");function M(e,i=0,s=100){let t=Number.isFinite(i)?i:0,o=Number.isFinite(s)&&s>t?s:t+100;(!Number.isFinite(o)||o<=t)&&(t=0,o=100);const u=Number.isFinite(e)?Math.min(o,Math.max(t,e)):t;return{min:t,max:o,value:u,percent:(Number.isFinite(o-t)?(u-t)/(o-t):(u/2-t/2)/(o/2-t/2))*100}}function z({range:e,variant:i,valuePlacement:s,marks:t,valueLabel:o,trackProps:u,fillProps:w,markerProps:b,renderMark:f}){const v=i==="steps",n=i==="checkpoints",j=v||n,h=o===void 0?Math.round(e.percent)+"%":o,g=t??[{value:e.min},{value:e.min/2+e.max/2},{value:e.max}],P=i==="marker"&&o===void 0?e.value:h;return r.jsxs(p.Flex,{gap:12,align:"center",width:"100%",children:[i==="marker"&&r.jsx(c.Box,{color:"--color-text-secondary",children:e.min}),s==="start"&&r.jsx(p.Flex,{shrink:0,children:h}),r.jsx(p.Flex,{flexDirection:"column",position:{type:"relative"},grow:1,minWidth:0,p:j?{px:n?20:10,pt:v||g.some(l=>l.label!=null)?40:n?14:0,pb:n?14:4}:s==="marker"?{py:6}:0,children:r.jsxs(c.Box,{position:{type:"relative"},height:12,bg:"--color-background-subtle",border:{radius:"999px"},...u,children:[r.jsx(c.Box,{height:"100%",width:e.percent+"%",bg:"currentColor",border:{radius:"inherit"},...w}),s==="marker"&&r.jsx(p.Flex,{position:{type:"absolute",top:"50%",left:e.percent+"%"},transform:"translate(-50%, -50%)",align:"center",justify:"center",minWidth:40,height:24,p:{px:8},bg:"currentColor",border:{radius:"999px",width:"2px",color:"--color-background-default"},...b,children:r.jsx(c.Box,{color:"--color-background-default",children:P})}),j&&g.map((l,k)=>{const d=M(l.value,e.min,e.max),m=d.value===e.value?"current":d.value<e.value?"completed":"pending";return r.jsxs(p.Flex,{position:{type:"absolute",top:"50%",left:d.percent+"%"},transform:"translate(-50%, -50%)",align:"center",justify:"center",children:[l.label!=null&&r.jsx(c.Box,{position:{type:"absolute",bottom:"calc(100% + 10px)",left:"50%"},transform:"translateX(-50%)",bg:"--color-background-default",color:"--color-text-primary",p:{px:8,py:4},border:{radius:"4px"},style:{whiteSpace:"nowrap",fontSize:14},children:l.label}),r.jsx(p.Flex,{align:"center",justify:"center",width:n?40:20,height:n?40:20,bg:m==="pending"&&n?"--color-background-subtle":"currentColor",border:{radius:"50%",width:"2px",color:"--color-background-default"},...b,children:r.jsx(c.Box,{color:m==="pending"&&n?"--color-text-secondary":"--color-background-default",children:f?f({mark:l,index:k,state:m}):l.content??(n?l.value:r.jsx(c.Box,{width:12,height:12,border:{radius:"50%",width:"1px",color:"--color-background-default"}}))})})]},k)})]})}),s==="end"&&r.jsx(p.Flex,{shrink:0,children:h}),i==="marker"&&r.jsx(c.Box,{color:"--color-text-secondary",children:e.max})]})}function D({value:e,min:i,max:s,variant:t="line",valuePlacement:o,label:u,ariaLabel:w="Прогресс",marks:b,valueLabel:f,trackProps:v,fillProps:n,markerProps:j,renderMark:h,md:g,lg:P,xl:l,...k}){const d=M(e,i,s),m=["line","steps","marker","checkpoints"],O=["start","end","marker","none"],N={md:g,lg:P,xl:l},B=[{variant:t,valuePlacement:o}];for(const a of C.responsiveBreakpoints)B.push({variant:N[a]?.variant??B.at(-1)?.variant??t,valuePlacement:N[a]?.valuePlacement??B.at(-1)?.valuePlacement});const S=Object.fromEntries(C.responsiveBreakpoints.map(a=>{const{variant:y,valuePlacement:F,...q}=N[a]??{};return[a,q]}));return r.jsxs(p.Flex,{flexDirection:"column",gap:12,width:"100%",color:"--color-primary-accent",role:"progressbar","aria-label":w,"aria-valuemin":d.min,"aria-valuemax":d.max,"aria-valuenow":d.value,...S,...k,children:[u!=null&&r.jsx(c.Box,{children:u}),m.flatMap(a=>O.map(y=>{const F=B.map(x=>x.variant===a&&(x.valuePlacement??(x.variant==="line"?"start":x.variant==="marker"?"marker":"none"))===y);if(!F.some(Boolean))return null;const q=Object.fromEntries(C.responsiveBreakpoints.map((x,_)=>[x,{display:F[_+1]?"flex":"hidden"}]));return r.jsx(c.Box,{width:"100%",display:F[0]?"flex":"hidden",...q,children:z({range:d,variant:a,valuePlacement:y,marks:b,valueLabel:f,trackProps:v,fillProps:n,markerProps:j,renderMark:h})},a+y)}))]})}exports.ProgressBar=D;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./progress-bar-XIJDb_UM.cjs");exports.ProgressBar=r.ProgressBar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { responsiveBreakpointMinWidth, responsiveBreakpoints } from './responsive-style.config';
|