@lobehub/ui 6.5.0 → 6.6.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 +87 -125
- package/es/Accordion/style.d.mts +2 -2
- package/es/AutoComplete/style.d.mts +1 -1
- package/es/Carousel/Carousel.mjs +7 -8
- package/es/Carousel/Carousel.mjs.map +1 -1
- package/es/Drawer/atoms.mjs +5 -5
- package/es/Drawer/atoms.mjs.map +1 -1
- package/es/EditorSlashMenu/EditorSlashMenu.mjs +7 -9
- package/es/EditorSlashMenu/EditorSlashMenu.mjs.map +1 -1
- package/es/FormKit/List.mjs +24 -24
- package/es/FormKit/List.mjs.map +1 -1
- package/es/Highlighter/Highlighter.mjs +1 -3
- package/es/Highlighter/Highlighter.mjs.map +1 -1
- package/es/Highlighter/LangSelect.mjs +2 -2
- package/es/Highlighter/LangSelect.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.mjs +2 -3
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/StreamRenderer.mjs +4 -20
- package/es/Highlighter/SyntaxHighlighter/StreamRenderer.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/index.mjs +2 -3
- package/es/Highlighter/SyntaxHighlighter/index.mjs.map +1 -1
- package/es/Highlighter/SyntaxHighlighter/tokenFade.mjs.map +1 -1
- package/es/Highlighter/const.d.mts +2 -0
- package/es/Highlighter/const.mjs +95 -12
- package/es/Highlighter/const.mjs.map +1 -1
- package/es/Highlighter/engine.mjs +75 -0
- package/es/Highlighter/engine.mjs.map +1 -0
- package/es/Highlighter/languages.mjs +501 -0
- package/es/Highlighter/languages.mjs.map +1 -0
- package/es/Highlighter/theme/lobe-highlights-theme.mjs +73 -0
- package/es/Highlighter/theme/lobe-highlights-theme.mjs.map +1 -0
- package/es/Highlighter/tokens.mjs +50 -0
- package/es/Highlighter/tokens.mjs.map +1 -0
- package/es/Highlighter/type.d.mts +5 -2
- package/es/Image/viewer/ActualSizeIcon.mjs +3 -4
- package/es/Image/viewer/ActualSizeIcon.mjs.map +1 -1
- package/es/ImageSelect/ImageSelect.mjs +22 -22
- package/es/ImageSelect/ImageSelect.mjs.map +1 -1
- package/es/Markdown/SyntaxMarkdown/MarkdownRender.mjs.map +1 -1
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.mjs.map +1 -1
- package/es/Markdown/components/Footnotes.mjs +26 -26
- package/es/Markdown/components/Footnotes.mjs.map +1 -1
- package/es/Markdown/plugins/remarkCjkAutolink.mjs +101 -0
- package/es/Markdown/plugins/remarkCjkAutolink.mjs.map +1 -0
- package/es/Modal/Modal.mjs.map +1 -1
- package/es/Modal/atoms.mjs +5 -5
- package/es/Modal/atoms.mjs.map +1 -1
- package/es/Pagination/Pagination.mjs +5 -5
- package/es/Pagination/Pagination.mjs.map +1 -1
- package/es/Popover/PopoverInGroup.mjs.map +1 -1
- package/es/Rate/Rate.mjs +3 -4
- package/es/Rate/Rate.mjs.map +1 -1
- package/es/SearchBar/SearchBar.mjs +3 -1
- package/es/SearchBar/SearchBar.mjs.map +1 -1
- package/es/Select/parts.mjs +20 -20
- package/es/Select/parts.mjs.map +1 -1
- package/es/Spin/NetworkGlyph.mjs +5 -7
- package/es/Spin/NetworkGlyph.mjs.map +1 -1
- package/es/Table/render/Header.mjs +15 -16
- package/es/Table/render/Header.mjs.map +1 -1
- package/es/color/ColorScales/ScaleRow.mjs +7 -7
- package/es/color/ColorScales/ScaleRow.mjs.map +1 -1
- package/es/color/ColorScales/index.mjs +20 -21
- package/es/color/ColorScales/index.mjs.map +1 -1
- package/es/color/CssVar/ScaleRow.mjs +7 -7
- package/es/color/CssVar/ScaleRow.mjs.map +1 -1
- package/es/color/CssVar/VarRow.mjs +7 -7
- package/es/color/CssVar/VarRow.mjs.map +1 -1
- package/es/color/CssVar/index.mjs +20 -21
- package/es/color/CssVar/index.mjs.map +1 -1
- package/es/dashboard/PageSkeleton/PageSkeleton.mjs +30 -25
- package/es/dashboard/PageSkeleton/PageSkeleton.mjs.map +1 -1
- package/es/eslint/index.d.mts +1 -1
- package/es/hooks/useHighlight.mjs +35 -107
- package/es/hooks/useHighlight.mjs.map +1 -1
- package/es/hooks/useMarkdown/useMarkdownRemarkPlugins.mjs +2 -0
- package/es/hooks/useMarkdown/useMarkdownRemarkPlugins.mjs.map +1 -1
- package/es/hooks/useStreamHighlight.mjs +90 -194
- package/es/hooks/useStreamHighlight.mjs.map +1 -1
- package/es/node_modules/.pnpm/{eslint@10.13.0_jiti@2.6.1_supports-color@10.2.2 → eslint@10.13.0_jiti@2.7.0_supports-color@10.2.2}/node_modules/eslint/lib/types/index.d.mts +1 -1
- package/es/style.css +2 -46
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
<img height="120" src="https://raw.githubusercontent.com/lobehub/lobe-assets/master/packages/assets-logo/assets/split.svg">
|
|
7
|
-
<img height="120" src="https://raw.githubusercontent.com/lobehub/lobe-assets/master/packages/assets-emoji/assets/lollipop.webp">
|
|
5
|
+

|
|
8
6
|
|
|
9
7
|
<h1>Lobe UI</h1>
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
<h3>The React UI Kit for AI-Native Web Apps</h3>
|
|
10
|
+
|
|
11
|
+
LobeHub's open-source React component library for building AI chat and AIGC web apps.
|
|
12
12
|
|
|
13
13
|
[Documents](https://ui.lobehub.com) · [Changelog](./CHANGELOG.md) · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
|
|
14
14
|
|
|
@@ -27,8 +27,6 @@ Lobe UI is an open-source UI component library for building _AIGC_ web apps
|
|
|
27
27
|
[![][github-issues-shield]][github-issues-link]
|
|
28
28
|
[![][github-license-shield]][github-license-link]
|
|
29
29
|
|
|
30
|
-
[![][banner]][vercel-link]
|
|
31
|
-
|
|
32
30
|
</div>
|
|
33
31
|
|
|
34
32
|
<details>
|
|
@@ -36,51 +34,31 @@ Lobe UI is an open-source UI component library for building _AIGC_ web apps
|
|
|
36
34
|
|
|
37
35
|
#### TOC
|
|
38
36
|
|
|
39
|
-
- [
|
|
40
|
-
|
|
41
|
-
- [
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
- [✨ Why Lobe UI?](#-why-lobe-ui)
|
|
38
|
+
- [🚀 Getting Started](#-getting-started)
|
|
39
|
+
- [🤖 AI-Powered Development](#-ai-powered-development)
|
|
40
|
+
- [📦 Entry Points](#-entry-points)
|
|
41
|
+
- [📖 Documentation](#-documentation)
|
|
42
|
+
- [💬 Community](#-community)
|
|
44
43
|
- [⌨️ Local Development](#️-local-development)
|
|
45
44
|
- [🤝 Contributing](#-contributing)
|
|
46
45
|
- [🩷 Sponsor](#-sponsor)
|
|
47
46
|
- [🔗 Links](#-links)
|
|
48
|
-
- [More Products](#more-products)
|
|
49
|
-
- [Design Resources](#design-resources)
|
|
50
|
-
- [Development Resources](#development-resources)
|
|
51
47
|
|
|
52
48
|
####
|
|
53
49
|
|
|
54
50
|
</details>
|
|
55
51
|
|
|
56
|
-
##
|
|
57
|
-
|
|
58
|
-
> \[!IMPORTANT]\
|
|
59
|
-
> This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
|
|
60
|
-
|
|
61
|
-
To install Lobe UI, run the following command:
|
|
62
|
-
|
|
63
|
-
[![][pnpm-shield]][pnpm-link]
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
$ pnpm add @lobehub/ui
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Upgrading from 5.x? Follow the [v6 migration guide](https://ui.lobehub.com/migration-v6) and run `npx @lobehub/ui-codemod@beta v6 .`.
|
|
70
|
-
|
|
71
|
-
### Compile with NextJS
|
|
52
|
+
## ✨ Why Lobe UI?
|
|
72
53
|
|
|
73
|
-
|
|
74
|
-
> By work correct with nextjs page router SSR, add `transpilePackages: ['@lobehub/ui']` to `next.config.js`. For example:
|
|
54
|
+
Lobe UI is the React component library behind LobeHub, made for building AI chat and AIGC web apps.
|
|
75
55
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
};
|
|
83
|
-
```
|
|
56
|
+
- **Built for AI apps**: render LLM output (Markdown, code, Mermaid diagrams, diffs, HTML previews) and ship chat interfaces without building them from scratch.
|
|
57
|
+
- **From landing page to admin console**: one design language across chat, dashboards, data tables, forms and marketing pages.
|
|
58
|
+
- **Theme in one line**: light and dark modes plus primary and neutral colors switch with a single attribute, with no flash on first load.
|
|
59
|
+
- **Easy to restyle**: stable class names let you override any component with plain CSS or Tailwind.
|
|
60
|
+
- **Ready for global users**: English and Simplified Chinese texts included.
|
|
61
|
+
- **AI-native docs**: coding agents read every component's usage and props through [skills.md](https://ui.lobehub.com/skills.md) and [llms.txt](https://ui.lobehub.com/llms.txt).
|
|
84
62
|
|
|
85
63
|
<div align="right">
|
|
86
64
|
|
|
@@ -88,105 +66,98 @@ const nextConfig = {
|
|
|
88
66
|
|
|
89
67
|
</div>
|
|
90
68
|
|
|
91
|
-
##
|
|
69
|
+
## 🚀 Getting Started
|
|
70
|
+
|
|
71
|
+
[![][pnpm-shield]][pnpm-link]
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
$ pnpm add @lobehub/ui @lobehub/icons @lobehub/fluent-emoji motion
|
|
75
|
+
```
|
|
92
76
|
|
|
93
|
-
|
|
77
|
+
Lobe UI is ESM only and needs React 19, `motion` 13 or 14, `@lobehub/icons` 6 and `@lobehub/fluent-emoji` 5 as peer dependencies.
|
|
94
78
|
|
|
95
79
|
```tsx
|
|
96
80
|
import '@lobehub/ui/theme.css';
|
|
97
81
|
import '@lobehub/ui/style.css';
|
|
98
|
-
// optional document resets (body font, background, scrollbars)
|
|
99
|
-
import '@lobehub/ui/global.css';
|
|
100
82
|
|
|
101
83
|
import { Button, ConfigProvider } from '@lobehub/ui';
|
|
102
84
|
import { motion } from 'motion/react';
|
|
103
85
|
|
|
104
86
|
export default () => (
|
|
105
87
|
<ConfigProvider motion={motion}>
|
|
106
|
-
<Button>Hello AIGC</Button>
|
|
88
|
+
<Button type="primary">Hello AIGC</Button>
|
|
107
89
|
</ConfigProvider>
|
|
108
90
|
);
|
|
109
91
|
```
|
|
110
92
|
|
|
111
|
-
|
|
93
|
+
Theming, i18n, CSS layers and framework setup are covered in the [documentation](https://ui.lobehub.com). Upgrading from 5.x? v6 drops Ant Design; follow the [v6 migration guide](https://ui.lobehub.com/migration-v6).
|
|
112
94
|
|
|
113
|
-
|
|
114
|
-
@layer reset, lobe-base, lobe-popup, lobe-ui;
|
|
95
|
+
<div align="right">
|
|
115
96
|
|
|
116
|
-
|
|
117
|
-
button {
|
|
118
|
-
font: inherit;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
97
|
+
[![][back-to-top]](#readme-top)
|
|
122
98
|
|
|
123
|
-
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
## 🤖 AI-Powered Development
|
|
102
|
+
|
|
103
|
+
Lobe UI's docs are generated for coding agents as well as people.
|
|
104
|
+
|
|
105
|
+
| Resource | What it does |
|
|
106
|
+
| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| [skills.md](https://ui.lobehub.com/skills.md) | Agent skill entry point with a Markdown reference (usage, props, API) for every component |
|
|
108
|
+
| [llms.txt](https://ui.lobehub.com/llms.txt) | Page index with outlines for [llms.txt](https://llmstxt.org)-aware tools |
|
|
109
|
+
| [v6 migration skill](https://github.com/lobehub/lobe-ui/tree/master/.agents/skills/lobe-ui-v6-migration) | `npx skills add lobehub/lobe-ui`: lets your agent upgrade a 5.x app |
|
|
110
|
+
| [Codemod](https://github.com/lobehub/lobe-ui/tree/master/packages/codemod) | `npx @lobehub/ui-codemod@latest v6 . --dry`: rewrites v5 code and writes a JSON report agents can work through |
|
|
124
111
|
|
|
125
|
-
|
|
112
|
+
Paste this into Cursor, Claude Code, Codex or any other coding agent:
|
|
126
113
|
|
|
127
|
-
```
|
|
128
|
-
|
|
114
|
+
```text
|
|
115
|
+
Read https://ui.lobehub.com/skills.md, then use @lobehub/ui to build a chat page with a message list and an input box. Only use components, props and imports documented there.
|
|
129
116
|
```
|
|
130
117
|
|
|
131
|
-
|
|
118
|
+
Works with Cursor, Claude Code, Windsurf, GitHub Copilot and other llms.txt-aware tools.
|
|
132
119
|
|
|
133
|
-
|
|
120
|
+
<div align="right">
|
|
134
121
|
|
|
135
|
-
|
|
122
|
+
[![][back-to-top]](#readme-top)
|
|
136
123
|
|
|
137
|
-
|
|
138
|
-
<html data-theme="dark" data-primary-color="blue" data-neutral-color="slate"></html>
|
|
139
|
-
```
|
|
124
|
+
</div>
|
|
140
125
|
|
|
141
|
-
|
|
142
|
-
- `<ThemeScope appearance="dark">` themes a subtree (e.g. a dark island in a light page).
|
|
143
|
-
- Style with `createStaticStyles` / `cssVar` / `cx` from `@lobehub/ui`; `useTheme()` / `useThemeMode()` return the current tokens when JS needs concrete values.
|
|
144
|
-
- Apps that compile StyleX themselves can import the same tokens from `@lobehub/ui/stylex/cssVar.stylex` and `@lobehub/ui/stylex/media.stylex`. Those entries are uncompiled `stylex.defineConsts` modules, so the app compiler has to transform them in the same build.
|
|
126
|
+
## 📦 Entry Points
|
|
145
127
|
|
|
146
|
-
|
|
128
|
+
| Entry | Purpose |
|
|
129
|
+
| -------------------------------------------------------------------- | ------------------------------------------ |
|
|
130
|
+
| `@lobehub/ui` | Core components, `ConfigProvider`, theming |
|
|
131
|
+
| `@lobehub/ui/chat`, `@lobehub/ui/mobile` | Chat and mobile UI |
|
|
132
|
+
| `@lobehub/ui/dashboard`, `@lobehub/ui/pro-table`, `@lobehub/ui/form` | Admin consoles, data tables, forms |
|
|
133
|
+
| `@lobehub/ui/awesome`, `@lobehub/ui/brand`, `@lobehub/ui/mdx` | Landing pages, LobeHub brand, MDX docs |
|
|
134
|
+
| `@lobehub/ui/icons`, `@lobehub/ui/i18n` | Platform icons, locale bundles |
|
|
147
135
|
|
|
148
|
-
|
|
136
|
+
<div align="right">
|
|
149
137
|
|
|
150
|
-
|
|
151
|
-
import { I18nProvider } from '@lobehub/ui';
|
|
152
|
-
import formMessages from '@lobehub/ui/i18n/resources/form';
|
|
153
|
-
import hotkeyMessages from '@lobehub/ui/i18n/resources/hotkey';
|
|
138
|
+
[![][back-to-top]](#readme-top)
|
|
154
139
|
|
|
155
|
-
|
|
156
|
-
<App />
|
|
157
|
-
</I18nProvider>;
|
|
158
|
-
```
|
|
140
|
+
</div>
|
|
159
141
|
|
|
160
|
-
|
|
142
|
+
## 📖 Documentation
|
|
161
143
|
|
|
162
|
-
|
|
144
|
+
- **Docs and live demos**: [ui.lobehub.com](https://ui.lobehub.com)
|
|
145
|
+
- **Migrating to v6**: [ui.lobehub.com/migration-v6](https://ui.lobehub.com/migration-v6)
|
|
146
|
+
- **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
|
|
163
147
|
|
|
164
|
-
|
|
165
|
-
import { ConfigProvider } from '@lobehub/ui';
|
|
166
|
-
import { motion } from 'motion/react';
|
|
148
|
+
<div align="right">
|
|
167
149
|
|
|
168
|
-
|
|
169
|
-
<ConfigProvider motion={motion}>
|
|
170
|
-
<App />
|
|
171
|
-
</ConfigProvider>
|
|
172
|
-
);
|
|
173
|
-
```
|
|
150
|
+
[![][back-to-top]](#readme-top)
|
|
174
151
|
|
|
175
|
-
|
|
152
|
+
</div>
|
|
176
153
|
|
|
177
|
-
|
|
178
|
-
import { ConfigProvider } from '@lobehub/ui';
|
|
179
|
-
import { LazyMotion, domAnimation } from 'motion/react';
|
|
180
|
-
import * as m from 'motion/react-m';
|
|
154
|
+
## 💬 Community
|
|
181
155
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</LazyMotion>
|
|
188
|
-
);
|
|
189
|
-
```
|
|
156
|
+
Questions, ideas and showcases are all welcome:
|
|
157
|
+
|
|
158
|
+
- [Discord][discord-link]
|
|
159
|
+
- [GitHub Discussions](https://github.com/lobehub/lobe-ui/discussions)
|
|
160
|
+
- [GitHub Issues][github-issues-link]
|
|
190
161
|
|
|
191
162
|
<div align="right">
|
|
192
163
|
|
|
@@ -200,7 +171,7 @@ You can use Github Codespaces for online development:
|
|
|
200
171
|
|
|
201
172
|
[![][codespaces-shield]][codespaces-link]
|
|
202
173
|
|
|
203
|
-
Or clone it for local development:
|
|
174
|
+
Or clone it for local development (Node.js >= 22.22 and pnpm):
|
|
204
175
|
|
|
205
176
|
```bash
|
|
206
177
|
$ git clone https://github.com/lobehub/lobe-ui.git
|
|
@@ -248,24 +219,15 @@ Every bit counts and your one-time donation sparkles in our galaxy of support! Y
|
|
|
248
219
|
|
|
249
220
|
## 🔗 Links
|
|
250
221
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
- **[
|
|
254
|
-
- **[
|
|
255
|
-
- **[
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
- **[
|
|
260
|
-
- **[🥨 Lobe Icons](https://lobehub.com/icons)** - Popular AI / LLM Model Brand SVG Logo and Icon Collection.
|
|
261
|
-
- **[📊 Lobe Charts](https://charts.lobehub.com)** - React modern charts components built on recharts
|
|
262
|
-
|
|
263
|
-
### Development Resources
|
|
264
|
-
|
|
265
|
-
- **[🎤 Lobe TTS](https://tts.lobehub.com)** - A high-quality & reliable TTS/STT library for Server and Browser
|
|
266
|
-
- **[🌏 Lobe i18n](https://github.com/lobehub/lobe-cli-toolbox/blob/master/packages/lobe-i18n)** - Automation ai tool for the i18n (internationalization) translation process.
|
|
267
|
-
|
|
268
|
-
[More Resources](https://lobehub.com/resources)
|
|
222
|
+
- **[🍭 Lobe UI](https://github.com/lobehub/lobe-ui)** - React component library for AI apps
|
|
223
|
+
- **[🥨 Lobe Icons](https://github.com/lobehub/lobe-icons)** - AI / LLM brand logos and icons
|
|
224
|
+
- **[📊 Lobe Charts](https://github.com/lobehub/lobe-charts)** - React chart components
|
|
225
|
+
- **[✒️ Lobe Editor](https://github.com/lobehub/lobe-editor)** - Lexical-based rich text editor for React, with Markdown, plugins and a chat composer
|
|
226
|
+
- **[🎤 Lobe TTS](https://github.com/lobehub/lobe-tts)** - TTS / STT speech library
|
|
227
|
+
- **[📐 Lobe Lint](https://github.com/lobehub/lobe-lint)** - ESLint, Prettier, Stylelint, Commitlint and more lint configs
|
|
228
|
+
- **[😀 Fluent Emoji](https://github.com/lobehub/fluent-emoji)** - Fluent Emoji assets
|
|
229
|
+
- **[📖 Docs Kit](https://github.com/lobehub/docs-kit)** - Reusable documentation toolkit and lobedocs CLI for LobeHub component libraries
|
|
230
|
+
- **[🌊 Streamdown](https://github.com/lobehub/streamdown)** - Headless streaming markdown engine for React
|
|
269
231
|
|
|
270
232
|
<div align="right">
|
|
271
233
|
|
|
@@ -298,9 +260,9 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
298
260
|
[discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
|
|
299
261
|
[fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-ui
|
|
300
262
|
[fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-ui.svg?type=large
|
|
301
|
-
[github-action-release-link]: https://github.com/
|
|
263
|
+
[github-action-release-link]: https://github.com/lobehub/lobe-ui/actions/workflows/release.yml
|
|
302
264
|
[github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-ui/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
|
303
|
-
[github-action-test-link]: https://github.com/
|
|
265
|
+
[github-action-test-link]: https://github.com/lobehub/lobe-ui/actions/workflows/test.yml
|
|
304
266
|
[github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-ui/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
|
305
267
|
[github-contributors-link]: https://github.com/lobehub/lobe-ui/graphs/contributors
|
|
306
268
|
[github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-ui?color=c4f042&labelColor=black&style=flat-square
|
|
@@ -312,13 +274,13 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
312
274
|
[github-license-shield]: https://img.shields.io/github/license/lobehub/lobe-ui?color=white&labelColor=black&style=flat-square
|
|
313
275
|
[github-releasedate-link]: https://github.com/lobehub/lobe-ui/releases
|
|
314
276
|
[github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/lobe-ui?labelColor=black&style=flat-square
|
|
315
|
-
[github-stars-link]: https://github.com/lobehub/lobe-ui/
|
|
277
|
+
[github-stars-link]: https://github.com/lobehub/lobe-ui/stargazers
|
|
316
278
|
[github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-ui?color=ffcb47&labelColor=black&style=flat-square
|
|
317
279
|
[npm-downloads-link]: https://www.npmjs.com/package/@lobehub/ui
|
|
318
280
|
[npm-downloads-shield]: https://img.shields.io/npm/dt/@lobehub/ui?labelColor=black&style=flat-square
|
|
319
281
|
[npm-release-link]: https://www.npmjs.com/package/@lobehub/ui
|
|
320
282
|
[npm-release-shield]: https://img.shields.io/npm/v/@lobehub/ui?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
|
321
|
-
[pr-welcome-link]: https://github.com/lobehub/lobe-
|
|
283
|
+
[pr-welcome-link]: https://github.com/lobehub/lobe-ui/pulls
|
|
322
284
|
[pr-welcome-shield]: https://img.shields.io/badge/🤯_pr_welcome-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
|
|
323
285
|
[profile-link]: https://github.com/lobehub
|
|
324
286
|
[vercel-link]: https://ui.lobehub.com
|
package/es/Accordion/style.d.mts
CHANGED
|
@@ -2,12 +2,12 @@ import "@stylexjs/stylex";
|
|
|
2
2
|
//#region src/Accordion/style.d.ts
|
|
3
3
|
export declare const accordionStyles: {
|
|
4
4
|
panel: string;
|
|
5
|
-
header: string;
|
|
6
5
|
action: string;
|
|
7
6
|
content: string;
|
|
8
7
|
trigger: string;
|
|
9
|
-
|
|
8
|
+
header: string;
|
|
10
9
|
root: string;
|
|
10
|
+
item: string;
|
|
11
11
|
indicator: string;
|
|
12
12
|
itemOutlined: string;
|
|
13
13
|
rootOutlined: string;
|
|
@@ -42,7 +42,7 @@ declare const styleArrays: {
|
|
|
42
42
|
}> | Readonly<{
|
|
43
43
|
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "transparent">;
|
|
44
44
|
readonly cursor: stylex.StyleXClassNameFor<"cursor", "default">;
|
|
45
|
-
readonly display: stylex.StyleXClassNameFor<"display", "
|
|
45
|
+
readonly display: stylex.StyleXClassNameFor<"display", "flex" | "none">;
|
|
46
46
|
}>)[];
|
|
47
47
|
item: Readonly<{
|
|
48
48
|
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|
package/es/Carousel/Carousel.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { useControlledState } from "../hooks/useControlledState.mjs";
|
|
|
6
6
|
import { carouselClasses } from "./stable.mjs";
|
|
7
7
|
import { styles } from "./style.mjs";
|
|
8
8
|
import clsx$1 from "clsx";
|
|
9
|
-
import { Children,
|
|
9
|
+
import { Children, isValidElement, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
12
12
|
//#region src/Carousel/Carousel.tsx
|
|
@@ -110,18 +110,18 @@ const Carousel = memo(({ adaptiveHeight = false, arrows = false, autoplay = fals
|
|
|
110
110
|
style: { transform: `translateX(-${current * 100}%)` },
|
|
111
111
|
children: slides.map((slide, slideIndex) => {
|
|
112
112
|
const active = slideIndex === current;
|
|
113
|
-
return /* @__PURE__ */
|
|
113
|
+
return /* @__PURE__ */ jsx("div", {
|
|
114
114
|
"aria-hidden": !active || void 0,
|
|
115
115
|
"aria-label": `${slideIndex + 1} of ${count}`,
|
|
116
116
|
"aria-roledescription": "slide",
|
|
117
117
|
...styleProps(styles.slide, carouselClasses("slide")),
|
|
118
118
|
inert: !active,
|
|
119
|
-
key: keys[slideIndex],
|
|
120
119
|
role: "group",
|
|
121
120
|
ref: (node) => {
|
|
122
121
|
slidesRef.current[slideIndex] = node;
|
|
123
|
-
}
|
|
124
|
-
|
|
122
|
+
},
|
|
123
|
+
children: slide
|
|
124
|
+
}, keys[slideIndex]);
|
|
125
125
|
})
|
|
126
126
|
}), arrows && count > 1 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ActionIconImpl, {
|
|
127
127
|
"aria-label": "Previous slide",
|
|
@@ -142,14 +142,13 @@ const Carousel = memo(({ adaptiveHeight = false, arrows = false, autoplay = fals
|
|
|
142
142
|
})] })]
|
|
143
143
|
}), dots && count > 1 && /* @__PURE__ */ jsx("div", {
|
|
144
144
|
...styleProps(styles.dots, carouselClasses("dots")),
|
|
145
|
-
children: slides.map((_, dotIndex) => /* @__PURE__ */
|
|
145
|
+
children: slides.map((_, dotIndex) => /* @__PURE__ */ jsx("button", {
|
|
146
146
|
"aria-current": dotIndex === current || void 0,
|
|
147
147
|
"aria-label": `Go to slide ${dotIndex + 1}`,
|
|
148
148
|
...styleProps(styles.dot, carouselClasses("dot")),
|
|
149
|
-
key: keys[dotIndex],
|
|
150
149
|
type: "button",
|
|
151
150
|
onClick: () => goTo(dotIndex)
|
|
152
|
-
}))
|
|
151
|
+
}, keys[dotIndex]))
|
|
153
152
|
})]
|
|
154
153
|
});
|
|
155
154
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.mjs","names":["clsx","ActionIcon"],"sources":["../../src/Carousel/Carousel.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\nimport {\n Children,\n isValidElement,\n memo,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { ActionIconImpl as ActionIcon } from '@/ActionIcon/ActionIcon';\nimport { useControlledState } from '@/hooks/useControlledState';\nimport { useEventCallback } from '@/hooks/useEventCallback';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { carouselClasses } from './stable';\nimport { styles } from './style';\nimport type { CarouselProps } from './type';\n\nconst DEFAULT_INTERVAL = 5000;\nconst SWIPE_THRESHOLD = 40;\nconst ARROW_SIZE = { blockSize: 28, borderRadius: '50%', size: 16 };\n\nconst Carousel = memo<CarouselProps>(\n ({\n adaptiveHeight = false,\n arrows = false,\n autoplay = false,\n children,\n className,\n defaultIndex = 0,\n dots = true,\n index,\n loop = true,\n onIndexChange,\n onPointerEnter,\n onPointerLeave,\n pauseOnHover = true,\n ref,\n ...rest\n }) => {\n const slides = Children.toArray(children);\n const count = slides.length;\n const keys = slides.map((slide, slideIndex) =>\n isValidElement(slide) && slide.key !== null ? slide.key : slideIndex,\n );\n const [mergedIndex, setMergedIndex] = useControlledState(defaultIndex, {\n onChange: onIndexChange,\n value: index,\n });\n const current = Math.min(Math.max(mergedIndex, 0), Math.max(count - 1, 0));\n\n const [hovered, setHovered] = useState(false);\n const [height, setHeight] = useState<number>();\n const slidesRef = useRef<(HTMLDivElement | null)[]>([]);\n const swipeStartXRef = useRef<number | null>(null);\n\n const goTo = useEventCallback((target: number) => {\n if (count === 0) return;\n const next = loop\n ? ((target % count) + count) % count\n : Math.min(Math.max(target, 0), count - 1);\n if (next !== current) setMergedIndex(next);\n });\n const next = useEventCallback(() => goTo(current + 1));\n const prev = useEventCallback(() => goTo(current - 1));\n\n useImperativeHandle(ref, () => ({ goTo, next, prev }), [goTo, next, prev]);\n\n const interval = autoplay === true ? DEFAULT_INTERVAL : autoplay || 0;\n const paused = pauseOnHover && hovered;\n const atEnd = !loop && current >= count - 1;\n\n useEffect(() => {\n if (!interval || paused || count < 2 || atEnd) return;\n const timer = setTimeout(next, interval);\n return () => clearTimeout(timer);\n }, [interval, paused, count, atEnd, current, next]);\n\n useLayoutEffect(() => {\n const slide = slidesRef.current[current];\n if (!adaptiveHeight || !slide) return;\n setHeight(slide.offsetHeight);\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => setHeight(slide.offsetHeight));\n observer.observe(slide);\n return () => observer.disconnect();\n }, [adaptiveHeight, current, count]);\n\n return (\n <div\n aria-roledescription=\"carousel\"\n className={styleProps(styles.root, clsx(carouselClasses(), className)).className}\n role=\"region\"\n onPointerEnter={(event) => {\n onPointerEnter?.(event);\n setHovered(true);\n }}\n onPointerLeave={(event) => {\n onPointerLeave?.(event);\n setHovered(false);\n }}\n {...rest}\n >\n <div\n {...styleProps(styles.viewport, carouselClasses('viewport'))}\n style={adaptiveHeight && height !== undefined ? { height } : undefined}\n onPointerCancel={() => {\n swipeStartXRef.current = null;\n }}\n onPointerDown={(event) => {\n if (event.pointerType !== 'mouse') swipeStartXRef.current = event.clientX;\n }}\n onPointerUp={(event) => {\n if (swipeStartXRef.current === null) return;\n const delta = event.clientX - swipeStartXRef.current;\n swipeStartXRef.current = null;\n if (Math.abs(delta) < SWIPE_THRESHOLD) return;\n if (delta < 0) next();\n else prev();\n }}\n >\n <div\n aria-live={interval && !paused ? 'off' : 'polite'}\n {...styleProps(\n [styles.track, adaptiveHeight && styles.trackAdaptive],\n carouselClasses('track'),\n )}\n style={{ transform: `translateX(-${current * 100}%)` }}\n >\n {slides.map((slide, slideIndex) => {\n const active = slideIndex === current;\n return (\n <div\n aria-hidden={!active || undefined}\n aria-label={`${slideIndex + 1} of ${count}`}\n aria-roledescription=\"slide\"\n {...styleProps(styles.slide, carouselClasses('slide'))}\n inert={!active}\n key={keys[slideIndex]}\n role=\"group\"\n ref={(node) => {\n slidesRef.current[slideIndex] = node;\n }}\n >\n {slide}\n </div>\n );\n })}\n </div>\n {arrows && count > 1 && (\n <>\n <ActionIcon\n aria-label=\"Previous slide\"\n className={carouselClasses('prev')}\n disabled={!loop && current === 0}\n icon={ChevronLeft}\n size={ARROW_SIZE}\n xstyle={[styles.arrow, styles.arrowPrev]}\n onClick={prev}\n />\n <ActionIcon\n aria-label=\"Next slide\"\n className={carouselClasses('next')}\n disabled={atEnd}\n icon={ChevronRight}\n size={ARROW_SIZE}\n xstyle={[styles.arrow, styles.arrowNext]}\n onClick={next}\n />\n </>\n )}\n </div>\n {dots && count > 1 && (\n <div {...styleProps(styles.dots, carouselClasses('dots'))}>\n {slides.map((_, dotIndex) => (\n <button\n aria-current={dotIndex === current || undefined}\n aria-label={`Go to slide ${dotIndex + 1}`}\n {...styleProps(styles.dot, carouselClasses('dot'))}\n key={keys[dotIndex]}\n type=\"button\"\n onClick={() => goTo(dotIndex)}\n />\n ))}\n </div>\n )}\n </div>\n );\n },\n);\n\nCarousel.displayName = 'Carousel';\n\nexport default Carousel;\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,aAAa;CAAE,WAAW;CAAI,cAAc;CAAO,MAAM;AAAG;AAElE,MAAM,WAAW,MACd,EACC,iBAAiB,OACjB,SAAS,OACT,WAAW,OACX,UACA,WACA,eAAe,GACf,OAAO,MACP,OACA,OAAO,MACP,eACA,gBACA,gBACA,eAAe,MACf,KACA,GAAG,WACC;CACJ,MAAM,SAAS,SAAS,QAAQ,QAAQ;CACxC,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,KAAK,OAAO,eAC9B,eAAe,KAAK,KAAK,MAAM,QAAQ,OAAO,MAAM,MAAM,UAC5D;CACA,MAAM,CAAC,aAAa,kBAAkB,mBAAmB,cAAc;EACrE,UAAU;EACV,OAAO;CACT,CAAC;CACD,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI,aAAa,CAAC,GAAG,KAAK,IAAI,QAAQ,GAAG,CAAC,CAA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A,UAAA,CACE,oBAACC,gBAAD;IACE,cAAW;IACX,WAAW,gBAAgB,MAAM;IACjC,UAAU,CAAC,QAAQ,YAAY;IAC/B,MAAM;IACN,MAAM;IACN,QAAQ,CAAC,OAAO,OAAO,OAAO,SAAS;IACvC,SAAS;GACV,CAAA,GACD,oBAACA,gBAAD;IACE,cAAW;IACX,WAAW,gBAAgB,MAAM;IACjC,UAAU;IACV,MAAM;IACN,MAAM;IACN,QAAQ,CAAC,OAAO,OAAO,OAAO,SAAS;IACvC,SAAS;GACV,CAAA,CACD,EAAA,CAAA,CAED;EACJ,CAAA,GAAA,QAAQ,QAAQ,KACf,oBAAC,OAAD;GAAK,GAAI,WAAW,OAAO,MAAM,gBAAgB,MAAM,CAAC;GACrD,UAAA,OAAO,KAAK,GAAG,aACd,8BAAC,UAAD;IACE,gBAAc,aAAa,WAAW,KAAA;IACtC,cAAY,eAAe,WAAW;IACtC,GAAI,WAAW,OAAO,KAAK,gBAAgB,KAAK,CAAC;IACjD,KAAK,KAAK;IACV,MAAK;IACL,eAAe,KAAK,QAAQ;GAC7B,CAAA,CACF;EACE,CAAA,CAEJ;;AAET,CACF;AAEA,SAAS,cAAc"}
|
|
1
|
+
{"version":3,"file":"Carousel.mjs","names":["clsx","ActionIcon"],"sources":["../../src/Carousel/Carousel.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\nimport {\n Children,\n isValidElement,\n memo,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { ActionIconImpl as ActionIcon } from '@/ActionIcon/ActionIcon';\nimport { useControlledState } from '@/hooks/useControlledState';\nimport { useEventCallback } from '@/hooks/useEventCallback';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { carouselClasses } from './stable';\nimport { styles } from './style';\nimport type { CarouselProps } from './type';\n\nconst DEFAULT_INTERVAL = 5000;\nconst SWIPE_THRESHOLD = 40;\nconst ARROW_SIZE = { blockSize: 28, borderRadius: '50%', size: 16 };\n\nconst Carousel = memo<CarouselProps>(\n ({\n adaptiveHeight = false,\n arrows = false,\n autoplay = false,\n children,\n className,\n defaultIndex = 0,\n dots = true,\n index,\n loop = true,\n onIndexChange,\n onPointerEnter,\n onPointerLeave,\n pauseOnHover = true,\n ref,\n ...rest\n }) => {\n const slides = Children.toArray(children);\n const count = slides.length;\n const keys = slides.map((slide, slideIndex) =>\n isValidElement(slide) && slide.key !== null ? slide.key : slideIndex,\n );\n const [mergedIndex, setMergedIndex] = useControlledState(defaultIndex, {\n onChange: onIndexChange,\n value: index,\n });\n const current = Math.min(Math.max(mergedIndex, 0), Math.max(count - 1, 0));\n\n const [hovered, setHovered] = useState(false);\n const [height, setHeight] = useState<number>();\n const slidesRef = useRef<(HTMLDivElement | null)[]>([]);\n const swipeStartXRef = useRef<number | null>(null);\n\n const goTo = useEventCallback((target: number) => {\n if (count === 0) return;\n const next = loop\n ? ((target % count) + count) % count\n : Math.min(Math.max(target, 0), count - 1);\n if (next !== current) setMergedIndex(next);\n });\n const next = useEventCallback(() => goTo(current + 1));\n const prev = useEventCallback(() => goTo(current - 1));\n\n useImperativeHandle(ref, () => ({ goTo, next, prev }), [goTo, next, prev]);\n\n const interval = autoplay === true ? DEFAULT_INTERVAL : autoplay || 0;\n const paused = pauseOnHover && hovered;\n const atEnd = !loop && current >= count - 1;\n\n useEffect(() => {\n if (!interval || paused || count < 2 || atEnd) return;\n const timer = setTimeout(next, interval);\n return () => clearTimeout(timer);\n }, [interval, paused, count, atEnd, current, next]);\n\n useLayoutEffect(() => {\n const slide = slidesRef.current[current];\n if (!adaptiveHeight || !slide) return;\n setHeight(slide.offsetHeight);\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => setHeight(slide.offsetHeight));\n observer.observe(slide);\n return () => observer.disconnect();\n }, [adaptiveHeight, current, count]);\n\n return (\n <div\n aria-roledescription=\"carousel\"\n className={styleProps(styles.root, clsx(carouselClasses(), className)).className}\n role=\"region\"\n onPointerEnter={(event) => {\n onPointerEnter?.(event);\n setHovered(true);\n }}\n onPointerLeave={(event) => {\n onPointerLeave?.(event);\n setHovered(false);\n }}\n {...rest}\n >\n <div\n {...styleProps(styles.viewport, carouselClasses('viewport'))}\n style={adaptiveHeight && height !== undefined ? { height } : undefined}\n onPointerCancel={() => {\n swipeStartXRef.current = null;\n }}\n onPointerDown={(event) => {\n if (event.pointerType !== 'mouse') swipeStartXRef.current = event.clientX;\n }}\n onPointerUp={(event) => {\n if (swipeStartXRef.current === null) return;\n const delta = event.clientX - swipeStartXRef.current;\n swipeStartXRef.current = null;\n if (Math.abs(delta) < SWIPE_THRESHOLD) return;\n if (delta < 0) next();\n else prev();\n }}\n >\n <div\n aria-live={interval && !paused ? 'off' : 'polite'}\n {...styleProps(\n [styles.track, adaptiveHeight && styles.trackAdaptive],\n carouselClasses('track'),\n )}\n style={{ transform: `translateX(-${current * 100}%)` }}\n >\n {slides.map((slide, slideIndex) => {\n const active = slideIndex === current;\n return (\n <div\n aria-hidden={!active || undefined}\n aria-label={`${slideIndex + 1} of ${count}`}\n aria-roledescription=\"slide\"\n key={keys[slideIndex]}\n {...styleProps(styles.slide, carouselClasses('slide'))}\n inert={!active}\n role=\"group\"\n ref={(node) => {\n slidesRef.current[slideIndex] = node;\n }}\n >\n {slide}\n </div>\n );\n })}\n </div>\n {arrows && count > 1 && (\n <>\n <ActionIcon\n aria-label=\"Previous slide\"\n className={carouselClasses('prev')}\n disabled={!loop && current === 0}\n icon={ChevronLeft}\n size={ARROW_SIZE}\n xstyle={[styles.arrow, styles.arrowPrev]}\n onClick={prev}\n />\n <ActionIcon\n aria-label=\"Next slide\"\n className={carouselClasses('next')}\n disabled={atEnd}\n icon={ChevronRight}\n size={ARROW_SIZE}\n xstyle={[styles.arrow, styles.arrowNext]}\n onClick={next}\n />\n </>\n )}\n </div>\n {dots && count > 1 && (\n <div {...styleProps(styles.dots, carouselClasses('dots'))}>\n {slides.map((_, dotIndex) => (\n <button\n aria-current={dotIndex === current || undefined}\n aria-label={`Go to slide ${dotIndex + 1}`}\n key={keys[dotIndex]}\n {...styleProps(styles.dot, carouselClasses('dot'))}\n type=\"button\"\n onClick={() => goTo(dotIndex)}\n />\n ))}\n </div>\n )}\n </div>\n );\n },\n);\n\nCarousel.displayName = 'Carousel';\n\nexport default Carousel;\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,aAAa;CAAE,WAAW;CAAI,cAAc;CAAO,MAAM;AAAG;AAElE,MAAM,WAAW,MACd,EACC,iBAAiB,OACjB,SAAS,OACT,WAAW,OACX,UACA,WACA,eAAe,GACf,OAAO,MACP,OACA,OAAO,MACP,eACA,gBACA,gBACA,eAAe,MACf,KACA,GAAG,WACC;CACJ,MAAM,SAAS,SAAS,QAAQ,QAAQ;CACxC,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,KAAK,OAAO,eAC9B,eAAe,KAAK,KAAK,MAAM,QAAQ,OAAO,MAAM,MAAM,UAC5D;CACA,MAAM,CAAC,aAAa,kBAAkB,mBAAmB,cAAc;EACrE,UAAU;EACV,OAAO;CACT,CAAC;CACD,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI,aAAa,CAAC,GAAG,KAAK,IAAI,QAAQ,GAAG,CAAC,CAAC;CAEzE,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,QAAQ,aAAa,SAAiB;CAC7C,MAAM,YAAY,OAAkC,CAAC,CAAC;CACtD,MAAM,iBAAiB,OAAsB,IAAI;CAEjD,MAAM,OAAO,kBAAkB,WAAmB;EAChD,IAAI,UAAU,GAAG;EACjB,MAAM,OAAO,QACP,SAAS,QAAS,SAAS,QAC7B,KAAK,IAAI,KAAK,IAAI,QAAQ,CAAC,GAAG,QAAQ,CAAC;EAC3C,IAAI,SAAS,SAAS,eAAe,IAAI;CAC3C,CAAC;CACD,MAAM,O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,QAAQ,KACf,oBAAC,OAAD;GAAK,GAAI,WAAW,OAAO,MAAM,gBAAgB,MAAM,CAAC;GACrD,UAAA,OAAO,KAAK,GAAG,aACd,oBAAC,UAAD;IACE,gBAAc,aAAa,WAAW,KAAA;IACtC,cAAY,eAAe,WAAW;IAEtC,GAAI,WAAW,OAAO,KAAK,gBAAgB,KAAK,CAAC;IACjD,MAAK;IACL,eAAe,KAAK,QAAQ;GAC7B,GAJM,KAAK,SAIX,CACF;EACE,CAAA,CAEJ;;AAET,CACF;AAEA,SAAS,cAAc"}
|
package/es/Drawer/atoms.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { DrawerLayerProvider, useDrawerLayer } from "./DrawerLayerContext.mjs";
|
|
|
12
12
|
import { drawerClasses } from "./stable.mjs";
|
|
13
13
|
import { styles } from "./style.mjs";
|
|
14
14
|
import clsx$1 from "clsx";
|
|
15
|
-
import { cloneElement, createContext,
|
|
15
|
+
import { cloneElement, createContext, isValidElement, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
16
16
|
import { jsx } from "react/jsx-runtime";
|
|
17
17
|
import * as stylex from "@stylexjs/stylex";
|
|
18
18
|
import { X } from "lucide-react";
|
|
@@ -178,18 +178,18 @@ const DrawerPopupImpl = ({ className, children, placement: placementProp = "righ
|
|
|
178
178
|
className: clsx$1(stylex.props(popupXstyle).className, drawerClasses("popup"), className),
|
|
179
179
|
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
180
180
|
onExitComplete: actions.onExitComplete,
|
|
181
|
-
children: open ? /* @__PURE__ */
|
|
181
|
+
children: open ? /* @__PURE__ */ jsx(Motion.div, {
|
|
182
182
|
...motionConfig,
|
|
183
183
|
...motionProps,
|
|
184
184
|
className: resolvedPanelClassName,
|
|
185
185
|
"data-drawer-placement": placement,
|
|
186
186
|
"data-placement": placement,
|
|
187
|
-
key: "drawer-popup-panel",
|
|
188
187
|
style: {
|
|
189
188
|
transition: "none",
|
|
190
189
|
...panelStyle
|
|
191
|
-
}
|
|
192
|
-
|
|
190
|
+
},
|
|
191
|
+
children
|
|
192
|
+
}, "drawer-popup-panel") : null
|
|
193
193
|
})
|
|
194
194
|
});
|
|
195
195
|
}
|
package/es/Drawer/atoms.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/Drawer/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Dialog } from '@base-ui/react/dialog';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport { X } from 'lucide-react';\nimport { AnimatePresence } from 'motion/react';\nimport type React from 'react';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useAppElement } from '@/ConfigProvider/AppElementContext';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { useMotionComponent } from '@/MotionProvider';\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { getElementRef } from '@/utils/getElementRef';\nimport { mergeRefs, useMergeRefs } from '@/utils/mergeRefs';\n\nimport { useLayerZIndex } from '../internal/zIndex';\nimport { drawerBackdropTransition, getDrawerMotionConfig, pushAxis } from './constants';\nimport { DrawerLayerProvider, useDrawerLayer } from './DrawerLayerContext';\nimport { drawerClasses } from './stable';\nimport { styles } from './style';\nimport type { DrawerPlacement } from './type';\n\ntype XStyle = Parameters<typeof styleProps>[0];\n\nconst mergeStateClassName = <TState,>(\n xstyle: XStyle,\n className: string | ((state: TState) => string | undefined) | undefined,\n stableClassName?: string,\n) => {\n const base = clsx(stylex.props(xstyle).className, stableClassName);\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\nconst popupPlacementClass = {\n bottom: styles.popupBottom,\n left: styles.popupLeft,\n right: styles.popupRight,\n top: styles.popupTop,\n};\n\nconst panelPlacementClass = {\n bottom: styles.panelBottom,\n left: styles.panelLeft,\n right: styles.panelRight,\n top: styles.panelTop,\n};\n\nconst panelRoundedClass = {\n bottom: styles.panelRoundedBottom,\n left: styles.panelRoundedLeft,\n right: styles.panelRoundedRight,\n top: styles.panelRoundedTop,\n};\n\nconst DrawerOpenContext = createContext<boolean | null>(null);\n\ninterface DrawerAnimationActions {\n onExitComplete: () => void;\n}\nconst DrawerActionsContext = createContext<DrawerAnimationActions | null>(null);\n\nexport const useDrawerOpen = () => use(DrawerOpenContext);\nexport const useDrawerActions = () => use(DrawerActionsContext);\n\nexport type DrawerRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedDrawerRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<DrawerRootProps, 'open'> & { open: boolean }) => {\n const [isPresent, setIsPresent] = useState(!!open);\n\n useEffect(() => {\n if (open) setIsPresent(true);\n }, [open]);\n\n const handleExitComplete = useCallback(() => {\n setIsPresent(false);\n onExitCompleteProp?.();\n }, [onExitCompleteProp]);\n\n const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);\n\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n if (!isPresent) return null;\n\n return (\n <DrawerOpenContext value={open}>\n <DrawerActionsContext value={actions}>\n <DrawerLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </DrawerLayerProvider>\n </DrawerActionsContext>\n </DrawerOpenContext>\n );\n};\n\nconst NonAnimatedDrawerRoot = ({ zIndex: explicitZIndex, children, ...rest }: DrawerRootProps) => {\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n return (\n <DrawerLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </DrawerLayerProvider>\n );\n};\n\nexport const DrawerRoot = ({ open, onExitComplete, ...rest }: DrawerRootProps) => {\n if (open !== undefined) {\n return <AnimatedDrawerRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedDrawerRoot {...rest} />;\n};\n\nexport type DrawerPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const DrawerPortal = ({ container, ...rest }: DrawerPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\nexport type DrawerBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const DrawerBackdrop = ({ className, style, ...rest }: DrawerBackdropProps) => {\n const open = useDrawerOpen();\n const layer = useDrawerLayer();\n const Motion = useMotionComponent();\n const layerStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex } : undefined;\n\n if (open !== null) {\n return (\n <Dialog.Backdrop\n {...rest}\n style={{ ...layerStyle, ...style, transition: 'none' }}\n className={clsx(\n stylex.props(styles.backdrop).className,\n drawerClasses('backdrop'),\n className as string,\n )}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={drawerBackdropTransition}\n />\n }\n />\n );\n }\n\n return (\n <Dialog.Backdrop\n {...rest}\n style={{ ...layerStyle, ...style }}\n className={\n mergeStateClassName(styles.backdrop, className as any, drawerClasses('backdrop')) as any\n }\n />\n );\n};\n\nexport type DrawerPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n flush?: boolean;\n height?: number | string;\n motionProps?: Record<string, any>;\n panelClassName?: string;\n panelStyle?: React.CSSProperties;\n placement?: DrawerPlacement;\n popupStyle?: React.CSSProperties;\n pushOffset?: number;\n width?: number | string;\n};\n\nexport const DrawerPopupImpl = ({\n className,\n children,\n placement: placementProp = 'right',\n width: widthProp,\n height: heightProp,\n flush,\n pushOffset = 0,\n motionProps,\n panelClassName,\n panelStyle,\n panelXstyle,\n popupStyle,\n ref: forwardedRef,\n defaultSize,\n ...rest\n}: DrawerPopupProps & { defaultSize?: boolean; panelXstyle?: XStyle }) => {\n const open = useDrawerOpen();\n const actions = useDrawerActions();\n const layer = useDrawerLayer();\n const Motion = useMotionComponent();\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n // The exiting panel lives inside AnimatePresence and keeps the props it had while open,\n // but this popup re-renders with whatever the consumer passes now. Freezing the geometry\n // during exit keeps the two in sync — otherwise a placement change on close teleports the\n // popup to the new edge while the panel animates out along the old axis.\n const openGeometryRef = useRef({\n height: heightProp,\n placement: placementProp,\n width: widthProp,\n });\n if (open !== false) {\n openGeometryRef.current = { height: heightProp, placement: placementProp, width: widthProp };\n }\n const { height, placement, width } = openGeometryRef.current;\n\n const isHorizontal = placement === 'left' || placement === 'right';\n const sizeStyle: React.CSSProperties = isHorizontal ? { width } : { height };\n const resolvedPopupStyle: React.CSSProperties = {\n ...(layer?.zIndex === undefined ? undefined : { zIndex: layer.zIndex + 1 }),\n ...sizeStyle,\n ...popupStyle,\n };\n const popupXstyle = [\n styles.popup,\n popupPlacementClass[placement],\n defaultSize &&\n (isHorizontal\n ? width === undefined && styles.popupDefaultWidth\n : height === undefined && styles.popupDefaultHeight),\n ];\n const resolvedPanelClassName = clsx(\n stylex.props(\n styles.panel,\n panelPlacementClass[placement],\n flush ? styles.panelFlush : panelRoundedClass[placement],\n panelXstyle,\n ).className,\n drawerClasses(),\n panelClassName,\n );\n\n if (open !== null && actions) {\n const motionConfig = getDrawerMotionConfig(placement, pushOffset);\n return (\n <Dialog.Popup\n {...rest}\n data-drawer-anchor={placement}\n data-placement={placement}\n ref={composedRef as any}\n style={resolvedPopupStyle}\n className={clsx(\n stylex.props(popupXstyle).className,\n drawerClasses('popup'),\n className as string,\n )}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n {...motionConfig}\n {...motionProps}\n className={resolvedPanelClassName}\n data-drawer-placement={placement}\n data-placement={placement}\n key=\"drawer-popup-panel\"\n style={{ transition: 'none', ...panelStyle }}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n const { axis, sign } = pushAxis[placement];\n const pushVars = {\n [axis === 'x' ? '--drawer-push-x' : '--drawer-push-y']: `${pushOffset * sign}px`,\n } as React.CSSProperties;\n\n return (\n <Dialog.Popup\n {...rest}\n className={mergeStateClassName(popupXstyle, className as any, drawerClasses('popup')) as any}\n data-drawer-anchor={placement}\n data-placement={placement}\n ref={composedRef as any}\n style={resolvedPopupStyle}\n >\n <div\n className={resolvedPanelClassName}\n data-drawer-placement={placement}\n data-placement={placement}\n style={{ ...pushVars, ...panelStyle }}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\nexport const DrawerPopup: React.FC<DrawerPopupProps> = DrawerPopupImpl;\n\nexport type DrawerHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerHeader = ({ className, style, ...rest }: DrawerHeaderProps) => (\n <div {...rest} {...styleProps(styles.header, clsx(drawerClasses('header'), className), style)} />\n);\n\nexport type DrawerTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const DrawerTitle = ({ className, ...rest }: DrawerTitleProps) => (\n <Dialog.Title\n {...rest}\n className={mergeStateClassName(styles.title, className as any, drawerClasses('title')) as any}\n />\n);\n\nexport type DrawerDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const DrawerDescription: React.FC<DrawerDescriptionProps> = ({ className, ...rest }) => (\n <Dialog.Description\n {...rest}\n className={\n mergeStateClassName(undefined, className as any, drawerClasses('description')) as any\n }\n />\n);\n\nexport type DrawerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerContentImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: DrawerContentProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.content, xstyle], clsx(drawerClasses('content'), className), style)}\n />\n);\nexport const DrawerContent: React.FC<DrawerContentProps> = DrawerContentImpl;\n\nexport type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerFooter = ({ className, style, ...rest }: DrawerFooterProps) => (\n <div {...rest} {...styleProps(styles.footer, clsx(drawerClasses('footer'), className), style)} />\n);\n\nexport type DrawerCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const DrawerClose = ({ className, children, ...rest }: DrawerCloseProps) => (\n <Dialog.Close\n {...rest}\n className={\n mergeStateClassName(\n [styles.close, focusRing.info],\n className as any,\n drawerClasses('close'),\n ) as any\n }\n >\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\n\nexport type DrawerTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const DrawerTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: DrawerTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n ref: mergeRefs([getElementRef(children), (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return (\n <Dialog.Trigger\n {...rest}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n className={\n mergeStateClassName(undefined, className as any, drawerClasses('trigger')) as any\n }\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={mergeStateClassName(undefined, className as any, drawerClasses('trigger')) as any}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,uBAAgC,QAAgB,WAAyE,oBAA6B;CAC1J,MAAM,OAAOA,OAAK,OAAO,MAAM,MAAM,CAAC,CAAC,WAAW,eAAe;CACjE,IAAI,OAAO,cAAc,YAAY,QAAQ,UAAkBA,OAAK,MAAM,UAAU,KAAK,CAAC;CAC1F,OAAOA,OAAK,MAAM,SAAS;AAC7B;AACA,MAAM,sBAAsB;CAC1B,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AACA,MAAM,sBAAsB;CAC1B,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AACA,MAAM,oBAAoB;CACxB,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AACA,MAAM,oBAAoB,cAA8B,IAAI;AAI5D,MAAM,uBAAuB,cAA6C,IAAI;AAC9E,MAAa,sBAAsB,IAAI,iBAAiB;AACxD,MAAa,yBAAyB,IAAI,oBAAoB;AAK9D,MAAM,sBAAsB,EAC1B,MACA,UACA,gBAAgB,oBAChB,QAAQ,gBACR,GAAG,WAGC;CACJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,CAAC,CAAC,IAAI;CACjD,gBAAgB;EACd,IAAI,MAAM,aAAa,IAAI;CAC7B,GAAG,CAAC,IAAI,CAAC;CACT,MAAM,qBAAqB,kBAAkB;EAC3C,aAAa,KAAK;EAClB,qBAAqB;CACvB,GAAG,CAAC,kBAAkB,CAAC;CACvB,MAAM,UAAU,eAAe,EAC7B,gBAAgB,mBAClB,IAAI,CAAC,kBAAkB,CAAC;CACxB,MAAM,EACJ,QACA,KAA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J,MACA,GAAG,cACD;GACJ,OAAO;EACT,EAAA,CAAG;EACH,MAAM,cAAc,WAAY,SAAiB,OAAO,aAAa;EACrE,OAAO,aAAa,UAAiB;GACnC,GAAG;GACH,KAAK,UAAU;IAAC,cAAc,QAAQ;IAAI,MAAc;IAAK;GAAO,CAAC;EACvE,CAAC;CACH;CACA,IAAI,eAAe,QAAQ,GACzB,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAM,cAAc;EAAsB,QAAQ;EAAiB,WAAW,oBAAoB,KAAA,GAAW,WAAkB,cAAc,SAAS,CAAC;CAAW,CAAA;CAE/L,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAM,WAAW,oBAAoB,KAAA,GAAW,WAAkB,cAAc,SAAS,CAAC;EAAU,cAAc;EAAsB,KAAK;EACnK;CACa,CAAA;AACpB"}
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/Drawer/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Dialog } from '@base-ui/react/dialog';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport { X } from 'lucide-react';\nimport { AnimatePresence } from 'motion/react';\nimport type React from 'react';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useAppElement } from '@/ConfigProvider/AppElementContext';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { useMotionComponent } from '@/MotionProvider';\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { getElementRef } from '@/utils/getElementRef';\nimport { mergeRefs, useMergeRefs } from '@/utils/mergeRefs';\n\nimport { useLayerZIndex } from '../internal/zIndex';\nimport { drawerBackdropTransition, getDrawerMotionConfig, pushAxis } from './constants';\nimport { DrawerLayerProvider, useDrawerLayer } from './DrawerLayerContext';\nimport { drawerClasses } from './stable';\nimport { styles } from './style';\nimport type { DrawerPlacement } from './type';\n\ntype XStyle = Parameters<typeof styleProps>[0];\n\nconst mergeStateClassName = <TState,>(\n xstyle: XStyle,\n className: string | ((state: TState) => string | undefined) | undefined,\n stableClassName?: string,\n) => {\n const base = clsx(stylex.props(xstyle).className, stableClassName);\n if (typeof className === 'function') return (state: TState) => clsx(base, className(state));\n return clsx(base, className);\n};\n\nconst popupPlacementClass = {\n bottom: styles.popupBottom,\n left: styles.popupLeft,\n right: styles.popupRight,\n top: styles.popupTop,\n};\n\nconst panelPlacementClass = {\n bottom: styles.panelBottom,\n left: styles.panelLeft,\n right: styles.panelRight,\n top: styles.panelTop,\n};\n\nconst panelRoundedClass = {\n bottom: styles.panelRoundedBottom,\n left: styles.panelRoundedLeft,\n right: styles.panelRoundedRight,\n top: styles.panelRoundedTop,\n};\n\nconst DrawerOpenContext = createContext<boolean | null>(null);\n\ninterface DrawerAnimationActions {\n onExitComplete: () => void;\n}\nconst DrawerActionsContext = createContext<DrawerAnimationActions | null>(null);\n\nexport const useDrawerOpen = () => use(DrawerOpenContext);\nexport const useDrawerActions = () => use(DrawerActionsContext);\n\nexport type DrawerRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedDrawerRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<DrawerRootProps, 'open'> & { open: boolean }) => {\n const [isPresent, setIsPresent] = useState(!!open);\n\n useEffect(() => {\n if (open) setIsPresent(true);\n }, [open]);\n\n const handleExitComplete = useCallback(() => {\n setIsPresent(false);\n onExitCompleteProp?.();\n }, [onExitCompleteProp]);\n\n const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);\n\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n if (!isPresent) return null;\n\n return (\n <DrawerOpenContext value={open}>\n <DrawerActionsContext value={actions}>\n <DrawerLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </DrawerLayerProvider>\n </DrawerActionsContext>\n </DrawerOpenContext>\n );\n};\n\nconst NonAnimatedDrawerRoot = ({ zIndex: explicitZIndex, children, ...rest }: DrawerRootProps) => {\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n return (\n <DrawerLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </DrawerLayerProvider>\n );\n};\n\nexport const DrawerRoot = ({ open, onExitComplete, ...rest }: DrawerRootProps) => {\n if (open !== undefined) {\n return <AnimatedDrawerRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedDrawerRoot {...rest} />;\n};\n\nexport type DrawerPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const DrawerPortal = ({ container, ...rest }: DrawerPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\nexport type DrawerBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const DrawerBackdrop = ({ className, style, ...rest }: DrawerBackdropProps) => {\n const open = useDrawerOpen();\n const layer = useDrawerLayer();\n const Motion = useMotionComponent();\n const layerStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex } : undefined;\n\n if (open !== null) {\n return (\n <Dialog.Backdrop\n {...rest}\n style={{ ...layerStyle, ...style, transition: 'none' }}\n className={clsx(\n stylex.props(styles.backdrop).className,\n drawerClasses('backdrop'),\n className as string,\n )}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={drawerBackdropTransition}\n />\n }\n />\n );\n }\n\n return (\n <Dialog.Backdrop\n {...rest}\n style={{ ...layerStyle, ...style }}\n className={\n mergeStateClassName(styles.backdrop, className as any, drawerClasses('backdrop')) as any\n }\n />\n );\n};\n\nexport type DrawerPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n flush?: boolean;\n height?: number | string;\n motionProps?: Record<string, any>;\n panelClassName?: string;\n panelStyle?: React.CSSProperties;\n placement?: DrawerPlacement;\n popupStyle?: React.CSSProperties;\n pushOffset?: number;\n width?: number | string;\n};\n\nexport const DrawerPopupImpl = ({\n className,\n children,\n placement: placementProp = 'right',\n width: widthProp,\n height: heightProp,\n flush,\n pushOffset = 0,\n motionProps,\n panelClassName,\n panelStyle,\n panelXstyle,\n popupStyle,\n ref: forwardedRef,\n defaultSize,\n ...rest\n}: DrawerPopupProps & { defaultSize?: boolean; panelXstyle?: XStyle }) => {\n const open = useDrawerOpen();\n const actions = useDrawerActions();\n const layer = useDrawerLayer();\n const Motion = useMotionComponent();\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n // The exiting panel lives inside AnimatePresence and keeps the props it had while open,\n // but this popup re-renders with whatever the consumer passes now. Freezing the geometry\n // during exit keeps the two in sync — otherwise a placement change on close teleports the\n // popup to the new edge while the panel animates out along the old axis.\n const openGeometryRef = useRef({\n height: heightProp,\n placement: placementProp,\n width: widthProp,\n });\n if (open !== false) {\n openGeometryRef.current = { height: heightProp, placement: placementProp, width: widthProp };\n }\n const { height, placement, width } = openGeometryRef.current;\n\n const isHorizontal = placement === 'left' || placement === 'right';\n const sizeStyle: React.CSSProperties = isHorizontal ? { width } : { height };\n const resolvedPopupStyle: React.CSSProperties = {\n ...(layer?.zIndex === undefined ? undefined : { zIndex: layer.zIndex + 1 }),\n ...sizeStyle,\n ...popupStyle,\n };\n const popupXstyle = [\n styles.popup,\n popupPlacementClass[placement],\n defaultSize &&\n (isHorizontal\n ? width === undefined && styles.popupDefaultWidth\n : height === undefined && styles.popupDefaultHeight),\n ];\n const resolvedPanelClassName = clsx(\n stylex.props(\n styles.panel,\n panelPlacementClass[placement],\n flush ? styles.panelFlush : panelRoundedClass[placement],\n panelXstyle,\n ).className,\n drawerClasses(),\n panelClassName,\n );\n\n if (open !== null && actions) {\n const motionConfig = getDrawerMotionConfig(placement, pushOffset);\n return (\n <Dialog.Popup\n {...rest}\n data-drawer-anchor={placement}\n data-placement={placement}\n ref={composedRef as any}\n style={resolvedPopupStyle}\n className={clsx(\n stylex.props(popupXstyle).className,\n drawerClasses('popup'),\n className as string,\n )}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n key=\"drawer-popup-panel\"\n {...motionConfig}\n {...motionProps}\n className={resolvedPanelClassName}\n data-drawer-placement={placement}\n data-placement={placement}\n style={{ transition: 'none', ...panelStyle }}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n const { axis, sign } = pushAxis[placement];\n const pushVars = {\n [axis === 'x' ? '--drawer-push-x' : '--drawer-push-y']: `${pushOffset * sign}px`,\n } as React.CSSProperties;\n\n return (\n <Dialog.Popup\n {...rest}\n className={mergeStateClassName(popupXstyle, className as any, drawerClasses('popup')) as any}\n data-drawer-anchor={placement}\n data-placement={placement}\n ref={composedRef as any}\n style={resolvedPopupStyle}\n >\n <div\n className={resolvedPanelClassName}\n data-drawer-placement={placement}\n data-placement={placement}\n style={{ ...pushVars, ...panelStyle }}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\nexport const DrawerPopup: React.FC<DrawerPopupProps> = DrawerPopupImpl;\n\nexport type DrawerHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerHeader = ({ className, style, ...rest }: DrawerHeaderProps) => (\n <div {...rest} {...styleProps(styles.header, clsx(drawerClasses('header'), className), style)} />\n);\n\nexport type DrawerTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const DrawerTitle = ({ className, ...rest }: DrawerTitleProps) => (\n <Dialog.Title\n {...rest}\n className={mergeStateClassName(styles.title, className as any, drawerClasses('title')) as any}\n />\n);\n\nexport type DrawerDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const DrawerDescription: React.FC<DrawerDescriptionProps> = ({ className, ...rest }) => (\n <Dialog.Description\n {...rest}\n className={\n mergeStateClassName(undefined, className as any, drawerClasses('description')) as any\n }\n />\n);\n\nexport type DrawerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerContentImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: DrawerContentProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.content, xstyle], clsx(drawerClasses('content'), className), style)}\n />\n);\nexport const DrawerContent: React.FC<DrawerContentProps> = DrawerContentImpl;\n\nexport type DrawerFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const DrawerFooter = ({ className, style, ...rest }: DrawerFooterProps) => (\n <div {...rest} {...styleProps(styles.footer, clsx(drawerClasses('footer'), className), style)} />\n);\n\nexport type DrawerCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const DrawerClose = ({ className, children, ...rest }: DrawerCloseProps) => (\n <Dialog.Close\n {...rest}\n className={\n mergeStateClassName(\n [styles.close, focusRing.info],\n className as any,\n drawerClasses('close'),\n ) as any\n }\n >\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\n\nexport type DrawerTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const DrawerTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: DrawerTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n ref: mergeRefs([getElementRef(children), (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return (\n <Dialog.Trigger\n {...rest}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n className={\n mergeStateClassName(undefined, className as any, drawerClasses('trigger')) as any\n }\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={mergeStateClassName(undefined, className as any, drawerClasses('trigger')) as any}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,uBAAgC,QAAgB,WAAyE,oBAA6B;CAC1J,MAAM,OAAOA,OAAK,OAAO,MAAM,MAAM,CAAC,CAAC,WAAW,eAAe;CACjE,IAAI,OAAO,cAAc,YAAY,QAAQ,UAAkBA,OAAK,MAAM,UAAU,KAAK,CAAC;CAC1F,OAAOA,OAAK,MAAM,SAAS;AAC7B;AACA,MAAM,sBAAsB;CAC1B,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AACA,MAAM,sBAAsB;CAC1B,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AACA,MAAM,oBAAoB;CACxB,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd;AACA,MAAM,oBAAoB,cAA8B,IAAI;AAI5D,MAAM,uBAAuB,cAA6C,IAAI;AAC9E,MAAa,sBAAsB,IAAI,iBAAiB;AACxD,MAAa,yBAAyB,IAAI,oBAAoB;AAK9D,MAAM,sBAAsB,EAC1B,MACA,UACA,gBAAgB,o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AAoB,CAAC,OAAO,OAAO,UAAU,IAAI,GAAG,WAAkB,cAAc,OAAO,CAAC;CAClJ,UAAA,YAAY,oBAAC,GAAD,EAAG,MAAM,GAAK,CAAA;AACf,CAAA;AAKhB,MAAa,iBAAiB,EAC5B,UACA,WACA,cACA,KAAK,SACL,GAAG,WACqB;CACxB,MAAM,EACJ,8BACA,yBACE,gBAAgB;EAClB;EACA;CACF,CAAC;CACD,MAAM,YAAY,UAAe;EAC/B,MAAM,uBAAuB;GAC3B,IAAI,8BAA8B,OAAO;GAEzC,MAAM,EACJ,MACA,GAAG,cACD;GACJ,OAAO;EACT,EAAA,CAAG;EACH,MAAM,cAAc,WAAY,SAAiB,OAAO,aAAa;EACrE,OAAO,aAAa,UAAiB;GACnC,GAAG;GACH,KAAK,UAAU;IAAC,cAAc,QAAQ;IAAI,MAAc;IAAK;GAAO,CAAC;EACvE,CAAC;CACH;CACA,IAAI,eAAe,QAAQ,GACzB,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAM,cAAc;EAAsB,QAAQ;EAAiB,WAAW,oBAAoB,KAAA,GAAW,WAAkB,cAAc,SAAS,CAAC;CAAW,CAAA;CAE/L,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAM,WAAW,oBAAoB,KAAA,GAAW,WAAkB,cAAc,SAAS,CAAC;EAAU,cAAc;EAAsB,KAAK;EACnK;CACa,CAAA;AACpB"}
|
|
@@ -4,7 +4,7 @@ import { MenuItemRenderer } from "./MenuItemRenderer.mjs";
|
|
|
4
4
|
import { isGroup } from "./utils.mjs";
|
|
5
5
|
import { useKeyboardNavigation } from "./useKeyboardNavigation.mjs";
|
|
6
6
|
import { useNormalizedItems } from "./useNormalizedItems.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
//#region src/EditorSlashMenu/EditorSlashMenu.tsx
|
|
10
10
|
const EditorSlashMenu = memo(({ items, anchor, open, defaultOpen, onOpenChange, onOpenChangeComplete, value, defaultValue, onValueChange, updateValueOnSelect = false, onSelect, empty = "No results", renderGroupLabel, renderItem, reserveIconSpace = true, rootProps, portalProps, positionerProps, popupProps, listProps, withHiddenInput = false, hiddenInputProps }) => {
|
|
@@ -71,17 +71,15 @@ const EditorSlashMenu = memo(({ items, anchor, open, defaultOpen, onOpenChange,
|
|
|
71
71
|
...listProps,
|
|
72
72
|
ref: setListRef,
|
|
73
73
|
children: (entry) => {
|
|
74
|
-
if (isGroup(entry)) return /* @__PURE__ */ jsxs(EditorSlashMenuGroup, { children: [entry.label ? renderGroupLabel?.(entry.label) ?? /* @__PURE__ */ jsx(EditorSlashMenuGroupLabel, { children: entry.label }) : null, entry.items.map((item) => /* @__PURE__ */
|
|
74
|
+
if (isGroup(entry)) return /* @__PURE__ */ jsxs(EditorSlashMenuGroup, { children: [entry.label ? renderGroupLabel?.(entry.label) ?? /* @__PURE__ */ jsx(EditorSlashMenuGroupLabel, { children: entry.label }) : null, entry.items.map((item) => /* @__PURE__ */ jsx(MenuItemRenderer, {
|
|
75
75
|
...menuItemProps,
|
|
76
|
-
item
|
|
77
|
-
|
|
78
|
-
}))] }, entry.label ?? entry.items.map((i) => i.value).join("|"));
|
|
76
|
+
item
|
|
77
|
+
}, item.value))] }, entry.label ?? entry.items.map((i) => i.value).join("|"));
|
|
79
78
|
const item = entry;
|
|
80
|
-
return /* @__PURE__ */
|
|
79
|
+
return /* @__PURE__ */ jsx(MenuItemRenderer, {
|
|
81
80
|
...menuItemProps,
|
|
82
|
-
item
|
|
83
|
-
|
|
84
|
-
});
|
|
81
|
+
item
|
|
82
|
+
}, item.value);
|
|
85
83
|
}
|
|
86
84
|
}), /* @__PURE__ */ jsx(EditorSlashMenuEmpty, { children: empty })]
|
|
87
85
|
})
|