@shmidko61/lc-ui-kit 0.13.0 → 0.16.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 +61 -0
- package/dist/box/box.d.ts +2 -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/box-scrollbar.helpers.d.ts +7 -0
- package/dist/box/helpers/index.d.ts +2 -0
- package/dist/box/types/box-animation.types.d.ts +3 -0
- package/dist/box/types/box-scrollbar.types.d.ts +7 -0
- package/dist/box/types/index.d.ts +2 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +476 -307
- package/dist/button.cjs +1 -1
- package/dist/button.js +163 -156
- package/dist/flex/flex.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +70 -62
- 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/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/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/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 +2 -0
- package/dist/types/scrollbar.types.d.ts +33 -0
- package/package.json +44 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getTabsIds, getTabsVariantProps, mergeTabsProps } from './tabs.helpers';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TabsContextValue, TabsIds, TabsVisualProps } from '../types/index';
|
|
2
|
+
/** Объединяет только составные style props по полям, className — строками, события — последовательно. */
|
|
3
|
+
export declare function mergeTabsProps<T extends object>(...sources: Array<T | undefined>): T;
|
|
4
|
+
/** Генерирует одинаковые ID для trigger/panel без зависимости от порядка рендера. */
|
|
5
|
+
export declare function getTabsIds(id: string, value: string): TabsIds;
|
|
6
|
+
/** Создаёт props оформления через стандартную responsive CSS-variable pipeline ui-kit. */
|
|
7
|
+
export declare function getTabsVariantProps(variants: TabsContextValue['variants'], part: 'list' | 'trigger', selected?: boolean): TabsVisualProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TabsContext, useTabsContext } from './tabs.hooks';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TabsContextValue } from '../types/index';
|
|
2
|
+
/** Внутренний контекст ближайшего Tabs, вложенные наборы изолированы. */
|
|
3
|
+
export declare const TabsContext: import('react').Context<TabsContextValue | null>;
|
|
4
|
+
/** Получает ближайший Tabs или сообщает об использовании части без корня. */
|
|
5
|
+
export declare function useTabsContext(): TabsContextValue;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TabsComponent } from './types/index';
|
|
2
|
+
/** Составной Tabs с List, Trigger и Panel; все публичные части поддерживают ref и стандартные style props. */
|
|
3
|
+
export declare const Tabs: TabsComponent;
|
|
4
|
+
export type { TabsBreakpointProps, TabsComponent, TabsListProps, TabsPanelAppearanceProps, TabsPanelProps, TabsProps, TabsSelectedStyleProps, TabsTriggerAppearanceProps, TabsTriggerProps, TabsVariant, } from './types/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { TabsBreakpointProps, TabsComponent, TabsComposedEvent, TabsContextValue, TabsIds, TabsListProps, TabsPanelAppearanceProps, TabsPanelProps, TabsProps, TabsSelectedStyleProps, TabsTriggerAppearanceProps, TabsTriggerProps, TabsVariant, TabsVisualProps, } from './tabs.types';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, ReactNode, RefAttributes, RefObject } from 'react';
|
|
2
|
+
import { BoxBreakpointProps, BoxProps } from '../../box/index';
|
|
3
|
+
import { ButtonProps } from '../../button/index';
|
|
4
|
+
import { FlexBreakpointProps, FlexProps } from '../../flex/index';
|
|
5
|
+
/** Готовые оформления Tabs: pills из макета, подчёркивание или plain. */
|
|
6
|
+
export type TabsVariant = 'pills' | 'underline' | 'plain';
|
|
7
|
+
/** Визуальные настройки активной вкладки; не содержат событий и служебных ARIA props. */
|
|
8
|
+
export type TabsSelectedStyleProps = BoxBreakpointProps & {
|
|
9
|
+
/** Overrides от 768 px. */ md?: BoxBreakpointProps;
|
|
10
|
+
/** Overrides от 1024 px. */ lg?: BoxBreakpointProps;
|
|
11
|
+
/** Overrides от 1440 px. */ xl?: BoxBreakpointProps;
|
|
12
|
+
};
|
|
13
|
+
/** Props кнопки ui-kit без ссылок и служебных атрибутов вкладки. */
|
|
14
|
+
export type TabsTriggerAppearanceProps = Omit<Extract<ButtonProps, {
|
|
15
|
+
href?: undefined;
|
|
16
|
+
}>, 'href' | 'children' | 'id' | 'role' | 'tabIndex' | 'aria-controls' | 'aria-selected' | 'type'>;
|
|
17
|
+
/** Общие настройки панели на базе Box. */
|
|
18
|
+
export type TabsPanelAppearanceProps = Omit<BoxProps, 'as' | 'children' | 'id' | 'role' | 'hidden' | 'aria-labelledby'>;
|
|
19
|
+
/** Настройки списка вкладок на базе Flex. */
|
|
20
|
+
export type TabsListProps = Omit<FlexProps, 'as' | 'role' | 'aria-orientation'>;
|
|
21
|
+
/** Responsive-настройки корневого компонента. */
|
|
22
|
+
export type TabsBreakpointProps = FlexBreakpointProps & {
|
|
23
|
+
/** Оформление на breakpoint; пропущенное наследуется. */ variant?: TabsVariant;
|
|
24
|
+
};
|
|
25
|
+
/** Корень Tabs. Общие props частей дополняются локальными props; style имеет приоритет. */
|
|
26
|
+
export type TabsProps = Omit<FlexProps, 'as' | 'defaultValue' | 'md' | 'lg' | 'xl'> & {
|
|
27
|
+
/** Управляемое активное значение. */ value?: string;
|
|
28
|
+
/** Начальная вкладка; без неё выбирается первая доступная в DOM. */ defaultValue?: string;
|
|
29
|
+
/** Запрос переключения вкладки. */ onValueChange?: (value: string) => void;
|
|
30
|
+
/** Оформление, по умолчанию pills. */ variant?: TabsVariant;
|
|
31
|
+
/** Направление и клавиатурная ось, по умолчанию horizontal. */ orientation?: 'horizontal' | 'vertical';
|
|
32
|
+
/** automatic выбирает при движении фокуса; manual требует Enter/Space. По умолчанию automatic. */ activationMode?: 'automatic' | 'manual';
|
|
33
|
+
/** Зацикливать стрелки, по умолчанию true. */ loop?: boolean;
|
|
34
|
+
/** Общие Flex props списка, включая события и style. */ listProps?: TabsListProps;
|
|
35
|
+
/** Общие props кнопок; события объединяются с локальными. */ triggerProps?: TabsTriggerAppearanceProps;
|
|
36
|
+
/** Общие визуальные props выбранной кнопки. */ selectedTriggerProps?: TabsSelectedStyleProps;
|
|
37
|
+
/** Общие Box props панелей. */ panelProps?: TabsPanelAppearanceProps;
|
|
38
|
+
/** Overrides от 768 px. */ md?: TabsBreakpointProps;
|
|
39
|
+
/** Overrides от 1024 px; наследуются от md. */ lg?: TabsBreakpointProps;
|
|
40
|
+
/** Overrides от 1440 px; наследуются от lg. */ xl?: TabsBreakpointProps;
|
|
41
|
+
};
|
|
42
|
+
/** Кнопка вкладки: value уникально внутри корня. */
|
|
43
|
+
export type TabsTriggerProps = TabsTriggerAppearanceProps & {
|
|
44
|
+
/** Значение вкладки. */ value: string;
|
|
45
|
+
/** Содержимое кнопки. */ children?: ReactNode;
|
|
46
|
+
/** Произвольный слот перед содержимым. */ startSlot?: ReactNode;
|
|
47
|
+
/** Произвольный слот после содержимого. */ endSlot?: ReactNode;
|
|
48
|
+
/** Визуальные overrides выбранного состояния поверх общих selectedTriggerProps. */ selectedProps?: TabsSelectedStyleProps;
|
|
49
|
+
};
|
|
50
|
+
/** Панель выбранной вкладки. */
|
|
51
|
+
export type TabsPanelProps = TabsPanelAppearanceProps & {
|
|
52
|
+
/** Значение соответствующего Trigger. */ value: string;
|
|
53
|
+
/** Содержимое панели. */ children?: ReactNode;
|
|
54
|
+
/** Сохранять содержимое скрытой панели, по умолчанию true. */ keepMounted?: boolean;
|
|
55
|
+
};
|
|
56
|
+
/** Внутренние свойства контекста Tabs. */
|
|
57
|
+
export type TabsContextValue = {
|
|
58
|
+
id: string;
|
|
59
|
+
selected?: string;
|
|
60
|
+
/** Доступная точка входа с Tab, в том числе при недоступном controlled value. */
|
|
61
|
+
tabStop?: string;
|
|
62
|
+
select: (value: string) => void;
|
|
63
|
+
register: () => () => void;
|
|
64
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
65
|
+
orientation: 'horizontal' | 'vertical';
|
|
66
|
+
activationMode: 'automatic' | 'manual';
|
|
67
|
+
loop: boolean;
|
|
68
|
+
variants: {
|
|
69
|
+
base: TabsVariant;
|
|
70
|
+
md?: TabsVariant;
|
|
71
|
+
lg?: TabsVariant;
|
|
72
|
+
xl?: TabsVariant;
|
|
73
|
+
};
|
|
74
|
+
listProps?: TabsListProps;
|
|
75
|
+
triggerProps?: TabsTriggerAppearanceProps;
|
|
76
|
+
selectedTriggerProps?: TabsSelectedStyleProps;
|
|
77
|
+
panelProps?: TabsPanelAppearanceProps;
|
|
78
|
+
};
|
|
79
|
+
/** Внутренние общие визуальные props для вариантов. */
|
|
80
|
+
export type TabsVisualProps = TabsSelectedStyleProps;
|
|
81
|
+
/** Внутренние ID связанных элементов. */
|
|
82
|
+
export type TabsIds = {
|
|
83
|
+
trigger: string;
|
|
84
|
+
panel: string;
|
|
85
|
+
};
|
|
86
|
+
/** Минимальный контракт события для объединения общих и локальных callbacks. */
|
|
87
|
+
export type TabsComposedEvent = {
|
|
88
|
+
defaultPrevented?: boolean;
|
|
89
|
+
};
|
|
90
|
+
/** Составной компонент и типизированные части с публичными DOM refs. */
|
|
91
|
+
export type TabsComponent = ForwardRefExoticComponent<TabsProps & RefAttributes<HTMLDivElement>> & {
|
|
92
|
+
/** Список вкладок. */ List: ForwardRefExoticComponent<TabsListProps & RefAttributes<HTMLDivElement>>;
|
|
93
|
+
/** Кнопка вкладки. */ Trigger: ForwardRefExoticComponent<TabsTriggerProps & RefAttributes<HTMLButtonElement>>;
|
|
94
|
+
/** Панель вкладки. */ Panel: ForwardRefExoticComponent<TabsPanelProps & RefAttributes<HTMLDivElement>>;
|
|
95
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";const m=require("react/jsx-runtime"),a=require("react"),R=require("./flex.cjs"),W=require("./responsive-style.config-B2m9jVlX.cjs"),Z=require("./box.cjs"),G=require("./button.cjs");function h(...u){const e={},l=new Set(["md","lg","xl","border","position","p","m","hover","focusVisible","active","disabledStyle","style"]);for(const i of u)for(const[s,r]of Object.entries(i??{})){if(r===void 0)continue;const t=e[s];s==="className"?e[s]=[t,r].filter(Boolean).join(" "):/^on[A-Z]/.test(s)&&typeof t=="function"&&typeof r=="function"?e[s]=n=>{t(n),n.defaultPrevented||r(n)}:l.has(s)&&t&&r&&typeof t=="object"&&typeof r=="object"&&!Array.isArray(t)&&!Array.isArray(r)?e[s]=h(t,r):e[s]=r}return e}function B(u,e){const l=encodeURIComponent(e);return{trigger:u+"-tab-"+l,panel:u+"-panel-"+l}}function L(u,e,l=!1){const i=r=>e==="list"?{bg:r==="pills"?"--color-background-subtle":"transparent",border:{radius:r==="pills"?"999px":"0px"},p:r==="pills"?4:0}:{bg:l&&r==="pills"?"--color-primary-accent":"transparent",color:l?r==="pills"?"--color-background-default":"--color-primary-accent":"--color-text-primary",border:{radius:r==="pills"?"999px":"0px",width:"0px"},...r==="underline"?{border:{radius:"0px",style:"solid",width:{top:"0px",right:"0px",bottom:"2px",left:"0px"},color:l?"--color-primary-accent":"transparent"}}:{}},s=i(u.base);for(const r of W.responsiveBreakpoints)u[r]&&(s[r]=i(u[r]));return s}const F=a.createContext(null);function C(){const u=a.useContext(F);if(!u)throw new Error("Tabs parts require a Tabs root");return u}const J=a.forwardRef(function({value:e,defaultValue:l,onValueChange:i,variant:s="pills",orientation:r="horizontal",activationMode:t="automatic",loop:n=!0,listProps:o,triggerProps:f,selectedTriggerProps:g,panelProps:y,md:c,lg:p,xl:b,children:O,...V},T){const w=a.useId(),A=a.useRef(null),[S,j]=a.useState(l),[E,P]=a.useState(0),[q,_]=a.useState(e??l),k=e??S,D=a.useCallback(d=>{d!==k&&(e===void 0&&j(d),i?.(d))},[e,k,i]),I=a.useCallback(()=>(P(d=>d+1),()=>P(d=>d+1)),[]);a.useEffect(()=>{const d=Array.from(A.current?.querySelectorAll("[role=tab]")??[]).filter(x=>x.dataset.lcTabsOwner===w&&!x.disabled),K=d.find(x=>x.dataset.lcTabsValue===(e??S))?.dataset.lcTabsValue??d[0]?.dataset.lcTabsValue;_(K),e===void 0&&!d.some(x=>x.dataset.lcTabsValue===S)&&j(K)},[E,S,w,e]);const z=a.useMemo(()=>({id:w,selected:k,tabStop:q,select:D,register:I,rootRef:A,orientation:r,activationMode:t,loop:n,variants:{base:s,md:c?.variant,lg:p?.variant,xl:b?.variant},listProps:o,triggerProps:f,selectedTriggerProps:g,panelProps:y}),[w,k,q,D,I,r,t,n,s,c?.variant,p?.variant,b?.variant,o,f,g,y]),{variant:v,...M}=c??{},{variant:tt,...H}=p??{},{variant:et,...U}=b??{},N=a.useCallback(d=>{if(A.current=d,typeof T=="function")return T(d);T&&(T.current=d)},[T]);return m.jsx(F.Provider,{value:z,children:m.jsx(R.Flex,{flexDirection:"column",gap:16,...V,md:M,lg:H,xl:U,ref:N,children:O})})}),Q=a.forwardRef(function(e,l){const i=C(),s=h({inline:!0,width:"fit-content",gap:4,flexDirection:i.orientation==="vertical"?"column":"row"},L(i.variants,"list"),i.listProps,e),r=t=>{if(s.onKeyDown?.(t),t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey)return;const n=Array.from(t.currentTarget.querySelectorAll("[role=tab]")).filter(p=>!p.disabled&&p.getClientRects().length>0&&p.closest("[role=tablist]")===t.currentTarget),o=n.indexOf(t.target);if(o<0||!n.length)return;const f=getComputedStyle(t.currentTarget).direction==="rtl",g=i.orientation==="vertical"?"ArrowDown":f?"ArrowLeft":"ArrowRight",y=i.orientation==="vertical"?"ArrowUp":f?"ArrowRight":"ArrowLeft";let c=o;if(t.key==="Home")c=0;else if(t.key==="End")c=n.length-1;else if(t.key===g)c=i.loop?(o+1)%n.length:Math.min(o+1,n.length-1);else if(t.key===y)c=i.loop?(o-1+n.length)%n.length:Math.max(o-1,0);else return;t.preventDefault(),n[c].focus()};return m.jsx(R.Flex,{...s,ref:l,role:"tablist","aria-orientation":i.orientation,onKeyDown:r})}),X=a.forwardRef(function({value:e,startSlot:l,endSlot:i,selectedProps:s,children:r,...t},n){const o=C(),f=o.selected===e,g=B(o.id,e),y=h({size:"sm",p:{px:12,py:8},fontSize:"13px",lineHeight:"16px",focusVisible:{outlineStyle:"solid",outlineWidth:"2px",outlineColor:"--color-primary-accent",outlineOffset:"2px"}},L(o.variants,"trigger",f),o.triggerProps,t),c=h(y,f?o.selectedTriggerProps:void 0,f?s:void 0);c.style={...o.triggerProps?.style,...t.style};const p=!!c.disabled||!!c.isLoading;return a.useEffect(()=>o.register(),[o.register,e,p]),m.jsx(G.Button,{...c,ref:n,id:g.trigger,type:"button",role:"tab","data-lc-tabs-owner":o.id,"data-lc-tabs-value":e,"aria-selected":f,"aria-controls":g.panel,tabIndex:o.tabStop===e&&!p?0:-1,onClick:b=>{c.onClick?.(b),!b.defaultPrevented&&!p&&o.select(e)},onFocus:b=>{c.onFocus?.(b),!b.defaultPrevented&&o.activationMode==="automatic"&&!p&&o.select(e)},children:m.jsxs(R.Flex,{as:"span",align:"center",gap:6,children:[l,r,i]})})}),Y=a.forwardRef(function({value:e,children:l,keepMounted:i=!0,...s},r){const t=C(),n=t.selected===e,o=B(t.id,e),f=h(t.panelProps,s);return m.jsx(Z.Box,{...f,ref:r,id:o.panel,role:"tabpanel","aria-labelledby":o.trigger,tabIndex:f.tabIndex??0,hidden:!n,style:{...f.style,...n?{}:{display:"none"}},children:n||i?l:null})}),$=Object.assign(J,{List:Q,Trigger:X,Panel:Y});exports.Tabs=$;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as x, jsxs as J } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as Q, useContext as X, forwardRef as S, useId as Y, useRef as $, useState as C, useCallback as P, useEffect as V, useMemo as v } from "react";
|
|
4
|
+
import { Flex as R } from "./flex.js";
|
|
5
|
+
import { a as tt } from "./responsive-style.config-DFuATrIM.js";
|
|
6
|
+
import { Box as et } from "./box.js";
|
|
7
|
+
import { Button as ot } from "./button.js";
|
|
8
|
+
function T(...c) {
|
|
9
|
+
const e = {}, l = /* @__PURE__ */ new Set([
|
|
10
|
+
"md",
|
|
11
|
+
"lg",
|
|
12
|
+
"xl",
|
|
13
|
+
"border",
|
|
14
|
+
"position",
|
|
15
|
+
"p",
|
|
16
|
+
"m",
|
|
17
|
+
"hover",
|
|
18
|
+
"focusVisible",
|
|
19
|
+
"active",
|
|
20
|
+
"disabledStyle",
|
|
21
|
+
"style"
|
|
22
|
+
]);
|
|
23
|
+
for (const i of c)
|
|
24
|
+
for (const [n, o] of Object.entries(i ?? {})) {
|
|
25
|
+
if (o === void 0) continue;
|
|
26
|
+
const t = e[n];
|
|
27
|
+
n === "className" ? e[n] = [t, o].filter(Boolean).join(" ") : /^on[A-Z]/.test(n) && typeof t == "function" && typeof o == "function" ? e[n] = (s) => {
|
|
28
|
+
t(s), s.defaultPrevented || o(s);
|
|
29
|
+
} : l.has(n) && t && o && typeof t == "object" && typeof o == "object" && !Array.isArray(t) && !Array.isArray(o) ? e[n] = T(t, o) : e[n] = o;
|
|
30
|
+
}
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
function q(c, e) {
|
|
34
|
+
const l = encodeURIComponent(e);
|
|
35
|
+
return { trigger: c + "-tab-" + l, panel: c + "-panel-" + l };
|
|
36
|
+
}
|
|
37
|
+
function z(c, e, l = !1) {
|
|
38
|
+
const i = (o) => e === "list" ? {
|
|
39
|
+
bg: o === "pills" ? "--color-background-subtle" : "transparent",
|
|
40
|
+
border: { radius: o === "pills" ? "999px" : "0px" },
|
|
41
|
+
p: o === "pills" ? 4 : 0
|
|
42
|
+
} : {
|
|
43
|
+
bg: l && o === "pills" ? "--color-primary-accent" : "transparent",
|
|
44
|
+
color: l ? o === "pills" ? "--color-background-default" : "--color-primary-accent" : "--color-text-primary",
|
|
45
|
+
border: { radius: o === "pills" ? "999px" : "0px", width: "0px" },
|
|
46
|
+
...o === "underline" ? {
|
|
47
|
+
border: {
|
|
48
|
+
radius: "0px",
|
|
49
|
+
style: "solid",
|
|
50
|
+
width: { top: "0px", right: "0px", bottom: "2px", left: "0px" },
|
|
51
|
+
color: l ? "--color-primary-accent" : "transparent"
|
|
52
|
+
}
|
|
53
|
+
} : {}
|
|
54
|
+
}, n = i(c.base);
|
|
55
|
+
for (const o of tt) c[o] && (n[o] = i(c[o]));
|
|
56
|
+
return n;
|
|
57
|
+
}
|
|
58
|
+
const E = Q(null);
|
|
59
|
+
function j() {
|
|
60
|
+
const c = X(E);
|
|
61
|
+
if (!c) throw new Error("Tabs parts require a Tabs root");
|
|
62
|
+
return c;
|
|
63
|
+
}
|
|
64
|
+
const rt = S(function({
|
|
65
|
+
value: e,
|
|
66
|
+
defaultValue: l,
|
|
67
|
+
onValueChange: i,
|
|
68
|
+
variant: n = "pills",
|
|
69
|
+
orientation: o = "horizontal",
|
|
70
|
+
activationMode: t = "automatic",
|
|
71
|
+
loop: s = !0,
|
|
72
|
+
listProps: r,
|
|
73
|
+
triggerProps: f,
|
|
74
|
+
selectedTriggerProps: b,
|
|
75
|
+
panelProps: g,
|
|
76
|
+
md: a,
|
|
77
|
+
lg: u,
|
|
78
|
+
xl: p,
|
|
79
|
+
children: F,
|
|
80
|
+
...M
|
|
81
|
+
}, m) {
|
|
82
|
+
const h = Y(), k = $(null), [w, D] = C(l), [_, I] = C(0), [K, H] = C(e ?? l), A = e ?? w, B = P(
|
|
83
|
+
(d) => {
|
|
84
|
+
d !== A && (e === void 0 && D(d), i?.(d));
|
|
85
|
+
},
|
|
86
|
+
[e, A, i]
|
|
87
|
+
), L = P(() => (I((d) => d + 1), () => I((d) => d + 1)), []);
|
|
88
|
+
V(() => {
|
|
89
|
+
const d = Array.from(
|
|
90
|
+
k.current?.querySelectorAll("[role=tab]") ?? []
|
|
91
|
+
).filter((y) => y.dataset.lcTabsOwner === h && !y.disabled), O = d.find((y) => y.dataset.lcTabsValue === (e ?? w))?.dataset.lcTabsValue ?? d[0]?.dataset.lcTabsValue;
|
|
92
|
+
H(O), e === void 0 && !d.some((y) => y.dataset.lcTabsValue === w) && D(O);
|
|
93
|
+
}, [_, w, h, e]);
|
|
94
|
+
const U = v(
|
|
95
|
+
() => ({
|
|
96
|
+
id: h,
|
|
97
|
+
selected: A,
|
|
98
|
+
tabStop: K,
|
|
99
|
+
select: B,
|
|
100
|
+
register: L,
|
|
101
|
+
rootRef: k,
|
|
102
|
+
orientation: o,
|
|
103
|
+
activationMode: t,
|
|
104
|
+
loop: s,
|
|
105
|
+
variants: { base: n, md: a?.variant, lg: u?.variant, xl: p?.variant },
|
|
106
|
+
listProps: r,
|
|
107
|
+
triggerProps: f,
|
|
108
|
+
selectedTriggerProps: b,
|
|
109
|
+
panelProps: g
|
|
110
|
+
}),
|
|
111
|
+
[
|
|
112
|
+
h,
|
|
113
|
+
A,
|
|
114
|
+
K,
|
|
115
|
+
B,
|
|
116
|
+
L,
|
|
117
|
+
o,
|
|
118
|
+
t,
|
|
119
|
+
s,
|
|
120
|
+
n,
|
|
121
|
+
a?.variant,
|
|
122
|
+
u?.variant,
|
|
123
|
+
p?.variant,
|
|
124
|
+
r,
|
|
125
|
+
f,
|
|
126
|
+
b,
|
|
127
|
+
g
|
|
128
|
+
]
|
|
129
|
+
), { variant: lt, ...N } = a ?? {}, { variant: at, ...W } = u ?? {}, { variant: ct, ...Z } = p ?? {}, G = P(
|
|
130
|
+
(d) => {
|
|
131
|
+
if (k.current = d, typeof m == "function") return m(d);
|
|
132
|
+
m && (m.current = d);
|
|
133
|
+
},
|
|
134
|
+
[m]
|
|
135
|
+
);
|
|
136
|
+
return /* @__PURE__ */ x(E.Provider, { value: U, children: /* @__PURE__ */ x(
|
|
137
|
+
R,
|
|
138
|
+
{
|
|
139
|
+
flexDirection: "column",
|
|
140
|
+
gap: 16,
|
|
141
|
+
...M,
|
|
142
|
+
md: N,
|
|
143
|
+
lg: W,
|
|
144
|
+
xl: Z,
|
|
145
|
+
ref: G,
|
|
146
|
+
children: F
|
|
147
|
+
}
|
|
148
|
+
) });
|
|
149
|
+
}), nt = S(
|
|
150
|
+
function(e, l) {
|
|
151
|
+
const i = j(), n = T(
|
|
152
|
+
{
|
|
153
|
+
inline: !0,
|
|
154
|
+
width: "fit-content",
|
|
155
|
+
gap: 4,
|
|
156
|
+
flexDirection: i.orientation === "vertical" ? "column" : "row"
|
|
157
|
+
},
|
|
158
|
+
z(i.variants, "list"),
|
|
159
|
+
i.listProps,
|
|
160
|
+
e
|
|
161
|
+
), o = (t) => {
|
|
162
|
+
if (n.onKeyDown?.(t), t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey) return;
|
|
163
|
+
const s = Array.from(
|
|
164
|
+
t.currentTarget.querySelectorAll("[role=tab]")
|
|
165
|
+
).filter(
|
|
166
|
+
(u) => !u.disabled && u.getClientRects().length > 0 && u.closest("[role=tablist]") === t.currentTarget
|
|
167
|
+
), r = s.indexOf(t.target);
|
|
168
|
+
if (r < 0 || !s.length) return;
|
|
169
|
+
const f = getComputedStyle(t.currentTarget).direction === "rtl", b = i.orientation === "vertical" ? "ArrowDown" : f ? "ArrowLeft" : "ArrowRight", g = i.orientation === "vertical" ? "ArrowUp" : f ? "ArrowRight" : "ArrowLeft";
|
|
170
|
+
let a = r;
|
|
171
|
+
if (t.key === "Home") a = 0;
|
|
172
|
+
else if (t.key === "End") a = s.length - 1;
|
|
173
|
+
else if (t.key === b)
|
|
174
|
+
a = i.loop ? (r + 1) % s.length : Math.min(r + 1, s.length - 1);
|
|
175
|
+
else if (t.key === g)
|
|
176
|
+
a = i.loop ? (r - 1 + s.length) % s.length : Math.max(r - 1, 0);
|
|
177
|
+
else return;
|
|
178
|
+
t.preventDefault(), s[a].focus();
|
|
179
|
+
};
|
|
180
|
+
return /* @__PURE__ */ x(
|
|
181
|
+
R,
|
|
182
|
+
{
|
|
183
|
+
...n,
|
|
184
|
+
ref: l,
|
|
185
|
+
role: "tablist",
|
|
186
|
+
"aria-orientation": i.orientation,
|
|
187
|
+
onKeyDown: o
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
), st = S(function({ value: e, startSlot: l, endSlot: i, selectedProps: n, children: o, ...t }, s) {
|
|
192
|
+
const r = j(), f = r.selected === e, b = q(r.id, e), g = T(
|
|
193
|
+
{
|
|
194
|
+
size: "sm",
|
|
195
|
+
p: { px: 12, py: 8 },
|
|
196
|
+
fontSize: "13px",
|
|
197
|
+
lineHeight: "16px",
|
|
198
|
+
focusVisible: {
|
|
199
|
+
outlineStyle: "solid",
|
|
200
|
+
outlineWidth: "2px",
|
|
201
|
+
outlineColor: "--color-primary-accent",
|
|
202
|
+
outlineOffset: "2px"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
z(r.variants, "trigger", f),
|
|
206
|
+
r.triggerProps,
|
|
207
|
+
t
|
|
208
|
+
), a = T(
|
|
209
|
+
g,
|
|
210
|
+
f ? r.selectedTriggerProps : void 0,
|
|
211
|
+
f ? n : void 0
|
|
212
|
+
);
|
|
213
|
+
a.style = { ...r.triggerProps?.style, ...t.style };
|
|
214
|
+
const u = !!a.disabled || !!a.isLoading;
|
|
215
|
+
return V(() => r.register(), [r.register, e, u]), /* @__PURE__ */ x(
|
|
216
|
+
ot,
|
|
217
|
+
{
|
|
218
|
+
...a,
|
|
219
|
+
ref: s,
|
|
220
|
+
id: b.trigger,
|
|
221
|
+
type: "button",
|
|
222
|
+
role: "tab",
|
|
223
|
+
"data-lc-tabs-owner": r.id,
|
|
224
|
+
"data-lc-tabs-value": e,
|
|
225
|
+
"aria-selected": f,
|
|
226
|
+
"aria-controls": b.panel,
|
|
227
|
+
tabIndex: r.tabStop === e && !u ? 0 : -1,
|
|
228
|
+
onClick: (p) => {
|
|
229
|
+
a.onClick?.(p), !p.defaultPrevented && !u && r.select(e);
|
|
230
|
+
},
|
|
231
|
+
onFocus: (p) => {
|
|
232
|
+
a.onFocus?.(p), !p.defaultPrevented && r.activationMode === "automatic" && !u && r.select(e);
|
|
233
|
+
},
|
|
234
|
+
children: /* @__PURE__ */ J(R, { as: "span", align: "center", gap: 6, children: [
|
|
235
|
+
l,
|
|
236
|
+
o,
|
|
237
|
+
i
|
|
238
|
+
] })
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}), it = S(function({ value: e, children: l, keepMounted: i = !0, ...n }, o) {
|
|
242
|
+
const t = j(), s = t.selected === e, r = q(t.id, e), f = T(t.panelProps, n);
|
|
243
|
+
return /* @__PURE__ */ x(
|
|
244
|
+
et,
|
|
245
|
+
{
|
|
246
|
+
...f,
|
|
247
|
+
ref: o,
|
|
248
|
+
id: r.panel,
|
|
249
|
+
role: "tabpanel",
|
|
250
|
+
"aria-labelledby": r.trigger,
|
|
251
|
+
tabIndex: f.tabIndex ?? 0,
|
|
252
|
+
hidden: !s,
|
|
253
|
+
style: { ...f.style, ...s ? {} : { display: "none" } },
|
|
254
|
+
children: s || i ? l : null
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}), yt = Object.assign(rt, {
|
|
258
|
+
List: nt,
|
|
259
|
+
Trigger: st,
|
|
260
|
+
Panel: it
|
|
261
|
+
});
|
|
262
|
+
export {
|
|
263
|
+
yt as T
|
|
264
|
+
};
|
package/dist/tabs.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./tabs-BNZDJRz_.cjs");exports.Tabs=e.Tabs;
|
package/dist/tabs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getTooltipPosition, toTooltipBoxProps } from './tooltip.helpers';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { BoxProps } from '../../box/index';
|
|
3
|
+
import { TooltipPlacement, TooltipPosition } from '../types/index';
|
|
4
|
+
/** Вычисляет координаты поверхности и стрелки для выбранного положения. */
|
|
5
|
+
export declare function getTooltipPosition(placement: TooltipPlacement): TooltipPosition;
|
|
6
|
+
/** Переводит координаты подсказки в responsive style props Box. */
|
|
7
|
+
export declare function toTooltipBoxProps(style: CSSProperties): NonNullable<BoxProps['md']>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { TooltipProps } from './types/index';
|
|
3
|
+
/** Подсказка по наведению или фокусу; Escape закрывает её. */
|
|
4
|
+
export declare function Tooltip({ children, content, placement, responsive, md: mdProps, lg: lgProps, xl: xlProps, open, defaultOpen, onOpenChange, delay, showArrow, disabled, contentProps, }: TooltipProps): JSX.Element;
|
|
5
|
+
export type { TooltipBreakpointProps, TooltipPlacement, TooltipProps, TooltipResponsivePlacement, } from './types/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { TooltipBreakpointProps, TooltipPlacement, TooltipPosition, TooltipProps, TooltipResponsivePlacement, } from './tooltip.types';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CSSProperties, HTMLAttributes, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { BoxProps } from '../../box/index';
|
|
3
|
+
/** Сторона и выравнивание подсказки относительно trigger. */
|
|
4
|
+
export type TooltipPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
5
|
+
/** Responsive положение: пропущенные md/lg/xl наследуют ближайшее меньшее значение. */
|
|
6
|
+
export type TooltipResponsivePlacement = {
|
|
7
|
+
/** Положение от 768 px. */ md?: TooltipPlacement;
|
|
8
|
+
/** Положение от 1024 px. */ lg?: TooltipPlacement;
|
|
9
|
+
/** Положение от 1440 px. */ xl?: TooltipPlacement;
|
|
10
|
+
};
|
|
11
|
+
/** Переопределение положения на одном брейкпоинте; null возвращает базовое placement. */
|
|
12
|
+
export type TooltipBreakpointProps = {
|
|
13
|
+
/** Положение; пропущенное значение наследуется, null сбрасывает к base. */
|
|
14
|
+
placement?: TooltipPlacement | null;
|
|
15
|
+
};
|
|
16
|
+
/** Настройки подсказки. Визуальные props поверхности совпадают с Box. */
|
|
17
|
+
export type TooltipProps = {
|
|
18
|
+
/** Один focusable React-элемент, к которому добавляется aria-describedby. */
|
|
19
|
+
children: ReactElement<HTMLAttributes<HTMLElement>>;
|
|
20
|
+
/** Текст или ReactNode подсказки; интерактивное содержимое требует другого компонента. */
|
|
21
|
+
content: ReactNode;
|
|
22
|
+
/** Базовое положение, по умолчанию top. */
|
|
23
|
+
placement?: TooltipPlacement;
|
|
24
|
+
/** Положение от 768 px; приоритетнее responsive.md. */
|
|
25
|
+
md?: TooltipBreakpointProps;
|
|
26
|
+
/** Положение от 1024 px; пропущенное наследует md. */
|
|
27
|
+
lg?: TooltipBreakpointProps;
|
|
28
|
+
/** Положение от 1440 px; пропущенное наследует lg. */
|
|
29
|
+
xl?: TooltipBreakpointProps;
|
|
30
|
+
/** Совместимый alias для md/lg/xl; прямые props имеют приоритет. */
|
|
31
|
+
responsive?: TooltipResponsivePlacement;
|
|
32
|
+
/** Управляемое состояние; без него используется внутреннее состояние. */
|
|
33
|
+
open?: boolean;
|
|
34
|
+
/** Начальное состояние неуправляемой подсказки, по умолчанию false. */
|
|
35
|
+
defaultOpen?: boolean;
|
|
36
|
+
/** Вызывается при запросе открытия или закрытия. */
|
|
37
|
+
onOpenChange?: (open: boolean) => void;
|
|
38
|
+
/** Задержка открытия в миллисекундах, по умолчанию 0. */
|
|
39
|
+
delay?: number;
|
|
40
|
+
/** Показывать стрелку, по умолчанию true. */
|
|
41
|
+
showArrow?: boolean;
|
|
42
|
+
/** Отключает открытие и закрывает подсказку. */
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
/** Props поверхности Box, включая style, className и md/lg/xl; style имеет приоритет. */
|
|
45
|
+
contentProps?: Omit<BoxProps, 'children' | 'as'>;
|
|
46
|
+
};
|
|
47
|
+
/** Внутренние координаты поверхности и стрелки относительно trigger. */
|
|
48
|
+
export type TooltipPosition = {
|
|
49
|
+
box: CSSProperties;
|
|
50
|
+
arrow: CSSProperties;
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";const R=require("react/jsx-runtime"),i=require("react"),A=require("./flex.cjs"),X=require("./box.cjs");function g(o){const[e,u]=o.split("-"),d=e==="top"||e==="bottom",a=u==="start",t=u==="end";return{box:d?{left:a?"0":t?"auto":"50%",right:t?"0":"auto",top:e==="bottom"?"calc(100% + 6px)":"auto",bottom:e==="top"?"calc(100% + 6px)":"auto",transform:a||t?"none":"translateX(-50%)"}:{top:a?"0":t?"auto":"50%",bottom:t?"0":"auto",left:e==="right"?"calc(100% + 6px)":"auto",right:e==="left"?"calc(100% + 6px)":"auto",transform:a||t?"none":"translateY(-50%)"},arrow:d?{left:a?"12px":t?"auto":"50%",right:t?"12px":"auto",top:e==="bottom"?"-4px":"auto",bottom:e==="top"?"-4px":"auto",transform:"translateX(-50%) rotate(45deg)"}:{top:a?"12px":t?"auto":"50%",bottom:t?"12px":"auto",left:e==="right"?"-4px":"auto",right:e==="left"?"-4px":"auto",transform:"translateY(-50%) rotate(45deg)"}}}function n(o){return{position:{type:"absolute",top:o.top,bottom:o.bottom,left:o.left,right:o.right},transform:o.transform}}function G({children:o,content:e,placement:u="top",responsive:d,md:a,lg:t,xl:v,open:p,defaultOpen:Y=!1,onOpenChange:T,delay:j=0,showArrow:K=!0,disabled:m=!1,contentProps:r}){const[L,O]=i.useState(Y),[y,B]=i.useState(!1),[E,S]=i.useState(!1),[q,h]=i.useState(!1),z=i.useId(),b=!m&&(p??L),f=i.useRef(!1),F=i.useRef(p),I=i.useRef(b);F.current=p,I.current=b;const M=i.useRef(T);M.current=T,i.useEffect(()=>{if(!f.current&&!m)return;const s=!m&&!q&&(y||E);if(s===I.current)return;const W=setTimeout(()=>{F.current===void 0&&O(s),M.current?.(s)},s?Math.max(0,j):0);return()=>clearTimeout(W)},[y,E,m,q,j]);const V=i.isValidElement(o)?i.cloneElement(o,{"aria-describedby":[o.props["aria-describedby"],b?z:void 0].filter(Boolean).join(" ")||void 0}):o,w=g(u),k=a?.placement!==void 0?a.placement??u:d?.md,l=k?g(k):void 0,D=t?.placement!==void 0?t.placement??u:d?.lg,c=D?g(D):void 0,H=v?.placement!==void 0?v.placement??u:d?.xl,x=H?g(H):void 0;return R.jsxs(A.Flex,{as:"span",inline:!0,position:{type:"relative"},onMouseEnter:()=>{f.current=!0,h(!1),B(!0)},onMouseLeave:()=>{f.current=!0,B(!1)},onFocus:()=>{f.current=!0,h(!1),S(!0)},onBlur:s=>{s.currentTarget.contains(s.relatedTarget)||(f.current=!0,S(!1))},onKeyDown:s=>{s.key==="Escape"&&(f.current=!0,h(!0))},children:[V,b&&R.jsxs(X.Box,{role:"tooltip",id:z,bg:"--color-background-default",color:"--color-text-primary",p:{px:8,py:6},border:{radius:"4px"},width:"max-content",maxWidth:"min(280px, calc(100vw - 24px))",...n(w.box),...r,position:{...n(w.box).position,...r?.position},md:l||r?.md?{...l?n(l.box):{},...r?.md,position:{...l?n(l.box).position:{},...r?.md?.position}}:void 0,lg:c||r?.lg?{...c?n(c.box):{},...r?.lg,position:{...c?n(c.box).position:{},...r?.lg?.position}}:void 0,xl:x||r?.xl?{...x?n(x.box):{},...r?.xl,position:{...x?n(x.box).position:{},...r?.xl?.position}}:void 0,style:{fontSize:"12px",lineHeight:"14px",zIndex:1e3,...r?.style},children:[K&&R.jsx(X.Box,{"aria-hidden":"true",width:8,height:8,bg:"inherit",...n(w.arrow),md:l?n(l.arrow):void 0,lg:c?n(c.arrow):void 0,xl:x?n(x.arrow):void 0}),e]})]})}exports.Tooltip=G;
|