@lobehub/ui 6.0.0-beta.4 → 6.0.0-beta.6
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/es/ActionIcon/style.mjs +1 -1
- package/es/ActionIcon/style.mjs.map +1 -1
- package/es/Anchor/Anchor.mjs +2 -2
- package/es/Anchor/Anchor.mjs.map +1 -1
- package/es/Carousel/Carousel.mjs +1 -1
- package/es/Carousel/Carousel.mjs.map +1 -1
- package/es/CodeDiff/CodeDiff.mjs.map +1 -1
- package/es/CodeDiff/PatchDiff.mjs.map +1 -1
- package/es/CodeDiff/theme.mjs.map +1 -1
- package/es/CodeDiff/type.d.mts +2 -2
- package/es/CodeEditor/CodeEditor.mjs +1 -1
- package/es/CodeEditor/CodeEditor.mjs.map +1 -1
- package/es/ColorPicker/ColorPicker.mjs +1 -1
- package/es/ColorPicker/ColorPicker.mjs.map +1 -1
- package/es/ColorSwatches/ColorSwatches.mjs +18 -23
- package/es/ColorSwatches/ColorSwatches.mjs.map +1 -1
- package/es/ColorSwatches/CustomPicker.mjs +101 -0
- package/es/ColorSwatches/CustomPicker.mjs.map +1 -0
- package/es/ColorSwatches/index.d.mts +2 -2
- package/es/ColorSwatches/marker.stylex.mjs +9 -0
- package/es/ColorSwatches/marker.stylex.mjs.map +1 -0
- package/es/ColorSwatches/style.mjs +36 -0
- package/es/ColorSwatches/style.mjs.map +1 -1
- package/es/ColorSwatches/type.d.mts +9 -0
- package/es/ConfigProvider/cdnAssets.mjs +6 -0
- package/es/ConfigProvider/cdnAssets.mjs.map +1 -0
- package/es/ConfigProvider/index.mjs +2 -1
- package/es/ConfigProvider/index.mjs.map +1 -1
- package/es/ContextMenu/store.d.mts +0 -1
- package/es/ContextMenu/store.mjs.map +1 -1
- package/es/DatePicker/DatePicker.mjs +1 -1
- package/es/DatePicker/DatePicker.mjs.map +1 -1
- package/es/DatePicker/DateRangePicker.mjs +1 -1
- package/es/DatePicker/DateRangePicker.mjs.map +1 -1
- package/es/DraggablePanel/atoms.mjs +1 -1
- package/es/DraggablePanel/atoms.mjs.map +1 -1
- package/es/DraggableSideNav/DraggableSideNav.mjs +2 -2
- package/es/DraggableSideNav/DraggableSideNav.mjs.map +1 -1
- package/es/Drawer/atoms.mjs +1 -1
- package/es/Drawer/atoms.mjs.map +1 -1
- package/es/DropdownMenu/atoms.mjs +1 -1
- package/es/DropdownMenu/atoms.mjs.map +1 -1
- package/es/EditableText/ControlInput.mjs +42 -29
- package/es/EditableText/ControlInput.mjs.map +1 -1
- package/es/EditableText/EditableText.mjs +1 -1
- package/es/EditableText/EditableText.mjs.map +1 -1
- package/es/EmojiPicker/EmojiPicker.mjs +3 -9
- package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
- package/es/EmojiPicker/useEmojiMartI18n.mjs +37 -0
- package/es/EmojiPicker/useEmojiMartI18n.mjs.map +1 -0
- package/es/FormKit/engine/tanstack.mjs +1 -1
- package/es/FormKit/engine/tanstack.mjs.map +1 -1
- package/es/Grid/style.mjs +1 -1
- package/es/Grid/style.mjs.map +1 -1
- package/es/HotkeyInput/HotkeyInput.mjs +1 -1
- package/es/HotkeyInput/HotkeyInput.mjs.map +1 -1
- package/es/Image/type.d.mts +1 -0
- package/es/Image/viewer/ImageViewer.mjs +2 -1
- package/es/Image/viewer/ImageViewer.mjs.map +1 -1
- package/es/Image/viewer/Toolbar.mjs +19 -6
- package/es/Image/viewer/Toolbar.mjs.map +1 -1
- package/es/Image/viewer/ViewerChrome.mjs.map +1 -1
- package/es/ImageSelect/ImageSelect.mjs +1 -1
- package/es/ImageSelect/ImageSelect.mjs.map +1 -1
- package/es/Input/Input.mjs +7 -5
- package/es/Input/Input.mjs.map +1 -1
- package/es/Input/TextArea.mjs +1 -1
- package/es/Input/TextArea.mjs.map +1 -1
- package/es/Input/style.mjs +3 -3
- package/es/Input/style.mjs.map +1 -1
- package/es/Modal/atoms.mjs +3 -3
- package/es/Modal/atoms.mjs.map +1 -1
- package/es/Pagination/Pagination.mjs +1 -1
- package/es/Pagination/Pagination.mjs.map +1 -1
- package/es/Popover/PopoverInGroup.mjs +1 -1
- package/es/Popover/PopoverInGroup.mjs.map +1 -1
- package/es/Popover/atoms.mjs +1 -1
- package/es/Popover/atoms.mjs.map +1 -1
- package/es/Rate/Rate.mjs +1 -1
- package/es/Rate/Rate.mjs.map +1 -1
- package/es/ScrollShadow/ScrollShadow.mjs +1 -1
- package/es/ScrollShadow/ScrollShadow.mjs.map +1 -1
- package/es/SearchBar/SearchBar.mjs +31 -25
- package/es/SearchBar/SearchBar.mjs.map +1 -1
- package/es/Segmented/Segmented.mjs +1 -1
- package/es/Segmented/Segmented.mjs.map +1 -1
- package/es/Select/atoms.mjs +1 -1
- package/es/Select/atoms.mjs.map +1 -1
- package/es/Switch/atoms.mjs +1 -1
- package/es/Switch/atoms.mjs.map +1 -1
- package/es/Tabs/Tabs.mjs +35 -21
- package/es/Tabs/Tabs.mjs.map +1 -1
- package/es/ToggleGroup/ToggleGroup.mjs +1 -1
- package/es/ToggleGroup/ToggleGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipInGroup.mjs +1 -1
- package/es/Tooltip/TooltipInGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipStandalone.mjs +1 -1
- package/es/Tooltip/TooltipStandalone.mjs.map +1 -1
- package/es/Tree/Tree.mjs +1 -1
- package/es/Tree/Tree.mjs.map +1 -1
- package/es/awesome/Giscus/style.mjs +9 -9
- package/es/awesome/Giscus/style.mjs.map +1 -1
- package/es/awesome/Grainient/Grainient.d.mts +11 -0
- package/es/awesome/Grainient/Grainient.mjs +314 -0
- package/es/awesome/Grainient/Grainient.mjs.map +1 -0
- package/es/awesome/Grainient/index.d.mts +3 -0
- package/es/awesome/Grainient/style.mjs +23 -0
- package/es/awesome/Grainient/style.mjs.map +1 -0
- package/es/awesome/Grainient/type.d.mts +121 -0
- package/es/awesome/GridBackground/GridBackground.mjs +1 -1
- package/es/awesome/GridBackground/GridBackground.mjs.map +1 -1
- package/es/awesome/GridBackground/GridShowcase.mjs +4 -4
- package/es/awesome/GridBackground/GridShowcase.mjs.map +1 -1
- package/es/awesome/Spline/ParentSize.mjs +1 -1
- package/es/awesome/Spline/ParentSize.mjs.map +1 -1
- package/es/awesome/index.d.mts +4 -1
- package/es/awesome/index.mjs +2 -1
- package/es/chat/BackBottom/BackBottom.mjs +1 -1
- package/es/chat/BackBottom/BackBottom.mjs.map +1 -1
- package/es/chat/BackBottom/type.d.mts +2 -2
- package/es/chat/EditableMessage/EditableMessage.mjs +1 -1
- package/es/chat/EditableMessage/EditableMessage.mjs.map +1 -1
- package/es/chat/EditableMessageList/EditableMessageList.mjs +1 -1
- package/es/chat/EditableMessageList/EditableMessageList.mjs.map +1 -1
- package/es/chat/EditableMessageList/messageReducer.mjs +30 -23
- package/es/chat/EditableMessageList/messageReducer.mjs.map +1 -1
- package/es/chat/MessageModal/MessageModal.mjs +1 -1
- package/es/chat/MessageModal/MessageModal.mjs.map +1 -1
- package/es/chat/TokenTag/TokenTag.mjs +2 -3
- package/es/chat/TokenTag/TokenTag.mjs.map +1 -1
- package/es/dashboard/AuthLayout/Aside.d.mts +10 -0
- package/es/dashboard/AuthLayout/Aside.mjs +31 -0
- package/es/dashboard/AuthLayout/Aside.mjs.map +1 -0
- package/es/dashboard/AuthLayout/AuthLayout.d.mts +3 -1
- package/es/dashboard/AuthLayout/AuthLayout.mjs +93 -37
- package/es/dashboard/AuthLayout/AuthLayout.mjs.map +1 -1
- package/es/dashboard/AuthLayout/index.d.mts +3 -2
- package/es/dashboard/AuthLayout/style.mjs +98 -1
- package/es/dashboard/AuthLayout/style.mjs.map +1 -1
- package/es/dashboard/AuthLayout/type.d.mts +38 -2
- package/es/dashboard/AuthTools/AuthLocaleSwitch.d.mts +10 -0
- package/es/dashboard/AuthTools/AuthLocaleSwitch.mjs +33 -0
- package/es/dashboard/AuthTools/AuthLocaleSwitch.mjs.map +1 -0
- package/es/dashboard/AuthTools/AuthThemeSwitch.d.mts +10 -0
- package/es/dashboard/AuthTools/AuthThemeSwitch.mjs +59 -0
- package/es/dashboard/AuthTools/AuthThemeSwitch.mjs.map +1 -0
- package/es/dashboard/AuthTools/index.d.mts +4 -0
- package/es/dashboard/AuthTools/style.mjs +27 -0
- package/es/dashboard/AuthTools/style.mjs.map +1 -0
- package/es/dashboard/AuthTools/type.d.mts +29 -0
- package/es/dashboard/ChartGrid/ChartGrid.d.mts +10 -0
- package/es/dashboard/ChartGrid/ChartGrid.mjs +19 -0
- package/es/dashboard/ChartGrid/ChartGrid.mjs.map +1 -0
- package/es/dashboard/ChartGrid/index.d.mts +3 -0
- package/es/dashboard/ChartGrid/style.mjs +18 -0
- package/es/dashboard/ChartGrid/style.mjs.map +1 -0
- package/es/dashboard/ChartGrid/type.d.mts +8 -0
- package/es/dashboard/ConsoleNav/Skeleton.d.mts +15 -0
- package/es/dashboard/ConsoleNav/Skeleton.mjs +82 -0
- package/es/dashboard/ConsoleNav/Skeleton.mjs.map +1 -0
- package/es/dashboard/ConsoleNav/index.d.mts +3 -2
- package/es/dashboard/ConsoleNav/style.mjs +18 -0
- package/es/dashboard/ConsoleNav/style.mjs.map +1 -1
- package/es/dashboard/ConsoleNav/type.d.mts +13 -0
- package/es/dashboard/ConsoleShell/ConsoleShell.d.mts +1 -1
- package/es/dashboard/ConsoleShell/ConsoleShell.mjs +26 -6
- package/es/dashboard/ConsoleShell/ConsoleShell.mjs.map +1 -1
- package/es/dashboard/ConsoleShell/style.mjs +10 -0
- package/es/dashboard/ConsoleShell/style.mjs.map +1 -1
- package/es/dashboard/ConsoleShell/type.d.mts +11 -0
- package/es/dashboard/FilterSidebar/FilterSidebar.mjs +18 -17
- package/es/dashboard/FilterSidebar/FilterSidebar.mjs.map +1 -1
- package/es/dashboard/FilterStrip/FilterStrip.d.mts +11 -0
- package/es/dashboard/FilterStrip/FilterStrip.mjs +55 -0
- package/es/dashboard/FilterStrip/FilterStrip.mjs.map +1 -0
- package/es/dashboard/FilterStrip/index.d.mts +3 -0
- package/es/dashboard/FilterStrip/style.mjs +78 -0
- package/es/dashboard/FilterStrip/style.mjs.map +1 -0
- package/es/dashboard/FilterStrip/type.d.mts +25 -0
- package/es/dashboard/LabelWithKey/LabelWithKey.d.mts +10 -0
- package/es/dashboard/LabelWithKey/LabelWithKey.mjs +18 -0
- package/es/dashboard/LabelWithKey/LabelWithKey.mjs.map +1 -0
- package/es/dashboard/LabelWithKey/index.d.mts +3 -0
- package/es/dashboard/LabelWithKey/type.d.mts +11 -0
- package/es/dashboard/MetricStrip/MetricCell.mjs +81 -0
- package/es/dashboard/MetricStrip/MetricCell.mjs.map +1 -0
- package/es/dashboard/MetricStrip/MetricStrip.d.mts +13 -0
- package/es/dashboard/MetricStrip/MetricStrip.mjs +47 -0
- package/es/dashboard/MetricStrip/MetricStrip.mjs.map +1 -0
- package/es/dashboard/MetricStrip/index.d.mts +3 -0
- package/es/dashboard/MetricStrip/style.mjs +156 -0
- package/es/dashboard/MetricStrip/style.mjs.map +1 -0
- package/es/dashboard/MetricStrip/type.d.mts +36 -0
- package/es/dashboard/PageSkeleton/PageSkeleton.mjs +20 -18
- package/es/dashboard/PageSkeleton/PageSkeleton.mjs.map +1 -1
- package/es/dashboard/PageSkeleton/style.mjs +1 -1
- package/es/dashboard/PageSkeleton/style.mjs.map +1 -1
- package/es/dashboard/PageToolbar/PageToolbar.d.mts +10 -0
- package/es/dashboard/PageToolbar/PageToolbar.mjs +22 -0
- package/es/dashboard/PageToolbar/PageToolbar.mjs.map +1 -0
- package/es/dashboard/PageToolbar/index.d.mts +3 -0
- package/es/dashboard/PageToolbar/style.mjs +36 -0
- package/es/dashboard/PageToolbar/style.mjs.map +1 -0
- package/es/dashboard/PageToolbar/type.d.mts +11 -0
- package/es/dashboard/PanelSurface/PanelSurface.d.mts +10 -0
- package/es/dashboard/PanelSurface/PanelSurface.mjs +40 -0
- package/es/dashboard/PanelSurface/PanelSurface.mjs.map +1 -0
- package/es/dashboard/PanelSurface/index.d.mts +3 -0
- package/es/dashboard/PanelSurface/style.mjs +25 -0
- package/es/dashboard/PanelSurface/style.mjs.map +1 -0
- package/es/dashboard/PanelSurface/type.d.mts +17 -0
- package/es/dashboard/Section/Section.d.mts +10 -0
- package/es/dashboard/Section/Section.mjs +81 -0
- package/es/dashboard/Section/Section.mjs.map +1 -0
- package/es/dashboard/Section/index.d.mts +3 -0
- package/es/dashboard/Section/style.mjs +31 -0
- package/es/dashboard/Section/style.mjs.map +1 -0
- package/es/dashboard/Section/type.d.mts +23 -0
- package/es/dashboard/StatCard/StatCard.d.mts +2 -1
- package/es/dashboard/StatCard/StatCard.mjs +28 -91
- package/es/dashboard/StatCard/StatCard.mjs.map +1 -1
- package/es/dashboard/StatCard/type.d.mts +16 -5
- package/es/dashboard/Surface/Surface.d.mts +4 -3
- package/es/dashboard/Surface/Surface.mjs +91 -8
- package/es/dashboard/Surface/Surface.mjs.map +1 -1
- package/es/dashboard/Surface/index.d.mts +3 -2
- package/es/dashboard/Surface/link.d.mts +16 -0
- package/es/dashboard/Surface/link.mjs +40 -0
- package/es/dashboard/Surface/link.mjs.map +1 -0
- package/es/dashboard/Surface/marker.stylex.mjs +9 -0
- package/es/dashboard/Surface/marker.stylex.mjs.map +1 -0
- package/es/dashboard/Surface/style.d.mts +2 -0
- package/es/dashboard/Surface/style.mjs +155 -14
- package/es/dashboard/Surface/style.mjs.map +1 -1
- package/es/dashboard/Surface/type.d.mts +29 -1
- package/es/dashboard/TableIconActions/TableIconActions.d.mts +17 -0
- package/es/dashboard/TableIconActions/TableIconActions.mjs +39 -0
- package/es/dashboard/TableIconActions/TableIconActions.mjs.map +1 -0
- package/es/dashboard/TableIconActions/index.d.mts +3 -0
- package/es/dashboard/TableIconActions/type.d.mts +17 -0
- package/es/dashboard/TitleWithTips/TitleWithTips.d.mts +10 -0
- package/es/dashboard/TitleWithTips/TitleWithTips.mjs +28 -0
- package/es/dashboard/TitleWithTips/TitleWithTips.mjs.map +1 -0
- package/es/dashboard/TitleWithTips/index.d.mts +3 -0
- package/es/dashboard/TitleWithTips/type.d.mts +10 -0
- package/es/dashboard/index.d.mts +38 -4
- package/es/dashboard/index.mjs +17 -3
- package/es/hooks/useControlledState.mjs +20 -0
- package/es/hooks/useControlledState.mjs.map +1 -0
- package/es/hooks/useHighlight.mjs +2 -2
- package/es/hooks/useHighlight.mjs.map +1 -1
- package/es/hooks/useHover.mjs +22 -0
- package/es/hooks/useHover.mjs.map +1 -0
- package/es/hooks/useScroll.d.mts +8 -0
- package/es/hooks/useScroll.mjs +33 -0
- package/es/hooks/useScroll.mjs.map +1 -0
- package/es/hooks/useSize.mjs +26 -0
- package/es/hooks/useSize.mjs.map +1 -0
- package/es/internal/virtual/VirtualScrollArea.mjs +1 -1
- package/es/internal/virtual/VirtualScrollArea.mjs.map +1 -1
- package/es/mobile/ChatInputArea/ChatInputArea.mjs +1 -1
- package/es/mobile/ChatInputArea/ChatInputArea.mjs.map +1 -1
- package/es/mobile/TabBar/TabBar.mjs +1 -1
- package/es/mobile/TabBar/TabBar.mjs.map +1 -1
- package/es/node_modules/.pnpm/@eslint_core@1.2.1/node_modules/@eslint/core/dist/esm/types.d.mts +2 -46
- package/es/node_modules/.pnpm/@eslint_plugin-kit@0.7.3/node_modules/@eslint/plugin-kit/dist/cjs/index.d.mts +1 -1
- package/es/node_modules/.pnpm/@types_estree@1.0.9/node_modules/@types/estree/index.d.mts +1 -4
- package/es/node_modules/.pnpm/eslint@10.12.0_jiti@2.6.1_supports-color@10.2.2/node_modules/eslint/lib/types/index.d.mts +1 -1
- package/es/style.css +339 -32
- package/es/styles/theme/token/neutral.mjs +5 -5
- package/es/styles/theme/token/neutral.mjs.map +1 -1
- package/es/utils/colorMath.mjs +52 -0
- package/es/utils/colorMath.mjs.map +1 -0
- package/es/utils/formatNumber.mjs +7 -0
- package/es/utils/formatNumber.mjs.map +1 -0
- package/es/utils/genCdnUrl.mjs +6 -3
- package/es/utils/genCdnUrl.mjs.map +1 -1
- package/es/utils/hashString.mjs +19 -0
- package/es/utils/hashString.mjs.map +1 -0
- package/es/utils/mergeRefs.mjs +20 -0
- package/es/utils/mergeRefs.mjs.map +1 -0
- package/es/utils/placement.d.mts +5 -5
- package/es/utils/placement.mjs.map +1 -1
- package/package.json +16 -42
- package/es/dashboard/StatCard/style.mjs +0 -105
- package/es/dashboard/StatCard/style.mjs.map +0 -1
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from "react";
|
|
2
2
|
//#region src/dashboard/Surface/type.d.ts
|
|
3
|
-
export interface
|
|
3
|
+
export interface SurfaceLinkProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
href: string;
|
|
7
|
+
rel?: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Renders a link with the app's router. Defaults to a plain `<a>`. */
|
|
11
|
+
export type SurfaceRenderLink = (props: SurfaceLinkProps) => ReactNode;
|
|
12
|
+
export interface SurfaceProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
13
|
+
/** Drop body padding and widen table cells so a table sits on the card edges. */
|
|
14
|
+
bleed?: boolean;
|
|
15
|
+
/** Full-width slot under the body, for a chart that meets the card edges. */
|
|
16
|
+
chart?: ReactNode;
|
|
4
17
|
children?: ReactNode;
|
|
18
|
+
description?: ReactNode;
|
|
19
|
+
extra?: ReactNode;
|
|
20
|
+
/** Makes the heading a link to the page this card summarises. */
|
|
21
|
+
href?: string;
|
|
22
|
+
/**
|
|
23
|
+
* First load: with no children the body is a placeholder block.
|
|
24
|
+
* A refresh with children keeps them and shows a small spinner in the header.
|
|
25
|
+
*/
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
/** Pad the body. Defaults to on for a card with a header and off for a bare card. */
|
|
28
|
+
padded?: boolean;
|
|
29
|
+
/** Overrides the link renderer from `SurfaceLinkProvider`. */
|
|
30
|
+
renderLink?: SurfaceRenderLink;
|
|
31
|
+
/** Visible heading. */
|
|
32
|
+
title?: ReactNode;
|
|
5
33
|
}
|
|
6
34
|
//#endregion
|
|
7
35
|
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TableIconActionProps, TableIconActionsProps } from "./type.mjs";
|
|
2
|
+
//#region src/dashboard/TableIconActions/TableIconActions.d.ts
|
|
3
|
+
/** Column width for a row of `count` small filled action icons. */
|
|
4
|
+
export declare const tableActionColumnWidth: (count: number) => number;
|
|
5
|
+
/** Right-aligned row of icon actions for a table's last column. */
|
|
6
|
+
declare const TableIconActions: {
|
|
7
|
+
({ children }: TableIconActionsProps): import("react").JSX.Element;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
/** One row action: a small filled icon button whose label is its name and tooltip. */
|
|
11
|
+
export declare const TableIconAction: {
|
|
12
|
+
({ danger, disabled, icon, label, loading, onClick }: TableIconActionProps): import("react").JSX.Element;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { TableIconActions as default };
|
|
17
|
+
//# sourceMappingURL=TableIconActions.d.mts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import FlexBasic_default from "../../Flex/FlexBasic.mjs";
|
|
3
|
+
import ActionIcon from "../../ActionIcon/ActionIcon.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/dashboard/TableIconActions/TableIconActions.tsx
|
|
6
|
+
/** `ActionIcon` `size="small"` is 24px. */
|
|
7
|
+
const ACTION_ICON_SIZE = 24;
|
|
8
|
+
const ACTION_ICON_GAP = 4;
|
|
9
|
+
/** Table cell horizontal padding, so the icons are not clipped by the column. */
|
|
10
|
+
const ACTION_CELL_PADDING = 32;
|
|
11
|
+
/** Column width for a row of `count` small filled action icons. */
|
|
12
|
+
const tableActionColumnWidth = (count) => count * ACTION_ICON_SIZE + Math.max(0, count - 1) * ACTION_ICON_GAP + ACTION_CELL_PADDING;
|
|
13
|
+
/** Right-aligned row of icon actions for a table's last column. */
|
|
14
|
+
const TableIconActions = ({ children }) => /* @__PURE__ */ jsx(FlexBasic_default, {
|
|
15
|
+
horizontal: true,
|
|
16
|
+
align: "center",
|
|
17
|
+
gap: ACTION_ICON_GAP,
|
|
18
|
+
justify: "flex-end",
|
|
19
|
+
width: "100%",
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
TableIconActions.displayName = "TableIconActions";
|
|
23
|
+
/** One row action: a small filled icon button whose label is its name and tooltip. */
|
|
24
|
+
const TableIconAction = ({ danger, disabled, icon, label, loading, onClick }) => /* @__PURE__ */ jsx(ActionIcon, {
|
|
25
|
+
"aria-label": label,
|
|
26
|
+
danger,
|
|
27
|
+
disabled,
|
|
28
|
+
icon,
|
|
29
|
+
loading,
|
|
30
|
+
size: "small",
|
|
31
|
+
title: label,
|
|
32
|
+
variant: "filled",
|
|
33
|
+
onClick
|
|
34
|
+
});
|
|
35
|
+
TableIconAction.displayName = "TableIconAction";
|
|
36
|
+
//#endregion
|
|
37
|
+
export { TableIconAction, TableIconActions as default, tableActionColumnWidth };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=TableIconActions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableIconActions.mjs","names":["Flexbox"],"sources":["../../../src/dashboard/TableIconActions/TableIconActions.tsx"],"sourcesContent":["'use client';\n\nimport ActionIcon from '@/ActionIcon';\nimport { Flexbox } from '@/Flex';\n\nimport type { TableIconActionProps, TableIconActionsProps } from './type';\n\n/** `ActionIcon` `size=\"small\"` is 24px. */\nconst ACTION_ICON_SIZE = 24;\nconst ACTION_ICON_GAP = 4;\n/** Table cell horizontal padding, so the icons are not clipped by the column. */\nconst ACTION_CELL_PADDING = 32;\n\n/** Column width for a row of `count` small filled action icons. */\nexport const tableActionColumnWidth = (count: number) =>\n count * ACTION_ICON_SIZE + Math.max(0, count - 1) * ACTION_ICON_GAP + ACTION_CELL_PADDING;\n\n/** Right-aligned row of icon actions for a table's last column. */\nconst TableIconActions = ({ children }: TableIconActionsProps) => (\n <Flexbox horizontal align={'center'} gap={ACTION_ICON_GAP} justify={'flex-end'} width={'100%'}>\n {children}\n </Flexbox>\n);\n\nTableIconActions.displayName = 'TableIconActions';\n\n/** One row action: a small filled icon button whose label is its name and tooltip. */\nexport const TableIconAction = ({\n danger,\n disabled,\n icon,\n label,\n loading,\n onClick,\n}: TableIconActionProps) => (\n <ActionIcon\n aria-label={label}\n danger={danger}\n disabled={disabled}\n icon={icon}\n loading={loading}\n size={'small'}\n title={label}\n variant={'filled'}\n onClick={onClick}\n />\n);\n\nTableIconAction.displayName = 'TableIconAction';\n\nexport default TableIconActions;\n"],"mappings":";;;;;;AAQA,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;;AAExB,MAAM,sBAAsB;;AAG5B,MAAa,0BAA0B,UACrC,QAAQ,mBAAmB,KAAK,IAAI,GAAG,QAAQ,CAAC,IAAI,kBAAkB;;AAGxE,MAAM,oBAAoB,EAAE,eAC1B,oBAACA,mBAAD;CAAS,YAAA;CAAW,OAAO;CAAU,KAAK;CAAiB,SAAS;CAAY,OAAO;CACpF;AACM,CAAA;AAGX,iBAAiB,cAAc;;AAG/B,MAAa,mBAAmB,EAC9B,QACA,UACA,MACA,OACA,SACA,cAEA,oBAAC,YAAD;CACE,cAAY;CACJ;CACE;CACJ;CACG;CACT,MAAM;CACN,OAAO;CACP,SAAS;CACA;AACV,CAAA;AAGH,gBAAgB,cAAc"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TableIconActionProps, TableIconActionsProps } from "./type.mjs";
|
|
2
|
+
import TableIconActions, { TableIconAction, tableActionColumnWidth } from "./TableIconActions.mjs";
|
|
3
|
+
export { TableIconAction, type TableIconActionProps, type TableIconActionsProps, TableIconActions as default, tableActionColumnWidth };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from "react";
|
|
2
|
+
import { LucideIcon } from "lucide-react";
|
|
3
|
+
//#region src/dashboard/TableIconActions/type.d.ts
|
|
4
|
+
export interface TableIconActionsProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface TableIconActionProps {
|
|
8
|
+
danger?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
icon: LucideIcon;
|
|
11
|
+
/** Accessible name and tooltip. Required: the button has no visible text. */
|
|
12
|
+
label: string;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TitleWithTipsProps } from "./type.mjs";
|
|
2
|
+
//#region src/dashboard/TitleWithTips/TitleWithTips.d.ts
|
|
3
|
+
/** A column or field title with an info icon that explains it on hover. */
|
|
4
|
+
declare const TitleWithTips: {
|
|
5
|
+
({ className, tips, title }: TitleWithTipsProps): import("react").JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { TitleWithTips as default };
|
|
10
|
+
//# sourceMappingURL=TitleWithTips.d.mts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cssVar } from "../../styles/stylex/cssVar.stylex.mjs";
|
|
3
|
+
import Icon from "../../Icon/Icon.mjs";
|
|
4
|
+
import FlexBasic_default from "../../Flex/FlexBasic.mjs";
|
|
5
|
+
import { Tooltip } from "../../Tooltip/Tooltip.mjs";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { InfoIcon } from "lucide-react";
|
|
8
|
+
//#region src/dashboard/TitleWithTips/TitleWithTips.tsx
|
|
9
|
+
/** A column or field title with an info icon that explains it on hover. */
|
|
10
|
+
const TitleWithTips = ({ className, tips, title }) => /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
11
|
+
horizontal: true,
|
|
12
|
+
align: "center",
|
|
13
|
+
className,
|
|
14
|
+
gap: 4,
|
|
15
|
+
children: [/* @__PURE__ */ jsx("span", { children: title }), /* @__PURE__ */ jsx(Tooltip, {
|
|
16
|
+
title: tips,
|
|
17
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
18
|
+
color: cssVar.colorTextTertiary,
|
|
19
|
+
icon: InfoIcon,
|
|
20
|
+
style: { cursor: "help" }
|
|
21
|
+
})
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
TitleWithTips.displayName = "TitleWithTips";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { TitleWithTips as default };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=TitleWithTips.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TitleWithTips.mjs","names":["Flexbox"],"sources":["../../../src/dashboard/TitleWithTips/TitleWithTips.tsx"],"sourcesContent":["'use client';\n\nimport { InfoIcon } from 'lucide-react';\n\nimport { Flexbox } from '@/Flex';\nimport Icon from '@/Icon';\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\nimport Tooltip from '@/Tooltip';\n\nimport type { TitleWithTipsProps } from './type';\n\n/** A column or field title with an info icon that explains it on hover. */\nconst TitleWithTips = ({ className, tips, title }: TitleWithTipsProps) => (\n <Flexbox horizontal align={'center'} className={className} gap={4}>\n <span>{title}</span>\n <Tooltip title={tips}>\n <Icon color={cssVar.colorTextTertiary} icon={InfoIcon} style={{ cursor: 'help' }} />\n </Tooltip>\n </Flexbox>\n);\n\nTitleWithTips.displayName = 'TitleWithTips';\n\nexport default TitleWithTips;\n"],"mappings":";;;;;;;;;AAYA,MAAM,iBAAiB,EAAE,WAAW,MAAM,YACxC,qBAACA,mBAAD;CAAS,YAAA;CAAW,OAAO;CAAqB;CAAW,KAAK;CAAhE,UAAA,CACE,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA,GACnB,oBAAC,SAAD;EAAS,OAAO;EACd,UAAA,oBAAC,MAAD;GAAM,OAAO,OAAO;GAAmB,MAAM;GAAU,OAAO,EAAE,QAAQ,OAAO;EAAI,CAAA;CAC5E,CAAA,CACF;;AAGX,cAAc,cAAc"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/dashboard/TitleWithTips/type.d.ts
|
|
3
|
+
export interface TitleWithTipsProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
/** Tooltip shown on the info icon. */
|
|
6
|
+
tips: ReactNode;
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=type.d.mts.map
|
package/es/dashboard/index.d.mts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { AuthLayoutProps } from "./AuthLayout/type.mjs";
|
|
1
|
+
import { AuthLayoutAsideProps, AuthLayoutBackground, AuthLayoutProps, AuthLayoutVariant } from "./AuthLayout/type.mjs";
|
|
2
|
+
import AuthLayoutAside from "./AuthLayout/Aside.mjs";
|
|
2
3
|
import AuthLayout from "./AuthLayout/AuthLayout.mjs";
|
|
3
4
|
import "./AuthLayout/index.mjs";
|
|
5
|
+
import { AuthLocaleOption, AuthLocaleSwitchProps, AuthThemeMode, AuthThemeSwitchProps } from "./AuthTools/type.mjs";
|
|
6
|
+
import AuthLocaleSwitch from "./AuthTools/AuthLocaleSwitch.mjs";
|
|
7
|
+
import AuthThemeSwitch from "./AuthTools/AuthThemeSwitch.mjs";
|
|
8
|
+
import "./AuthTools/index.mjs";
|
|
4
9
|
import { BreadcrumbItem, BreadcrumbProps } from "./Breadcrumb/type.mjs";
|
|
5
10
|
import Breadcrumb from "./Breadcrumb/Breadcrumb.mjs";
|
|
6
11
|
import "./Breadcrumb/index.mjs";
|
|
7
|
-
import {
|
|
12
|
+
import { ChartGridProps } from "./ChartGrid/type.mjs";
|
|
13
|
+
import ChartGrid from "./ChartGrid/ChartGrid.mjs";
|
|
14
|
+
import "./ChartGrid/index.mjs";
|
|
15
|
+
import { ConsoleNavGroup, ConsoleNavItem, ConsoleNavProps, ConsoleNavSkeletonProps } from "./ConsoleNav/type.mjs";
|
|
8
16
|
import { resolveActiveHref } from "./ConsoleNav/active.mjs";
|
|
9
17
|
import ConsoleNav from "./ConsoleNav/ConsoleNav.mjs";
|
|
18
|
+
import ConsoleNavSkeleton, { ConsoleFooterSkeleton } from "./ConsoleNav/Skeleton.mjs";
|
|
10
19
|
import "./ConsoleNav/index.mjs";
|
|
11
20
|
import { ConsoleBrandProps, ConsoleShellProps, ConsoleShellState } from "./ConsoleShell/type.mjs";
|
|
12
21
|
import ConsoleBrand from "./ConsoleShell/ConsoleBrand.mjs";
|
|
@@ -17,6 +26,16 @@ import { useInFilterSplit } from "./FilterSidebar/context.mjs";
|
|
|
17
26
|
import { FilterOptionProps, FilterRowProps, FilterSidebarProps } from "./FilterSidebar/type.mjs";
|
|
18
27
|
import FilterSidebar, { FilterOption, FilterRow } from "./FilterSidebar/FilterSidebar.mjs";
|
|
19
28
|
import "./FilterSidebar/index.mjs";
|
|
29
|
+
import { FilterStripItem, FilterStripProps } from "./FilterStrip/type.mjs";
|
|
30
|
+
import FilterStrip, { formatInteger } from "./FilterStrip/FilterStrip.mjs";
|
|
31
|
+
import "./FilterStrip/index.mjs";
|
|
32
|
+
import { LabelWithKeyProps } from "./LabelWithKey/type.mjs";
|
|
33
|
+
import LabelWithKey from "./LabelWithKey/LabelWithKey.mjs";
|
|
34
|
+
import "./LabelWithKey/index.mjs";
|
|
35
|
+
import { SurfaceLinkProps, SurfaceProps, SurfaceRenderLink } from "./Surface/type.mjs";
|
|
36
|
+
import { MetricItem, MetricStripProps } from "./MetricStrip/type.mjs";
|
|
37
|
+
import MetricStrip from "./MetricStrip/MetricStrip.mjs";
|
|
38
|
+
import "./MetricStrip/index.mjs";
|
|
20
39
|
import { PageHeaderProps } from "./PageHeader/type.mjs";
|
|
21
40
|
import PageHeader from "./PageHeader/PageHeader.mjs";
|
|
22
41
|
import "./PageHeader/index.mjs";
|
|
@@ -25,13 +44,28 @@ import PageLoading, { LoadingAnnouncer, PageHeaderSkeleton, StatCardSkeleton, Ta
|
|
|
25
44
|
import { PageTab, PageTabsProps } from "./PageTabs/type.mjs";
|
|
26
45
|
import PageTabs from "./PageTabs/PageTabs.mjs";
|
|
27
46
|
import "./PageTabs/index.mjs";
|
|
47
|
+
import { PageToolbarProps } from "./PageToolbar/type.mjs";
|
|
48
|
+
import PageToolbar from "./PageToolbar/PageToolbar.mjs";
|
|
49
|
+
import "./PageToolbar/index.mjs";
|
|
50
|
+
import { PanelSurfaceProps } from "./PanelSurface/type.mjs";
|
|
51
|
+
import PanelSurface from "./PanelSurface/PanelSurface.mjs";
|
|
52
|
+
import "./PanelSurface/index.mjs";
|
|
28
53
|
import { RouteProgressProps } from "./RouteProgress/type.mjs";
|
|
29
54
|
import RouteProgress from "./RouteProgress/RouteProgress.mjs";
|
|
55
|
+
import { SectionProps } from "./Section/type.mjs";
|
|
56
|
+
import Section from "./Section/Section.mjs";
|
|
57
|
+
import "./Section/index.mjs";
|
|
30
58
|
import { StatCardProps, StatDirection } from "./StatCard/type.mjs";
|
|
31
59
|
import StatCard from "./StatCard/StatCard.mjs";
|
|
32
60
|
import "./StatCard/index.mjs";
|
|
61
|
+
import { SurfaceLinkProvider, useSurfaceCardClassName, useSurfaceDepth, useSurfaceLink } from "./Surface/link.mjs";
|
|
33
62
|
import { surfaceStyles } from "./Surface/style.mjs";
|
|
34
|
-
import { SurfaceProps } from "./Surface/type.mjs";
|
|
35
63
|
import Surface from "./Surface/Surface.mjs";
|
|
36
64
|
import "./Surface/index.mjs";
|
|
37
|
-
|
|
65
|
+
import { TableIconActionProps, TableIconActionsProps } from "./TableIconActions/type.mjs";
|
|
66
|
+
import TableIconActions, { TableIconAction, tableActionColumnWidth } from "./TableIconActions/TableIconActions.mjs";
|
|
67
|
+
import "./TableIconActions/index.mjs";
|
|
68
|
+
import { TitleWithTipsProps } from "./TitleWithTips/type.mjs";
|
|
69
|
+
import TitleWithTips from "./TitleWithTips/TitleWithTips.mjs";
|
|
70
|
+
import "./TitleWithTips/index.mjs";
|
|
71
|
+
export { AuthLayout, AuthLayoutAside, type AuthLayoutAsideProps, type AuthLayoutBackground, type AuthLayoutProps, type AuthLayoutVariant, type AuthLocaleOption, AuthLocaleSwitch, type AuthLocaleSwitchProps, type AuthThemeMode, AuthThemeSwitch, type AuthThemeSwitchProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, ChartGrid, type ChartGridProps, ConsoleBrand, type ConsoleBrandProps, ConsoleFooterSkeleton, ConsoleNav, type ConsoleNavGroup, type ConsoleNavItem, type ConsoleNavProps, ConsoleNavSkeleton, type ConsoleNavSkeletonProps, ConsoleShell, type ConsoleShellProps, type ConsoleShellState, FilterOption, type FilterOptionProps, FilterRow, type FilterRowProps, FilterSidebar, type FilterSidebarProps, FilterStrip, type FilterStripItem, type FilterStripProps, LabelWithKey, type LabelWithKeyProps, LoadingAnnouncer, type MetricItem, MetricStrip, type MetricStripProps, PageHeader, type PageHeaderProps, PageHeaderSkeleton, PageLoading, type PageLoadingProps, type PageTab, PageTabs, type PageTabsProps, PageToolbar, type PageToolbarProps, PanelSurface, type PanelSurfaceProps, RouteProgress, type RouteProgressProps, Section, type SectionProps, StatCard, type StatCardProps, StatCardSkeleton, type StatDirection, Surface, type SurfaceLinkProps, SurfaceLinkProvider, type SurfaceProps, type SurfaceRenderLink, TableIconAction, type TableIconActionProps, TableIconActions, type TableIconActionsProps, TableSkeleton, TitleWithTips, type TitleWithTipsProps, formatInteger, resolveActiveHref, surfaceStyles, tableActionColumnWidth, useConsoleShell, useInFilterSplit, useSurfaceCardClassName, useSurfaceDepth, useSurfaceLink };
|
package/es/dashboard/index.mjs
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
|
+
import AuthLayoutAside from "./AuthLayout/Aside.mjs";
|
|
1
2
|
import { surfaceStyles } from "./Surface/style.mjs";
|
|
3
|
+
import { SurfaceLinkProvider, useSurfaceCardClassName, useSurfaceDepth, useSurfaceLink } from "./Surface/link.mjs";
|
|
2
4
|
import AuthLayout from "./AuthLayout/AuthLayout.mjs";
|
|
5
|
+
import AuthLocaleSwitch from "./AuthTools/AuthLocaleSwitch.mjs";
|
|
6
|
+
import AuthThemeSwitch from "./AuthTools/AuthThemeSwitch.mjs";
|
|
3
7
|
import Breadcrumb from "./Breadcrumb/Breadcrumb.mjs";
|
|
8
|
+
import ChartGrid from "./ChartGrid/ChartGrid.mjs";
|
|
4
9
|
import { resolveActiveHref } from "./ConsoleNav/active.mjs";
|
|
5
10
|
import { useConsoleShell } from "./ConsoleShell/context.mjs";
|
|
6
11
|
import ConsoleNav from "./ConsoleNav/ConsoleNav.mjs";
|
|
12
|
+
import ConsoleNavSkeleton, { ConsoleFooterSkeleton } from "./ConsoleNav/Skeleton.mjs";
|
|
7
13
|
import ConsoleBrand from "./ConsoleShell/ConsoleBrand.mjs";
|
|
14
|
+
import PageLoading, { LoadingAnnouncer, PageHeaderSkeleton, StatCardSkeleton, TableSkeleton } from "./PageSkeleton/PageSkeleton.mjs";
|
|
8
15
|
import ConsoleShell from "./ConsoleShell/ConsoleShell.mjs";
|
|
9
16
|
import { useInFilterSplit } from "./FilterSidebar/context.mjs";
|
|
10
17
|
import FilterSidebar, { FilterOption, FilterRow } from "./FilterSidebar/FilterSidebar.mjs";
|
|
18
|
+
import Surface from "./Surface/Surface.mjs";
|
|
19
|
+
import FilterStrip, { formatInteger } from "./FilterStrip/FilterStrip.mjs";
|
|
20
|
+
import LabelWithKey from "./LabelWithKey/LabelWithKey.mjs";
|
|
21
|
+
import MetricStrip from "./MetricStrip/MetricStrip.mjs";
|
|
11
22
|
import PageHeader from "./PageHeader/PageHeader.mjs";
|
|
12
|
-
import PageLoading, { LoadingAnnouncer, PageHeaderSkeleton, StatCardSkeleton, TableSkeleton } from "./PageSkeleton/PageSkeleton.mjs";
|
|
13
23
|
import PageTabs from "./PageTabs/PageTabs.mjs";
|
|
24
|
+
import PageToolbar from "./PageToolbar/PageToolbar.mjs";
|
|
25
|
+
import PanelSurface from "./PanelSurface/PanelSurface.mjs";
|
|
14
26
|
import RouteProgress from "./RouteProgress/RouteProgress.mjs";
|
|
27
|
+
import Section from "./Section/Section.mjs";
|
|
15
28
|
import StatCard from "./StatCard/StatCard.mjs";
|
|
16
|
-
import
|
|
17
|
-
|
|
29
|
+
import TableIconActions, { TableIconAction, tableActionColumnWidth } from "./TableIconActions/TableIconActions.mjs";
|
|
30
|
+
import TitleWithTips from "./TitleWithTips/TitleWithTips.mjs";
|
|
31
|
+
export { AuthLayout, AuthLayoutAside, AuthLocaleSwitch, AuthThemeSwitch, Breadcrumb, ChartGrid, ConsoleBrand, ConsoleFooterSkeleton, ConsoleNav, ConsoleNavSkeleton, ConsoleShell, FilterOption, FilterRow, FilterSidebar, FilterStrip, LabelWithKey, LoadingAnnouncer, MetricStrip, PageHeader, PageHeaderSkeleton, PageLoading, PageTabs, PageToolbar, PanelSurface, RouteProgress, Section, StatCard, StatCardSkeleton, Surface, SurfaceLinkProvider, TableIconAction, TableIconActions, TableSkeleton, TitleWithTips, formatInteger, resolveActiveHref, surfaceStyles, tableActionColumnWidth, useConsoleShell, useInFilterSplit, useSurfaceCardClassName, useSurfaceDepth, useSurfaceLink };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEventCallback } from "./useEventCallback.mjs";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
//#region src/hooks/useControlledState.ts
|
|
4
|
+
const resolveInitial = (initial) => typeof initial === "function" ? initial() : initial;
|
|
5
|
+
const useControlledState = (defaultStateValue, { defaultValue, onChange, value } = {}) => {
|
|
6
|
+
const [innerValue, setInnerValue] = useState(() => {
|
|
7
|
+
if (value !== void 0) return value;
|
|
8
|
+
if (defaultValue !== void 0) return resolveInitial(defaultValue);
|
|
9
|
+
return resolveInitial(defaultStateValue);
|
|
10
|
+
});
|
|
11
|
+
const mergedValue = value === void 0 ? innerValue : value;
|
|
12
|
+
return [mergedValue, useEventCallback((next) => {
|
|
13
|
+
setInnerValue(next);
|
|
14
|
+
if (mergedValue !== next) onChange?.(next, mergedValue);
|
|
15
|
+
})];
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { useControlledState };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=useControlledState.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControlledState.mjs","names":[],"sources":["../../src/hooks/useControlledState.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useEventCallback } from './useEventCallback';\n\ntype Initial<T> = T | (() => T);\n\nexport interface ControlledStateOptions<T> {\n defaultValue?: Initial<T>;\n onChange?: (value: T, prevValue: T) => void;\n value?: T;\n}\n\nconst resolveInitial = <T>(initial: Initial<T>): T =>\n typeof initial === 'function' ? (initial as () => T)() : initial;\n\nexport const useControlledState = <T>(\n defaultStateValue: Initial<T>,\n { defaultValue, onChange, value }: ControlledStateOptions<T> = {},\n): [T, (next: T) => void] => {\n const [innerValue, setInnerValue] = useState<T>(() => {\n if (value !== undefined) return value;\n if (defaultValue !== undefined) return resolveInitial(defaultValue);\n return resolveInitial(defaultStateValue);\n });\n\n const mergedValue = value === undefined ? innerValue : value;\n\n const setValue = useEventCallback((next: T) => {\n setInnerValue(next);\n if (mergedValue !== next) onChange?.(next, mergedValue);\n });\n\n return [mergedValue, setValue];\n};\n"],"mappings":";;;AAYA,MAAM,kBAAqB,YACzB,OAAO,YAAY,aAAc,QAAoB,IAAI;AAE3D,MAAa,sBACX,mBACA,EAAE,cAAc,UAAU,UAAqC,CAAC,MACrC;CAC3B,MAAM,CAAC,YAAY,iBAAiB,eAAkB;EACpD,IAAI,UAAU,KAAA,GAAW,OAAO;EAChC,IAAI,iBAAiB,KAAA,GAAW,OAAO,eAAe,YAAY;EAClE,OAAO,eAAe,iBAAiB;CACzC,CAAC;CAED,MAAM,cAAc,UAAU,KAAA,IAAY,aAAa;CAOvD,OAAO,CAAC,aALS,kBAAkB,SAAY;EAC7C,cAAc,IAAI;EAClB,IAAI,gBAAgB,MAAM,WAAW,MAAM,WAAW;CACxD,CAE4B,CAAC;AAC/B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import lobe_theme_default from "../Highlighter/theme/lobe-theme.mjs";
|
|
3
3
|
import { getCodeLanguageByInput } from "../Highlighter/const.mjs";
|
|
4
|
+
import { hashString } from "../utils/hashString.mjs";
|
|
4
5
|
import { useEffect, useMemo, useState } from "react";
|
|
5
6
|
import { transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight } from "@shikijs/transformers";
|
|
6
|
-
import { Md5 } from "ts-md5";
|
|
7
7
|
//#region src/hooks/useHighlight.ts
|
|
8
8
|
const MD5_LENGTH_THRESHOLD = 1e4;
|
|
9
9
|
const highlightCache = /* @__PURE__ */ new Map();
|
|
@@ -46,7 +46,7 @@ const useHighlight = (text, { language, enableTransformer, theme: builtinTheme,
|
|
|
46
46
|
}, [enableTransformer]);
|
|
47
47
|
const cacheKey = useMemo(() => {
|
|
48
48
|
if (streaming) return null;
|
|
49
|
-
const hash = safeText.length < 1e4 ? safeText :
|
|
49
|
+
const hash = safeText.length < 1e4 ? safeText : `${safeText.length}:${hashString(safeText)}`;
|
|
50
50
|
return [
|
|
51
51
|
matchedLanguage,
|
|
52
52
|
builtinTheme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHighlight.mjs","names":["lobeTheme"],"sources":["../../src/hooks/useHighlight.ts"],"sourcesContent":["'use client';\n\nimport {\n transformerNotationDiff,\n transformerNotationErrorLevel,\n transformerNotationFocus,\n transformerNotationHighlight,\n transformerNotationWordHighlight,\n} from '@shikijs/transformers';\nimport { type CSSProperties, useEffect, useMemo, useState } from 'react';\nimport type { BuiltinTheme, CodeToHastOptions, ThemedToken } from 'shiki';\
|
|
1
|
+
{"version":3,"file":"useHighlight.mjs","names":["lobeTheme"],"sources":["../../src/hooks/useHighlight.ts"],"sourcesContent":["'use client';\n\nimport {\n transformerNotationDiff,\n transformerNotationErrorLevel,\n transformerNotationFocus,\n transformerNotationHighlight,\n transformerNotationWordHighlight,\n} from '@shikijs/transformers';\nimport { type CSSProperties, useEffect, useMemo, useState } from 'react';\nimport type { BuiltinTheme, CodeToHastOptions, ThemedToken } from 'shiki';\n\nimport { getCodeLanguageByInput } from '@/Highlighter/const';\nimport lobeTheme from '@/Highlighter/theme/lobe-theme';\nimport { hashString } from '@/utils/hashString';\n\n// Application-level cache to avoid repeated calculations\nexport const MD5_LENGTH_THRESHOLD = 10_000;\n\nexport type StreamingHighlightResult = {\n lines: ThemedToken[][];\n preStyle?: CSSProperties;\n};\n\n// Application-level cache for highlighted HTML\n// Key: cacheKey string, Value: Promise<string>\nconst highlightCache = new Map<string, Promise<string>>();\n\n// Maximum cache size to prevent memory leaks\nconst MAX_CACHE_SIZE = 1000;\n\n// Clean up old cache entries when limit is reached\nconst cleanupCache = () => {\n if (highlightCache.size > MAX_CACHE_SIZE) {\n // Remove oldest 20% of entries\n const entriesToRemove = Math.floor(MAX_CACHE_SIZE * 0.2);\n const keysToRemove = Array.from(highlightCache.keys()).slice(0, entriesToRemove);\n for (const key of keysToRemove) {\n highlightCache.delete(key);\n }\n }\n};\n\nexport type ICodeToHtml = (code: string, options: CodeToHastOptions) => Promise<string>;\nexport type ShikiModule = typeof import('shiki');\n\n// Use codeToHtml shorthand for better performance\n// It automatically manages highlighter instances and loads themes/languages on-demand\nlet codeToHtmlPromise: Promise<ICodeToHtml | null> | null = null;\n\nconst loadCodeToHtml = (): Promise<ICodeToHtml | null> => {\n if (typeof window === 'undefined') return Promise.resolve(null);\n\n if (!codeToHtmlPromise) {\n codeToHtmlPromise = import('shiki').then((mod) => mod.codeToHtml ?? null);\n }\n\n return codeToHtmlPromise;\n};\n\n// Export shikiModulePromise for useStreamHighlight compatibility\nconst loadShikiModule = (): Promise<ShikiModule | null> => {\n if (typeof window === 'undefined') return Promise.resolve(null);\n return import('shiki');\n};\nexport const shikiModulePromise = loadShikiModule();\n\n// Helper function: Safe HTML escaping\nexport const escapeHtml = (str: string): string => {\n return str\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n};\n\n// Main highlight component - optimized version without SWR\nconst customThemes = {\n 'lobe-theme': lobeTheme,\n};\n\nexport const useHighlight = (\n text: string,\n {\n language,\n enableTransformer,\n theme: builtinTheme,\n streaming,\n }: { enableTransformer?: boolean; language: string; streaming?: boolean; theme?: BuiltinTheme },\n): string => {\n // Safely handle language and text with boundary checks\n const safeText = text ?? '';\n const lang = (language ?? 'plaintext').toLowerCase();\n\n // Match supported languages\n const matchedLanguage = useMemo(() => getCodeLanguageByInput(lang), [lang]);\n\n // Optimize transformer creation\n const transformers = useMemo(() => {\n if (!enableTransformer) return;\n return [\n transformerNotationDiff(),\n transformerNotationHighlight(),\n transformerNotationWordHighlight(),\n transformerNotationFocus(),\n transformerNotationErrorLevel(),\n ];\n }, [enableTransformer]);\n\n // Build cache key\n const cacheKey = useMemo((): string | null => {\n if (streaming) return null;\n // Use hash for long text\n const hash =\n safeText.length < MD5_LENGTH_THRESHOLD\n ? safeText\n : `${safeText.length}:${hashString(safeText)}`;\n return [matchedLanguage, builtinTheme, hash].filter(Boolean).join('-');\n }, [safeText, matchedLanguage, builtinTheme, streaming]);\n\n const [data, setData] = useState<string | undefined>();\n\n useEffect(() => {\n if (!cacheKey) {\n setData(undefined);\n return;\n }\n\n // Check cache first\n const cachedPromise = highlightCache.get(cacheKey);\n if (cachedPromise) {\n cachedPromise\n .then((html) => {\n setData(html);\n })\n .catch(() => {\n // Silently handle errors, fallback will be handled in the promise\n });\n return;\n }\n\n // Create new promise for highlighting\n // Using codeToHtml shorthand: automatically loads themes/languages on-demand\n const highlightPromise = (async (): Promise<string> => {\n try {\n // Try full rendering with transformers\n const shikiModule = await shikiModulePromise;\n if (!shikiModule) return safeText;\n\n const effectiveTheme = builtinTheme || 'lobe-theme';\n\n // Load custom theme if using slack-dark or slack-ochin\n if (!builtinTheme && effectiveTheme === 'lobe-theme') {\n const customTheme = customThemes[effectiveTheme];\n if (customTheme) {\n // Use getSingletonHighlighter to load custom theme\n const highlighter = await shikiModule.getSingletonHighlighter({\n langs: [matchedLanguage],\n themes: [customTheme as any],\n });\n\n const html = await highlighter.codeToHtml(safeText, {\n lang: matchedLanguage,\n theme: effectiveTheme,\n transformers,\n });\n\n return html;\n }\n }\n\n // Fallback to codeToHtml for builtin themes\n const codeToHtml = await loadCodeToHtml();\n if (!codeToHtml) return safeText;\n\n const html = await codeToHtml(safeText, {\n lang: matchedLanguage,\n theme: effectiveTheme,\n transformers,\n });\n\n return html;\n } catch (error_) {\n console.error('Advanced rendering failed:', error_);\n\n try {\n // Try simple rendering (without transformers)\n const codeToHtml = await loadCodeToHtml();\n if (!codeToHtml) return safeText;\n const html = await codeToHtml(safeText, {\n lang: matchedLanguage,\n theme: 'lobe-theme',\n });\n return html;\n } catch {\n // Fallback to plain text\n const fallbackHtml = `<pre class=\"fallback\"><code>${escapeHtml(safeText)}</code></pre>`;\n return fallbackHtml;\n }\n }\n })();\n\n // Cache the promise\n highlightCache.set(cacheKey, highlightPromise);\n cleanupCache();\n\n // Handle promise result\n highlightPromise\n .then((html) => {\n // Only update if this is still the current cache key\n if (highlightCache.get(cacheKey) === highlightPromise) {\n setData(html);\n }\n })\n .catch(() => {\n // Remove failed promise from cache\n if (highlightCache.get(cacheKey) === highlightPromise) {\n highlightCache.delete(cacheKey);\n }\n });\n }, [cacheKey, safeText, matchedLanguage, builtinTheme, transformers, customThemes]);\n\n return data || '';\n};\n"],"mappings":";;;;;;;AAiBA,MAAa,uBAAuB;AASpC,MAAM,iCAAiB,IAAI,IAA6B;AAGxD,MAAM,iBAAiB;AAGvB,MAAM,qBAAqB;CACzB,IAAI,eAAe,OAAO,gBAAgB;EAExC,MAAM,kBAAkB,KAAK,MAAM,iBAAiB,EAAG;EACvD,MAAM,eAAe,MAAM,KAAK,eAAe,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,eAAe;EAC/E,KAAK,MAAM,OAAO,cAChB,eAAe,OAAO,GAAG;CAE7B;AACF;AAOA,IAAI,oBAAwD;AAE5D,MAAM,uBAAoD;CACxD,IAAI,OAAO,WAAW,aAAa,OAAO,QAAQ,QAAQ,IAAI;CAE9D,IAAI,CAAC,mBACH,oBAAoB,OAAO,QAAQ,CAAC,MAAM,QAAQ,IAAI,cAAc,IAAI;CAG1E,OAAO;AACT;AAGA,MAAM,wBAAqD;CACzD,IAAI,OAAO,WAAW,aAAa,OAAO,QAAQ,QAAQ,IAAI;CAC9D,OAAO,OAAO;AAChB;AACA,MAAa,qBAAqB,gBAAgB;AAGlD,MAAa,cAAc,QAAwB;CACjD,OAAO,IACJ,WAAW,KAAK,OAAO,CAAC,CACxB,WAAW,KAAK,MAAM,CAAC,CACvB,WAAW,KAAK,MAAM,CAAC,CACvB,WAAW,MAAK,QAAQ,CAAC,CACzB,WAAW,KAAK,QAAQ;AAC7B;AAGA,MAAM,eAAe,EACnB,cAAcA,mBAChB;AAEA,MAAa,gBACX,MACA,EACE,UACA,mBACA,OAAO,cACP,gBAES;CAEX,MAAM,WAAW,QAAQ;CACzB,MAAM,QAAQ,YAAY,YAAA,CAAa,YAAY;CAGnD,MAAM,kBAAkB,cAAc,uBAAuB,IAAI,GAAG,CAAC,IAAI,CAAC;CAG1E,MAAM,eAAe,cAAc;EACjC,IAAI,CAAC,mBAAmB;EACxB,OAAO;GACL,wBAAwB;GACxB,6BAA6B;GAC7B,iCAAiC;GACjC,yBAAyB;GACzB,8BAA8B;EAChC;CACF,GAAG,CAAC,iBAAiB,CAAC;CAGtB,MAAM,WAAW,cAA6B;EAC5C,IAAI,WAAW,OAAO;EAEtB,MAAM,OACJ,SAAS,SAAA,MACL,WACA,GAAG,SAAS,OAAO,GAAG,WAAW,QAAQ;EAC/C,OAAO;GAAC;GAAiB;GAAc;EAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CACvE,GAAG;EAAC;EAAU;EAAiB;EAAc;CAAS,CAAC;CAEvD,MAAM,CAAC,MAAM,WAAW,SAA6B;CAErD,gBAAgB;EACd,IAAI,CAAC,UAAU;GACb,QAAQ,KAAA,CAAS;GACjB;EACF;EAGA,MAAM,gBAAgB,eAAe,IAAI,QAAQ;EACjD,IAAI,eAAe;GACjB,cACG,MAAM,SAAS;IACd,QAAQ,IAAI;GACd,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;GACH;EACF;EAIA,MAAM,oBAAoB,YAA6B;GACrD,IAAI;IAEF,MAAM,cAAc,MAAM;IAC1B,IAAI,CAAC,aAAa,OAAO;IAEzB,MAAM,iBAAiB,gBAAgB;IAGvC,IAAI,CAAC,gBAAgB,mBAAmB,cAAc;KACpD,MAAM,cAAc,aAAa;KACjC,IAAI,aAaF,OAAO,OANY,MALO,YAAY,wBAAwB;MAC5D,OAAO,CAAC,eAAe;MACvB,QAAQ,CAAC,WAAkB;KAC7B,CAAC,EAAA,CAE8B,WAAW,UAAU;MAClD,MAAM;MACN,OAAO;MACP;KACF,CAAC;IAIL;IAGA,MAAM,aAAa,MAAM,eAAe;IACxC,IAAI,CAAC,YAAY,OAAO;IAQxB,OAAO,MANY,WAAW,UAAU;KACtC,MAAM;KACN,OAAO;KACP;IACF,CAAC;GAGH,SAAS,QAAQ;IACf,QAAQ,MAAM,8BAA8B,MAAM;IAElD,IAAI;KAEF,MAAM,aAAa,MAAM,eAAe;KACxC,IAAI,CAAC,YAAY,OAAO;KAKxB,OAAO,MAJY,WAAW,UAAU;MACtC,MAAM;MACN,OAAO;KACT,CAAC;IAEH,QAAQ;KAGN,OAAO,+BAD6C,WAAW,QAAQ,EAAE;IAE3E;GACF;EACF,EAAA,CAAG;EAGH,eAAe,IAAI,UAAU,gBAAgB;EAC7C,aAAa;EAGb,iBACG,MAAM,SAAS;GAEd,IAAI,eAAe,IAAI,QAAQ,MAAM,kBACnC,QAAQ,IAAI;EAEhB,CAAC,CAAC,CACD,YAAY;GAEX,IAAI,eAAe,IAAI,QAAQ,MAAM,kBACnC,eAAe,OAAO,QAAQ;EAElC,CAAC;CACL,GAAG;EAAC;EAAU;EAAU;EAAiB;EAAc;EAAc;CAAY,CAAC;CAElF,OAAO,QAAQ;AACjB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
//#region src/hooks/useHover.ts
|
|
3
|
+
const useHover = (ref) => {
|
|
4
|
+
const [hovering, setHovering] = useState(false);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const element = ref.current;
|
|
7
|
+
if (!element) return;
|
|
8
|
+
const enter = () => setHovering(true);
|
|
9
|
+
const leave = () => setHovering(false);
|
|
10
|
+
element.addEventListener("mouseenter", enter);
|
|
11
|
+
element.addEventListener("mouseleave", leave);
|
|
12
|
+
return () => {
|
|
13
|
+
element.removeEventListener("mouseenter", enter);
|
|
14
|
+
element.removeEventListener("mouseleave", leave);
|
|
15
|
+
};
|
|
16
|
+
}, [ref]);
|
|
17
|
+
return hovering;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { useHover };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=useHover.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHover.mjs","names":[],"sources":["../../src/hooks/useHover.ts"],"sourcesContent":["import { type RefObject, useEffect, useState } from 'react';\n\nexport const useHover = (ref: RefObject<Element | null>): boolean => {\n const [hovering, setHovering] = useState(false);\n\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n const enter = () => setHovering(true);\n const leave = () => setHovering(false);\n element.addEventListener('mouseenter', enter);\n element.addEventListener('mouseleave', leave);\n return () => {\n element.removeEventListener('mouseenter', enter);\n element.removeEventListener('mouseleave', leave);\n };\n }, [ref]);\n\n return hovering;\n};\n"],"mappings":";;AAEA,MAAa,YAAY,QAA4C;CACnE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAE9C,gBAAgB;EACd,MAAM,UAAU,IAAI;EACpB,IAAI,CAAC,SAAS;EACd,MAAM,cAAc,YAAY,IAAI;EACpC,MAAM,cAAc,YAAY,KAAK;EACrC,QAAQ,iBAAiB,cAAc,KAAK;EAC5C,QAAQ,iBAAiB,cAAc,KAAK;EAC5C,aAAa;GACX,QAAQ,oBAAoB,cAAc,KAAK;GAC/C,QAAQ,oBAAoB,cAAc,KAAK;EACjD;CACF,GAAG,CAAC,GAAG,CAAC;CAER,OAAO;AACT"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/hooks/useScroll.d.ts
|
|
2
|
+
type ScrollTargetValue = Element | Document | null | undefined;
|
|
3
|
+
export type ScrollTarget = ScrollTargetValue | (() => ScrollTargetValue) | {
|
|
4
|
+
current: ScrollTargetValue;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=useScroll.d.mts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
//#region src/hooks/useScroll.ts
|
|
3
|
+
const resolveTarget = (target) => {
|
|
4
|
+
if (typeof target === "function") return target();
|
|
5
|
+
if (target && "current" in target) return target.current;
|
|
6
|
+
return target;
|
|
7
|
+
};
|
|
8
|
+
const readPosition = (element) => {
|
|
9
|
+
const scroller = element instanceof Document ? element.scrollingElement ?? element.documentElement : element;
|
|
10
|
+
return {
|
|
11
|
+
left: scroller.scrollLeft,
|
|
12
|
+
top: scroller.scrollTop
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const useScroll = (target) => {
|
|
16
|
+
const [position, setPosition] = useState();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const element = resolveTarget(target);
|
|
19
|
+
if (!element) return;
|
|
20
|
+
const update = () => {
|
|
21
|
+
const next = readPosition(element);
|
|
22
|
+
setPosition((prev) => prev && prev.left === next.left && prev.top === next.top ? prev : next);
|
|
23
|
+
};
|
|
24
|
+
update();
|
|
25
|
+
element.addEventListener("scroll", update, { passive: true });
|
|
26
|
+
return () => element.removeEventListener("scroll", update);
|
|
27
|
+
}, [target]);
|
|
28
|
+
return position;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { useScroll };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=useScroll.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScroll.mjs","names":[],"sources":["../../src/hooks/useScroll.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\ntype ScrollTargetValue = Element | Document | null | undefined;\n\nexport type ScrollTarget =\n ScrollTargetValue | (() => ScrollTargetValue) | { current: ScrollTargetValue };\n\nexport interface ScrollPosition {\n left: number;\n top: number;\n}\n\nconst resolveTarget = (target: ScrollTarget): ScrollTargetValue => {\n if (typeof target === 'function') return target();\n if (target && 'current' in target) return target.current;\n return target;\n};\n\nconst readPosition = (element: Element | Document): ScrollPosition => {\n const scroller =\n element instanceof Document ? (element.scrollingElement ?? element.documentElement) : element;\n return { left: scroller.scrollLeft, top: scroller.scrollTop };\n};\n\nexport const useScroll = (target: ScrollTarget): ScrollPosition | undefined => {\n const [position, setPosition] = useState<ScrollPosition>();\n\n useEffect(() => {\n const element = resolveTarget(target);\n if (!element) return;\n const update = () => {\n const next = readPosition(element);\n setPosition((prev) =>\n prev && prev.left === next.left && prev.top === next.top ? prev : next,\n );\n };\n update();\n element.addEventListener('scroll', update, { passive: true });\n return () => element.removeEventListener('scroll', update);\n }, [target]);\n\n return position;\n};\n"],"mappings":";;AAYA,MAAM,iBAAiB,WAA4C;CACjE,IAAI,OAAO,WAAW,YAAY,OAAO,OAAO;CAChD,IAAI,UAAU,aAAa,QAAQ,OAAO,OAAO;CACjD,OAAO;AACT;AAEA,MAAM,gBAAgB,YAAgD;CACpE,MAAM,WACJ,mBAAmB,WAAY,QAAQ,oBAAoB,QAAQ,kBAAmB;CACxF,OAAO;EAAE,MAAM,SAAS;EAAY,KAAK,SAAS;CAAU;AAC9D;AAEA,MAAa,aAAa,WAAqD;CAC7E,MAAM,CAAC,UAAU,eAAe,SAAyB;CAEzD,gBAAgB;EACd,MAAM,UAAU,cAAc,MAAM;EACpC,IAAI,CAAC,SAAS;EACd,MAAM,eAAe;GACnB,MAAM,OAAO,aAAa,OAAO;GACjC,aAAa,SACX,QAAQ,KAAK,SAAS,KAAK,QAAQ,KAAK,QAAQ,KAAK,MAAM,OAAO,IACpE;EACF;EACA,OAAO;EACP,QAAQ,iBAAiB,UAAU,QAAQ,EAAE,SAAS,KAAK,CAAC;EAC5D,aAAa,QAAQ,oBAAoB,UAAU,MAAM;CAC3D,GAAG,CAAC,MAAM,CAAC;CAEX,OAAO;AACT"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from "react";
|
|
2
|
+
//#region src/hooks/useSize.ts
|
|
3
|
+
const useSize = (ref) => {
|
|
4
|
+
const [size, setSize] = useState();
|
|
5
|
+
useLayoutEffect(() => {
|
|
6
|
+
const element = ref.current;
|
|
7
|
+
if (!element) return;
|
|
8
|
+
setSize({
|
|
9
|
+
height: element.clientHeight,
|
|
10
|
+
width: element.clientWidth
|
|
11
|
+
});
|
|
12
|
+
const observer = new ResizeObserver((entries) => {
|
|
13
|
+
for (const { target } of entries) setSize({
|
|
14
|
+
height: target.clientHeight,
|
|
15
|
+
width: target.clientWidth
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
observer.observe(element);
|
|
19
|
+
return () => observer.disconnect();
|
|
20
|
+
}, [ref]);
|
|
21
|
+
return size;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { useSize };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=useSize.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSize.mjs","names":[],"sources":["../../src/hooks/useSize.ts"],"sourcesContent":["import { type RefObject, useLayoutEffect, useState } from 'react';\n\nexport interface ElementSize {\n height: number;\n width: number;\n}\n\nexport const useSize = (ref: RefObject<Element | null>): ElementSize | undefined => {\n const [size, setSize] = useState<ElementSize>();\n\n useLayoutEffect(() => {\n const element = ref.current;\n if (!element) return;\n setSize({ height: element.clientHeight, width: element.clientWidth });\n\n const observer = new ResizeObserver((entries) => {\n for (const { target } of entries) {\n setSize({ height: target.clientHeight, width: target.clientWidth });\n }\n });\n observer.observe(element);\n return () => observer.disconnect();\n }, [ref]);\n\n return size;\n};\n"],"mappings":";;AAOA,MAAa,WAAW,QAA4D;CAClF,MAAM,CAAC,MAAM,WAAW,SAAsB;CAE9C,sBAAsB;EACpB,MAAM,UAAU,IAAI;EACpB,IAAI,CAAC,SAAS;EACd,QAAQ;GAAE,QAAQ,QAAQ;GAAc,OAAO,QAAQ;EAAY,CAAC;EAEpE,MAAM,WAAW,IAAI,gBAAgB,YAAY;GAC/C,KAAK,MAAM,EAAE,YAAY,SACvB,QAAQ;IAAE,QAAQ,OAAO;IAAc,OAAO,OAAO;GAAY,CAAC;EAEtE,CAAC;EACD,SAAS,QAAQ,OAAO;EACxB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,GAAG,CAAC;CAER,OAAO;AACT"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { styleProps } from "../../styles/stylex/props.mjs";
|
|
3
|
+
import { useMergeRefs } from "../../utils/mergeRefs.mjs";
|
|
3
4
|
import { ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewportImpl } from "../../ScrollArea/atoms.mjs";
|
|
4
5
|
import { Children, cloneElement, useCallback, useEffect, useRef } from "react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { useMergeRefs } from "react-merge-refs";
|
|
7
7
|
import { Virtualizer } from "virtua";
|
|
8
8
|
//#region src/internal/virtual/VirtualScrollArea.tsx
|
|
9
9
|
const styles = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualScrollArea.mjs","names":[],"sources":["../../../src/internal/virtual/VirtualScrollArea.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport {\n Children,\n cloneElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useEffect,\n useRef,\n} from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"VirtualScrollArea.mjs","names":[],"sources":["../../../src/internal/virtual/VirtualScrollArea.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport {\n Children,\n cloneElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useEffect,\n useRef,\n} from 'react';\nimport { Virtualizer, type VirtualizerHandle } from 'virtua';\n\nimport {\n ScrollAreaRoot,\n type ScrollAreaRootProps,\n ScrollAreaScrollbar,\n ScrollAreaThumb,\n ScrollAreaViewportImpl,\n type ScrollAreaViewportProps,\n} from '@/ScrollArea/atoms';\nimport { styleProps } from '@/styles/stylex/props';\nimport { useMergeRefs } from '@/utils/mergeRefs';\n\n// `--lobe-virtual-scroll-inset` is the inline padding of the box the scroll area sits in: the\n// root bleeds out by it so the scrollbar hugs that box's edge, and the viewport pads the rows back.\nconst styles = stylex.create({\n root: {\n marginInline: 'calc(-1 * var(--lobe-virtual-scroll-inset, 0px))',\n display: 'flex',\n flexBasis: '0%',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n minHeight: 0,\n },\n viewport: {\n paddingInline: 'var(--lobe-virtual-scroll-inset, 0)',\n flexBasis: '0%',\n flexGrow: 1,\n flexShrink: 1,\n height: 'auto',\n minHeight: 0,\n },\n});\n\n// Rows mounted on the very first render, before the viewport is measured, so Base UI's\n// list navigation sees the leading rows (not a pinned footer item) when it focuses on open.\nconst INITIAL_ROW_COUNT = 20;\n\nexport interface VirtualScrollAreaProps extends Omit<ScrollAreaRootProps, 'children'> {\n children: ReactNode;\n itemSize?: number;\n keepMounted?: readonly number[];\n /**\n * Element that owns the scrolling box (e.g. a Base UI `Select.List`); it is rendered\n * through the ScrollArea viewport so its own props and role win.\n */\n viewport?: ReactElement<{ children?: ReactNode; render?: ReactElement }>;\n viewportProps?: ScrollAreaViewportProps;\n virtualizerRef?: Ref<VirtualizerHandle>;\n}\n\nexport const VirtualScrollArea = ({\n children,\n className,\n itemSize,\n keepMounted,\n viewport,\n viewportProps,\n virtualizerRef,\n ...rest\n}: VirtualScrollAreaProps) => {\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const mergedViewportRef = useMergeRefs([viewportRef, viewportProps?.ref]);\n\n const list = (\n <Virtualizer\n itemSize={itemSize}\n keepMounted={keepMounted}\n ref={virtualizerRef}\n scrollRef={viewportRef}\n ssrCount={Math.min(INITIAL_ROW_COUNT, Children.count(children))}\n >\n {children}\n </Virtualizer>\n );\n const viewportElement = (\n <ScrollAreaViewportImpl\n tabIndex={-1}\n {...viewportProps}\n ref={mergedViewportRef}\n xstyle={styles.viewport}\n />\n );\n\n return (\n <ScrollAreaRoot\n data-virtual=\"\"\n {...rest}\n className={styleProps(styles.root, className as string).className}\n >\n {cloneElement(viewport ?? viewportElement, {\n children: list,\n ...(viewport && { render: viewportElement }),\n })}\n <ScrollAreaScrollbar>\n <ScrollAreaThumb />\n </ScrollAreaScrollbar>\n </ScrollAreaRoot>\n );\n};\n\nVirtualScrollArea.displayName = 'VirtualScrollArea';\n\n// Base UI scrolls the highlighted item into view after focusing it; while the pointer drives\n// the scroll that would yank the list back, so callers consult `pointerScrollRef` first.\nexport function usePointerScrollGuard() {\n const pointerScrollRef = useRef(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const markPointerScroll = useCallback(() => {\n pointerScrollRef.current = true;\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(() => {\n pointerScrollRef.current = false;\n }, 120);\n }, []);\n\n useEffect(() => {\n return () => {\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n };\n }, []);\n\n return {\n markPointerScroll,\n pointerScrollRef,\n scrollGuardProps: {\n onPointerDown: markPointerScroll,\n onTouchMove: markPointerScroll,\n onWheel: markPointerScroll,\n },\n };\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,SAAS;CACb,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF;AAIA,MAAM,oBAAoB;AAgB1B,MAAa,qBAAqB,EAChC,UACA,WACA,UACA,aACA,UACA,eACA,gBACA,GAAG,WACyB;CAC5B,MAAM,cAAc,OAA8B,IAAI;CACtD,MAAM,oBAAoB,aAAa,CAAC,aAAa,eAAe,GAAG,CAAC;CACxE,MAAM,OAAO,oBAAC,aAAD;EAAuB;EAAuB;EAAa,KAAK;EAAgB,WAAW;EAAa,UAAU,KAAK,IAAI,mBAAmB,SAAS,MAAM,QAAQ,CAAC;EAC9K;CACU,CAAA;CACf,MAAM,kBAAkB,oBAAC,wBAAD;EAAwB,UAAU;EAAI,GAAI;EAAe,KAAK;EAAmB,QAAQ,OAAO;CAAW,CAAA;CACnI,OAAO,qBAAC,gBAAD;EAAgB,gBAAa;EAAG,GAAI;EAAM,WAAW,WAAW,OAAO,MAAM,SAAmB,CAAC,CAAC;EAAlG,UAAA,CACF,aAAa,YAAY,iBAAiB;GAC3C,UAAU;GACV,GAAI,YAAY,EACd,QAAQ,gBACV;EACF,CAAC,GACC,oBAAC,qBAAD,EAAA,UACE,oBAAC,iBAAD,CAAkB,CAAA,EACC,CAAA,CACP;;AACpB;AACA,kBAAkB,cAAc;AAIhC,SAAgB,wBAAwB;CACtC,MAAM,mBAAmB,OAAO,KAAK;CACrC,MAAM,aAAa,OAA6C,IAAI;CACpE,MAAM,oBAAoB,kBAAkB;EAC1C,iBAAiB,UAAU;EAC3B,IAAI,WAAW,SAAS,aAAa,WAAW,OAAO;EACvD,WAAW,UAAU,iBAAiB;GACpC,iBAAiB,UAAU;EAC7B,GAAG,GAAG;CACR,GAAG,CAAC,CAAC;CACL,gBAAgB;EACd,aAAa;GACX,IAAI,WAAW,SAAS,aAAa,WAAW,OAAO;EACzD;CACF,GAAG,CAAC,CAAC;CACL,OAAO;EACL;EACA;EACA,kBAAkB;GAChB,eAAe;GACf,aAAa;GACb,SAAS;EACX;CACF;AACF"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { styleProps } from "../../styles/stylex/props.mjs";
|
|
3
3
|
import FlexBasic_default from "../../Flex/FlexBasic.mjs";
|
|
4
4
|
import ActionIcon from "../../ActionIcon/ActionIcon.mjs";
|
|
5
|
+
import { useSize } from "../../hooks/useSize.mjs";
|
|
5
6
|
import ChatInputAreaInner from "../../chat/ChatInputArea/components/ChatInputAreaInner.mjs";
|
|
6
7
|
import SafeArea from "../SafeArea/SafeArea.mjs";
|
|
7
8
|
import { styles } from "./style.mjs";
|
|
8
9
|
import { memo, useCallback, useEffect, useRef, useState } from "react";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
11
|
-
import { useSize } from "ahooks";
|
|
12
12
|
//#region src/mobile/ChatInputArea/ChatInputArea.tsx
|
|
13
13
|
const ChatInputArea = memo(({ ref, className, style, topAddons, textAreaLeftAddons, textAreaRightAddons, bottomAddons, expand = false, setExpand, onSend, onInput, loading, value, safeArea }) => {
|
|
14
14
|
const containerRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatInputArea.mjs","names":["Flexbox"],"sources":["../../../src/mobile/ChatInputArea/ChatInputArea.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"ChatInputArea.mjs","names":["Flexbox"],"sources":["../../../src/mobile/ChatInputArea/ChatInputArea.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronDown, ChevronUp } from 'lucide-react';\nimport {\n type FC,\n memo,\n type PropsWithChildren,\n type ReactNode,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport ActionIcon from '@/ActionIcon';\nimport ChatInputAreaInner from '@/chat/ChatInputArea/components/ChatInputAreaInner';\nimport { Flexbox } from '@/Flex';\nimport { useSize } from '@/hooks/useSize';\nimport SafeArea from '@/mobile/SafeArea';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { styles } from './style';\nimport { type ChatInputAreaProps } from './type';\n\nconst ChatInputArea = memo<ChatInputAreaProps>(\n ({\n ref,\n className,\n style,\n topAddons,\n textAreaLeftAddons,\n textAreaRightAddons,\n bottomAddons,\n expand = false,\n setExpand,\n onSend,\n onInput,\n loading,\n value,\n safeArea,\n }) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const size = useSize(containerRef);\n const [showFullscreen, setShowFullscreen] = useState<boolean>(false);\n const [isFocused, setIsFocused] = useState<boolean>(false);\n\n useEffect(() => {\n if (!size?.height) return;\n setShowFullscreen(size.height > 72);\n }, [size]);\n\n const InnerContainer: FC<\n PropsWithChildren & {\n bottomAddons?: ReactNode;\n textAreaLeftAddons?: ReactNode;\n textAreaRightAddons?: ReactNode;\n topAddons?: ReactNode;\n }\n > = useCallback(\n ({ children, ...r }) =>\n expand ? (\n <Flexbox gap={8} height={'inherit'} paddingInline={8}>\n <Flexbox horizontal gap={8} justify={'flex-end'}>\n {r.textAreaLeftAddons}\n {r.textAreaRightAddons}\n </Flexbox>\n {children}\n {r.topAddons}\n {r.bottomAddons}\n </Flexbox>\n ) : (\n <Flexbox horizontal align={'flex-end'} gap={8} height={'inherit'} paddingInline={8}>\n {r.textAreaLeftAddons}\n {children}\n {r.textAreaRightAddons}\n </Flexbox>\n ),\n [expand, loading],\n );\n\n const showAddons = !expand && !isFocused;\n\n return (\n <Flexbox\n flex={'none'}\n gap={12}\n height={expand ? '100%' : undefined}\n paddingBlock={12}\n width={expand ? '100%' : undefined}\n {...styleProps([styles.container, expand && styles.expand], className, style)}\n >\n {topAddons && <Flexbox style={showAddons ? {} : { display: 'none' }}>{topAddons}</Flexbox>}\n <Flexbox\n height={expand ? '100%' : undefined}\n ref={containerRef}\n style={{ position: 'relative' }}\n width={expand ? '100%' : undefined}\n >\n {showFullscreen && (\n <ActionIcon\n active\n icon={expand ? ChevronDown : ChevronUp}\n id={'sssssss'}\n size={{ blockSize: 24, borderRadius: '50%', size: 14 }}\n style={{ insetInlineEnd: 14, position: 'absolute', ...(expand ? { top: 6 } : {}) }}\n onClick={() => setExpand?.(!expand)}\n />\n )}\n <InnerContainer\n bottomAddons={bottomAddons}\n textAreaLeftAddons={textAreaLeftAddons}\n textAreaRightAddons={textAreaRightAddons}\n topAddons={topAddons}\n >\n <ChatInputAreaInner\n autoSize={expand ? false : { maxRows: 6, minRows: 1 }}\n loading={loading}\n ref={ref}\n style={{ flex: 1, minHeight: 36, paddingBlock: 6 }}\n value={value}\n variant={expand ? 'borderless' : 'filled'}\n onBlur={() => setIsFocused(false)}\n onFocus={() => setIsFocused(true)}\n onInput={onInput}\n onSend={onSend}\n />\n </InnerContainer>\n </Flexbox>\n {bottomAddons && (\n <Flexbox style={showAddons ? {} : { display: 'none' }}>{bottomAddons}</Flexbox>\n )}\n {safeArea && !isFocused && <SafeArea position={'bottom'} />}\n </Flexbox>\n );\n },\n);\n\nChatInputArea.displayName = 'ChatInputArea';\n\nexport default ChatInputArea;\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,gBAAgB,MACnB,EACC,KACA,WACA,OACA,WACA,oBACA,qBACA,cACA,SAAS,OACT,WACA,QACA,SACA,SACA,OACA,eACI;CACJ,MAAM,eAAe,OAAuB,IAAI;CAChD,MAAM,OAAO,QAAQ,YAAY;CACjC,MAAM,CAAC,gBAAgB,qBAAqB,SAAkB,KAAK;CACnE,MAAM,CAAC,WAAW,gBAAgB,SAAkB,KAAK;CAEzD,gBAAgB;EACd,IAAI,CAAC,MAAM,QAAQ;EACnB,kBAAkB,KAAK,SAAS,EAAE;CACpC,GAAG,CAAC,IAAI,CAAC;CAET,MAAM,iBAOF,aACD,EAAE,UAAU,GAAG,QACd,SACE,qBAACA,mBAAD;EAAS,KAAK;EAAG,QAAQ;EAAW,eAAe;EAAnD,UAAA;GACE,qBAACA,mBAAD;IAAS,YAAA;IAAW,KAAK;IAAG,SAAS;IAArC,UAAA,CACG,EAAE,oBACF,EAAE,mBACI;;GACR;GACA,EAAE;GACF,EAAE;EACI;CAET,CAAA,IAAA,qBAACA,mBAAD;EAAS,YAAA;EAAW,OAAO;EAAY,KAAK;EAAG,QAAQ;EAAW,eAAe;EAAjF,UAAA;GACG,EAAE;GACF;GACA,EAAE;EACI;CAEb,CAAA,GAAA,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,aAAa,CAAC,UAAU,CAAC;CAE/B,OACE,qBAACA,mBAAD;EACE,MAAM;EACN,KAAK;EACL,QAAQ,SAAS,SAAS,KAAA;EAC1B,cAAc;EACd,OAAO,SAAS,SAAS,KAAA;EACzB,GAAI,WAAW,CAAC,OAAO,WAAW,UAAU,OAAO,MAAM,GAAG,WAAW,KAAK;EAN9E,UAAA;GAQG,aAAa,oBAACA,mBAAD;IAAS,OAAO,aAAa,CAAC,IAAI,EAAE,SAAS,OAAO;IAAI,UAAA;GAAmB,CAAA;GACzF,qBAACA,mBAAD;IACE,QAAQ,SAAS,SAAS,KAAA;IAC1B,KAAK;IACL,OAAO,EAAE,UAAU,WAAW;IAC9B,OAAO,SAAS,SAAS,KAAA;IAJ3B,UAAA,CAMG,kBACC,oBAAC,YAAD;KACE,QAAA;KACA,MAAM,SAAS,cAAc;KAC7B,IAAI;KACJ,MAAM;MAAE,WAAW;MAAI,cAAc;MAAO,MAAM;KAAG;KACrD,OAAO;MAAE,gBAAgB;MAAI,UAAU;MAAY,GAAI,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC;KAAG;KACjF,eAAe,YAAY,CAAC,MAAM;IACnC,CAAA,GAEH,oBAAC,gBAAD;KACgB;KACM;KACC;KACV;KAEX,UAAA,oBAAC,oBAAD;MACE,UAAU,SAAS,QAAQ;OAAE,SAAS;OAAG,SAAS;MAAE;MAC3C;MACJ;MACL,OAAO;OAAE,MAAM;OAAG,WAAW;OAAI,cAAc;MAAE;MAC1C;MACP,SAAS,SAAS,eAAe;MACjC,cAAc,aAAa,KAAK;MAChC,eAAe,aAAa,IAAI;MACvB;MACD;KACT,CAAA;IACa,CAAA,CACT;;GACR,gBACC,oBAACA,mBAAD;IAAS,OAAO,aAAa,CAAC,IAAI,EAAE,SAAS,OAAO;IAAI,UAAA;GAAsB,CAAA;GAE/E,YAAY,CAAC,aAAa,oBAAC,UAAD,EAAU,UAAU,SAAW,CAAA;EACnD;;AAEb,CACF;AAEA,cAAc,cAAc"}
|