@lobehub/ui 6.5.1 → 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/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/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 +3 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lobe-highlights-theme.mjs","names":[],"sources":["../../../src/Highlighter/theme/lobe-highlights-theme.ts"],"sourcesContent":["import type { Theme } from '@pierre/highlights';\n\n// Palette mode: every color below is a `--lobe-*` variable suffix, so the\n// highlighted spans follow the active lobe theme without re-tokenizing.\nconst lobeHighlightsTheme: Theme = {\n appearance: 'dark',\n cssVariables: { prefix: '--lobe-' },\n name: 'lobe-theme',\n style: {\n background: 'color-bg-container',\n foreground: 'color-text',\n syntax: {\n 'attribute': 'purple-10',\n 'boolean': 'purple-10',\n 'comment': { color: 'color-text-quaternary', font_style: 'italic' },\n 'constant': 'color-info',\n 'constructor': 'color-warning',\n 'diff.minus': 'volcano-10',\n 'diff.plus': 'color-success',\n 'embedded': 'color-text',\n 'emphasis': { color: 'volcano-10', font_style: 'italic' },\n 'emphasis.strong': { color: 'volcano-10', font_weight: 700 },\n 'enum': 'color-warning',\n 'function': 'geekblue-10',\n 'function.method': 'geekblue-10',\n 'keyword': 'color-info',\n 'keyword.control': { color: 'color-info', font_style: 'italic' },\n 'keyword.declaration': 'purple-10',\n 'label': 'volcano-10',\n 'link_text': 'volcano-10',\n 'link_uri': 'volcano-10',\n 'namespace': 'color-text',\n 'number': 'volcano-10',\n 'operator': 'color-info',\n 'preproc': 'color-text-quaternary',\n 'property': 'volcano-10',\n 'property.json_key': 'purple-10',\n 'punctuation': 'color-info',\n 'punctuation.list_marker': 'color-info',\n 'selector': 'color-warning',\n 'selector.id': 'volcano-10',\n 'string': 'color-success',\n 'string.escape': 'color-text',\n 'string.special.symbol': 'color-info',\n 'tag': 'volcano-10',\n 'tag.component.jsx': 'color-warning',\n 'text.jsx': 'color-text',\n 'text.literal': 'color-success',\n 'title': 'color-info',\n 'type': 'color-warning',\n 'variable': 'color-text',\n 'variable.parameter': { color: 'color-text', font_style: 'italic' },\n 'variable.special': 'color-info',\n 'variant': 'color-warning',\n },\n },\n};\n\nexport default lobeHighlightsTheme;\n"],"mappings":";AAIA,MAAM,sBAA6B;CACjC,YAAY;CACZ,cAAc,EAAE,QAAQ,UAAU;CAClC,MAAM;CACN,OAAO;EACL,YAAY;EACZ,YAAY;EACZ,QAAQ;GACN,aAAa;GACb,WAAW;GACX,WAAW;IAAE,OAAO;IAAyB,YAAY;GAAS;GAClE,YAAY;GACZ,eAAe;GACf,cAAc;GACd,aAAa;GACb,YAAY;GACZ,YAAY;IAAE,OAAO;IAAc,YAAY;GAAS;GACxD,mBAAmB;IAAE,OAAO;IAAc,aAAa;GAAI;GAC3D,QAAQ;GACR,YAAY;GACZ,mBAAmB;GACnB,WAAW;GACX,mBAAmB;IAAE,OAAO;IAAc,YAAY;GAAS;GAC/D,uBAAuB;GACvB,SAAS;GACT,aAAa;GACb,YAAY;GACZ,aAAa;GACb,UAAU;GACV,YAAY;GACZ,WAAW;GACX,YAAY;GACZ,qBAAqB;GACrB,eAAe;GACf,2BAA2B;GAC3B,YAAY;GACZ,eAAe;GACf,UAAU;GACV,iBAAiB;GACjB,yBAAyB;GACzB,OAAO;GACP,qBAAqB;GACrB,YAAY;GACZ,gBAAgB;GAChB,SAAS;GACT,QAAQ;GACR,YAAY;GACZ,sBAAsB;IAAE,OAAO;IAAc,YAAY;GAAS;GAClE,oBAAoB;GACpB,WAAW;EACb;CACF;AACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/Highlighter/tokens.ts
|
|
2
|
+
const FONT_ITALIC = 1;
|
|
3
|
+
const FONT_BOLD = 2;
|
|
4
|
+
const FONT_UNDERLINE = 4;
|
|
5
|
+
const escapeHtml = (str) => str.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
6
|
+
const tokenStyleEntries = (token) => {
|
|
7
|
+
if (token.htmlStyle) return Object.entries(token.htmlStyle);
|
|
8
|
+
const entries = [];
|
|
9
|
+
if (token.color) entries.push(["color", token.color]);
|
|
10
|
+
if (token.bgColor) entries.push(["background-color", token.bgColor]);
|
|
11
|
+
const fontStyle = token.fontStyle ?? 0;
|
|
12
|
+
if (fontStyle & FONT_ITALIC) entries.push(["font-style", "italic"]);
|
|
13
|
+
if (fontStyle & FONT_BOLD) entries.push(["font-weight", "bold"]);
|
|
14
|
+
if (fontStyle & FONT_UNDERLINE) entries.push(["text-decoration", "underline"]);
|
|
15
|
+
return entries;
|
|
16
|
+
};
|
|
17
|
+
const styleCache = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
const getTokenStyle = (token) => {
|
|
19
|
+
const cached = styleCache.get(token);
|
|
20
|
+
if (cached) return cached;
|
|
21
|
+
const style = { whiteSpace: "pre" };
|
|
22
|
+
for (const [key, value] of tokenStyleEntries(token)) style[key.startsWith("--") ? key : key.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase())] = value;
|
|
23
|
+
styleCache.set(token, style);
|
|
24
|
+
return style;
|
|
25
|
+
};
|
|
26
|
+
const getPreStyle = ({ bg, fg }) => {
|
|
27
|
+
if (!bg && !fg) return;
|
|
28
|
+
return {
|
|
29
|
+
backgroundColor: bg,
|
|
30
|
+
color: fg
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const tokensToHtml = (result, themeName) => {
|
|
34
|
+
const preStyle = [result.bg && `background-color:${result.bg}`, result.fg && `color:${result.fg}`].filter(Boolean).join(";");
|
|
35
|
+
let html = `<pre class="shiki ${escapeHtml(themeName)}" style="${preStyle}" tabindex="0"><code>`;
|
|
36
|
+
for (const [index, line] of result.tokens.entries()) {
|
|
37
|
+
if (index > 0) html += "\n";
|
|
38
|
+
html += "<span class=\"line\">";
|
|
39
|
+
for (const token of line) {
|
|
40
|
+
const style = tokenStyleEntries(token).map(([key, value]) => `${key}:${value}`).join(";");
|
|
41
|
+
html += style ? `<span style="${style}">${escapeHtml(token.content)}</span>` : `<span>${escapeHtml(token.content)}</span>`;
|
|
42
|
+
}
|
|
43
|
+
html += "</span>";
|
|
44
|
+
}
|
|
45
|
+
return `${html}</code></pre>`;
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { escapeHtml, getPreStyle, getTokenStyle, tokensToHtml };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=tokens.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.mjs","names":[],"sources":["../../src/Highlighter/tokens.ts"],"sourcesContent":["import type { ThemedToken, TokensResult } from '@pierre/highlights';\nimport type { CSSProperties } from 'react';\n\nconst FONT_ITALIC = 1;\nconst FONT_BOLD = 2;\nconst FONT_UNDERLINE = 4;\n\nexport const escapeHtml = (str: string): string =>\n str\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n\nconst tokenStyleEntries = (token: ThemedToken): [string, string][] => {\n if (token.htmlStyle) return Object.entries(token.htmlStyle);\n\n const entries: [string, string][] = [];\n if (token.color) entries.push(['color', token.color]);\n if (token.bgColor) entries.push(['background-color', token.bgColor]);\n const fontStyle = token.fontStyle ?? 0;\n if (fontStyle & FONT_ITALIC) entries.push(['font-style', 'italic']);\n if (fontStyle & FONT_BOLD) entries.push(['font-weight', 'bold']);\n if (fontStyle & FONT_UNDERLINE) entries.push(['text-decoration', 'underline']);\n return entries;\n};\n\nconst styleCache = new WeakMap<ThemedToken, CSSProperties>();\n\nexport const getTokenStyle = (token: ThemedToken): CSSProperties => {\n const cached = styleCache.get(token);\n if (cached) return cached;\n\n const style: Record<string, string> = { whiteSpace: 'pre' };\n for (const [key, value] of tokenStyleEntries(token)) {\n style[key.startsWith('--') ? key : key.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase())] =\n value;\n }\n styleCache.set(token, style as CSSProperties);\n return style as CSSProperties;\n};\n\nexport const getPreStyle = ({ bg, fg }: Pick<TokensResult, 'bg' | 'fg'>) => {\n if (!bg && !fg) return;\n return { backgroundColor: bg, color: fg } satisfies CSSProperties;\n};\n\nexport const tokensToHtml = (result: TokensResult, themeName: string): string => {\n const preStyle = [result.bg && `background-color:${result.bg}`, result.fg && `color:${result.fg}`]\n .filter(Boolean)\n .join(';');\n\n let html = `<pre class=\"shiki ${escapeHtml(themeName)}\" style=\"${preStyle}\" tabindex=\"0\"><code>`;\n for (const [index, line] of result.tokens.entries()) {\n if (index > 0) html += '\\n';\n html += '<span class=\"line\">';\n for (const token of line) {\n const style = tokenStyleEntries(token)\n .map(([key, value]) => `${key}:${value}`)\n .join(';');\n html += style\n ? `<span style=\"${style}\">${escapeHtml(token.content)}</span>`\n : `<span>${escapeHtml(token.content)}</span>`;\n }\n html += '</span>';\n }\n return `${html}</code></pre>`;\n};\n"],"mappings":";AAGA,MAAM,cAAc;AACpB,MAAM,YAAY;AAClB,MAAM,iBAAiB;AAEvB,MAAa,cAAc,QACzB,IACG,WAAW,KAAK,OAAO,CAAC,CACxB,WAAW,KAAK,MAAM,CAAC,CACvB,WAAW,KAAK,MAAM,CAAC,CACvB,WAAW,MAAK,QAAQ,CAAC,CACzB,WAAW,KAAK,QAAQ;AAE7B,MAAM,qBAAqB,UAA2C;CACpE,IAAI,MAAM,WAAW,OAAO,OAAO,QAAQ,MAAM,SAAS;CAE1D,MAAM,UAA8B,CAAC;CACrC,IAAI,MAAM,OAAO,QAAQ,KAAK,CAAC,SAAS,MAAM,KAAK,CAAC;CACpD,IAAI,MAAM,SAAS,QAAQ,KAAK,CAAC,oBAAoB,MAAM,OAAO,CAAC;CACnE,MAAM,YAAY,MAAM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AM,OAAO,EAAE,WACpD,SAAS,WAAW,MAAM,OAAO,EAAE;EACzC;EACA,QAAQ;CACV;CACA,OAAO,GAAG,KAAK;AACjB"}
|
|
@@ -3,8 +3,8 @@ import "../Flex/index.mjs";
|
|
|
3
3
|
import { DivProps } from "../types/index.mjs";
|
|
4
4
|
import { ActionIconProps } from "../ActionIcon/type.mjs";
|
|
5
5
|
import "../ActionIcon/index.mjs";
|
|
6
|
+
import { BundledHighlighterTheme } from "./const.mjs";
|
|
6
7
|
import { CSSProperties, ReactNode, Ref } from "react";
|
|
7
|
-
import { BuiltinTheme } from "shiki";
|
|
8
8
|
//#region src/Highlighter/type.d.ts
|
|
9
9
|
export interface SyntaxHighlighterProps extends DivProps {
|
|
10
10
|
animated?: boolean;
|
|
@@ -39,6 +39,9 @@ export interface HighlighterProps extends Omit<FlexboxProps, 'children' | 'wrap'
|
|
|
39
39
|
};
|
|
40
40
|
copyable?: boolean;
|
|
41
41
|
defaultExpand?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Notation transformers (`// [!code ++]` etc.) are no longer supported; this prop has no effect.
|
|
44
|
+
*/
|
|
42
45
|
enableTransformer?: boolean;
|
|
43
46
|
fileName?: string;
|
|
44
47
|
fullFeatured?: boolean;
|
|
@@ -51,7 +54,7 @@ export interface HighlighterProps extends Omit<FlexboxProps, 'children' | 'wrap'
|
|
|
51
54
|
content?: CSSProperties;
|
|
52
55
|
header?: CSSProperties;
|
|
53
56
|
};
|
|
54
|
-
theme?: 'lobe-theme' |
|
|
57
|
+
theme?: 'lobe-theme' | BundledHighlighterTheme;
|
|
55
58
|
variant?: 'filled' | 'outlined' | 'borderless';
|
|
56
59
|
wrap?: boolean;
|
|
57
60
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { styles } from "../style.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { memo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import * as stylex from "@stylexjs/stylex";
|
|
6
6
|
//#region src/Image/viewer/ActualSizeIcon.tsx
|
|
@@ -32,12 +32,11 @@ const ActualSizeIcon = memo(({ color = "currentColor", fill = "none", height = 2
|
|
|
32
32
|
viewBox: "0 0 24 24",
|
|
33
33
|
width,
|
|
34
34
|
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
-
children: CORNERS.map(({ d, origin }) => /* @__PURE__ */
|
|
35
|
+
children: CORNERS.map(({ d, origin }) => /* @__PURE__ */ jsx("path", {
|
|
36
36
|
...stylex.props(styles.actualSizeCorner),
|
|
37
37
|
d,
|
|
38
|
-
key: d,
|
|
39
38
|
style: { transformOrigin: origin }
|
|
40
|
-
}))
|
|
39
|
+
}, d))
|
|
41
40
|
}));
|
|
42
41
|
ActualSizeIcon.displayName = "ActualSizeIcon";
|
|
43
42
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActualSizeIcon.mjs","names":[],"sources":["../../../src/Image/viewer/ActualSizeIcon.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { memo } from 'react';\n\nimport { styles } from '../style';\n\n// lucide's Expand, kept as four separate corners so each can be transformed on\n// its own. Expand and Shrink are not two unrelated glyphs: rotating each of\n// these corners 180° about its own quadrant centre maps Expand onto Shrink\n// exactly, coordinate for coordinate. That makes the toggle a transform\n// animation rather than a path interpolation, so it needs no morphing library\n// and stays on the compositor.\nconst CORNERS = [\n { d: 'm21 21-6-6m6 6v-4.8m0 4.8h-4.8', origin: '18px 18px' },\n { d: 'M3 16.2V21m0 0h4.8M3 21l6-6', origin: '6px 18px' },\n { d: 'M21 7.8V3m0 0h-4.8M21 3l-6 6', origin: '18px 6px' },\n { d: 'M3 7.8V3m0 0h4.8M3 3l6 6', origin: '6px 6px' },\n];\n\nexport interface ActualSizeIconProps {\n color?: string;\n fill?: string;\n height?: number | string;\n strokeWidth?: number | string;\n width?: number | string;\n}\n\nconst ActualSizeIcon = memo<ActualSizeIconProps>(\n ({ color = 'currentColor', fill = 'none', height = 24, strokeWidth = 2, width = 24 }) => (\n <svg\n fill={fill}\n height={height}\n stroke={color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={strokeWidth}\n viewBox=\"0 0 24 24\"\n width={width}\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {CORNERS.map(({ d, origin }) => (\n <path\n {...stylex.props(styles.actualSizeCorner)}\n d={d}\n
|
|
1
|
+
{"version":3,"file":"ActualSizeIcon.mjs","names":[],"sources":["../../../src/Image/viewer/ActualSizeIcon.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { memo } from 'react';\n\nimport { styles } from '../style';\n\n// lucide's Expand, kept as four separate corners so each can be transformed on\n// its own. Expand and Shrink are not two unrelated glyphs: rotating each of\n// these corners 180° about its own quadrant centre maps Expand onto Shrink\n// exactly, coordinate for coordinate. That makes the toggle a transform\n// animation rather than a path interpolation, so it needs no morphing library\n// and stays on the compositor.\nconst CORNERS = [\n { d: 'm21 21-6-6m6 6v-4.8m0 4.8h-4.8', origin: '18px 18px' },\n { d: 'M3 16.2V21m0 0h4.8M3 21l6-6', origin: '6px 18px' },\n { d: 'M21 7.8V3m0 0h-4.8M21 3l-6 6', origin: '18px 6px' },\n { d: 'M3 7.8V3m0 0h4.8M3 3l6 6', origin: '6px 6px' },\n];\n\nexport interface ActualSizeIconProps {\n color?: string;\n fill?: string;\n height?: number | string;\n strokeWidth?: number | string;\n width?: number | string;\n}\n\nconst ActualSizeIcon = memo<ActualSizeIconProps>(\n ({ color = 'currentColor', fill = 'none', height = 24, strokeWidth = 2, width = 24 }) => (\n <svg\n fill={fill}\n height={height}\n stroke={color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={strokeWidth}\n viewBox=\"0 0 24 24\"\n width={width}\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {CORNERS.map(({ d, origin }) => (\n <path\n key={d}\n {...stylex.props(styles.actualSizeCorner)}\n d={d}\n style={{ transformOrigin: origin }}\n />\n ))}\n </svg>\n ),\n);\n\nActualSizeIcon.displayName = 'ActualSizeIcon';\n\nexport default ActualSizeIcon;\n"],"mappings":";;;;;;AAYA,MAAM,UAAU;CAAC;EACf,GAAG;EACH,QAAQ;CACV;CAAG;EACD,GAAG;EACH,QAAQ;CACV;CAAG;EACD,GAAG;EACH,QAAQ;CACV;CAAG;EACD,GAAG;EACH,QAAQ;CACV;AAAC;AAQD,MAAM,iBAAiB,MAA2B,EAChD,QAAQ,gBACR,OAAO,QACP,SAAS,IACT,cAAc,GACd,QAAQ,SACJ,oBAAC,OAAD;CAAW;CAAc;CAAQ,QAAQ;CAAO,eAAc;CAAQ,gBAAe;CAAqB;CAAa,SAAQ;CAAmB;CAAO,OAAM;CAC9J,UAAA,QAAQ,KAAK,EAChB,GACA,aACI,oBAAC,QAAD;EAAc,GAAI,OAAO,MAAM,OAAO,gBAAgB;EAAM;EAAG,OAAO,EAC1E,iBAAiB,OACnB;CAAI,GAFa,CAEb,CAAC;AACE,CAAA,CAAC;AACV,eAAe,cAAc"}
|
|
@@ -8,7 +8,7 @@ import Img from "../Img/index.mjs";
|
|
|
8
8
|
import { imageSelectClasses } from "./stable.mjs";
|
|
9
9
|
import { styles } from "./styles.mjs";
|
|
10
10
|
import clsx$1 from "clsx";
|
|
11
|
-
import {
|
|
11
|
+
import { memo } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
//#region src/ImageSelect/ImageSelect.tsx
|
|
14
14
|
const ImageSelect = memo(({ ref, className, style, value, defaultValue, onChange, options, width, height, styles: customStyles, classNames, unoptimized, ...rest }) => {
|
|
@@ -26,31 +26,31 @@ const ImageSelect = memo(({ ref, className, style, value, defaultValue, onChange
|
|
|
26
26
|
...rest,
|
|
27
27
|
children: options?.map((item) => {
|
|
28
28
|
const isActive = item.value === currentValue;
|
|
29
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
30
30
|
align: "center",
|
|
31
31
|
gap: 4,
|
|
32
32
|
...toDataAttributes({ active: isActive }),
|
|
33
33
|
...styleProps([styles.container, isActive && styles.active], imageSelectClasses("item")),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
34
|
+
onClick: () => setCurrentValue(item.value),
|
|
35
|
+
children: [/* @__PURE__ */ jsx(Img, {
|
|
36
|
+
alt: item.alt || item.value,
|
|
37
|
+
height: height ?? 86,
|
|
38
|
+
src: item.img,
|
|
39
|
+
unoptimized,
|
|
40
|
+
width: width ?? 144,
|
|
41
|
+
...styleProps([styles.img, isActive && styles.imgActive], clsx$1(imageSelectClasses("img"), classNames?.img), {
|
|
42
|
+
...customStyles?.img,
|
|
43
|
+
...height !== void 0 && { height },
|
|
44
|
+
...width !== void 0 && { width }
|
|
45
|
+
})
|
|
46
|
+
}), /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
47
|
+
horizontal: true,
|
|
48
|
+
align: "center",
|
|
49
|
+
className: imageSelectClasses("label"),
|
|
50
|
+
gap: 4,
|
|
51
|
+
children: [item.icon && /* @__PURE__ */ jsx(Icon, { icon: item.icon }), item.label]
|
|
52
|
+
})]
|
|
53
|
+
}, item.value);
|
|
54
54
|
})
|
|
55
55
|
});
|
|
56
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageSelect.mjs","names":["Flexbox","clsx"],"sources":["../../src/ImageSelect/ImageSelect.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { memo } from 'react';\n\nimport { Flexbox } from '@/Flex';\nimport { useControlledState } from '@/hooks/useControlledState';\nimport Icon from '@/Icon';\nimport Img from '@/Img';\nimport { styleProps } from '@/styles/stylex/props';\nimport { toDataAttributes } from '@/utils/bem';\n\nimport { imageSelectClasses } from './stable';\nimport { styles } from './styles';\nimport type { ImageSelectProps } from './type';\n\nconst ImageSelect = memo<ImageSelectProps>(\n ({\n ref,\n className,\n style,\n value,\n defaultValue,\n onChange,\n options,\n width,\n height,\n styles: customStyles,\n classNames,\n unoptimized,\n ...rest\n }) => {\n const [currentValue, setCurrentValue] = useControlledState<string>(defaultValue, {\n defaultValue,\n onChange,\n value,\n });\n\n return (\n <Flexbox\n horizontal\n className={clsx(imageSelectClasses(), className)}\n gap={16}\n ref={ref}\n style={style}\n {...rest}\n >\n {options?.map((item) => {\n const isActive = item.value === currentValue;\n return (\n <Flexbox\n align={'center'}\n gap={4}\n {...toDataAttributes({ active: isActive })}\n {...styleProps(\n [styles.container, isActive && styles.active],\n imageSelectClasses('item'),\n )}\n
|
|
1
|
+
{"version":3,"file":"ImageSelect.mjs","names":["Flexbox","clsx"],"sources":["../../src/ImageSelect/ImageSelect.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { memo } from 'react';\n\nimport { Flexbox } from '@/Flex';\nimport { useControlledState } from '@/hooks/useControlledState';\nimport Icon from '@/Icon';\nimport Img from '@/Img';\nimport { styleProps } from '@/styles/stylex/props';\nimport { toDataAttributes } from '@/utils/bem';\n\nimport { imageSelectClasses } from './stable';\nimport { styles } from './styles';\nimport type { ImageSelectProps } from './type';\n\nconst ImageSelect = memo<ImageSelectProps>(\n ({\n ref,\n className,\n style,\n value,\n defaultValue,\n onChange,\n options,\n width,\n height,\n styles: customStyles,\n classNames,\n unoptimized,\n ...rest\n }) => {\n const [currentValue, setCurrentValue] = useControlledState<string>(defaultValue, {\n defaultValue,\n onChange,\n value,\n });\n\n return (\n <Flexbox\n horizontal\n className={clsx(imageSelectClasses(), className)}\n gap={16}\n ref={ref}\n style={style}\n {...rest}\n >\n {options?.map((item) => {\n const isActive = item.value === currentValue;\n return (\n <Flexbox\n align={'center'}\n gap={4}\n key={item.value}\n {...toDataAttributes({ active: isActive })}\n {...styleProps(\n [styles.container, isActive && styles.active],\n imageSelectClasses('item'),\n )}\n onClick={() => setCurrentValue(item.value)}\n >\n <Img\n alt={item.alt || item.value}\n height={height ?? 86}\n src={item.img}\n unoptimized={unoptimized}\n width={width ?? 144}\n {...styleProps(\n [styles.img, isActive && styles.imgActive],\n clsx(imageSelectClasses('img'), classNames?.img),\n {\n ...customStyles?.img,\n ...(height !== undefined && { height }),\n ...(width !== undefined && { width }),\n },\n )}\n />\n\n <Flexbox horizontal align={'center'} className={imageSelectClasses('label')} gap={4}>\n {item.icon && <Icon icon={item.icon} />}\n {item.label}\n </Flexbox>\n </Flexbox>\n );\n })}\n </Flexbox>\n );\n },\n);\n\nImageSelect.displayName = 'ImageSelect';\n\nexport default ImageSelect;\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,cAAc,MACjB,EACC,KACA,WACA,OACA,OACA,cACA,UACA,SACA,OACA,QACA,QAAQ,cACR,YACA,aACA,GAAG,WACC;CACJ,MAAM,CAAC,cAAc,mBAAmB,mBAA2B,cAAc;EAC/E;EACA;EACA;CACF,CAAC;CAED,OACE,oBAACA,mBAAD;EACE,YAAA;EACA,WAAWC,OAAK,mBAAmB,GAAG,SAAS;EAC/C,KAAK;EACA;EACE;EACP,GAAI;EAEH,UAAA,SAAS,KAAK,SAAS;GACtB,MAAM,WAAW,KAAK,UAAU;GAChC,OACE,qBAACD,mBAAD;IACE,OAAO;IACP,KAAK;IAEL,GAAI,iBAAiB,EAAE,QAAQ,SAAS,CAAC;IACzC,GAAI,WACF,CAAC,OAAO,WAAW,YAAY,OAAO,MAAM,GAC5C,mBAAmB,MAAM,CAC3B;IACA,eAAe,gBAAgB,KAAK,KAAK;IAT3C,UAAA,CAWE,oBAAC,KAAD;KACE,KAAK,KAAK,OAAO,KAAK;KACtB,QAAQ,UAAU;KAClB,KAAK,KAAK;KACG;KACb,OAAO,SAAS;KAChB,GAAI,WACF,CAAC,OAAO,KAAK,YAAY,OAAO,SAAS,GACzCC,OAAK,mBAAmB,KAAK,GAAG,YAAY,GAAG,GAC/C;MACE,GAAG,cAAc;MACjB,GAAI,WAAW,KAAA,KAAa,EAAE,OAAO;MACrC,GAAI,UAAU,KAAA,KAAa,EAAE,MAAM;KACrC,CACF;IACD,CAAA,GAED,qBAACD,mBAAD;KAAS,YAAA;KAAW,OAAO;KAAU,WAAW,mBAAmB,OAAO;KAAG,KAAK;KAAlF,UAAA,CACG,KAAK,QAAQ,oBAAC,MAAD,EAAM,MAAM,KAAK,KAAO,CAAA,GACrC,KAAK,KACC;IACF,CAAA,CAAA;GA7BF,GAAA,KAAK,KA6BH;EAEb,CAAC;CACM,CAAA;AAEb,CACF;AAEA,YAAY,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRender.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/MarkdownRender.tsx"],"sourcesContent":["'use client';\n\nimport { memo } from 'react';\nimport Markdown, { type Options } from 'react-markdown';\n\nimport {\n useMarkdownComponents,\n useMarkdownContent,\n useMarkdownRehypePlugins,\n useMarkdownRemarkPlugins,\n} from '@/hooks/useMarkdown';\n\nconst MarkdownRenderer = memo<Options>(\n ({ children, ...rest }) => {\n const escapedContent = useMarkdownContent(children || '');\n const components = useMarkdownComponents();\n const rehypePluginsList = useMarkdownRehypePlugins();\n const remarkPluginsList = useMarkdownRemarkPlugins();\n\n return (\n <Markdown\n {...rest}\n components={components}\n rehypePlugins={rehypePluginsList}\n remarkPlugins={remarkPluginsList}\n >\n {escapedContent}\n </Markdown>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nexport default MarkdownRenderer;\n"],"mappings":";;;;;;;;;AAYA,MAAM,
|
|
1
|
+
{"version":3,"file":"MarkdownRender.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/MarkdownRender.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type NamedExoticComponent } from 'react';\nimport Markdown, { type Options } from 'react-markdown';\n\nimport {\n useMarkdownComponents,\n useMarkdownContent,\n useMarkdownRehypePlugins,\n useMarkdownRemarkPlugins,\n} from '@/hooks/useMarkdown';\n\nconst MarkdownRenderer: NamedExoticComponent<Options> = memo<Options>(\n ({ children, ...rest }) => {\n const escapedContent = useMarkdownContent(children || '');\n const components = useMarkdownComponents();\n const rehypePluginsList = useMarkdownRehypePlugins();\n const remarkPluginsList = useMarkdownRemarkPlugins();\n\n return (\n <Markdown\n {...rest}\n components={components}\n rehypePlugins={rehypePluginsList}\n remarkPlugins={remarkPluginsList}\n >\n {escapedContent}\n </Markdown>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children,\n);\n\nexport default MarkdownRenderer;\n"],"mappings":";;;;;;;;;AAYA,MAAM,mBAAkD,MACrD,EAAE,UAAU,GAAG,WAAW;CACzB,MAAM,iBAAiB,mBAAmB,YAAY,EAAE;CACxD,MAAM,aAAa,sBAAsB;CACzC,MAAM,oBAAoB,yBAAyB;CACnD,MAAM,oBAAoB,yBAAyB;CAEnD,OACE,oBAAC,UAAD;EACE,GAAI;EACQ;EACZ,eAAe;EACf,eAAe;EAEd,UAAA;CACO,CAAA;AAEd,IACC,WAAW,cAAc,UAAU,aAAa,UAAU,QAC7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamdownRender.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/StreamdownRender.tsx"],"sourcesContent":["'use client';\n\nimport { Streamdown } from '@lobehub/streamdown';\nimport { memo } from 'react';\nimport { type Options } from 'react-markdown';\n\nimport {\n useMarkdownComponents,\n useMarkdownContent,\n useMarkdownRehypePlugins,\n useMarkdownRemarkPlugins,\n} from '@/hooks/useMarkdown';\nimport { useMarkdownContext } from '@/Markdown/components/MarkdownProvider';\n\nexport const StreamdownRender = memo<Options>(({ children, ...rest }) => {\n
|
|
1
|
+
{"version":3,"file":"StreamdownRender.mjs","names":[],"sources":["../../../src/Markdown/SyntaxMarkdown/StreamdownRender.tsx"],"sourcesContent":["'use client';\n\nimport { Streamdown } from '@lobehub/streamdown';\nimport { memo, type NamedExoticComponent } from 'react';\nimport { type Options } from 'react-markdown';\n\nimport {\n useMarkdownComponents,\n useMarkdownContent,\n useMarkdownRehypePlugins,\n useMarkdownRemarkPlugins,\n} from '@/hooks/useMarkdown';\nimport { useMarkdownContext } from '@/Markdown/components/MarkdownProvider';\n\nexport const StreamdownRender: NamedExoticComponent<Options> = memo<Options>(\n ({ children, ...rest }) => {\n const {\n enableLatex = true,\n streamAnimationGranularity = 'char',\n streamSmoothingPreset = 'balanced',\n } = useMarkdownContext();\n const escapedContent = useMarkdownContent(children || '');\n const components = useMarkdownComponents();\n const rehypePlugins = useMarkdownRehypePlugins();\n const remarkPlugins = useMarkdownRemarkPlugins();\n\n return (\n <Streamdown\n {...rest}\n components={components}\n content={typeof escapedContent === 'string' ? escapedContent : ''}\n granularity={streamAnimationGranularity}\n latexGuard={enableLatex}\n rehypePlugins={rehypePlugins}\n remarkPlugins={remarkPlugins}\n smoothing={streamSmoothingPreset}\n />\n );\n },\n);\n\nStreamdownRender.displayName = 'StreamdownRender';\n\nexport default StreamdownRender;\n"],"mappings":";;;;;;;;;;AAcA,MAAa,mBAAkD,MAC5D,EAAE,UAAU,GAAG,WAAW;CACzB,MAAM,EACJ,cAAc,MACd,6BAA6B,QAC7B,wBAAwB,eACtB,mBAAmB;CACvB,MAAM,iBAAiB,mBAAmB,YAAY,EAAE;CACxD,MAAM,aAAa,sBAAsB;CACzC,MAAM,gBAAgB,yBAAyB;CAC/C,MAAM,gBAAgB,yBAAyB;CAE/C,OACE,oBAAC,YAAD;EACE,GAAI;EACQ;EACZ,SAAS,OAAO,mBAAmB,WAAW,iBAAiB;EAC/D,aAAa;EACb,YAAY;EACG;EACA;EACf,WAAW;CACZ,CAAA;AAEL,CACF;AAEA,iBAAiB,cAAc"}
|
|
@@ -4,7 +4,7 @@ import FlexBasic_default from "../../Flex/FlexBasic.mjs";
|
|
|
4
4
|
import Block from "../../Block/Block.mjs";
|
|
5
5
|
import Text from "../../Text/Text.mjs";
|
|
6
6
|
import SearchResultCards from "./SearchResultCards/index.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { memo, useMemo } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
//#region src/Markdown/components/Footnotes.tsx
|
|
10
10
|
const DefaultFootnotes = memo(({ dataSource }) => {
|
|
@@ -29,37 +29,37 @@ const DefaultFootnotes = memo(({ dataSource }) => {
|
|
|
29
29
|
wrap: "wrap",
|
|
30
30
|
children: items.map(({ children, props }, index) => {
|
|
31
31
|
const { node, href, ...rest } = props;
|
|
32
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsx(href ? A : "div", {
|
|
33
33
|
...href ? {
|
|
34
34
|
href,
|
|
35
35
|
...rest
|
|
36
36
|
} : rest,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
children: /* @__PURE__ */ jsxs(Block, {
|
|
38
|
+
horizontal: true,
|
|
39
|
+
align: "stretch",
|
|
40
|
+
style: {
|
|
41
|
+
overflow: "hidden",
|
|
42
|
+
position: "relative"
|
|
43
|
+
},
|
|
44
|
+
variant: "outlined",
|
|
45
|
+
children: [/* @__PURE__ */ jsx(Block, {
|
|
46
|
+
paddingInline: "0.66em",
|
|
47
|
+
style: { borderRadius: 0 },
|
|
48
|
+
variant: "filled",
|
|
49
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
50
|
+
code: true,
|
|
51
|
+
as: "span",
|
|
52
|
+
type: "secondary",
|
|
53
|
+
children: index + 1
|
|
54
|
+
})
|
|
55
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
52
56
|
as: "span",
|
|
57
|
+
style: { paddingInline: "0.66em" },
|
|
53
58
|
type: "secondary",
|
|
54
|
-
children
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
style: { paddingInline: "0.66em" },
|
|
59
|
-
type: "secondary",
|
|
60
|
-
children
|
|
61
|
-
})]
|
|
62
|
-
}));
|
|
59
|
+
children
|
|
60
|
+
})]
|
|
61
|
+
})
|
|
62
|
+
}, index);
|
|
63
63
|
})
|
|
64
64
|
});
|
|
65
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Footnotes.mjs","names":["Flexbox"],"sources":["../../../src/Markdown/components/Footnotes.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useMemo } from 'react';\n\nimport A from '@/A';\nimport Block from '@/Block';\nimport { Flexbox } from '@/Flex';\nimport Text from '@/Text';\n\nimport SearchResultCards from './SearchResultCards';\n\ninterface FootnotesProps {\n 'children': ReactNode;\n 'data-footnote-links'?: string;\n 'data-footnotes'?: boolean;\n}\n\nconst DefaultFootnotes = memo<{ dataSource: any[] }>(({ dataSource }) => {\n const items = useMemo(\n () =>\n dataSource\n .find((child) => child?.type === 'ol')\n ?.props?.children?.map((item: any) => {\n if (typeof item === 'string' || item?.type !== 'li') return false;\n const data = item?.props?.children?.find((note: any) => note?.props?.children)?.props\n ?.children;\n if (!data || !Array.isArray(data)) return false;\n return {\n children: data[0],\n props: data[1]?.props || {},\n };\n })\n .filter(Boolean),\n [dataSource],\n );\n\n if (!Array.isArray(items)) return null;\n\n return (\n <Flexbox\n horizontal\n align={'flex-start'}\n as={'section'}\n className={'footnotes'}\n data-footnotes=\"true\"\n gap={'0.5em'}\n justify={'flex-start'}\n wrap={'wrap'}\n >\n {items.map(({ children, props }, index) => {\n const { node, href, ...rest } = props;\n const Container = href ? A : 'div';\n return (\n <Container {...(href ? { href, ...rest } : rest)}
|
|
1
|
+
{"version":3,"file":"Footnotes.mjs","names":["Flexbox"],"sources":["../../../src/Markdown/components/Footnotes.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useMemo } from 'react';\n\nimport A from '@/A';\nimport Block from '@/Block';\nimport { Flexbox } from '@/Flex';\nimport Text from '@/Text';\n\nimport SearchResultCards from './SearchResultCards';\n\ninterface FootnotesProps {\n 'children': ReactNode;\n 'data-footnote-links'?: string;\n 'data-footnotes'?: boolean;\n}\n\nconst DefaultFootnotes = memo<{ dataSource: any[] }>(({ dataSource }) => {\n const items = useMemo(\n () =>\n dataSource\n .find((child) => child?.type === 'ol')\n ?.props?.children?.map((item: any) => {\n if (typeof item === 'string' || item?.type !== 'li') return false;\n const data = item?.props?.children?.find((note: any) => note?.props?.children)?.props\n ?.children;\n if (!data || !Array.isArray(data)) return false;\n return {\n children: data[0],\n props: data[1]?.props || {},\n };\n })\n .filter(Boolean),\n [dataSource],\n );\n\n if (!Array.isArray(items)) return null;\n\n return (\n <Flexbox\n horizontal\n align={'flex-start'}\n as={'section'}\n className={'footnotes'}\n data-footnotes=\"true\"\n gap={'0.5em'}\n justify={'flex-start'}\n wrap={'wrap'}\n >\n {items.map(({ children, props }, index) => {\n const { node, href, ...rest } = props;\n const Container = href ? A : 'div';\n return (\n <Container key={index} {...(href ? { href, ...rest } : rest)}>\n <Block\n horizontal\n align={'stretch'}\n style={{ overflow: 'hidden', position: 'relative' }}\n variant={'outlined'}\n >\n <Block paddingInline={'0.66em'} style={{ borderRadius: 0 }} variant={'filled'}>\n <Text code as=\"span\" type={'secondary'}>\n {index + 1}\n </Text>\n </Block>\n <Text as=\"span\" style={{ paddingInline: '0.66em' }} type={'secondary'}>\n {children}\n </Text>\n </Block>\n </Container>\n );\n })}\n </Flexbox>\n );\n});\n\nconst Footnotes = memo<FootnotesProps>(({ children, ...rest }) => {\n const links = useMemo(() => {\n try {\n return JSON.parse(rest['data-footnote-links'] || '[]');\n } catch (error) {\n console.error('Failed to parse footnote links:', error);\n return [];\n }\n }, [rest['data-footnote-links']]);\n\n const isError = links.length === 0;\n\n if (!children) return;\n\n if (isError) {\n if (!Array.isArray(children)) return children;\n return <DefaultFootnotes dataSource={children} />;\n }\n\n return (\n <section className={'footnotes'} data-footnotes=\"true\">\n <SearchResultCards dataSource={links} />\n </section>\n );\n});\n\nFootnotes.displayName = 'Footnotes';\n\nexport default Footnotes;\n"],"mappings":";;;;;;;;;AAiBA,MAAM,mBAAmB,MAA6B,EAAE,iBAAiB;CACvE,MAAM,QAAQ,cAEV,WACG,MAAM,UAAU,OAAO,SAAS,IAAI,CAAC,EACpC,OAAO,UAAU,KAAK,SAAc;EACpC,IAAI,OAAO,SAAS,YAAY,MAAM,SAAS,MAAM,OAAO;EAC5D,MAAM,OAAO,MAAM,OAAO,UAAU,MAAM,SAAc,MAAM,OAAO,QAAQ,CAAC,EAAE,OAC5E;EACJ,IAAI,CAAC,QAAQ,CAAC,MAAM,QAAQ,IAAI,GAAG,OAAO;EAC1C,OAAO;GACL,UAAU,KAAK;GACf,OAAO,KAAK,EAAE,EAAE,SAAS,CAAC;EAC5B;CACF,CAAC,CAAC,CACD,OAAO,OAAO,GACnB,CAAC,UAAU,CACb;CAEA,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO;CAElC,OACE,oBAACA,mBAAD;EACE,YAAA;EACA,OAAO;EACP,IAAI;EACJ,WAAW;EACX,kBAAe;EACf,KAAK;EACL,SAAS;EACT,MAAM;EAEL,UAAA,MAAM,KAAK,EAAE,UAAU,SAAS,UAAU;GACzC,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS;GAEhC,OACE,oBAFgB,OAAO,IAAI,OAE3B;IAAuB,GAAK,OAAO;KAAE;KAAM,GAAG;IAAK,IAAI;IACrD,UAAA,qBAAC,OAAD;KACE,YAAA;KACA,OAAO;KACP,OAAO;MAAE,UAAU;MAAU,UAAU;KAAW;KAClD,SAAS;KAJX,UAAA,CAME,oBAAC,OAAD;MAAO,eAAe;MAAU,OAAO,EAAE,cAAc,EAAE;MAAG,SAAS;MACnE,UAAA,oBAAC,MAAD;OAAM,MAAA;OAAK,IAAG;OAAO,MAAM;OACxB,UAAA,QAAQ;MACL,CAAA;KACD,CAAA,GACP,oBAAC,MAAD;MAAM,IAAG;MAAO,OAAO,EAAE,eAAe,SAAS;MAAG,MAAM;MACvD;KACG,CAAA,CACD;;GACE,GAhBK,KAgBL;EAEf,CAAC;CACM,CAAA;AAEb,CAAC;AAED,MAAM,YAAY,MAAsB,EAAE,UAAU,GAAG,WAAW;CAChE,MAAM,QAAQ,cAAc;EAC1B,IAAI;GACF,OAAO,KAAK,MAAM,KAAK,0BAA0B,IAAI;EACvD,SAAS,OAAO;GACd,QAAQ,MAAM,mCAAmC,KAAK;GACtD,OAAO,CAAC;EACV;CACF,GAAG,CAAC,KAAK,sBAAsB,CAAC;CAEhC,MAAM,UAAU,MAAM,WAAW;CAEjC,IAAI,CAAC,UAAU;CAEf,IAAI,SAAS;EACX,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG,OAAO;EACrC,OAAO,oBAAC,kBAAD,EAAkB,YAAY,SAAW,CAAA;CAClD;CAEA,OACE,oBAAC,WAAD;EAAS,WAAW;EAAa,kBAAe;EAC9C,UAAA,oBAAC,mBAAD,EAAmB,YAAY,MAAQ,CAAA;CAChC,CAAA;AAEb,CAAC;AAED,UAAU,cAAc"}
|
package/es/Modal/Modal.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.mjs","names":[],"sources":["../../src/Modal/Modal.tsx"],"sourcesContent":["'use client';\n\nimport { Maximize2, Minimize2, X } from 'lucide-react';\nimport { useDragControls } from 'motion/react';\nimport type { MouseEvent, PointerEvent } from 'react';\nimport type React from 'react';\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { toDataAttributes } from '@/utils/bem';\nimport { stopPropagation } from '@/utils/dom';\n\nimport { Button } from '../Button';\nimport {\n ModalBackdrop,\n ModalContentImpl,\n ModalFooter,\n ModalHeaderImpl,\n ModalPopupImpl,\n ModalPortal,\n ModalRoot,\n ModalTitle,\n} from './atoms';\nimport { modalClasses } from './stable';\nimport { styles } from './style';\nimport type { ModalComponentProps } from './type';\n\ninterface OkBtnProps {\n confirmLoading?: boolean;\n okButtonProps?: ModalComponentProps['okButtonProps'];\n okText?: React.ReactNode;\n onOk: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst OkBtn: React.FC<OkBtnProps> = ({ confirmLoading, okButtonProps, okText, onOk }) => {\n const { onClick: userOnClick, ...restOk } = okButtonProps ?? {};\n return (\n <Button\n loading={confirmLoading}\n type=\"primary\"\n {...restOk}\n onClick={(e) => {\n onOk(e as MouseEvent<HTMLButtonElement>);\n userOnClick?.(e as never);\n }}\n >\n {okText}\n </Button>\n );\n};\ninterface CancelBtnProps {\n cancelButtonProps?: ModalComponentProps['cancelButtonProps'];\n cancelText?: React.ReactNode;\n onCancel: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst CancelBtn: React.FC<CancelBtnProps> = ({ cancelButtonProps, cancelText, onCancel }) => {\n const { onClick: userOnClick, ...restCancel } = cancelButtonProps ?? {};\n return (\n <Button\n {...restCancel}\n onClick={(e) => {\n onCancel(e as MouseEvent<HTMLButtonElement>);\n userOnClick?.(e as never);\n }}\n >\n {cancelText}\n </Button>\n );\n};\n\nconst Modal = memo<ModalComponentProps>(\n ({\n open,\n title,\n children,\n onOk,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n okButtonProps,\n cancelButtonProps,\n confirmLoading,\n footer,\n width,\n height,\n maskClosable = true,\n closable = true,\n closeIcon,\n className,\n style,\n classNames,\n styles: semanticStyles,\n zIndex,\n afterClose,\n afterOpenChange,\n loading,\n getContainer,\n mask = true,\n keyboard,\n draggable = true,\n allowFullscreen = false,\n }) => {\n const dragControls = useDragControls();\n const constraintsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [isDenying, setIsDenying] = useState(false);\n const denyTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n useEffect(() => () => clearTimeout(denyTimerRef.current), []);\n\n const triggerDeny = useCallback(() => {\n clearTimeout(denyTimerRef.current);\n setIsDenying(true);\n denyTimerRef.current = setTimeout(() => setIsDenying(false), 300);\n }, []);\n\n const handleOpenChange = useCallback(\n (nextOpen: boolean, eventDetails: { reason: string }) => {\n if (!open) return;\n if (!nextOpen && keyboard === false && eventDetails.reason === 'escape-key') return;\n if (!nextOpen && !maskClosable && eventDetails.reason === 'outside-press') {\n triggerDeny();\n return;\n }\n if (!nextOpen) {\n onCancel?.(new MouseEvent('click') as unknown as MouseEvent<HTMLButtonElement>);\n }\n },\n [onCancel, keyboard, maskClosable, open, triggerDeny],\n );\n\n const handleExitComplete = useCallback(() => {\n setIsFullscreen(false);\n afterClose?.();\n afterOpenChange?.(false);\n }, [afterClose, afterOpenChange]);\n\n const handleAnimationComplete = useCallback(() => {\n if (open) afterOpenChange?.(true);\n }, [open, afterOpenChange]);\n\n const handleDragStart = useCallback(\n (e: PointerEvent) => {\n if (draggable && !isFullscreen) {\n dragControls.start(e);\n setIsDragging(true);\n }\n },\n [draggable, dragControls, isFullscreen],\n );\n\n const handleDragEnd = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n const handleOk = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onOk?.(e);\n },\n [onOk],\n );\n\n const handleCancel = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onCancel?.(e);\n },\n [onCancel],\n );\n\n const footerNode = useMemo(() => {\n if (footer === false || footer === null) return null;\n const cancelBtnNode = (\n <CancelBtn\n cancelButtonProps={cancelButtonProps}\n cancelText={cancelText}\n onCancel={handleCancel}\n />\n );\n const okBtnNode = (\n <OkBtn\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n okText={okText}\n onOk={handleOk}\n />\n );\n const defaultFooter = (\n <>\n {cancelBtnNode}\n {okBtnNode}\n </>\n );\n\n if (typeof footer === 'function') {\n return footer(defaultFooter, { CancelBtn: () => cancelBtnNode, OkBtn: () => okBtnNode });\n }\n\n return footer ?? defaultFooter;\n }, [\n footer,\n cancelButtonProps,\n cancelText,\n handleCancel,\n confirmLoading,\n okButtonProps,\n okText,\n handleOk,\n ]);\n\n const container = getContainer === false ? undefined : (getContainer ?? undefined);\n\n const shouldDrag = draggable && !isFullscreen;\n const dragProps = shouldDrag\n ? {\n drag: true as const,\n dragConstraints: constraintsRef,\n dragControls,\n dragElastic: 0,\n dragListener: false,\n dragMomentum: false,\n whileDrag: { cursor: 'grabbing' as const },\n }\n : {};\n\n const showTitle = title !== undefined && title !== false && title !== null;\n const showHeader = showTitle || closable || allowFullscreen;\n\n const hasHeight = height !== undefined;\n const dataAttributes = toDataAttributes({ draggable: shouldDrag, fullscreen: isFullscreen });\n const panelStyle: React.CSSProperties = {\n ...(hasHeight && !isFullscreen ? { height } : {}),\n ...style,\n };\n\n return (\n <ModalRoot\n open={open ?? false}\n zIndex={zIndex}\n onExitComplete={handleExitComplete}\n onOpenChange={handleOpenChange}\n >\n <ModalPortal container={container}>\n {mask && (\n <ModalBackdrop\n className={classNames?.mask}\n style={semanticStyles?.mask}\n {...dataAttributes}\n />\n )}\n <ModalPopupImpl\n className={classNames?.wrapper}\n panelClassName={className}\n panelData={dataAttributes}\n {...dataAttributes}\n popupStyle={semanticStyles?.wrapper}\n ref={constraintsRef}\n style={panelStyle}\n width={isFullscreen ? undefined : width}\n motionProps={{\n ...dragProps,\n onAnimationComplete: handleAnimationComplete,\n }}\n panelXstyle={[\n isFullscreen && styles.fullscreenPopupInner,\n isDenying && styles.denyAnimation,\n ]}\n >\n {showHeader && (\n <ModalHeaderImpl\n className={classNames?.header}\n xstyle={shouldDrag && styles.headerDraggable}\n style={{\n ...(isDragging ? { cursor: 'grabbing' } : {}),\n ...semanticStyles?.header,\n }}\n onPointerCancel={handleDragEnd}\n onPointerDown={handleDragStart}\n onPointerUp={handleDragEnd}\n >\n {showTitle ? (\n <ModalTitle className={classNames?.title} style={semanticStyles?.title}>\n {title}\n </ModalTitle>\n ) : (\n <span />\n )}\n <div\n {...styleProps(styles.headerActions, modalClasses('header-actions'))}\n onPointerDown={stopPropagation}\n >\n {allowFullscreen && (\n <button\n aria-label={isFullscreen ? 'Exit fullscreen' : 'Fullscreen'}\n {...styleProps(\n [styles.fullscreenToggle, focusRing.info],\n modalClasses('fullscreen-toggle'),\n )}\n type=\"button\"\n onClick={() => setIsFullscreen((prev) => !prev)}\n >\n {isFullscreen ? <Minimize2 size={14} /> : <Maximize2 size={14} />}\n </button>\n )}\n {closable && (\n <button\n aria-label=\"Close\"\n {...styleProps([styles.closeInline, focusRing.info], modalClasses('close'))}\n type=\"button\"\n onClick={handleCancel}\n >\n {closeIcon ?? <X size={16} />}\n </button>\n )}\n </div>\n </ModalHeaderImpl>\n )}\n <ModalContentImpl\n className={classNames?.body}\n xstyle={!showHeader && styles.contentNoHeader}\n style={{\n ...(hasHeight || isFullscreen ? { flex: 1 } : {}),\n ...semanticStyles?.body,\n }}\n >\n {loading ? (\n <div {...styleProps(styles.loading, modalClasses('loading'))}>\n <span {...styleProps([styles.loadingSpinner, styles.loadingSpinnerLarge])} />\n </div>\n ) : (\n children\n )}\n </ModalContentImpl>\n {footerNode !== null && (\n <ModalFooter className={classNames?.footer} style={semanticStyles?.footer}>\n {footerNode}\n </ModalFooter>\n )}\n </ModalPopupImpl>\n </ModalPortal>\n </ModalRoot>\n );\n },\n);\n\nModal.displayName = 'Modal';\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;AAmCA,MAAM,SAA+B,EAAE,gBAAgB,eAAe,QAAQ,WAAW;CACvF,MAAM,EAAE,SAAS,aAAa,GAAG,WAA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,GAAI,WAAW,OAAO,eAAe,aAAa,gBAAgB,CAAC;OACnE,eAAe;OAFjB,UAAA,CAIG,mBACC,oBAAC,UAAD;QACE,cAAY,eAAe,oBAAoB;QAC/C,GAAI,WACF,CAAC,OAAO,kBAAkB,UAAU,IAAI,GACxC,aAAa,mBAAmB,CAClC;QACA,MAAK;QACL,eAAe,iBAAiB,SAAS,CAAC,IAAI;QAE7C,UAAA,eAAe,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,IAAI,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA;OAC1D,CAAA,GAET,YACC,oBAAC,UAAD;QACE,cAAW;QACX,GAAI,WAAW,CAAC,OAAO,aAAa,UAAU,IAAI,GAAG,aAAa,OAAO,CAAC;QAC1E,MAAK;QACL,SAAS;QAER,UAAA,aAAa,oBAAC,GAAD,EAAG,MAAM,GAAK,CAAA;OACtB,CAAA,CAEP;MACU,CAAA,CAAA;;KAEnB,oBAAC,kBAAD;MACE,WAAW,YAAY;MACvB,QAAQ,CAAC,cAAc,OAAO;MAC9B,OAAO;OACL,GAAI,aAAa,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC;OAC/C,GAAG,gBAAgB;MACrB;MAEC,UAAA,UACC,oBAAC,OAAD;OAAK,GAAI,WAAW,OAAO,SAAS,aAAa,SAAS,CAAC;OACzD,UAAA,oBAAC,QAAD,EAAM,GAAI,WAAW,CAAC,OAAO,gBAAgB,OAAO,mBAAmB,CAAC,EAAI,CAAA;MACzE,CAAA,IAEL;KAEc,CAAA;KACjB,eAAe,QACd,oBAAC,aAAD;MAAa,WAAW,YAAY;MAAQ,OAAO,gBAAgB;MAChE,UAAA;KACU,CAAA;IAED;GACL,CAAA,CAAA;;CACJ,CAAA;AAEf,CACF;AAEA,MAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"Modal.mjs","names":[],"sources":["../../src/Modal/Modal.tsx"],"sourcesContent":["'use client';\n\nimport { Maximize2, Minimize2, X } from 'lucide-react';\nimport { useDragControls } from 'motion/react';\nimport type React from 'react';\nimport type { MouseEvent, PointerEvent } from 'react';\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { toDataAttributes } from '@/utils/bem';\nimport { stopPropagation } from '@/utils/dom';\n\nimport { Button } from '../Button';\nimport {\n ModalBackdrop,\n ModalContentImpl,\n ModalFooter,\n ModalHeaderImpl,\n ModalPopupImpl,\n ModalPortal,\n ModalRoot,\n ModalTitle,\n} from './atoms';\nimport { modalClasses } from './stable';\nimport { styles } from './style';\nimport type { ModalComponentProps } from './type';\n\ninterface OkBtnProps {\n confirmLoading?: boolean;\n okButtonProps?: ModalComponentProps['okButtonProps'];\n okText?: React.ReactNode;\n onOk: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst OkBtn: React.FC<OkBtnProps> = ({ confirmLoading, okButtonProps, okText, onOk }) => {\n const { onClick: userOnClick, ...restOk } = okButtonProps ?? {};\n return (\n <Button\n loading={confirmLoading}\n type=\"primary\"\n {...restOk}\n onClick={(e) => {\n onOk(e as MouseEvent<HTMLButtonElement>);\n userOnClick?.(e as never);\n }}\n >\n {okText}\n </Button>\n );\n};\ninterface CancelBtnProps {\n cancelButtonProps?: ModalComponentProps['cancelButtonProps'];\n cancelText?: React.ReactNode;\n onCancel: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst CancelBtn: React.FC<CancelBtnProps> = ({ cancelButtonProps, cancelText, onCancel }) => {\n const { onClick: userOnClick, ...restCancel } = cancelButtonProps ?? {};\n return (\n <Button\n {...restCancel}\n onClick={(e) => {\n onCancel(e as MouseEvent<HTMLButtonElement>);\n userOnClick?.(e as never);\n }}\n >\n {cancelText}\n </Button>\n );\n};\n\nconst Modal = memo<ModalComponentProps>(\n ({\n open,\n title,\n children,\n onOk,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n okButtonProps,\n cancelButtonProps,\n confirmLoading,\n footer,\n width,\n height,\n maskClosable = true,\n closable = true,\n closeIcon,\n className,\n style,\n classNames,\n styles: semanticStyles,\n zIndex,\n afterClose,\n afterOpenChange,\n loading,\n getContainer,\n mask = true,\n keyboard,\n draggable = true,\n allowFullscreen = false,\n }) => {\n const dragControls = useDragControls();\n const constraintsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [isDenying, setIsDenying] = useState(false);\n const denyTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n useEffect(() => () => clearTimeout(denyTimerRef.current), []);\n\n const triggerDeny = useCallback(() => {\n clearTimeout(denyTimerRef.current);\n setIsDenying(true);\n denyTimerRef.current = setTimeout(() => setIsDenying(false), 300);\n }, []);\n\n const handleOpenChange = useCallback(\n (nextOpen: boolean, eventDetails: { reason: string }) => {\n if (!open) return;\n if (!nextOpen && keyboard === false && eventDetails.reason === 'escape-key') return;\n if (!nextOpen && !maskClosable && eventDetails.reason === 'outside-press') {\n triggerDeny();\n return;\n }\n if (!nextOpen) {\n onCancel?.(new MouseEvent('click') as unknown as MouseEvent<HTMLButtonElement>);\n }\n },\n [onCancel, keyboard, maskClosable, open, triggerDeny],\n );\n\n const handleExitComplete = useCallback(() => {\n setIsFullscreen(false);\n afterClose?.();\n afterOpenChange?.(false);\n }, [afterClose, afterOpenChange]);\n\n const handleAnimationComplete = useCallback(() => {\n if (open) afterOpenChange?.(true);\n }, [open, afterOpenChange]);\n\n const handleDragStart = useCallback(\n (e: PointerEvent) => {\n if (draggable && !isFullscreen) {\n dragControls.start(e);\n setIsDragging(true);\n }\n },\n [draggable, dragControls, isFullscreen],\n );\n\n const handleDragEnd = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n const handleOk = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onOk?.(e);\n },\n [onOk],\n );\n\n const handleCancel = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onCancel?.(e);\n },\n [onCancel],\n );\n\n const footerNode = useMemo(() => {\n if (footer === false || footer === null) return null;\n const cancelBtnNode = (\n <CancelBtn\n cancelButtonProps={cancelButtonProps}\n cancelText={cancelText}\n onCancel={handleCancel}\n />\n );\n const okBtnNode = (\n <OkBtn\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n okText={okText}\n onOk={handleOk}\n />\n );\n const defaultFooter = (\n <>\n {cancelBtnNode}\n {okBtnNode}\n </>\n );\n\n if (typeof footer === 'function') {\n return footer(defaultFooter, { CancelBtn: () => cancelBtnNode, OkBtn: () => okBtnNode });\n }\n\n return footer ?? defaultFooter;\n }, [\n footer,\n cancelButtonProps,\n cancelText,\n handleCancel,\n confirmLoading,\n okButtonProps,\n okText,\n handleOk,\n ]);\n\n const container = getContainer === false ? undefined : (getContainer ?? undefined);\n\n const shouldDrag = draggable && !isFullscreen;\n const dragProps = shouldDrag\n ? {\n drag: true as const,\n dragConstraints: constraintsRef,\n dragControls,\n dragElastic: 0,\n dragListener: false,\n dragMomentum: false,\n whileDrag: { cursor: 'grabbing' as const },\n }\n : {};\n\n const showTitle = title !== undefined && title !== false && title !== null;\n const showHeader = showTitle || closable || allowFullscreen;\n\n const hasHeight = height !== undefined;\n const dataAttributes = toDataAttributes({ draggable: shouldDrag, fullscreen: isFullscreen });\n const panelStyle: React.CSSProperties = {\n ...(hasHeight && !isFullscreen ? { height } : {}),\n ...style,\n };\n\n return (\n <ModalRoot\n open={open ?? false}\n zIndex={zIndex}\n onExitComplete={handleExitComplete}\n onOpenChange={handleOpenChange}\n >\n <ModalPortal container={container}>\n {mask && (\n <ModalBackdrop\n className={classNames?.mask}\n style={semanticStyles?.mask}\n {...dataAttributes}\n />\n )}\n <ModalPopupImpl\n className={classNames?.wrapper}\n panelClassName={className}\n panelData={dataAttributes}\n {...dataAttributes}\n popupStyle={semanticStyles?.wrapper}\n ref={constraintsRef}\n style={panelStyle}\n width={isFullscreen ? undefined : width}\n motionProps={{\n ...dragProps,\n onAnimationComplete: handleAnimationComplete,\n }}\n panelXstyle={[\n isFullscreen && styles.fullscreenPopupInner,\n isDenying && styles.denyAnimation,\n ]}\n >\n {showHeader && (\n <ModalHeaderImpl\n className={classNames?.header}\n xstyle={shouldDrag && styles.headerDraggable}\n style={{\n ...(isDragging ? { cursor: 'grabbing' } : {}),\n ...semanticStyles?.header,\n }}\n onPointerCancel={handleDragEnd}\n onPointerDown={handleDragStart}\n onPointerUp={handleDragEnd}\n >\n {showTitle ? (\n <ModalTitle className={classNames?.title} style={semanticStyles?.title}>\n {title}\n </ModalTitle>\n ) : (\n <span />\n )}\n <div\n {...styleProps(styles.headerActions, modalClasses('header-actions'))}\n onPointerDown={stopPropagation}\n >\n {allowFullscreen && (\n <button\n aria-label={isFullscreen ? 'Exit fullscreen' : 'Fullscreen'}\n {...styleProps(\n [styles.fullscreenToggle, focusRing.info],\n modalClasses('fullscreen-toggle'),\n )}\n type=\"button\"\n onClick={() => setIsFullscreen((prev) => !prev)}\n >\n {isFullscreen ? <Minimize2 size={14} /> : <Maximize2 size={14} />}\n </button>\n )}\n {closable && (\n <button\n aria-label=\"Close\"\n {...styleProps([styles.closeInline, focusRing.info], modalClasses('close'))}\n type=\"button\"\n onClick={handleCancel}\n >\n {closeIcon ?? <X size={16} />}\n </button>\n )}\n </div>\n </ModalHeaderImpl>\n )}\n <ModalContentImpl\n className={classNames?.body}\n xstyle={!showHeader && styles.contentNoHeader}\n style={{\n ...(hasHeight || isFullscreen ? { flex: 1 } : {}),\n ...semanticStyles?.body,\n }}\n >\n {loading ? (\n <div {...styleProps(styles.loading, modalClasses('loading'))}>\n <span {...styleProps([styles.loadingSpinner, styles.loadingSpinnerLarge])} />\n </div>\n ) : (\n children\n )}\n </ModalContentImpl>\n {footerNode !== null && (\n <ModalFooter className={classNames?.footer} style={semanticStyles?.footer}>\n {footerNode}\n </ModalFooter>\n )}\n </ModalPopupImpl>\n </ModalPortal>\n </ModalRoot>\n );\n },\n);\n\nModal.displayName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A,MAAM,cAAc"}
|
package/es/Modal/atoms.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { ModalLayerProvider, useModalLayer } from "./ModalLayerContext.mjs";
|
|
|
12
12
|
import { modalClasses } 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, 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";
|
|
@@ -140,18 +140,18 @@ const ModalPopupImpl = ({ className, children, width, style, motionProps, panelC
|
|
|
140
140
|
className: clsx$1(stylex.props(styles.popup, xstyle).className, modalClasses("wrapper"), className),
|
|
141
141
|
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
142
142
|
onExitComplete: actions.onExitComplete,
|
|
143
|
-
children: open ? /* @__PURE__ */
|
|
143
|
+
children: open ? /* @__PURE__ */ jsx(Motion.div, {
|
|
144
144
|
...modalMotionConfig,
|
|
145
145
|
...motionProps,
|
|
146
|
-
key: "modal-popup-panel",
|
|
147
146
|
...panelData,
|
|
148
147
|
style: {
|
|
149
148
|
maxWidth: width ?? void 0,
|
|
150
149
|
transition: "none",
|
|
151
150
|
...style
|
|
152
151
|
},
|
|
153
|
-
className: clsx$1(stylex.props(styles.popupInner, panelXstyle).className, modalClasses(), panelClassName)
|
|
154
|
-
|
|
152
|
+
className: clsx$1(stylex.props(styles.popupInner, panelXstyle).className, modalClasses(), panelClassName),
|
|
153
|
+
children
|
|
154
|
+
}, "modal-popup-panel") : null
|
|
155
155
|
})
|
|
156
156
|
});
|
|
157
157
|
return /* @__PURE__ */ jsx(Dialog.Popup, {
|
package/es/Modal/atoms.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/Modal/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 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 { backdropTransition, modalMotionConfig } from './constants';\nimport { ModalLayerProvider, useModalLayer } from './ModalLayerContext';\nimport { modalClasses } from './stable';\nimport { styles } from './style';\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\n// --- Animation Contexts (granular to minimize re-renders) ---\n\n// State: open boolean, null = non-animated mode\nconst ModalOpenContext = createContext<boolean | null>(null);\n\n// Actions: stable callbacks, null = non-animated mode\ninterface ModalAnimationActions {\n onExitComplete: () => void;\n}\nconst ModalActionsContext = createContext<ModalAnimationActions | null>(null);\n\nexport const useModalOpen = () => use(ModalOpenContext);\nexport const useModalActions = () => use(ModalActionsContext);\n\n// --- Root ---\nexport type ModalRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedModalRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<ModalRootProps, '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 <ModalOpenContext value={open}>\n <ModalActionsContext value={actions}>\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n </ModalActionsContext>\n </ModalOpenContext>\n );\n};\n\nconst NonAnimatedModalRoot = ({ zIndex: explicitZIndex, children, ...rest }: ModalRootProps) => {\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 return (\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n );\n};\n\nexport const ModalRoot = ({ open, onExitComplete, ...rest }: ModalRootProps) => {\n if (open !== undefined) {\n return <AnimatedModalRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedModalRoot {...rest} />;\n};\n\n// --- Portal ---\nexport type ModalPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const ModalPortal = ({ container, ...rest }: ModalPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\n// --- Viewport ---\nexport type ModalViewportProps = React.ComponentProps<typeof Dialog.Viewport>;\nexport const ModalViewport = ({ className, ...rest }: ModalViewportProps) => (\n <Dialog.Viewport\n {...rest}\n className={\n mergeStateClassName(styles.viewport, className as any, modalClasses('viewport')) as any\n }\n />\n);\n\n// --- Backdrop ---\nexport type ModalBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const ModalBackdrop = ({ className, style, ...rest }: ModalBackdropProps) => {\n const open = useModalOpen();\n const layer = useModalLayer();\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 modalClasses('backdrop'),\n className as string,\n )}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={backdropTransition}\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, modalClasses('backdrop')) as any\n }\n />\n );\n};\n\n// --- Popup ---\nexport type ModalPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n motionProps?: Record<string, any>;\n panelClassName?: string;\n panelData?: Record<`data-${string}`, string>;\n popupStyle?: React.CSSProperties;\n width?: number | string;\n};\nexport const ModalPopupImpl = ({\n className,\n children,\n width,\n style,\n motionProps,\n panelClassName,\n panelData,\n panelXstyle,\n popupStyle,\n ref: forwardedRef,\n xstyle,\n ...rest\n}: ModalPopupProps & { panelXstyle?: XStyle; xstyle?: XStyle }) => {\n const open = useModalOpen();\n const actions = useModalActions();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const popupZIndexStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex + 1 } : undefined;\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n if (open !== null && actions) {\n return (\n <Dialog.Popup\n {...rest}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n className={clsx(\n stylex.props(styles.popup, xstyle).className,\n modalClasses('wrapper'),\n className as string,\n )}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n {...modalMotionConfig}\n {...motionProps}\n key=\"modal-popup-panel\"\n {...panelData}\n style={{ maxWidth: width ?? undefined, transition: 'none', ...style }}\n className={clsx(\n stylex.props(styles.popupInner, panelXstyle).className,\n modalClasses(),\n panelClassName,\n )}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n return (\n <Dialog.Popup\n {...rest}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n className={\n mergeStateClassName(\n [styles.popup, xstyle],\n className as any,\n modalClasses('wrapper'),\n ) as any\n }\n >\n <div\n {...panelData}\n {...styleProps([styles.popupInner, panelXstyle], clsx(modalClasses(), panelClassName), {\n maxWidth: width ?? undefined,\n ...style,\n })}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\nexport const ModalPopup: React.FC<ModalPopupProps> = ModalPopupImpl;\n\n// --- Header ---\nexport type ModalHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalHeaderImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalHeaderProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.header, xstyle], clsx(modalClasses('header'), className), style)}\n />\n);\nexport const ModalHeader: React.FC<ModalHeaderProps> = ModalHeaderImpl;\n\n// --- Title ---\nexport type ModalTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const ModalTitleImpl = ({\n className,\n xstyle,\n ...rest\n}: ModalTitleProps & { xstyle?: XStyle }) => (\n <Dialog.Title\n {...rest}\n className={\n mergeStateClassName([styles.title, xstyle], className as any, modalClasses('title')) as any\n }\n />\n);\nexport const ModalTitle: React.FC<ModalTitleProps> = ModalTitleImpl;\n\n// --- Description ---\nexport type ModalDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const ModalDescription: React.FC<ModalDescriptionProps> = ({ className, ...rest }) => (\n <Dialog.Description\n {...rest}\n className={mergeStateClassName(undefined, className as any, modalClasses('description')) as any}\n />\n);\n\n// --- Content ---\nexport type ModalContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalContentImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalContentProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.content, xstyle], clsx(modalClasses('content'), className), style)}\n />\n);\nexport const ModalContent: React.FC<ModalContentProps> = ModalContentImpl;\n\n// --- Footer ---\nexport type ModalFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalFooterImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalFooterProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.footer, xstyle], clsx(modalClasses('footer'), className), style)}\n />\n);\nexport const ModalFooter: React.FC<ModalFooterProps> = ModalFooterImpl;\n\n// --- Close ---\nexport type ModalCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const ModalCloseImpl = ({\n className,\n children,\n xstyle,\n ...rest\n}: ModalCloseProps & { xstyle?: XStyle }) => (\n <Dialog.Close\n {...rest}\n className={\n mergeStateClassName(\n [styles.closeInline, styles.close, focusRing.info, xstyle],\n className as any,\n modalClasses('close'),\n ) as any\n }\n >\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\nexport const ModalClose: React.FC<ModalCloseProps> = ModalCloseImpl;\n\n// --- Trigger ---\nexport type ModalTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const ModalTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: ModalTriggerProps) => {\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 className={mergeStateClassName(undefined, className as any, modalClasses('trigger')) as any}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={mergeStateClassName(undefined, className as any, modalClasses('trigger')) as any}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,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;AAKA,MAAM,mBAAmB,cAA8B,IAAI;AAM3D,MAAM,sBAAsB,cAA4C,IAAI;AAC5E,MAAa,qBAAqB,IAAI,gBAAgB;AACtD,MAAa,wBAAwB,IAAI,mBAAmB;AAO5D,MAAM,qBAAqB,EACzB,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,CA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a,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,WAAW,oBAAoB,KAAA,GAAW,WAAkB,aAAa,SAAS,CAAC;EAAU,cAAc;EAAsB,QAAQ;CAAkB,CAAA;CAE9L,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAM,WAAW,oBAAoB,KAAA,GAAW,WAAkB,aAAa,SAAS,CAAC;EAAU,cAAc;EAAsB,KAAK;EAClK;CACa,CAAA;AACpB"}
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":["clsx"],"sources":["../../src/Modal/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 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 { backdropTransition, modalMotionConfig } from './constants';\nimport { ModalLayerProvider, useModalLayer } from './ModalLayerContext';\nimport { modalClasses } from './stable';\nimport { styles } from './style';\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\n// --- Animation Contexts (granular to minimize re-renders) ---\n\n// State: open boolean, null = non-animated mode\nconst ModalOpenContext = createContext<boolean | null>(null);\n\n// Actions: stable callbacks, null = non-animated mode\ninterface ModalAnimationActions {\n onExitComplete: () => void;\n}\nconst ModalActionsContext = createContext<ModalAnimationActions | null>(null);\n\nexport const useModalOpen = () => use(ModalOpenContext);\nexport const useModalActions = () => use(ModalActionsContext);\n\n// --- Root ---\nexport type ModalRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedModalRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<ModalRootProps, '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 <ModalOpenContext value={open}>\n <ModalActionsContext value={actions}>\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n </ModalActionsContext>\n </ModalOpenContext>\n );\n};\n\nconst NonAnimatedModalRoot = ({ zIndex: explicitZIndex, children, ...rest }: ModalRootProps) => {\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 return (\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n );\n};\n\nexport const ModalRoot = ({ open, onExitComplete, ...rest }: ModalRootProps) => {\n if (open !== undefined) {\n return <AnimatedModalRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedModalRoot {...rest} />;\n};\n\n// --- Portal ---\nexport type ModalPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const ModalPortal = ({ container, ...rest }: ModalPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\n// --- Viewport ---\nexport type ModalViewportProps = React.ComponentProps<typeof Dialog.Viewport>;\nexport const ModalViewport = ({ className, ...rest }: ModalViewportProps) => (\n <Dialog.Viewport\n {...rest}\n className={\n mergeStateClassName(styles.viewport, className as any, modalClasses('viewport')) as any\n }\n />\n);\n\n// --- Backdrop ---\nexport type ModalBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const ModalBackdrop = ({ className, style, ...rest }: ModalBackdropProps) => {\n const open = useModalOpen();\n const layer = useModalLayer();\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 modalClasses('backdrop'),\n className as string,\n )}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={backdropTransition}\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, modalClasses('backdrop')) as any\n }\n />\n );\n};\n\n// --- Popup ---\nexport type ModalPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n motionProps?: Record<string, any>;\n panelClassName?: string;\n panelData?: Record<`data-${string}`, string>;\n popupStyle?: React.CSSProperties;\n width?: number | string;\n};\nexport const ModalPopupImpl = ({\n className,\n children,\n width,\n style,\n motionProps,\n panelClassName,\n panelData,\n panelXstyle,\n popupStyle,\n ref: forwardedRef,\n xstyle,\n ...rest\n}: ModalPopupProps & { panelXstyle?: XStyle; xstyle?: XStyle }) => {\n const open = useModalOpen();\n const actions = useModalActions();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const popupZIndexStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex + 1 } : undefined;\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n if (open !== null && actions) {\n return (\n <Dialog.Popup\n {...rest}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n className={clsx(\n stylex.props(styles.popup, xstyle).className,\n modalClasses('wrapper'),\n className as string,\n )}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n key=\"modal-popup-panel\"\n {...modalMotionConfig}\n {...motionProps}\n {...panelData}\n style={{ maxWidth: width ?? undefined, transition: 'none', ...style }}\n className={clsx(\n stylex.props(styles.popupInner, panelXstyle).className,\n modalClasses(),\n panelClassName,\n )}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n return (\n <Dialog.Popup\n {...rest}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n className={\n mergeStateClassName(\n [styles.popup, xstyle],\n className as any,\n modalClasses('wrapper'),\n ) as any\n }\n >\n <div\n {...panelData}\n {...styleProps([styles.popupInner, panelXstyle], clsx(modalClasses(), panelClassName), {\n maxWidth: width ?? undefined,\n ...style,\n })}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\nexport const ModalPopup: React.FC<ModalPopupProps> = ModalPopupImpl;\n\n// --- Header ---\nexport type ModalHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalHeaderImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalHeaderProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.header, xstyle], clsx(modalClasses('header'), className), style)}\n />\n);\nexport const ModalHeader: React.FC<ModalHeaderProps> = ModalHeaderImpl;\n\n// --- Title ---\nexport type ModalTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const ModalTitleImpl = ({\n className,\n xstyle,\n ...rest\n}: ModalTitleProps & { xstyle?: XStyle }) => (\n <Dialog.Title\n {...rest}\n className={\n mergeStateClassName([styles.title, xstyle], className as any, modalClasses('title')) as any\n }\n />\n);\nexport const ModalTitle: React.FC<ModalTitleProps> = ModalTitleImpl;\n\n// --- Description ---\nexport type ModalDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const ModalDescription: React.FC<ModalDescriptionProps> = ({ className, ...rest }) => (\n <Dialog.Description\n {...rest}\n className={mergeStateClassName(undefined, className as any, modalClasses('description')) as any}\n />\n);\n\n// --- Content ---\nexport type ModalContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalContentImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalContentProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.content, xstyle], clsx(modalClasses('content'), className), style)}\n />\n);\nexport const ModalContent: React.FC<ModalContentProps> = ModalContentImpl;\n\n// --- Footer ---\nexport type ModalFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalFooterImpl = ({\n className,\n style,\n xstyle,\n ...rest\n}: ModalFooterProps & { xstyle?: XStyle }) => (\n <div\n {...rest}\n {...styleProps([styles.footer, xstyle], clsx(modalClasses('footer'), className), style)}\n />\n);\nexport const ModalFooter: React.FC<ModalFooterProps> = ModalFooterImpl;\n\n// --- Close ---\nexport type ModalCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const ModalCloseImpl = ({\n className,\n children,\n xstyle,\n ...rest\n}: ModalCloseProps & { xstyle?: XStyle }) => (\n <Dialog.Close\n {...rest}\n className={\n mergeStateClassName(\n [styles.closeInline, styles.close, focusRing.info, xstyle],\n className as any,\n modalClasses('close'),\n ) as any\n }\n >\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\nexport const ModalClose: React.FC<ModalCloseProps> = ModalCloseImpl;\n\n// --- Trigger ---\nexport type ModalTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const ModalTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: ModalTriggerProps) => {\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 className={mergeStateClassName(undefined, className as any, modalClasses('trigger')) as any}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={mergeStateClassName(undefined, className as any, modalClasses('trigger')) as any}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,uBAAgC,QAAgB,WAAyE,oBAA6B;CAC1J,MAAM,OAAOA,OAAK,OAAO,MAAM,MAAM,CAAC,CAA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,OAAO;EAAO,UAAU;EAAM;CAAM,GAAG,WAAkB,aAAa,OAAO,CAAC;CAC3J,UAAA,YAAY,oBAAC,GAAD,EAAG,MAAM,GAAK,CAAA;AACf,CAAA;AAChB,MAAa,aAAwC;AAOrD,MAAa,gBAAgB,EAC3B,UACA,WACA,cACA,KAAK,SACL,GAAG,WACoB;CACvB,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,WAAW,oBAAoB,KAAA,GAAW,WAAkB,aAAa,SAAS,CAAC;EAAU,cAAc;EAAsB,QAAQ;CAAkB,CAAA;CAE9L,OAAO,oBAAC,OAAO,SAAR;EAAgB,GAAI;EAAM,WAAW,oBAAoB,KAAA,GAAW,WAAkB,aAAa,SAAS,CAAC;EAAU,cAAc;EAAsB,KAAK;EAClK;CACa,CAAA;AACpB"}
|
|
@@ -10,7 +10,7 @@ import { paginationJumpMarker } from "./marker.stylex.mjs";
|
|
|
10
10
|
import { paginationClasses } from "./stable.mjs";
|
|
11
11
|
import { styles } from "./style.mjs";
|
|
12
12
|
import clsx$1 from "clsx";
|
|
13
|
-
import {
|
|
13
|
+
import { memo, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
14
14
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import * as stylex from "@stylexjs/stylex";
|
|
16
16
|
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react";
|
|
@@ -200,7 +200,7 @@ const Pagination = memo(({ align, className, classNames, components, current, de
|
|
|
200
200
|
type: "button",
|
|
201
201
|
onClick: () => goTo(item),
|
|
202
202
|
children: render(item, "page", item)
|
|
203
|
-
}, item) : /* @__PURE__ */
|
|
203
|
+
}, item) : /* @__PURE__ */ jsx("button", {
|
|
204
204
|
...styleProps([
|
|
205
205
|
paginationJumpMarker,
|
|
206
206
|
styles.ellipsis,
|
|
@@ -208,11 +208,11 @@ const Pagination = memo(({ align, className, classNames, components, current, de
|
|
|
208
208
|
], paginationClasses("jump")),
|
|
209
209
|
"data-pagination-jump": item === "ellipsis-prev" ? "prev" : "next",
|
|
210
210
|
disabled,
|
|
211
|
-
key: item,
|
|
212
211
|
type: "button",
|
|
213
212
|
title: title(item === "ellipsis-prev" ? `Previous ${jumpStep} Pages` : `Next ${jumpStep} Pages`),
|
|
214
|
-
onClick: () => goTo(item === "ellipsis-prev" ? Math.max(1, displayCurrent - jumpStep) : Math.min(pageCount, displayCurrent + jumpStep))
|
|
215
|
-
|
|
213
|
+
onClick: () => goTo(item === "ellipsis-prev" ? Math.max(1, displayCurrent - jumpStep) : Math.min(pageCount, displayCurrent + jumpStep)),
|
|
214
|
+
children: item === "ellipsis-prev" ? render(Math.max(1, displayCurrent - jumpStep), "jump-prev", /* @__PURE__ */ jsx(JumpIcon, { direction: "prev" })) : render(Math.min(pageCount, displayCurrent + jumpStep), "jump-next", /* @__PURE__ */ jsx(JumpIcon, { direction: "next" }))
|
|
215
|
+
}, item)),
|
|
216
216
|
nextButton
|
|
217
217
|
] }),
|
|
218
218
|
!simpleConfig && mergedShowSizeChanger && /* @__PURE__ */ jsx(SizeChanger, {
|