@graphty/compact-mantine 0.4.0 → 0.5.1

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
@@ -1,10 +1,14 @@
1
+ import { ActionIconProps } from '@mantine/core';
1
2
  import { default as default_2 } from 'react';
3
+ import { ForwardRefExoticComponent } from 'react';
2
4
  import { JSX } from 'react';
3
5
  import { MantineColorShade } from '@mantine/core';
4
6
  import { MantineColorsTuple } from '@mantine/core';
5
7
  import { MantineRadius } from '@mantine/core';
8
+ import { MantineTheme } from '@mantine/core';
6
9
  import { ReactNode } from 'react';
7
10
  import { ReactPortal } from 'react';
11
+ import { RefAttributes } from 'react';
8
12
  import { RefObject } from 'react';
9
13
  import { VariantColorsResolver } from '@mantine/core';
10
14
 
@@ -20,6 +24,33 @@ export declare interface ColorStop {
20
24
  color: string;
21
25
  }
22
26
 
27
+ /**
28
+ * Compact theme sizing constants.
29
+ * These values represent the standard sizing used throughout the compact theme
30
+ * for consistent component dimensions. Use these when creating custom components
31
+ * that need to match the compact theme's sizing.
32
+ * @example
33
+ * ```tsx
34
+ * import { COMPACT_SIZING } from '@graphty/compact-mantine';
35
+ *
36
+ * const MyComponent = () => (
37
+ * <div style={{ height: COMPACT_SIZING.HEIGHT, fontSize: COMPACT_SIZING.FONT_SIZE }}>
38
+ * Custom compact component
39
+ * </div>
40
+ * );
41
+ * ```
42
+ */
43
+ export declare const COMPACT_SIZING: {
44
+ /** Standard compact component height (inputs, buttons, icons) in pixels */
45
+ readonly HEIGHT: 24;
46
+ /** Standard compact font size in pixels */
47
+ readonly FONT_SIZE: 11;
48
+ /** Standard padding for control elements in pixels */
49
+ readonly CONTROL_PADDING: 8;
50
+ /** Gap between items in sections/lists in pixels */
51
+ readonly SECTION_GAP: 4;
52
+ };
53
+
23
54
  /**
24
55
  * Compact color input with optional opacity support.
25
56
  * Supports both controlled and uncontrolled modes.
@@ -64,9 +95,23 @@ export declare interface CompactColorInputProps {
64
95
 
65
96
  /**
66
97
  * Color configuration for the compact theme.
98
+ * Includes all default Mantine colors plus custom dark palette.
67
99
  */
68
100
  export declare const compactColors: {
69
101
  dark: MantineColorsTuple;
102
+ gray: MantineColorsTuple;
103
+ red: MantineColorsTuple;
104
+ pink: MantineColorsTuple;
105
+ grape: MantineColorsTuple;
106
+ violet: MantineColorsTuple;
107
+ indigo: MantineColorsTuple;
108
+ blue: MantineColorsTuple;
109
+ cyan: MantineColorsTuple;
110
+ green: MantineColorsTuple;
111
+ lime: MantineColorsTuple;
112
+ yellow: MantineColorsTuple;
113
+ orange: MantineColorsTuple;
114
+ teal: MantineColorsTuple;
70
115
  };
71
116
 
72
117
  /**
@@ -81,49 +126,79 @@ export declare const compactColors: {
81
126
  export declare const compactDarkColors: MantineColorsTuple;
82
127
 
83
128
  /**
84
- * Mantine theme with "compact" size support for dense UIs.
129
+ * Full Mantine theme with compact sizing by default for dense UIs.
85
130
  *
86
- * Compact size specifications:
131
+ * This is a complete theme merged with DEFAULT_THEME, suitable for:
132
+ * - Direct use with MantineProvider
133
+ * - Merging with other themes using mergeMantineTheme()
134
+ *
135
+ * All components default to size="sm" automatically with compact styling:
87
136
  * - Input height: 24px
88
137
  * - Font size: 11px
89
138
  * - No borders
90
139
  * - Semantic color backgrounds
140
+ *
141
+ * Global token overrides:
142
+ * - fontSizes: Smaller font sizes (xs: 10px, sm: 11px, md: 13px, lg: 14px, xl: 16px)
143
+ * - spacing: Tighter spacing (xs: 4px, sm: 6px, md: 8px, lg: 12px, xl: 16px)
144
+ * - radius: Compact corner radii (xs: 2px, sm: 4px, md: 6px, lg: 8px, xl: 12px)
145
+ * @example
146
+ * ```tsx
147
+ * // Simple usage - direct with MantineProvider
148
+ * import { MantineProvider } from '@mantine/core';
149
+ * import { compactTheme } from '@graphty/compact-mantine';
150
+ *
151
+ * <MantineProvider theme={compactTheme}>
152
+ * <App />
153
+ * </MantineProvider>
154
+ * ```
91
155
  * @example
92
156
  * ```tsx
93
- * import { MantineProvider, TextInput } from '@mantine/core';
157
+ * // Extending the theme with mergeMantineTheme
158
+ * import { mergeMantineTheme, createTheme } from '@mantine/core';
94
159
  * import { compactTheme } from '@graphty/compact-mantine';
95
160
  *
96
- * function App() {
97
- * return (
98
- * <MantineProvider theme={compactTheme}>
99
- * <TextInput size="compact" label="Name" />
100
- * </MantineProvider>
101
- * );
102
- * }
161
+ * const myTheme = mergeMantineTheme(compactTheme, createTheme({
162
+ * primaryColor: 'teal',
163
+ * }));
164
+ *
165
+ * <MantineProvider theme={myTheme}>
166
+ * <App />
167
+ * </MantineProvider>
103
168
  * ```
104
169
  */
105
- export declare const compactTheme: {
106
- focusRing?: "auto" | "always" | "never" | undefined;
170
+ export declare const compactTheme: MantineTheme;
171
+
172
+ /**
173
+ * Partial theme override with compact sizing for dense UIs.
174
+ *
175
+ * This is the raw theme override created with createTheme().
176
+ * Use this if you need to merge with other theme overrides using mergeThemeOverrides().
177
+ *
178
+ * For most use cases, use `compactTheme` instead which is a full merged theme.
179
+ */
180
+ export declare const compactThemeOverride: {
181
+ focusRing?: "auto" | "never" | "always" | undefined;
107
182
  scale?: number | undefined;
108
183
  fontSmoothing?: boolean | undefined;
109
184
  white?: string | undefined;
110
185
  black?: string | undefined;
111
186
  colors?: {
112
187
  [x: string & {}]: MantineColorsTuple | undefined;
188
+ dark?: MantineColorsTuple | undefined;
189
+ gray?: MantineColorsTuple | undefined;
190
+ red?: MantineColorsTuple | undefined;
191
+ pink?: MantineColorsTuple | undefined;
192
+ grape?: MantineColorsTuple | undefined;
193
+ violet?: MantineColorsTuple | undefined;
194
+ indigo?: MantineColorsTuple | undefined;
113
195
  blue?: MantineColorsTuple | undefined;
114
196
  cyan?: MantineColorsTuple | undefined;
115
- gray?: MantineColorsTuple | undefined;
116
197
  green?: MantineColorsTuple | undefined;
117
- indigo?: MantineColorsTuple | undefined;
118
198
  lime?: MantineColorsTuple | undefined;
199
+ yellow?: MantineColorsTuple | undefined;
119
200
  orange?: MantineColorsTuple | undefined;
120
- pink?: MantineColorsTuple | undefined;
121
- red?: MantineColorsTuple | undefined;
122
201
  teal?: MantineColorsTuple | undefined;
123
- violet?: MantineColorsTuple | undefined;
124
- yellow?: MantineColorsTuple | undefined;
125
- dark?: MantineColorsTuple | undefined;
126
- grape?: MantineColorsTuple | undefined;
127
202
  } | undefined;
128
203
  primaryShade?: MantineColorShade | {
129
204
  light?: MantineColorShade | undefined;
@@ -251,9 +326,10 @@ export declare const compactTheme: {
251
326
  * @param root0.label - The label text for the group header
252
327
  * @param root0.actions - Optional action buttons to display in the header
253
328
  * @param root0.children - Child controls to render in the group
329
+ * @param root0.bleed - When true, separator line extends to parent container edges
254
330
  * @returns The control group component
255
331
  */
256
- export declare function ControlGroup({ label, actions, children }: ControlGroupProps): default_2.JSX.Element;
332
+ export declare function ControlGroup({ label, actions, children, bleed }: ControlGroupProps): default_2.JSX.Element;
257
333
 
258
334
  /**
259
335
  * Props for the ControlGroup component.
@@ -265,6 +341,12 @@ export declare interface ControlGroupProps {
265
341
  actions?: ReactNode;
266
342
  /** Group content */
267
343
  children: ReactNode;
344
+ /**
345
+ * When true, the separator line extends beyond the component boundaries
346
+ * to reach the edges of the parent container (useful inside Popouts with padding).
347
+ * Uses negative margins to counteract the parent's padding.
348
+ */
349
+ bleed?: boolean;
268
350
  }
269
351
 
270
352
  /**
@@ -342,38 +424,6 @@ export declare function createDefaultGradientStops(): ColorStop[];
342
424
  */
343
425
  export declare const DEFAULT_GRADIENT_STOP_COLOR = "#888888";
344
426
 
345
- /**
346
- * A checkbox toggle that shows/hides child controls.
347
- * Supports both controlled and uncontrolled modes.
348
- * Used for enabling/disabling effects like glow and outline.
349
- * Provides clean visual indent for child content.
350
- * @param root0 - Component props
351
- * @param root0.label - The label for the toggle checkbox
352
- * @param root0.checked - Whether the toggle is checked (controlled mode)
353
- * @param root0.defaultChecked - Default checked state for uncontrolled mode
354
- * @param root0.onChange - Called when the toggle state changes (optional for uncontrolled mode)
355
- * @param root0.children - Child controls to show when checked
356
- * @returns The effect toggle component
357
- */
358
- export declare function EffectToggle({ label, checked, defaultChecked, onChange, children, }: EffectToggleProps): default_2.JSX.Element;
359
-
360
- /**
361
- * Props for EffectToggle component.
362
- * Supports both controlled and uncontrolled modes via useUncontrolled pattern.
363
- */
364
- export declare interface EffectToggleProps {
365
- /** Checkbox label */
366
- label: string;
367
- /** Whether effect is enabled (controlled mode) */
368
- checked?: boolean;
369
- /** Default checked state for uncontrolled mode */
370
- defaultChecked?: boolean;
371
- /** Called when checked state changes (optional for uncontrolled mode) */
372
- onChange?: (checked: boolean) => void;
373
- /** Content shown when checked */
374
- children: ReactNode;
375
- }
376
-
377
427
  /**
378
428
  * Editor for gradient color stops with optional direction control.
379
429
  * Supports both controlled and uncontrolled modes.
@@ -468,6 +518,7 @@ export declare const Popout: typeof PopoutRoot & {
468
518
  Trigger: typeof PopoutTrigger;
469
519
  Panel: typeof PopoutPanel;
470
520
  Content: typeof PopoutContent;
521
+ Anchor: typeof PopoutAnchor;
471
522
  };
472
523
 
473
524
  /**
@@ -495,6 +546,72 @@ export declare const POPOUT_Z_INDEX_BASE = 1000;
495
546
  */
496
547
  declare type PopoutAlignment = "start" | "center" | "end";
497
548
 
549
+ /**
550
+ * Provides an anchor element for descendant Popout panels to align to.
551
+ *
552
+ * When a Popout.Panel is inside a PopoutAnchor and doesn't have an explicit
553
+ * `anchorRef` prop, it will automatically align to the anchor element.
554
+ *
555
+ * This is useful for sidebars, control panels, or any container where you
556
+ * want popouts to align to the container edge rather than just the trigger.
557
+ * @param props - Component props
558
+ * @param props.children - The container element (must accept a ref)
559
+ * @returns The PopoutAnchor component
560
+ * @example
561
+ * ```tsx
562
+ * <Popout.Anchor>
563
+ * <Box style={{ width: 240, borderLeft: '1px solid gray' }}>
564
+ * <Popout>
565
+ * <Popout.Trigger>
566
+ * <PopoutButton icon={<Settings />} aria-label="Settings" />
567
+ * </Popout.Trigger>
568
+ * <Popout.Panel width={280} header={{ variant: "title", title: "Settings" }}>
569
+ * <Popout.Content>Content aligns to sidebar edge</Popout.Content>
570
+ * </Popout.Panel>
571
+ * </Popout>
572
+ * </Box>
573
+ * </Popout.Anchor>
574
+ * ```
575
+ */
576
+ declare function PopoutAnchor({ children }: PopoutAnchorProps): JSX.Element;
577
+
578
+ /**
579
+ * Props for PopoutAnchor.
580
+ */
581
+ declare interface PopoutAnchorProps {
582
+ /** The container element to use as anchor. Must accept a ref. */
583
+ children: ReactNode;
584
+ }
585
+
586
+ /**
587
+ * A button component designed to be used as a Popout trigger.
588
+ * Automatically highlights when the associated popout is open.
589
+ * Features:
590
+ * - Uses `subtle` variant when popout is closed (dimmed appearance)
591
+ * - Uses `light` variant when popout is open (highlighted appearance)
592
+ * - Must be used within a Popout component (inside Popout.Trigger)
593
+ * @example
594
+ * ```tsx
595
+ * <Popout>
596
+ * <Popout.Trigger>
597
+ * <PopoutButton icon={<Settings size={12} />} aria-label="Open settings" />
598
+ * </Popout.Trigger>
599
+ * <Popout.Panel width={280} header={{ variant: "title", title: "Settings" }}>
600
+ * <Popout.Content>Content here</Popout.Content>
601
+ * </Popout.Panel>
602
+ * </Popout>
603
+ * ```
604
+ */
605
+ export declare const PopoutButton: ForwardRefExoticComponent<PopoutButtonProps & RefAttributes<HTMLButtonElement>>;
606
+
607
+ /**
608
+ * Props for the PopoutButton component.
609
+ */
610
+ declare interface PopoutButtonProps extends Omit<ActionIconProps, "variant" | "children"> {
611
+ /** The icon to display inside the button */
612
+ icon: ReactNode;
613
+ }
614
+
498
615
  /**
499
616
  * Container for popout panel content.
500
617
  * Provides consistent padding and styling for panel content.
@@ -898,18 +1015,45 @@ export declare interface StyleSelectProps {
898
1015
  onChange?: (value: string | undefined) => void;
899
1016
  }
900
1017
 
901
- /**
902
- * Standard color swatches for color pickers throughout the application.
903
- * Used by CompactColorInput and GradientEditor.
904
- */
905
- export declare const SWATCH_COLORS: readonly ["#5B8FF9", "#FF6B6B", "#61D095", "#F7B731", "#9B59B6"];
906
-
907
1018
  /**
908
1019
  * Swatches with alpha channel for HEXA color pickers.
909
1020
  * Includes both fully opaque (FF) and semi-transparent (80) variants.
1021
+ * Used by CompactColorInput for color picker swatches.
910
1022
  */
911
1023
  export declare const SWATCH_COLORS_HEXA: readonly ["#5B8FF9FF", "#FF6B6BFF", "#61D095FF", "#F7B731FF", "#9B59B6FF", "#5B8FF980", "#FF6B6B80", "#61D09580", "#F7B73180", "#9B59B680"];
912
1024
 
1025
+ /**
1026
+ * A checkbox toggle that shows/hides child controls.
1027
+ * Supports both controlled and uncontrolled modes.
1028
+ * Used for enabling/disabling optional features with nested configuration.
1029
+ * Provides clean visual indent for child content.
1030
+ * @param root0 - Component props
1031
+ * @param root0.label - The label for the toggle checkbox
1032
+ * @param root0.checked - Whether the toggle is checked (controlled mode)
1033
+ * @param root0.defaultChecked - Default checked state for uncontrolled mode
1034
+ * @param root0.onChange - Called when the toggle state changes (optional for uncontrolled mode)
1035
+ * @param root0.children - Child controls to show when checked
1036
+ * @returns The toggle with content component
1037
+ */
1038
+ export declare function ToggleWithContent({ label, checked, defaultChecked, onChange, children, }: ToggleWithContentProps): default_2.JSX.Element;
1039
+
1040
+ /**
1041
+ * Props for ToggleWithContent component.
1042
+ * Supports both controlled and uncontrolled modes via useUncontrolled pattern.
1043
+ */
1044
+ export declare interface ToggleWithContentProps {
1045
+ /** Checkbox label */
1046
+ label: string;
1047
+ /** Whether toggle is enabled (controlled mode) */
1048
+ checked?: boolean;
1049
+ /** Default checked state for uncontrolled mode */
1050
+ defaultChecked?: boolean;
1051
+ /** Called when checked state changes (optional for uncontrolled mode) */
1052
+ onChange?: (checked: boolean) => void;
1053
+ /** Content shown when checked */
1054
+ children: ReactNode;
1055
+ }
1056
+
913
1057
  /**
914
1058
  * Convert RGB hex and opacity to HEXA format.
915
1059
  * @param hex - Color in hex format (#RRGGBB)
@@ -921,9 +1065,17 @@ export declare function toHexaColor(hex: string, opacity: number): string;
921
1065
  /**
922
1066
  * Hook to get the actual resolved color scheme.
923
1067
  * Resolves "auto" to the actual light/dark value based on system preference.
924
- * @returns "light" | "dark"
1068
+ * @param fallback - Fallback color scheme when system preference cannot be determined.
1069
+ * Defaults to "dark" for consistency with existing behavior.
1070
+ * @returns "light" | "dark" - The resolved color scheme
1071
+ * @example
1072
+ * // Use default fallback (dark)
1073
+ * const scheme = useActualColorScheme();
1074
+ * @example
1075
+ * // Use custom fallback
1076
+ * const scheme = useActualColorScheme("light");
925
1077
  */
926
- export declare function useActualColorScheme(): "light" | "dark";
1078
+ export declare function useActualColorScheme(fallback?: "light" | "dark"): "light" | "dark";
927
1079
 
928
1080
  export declare const VERSION = "0.1.0";
929
1081