@shmidko61/lc-ui-kit 0.16.1 → 0.17.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 +30 -0
- package/dist/accordion/accordion-item.d.ts +9 -2
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +84 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,3 +219,33 @@ Box/Flex поддерживают типизированный `scrollbar` в ba
|
|
|
219
219
|
CSS-размеры, частичное наследование и сброс через `null`. Оформление не включает
|
|
220
220
|
overflow. [API и ограничения](./src/box/README.md). Storybook: **UI Kit / Scrollbar**
|
|
221
221
|
(16 примеров, включая вложенность, сбросы и style escape hatch).
|
|
222
|
+
|
|
223
|
+
## Accordion: внутренняя обёртка
|
|
224
|
+
|
|
225
|
+
`Accordion.Item.contentInnerProps` настраивает внутренний Box через BoxProps,
|
|
226
|
+
включая `p: 0`, размеры, оформление и `md`/`lg`/`xl`. По умолчанию остаётся
|
|
227
|
+
`p={{ px: 24, pb: 24 }}`; `style` имеет приоритет. `contentProps` управляет
|
|
228
|
+
внешней анимированной панелью. Объектные responsive overrides наследуют
|
|
229
|
+
незаданные стороны от предыдущего breakpoint; `p: 0` сбрасывает все стороны.
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { Accordion } from '@shmidko61/lc-ui-kit/accordion';
|
|
233
|
+
import { Typography } from '@shmidko61/lc-ui-kit/typography';
|
|
234
|
+
import '@shmidko61/lc-ui-kit/styles.css';
|
|
235
|
+
|
|
236
|
+
export function Question() {
|
|
237
|
+
return (
|
|
238
|
+
<Accordion defaultExpandedKeys={['question']}>
|
|
239
|
+
<Accordion.Item
|
|
240
|
+
id="question"
|
|
241
|
+
title="Вопрос"
|
|
242
|
+
contentInnerProps={{ p: 0, lg: { p: { pt: 16, pb: 8 } }, xl: { p: 0 } }}
|
|
243
|
+
>
|
|
244
|
+
<Typography>Ответ</Typography>
|
|
245
|
+
</Accordion.Item>
|
|
246
|
+
</Accordion>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Storybook: **UI Kit / Accordion / ContentInner**.
|
|
@@ -41,8 +41,15 @@ export type AccordionItemProps = PropsWithChildren<AccordionItemHeaderProps & {
|
|
|
41
41
|
headingWrapper?: ComponentType<AccordionItemRenderProps>;
|
|
42
42
|
/** Props внешнего контейнера item. */
|
|
43
43
|
itemProps?: AccordionItemBoxProps;
|
|
44
|
-
/** Props panel
|
|
44
|
+
/** Props внешней анимированной panel; не задают отступы внутренней обёртки. */
|
|
45
45
|
contentProps?: AccordionItemContentProps;
|
|
46
|
+
/**
|
|
47
|
+
* Props внутреннего Box: отступы, размеры, оформление и md/lg/xl по контракту BoxProps.
|
|
48
|
+
* По умолчанию p={ px: 24, pb: 24 }; переданный p заменяет его целиком, включая 0.
|
|
49
|
+
* Responsive overrides наследуются как в Box; p: 0 сбрасывает отступы.
|
|
50
|
+
* className и HTML props передаются напрямую; явный style имеет приоритет над style props.
|
|
51
|
+
*/
|
|
52
|
+
contentInnerProps?: AccordionItemBoxProps;
|
|
46
53
|
}>;
|
|
47
|
-
export declare function AccordionItem({ children, className, contentProps, duration, headingWrapper: HeadingWrapper, hideIndicator, id, indicator, indicatorProps, isDisabled, isExpanded, itemProps, leading, onToggle, subtitle, surface, title, trailing, variant, ...headerProps }: AccordionItemProps): JSX.Element;
|
|
54
|
+
export declare function AccordionItem({ children, className, contentProps, contentInnerProps, duration, headingWrapper: HeadingWrapper, hideIndicator, id, indicator, indicatorProps, isDisabled, isExpanded, itemProps, leading, onToggle, subtitle, surface, title, trailing, variant, ...headerProps }: AccordionItemProps): JSX.Element;
|
|
48
55
|
export {};
|
package/dist/accordion.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),v=require("react-aria"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),v=require("react-aria"),ee=require("react-stately/useDisclosureState"),s=require("./box.cjs"),l=require("./flex.cjs"),te=require("./icons.cjs"),p=require("./responsive-style.config-B2m9jVlX.cjs"),E=require("./typography.cjs"),se=require("react-stately/useDisclosureGroupState"),R=i.createContext(null);function ne(){const t=i.useContext(R);if(!t)throw new Error("Accordion.Item должен использоваться внутри Accordion.");return t}function oe({children:t}){return e.jsx(l.Flex,{align:"center",gap:16,justify:"space-between",width:"100%",children:t})}function k({children:t,className:g,contentProps:a,contentInnerProps:d,duration:u=200,headingWrapper:f=oe,hideIndicator:y=!1,id:m,indicator:I,indicatorProps:n,isDisabled:_=!1,isExpanded:F,itemProps:o,leading:w,onToggle:W,subtitle:S,surface:b="card",title:G,trailing:D,variant:N="primary",...x}){const K=i.useId(),h=m??K,j=ne(),T=String(h),O=j.expandedKeys.has(h),Y=F??O,c=j.isDisabled||_,A=i.useRef(null),B=i.useRef(null),r=ee.useDisclosureState({isExpanded:Y,onExpandedChange:P=>{c||(j.toggleKey(h),W?.(P))}}),{buttonProps:$,panelProps:q}=v.useDisclosure({isDisabled:c},r,A),{buttonProps:z}=v.useButton($,B),H=a?.className,M=a?.style,J=q.style,L=o?.bg??(b==="card"?"--color-background-default":void 0),Q=b==="card"?{radius:"16px",style:"none",width:"0",...o?.border}:o?.border,U=o?.className,V=o?.style,X=x.style,Z={...J,height:"var(--disclosure-panel-height)",opacity:r.isExpanded?1:0,transitionDuration:`${u}ms`,...M};return e.jsxs(s.Box,{"data-disabled":c||void 0,"data-state":r.isExpanded?"open":"closed","data-value":T,...o,bg:L,border:Q,className:p.cn("grid min-w-0",b==="card"?"gap-0 overflow-hidden":"gap-[24px]",c&&"opacity-50",U),style:V,children:[e.jsx(s.Box,{...v.mergeProps(z,x),as:"button",border:{radius:"16px",style:"none",width:"0",...x.border},className:p.cn("group/accordion-trigger w-full text-left outline-none transition-colors disabled:cursor-not-allowed","focus-visible:ring-2 focus-visible:ring-[color-mix(in_srgb,var(--color-primary-accent)_35%,transparent)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--color-background-default)]",N==="primary"&&"bg-[var(--color-background-default)]",N==="secondary"&&"bg-transparent",g),cursor:c?"not-allowed":"pointer","data-state":r.isExpanded?"open":"closed",p:x.p??24,ref:B,style:X,type:"button",children:e.jsxs(f,{children:[e.jsxs(l.Flex,{align:"center",gap:16,minWidth:0,children:[w?e.jsx(s.Box,{as:"span",className:"flex shrink-0 items-center justify-center text-[var(--color-text-primary)] [&_svg]:size-[20px]",children:w}):null,e.jsxs(l.Flex,{flexDirection:"column",gap:8,minWidth:0,children:[e.jsx(E.Typography,{as:"span",className:"truncate",variant:"h4",children:G}),S?e.jsx(E.Typography,{as:"span",className:"truncate",color:"--color-text-secondary",variant:"b2",children:S}):null]})]}),e.jsxs(l.Flex,{align:"center",gap:12,shrink:0,children:[D?e.jsx(s.Box,{as:"span",children:D}):null,y?null:e.jsx(s.Box,{...n,as:"span",bg:n?.bg??"--color-background-default",border:n?.border??{radius:"8px"},style:n?.style,className:p.cn(n?"flex items-center justify-center":"flex min-h-[41px] min-w-[41px] items-center justify-center text-[var(--color-text-primary)] transition-colors group-hover/accordion-trigger:bg-[color-mix(in_srgb,var(--color-background-default)_90%,#000)]",n?.className),children:I??e.jsx(te.DropDown,{"aria-hidden":"true",className:"h-[12px] w-[12px] transition-transform",style:{transform:r.isExpanded?"translateY(-2px) rotate(180deg)":"translateY(2px) rotate(0deg)",transitionDuration:`${u}ms`}})})]})]})}),e.jsx(s.Box,{...q,...a,className:p.cn("overflow-hidden text-[var(--color-text-secondary)] transition-[height,opacity]",H),"data-state":r.isExpanded?"open":"closed",ref:A,style:Z,children:e.jsx(s.Box,{...d,p:d?.p??{px:24,pb:24},children:t})})]})}function C({allowsMultipleExpanded:t=!1,children:g,defaultExpandedKeys:a,expandedKeys:d,isDisabled:u=!1,onExpandedChange:f,...y}){const m=se.useDisclosureGroupState({allowsMultipleExpanded:t,defaultExpandedKeys:a,expandedKeys:d,isDisabled:u,onExpandedChange:f});return e.jsx(R.Provider,{value:m,children:e.jsx(l.Flex,{flexDirection:"column",gap:24,width:"100%",...y,children:g})})}const re=Object.assign(C,{Item:k});exports.Accordion=re;exports.AccordionItem=k;exports.AccordionRoot=C;
|
package/dist/accordion.js
CHANGED
|
@@ -1,108 +1,109 @@
|
|
|
1
1
|
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useDisclosure as
|
|
2
|
+
import { createContext as Z, useContext as P, useId as ee, useRef as k } from "react";
|
|
3
|
+
import { useDisclosure as te, useButton as re, mergeProps as oe } from "react-aria";
|
|
4
4
|
import { useDisclosureState as ne } from "react-stately/useDisclosureState";
|
|
5
5
|
import { Box as r } from "./box.js";
|
|
6
6
|
import { Flex as l } from "./flex.js";
|
|
7
|
-
import { DropDown as
|
|
8
|
-
import { c as
|
|
7
|
+
import { DropDown as ae } from "./icons.js";
|
|
8
|
+
import { c as m } from "./responsive-style.config-DFuATrIM.js";
|
|
9
9
|
import { Typography as C } from "./typography.js";
|
|
10
10
|
import { useDisclosureGroupState as se } from "react-stately/useDisclosureGroupState";
|
|
11
|
-
const B =
|
|
12
|
-
function
|
|
13
|
-
const t =
|
|
11
|
+
const B = Z(null);
|
|
12
|
+
function ie() {
|
|
13
|
+
const t = P(B);
|
|
14
14
|
if (!t)
|
|
15
15
|
throw new Error("Accordion.Item должен использоваться внутри Accordion.");
|
|
16
16
|
return t;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function ce({ children: t }) {
|
|
19
19
|
return /* @__PURE__ */ e(l, { align: "center", gap: 16, justify: "space-between", width: "100%", children: t });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function le({
|
|
22
22
|
children: t,
|
|
23
|
-
className:
|
|
24
|
-
contentProps:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
className: f,
|
|
24
|
+
contentProps: s,
|
|
25
|
+
contentInnerProps: d,
|
|
26
|
+
duration: u = 200,
|
|
27
|
+
headingWrapper: g = ce,
|
|
28
|
+
hideIndicator: x = !1,
|
|
29
|
+
id: y,
|
|
30
|
+
indicator: I,
|
|
31
|
+
indicatorProps: o,
|
|
32
|
+
isDisabled: _ = !1,
|
|
33
|
+
isExpanded: R,
|
|
34
|
+
itemProps: n,
|
|
34
35
|
leading: w,
|
|
35
|
-
onToggle:
|
|
36
|
+
onToggle: W,
|
|
36
37
|
subtitle: N,
|
|
37
38
|
surface: b = "card",
|
|
38
|
-
title:
|
|
39
|
+
title: K,
|
|
39
40
|
trailing: D,
|
|
40
41
|
variant: S = "primary",
|
|
41
|
-
...
|
|
42
|
+
...p
|
|
42
43
|
}) {
|
|
43
|
-
const
|
|
44
|
-
isExpanded:
|
|
45
|
-
onExpandedChange: (
|
|
46
|
-
i || (v.toggleKey(h),
|
|
44
|
+
const G = ee(), h = y ?? G, v = ie(), Y = String(h), $ = v.expandedKeys.has(h), z = R ?? $, i = v.isDisabled || _, A = k(null), E = k(null), a = ne({
|
|
45
|
+
isExpanded: z,
|
|
46
|
+
onExpandedChange: (X) => {
|
|
47
|
+
i || (v.toggleKey(h), W?.(X));
|
|
47
48
|
}
|
|
48
|
-
}), { buttonProps:
|
|
49
|
+
}), { buttonProps: F, panelProps: j } = te(
|
|
49
50
|
{ isDisabled: i },
|
|
50
|
-
|
|
51
|
+
a,
|
|
51
52
|
A
|
|
52
|
-
), { buttonProps:
|
|
53
|
+
), { buttonProps: H } = re(F, E), O = s?.className, T = s?.style, q = j.style, J = n?.bg ?? (b === "card" ? "--color-background-default" : void 0), L = b === "card" ? {
|
|
53
54
|
radius: "16px",
|
|
54
55
|
style: "none",
|
|
55
56
|
width: "0",
|
|
56
|
-
...
|
|
57
|
-
} :
|
|
58
|
-
...
|
|
57
|
+
...n?.border
|
|
58
|
+
} : n?.border, M = n?.className, Q = n?.style, U = p.style, V = {
|
|
59
|
+
...q,
|
|
59
60
|
height: "var(--disclosure-panel-height)",
|
|
60
|
-
opacity:
|
|
61
|
-
transitionDuration: `${
|
|
62
|
-
...
|
|
61
|
+
opacity: a.isExpanded ? 1 : 0,
|
|
62
|
+
transitionDuration: `${u}ms`,
|
|
63
|
+
...T
|
|
63
64
|
};
|
|
64
65
|
return /* @__PURE__ */ c(
|
|
65
66
|
r,
|
|
66
67
|
{
|
|
67
68
|
"data-disabled": i || void 0,
|
|
68
|
-
"data-state":
|
|
69
|
-
"data-value":
|
|
70
|
-
...
|
|
71
|
-
bg:
|
|
72
|
-
border:
|
|
73
|
-
className:
|
|
69
|
+
"data-state": a.isExpanded ? "open" : "closed",
|
|
70
|
+
"data-value": Y,
|
|
71
|
+
...n,
|
|
72
|
+
bg: J,
|
|
73
|
+
border: L,
|
|
74
|
+
className: m(
|
|
74
75
|
"grid min-w-0",
|
|
75
76
|
b === "card" ? "gap-0 overflow-hidden" : "gap-[24px]",
|
|
76
77
|
i && "opacity-50",
|
|
77
|
-
|
|
78
|
+
M
|
|
78
79
|
),
|
|
79
|
-
style:
|
|
80
|
+
style: Q,
|
|
80
81
|
children: [
|
|
81
82
|
/* @__PURE__ */ e(
|
|
82
83
|
r,
|
|
83
84
|
{
|
|
84
|
-
...
|
|
85
|
+
...oe(H, p),
|
|
85
86
|
as: "button",
|
|
86
87
|
border: {
|
|
87
88
|
radius: "16px",
|
|
88
89
|
style: "none",
|
|
89
90
|
width: "0",
|
|
90
|
-
...
|
|
91
|
+
...p.border
|
|
91
92
|
},
|
|
92
|
-
className:
|
|
93
|
+
className: m(
|
|
93
94
|
"group/accordion-trigger w-full text-left outline-none transition-colors disabled:cursor-not-allowed",
|
|
94
95
|
"focus-visible:ring-2 focus-visible:ring-[color-mix(in_srgb,var(--color-primary-accent)_35%,transparent)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--color-background-default)]",
|
|
95
96
|
S === "primary" && "bg-[var(--color-background-default)]",
|
|
96
97
|
S === "secondary" && "bg-transparent",
|
|
97
|
-
|
|
98
|
+
f
|
|
98
99
|
),
|
|
99
100
|
cursor: i ? "not-allowed" : "pointer",
|
|
100
|
-
"data-state":
|
|
101
|
-
p:
|
|
101
|
+
"data-state": a.isExpanded ? "open" : "closed",
|
|
102
|
+
p: p.p ?? 24,
|
|
102
103
|
ref: E,
|
|
103
|
-
style:
|
|
104
|
+
style: U,
|
|
104
105
|
type: "button",
|
|
105
|
-
children: /* @__PURE__ */ c(
|
|
106
|
+
children: /* @__PURE__ */ c(g, { children: [
|
|
106
107
|
/* @__PURE__ */ c(l, { align: "center", gap: 16, minWidth: 0, children: [
|
|
107
108
|
w ? /* @__PURE__ */ e(
|
|
108
109
|
r,
|
|
@@ -113,7 +114,7 @@ function ce({
|
|
|
113
114
|
}
|
|
114
115
|
) : null,
|
|
115
116
|
/* @__PURE__ */ c(l, { flexDirection: "column", gap: 8, minWidth: 0, children: [
|
|
116
|
-
/* @__PURE__ */ e(C, { as: "span", className: "truncate", variant: "h4", children:
|
|
117
|
+
/* @__PURE__ */ e(C, { as: "span", className: "truncate", variant: "h4", children: K }),
|
|
117
118
|
N ? /* @__PURE__ */ e(
|
|
118
119
|
C,
|
|
119
120
|
{
|
|
@@ -128,26 +129,26 @@ function ce({
|
|
|
128
129
|
] }),
|
|
129
130
|
/* @__PURE__ */ c(l, { align: "center", gap: 12, shrink: 0, children: [
|
|
130
131
|
D ? /* @__PURE__ */ e(r, { as: "span", children: D }) : null,
|
|
131
|
-
|
|
132
|
+
x ? null : /* @__PURE__ */ e(
|
|
132
133
|
r,
|
|
133
134
|
{
|
|
134
|
-
...
|
|
135
|
+
...o,
|
|
135
136
|
as: "span",
|
|
136
|
-
bg:
|
|
137
|
-
border:
|
|
138
|
-
style:
|
|
139
|
-
className:
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
bg: o?.bg ?? "--color-background-default",
|
|
138
|
+
border: o?.border ?? { radius: "8px" },
|
|
139
|
+
style: o?.style,
|
|
140
|
+
className: m(
|
|
141
|
+
o ? "flex items-center justify-center" : "flex min-h-[41px] min-w-[41px] items-center justify-center text-[var(--color-text-primary)] transition-colors group-hover/accordion-trigger:bg-[color-mix(in_srgb,var(--color-background-default)_90%,#000)]",
|
|
142
|
+
o?.className
|
|
142
143
|
),
|
|
143
|
-
children:
|
|
144
|
-
|
|
144
|
+
children: I ?? /* @__PURE__ */ e(
|
|
145
|
+
ae,
|
|
145
146
|
{
|
|
146
147
|
"aria-hidden": "true",
|
|
147
148
|
className: "h-[12px] w-[12px] transition-transform",
|
|
148
149
|
style: {
|
|
149
|
-
transform:
|
|
150
|
-
transitionDuration: `${
|
|
150
|
+
transform: a.isExpanded ? "translateY(-2px) rotate(180deg)" : "translateY(2px) rotate(0deg)",
|
|
151
|
+
transitionDuration: `${u}ms`
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
)
|
|
@@ -161,44 +162,44 @@ function ce({
|
|
|
161
162
|
r,
|
|
162
163
|
{
|
|
163
164
|
...j,
|
|
164
|
-
...
|
|
165
|
-
className:
|
|
165
|
+
...s,
|
|
166
|
+
className: m(
|
|
166
167
|
"overflow-hidden text-[var(--color-text-secondary)] transition-[height,opacity]",
|
|
167
|
-
|
|
168
|
+
O
|
|
168
169
|
),
|
|
169
|
-
"data-state":
|
|
170
|
+
"data-state": a.isExpanded ? "open" : "closed",
|
|
170
171
|
ref: A,
|
|
171
|
-
style:
|
|
172
|
-
children: /* @__PURE__ */ e(r, { p: { px: 24, pb: 24 }, children: t })
|
|
172
|
+
style: V,
|
|
173
|
+
children: /* @__PURE__ */ e(r, { ...d, p: d?.p ?? { px: 24, pb: 24 }, children: t })
|
|
173
174
|
}
|
|
174
175
|
)
|
|
175
176
|
]
|
|
176
177
|
}
|
|
177
178
|
);
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
+
function de({
|
|
180
181
|
allowsMultipleExpanded: t = !1,
|
|
181
|
-
children:
|
|
182
|
-
defaultExpandedKeys:
|
|
182
|
+
children: f,
|
|
183
|
+
defaultExpandedKeys: s,
|
|
183
184
|
expandedKeys: d,
|
|
184
|
-
isDisabled:
|
|
185
|
+
isDisabled: u = !1,
|
|
185
186
|
onExpandedChange: g,
|
|
186
187
|
...x
|
|
187
188
|
}) {
|
|
188
189
|
const y = se({
|
|
189
190
|
allowsMultipleExpanded: t,
|
|
190
|
-
defaultExpandedKeys:
|
|
191
|
+
defaultExpandedKeys: s,
|
|
191
192
|
expandedKeys: d,
|
|
192
|
-
isDisabled:
|
|
193
|
+
isDisabled: u,
|
|
193
194
|
onExpandedChange: g
|
|
194
195
|
});
|
|
195
|
-
return /* @__PURE__ */ e(B.Provider, { value: y, children: /* @__PURE__ */ e(l, { flexDirection: "column", gap: 24, width: "100%", ...x, children:
|
|
196
|
+
return /* @__PURE__ */ e(B.Provider, { value: y, children: /* @__PURE__ */ e(l, { flexDirection: "column", gap: 24, width: "100%", ...x, children: f }) });
|
|
196
197
|
}
|
|
197
|
-
const
|
|
198
|
-
Item:
|
|
198
|
+
const we = Object.assign(de, {
|
|
199
|
+
Item: le
|
|
199
200
|
});
|
|
200
201
|
export {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
we as Accordion,
|
|
203
|
+
le as AccordionItem,
|
|
204
|
+
de as AccordionRoot
|
|
204
205
|
};
|