@shmidko61/lc-ui-kit 0.11.0 → 0.13.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 +89 -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 +2 -2
- package/dist/box/box.types.d.ts +21 -1
- package/dist/box/index.d.ts +1 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +262 -203
- 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 +152 -141
- 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/flex.cjs +1 -1
- package/dist/flex.js +18 -18
- package/dist/grid.cjs +1 -1
- package/dist/grid.js +57 -57
- 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 +7 -3
- package/dist/index.js +101 -90
- package/dist/input/input.types.d.ts +1 -1
- 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/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/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/typography/index.d.ts +1 -0
- package/dist/typography/typography.helpers.d.ts +1 -1
- package/package.json +35 -4
- package/dist/vite.config.d.ts +0 -2
|
@@ -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 { responsiveBreakpointMinWidth, responsiveBreakpoints } from './responsive-style.config';
|