@liiift-studio/mac-os9-ui 0.2.21 → 0.2.24

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/index.d.ts CHANGED
@@ -813,6 +813,89 @@ interface TabsProps {
813
813
  */
814
814
  declare const Tabs: React__default.FC<TabsProps>;
815
815
 
816
+ /**
817
+ * Generic classes object for targeting sub-elements within components
818
+ * Components extend this with specific element keys
819
+ */
820
+ interface ComponentClasses {
821
+ root?: string;
822
+ [key: string]: string | undefined;
823
+ }
824
+ /**
825
+ * Base component props that all components should extend
826
+ * @template TClasses - Specific classes type for the component
827
+ */
828
+ interface BaseComponentProps<TClasses extends ComponentClasses = ComponentClasses> {
829
+ /** Additional CSS class name for root element */
830
+ className?: string;
831
+ /** Inline styles */
832
+ style?: React.CSSProperties;
833
+ /** Custom classes for targeting sub-elements */
834
+ classes?: TClasses;
835
+ /** Test ID for testing purposes */
836
+ 'data-testid'?: string;
837
+ }
838
+ /**
839
+ * Common render state interface for render prop patterns
840
+ * Provides information about element state for conditional rendering
841
+ */
842
+ interface RenderState {
843
+ /** Whether the element is being hovered */
844
+ isHovered?: boolean;
845
+ /** Whether the element is selected */
846
+ isSelected?: boolean;
847
+ /** Whether the element is in active state (e.g., pressed) */
848
+ isActive?: boolean;
849
+ /** Whether the element has keyboard focus */
850
+ isFocused?: boolean;
851
+ /** Whether the element is disabled */
852
+ isDisabled?: boolean;
853
+ }
854
+ /**
855
+ * Common variant types for Mac OS 9 components
856
+ */
857
+ type Variant = 'default' | 'primary' | 'secondary';
858
+ /**
859
+ * Common size types
860
+ */
861
+ type Size = 'small' | 'medium' | 'large';
862
+ /**
863
+ * Common state types
864
+ */
865
+ type State = 'default' | 'hover' | 'active' | 'disabled' | 'focused';
866
+ /**
867
+ * Window position for draggable windows
868
+ */
869
+ interface WindowPosition {
870
+ x: number;
871
+ y: number;
872
+ }
873
+ /**
874
+ * Component ref types
875
+ */
876
+ type ButtonRef = HTMLButtonElement;
877
+ type InputRef = HTMLInputElement;
878
+ type SelectRef = HTMLSelectElement;
879
+ type TextAreaRef = HTMLTextAreaElement;
880
+ type DivRef = HTMLDivElement;
881
+
882
+ /**
883
+ * Classes for targeting Window sub-elements
884
+ */
885
+ interface WindowClasses {
886
+ /** Root container */
887
+ root?: string;
888
+ /** Title bar */
889
+ titleBar?: string;
890
+ /** Title text */
891
+ titleText?: string;
892
+ /** Window controls container */
893
+ controls?: string;
894
+ /** Individual control button */
895
+ controlButton?: string;
896
+ /** Content area */
897
+ content?: string;
898
+ }
816
899
  interface WindowProps {
817
900
  /**
818
901
  * Window content
@@ -850,6 +933,10 @@ interface WindowProps {
850
933
  * Custom class name for the content area
851
934
  */
852
935
  contentClassName?: string;
936
+ /**
937
+ * Custom classes for targeting sub-elements
938
+ */
939
+ classes?: WindowClasses;
853
940
  /**
854
941
  * Whether to show window controls (close, minimize, maximize)
855
942
  * @default true
@@ -876,6 +963,27 @@ interface WindowProps {
876
963
  * @default false
877
964
  */
878
965
  resizable?: boolean;
966
+ /**
967
+ * Whether the window can be dragged by its title bar
968
+ * Window starts in normal flow and becomes absolutely positioned when dragged
969
+ * @default false
970
+ */
971
+ draggable?: boolean;
972
+ /**
973
+ * Initial position for draggable windows (uncontrolled)
974
+ * Only used when draggable is true
975
+ */
976
+ defaultPosition?: WindowPosition;
977
+ /**
978
+ * Controlled position for draggable windows
979
+ * Only used when draggable is true
980
+ */
981
+ position?: WindowPosition;
982
+ /**
983
+ * Callback when window position changes (during drag)
984
+ * Only called when draggable is true
985
+ */
986
+ onPositionChange?: (position: WindowPosition) => void;
879
987
  }
880
988
  /**
881
989
  * Mac OS 9 style Window component
@@ -888,6 +996,7 @@ interface WindowProps {
888
996
  * - Active/inactive states
889
997
  * - Composable with custom TitleBar component
890
998
  * - Flexible sizing
999
+ * - Draggable windows (optional) - drag by title bar
891
1000
  *
892
1001
  * @example
893
1002
  * ```tsx
@@ -909,6 +1018,31 @@ interface WindowProps {
909
1018
  * >
910
1019
  * <p>Content</p>
911
1020
  * </Window>
1021
+ *
1022
+ * // Draggable window (uncontrolled)
1023
+ * <Window title="Draggable" draggable>
1024
+ * <p>Drag me by the title bar!</p>
1025
+ * </Window>
1026
+ *
1027
+ * // Draggable window with initial position
1028
+ * <Window
1029
+ * title="Positioned"
1030
+ * draggable
1031
+ * defaultPosition={{ x: 100, y: 100 }}
1032
+ * >
1033
+ * <p>Starts at a specific position</p>
1034
+ * </Window>
1035
+ *
1036
+ * // Controlled draggable window
1037
+ * const [pos, setPos] = useState({ x: 0, y: 0 });
1038
+ * <Window
1039
+ * title="Controlled"
1040
+ * draggable
1041
+ * position={pos}
1042
+ * onPositionChange={setPos}
1043
+ * >
1044
+ * <p>Parent controls position</p>
1045
+ * </Window>
912
1046
  * ```
913
1047
  */
914
1048
  declare const Window: React__default.ForwardRefExoticComponent<WindowProps & React__default.RefAttributes<HTMLDivElement>>;
@@ -1156,6 +1290,10 @@ interface MenuItemProps {
1156
1290
  * @default false
1157
1291
  */
1158
1292
  hasSubmenu?: boolean;
1293
+ /**
1294
+ * Submenu items
1295
+ */
1296
+ items?: React__default.ReactNode;
1159
1297
  }
1160
1298
  /**
1161
1299
  * Mac OS 9 style MenuItem component
@@ -1196,6 +1334,42 @@ interface MenuItemProps {
1196
1334
  */
1197
1335
  declare const MenuItem: React__default.ForwardRefExoticComponent<MenuItemProps & React__default.RefAttributes<HTMLButtonElement>>;
1198
1336
 
1337
+ interface MenuDropdownProps {
1338
+ /**
1339
+ * Menu label (displayed in the menu bar/button)
1340
+ */
1341
+ label: React__default.ReactNode;
1342
+ /**
1343
+ * Menu items (content of the dropdown)
1344
+ */
1345
+ items: React__default.ReactNode;
1346
+ /**
1347
+ * Whether the menu is disabled
1348
+ * @default false
1349
+ */
1350
+ disabled?: boolean;
1351
+ /**
1352
+ * Custom class name for the menu container
1353
+ */
1354
+ className?: string;
1355
+ /**
1356
+ * Custom class name for menu dropdown
1357
+ */
1358
+ dropdownClassName?: string;
1359
+ /**
1360
+ * Alignment of the dropdown menu
1361
+ * @default 'left'
1362
+ */
1363
+ align?: 'left' | 'right';
1364
+ }
1365
+ /**
1366
+ * Mac OS 9 style MenuDropdown component
1367
+ *
1368
+ * A standalone dropdown menu that shares the styling of the MenuBar.
1369
+ * Useful for placing menus in the status area (rightContent) or other parts of the app.
1370
+ */
1371
+ declare const MenuDropdown: React__default.FC<MenuDropdownProps>;
1372
+
1199
1373
  interface ScrollbarProps {
1200
1374
  /**
1201
1375
  * Scrollbar orientation
@@ -1277,6 +1451,84 @@ interface ListItem {
1277
1451
  */
1278
1452
  icon?: React__default.ReactNode;
1279
1453
  }
1454
+ /**
1455
+ * Classes for targeting ListView sub-elements
1456
+ */
1457
+ interface ListViewClasses {
1458
+ /** Root container */
1459
+ root?: string;
1460
+ /** Header row container */
1461
+ header?: string;
1462
+ /** Individual header cell */
1463
+ headerCell?: string;
1464
+ /** Body container (scrollable area) */
1465
+ body?: string;
1466
+ /** Individual row */
1467
+ row?: string;
1468
+ /** Individual cell */
1469
+ cell?: string;
1470
+ }
1471
+ /**
1472
+ * Row render prop state
1473
+ */
1474
+ interface RowRenderState {
1475
+ /** Whether this row is selected */
1476
+ isSelected: boolean;
1477
+ /** Whether this row is being hovered */
1478
+ isHovered: boolean;
1479
+ /** Row index in the list */
1480
+ index: number;
1481
+ }
1482
+ /**
1483
+ * Row render prop default props
1484
+ * Spread these on your custom element for accessibility and behavior
1485
+ */
1486
+ interface RowDefaultProps {
1487
+ key: string;
1488
+ className: string;
1489
+ onClick: (e: React__default.MouseEvent) => void;
1490
+ onDoubleClick: () => void;
1491
+ onMouseEnter: () => void;
1492
+ onMouseLeave: () => void;
1493
+ 'data-selected': boolean;
1494
+ 'data-index': number;
1495
+ 'data-item-id': string;
1496
+ }
1497
+ /**
1498
+ * Cell render prop state
1499
+ */
1500
+ interface CellRenderState {
1501
+ /** Whether this cell is being hovered */
1502
+ isHovered: boolean;
1503
+ /** Whether the row containing this cell is selected */
1504
+ isRowSelected: boolean;
1505
+ /** Column index */
1506
+ columnIndex: number;
1507
+ /** Row index */
1508
+ rowIndex: number;
1509
+ }
1510
+ /**
1511
+ * Header cell render prop state
1512
+ */
1513
+ interface HeaderCellRenderState {
1514
+ /** Whether this column is currently sorted */
1515
+ isSorted: boolean;
1516
+ /** Current sort direction if sorted */
1517
+ sortDirection?: 'asc' | 'desc';
1518
+ }
1519
+ /**
1520
+ * Header cell render prop default props
1521
+ */
1522
+ interface HeaderCellDefaultProps {
1523
+ key: string;
1524
+ className: string;
1525
+ style: React__default.CSSProperties;
1526
+ onClick: () => void;
1527
+ 'data-column': string;
1528
+ 'data-sortable': boolean;
1529
+ 'data-sorted'?: boolean;
1530
+ 'data-sort-direction'?: 'asc' | 'desc';
1531
+ }
1280
1532
  interface ListViewProps {
1281
1533
  /**
1282
1534
  * Column definitions
@@ -1299,9 +1551,13 @@ interface ListViewProps {
1299
1551
  */
1300
1552
  onItemOpen?: (item: ListItem) => void;
1301
1553
  /**
1302
- * Callback when mouse enters an item
1554
+ * Callback when mouse enters an item (row-level)
1303
1555
  */
1304
1556
  onItemMouseEnter?: (item: ListItem) => void;
1557
+ /**
1558
+ * Callback when mouse leaves an item (row-level)
1559
+ */
1560
+ onItemMouseLeave?: (item: ListItem) => void;
1305
1561
  /**
1306
1562
  * Callback when column is clicked for sorting
1307
1563
  */
@@ -1314,6 +1570,47 @@ interface ListViewProps {
1314
1570
  * Height of the list view
1315
1571
  */
1316
1572
  height?: number | string;
1573
+ /**
1574
+ * Custom classes for targeting sub-elements
1575
+ */
1576
+ classes?: ListViewClasses;
1577
+ /**
1578
+ * Override row rendering
1579
+ * @param item - The list item
1580
+ * @param state - Row state (selected, hovered, index)
1581
+ * @param defaultProps - Props to spread on custom element for accessibility
1582
+ * @returns Custom row element (fully replaces default)
1583
+ */
1584
+ renderRow?: (item: ListItem, state: RowRenderState, defaultProps: RowDefaultProps) => React__default.ReactNode;
1585
+ /**
1586
+ * Override cell rendering
1587
+ * @param value - Cell value (item[columnKey])
1588
+ * @param item - Full item object
1589
+ * @param column - Column definition
1590
+ * @param state - Cell state (hovered, selected row, indices)
1591
+ * @returns Custom cell content (fully replaces default)
1592
+ */
1593
+ renderCell?: (value: any, item: ListItem, column: ListColumn, state: CellRenderState) => React__default.ReactNode;
1594
+ /**
1595
+ * Override header cell rendering
1596
+ * @param column - Column definition
1597
+ * @param state - Header state (sorted, direction)
1598
+ * @param defaultProps - Props to spread on custom element
1599
+ * @returns Custom header cell element (fully replaces default)
1600
+ */
1601
+ renderHeaderCell?: (column: ListColumn, state: HeaderCellRenderState, defaultProps: HeaderCellDefaultProps) => React__default.ReactNode;
1602
+ /**
1603
+ * Callback when a cell is clicked
1604
+ */
1605
+ onCellClick?: (item: ListItem, column: ListColumn, event: React__default.MouseEvent) => void;
1606
+ /**
1607
+ * Callback when mouse enters a cell
1608
+ */
1609
+ onCellMouseEnter?: (item: ListItem, column: ListColumn) => void;
1610
+ /**
1611
+ * Callback when mouse leaves a cell
1612
+ */
1613
+ onCellMouseLeave?: (item: ListItem, column: ListColumn) => void;
1317
1614
  }
1318
1615
  /**
1319
1616
  * Mac OS 9 style ListView component
@@ -1341,12 +1638,56 @@ interface ListViewProps {
1341
1638
  */
1342
1639
  declare const ListView: React__default.ForwardRefExoticComponent<ListViewProps & React__default.RefAttributes<HTMLDivElement>>;
1343
1640
 
1344
- interface FolderListProps extends Omit<WindowProps, 'children'> {
1641
+ /**
1642
+ * Classes for targeting FolderList sub-elements
1643
+ */
1644
+ interface FolderListClasses {
1645
+ /** Root window container */
1646
+ root?: string;
1647
+ /** Window component */
1648
+ window?: string;
1649
+ /** Title bar */
1650
+ titleBar?: string;
1651
+ /** ListView container */
1652
+ listView?: string;
1653
+ /** ListView header */
1654
+ header?: string;
1655
+ /** ListView header cell */
1656
+ headerCell?: string;
1657
+ /** ListView body */
1658
+ body?: string;
1659
+ /** ListView row */
1660
+ row?: string;
1661
+ /** ListView cell */
1662
+ cell?: string;
1663
+ }
1664
+ interface FolderListProps extends Omit<WindowProps, 'children' | 'classes'> {
1345
1665
  /**
1346
1666
  * Column definitions for the list
1347
1667
  * @default [{ key: 'name', label: 'Name' }, { key: 'modified', label: 'Date Modified' }, { key: 'size', label: 'Size' }]
1348
1668
  */
1349
1669
  columns?: ListColumn[];
1670
+ /**
1671
+ * Whether the folder list window can be dragged by its title bar
1672
+ * Window starts in normal flow and becomes absolutely positioned when dragged
1673
+ * @default false
1674
+ */
1675
+ draggable?: boolean;
1676
+ /**
1677
+ * Initial position for draggable folder lists (uncontrolled)
1678
+ * Only used when draggable is true
1679
+ */
1680
+ defaultPosition?: WindowPosition;
1681
+ /**
1682
+ * Controlled position for draggable folder lists
1683
+ * Only used when draggable is true
1684
+ */
1685
+ position?: WindowPosition;
1686
+ /**
1687
+ * Callback when folder list position changes (during drag)
1688
+ * Only called when draggable is true
1689
+ */
1690
+ onPositionChange?: (position: WindowPosition) => void;
1350
1691
  /**
1351
1692
  * Items to display in the list
1352
1693
  */
@@ -1364,9 +1705,13 @@ interface FolderListProps extends Omit<WindowProps, 'children'> {
1364
1705
  */
1365
1706
  onItemOpen?: (item: ListItem) => void;
1366
1707
  /**
1367
- * Callback when mouse enters an item
1708
+ * Callback when mouse enters an item (row-level)
1368
1709
  */
1369
1710
  onItemMouseEnter?: (item: ListItem) => void;
1711
+ /**
1712
+ * Callback when mouse leaves an item (row-level)
1713
+ */
1714
+ onItemMouseLeave?: (item: ListItem) => void;
1370
1715
  /**
1371
1716
  * Callback when column header is clicked for sorting
1372
1717
  */
@@ -1380,6 +1725,47 @@ interface FolderListProps extends Omit<WindowProps, 'children'> {
1380
1725
  * @default 400
1381
1726
  */
1382
1727
  listHeight?: number | string;
1728
+ /**
1729
+ * Custom classes for targeting sub-elements
1730
+ */
1731
+ classes?: FolderListClasses;
1732
+ /**
1733
+ * Override row rendering
1734
+ * @param item - The list item
1735
+ * @param state - Row state (selected, hovered, index)
1736
+ * @param defaultProps - Props to spread on custom element for accessibility
1737
+ * @returns Custom row element (fully replaces default)
1738
+ */
1739
+ renderRow?: (item: ListItem, state: RowRenderState, defaultProps: RowDefaultProps) => React__default.ReactNode;
1740
+ /**
1741
+ * Override cell rendering
1742
+ * @param value - Cell value (item[columnKey])
1743
+ * @param item - Full item object
1744
+ * @param column - Column definition
1745
+ * @param state - Cell state (hovered, selected row, indices)
1746
+ * @returns Custom cell content (fully replaces default)
1747
+ */
1748
+ renderCell?: (value: any, item: ListItem, column: ListColumn, state: CellRenderState) => React__default.ReactNode;
1749
+ /**
1750
+ * Override header cell rendering
1751
+ * @param column - Column definition
1752
+ * @param state - Header state (sorted, direction)
1753
+ * @param defaultProps - Props to spread on custom element
1754
+ * @returns Custom header cell element (fully replaces default)
1755
+ */
1756
+ renderHeaderCell?: (column: ListColumn, state: HeaderCellRenderState, defaultProps: HeaderCellDefaultProps) => React__default.ReactNode;
1757
+ /**
1758
+ * Callback when a cell is clicked
1759
+ */
1760
+ onCellClick?: (item: ListItem, column: ListColumn, event: React__default.MouseEvent) => void;
1761
+ /**
1762
+ * Callback when mouse enters a cell
1763
+ */
1764
+ onCellMouseEnter?: (item: ListItem, column: ListColumn) => void;
1765
+ /**
1766
+ * Callback when mouse leaves a cell
1767
+ */
1768
+ onCellMouseLeave?: (item: ListItem, column: ListColumn) => void;
1383
1769
  }
1384
1770
  /**
1385
1771
  * Mac OS 9 style FolderList component
@@ -1389,6 +1775,7 @@ interface FolderListProps extends Omit<WindowProps, 'children'> {
1389
1775
  *
1390
1776
  * @example
1391
1777
  * ```tsx
1778
+ * // Basic folder list
1392
1779
  * <FolderList
1393
1780
  * title="My Documents"
1394
1781
  * items={[
@@ -1398,8 +1785,14 @@ interface FolderListProps extends Omit<WindowProps, 'children'> {
1398
1785
  * selectedIds={['1']}
1399
1786
  * onSelectionChange={(ids) => console.log('Selected:', ids)}
1400
1787
  * onItemOpen={(item) => console.log('Open:', item.name)}
1401
- * onItemMouseEnter={(item) => console.log('Hovering:', item.name)}
1402
- * onMouseEnter={(e) => console.log('Mouse entered folder list')}
1788
+ * />
1789
+ *
1790
+ * // Draggable folder list
1791
+ * <FolderList
1792
+ * title="My Documents"
1793
+ * items={items}
1794
+ * draggable
1795
+ * defaultPosition={{ x: 100, y: 100 }}
1403
1796
  * />
1404
1797
  * ```
1405
1798
  */
@@ -1743,36 +2136,34 @@ declare const tokens: {
1743
2136
  };
1744
2137
 
1745
2138
  /**
1746
- * Base component props that all components should extend
1747
- */
1748
- interface BaseComponentProps {
1749
- /** Additional CSS class name */
1750
- className?: string;
1751
- /** Inline styles */
1752
- style?: React.CSSProperties;
1753
- /** Test ID for testing purposes */
1754
- 'data-testid'?: string;
1755
- }
1756
- /**
1757
- * Common variant types for Mac OS 9 components
1758
- */
1759
- type Variant = 'default' | 'primary' | 'secondary';
1760
- /**
1761
- * Common size types
2139
+ * Merges multiple class names into a single string
2140
+ * Filters out undefined, null, false, and empty strings
2141
+ *
2142
+ * @param classes - Class names to merge
2143
+ * @returns Merged class name string
2144
+ *
2145
+ * @example
2146
+ * ```ts
2147
+ * mergeClasses('base', isActive && 'active', undefined, 'custom')
2148
+ * // Returns: "base active custom"
2149
+ * ```
1762
2150
  */
1763
- type Size = 'small' | 'medium' | 'large';
2151
+ declare const mergeClasses: (...classes: (string | undefined | false | null)[]) => string;
1764
2152
  /**
1765
- * Common state types
1766
- */
1767
- type State = 'default' | 'hover' | 'active' | 'disabled' | 'focused';
1768
- /**
1769
- * Component ref types
2153
+ * Creates a class name builder function with a base class
2154
+ * Useful for component-level class management
2155
+ *
2156
+ * @param baseClass - Base class name
2157
+ * @returns Function that merges additional classes with base
2158
+ *
2159
+ * @example
2160
+ * ```ts
2161
+ * const cn = createClassBuilder('button');
2162
+ * cn('primary', isDisabled && 'disabled')
2163
+ * // Returns: "button primary disabled"
2164
+ * ```
1770
2165
  */
1771
- type ButtonRef = HTMLButtonElement;
1772
- type InputRef = HTMLInputElement;
1773
- type SelectRef = HTMLSelectElement;
1774
- type TextAreaRef = HTMLTextAreaElement;
1775
- type DivRef = HTMLDivElement;
2166
+ declare const createClassBuilder: (baseClass: string) => (...additionalClasses: (string | undefined | false | null)[]) => string;
1776
2167
 
1777
- export { Button, Checkbox, Dialog, DividerIcon, FolderList, Icon, IconButton, IconLibrary, ListView, MenuBar, MenuItem, Radio, Scrollbar, Select, TabPanel, Tabs, TextField, Window, borders, colors, shadows, spacing, tokens, transitions, typography, zIndex };
1778
- export type { BaseComponentProps, ButtonProps, ButtonRef, CheckboxProps, DialogProps, DivRef, FolderListProps, IconButtonProps, IconLibraryProps, IconName, IconProps, InputRef, ListColumn, ListItem, ListViewProps, Menu, MenuBarProps, MenuItemProps, RadioProps, ScrollbarProps, SelectOption, SelectProps, SelectRef, Size, State, TabPanelProps, TabsProps, TextAreaRef, TextFieldProps, Variant, WindowProps };
2168
+ export { Button, Checkbox, Dialog, DividerIcon, FolderList, Icon, IconButton, IconLibrary, ListView, MenuBar, MenuDropdown, MenuItem, Radio, Scrollbar, Select, TabPanel, Tabs, TextField, Window, borders, colors, createClassBuilder, mergeClasses, shadows, spacing, tokens, transitions, typography, zIndex };
2169
+ export type { BaseComponentProps, ButtonProps, ButtonRef, CellRenderState, CheckboxProps, ComponentClasses, DialogProps, DivRef, FolderListClasses, FolderListProps, HeaderCellDefaultProps, HeaderCellRenderState, IconButtonProps, IconLibraryProps, IconName, IconProps, InputRef, ListColumn, ListItem, ListViewClasses, ListViewProps, Menu, MenuBarProps, MenuDropdownProps, MenuItemProps, RadioProps, RenderState, RowDefaultProps, RowRenderState, ScrollbarProps, SelectOption, SelectProps, SelectRef, Size, State, TabPanelProps, TabsProps, TextAreaRef, TextFieldProps, Variant, WindowClasses, WindowPosition, WindowProps };