@mantine/code-highlight 7.13.5-alpha.1 → 7.13.5-alpha.2

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 (50) hide show
  1. package/cjs/CodeHighlight.cjs +65 -0
  2. package/cjs/CodeHighlight.cjs.map +1 -0
  3. package/cjs/CodeHighlight.module.css.cjs +7 -0
  4. package/cjs/CodeHighlight.module.css.cjs.map +1 -0
  5. package/cjs/CodeHighlight.theme.module.css.cjs +7 -0
  6. package/cjs/CodeHighlight.theme.module.css.cjs.map +1 -0
  7. package/cjs/CodeHighlightTabs.cjs +171 -0
  8. package/cjs/CodeHighlightTabs.cjs.map +1 -0
  9. package/cjs/CopyIcon.cjs +34 -0
  10. package/cjs/CopyIcon.cjs.map +1 -0
  11. package/cjs/ExpandIcon.cjs +40 -0
  12. package/cjs/ExpandIcon.cjs.map +1 -0
  13. package/cjs/FileIcon.cjs +17 -0
  14. package/cjs/FileIcon.cjs.map +1 -0
  15. package/cjs/InlineCodeHighlight.cjs +49 -0
  16. package/cjs/InlineCodeHighlight.cjs.map +1 -0
  17. package/cjs/index.cjs +12 -0
  18. package/cjs/index.cjs.map +1 -0
  19. package/cjs/use-highlight.cjs +32 -0
  20. package/cjs/use-highlight.cjs.map +1 -0
  21. package/esm/CodeHighlight.mjs +59 -0
  22. package/esm/CodeHighlight.mjs.map +1 -0
  23. package/esm/CodeHighlight.module.css.mjs +5 -0
  24. package/esm/CodeHighlight.module.css.mjs.map +1 -0
  25. package/esm/CodeHighlight.theme.module.css.mjs +5 -0
  26. package/esm/CodeHighlight.theme.module.css.mjs.map +1 -0
  27. package/esm/CodeHighlightTabs.mjs +164 -0
  28. package/esm/CodeHighlightTabs.mjs.map +1 -0
  29. package/esm/CopyIcon.mjs +32 -0
  30. package/esm/CopyIcon.mjs.map +1 -0
  31. package/esm/ExpandIcon.mjs +38 -0
  32. package/esm/ExpandIcon.mjs.map +1 -0
  33. package/esm/FileIcon.mjs +15 -0
  34. package/esm/FileIcon.mjs.map +1 -0
  35. package/esm/InlineCodeHighlight.mjs +42 -0
  36. package/esm/InlineCodeHighlight.mjs.map +1 -0
  37. package/esm/index.mjs +4 -0
  38. package/esm/index.mjs.map +1 -0
  39. package/esm/use-highlight.mjs +26 -0
  40. package/esm/use-highlight.mjs.map +1 -0
  41. package/lib/CodeHighlight.d.ts +26 -0
  42. package/lib/CodeHighlightTabs.d.ts +55 -0
  43. package/lib/CopyIcon.d.ts +8 -0
  44. package/lib/ExpandIcon.d.ts +5 -0
  45. package/lib/FileIcon.d.ts +9 -0
  46. package/lib/InlineCodeHighlight.d.ts +18 -0
  47. package/lib/index.d.mts +6 -0
  48. package/lib/index.d.ts +6 -0
  49. package/lib/use-highlight.d.ts +15 -0
  50. package/package.json +3 -3
@@ -0,0 +1,55 @@
1
+ import { BoxProps, ElementProps, Factory, StylesApiProps } from '@mantine/core';
2
+ export type CodeHighlightTabsStylesNames = 'root' | 'code' | 'codeWrapper' | 'showCodeButton' | 'pre' | 'controls' | 'control' | 'header' | 'file' | 'files' | 'fileIcon';
3
+ export type CodeHighlightTabsCssVariables = {
4
+ root: '--ch-max-collapsed-height';
5
+ };
6
+ export interface CodeHighlightTabsCode {
7
+ language?: string;
8
+ code: string;
9
+ fileName?: string;
10
+ icon?: React.ReactNode;
11
+ }
12
+ export interface CodeHighlightTabsProps extends BoxProps, StylesApiProps<CodeHighlightTabsFactory>, ElementProps<'div'> {
13
+ /** Code to highlight with meta data (file name and icon) */
14
+ code: CodeHighlightTabsCode | CodeHighlightTabsCode[];
15
+ /** Default active tab index */
16
+ defaultActiveTab?: number;
17
+ /** Index of controlled active tab state */
18
+ activeTab?: number;
19
+ /** Called when tab changes */
20
+ onTabChange?: (tab: number) => void;
21
+ /** Determines whether header with file names and copy button should be rendered, `true` by default */
22
+ withHeader?: boolean;
23
+ /** Copy tooltip label, `'Copy code'` by default */
24
+ copyLabel?: string;
25
+ /** Copied tooltip label, `'Copied'` by default */
26
+ copiedLabel?: string;
27
+ /** Function that returns icon based on file name */
28
+ getFileIcon?: (fileName: string) => React.ReactNode;
29
+ /** `max-height` of code in collapsed state */
30
+ maxCollapsedHeight?: React.CSSProperties['maxHeight'];
31
+ /** Controlled expanded state */
32
+ expanded?: boolean;
33
+ /** Uncontrolled expanded state initial value */
34
+ defaultExpanded?: boolean;
35
+ /** Called when expanded state changes */
36
+ onExpandedChange?: (expanded: boolean) => void;
37
+ /** Expand button label and tooltip, `'Expand code'` by default */
38
+ expandCodeLabel?: string;
39
+ /** Collapse button label and tooltip, `'Collapse code'` by default */
40
+ collapseCodeLabel?: string;
41
+ /** Determines whether to show the expand button, `false` by default */
42
+ withExpandButton?: boolean;
43
+ /** Determines whether copy button should be displayed, `true` by default */
44
+ withCopyButton?: boolean;
45
+ }
46
+ export type CodeHighlightTabsFactory = Factory<{
47
+ props: CodeHighlightTabsProps;
48
+ ref: HTMLDivElement;
49
+ stylesNames: CodeHighlightTabsStylesNames;
50
+ }>;
51
+ export declare const CodeHighlightTabs: import("@mantine/core").MantineComponent<{
52
+ props: CodeHighlightTabsProps;
53
+ ref: HTMLDivElement;
54
+ stylesNames: CodeHighlightTabsStylesNames;
55
+ }>;
@@ -0,0 +1,8 @@
1
+ interface CopyIconProps extends React.ComponentPropsWithoutRef<'svg'> {
2
+ copied: boolean;
3
+ }
4
+ export declare function CopyIcon({ copied, style, ...others }: CopyIconProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare namespace CopyIcon {
6
+ var displayName: string;
7
+ }
8
+ export {};
@@ -0,0 +1,5 @@
1
+ interface ExpandIconProps extends React.ComponentPropsWithoutRef<'svg'> {
2
+ expanded: boolean;
3
+ }
4
+ export declare function ExpandIcon({ expanded, style, ...others }: ExpandIconProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,9 @@
1
+ interface FileIconProps {
2
+ fileName: string | undefined;
3
+ getFileIcon?: ((fileName: string) => React.ReactNode) | undefined;
4
+ fileIcon: React.ReactNode | undefined;
5
+ className?: string;
6
+ style?: React.CSSProperties;
7
+ }
8
+ export declare function FileIcon({ fileIcon, fileName, getFileIcon, className, style }: FileIconProps): import("react/jsx-runtime").JSX.Element | null;
9
+ export {};
@@ -0,0 +1,18 @@
1
+ import { BoxProps, ElementProps, Factory, StylesApiProps } from '@mantine/core';
2
+ export type InlineCodeHighlightStylesNames = 'code';
3
+ export interface InlineCodeHighlightProps extends BoxProps, StylesApiProps<InlineCodeHighlightFactory>, ElementProps<'div'> {
4
+ /** Code to highlight */
5
+ code: string;
6
+ /** Code language, `'tsx'` by default */
7
+ language?: string;
8
+ }
9
+ export type InlineCodeHighlightFactory = Factory<{
10
+ props: InlineCodeHighlightProps;
11
+ ref: HTMLElement;
12
+ stylesNames: InlineCodeHighlightStylesNames;
13
+ }>;
14
+ export declare const InlineCodeHighlight: import("@mantine/core").MantineComponent<{
15
+ props: InlineCodeHighlightProps;
16
+ ref: HTMLElement;
17
+ stylesNames: InlineCodeHighlightStylesNames;
18
+ }>;
@@ -0,0 +1,6 @@
1
+ export { CodeHighlightTabs } from './CodeHighlightTabs';
2
+ export { CodeHighlight } from './CodeHighlight';
3
+ export { InlineCodeHighlight } from './InlineCodeHighlight';
4
+ export type { CodeHighlightTabsFactory, CodeHighlightTabsStylesNames, CodeHighlightTabsProps, CodeHighlightTabsCode, CodeHighlightTabsCssVariables, } from './CodeHighlightTabs';
5
+ export type { CodeHighlightFactory, CodeHighlightProps, CodeHighlightStylesNames, } from './CodeHighlight';
6
+ export type { InlineCodeHighlightFactory, InlineCodeHighlightProps, InlineCodeHighlightStylesNames, } from './InlineCodeHighlight';
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export { CodeHighlightTabs } from './CodeHighlightTabs';
2
+ export { CodeHighlight } from './CodeHighlight';
3
+ export { InlineCodeHighlight } from './InlineCodeHighlight';
4
+ export type { CodeHighlightTabsFactory, CodeHighlightTabsStylesNames, CodeHighlightTabsProps, CodeHighlightTabsCode, CodeHighlightTabsCssVariables, } from './CodeHighlightTabs';
5
+ export type { CodeHighlightFactory, CodeHighlightProps, CodeHighlightStylesNames, } from './CodeHighlight';
6
+ export type { InlineCodeHighlightFactory, InlineCodeHighlightProps, InlineCodeHighlightStylesNames, } from './InlineCodeHighlight';
@@ -0,0 +1,15 @@
1
+ interface UseHighlightInput {
2
+ code: string;
3
+ language: string;
4
+ highlightOnClient: boolean | undefined;
5
+ }
6
+ export declare function useHighlight({ code, language, highlightOnClient }: UseHighlightInput): () => {
7
+ dangerouslySetInnerHTML: {
8
+ __html: string;
9
+ };
10
+ children?: undefined;
11
+ } | {
12
+ children: string;
13
+ dangerouslySetInnerHTML?: undefined;
14
+ };
15
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/code-highlight",
3
- "version": "7.13.5-alpha.1",
3
+ "version": "7.13.5-alpha.2",
4
4
  "description": "Code highlight with Mantine theme",
5
5
  "homepage": "https://mantine.dev/x/code-highlight/",
6
6
  "license": "MIT",
@@ -45,8 +45,8 @@
45
45
  "directory": "packages/@mantine/code-highlight"
46
46
  },
47
47
  "peerDependencies": {
48
- "@mantine/core": "7.13.5-alpha.1",
49
- "@mantine/hooks": "7.13.5-alpha.1",
48
+ "@mantine/core": "7.13.5-alpha.2",
49
+ "@mantine/hooks": "7.13.5-alpha.2",
50
50
  "react": "^18.x || ^19.x",
51
51
  "react-dom": "^18.x || ^19.x"
52
52
  },