@sybilion/uilib 1.4.12 → 1.4.13

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.
Files changed (30) hide show
  1. package/dist/esm/components/ui/Button/Button.styl.js +1 -1
  2. package/dist/esm/components/ui/Sidebar/Sidebar.js +20 -7
  3. package/dist/esm/components/ui/Sidebar/Sidebar.styl.js +2 -2
  4. package/dist/esm/components/ui/SmartTextTruncate/SmartTextTruncate.js +260 -67
  5. package/dist/esm/components/ui/SmartTextTruncate/SmartTextTruncate.styl.js +7 -0
  6. package/dist/esm/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.js +5 -5
  7. package/dist/esm/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.styl.js +2 -2
  8. package/dist/esm/index.js +1 -1
  9. package/dist/esm/types/src/components/ui/Chat/ChatSheet/ChatSheet.d.ts +1 -1
  10. package/dist/esm/types/src/components/ui/Sidebar/Sidebar.d.ts +7 -2
  11. package/dist/esm/types/src/components/ui/SmartTextTruncate/SmartTextTruncate.d.ts +5 -3
  12. package/dist/esm/types/src/components/ui/SmartTextTruncate/index.d.ts +1 -1
  13. package/package.json +1 -1
  14. package/src/components/ui/Button/Button.styl +2 -2
  15. package/src/components/ui/Chat/ChatSheet/ChatSheet.tsx +1 -1
  16. package/src/components/ui/Sidebar/Sidebar.styl +60 -50
  17. package/src/components/ui/Sidebar/Sidebar.styl.d.ts +4 -0
  18. package/src/components/ui/Sidebar/Sidebar.tsx +66 -6
  19. package/src/components/ui/SmartTextTruncate/SmartTextTruncate.styl +34 -0
  20. package/src/components/ui/SmartTextTruncate/SmartTextTruncate.styl.d.ts +10 -0
  21. package/src/components/ui/SmartTextTruncate/SmartTextTruncate.tsx +335 -81
  22. package/src/components/ui/SmartTextTruncate/index.ts +5 -1
  23. package/src/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.styl +0 -24
  24. package/src/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.styl.d.ts +0 -2
  25. package/src/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.tsx +5 -11
  26. package/src/docs/components/DocsSidebar/DocsSidebar.tsx +3 -17
  27. package/src/docs/pages/SidebarDatasetsItemsGroupedPage.tsx +4 -1
  28. package/src/docs/pages/SmartTextTruncatePage.styl +22 -0
  29. package/src/docs/pages/SmartTextTruncatePage.styl.d.ts +2 -0
  30. package/src/docs/pages/SmartTextTruncatePage.tsx +21 -1
@@ -82,8 +82,13 @@ declare function SidebarGroupAction({ className, asChild, ...props }: ComponentP
82
82
  }): import("react/jsx-runtime").JSX.Element;
83
83
  declare function SidebarMenu({ className, ...props }: ComponentProps<'ul'>): import("react/jsx-runtime").JSX.Element;
84
84
  declare function SidebarMenuItem({ className, ...props }: ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
85
- declare function SidebarMenuButton({ asChild, isActive, variant, size, className, ...props }: ButtonProps & {
85
+ declare function SidebarMenuButton({ asChild, isActive, hasSubItems, isExpanded, variant, size, className, icon, children, ...props }: Omit<ButtonProps, 'icon'> & {
86
+ icon?: React.ReactNode;
86
87
  isActive?: boolean;
88
+ /** When true, renders an expand/collapse chevron (requires a non–asChild button). */
89
+ hasSubItems?: boolean;
90
+ /** Chevron direction when `hasSubItems` is true. */
91
+ isExpanded?: boolean;
87
92
  }): import("react/jsx-runtime").JSX.Element;
88
93
  declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }: ComponentProps<'button'> & {
89
94
  asChild?: boolean;
@@ -92,7 +97,7 @@ declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }
92
97
  declare function SidebarMenuBadge({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
93
98
  declare function SidebarMenuSub({ className, ...props }: ComponentProps<'ul'>): import("react/jsx-runtime").JSX.Element;
94
99
  declare function SidebarMenuSubItem({ className, ...props }: ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
95
- declare function SidebarMenuSubButton({ asChild, size, isActive, tooltip, className, onClick, ...props }: ComponentProps<'a'> & {
100
+ declare function SidebarMenuSubButton({ asChild, size, isActive, tooltip, className, onClick, children, ...props }: ComponentProps<'a'> & {
96
101
  asChild?: boolean;
97
102
  size?: 'sm' | 'md' | 'lg';
98
103
  isActive?: boolean;
@@ -1,3 +1,5 @@
1
- import type { SmartTextTruncateProps } from './SmartTextTruncate.types';
2
- declare function SmartTextTruncate({ children, className, ...props }: SmartTextTruncateProps): import("react/jsx-runtime").JSX.Element;
3
- export { SmartTextTruncate };
1
+ /** Panel resize handle — call on first pointer move after press, not on pointer down. */
2
+ declare function notifyPanelWidthDragStart(): void;
3
+ declare function notifyPanelWidthDragEnd(): void;
4
+ declare const SmartTextTruncate: import("react").NamedExoticComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>>;
5
+ export { SmartTextTruncate, notifyPanelWidthDragStart, notifyPanelWidthDragEnd, };
@@ -1,2 +1,2 @@
1
- export { SmartTextTruncate } from './SmartTextTruncate';
1
+ export { SmartTextTruncate, notifyPanelWidthDragStart, notifyPanelWidthDragEnd, } from './SmartTextTruncate';
2
2
  export type { SmartTextTruncateProps } from './SmartTextTruncate.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybilion/uilib",
3
- "version": "1.4.12",
3
+ "version": "1.4.13",
4
4
  "description": "Sybilion Design System — React UI components (Webpack + Stylus)",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -3,7 +3,7 @@
3
3
  display inline-flex
4
4
  align-items center
5
5
  justify-content center
6
- gap 10px
6
+ gap var(--p-2)
7
7
  flex-shrink 0
8
8
  white-space nowrap
9
9
  border-radius var(--radius-button)
@@ -105,7 +105,7 @@
105
105
  .sizeSm
106
106
  height 30px
107
107
  padding 0 14px
108
- font-size 13px
108
+ font-size var(--text-sm)
109
109
  border-radius var(--p-5)
110
110
 
111
111
  .sizeMd
@@ -27,7 +27,7 @@ export interface ChatSheetProps extends Omit<
27
27
  actionsRef?: React.MutableRefObject<ChatSheetActions | null>;
28
28
  renderTrigger?: (toggleOpen: () => void, isOpen: boolean) => React.ReactNode;
29
29
  triggerIcon?: React.ReactNode;
30
- triggerLabel?: string;
30
+ triggerLabel?: React.ReactNode;
31
31
  /** aria-label for icon-only trigger (required when trigger has no visible text) */
32
32
  triggerAriaLabel?: string;
33
33
  label?: string;
@@ -286,7 +286,7 @@
286
286
  border-radius 0.375rem
287
287
  padding-left 0.25rem
288
288
  padding-right 0.25rem
289
- font-size 0.75rem
289
+ // font-size 0.75rem
290
290
  font-weight 500
291
291
  user-select none
292
292
  &[data-size="sm"]
@@ -323,7 +323,7 @@
323
323
  position relative
324
324
  display flex
325
325
  flex-direction column
326
- gap var(--p-2)
326
+ gap var(--p-1)
327
327
 
328
328
  min-width 0
329
329
  padding 0
@@ -339,9 +339,9 @@
339
339
  &::before
340
340
  content ''
341
341
  position absolute
342
- left var(--p-5)
342
+ left 14px
343
343
  top 0
344
- bottom 26px
344
+ bottom 0
345
345
  width 1px
346
346
  background var(--sidebar-border)
347
347
  pointer-events none
@@ -353,19 +353,7 @@
353
353
  .sidebarMenuSubItem
354
354
  position relative
355
355
  min-width 0
356
- margin-left var(--p-6)
357
-
358
- &::before
359
- content ''
360
- position absolute
361
- left calc(var(--p-1) * -1)
362
- top var(--p-2)
363
- bottom 0
364
- width var(--p-3)
365
- height var(--p-3)
366
- border-left 1px solid var(--sidebar-border)
367
- border-bottom 1px solid var(--sidebar-border)
368
- border-bottom-left-radius var(--p-2)
356
+ margin-left var(--p-4)
369
357
 
370
358
  a:hover
371
359
  text-decoration: none;
@@ -447,7 +435,6 @@
447
435
  border-radius var(--p-3)
448
436
  padding var(--p-6) var(--p-3)
449
437
  text-align left
450
- font-size 0.875rem
451
438
  outline none
452
439
  cursor pointer
453
440
  transition all
@@ -484,11 +471,11 @@
484
471
  height 2rem !important
485
472
  padding 0.5rem !important
486
473
 
487
- & > span
488
- flex-grow 1
489
- line-height 20px
490
- white-space nowrap
491
- overflow hidden
474
+ // & > span
475
+ // flex-grow 1
476
+ // line-height 20px
477
+ // white-space nowrap
478
+ // overflow hidden
492
479
 
493
480
  & > svg
494
481
  width var(--p-5)
@@ -498,13 +485,13 @@
498
485
  // Size variants
499
486
  &.size-sm
500
487
  height 1.75rem
501
- font-size 0.75rem
488
+ // font-size 0.75rem
502
489
  &.size-md
503
490
  height var(--p-12)
504
- font-size 0.875rem
491
+ // font-size 0.875rem
505
492
  &.size-lg
506
493
  height 3rem
507
- font-size 0.875rem
494
+ // font-size 0.875rem
508
495
  &[data-collapsible="icon"]
509
496
  padding 0 !important
510
497
 
@@ -517,6 +504,27 @@
517
504
  color var(--sidebar-accent-foreground)
518
505
  box-shadow 0 0 0 1px var(--sidebar-accent)
519
506
 
507
+ .sidebarMenuButtonLabel
508
+ flex-grow 1
509
+
510
+ .sidebarMenuSubButtonLabel
511
+ flex-grow 1
512
+ min-width 0
513
+
514
+ .sidebarMenuButtonChevron
515
+ margin-left auto
516
+ display flex
517
+ flex-shrink 0
518
+ align-items center
519
+ transition transform 0.1s ease-out
520
+
521
+ &.expanded
522
+ transform rotate(90deg)
523
+
524
+ & > svg
525
+ width var(--p-5)
526
+ height var(--p-5)
527
+
520
528
  // Full-width primary CTA in sidebar (uses ui/Button variant=default; avoids nav hover conflicts)
521
529
  .sidebarMenuButtonCta
522
530
  display flex
@@ -604,18 +612,20 @@
604
612
 
605
613
  // Menu sub button variants
606
614
  .sidebarMenuSubButton
607
- color var(--sidebar-foreground)
608
615
  display flex
616
+ align-items center
617
+ gap var(--p-1)
618
+
609
619
  width calc(100% - var(--p-3))
610
620
  height var(--p-9)
611
621
  min-width 0
612
- transform translateX(-1px)
613
- align-items center
614
- gap var(--p-1)
622
+ padding var(--p-2) var(--p-3)
623
+ margin-left var(--p-1)
624
+
615
625
  overflow hidden
626
+ transform translateX(-1px)
616
627
  border-radius var(--p-3)
617
- padding var(--p-1) var(--p-2)
618
- margin-left var(--p-3)
628
+ color var(--sidebar-foreground)
619
629
  outline none
620
630
  cursor pointer
621
631
  text-decoration none
@@ -647,19 +657,19 @@
647
657
  &[data-collapsible="icon"]
648
658
  display none
649
659
 
650
- & > span
651
- flex-grow 1
652
- flex-shrink 1
653
- min-width 0
654
- line-height 20px
655
- white-space nowrap
656
- overflow hidden
660
+ // & > span
661
+ // flex-grow 1
662
+ // flex-shrink 1
663
+ // min-width 0
664
+ // line-height 20px
665
+ // white-space nowrap
666
+ // overflow hidden
657
667
 
658
- // Nested SmartTextTruncate (e.g. title pre-wrapped in app nav items)
659
- & > span
660
- display block
661
- width 100%
662
- min-width 0
668
+ // // Nested SmartTextTruncate (e.g. title pre-wrapped in app nav items)
669
+ // & > span
670
+ // display block
671
+ // width 100%
672
+ // min-width 0
663
673
 
664
674
  & > svg
665
675
  width 1rem
@@ -668,12 +678,12 @@
668
678
  color var(--sidebar-accent-foreground)
669
679
 
670
680
  // Size variants
671
- &.size-sm
672
- font-size 0.75rem
673
- &.size-md
674
- font-size 0.875rem
675
- &.size-lg
676
- font-size 1rem
681
+ // &.size-sm
682
+ // font-size 0.75rem
683
+ // &.size-md
684
+ // font-size 0.875rem
685
+ // &.size-lg
686
+ // font-size 1rem
677
687
 
678
688
  // View Transition API: opacity cross-fade is the UA default on old/new pseudos.
679
689
  // Setting animation-name below replaces that default; keyframes keep opacity + add blur.
@@ -2,6 +2,7 @@
2
2
  // Please do not change this file!
3
3
  interface CssExports {
4
4
  'chatPanelMount': string;
5
+ 'expanded': string;
5
6
  'fullHeightResizer': string;
6
7
  'sheetContentSidebar': string;
7
8
  'sheetSidebarInner': string;
@@ -19,13 +20,16 @@ interface CssExports {
19
20
  'sidebarMenuAction': string;
20
21
  'sidebarMenuBadge': string;
21
22
  'sidebarMenuButton': string;
23
+ 'sidebarMenuButtonChevron': string;
22
24
  'sidebarMenuButtonCta': string;
25
+ 'sidebarMenuButtonLabel': string;
23
26
  'sidebarMenuItem': string;
24
27
  'sidebarMenuSkeleton': string;
25
28
  'sidebarMenuSkeletonIcon': string;
26
29
  'sidebarMenuSkeletonText': string;
27
30
  'sidebarMenuSub': string;
28
31
  'sidebarMenuSubButton': string;
32
+ 'sidebarMenuSubButtonLabel': string;
29
33
  'sidebarMenuSubItem': string;
30
34
  'sidebarNone': string;
31
35
  'sidebarRail': string;
@@ -18,6 +18,11 @@ import type { ButtonProps } from '#uilib/components/ui/Button/Button.types';
18
18
  import { Logo } from '#uilib/components/ui/Logo/Logo';
19
19
  import { Separator } from '#uilib/components/ui/Separator';
20
20
  import { Sheet, SheetContent, SheetTitle } from '#uilib/components/ui/Sheet';
21
+ import {
22
+ SmartTextTruncate,
23
+ notifyPanelWidthDragEnd,
24
+ notifyPanelWidthDragStart,
25
+ } from '#uilib/components/ui/SmartTextTruncate/SmartTextTruncate';
21
26
  import {
22
27
  Tooltip,
23
28
  TooltipContent,
@@ -45,7 +50,7 @@ import { getCookie, setCookie } from '#uilib/lib/cookie';
45
50
  import { getCookiePreferences } from '#uilib/lib/cookie-consent/cookie-consent';
46
51
  import { LS, Scroll } from '@homecode/ui';
47
52
  import { Slot } from '@radix-ui/react-slot';
48
- import { PanelLeft } from 'lucide-react';
53
+ import { ChevronDown, ChevronRight, PanelLeft } from 'lucide-react';
49
54
 
50
55
  import S from './Sidebar.styl';
51
56
 
@@ -255,8 +260,17 @@ function SidebarProvider({
255
260
  chatPanelOpen: chatPanelOpenRef.current,
256
261
  chatWidthPx: chatWidthRef.current,
257
262
  });
263
+ sidebarWidthRef.current = next;
264
+
265
+ // Live drag: update CSS var only — avoid re-rendering the whole nav tree each frame.
266
+ if (wrapperRef.current) {
267
+ wrapperRef.current.style.setProperty('--sidebar-width', `${next}px`);
268
+ }
269
+
270
+ if (!persist) return;
271
+
258
272
  _setSidebarWidthPx(next);
259
- if (persist && allowPersistSidebarWidth) {
273
+ if (allowPersistSidebarWidth) {
260
274
  LS.set(sidebarLsKey, next);
261
275
  }
262
276
  },
@@ -722,6 +736,7 @@ function PanelResizeHandle({
722
736
 
723
737
  const handleDrag = useCallback(
724
738
  (delta: Delta) => {
739
+ notifyPanelWidthDragStart();
725
740
  const shellW = getShellWidth();
726
741
  if (shellW <= 0) return;
727
742
  const raw =
@@ -746,6 +761,7 @@ function PanelResizeHandle({
746
761
  const handleDragEnd = useCallback(
747
762
  (e: PointerEvent) => {
748
763
  onDragComplete?.(lastRawRef.current);
764
+ notifyPanelWidthDragEnd();
749
765
  try {
750
766
  handleRef.current?.releasePointerCapture(e.pointerId);
751
767
  } catch {
@@ -926,26 +942,65 @@ function SidebarMenuItem({ className, ...props }: ComponentProps<'li'>) {
926
942
  function SidebarMenuButton({
927
943
  asChild = false,
928
944
  isActive = false,
945
+ hasSubItems = false,
946
+ isExpanded = false,
929
947
  variant = 'ghost',
930
948
  size = 'sm',
931
949
  className,
950
+ icon,
951
+ children,
932
952
  ...props
933
- }: ButtonProps & { isActive?: boolean }) {
953
+ }: Omit<ButtonProps, 'icon'> & {
954
+ icon?: React.ReactNode;
955
+ isActive?: boolean;
956
+ /** When true, renders an expand/collapse chevron (requires a non–asChild button). */
957
+ hasSubItems?: boolean;
958
+ /** Chevron direction when `hasSubItems` is true. */
959
+ isExpanded?: boolean;
960
+ }) {
961
+ const effectiveAsChild = asChild && !hasSubItems;
962
+
963
+ const label = (
964
+ <SmartTextTruncate className={S.sidebarMenuButtonLabel}>
965
+ {children}
966
+ </SmartTextTruncate>
967
+ );
968
+
969
+ const chevron = hasSubItems ? (
970
+ <span
971
+ className={cn(S.sidebarMenuButtonChevron, isExpanded && S.expanded)}
972
+ aria-hidden="true"
973
+ >
974
+ <ChevronRight size={16} />
975
+ </span>
976
+ ) : null;
977
+
934
978
  return (
935
979
  <Button
936
- asChild={asChild}
980
+ asChild={effectiveAsChild}
937
981
  variant={variant}
938
982
  size={size}
939
983
  data-slot="sidebar-menu-button"
940
984
  data-sidebar="menu-button"
941
985
  data-active={isActive}
986
+ aria-expanded={hasSubItems ? isExpanded : undefined}
942
987
  className={cn(
943
988
  variant === 'default' ? S.sidebarMenuButtonCta : S.sidebarMenuButton,
944
989
  S[`size-${size}`],
945
990
  className,
946
991
  )}
947
992
  {...props}
948
- />
993
+ >
994
+ {icon}
995
+ {effectiveAsChild ? (
996
+ label
997
+ ) : (
998
+ <>
999
+ {label}
1000
+ {chevron}
1001
+ </>
1002
+ )}
1003
+ </Button>
949
1004
  );
950
1005
  }
951
1006
 
@@ -1014,6 +1069,7 @@ function SidebarMenuSubButton({
1014
1069
  tooltip,
1015
1070
  className,
1016
1071
  onClick,
1072
+ children,
1017
1073
  ...props
1018
1074
  }: ComponentProps<'a'> & {
1019
1075
  asChild?: boolean;
@@ -1040,7 +1096,11 @@ function SidebarMenuSubButton({
1040
1096
  className={cn(S.sidebarMenuSubButton, S[`size-${size}`], className)}
1041
1097
  onClick={handleClick}
1042
1098
  {...props}
1043
- />
1099
+ >
1100
+ <SmartTextTruncate className={S.sidebarMenuSubButtonLabel}>
1101
+ {children}
1102
+ </SmartTextTruncate>
1103
+ </Comp>
1044
1104
  );
1045
1105
 
1046
1106
  if (!tooltip) return button;
@@ -0,0 +1,34 @@
1
+ .root
2
+ position relative
3
+ overflow hidden
4
+ min-width 0
5
+
6
+ // Middle-truncated label — visible when settled.
7
+ .measuredLabel
8
+ display block
9
+ white-space nowrap
10
+ overflow hidden
11
+ min-width 0
12
+
13
+ // Full text + end ellipsis — visible only while dragging/resizing (html flag).
14
+ .liveLabel
15
+ display none
16
+ white-space nowrap
17
+ overflow hidden
18
+ text-overflow ellipsis
19
+ min-width 0
20
+
21
+ :global(html[data-smart-text-truncate-fast]) .measuredLabel
22
+ display none
23
+
24
+ :global(html[data-smart-text-truncate-fast]) .liveLabel
25
+ display block
26
+
27
+ :global(html[data-smart-text-truncate-fast]) .fullText
28
+ display none
29
+
30
+ .fullText
31
+ position absolute
32
+ visibility hidden
33
+ white-space nowrap
34
+ top -9999px
@@ -0,0 +1,10 @@
1
+ // This file is automatically generated.
2
+ // Please do not change this file!
3
+ interface CssExports {
4
+ 'fullText': string;
5
+ 'liveLabel': string;
6
+ 'measuredLabel': string;
7
+ 'root': string;
8
+ }
9
+ export const cssExports: CssExports;
10
+ export default cssExports;