@mks2508/mks-ui 0.9.0 → 0.10.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/dist/react-ui/index.js +4 -2
- package/dist/react-ui/ui/MiddleTruncate/MiddleTruncate.styles.d.ts +30 -0
- package/dist/react-ui/ui/MiddleTruncate/MiddleTruncate.styles.d.ts.map +1 -0
- package/dist/react-ui/ui/MiddleTruncate/MiddleTruncate.styles.js +31 -0
- package/dist/react-ui/ui/MiddleTruncate/MiddleTruncate.types.d.ts +66 -0
- package/dist/react-ui/ui/MiddleTruncate/MiddleTruncate.types.d.ts.map +1 -0
- package/dist/react-ui/ui/MiddleTruncate/index.d.ts +79 -0
- package/dist/react-ui/ui/MiddleTruncate/index.d.ts.map +1 -0
- package/dist/react-ui/ui/MiddleTruncate/index.js +164 -0
- package/dist/react-ui/ui/MiddleTruncatePath/MiddleTruncatePath.styles.js +1 -1
- package/dist/react-ui/ui/MiddleTruncatePath/index.d.ts +7 -1
- package/dist/react-ui/ui/MiddleTruncatePath/index.d.ts.map +1 -1
- package/dist/react-ui/ui/MiddleTruncatePath/index.js +21 -17
- package/dist/react-ui/ui/index.d.ts +1 -0
- package/dist/react-ui/ui/index.d.ts.map +1 -1
- package/dist/react-ui/ui/index.js +3 -1
- package/package.json +1 -1
package/dist/react-ui/index.js
CHANGED
|
@@ -75,7 +75,9 @@ import { fieldVariants } from "./ui/Field/Field.styles.js";
|
|
|
75
75
|
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle } from "./ui/Field/index.js";
|
|
76
76
|
import { FileIconStyles, FolderIconStyles, fileIconVariants, folderIconVariants } from "./ui/FileIcon/FileIcon.styles.js";
|
|
77
77
|
import { FileIcon, FolderIcon } from "./ui/FileIcon/index.js";
|
|
78
|
-
import {
|
|
78
|
+
import { MiddleTruncateStyles, middleTruncateVariants } from "./ui/MiddleTruncate/MiddleTruncate.styles.js";
|
|
79
|
+
import { MiddleTruncate } from "./ui/MiddleTruncate/index.js";
|
|
80
|
+
import { MiddleTruncatePathShortRootStyles, MiddleTruncatePathStyles } from "./ui/MiddleTruncatePath/MiddleTruncatePath.styles.js";
|
|
79
81
|
import { MiddleTruncatePath } from "./ui/MiddleTruncatePath/index.js";
|
|
80
82
|
import { FileItemGitStatusClasses, FileItemStyles, fileItemVariants } from "./ui/FileItem/FileItem.styles.js";
|
|
81
83
|
import { FileItem } from "./ui/FileItem/index.js";
|
|
@@ -173,4 +175,4 @@ import { TerminalPanelChrome } from "./blocks/Terminal/panel/TerminalPanelChrome
|
|
|
173
175
|
import { TerminalPanelFooter } from "./blocks/Terminal/panel/TerminalPanelFooter/index.js";
|
|
174
176
|
import "./blocks/Terminal/index.js";
|
|
175
177
|
|
|
176
|
-
export { ANIMATION_CONFIGS, ANIMATION_DEFAULTS, Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionStyles, AccordionTrigger, ActivityIcon, AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogPortal, AlertDialogStyles, AlertDialogTitle, AlertDialogTrigger, AnimationType, ArrowDownToLineIcon, ArrowUpIcon, AutoHeight, Badge, BellElectricIcon, BellIcon, BlurIntensity, BotIcon, BoxIcon, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Check, Checkbox, CheckboxIndicator, CircleCheckIcon, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, CornerBracket, CountingNumber, DEFAULT_ANIMATIONS, DEFAULT_ANIMATION_CONFIG, DEFAULT_CONFIG, DEFAULT_DIMENSIONS, DEFAULT_GLASS_CONFIG, DEFAULT_GOOEY_CONFIG, DEFAULT_SAFE_AREAS, DEFAULT_SPRING_CONFIG, DEFAULT_TWEEN_CONFIG, DEFAULT_VISUAL_STYLE, DOT_MATRIX_PATTERNS, DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, DeleteIcon, Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogTitle, DialogTrigger, DotMatrix, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicToggle, DynamicToggleGroup, DynamicToggleOption, EASINGS, EFFECTS, Edit2, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, FileIcon, FileIconStyles, FileItem, FileItemGitStatusClasses, FileItemStyles, FilePanel, FilePanelStyles, FileTree, FileTreeStyles, FolderIcon, FolderIconStyles, GOOEY_DEFAULTS, Globe, GooeyButton, GooeyCanvas, GooeyFilter, GooeyMorphingSurface, Highlight, HighlightItem, HomeIcon, HugeIcons, IconSize, IconWrapper, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, LOG_LEVEL_STYLES, Label, LabelPosition, Layers, LayoutPanelTopIcon, ListIcon, LogParserService, Menu, MenuArrow, MenuCheckboxItem, MenuCheckboxItemIndicator, MenuGroup, MenuGroupLabel, MenuHighlight, MenuHighlightItem, MenuItem, MenuPopup, MenuPortal, MenuPositioner, MenuRadioGroup, MenuRadioItem, MenuRadioItemIndicator, MenuSeparator, MenuShortcut, MenuSubmenu, MenuSubmenuTrigger, MenuTrigger, MiddleTruncatePath, MiddleTruncatePathStyles, MobileBottomNav, Morph, MorphPath, MorphingPopover, MorphingPopoverWithTarget, NavItemState, NavSize, NavVariant, OperationCard, OperationCardActions, OperationCardHeader, OperationCardProgress, OperationCardRoot, OperationCardStats, OperationCardStyles, OperationCardVisualizer, PRESETS, Package, Palette, PlusIcon, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RESPONSIVE_CONFIGS, RefreshCw, ReorderRoot as Reorder, Rocket, SIDEBAR_VISUAL_PRESETS, STATUS_COLORS, Save, SearchIcon, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, Sidebar, SidebarBorderRadius, SidebarCollapseMode, SidebarContent, SidebarFluidIndicator, SidebarHideBehaviour, SidebarHideOpensBehavior, SidebarIconLibrary, SidebarIndicator, SidebarItem, SidebarLayoutBehaviour, SidebarNav, SidebarSafeArea, SidebarSafeAreaPosition, SidebarSubContent, SidebarSubLink, SidebarTimingFunction, SidebarToggle, SidebarTooltip, SidebarTransitionDuration, SidebarWidth, SidebarZIndex, SlidingNumber, SlidingText, Slot, Switch, SwitchIcon, SwitchThumb, TIMING, TRANSFORMS, Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsPanel, TabsPanels, TabsTab, TerminalActionBar, TerminalClearButton, TerminalConnectionStatus, TerminalIcon, TerminalPanelChrome, TerminalPanelFooter, TerminalPanelHeader, TerminalSettingsPopover, TerminalStatusBar, TextFlow, Textarea, Tooltip, TooltipArrow, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipTrigger, Trash2, TrendingDownIcon, TrendingUpIcon, Type, Upload, XIcon, ZIndexLevel, accordionVariants, badgeVariants, bracketVariants, buildColorMatrixValues, buildDelays, buildFilterString, buttonStateStyles, buttonVariants, calculateSeparatorCoordination, cardVariants, checkboxStyles, cn, computeBlur, dataCardStyles, dataCardVariants, detectIOSVersion, dialogStyles, dynamicToggleStyles, dynamicToggleVariants, fieldVariants, fileIconVariants, fileItemVariants, filePanelVariants, fileTreeVariants, folderIconVariants, generateIndicatorStyles, generateSidebarStyles, getResponsiveDuration, getResponsiveStagger, getStrictContext, iconVariants, inputGroupAddonVariants, inputGroupButtonVariants, labelVariants,
|
|
178
|
+
export { ANIMATION_CONFIGS, ANIMATION_DEFAULTS, Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionStyles, AccordionTrigger, ActivityIcon, AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogPortal, AlertDialogStyles, AlertDialogTitle, AlertDialogTrigger, AnimationType, ArrowDownToLineIcon, ArrowUpIcon, AutoHeight, Badge, BellElectricIcon, BellIcon, BlurIntensity, BotIcon, BoxIcon, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Check, Checkbox, CheckboxIndicator, CircleCheckIcon, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, CornerBracket, CountingNumber, DEFAULT_ANIMATIONS, DEFAULT_ANIMATION_CONFIG, DEFAULT_CONFIG, DEFAULT_DIMENSIONS, DEFAULT_GLASS_CONFIG, DEFAULT_GOOEY_CONFIG, DEFAULT_SAFE_AREAS, DEFAULT_SPRING_CONFIG, DEFAULT_TWEEN_CONFIG, DEFAULT_VISUAL_STYLE, DOT_MATRIX_PATTERNS, DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, DeleteIcon, Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogPortal, DialogTitle, DialogTrigger, DotMatrix, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicToggle, DynamicToggleGroup, DynamicToggleOption, EASINGS, EFFECTS, Edit2, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, FileIcon, FileIconStyles, FileItem, FileItemGitStatusClasses, FileItemStyles, FilePanel, FilePanelStyles, FileTree, FileTreeStyles, FolderIcon, FolderIconStyles, GOOEY_DEFAULTS, Globe, GooeyButton, GooeyCanvas, GooeyFilter, GooeyMorphingSurface, Highlight, HighlightItem, HomeIcon, HugeIcons, IconSize, IconWrapper, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, LOG_LEVEL_STYLES, Label, LabelPosition, Layers, LayoutPanelTopIcon, ListIcon, LogParserService, Menu, MenuArrow, MenuCheckboxItem, MenuCheckboxItemIndicator, MenuGroup, MenuGroupLabel, MenuHighlight, MenuHighlightItem, MenuItem, MenuPopup, MenuPortal, MenuPositioner, MenuRadioGroup, MenuRadioItem, MenuRadioItemIndicator, MenuSeparator, MenuShortcut, MenuSubmenu, MenuSubmenuTrigger, MenuTrigger, MiddleTruncate, MiddleTruncatePath, MiddleTruncatePathShortRootStyles, MiddleTruncatePathStyles, MiddleTruncateStyles, MobileBottomNav, Morph, MorphPath, MorphingPopover, MorphingPopoverWithTarget, NavItemState, NavSize, NavVariant, OperationCard, OperationCardActions, OperationCardHeader, OperationCardProgress, OperationCardRoot, OperationCardStats, OperationCardStyles, OperationCardVisualizer, PRESETS, Package, Palette, PlusIcon, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RESPONSIVE_CONFIGS, RefreshCw, ReorderRoot as Reorder, Rocket, SIDEBAR_VISUAL_PRESETS, STATUS_COLORS, Save, SearchIcon, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, Sidebar, SidebarBorderRadius, SidebarCollapseMode, SidebarContent, SidebarFluidIndicator, SidebarHideBehaviour, SidebarHideOpensBehavior, SidebarIconLibrary, SidebarIndicator, SidebarItem, SidebarLayoutBehaviour, SidebarNav, SidebarSafeArea, SidebarSafeAreaPosition, SidebarSubContent, SidebarSubLink, SidebarTimingFunction, SidebarToggle, SidebarTooltip, SidebarTransitionDuration, SidebarWidth, SidebarZIndex, SlidingNumber, SlidingText, Slot, Switch, SwitchIcon, SwitchThumb, TIMING, TRANSFORMS, Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsPanel, TabsPanels, TabsTab, TerminalActionBar, TerminalClearButton, TerminalConnectionStatus, TerminalIcon, TerminalPanelChrome, TerminalPanelFooter, TerminalPanelHeader, TerminalSettingsPopover, TerminalStatusBar, TextFlow, Textarea, Tooltip, TooltipArrow, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipTrigger, Trash2, TrendingDownIcon, TrendingUpIcon, Type, Upload, XIcon, ZIndexLevel, accordionVariants, badgeVariants, bracketVariants, buildColorMatrixValues, buildDelays, buildFilterString, buttonStateStyles, buttonVariants, calculateSeparatorCoordination, cardVariants, checkboxStyles, cn, computeBlur, dataCardStyles, dataCardVariants, detectIOSVersion, dialogStyles, dynamicToggleStyles, dynamicToggleVariants, fieldVariants, fileIconVariants, fileItemVariants, filePanelVariants, fileTreeVariants, folderIconVariants, generateIndicatorStyles, generateSidebarStyles, getResponsiveDuration, getResponsiveStagger, getStrictContext, iconVariants, inputGroupAddonVariants, inputGroupButtonVariants, labelVariants, middleTruncateVariants, morphPathDown, morphPathUp, badgeVariants$1 as navBadgeVariants, navItemVariants, navListVariants, operationCardVariants, popoverStyles, progressStyles, rootVariants, shouldShowSeparator, spacerVariants, switchStyles, tabsIndicatorVariants, tabsListVariants, tabsTabVariants, tooltipStyles, useAccordionItem, useAlertDialog, useAnimationOrchestrator, useAutoHeight, useCSSGridMorph, useCheckbox, useComboboxAnchor, useControlledState, useDataCard, useDataState, useDialog, useDynamicToggle, useElementRegistry, useFLIPAnimation, useFLIPClipPath, useHighlight, useIOSFixedReset, useIOSSafariFix, useIsInView, useListFormat, useMenu, useMenuActiveValue, useMorph, useMorphContext, useMorphPath, useOperationCard, usePopover, usePositionCapture, useProgress, useReorder, useReorderPresence, useSidebarContext, useSidebarIndicator, useSidebarKeyboard, useSubContent, useSwitch, useTooltip, useViewTransitions };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for MiddleTruncate.
|
|
3
|
+
*
|
|
4
|
+
* @module @mks2508/mks-ui/react/ui/MiddleTruncate
|
|
5
|
+
*/
|
|
6
|
+
import type { StyleSlots } from '../../../core/types';
|
|
7
|
+
/**
|
|
8
|
+
* Visual regions of the MiddleTruncate component.
|
|
9
|
+
*
|
|
10
|
+
* | Slot | Region |
|
|
11
|
+
* |------|--------|
|
|
12
|
+
* | `root` | Container `<span>` wrapping start + ellipsis + end segments |
|
|
13
|
+
* | `start` | Truncatable leading portion (collapses when narrow) |
|
|
14
|
+
* | `ellipsis` | Ellipsis character(s) between start and end |
|
|
15
|
+
* | `end` | Fixed trailing portion (always visible) |
|
|
16
|
+
*/
|
|
17
|
+
export type TMiddleTruncateSlot = 'root' | 'start' | 'ellipsis' | 'end';
|
|
18
|
+
/**
|
|
19
|
+
* Default Tailwind classes for each MiddleTruncate slot.
|
|
20
|
+
*
|
|
21
|
+
* Uses CSS-only flex truncation — `start` segment has `min-w-0 flex-1 truncate`
|
|
22
|
+
* so the browser truncates it automatically when the container is too narrow.
|
|
23
|
+
* No JS measurement, no ResizeObserver.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MiddleTruncateStyles: StyleSlots<TMiddleTruncateSlot>;
|
|
26
|
+
/** CVA variants for the MiddleTruncate root. */
|
|
27
|
+
export declare const middleTruncateVariants: (props?: ({} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
28
|
+
/** Tailwind classes used when text is short enough to skip splitting. */
|
|
29
|
+
export declare const MiddleTruncateShortRootStyles: "truncate";
|
|
30
|
+
//# sourceMappingURL=MiddleTruncate.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MiddleTruncate.styles.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/MiddleTruncate/MiddleTruncate.styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC;AAExE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,UAAU,CAAC,mBAAmB,CAKvD,CAAC;AAEX,gDAAgD;AAChD,eAAO,MAAM,sBAAsB,2FAGjC,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,6BAA6B,EAAG,UAAmB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
//#region src/react-ui/ui/MiddleTruncate/MiddleTruncate.styles.ts
|
|
4
|
+
/**
|
|
5
|
+
* Styles for MiddleTruncate.
|
|
6
|
+
*
|
|
7
|
+
* @module @mks2508/mks-ui/react/ui/MiddleTruncate
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Default Tailwind classes for each MiddleTruncate slot.
|
|
11
|
+
*
|
|
12
|
+
* Uses CSS-only flex truncation — `start` segment has `min-w-0 flex-1 truncate`
|
|
13
|
+
* so the browser truncates it automatically when the container is too narrow.
|
|
14
|
+
* No JS measurement, no ResizeObserver.
|
|
15
|
+
*/
|
|
16
|
+
const MiddleTruncateStyles = {
|
|
17
|
+
root: "inline-flex items-baseline min-w-0 max-w-full",
|
|
18
|
+
start: "truncate min-w-0 flex-1",
|
|
19
|
+
ellipsis: "shrink-0",
|
|
20
|
+
end: "shrink-0"
|
|
21
|
+
};
|
|
22
|
+
/** CVA variants for the MiddleTruncate root. */
|
|
23
|
+
const middleTruncateVariants = cva(MiddleTruncateStyles.root, {
|
|
24
|
+
variants: {},
|
|
25
|
+
defaultVariants: {}
|
|
26
|
+
});
|
|
27
|
+
/** Tailwind classes used when text is short enough to skip splitting. */
|
|
28
|
+
const MiddleTruncateShortRootStyles = "truncate";
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { MiddleTruncateShortRootStyles, MiddleTruncateStyles, middleTruncateVariants };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for MiddleTruncate.
|
|
3
|
+
*
|
|
4
|
+
* @module @mks2508/mks-ui/react/ui/MiddleTruncate
|
|
5
|
+
*/
|
|
6
|
+
import type { SlotOverrides } from '../../../core/types';
|
|
7
|
+
import type { TMiddleTruncateSlot } from './MiddleTruncate.styles';
|
|
8
|
+
/**
|
|
9
|
+
* Props for `<MiddleTruncate>`.
|
|
10
|
+
*
|
|
11
|
+
* Supports two strategies via discriminated union:
|
|
12
|
+
* - `strategy: 'chars'` — split by individual characters (hashes, UUIDs, commit SHAs)
|
|
13
|
+
* - `strategy: 'segments'` — split by a separator string (paths, domains, k8s names)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // Char-based truncation (keep 6 start + 4 end chars)
|
|
18
|
+
* <MiddleTruncate strategy="chars" text="0xABCDEF1234567890" keepStart={6} keepEnd={4} />
|
|
19
|
+
* // → 0xABCD…7890
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // Segment-based truncation (file path)
|
|
25
|
+
* <MiddleTruncate strategy="segments" separator="/" text="src/components/Button/index.tsx" keepEnd={2} />
|
|
26
|
+
* // → src/…/Button/index.tsx
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export type IMiddleTruncateProps = {
|
|
30
|
+
/** Full text to truncate. */
|
|
31
|
+
text: string;
|
|
32
|
+
/** Character-level truncation. */
|
|
33
|
+
strategy: 'chars';
|
|
34
|
+
/** Leading characters locked visible. Default 0. */
|
|
35
|
+
keepStart?: number;
|
|
36
|
+
/** Trailing characters locked visible. Default 6. */
|
|
37
|
+
keepEnd?: number;
|
|
38
|
+
/** Ellipsis character. Default '…'. */
|
|
39
|
+
ellipsis?: string;
|
|
40
|
+
/** Tooltip on hover. Default: full text. */
|
|
41
|
+
title?: string;
|
|
42
|
+
/** Optional CSS class merged onto the root span. */
|
|
43
|
+
className?: string;
|
|
44
|
+
/** Override default Tailwind classes per visual slot. */
|
|
45
|
+
slots?: SlotOverrides<TMiddleTruncateSlot>;
|
|
46
|
+
} | {
|
|
47
|
+
/** Full text to truncate. */
|
|
48
|
+
text: string;
|
|
49
|
+
/** Segment-level truncation split by separator. */
|
|
50
|
+
strategy: 'segments';
|
|
51
|
+
/** Required separator string (e.g. '/' for paths, '.' for domains, '-' for k8s). */
|
|
52
|
+
separator: string;
|
|
53
|
+
/** Leading segments locked visible. Default 0. */
|
|
54
|
+
keepStart?: number;
|
|
55
|
+
/** Trailing segments locked visible. Default 1. */
|
|
56
|
+
keepEnd?: number;
|
|
57
|
+
/** Ellipsis character. Default '…'. */
|
|
58
|
+
ellipsis?: string;
|
|
59
|
+
/** Tooltip on hover. Default: full text. */
|
|
60
|
+
title?: string;
|
|
61
|
+
/** Optional CSS class merged onto the root span. */
|
|
62
|
+
className?: string;
|
|
63
|
+
/** Override default Tailwind classes per visual slot. */
|
|
64
|
+
slots?: SlotOverrides<TMiddleTruncateSlot>;
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=MiddleTruncate.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MiddleTruncate.types.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/MiddleTruncate/MiddleTruncate.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IACE,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC5C,GACD;IACE,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,QAAQ,EAAE,UAAU,CAAC;IACrB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC5C,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MiddleTruncate — CSS-only middle truncation primitive.
|
|
3
|
+
*
|
|
4
|
+
* Truncates text from the middle, preserving the start and/or end portions.
|
|
5
|
+
* Supports two strategies:
|
|
6
|
+
*
|
|
7
|
+
* - `strategy='chars'` — splits by individual characters, useful for hashes,
|
|
8
|
+
* UUIDs, commit SHAs, or any long identifier where you want to keep the
|
|
9
|
+
* first N and last M characters visible.
|
|
10
|
+
*
|
|
11
|
+
* - `strategy='segments'` — splits by a separator string (e.g. '/', '.', '-'),
|
|
12
|
+
* useful for file paths, domain names, or k8s resource names where segment
|
|
13
|
+
* boundaries are semantically meaningful.
|
|
14
|
+
*
|
|
15
|
+
* Uses CSS-only flex truncation: the `start` segment uses `flex-1 min-w-0 truncate`
|
|
16
|
+
* so the browser truncates it automatically when the container is too narrow.
|
|
17
|
+
* Zero JS measurement, zero ResizeObserver.
|
|
18
|
+
*
|
|
19
|
+
* @module @mks2508/mks-ui/react/ui/MiddleTruncate
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // Hash truncation — preserve first 6 and last 4 chars
|
|
24
|
+
* <MiddleTruncate strategy="chars" text="0xABCDEF1234567890" keepStart={6} keepEnd={4} />
|
|
25
|
+
* // → 0xABCD…7890
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // File path — preserve filename + parent dir
|
|
31
|
+
* <MiddleTruncate
|
|
32
|
+
* strategy="segments"
|
|
33
|
+
* separator="/"
|
|
34
|
+
* text="src/components/Terminal/primitives/ChromeShell.tsx"
|
|
35
|
+
* keepEnd={2}
|
|
36
|
+
* />
|
|
37
|
+
* // → src/…/ChromeShell.tsx
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Domain — preserve root + TLD
|
|
43
|
+
* <MiddleTruncate
|
|
44
|
+
* strategy="segments"
|
|
45
|
+
* separator="."
|
|
46
|
+
* text="api.production.eu-west.example.com"
|
|
47
|
+
* keepStart={1}
|
|
48
|
+
* keepEnd={2}
|
|
49
|
+
* />
|
|
50
|
+
* // → api.…example.com
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* // With slot overrides for custom styling
|
|
56
|
+
* <MiddleTruncate
|
|
57
|
+
* strategy="segments"
|
|
58
|
+
* separator="/"
|
|
59
|
+
* text={path}
|
|
60
|
+
* keepEnd={2}
|
|
61
|
+
* slots={{
|
|
62
|
+
* start: 'text-muted-foreground/60',
|
|
63
|
+
* ellipsis: 'text-muted-foreground/40 mx-0.5',
|
|
64
|
+
* end: 'font-semibold text-foreground',
|
|
65
|
+
* }}
|
|
66
|
+
* />
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
import type { IMiddleTruncateProps } from './MiddleTruncate.types';
|
|
70
|
+
/**
|
|
71
|
+
* Middle-truncates text, preserving start and/or end portions.
|
|
72
|
+
*
|
|
73
|
+
* @param props - See {@link IMiddleTruncateProps}
|
|
74
|
+
*/
|
|
75
|
+
export declare const MiddleTruncate: import("react").MemoExoticComponent<(props: IMiddleTruncateProps) => React.ReactElement>;
|
|
76
|
+
export { MiddleTruncateStyles, middleTruncateVariants, } from './MiddleTruncate.styles';
|
|
77
|
+
export type { TMiddleTruncateSlot } from './MiddleTruncate.styles';
|
|
78
|
+
export type { IMiddleTruncateProps } from './MiddleTruncate.types';
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/MiddleTruncate/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAWH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,cAAc,8CAClB,oBAAoB,KAC1B,KAAK,CAAC,YAAY,CAqBnB,CAAC;AA+FH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { MiddleTruncateShortRootStyles, MiddleTruncateStyles, middleTruncateVariants } from "./MiddleTruncate.styles.js";
|
|
5
|
+
import { memo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/react-ui/ui/MiddleTruncate/index.tsx
|
|
9
|
+
/**
|
|
10
|
+
* MiddleTruncate — CSS-only middle truncation primitive.
|
|
11
|
+
*
|
|
12
|
+
* Truncates text from the middle, preserving the start and/or end portions.
|
|
13
|
+
* Supports two strategies:
|
|
14
|
+
*
|
|
15
|
+
* - `strategy='chars'` — splits by individual characters, useful for hashes,
|
|
16
|
+
* UUIDs, commit SHAs, or any long identifier where you want to keep the
|
|
17
|
+
* first N and last M characters visible.
|
|
18
|
+
*
|
|
19
|
+
* - `strategy='segments'` — splits by a separator string (e.g. '/', '.', '-'),
|
|
20
|
+
* useful for file paths, domain names, or k8s resource names where segment
|
|
21
|
+
* boundaries are semantically meaningful.
|
|
22
|
+
*
|
|
23
|
+
* Uses CSS-only flex truncation: the `start` segment uses `flex-1 min-w-0 truncate`
|
|
24
|
+
* so the browser truncates it automatically when the container is too narrow.
|
|
25
|
+
* Zero JS measurement, zero ResizeObserver.
|
|
26
|
+
*
|
|
27
|
+
* @module @mks2508/mks-ui/react/ui/MiddleTruncate
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* // Hash truncation — preserve first 6 and last 4 chars
|
|
32
|
+
* <MiddleTruncate strategy="chars" text="0xABCDEF1234567890" keepStart={6} keepEnd={4} />
|
|
33
|
+
* // → 0xABCD…7890
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // File path — preserve filename + parent dir
|
|
39
|
+
* <MiddleTruncate
|
|
40
|
+
* strategy="segments"
|
|
41
|
+
* separator="/"
|
|
42
|
+
* text="src/components/Terminal/primitives/ChromeShell.tsx"
|
|
43
|
+
* keepEnd={2}
|
|
44
|
+
* />
|
|
45
|
+
* // → src/…/ChromeShell.tsx
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* // Domain — preserve root + TLD
|
|
51
|
+
* <MiddleTruncate
|
|
52
|
+
* strategy="segments"
|
|
53
|
+
* separator="."
|
|
54
|
+
* text="api.production.eu-west.example.com"
|
|
55
|
+
* keepStart={1}
|
|
56
|
+
* keepEnd={2}
|
|
57
|
+
* />
|
|
58
|
+
* // → api.…example.com
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* // With slot overrides for custom styling
|
|
64
|
+
* <MiddleTruncate
|
|
65
|
+
* strategy="segments"
|
|
66
|
+
* separator="/"
|
|
67
|
+
* text={path}
|
|
68
|
+
* keepEnd={2}
|
|
69
|
+
* slots={{
|
|
70
|
+
* start: 'text-muted-foreground/60',
|
|
71
|
+
* ellipsis: 'text-muted-foreground/40 mx-0.5',
|
|
72
|
+
* end: 'font-semibold text-foreground',
|
|
73
|
+
* }}
|
|
74
|
+
* />
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* Middle-truncates text, preserving start and/or end portions.
|
|
79
|
+
*
|
|
80
|
+
* @param props - See {@link IMiddleTruncateProps}
|
|
81
|
+
*/
|
|
82
|
+
const MiddleTruncate = memo(function MiddleTruncate(props) {
|
|
83
|
+
const { text, strategy, keepStart = 0, keepEnd = strategy === "chars" ? 6 : 1, ellipsis = "…", title, className, slots } = props;
|
|
84
|
+
const tooltip = title ?? text;
|
|
85
|
+
if (strategy === "chars") return /* @__PURE__ */ jsx(CharTruncator, {
|
|
86
|
+
text,
|
|
87
|
+
keepStart,
|
|
88
|
+
keepEnd,
|
|
89
|
+
ellipsis,
|
|
90
|
+
tooltip,
|
|
91
|
+
className,
|
|
92
|
+
slots
|
|
93
|
+
});
|
|
94
|
+
const sep = props.separator;
|
|
95
|
+
return /* @__PURE__ */ jsx(SegmentTruncator, {
|
|
96
|
+
text,
|
|
97
|
+
separator: sep,
|
|
98
|
+
keepStart,
|
|
99
|
+
keepEnd,
|
|
100
|
+
ellipsis,
|
|
101
|
+
tooltip,
|
|
102
|
+
className,
|
|
103
|
+
slots
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
function CharTruncator({ text, keepStart, keepEnd, ellipsis, tooltip, className, slots }) {
|
|
107
|
+
if (text.length <= keepStart + keepEnd) return /* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: cn(MiddleTruncateShortRootStyles, slots?.root, className),
|
|
109
|
+
title: tooltip,
|
|
110
|
+
children: text
|
|
111
|
+
});
|
|
112
|
+
const start = text.slice(0, keepStart);
|
|
113
|
+
const end = text.slice(-keepEnd);
|
|
114
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
115
|
+
className: cn(middleTruncateVariants(), slots?.root, className),
|
|
116
|
+
title: tooltip,
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: cn(MiddleTruncateStyles.start, slots?.start),
|
|
120
|
+
children: start
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ jsx("span", {
|
|
123
|
+
className: cn(MiddleTruncateStyles.ellipsis, slots?.ellipsis),
|
|
124
|
+
children: ellipsis
|
|
125
|
+
}),
|
|
126
|
+
/* @__PURE__ */ jsx("span", {
|
|
127
|
+
className: cn(MiddleTruncateStyles.end, slots?.end),
|
|
128
|
+
children: end
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function SegmentTruncator({ text, separator, keepStart, keepEnd, ellipsis, tooltip, className, slots }) {
|
|
134
|
+
const segments = text.split(separator);
|
|
135
|
+
if (segments.length <= keepStart + keepEnd) return /* @__PURE__ */ jsx("span", {
|
|
136
|
+
className: cn(MiddleTruncateShortRootStyles, slots?.root, className),
|
|
137
|
+
title: tooltip,
|
|
138
|
+
children: text
|
|
139
|
+
});
|
|
140
|
+
const endSegments = segments.slice(-keepEnd);
|
|
141
|
+
const start = segments.slice(0, -keepEnd).join(separator) + separator;
|
|
142
|
+
const end = endSegments.join(separator);
|
|
143
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
144
|
+
className: cn(middleTruncateVariants(), slots?.root, className),
|
|
145
|
+
title: tooltip,
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ jsx("span", {
|
|
148
|
+
className: cn(MiddleTruncateStyles.start, slots?.start),
|
|
149
|
+
children: start
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ jsx("span", {
|
|
152
|
+
className: cn(MiddleTruncateStyles.ellipsis, slots?.ellipsis),
|
|
153
|
+
children: ellipsis
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ jsx("span", {
|
|
156
|
+
className: cn(MiddleTruncateStyles.end, slots?.end),
|
|
157
|
+
children: end
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
export { MiddleTruncate };
|
|
@@ -29,4 +29,4 @@ const middleTruncatePathVariants = cva(MiddleTruncatePathStyles.root, {
|
|
|
29
29
|
const MiddleTruncatePathShortRootStyles = "truncate";
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
|
-
export { MiddleTruncatePathShortRootStyles, MiddleTruncatePathStyles
|
|
32
|
+
export { MiddleTruncatePathShortRootStyles, MiddleTruncatePathStyles };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MiddleTruncatePath — CSS-only middle truncation for file paths.
|
|
3
3
|
*
|
|
4
|
+
* @deprecated Use `<MiddleTruncate strategy="segments" separator="/">` instead.
|
|
5
|
+
* Path-specific wrapper kept for backward compatibility. Will be removed in v0.11.
|
|
6
|
+
*
|
|
4
7
|
* Splits a path into a truncatable start and a fixed end
|
|
5
8
|
* (`parent/filename` by default). When space is limited, the start
|
|
6
9
|
* truncates with ellipsis while the end (the most identifiable part)
|
|
@@ -16,6 +19,9 @@ import type { IMiddleTruncatePathProps } from './MiddleTruncatePath.types';
|
|
|
16
19
|
/**
|
|
17
20
|
* Middle-truncates a file path, keeping the end segments visible.
|
|
18
21
|
*
|
|
22
|
+
* @deprecated Use `<MiddleTruncate strategy="segments" separator="/">` instead.
|
|
23
|
+
* This component is a thin path-specific wrapper and will be removed in v0.11.
|
|
24
|
+
*
|
|
19
25
|
* @param slots - Override Tailwind classes per visual slot
|
|
20
26
|
*
|
|
21
27
|
* @example
|
|
@@ -27,7 +33,7 @@ import type { IMiddleTruncatePathProps } from './MiddleTruncatePath.types';
|
|
|
27
33
|
* ```
|
|
28
34
|
*/
|
|
29
35
|
export declare const MiddleTruncatePath: import("react").MemoExoticComponent<({ path, keepEnd, className, startClassName, endClassName, slots, }: IMiddleTruncatePathProps) => import("react/jsx-runtime").JSX.Element>;
|
|
30
|
-
export { MiddleTruncatePathStyles,
|
|
36
|
+
export { MiddleTruncatePathStyles, MiddleTruncatePathShortRootStyles, } from './MiddleTruncatePath.styles';
|
|
31
37
|
export type { MiddleTruncatePathSlot } from './MiddleTruncatePath.styles';
|
|
32
38
|
export type { IMiddleTruncatePathProps } from './MiddleTruncatePath.types';
|
|
33
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/MiddleTruncatePath/index.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/MiddleTruncatePath/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,2GAO5B,wBAAwB,6CA6BzB,CAAC;AAEH,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../lib/utils.js";
|
|
4
|
-
import {
|
|
4
|
+
import { MiddleTruncate } from "../MiddleTruncate/index.js";
|
|
5
|
+
import { MiddleTruncatePathShortRootStyles, MiddleTruncatePathStyles } from "./MiddleTruncatePath.styles.js";
|
|
5
6
|
import { memo } from "react";
|
|
6
|
-
import { jsx
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
|
|
8
9
|
//#region src/react-ui/ui/MiddleTruncatePath/index.tsx
|
|
9
10
|
/**
|
|
10
11
|
* MiddleTruncatePath — CSS-only middle truncation for file paths.
|
|
11
12
|
*
|
|
13
|
+
* @deprecated Use `<MiddleTruncate strategy="segments" separator="/">` instead.
|
|
14
|
+
* Path-specific wrapper kept for backward compatibility. Will be removed in v0.11.
|
|
15
|
+
*
|
|
12
16
|
* Splits a path into a truncatable start and a fixed end
|
|
13
17
|
* (`parent/filename` by default). When space is limited, the start
|
|
14
18
|
* truncates with ellipsis while the end (the most identifiable part)
|
|
@@ -23,6 +27,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
23
27
|
/**
|
|
24
28
|
* Middle-truncates a file path, keeping the end segments visible.
|
|
25
29
|
*
|
|
30
|
+
* @deprecated Use `<MiddleTruncate strategy="segments" separator="/">` instead.
|
|
31
|
+
* This component is a thin path-specific wrapper and will be removed in v0.11.
|
|
32
|
+
*
|
|
26
33
|
* @param slots - Override Tailwind classes per visual slot
|
|
27
34
|
*
|
|
28
35
|
* @example
|
|
@@ -34,25 +41,22 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
34
41
|
* ```
|
|
35
42
|
*/
|
|
36
43
|
const MiddleTruncatePath = memo(function MiddleTruncatePath({ path, keepEnd = 2, className, startClassName, endClassName, slots }) {
|
|
37
|
-
|
|
38
|
-
if (segments.length <= keepEnd) return /* @__PURE__ */ jsx("span", {
|
|
44
|
+
if (path.split("/").length <= keepEnd) return /* @__PURE__ */ jsx("span", {
|
|
39
45
|
className: cn(MiddleTruncatePathShortRootStyles, slots?.root, className),
|
|
40
46
|
title: path,
|
|
41
47
|
children: path
|
|
42
48
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
children: end
|
|
55
|
-
})]
|
|
49
|
+
return /* @__PURE__ */ jsx(MiddleTruncate, {
|
|
50
|
+
strategy: "segments",
|
|
51
|
+
separator: "/",
|
|
52
|
+
text: path,
|
|
53
|
+
keepEnd,
|
|
54
|
+
className,
|
|
55
|
+
slots: {
|
|
56
|
+
...slots,
|
|
57
|
+
start: cn(slots?.start, startClassName),
|
|
58
|
+
end: cn(slots?.end, endClassName)
|
|
59
|
+
}
|
|
56
60
|
});
|
|
57
61
|
});
|
|
58
62
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react-ui/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAG1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAG3B,cAAc,YAAY,CAAC;AAG3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react-ui/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAG1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAG3B,cAAc,YAAY,CAAC;AAG3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -38,7 +38,9 @@ import { fieldVariants } from "./Field/Field.styles.js";
|
|
|
38
38
|
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle } from "./Field/index.js";
|
|
39
39
|
import { FileIconStyles, FolderIconStyles, fileIconVariants, folderIconVariants } from "./FileIcon/FileIcon.styles.js";
|
|
40
40
|
import { FileIcon, FolderIcon } from "./FileIcon/index.js";
|
|
41
|
-
import {
|
|
41
|
+
import { MiddleTruncateStyles, middleTruncateVariants } from "./MiddleTruncate/MiddleTruncate.styles.js";
|
|
42
|
+
import { MiddleTruncate } from "./MiddleTruncate/index.js";
|
|
43
|
+
import { MiddleTruncatePathShortRootStyles, MiddleTruncatePathStyles } from "./MiddleTruncatePath/MiddleTruncatePath.styles.js";
|
|
42
44
|
import { MiddleTruncatePath } from "./MiddleTruncatePath/index.js";
|
|
43
45
|
import { FileItemGitStatusClasses, FileItemStyles, fileItemVariants } from "./FileItem/FileItem.styles.js";
|
|
44
46
|
import { FileItem } from "./FileItem/index.js";
|