@up42/up-components 5.5.3 → 5.6.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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { SxProps, Theme } from '@mui/material';
2
+ import { BoxProps, SxProps, Theme } from '@mui/material';
3
+ import Prism from 'prismjs';
3
4
  import 'prismjs/plugins/line-numbers/prism-line-numbers';
4
5
  import 'prismjs/components/prism-json';
5
6
  import 'prismjs/components/prism-python';
@@ -7,26 +8,55 @@ import 'prismjs/components/prism-kotlin';
7
8
  import 'prismjs/components/prism-java';
8
9
  import 'prismjs/components/prism-julia';
9
10
  import 'prismjs/components/prism-bash';
10
- export type Languages = 'DFS' | 'atom' | 'bash' | 'clike' | 'css' | 'extend' | 'html' | 'insertBefore' | 'java' | 'javascript' | 'js' | 'json' | 'julia' | 'kotlin' | 'kt' | 'kts' | 'markup' | 'mathml' | 'plain' | 'plaintext' | 'py' | 'python' | 'rss' | 'sh' | 'shell' | 'ssml' | 'svg' | 'text' | 'txt' | 'webmanifest' | 'xml';
11
- export interface CodeSnippetItemProps {
11
+ export interface CodeSnippetProps extends Omit<CodeBlockProps, 'code' | 'language'> {
12
+ snippets: CodeSnippetItemProps[];
13
+ onCopy?: (code: string) => void;
14
+ sx?: SxProps<Theme>;
15
+ /**
16
+ * Set value to show specific snippet when component mounts
17
+ */
18
+ initialSnippetIndex?: number;
19
+ }
20
+ export interface CodeSnippetItemProps extends CodeBlockProps {
12
21
  label: string;
22
+ }
23
+ /**
24
+ * Documentation: https://up-components.up42.com/?path=/docs/data-display-CodeSnippet--docs
25
+ */
26
+ export declare const CodeSnippet: ({ snippets, sx, onCopy, initialSnippetIndex, lineNumbers, maxLineLength, }: CodeSnippetProps) => React.JSX.Element;
27
+ export type Languages = keyof typeof Prism.languages;
28
+ export interface CodeBlockProps {
29
+ /**
30
+ * the code to display
31
+ */
13
32
  code: string;
33
+ /**
34
+ * the language of the code
35
+ */
14
36
  language: Languages;
15
37
  /**
16
38
  * limit the code height. defaults to 512px, **roughly** 22 lines
17
39
  */
18
40
  maxCodeHeight?: string;
19
- }
20
- export interface CodeSnippetProps {
21
- snippets: CodeSnippetItemProps[];
22
- onCopy?: (code: string) => void;
23
- sx?: SxProps<Theme>;
24
41
  /**
25
- * Set value to show specific snippet when component mounts
42
+ * show line numbers. defaults to true
26
43
  */
27
- initialSnippetIndex?: number;
44
+ lineNumbers?: boolean;
45
+ /**
46
+ * maximum characters per line before wrapping. defaults to no limit
47
+ */
48
+ maxLineLength?: number;
49
+ /**
50
+ * additional styles
51
+ */
52
+ sx?: BoxProps['sx'];
53
+ /**
54
+ * test id
55
+ */
56
+ testId?: string;
28
57
  }
29
58
  /**
30
- * Documentation: https://up-components.up42.com/?path=/docs/data-display-CodeSnippet--docs
59
+ * Not moved to a separate file to prevent the build from failing with "(!) Unused external imports" error.
60
+ * PrismJS generates unused imports, which causes the build to fail when importing this from a separate file.
31
61
  */
32
- export declare const CodeSnippet: ({ snippets, sx, onCopy, initialSnippetIndex }: CodeSnippetProps) => React.JSX.Element;
62
+ export declare function CodeBlock({ code, language, maxCodeHeight, lineNumbers, maxLineLength, sx, testId, }: CodeBlockProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { Languages } from './CodeSnippet';
2
+ export declare const languagesMock: Record<Languages, string>;
@@ -55,7 +55,7 @@ export { EditTagsButton, type EditTagsButtonProps } from './components/EditTagsB
55
55
  export { FeatureFlagCheckbox, type FeatureFlagCheckboxProps, } from './components/FeatureFlagCheckbox/FeatureFlagCheckbox';
56
56
  export { DocumentationPopover, type DocumentationPopoverProps, } from './components/DocumentationPopover/DocumentationPopover';
57
57
  export { CodeInline, type CodeInlineProps } from './components/CodeInline/CodeInline';
58
- export { CodeSnippet, type CodeSnippetProps, type CodeSnippetItemProps } from './components/CodeSnippet/CodeSnippet';
58
+ export { CodeSnippet, type CodeSnippetProps, type CodeSnippetItemProps, CodeBlock, type CodeBlockProps, } from './components/CodeSnippet/CodeSnippet';
59
59
  export { Table, TableBody, TableCell, TableHead, TableContainer, TableRow, TableFooter, TablePagination, TableSortLabel, type TableProps, type TableBodyProps, type TableCellProps, type TableHeadProps, type TableContainerProps, type TableRowProps, type TableFooterProps, type TablePaginationProps, type TableSortLabelProps, } from './components/Table/Table';
60
60
  export { DataGrid, GridRow, GridCell, GridEditInputCell, GridCellModes, GridFooter, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridRowCount, GridSelectedRowCount, gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector, gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridRowsLookupSelector, GRID_DETAIL_PANEL_TOGGLE_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, useGridApiContext, useGridApiRef, useGridSelector, } from './components/DataGrid/DataGrid';
61
61
  export type { GridColDef, GridRenderEditCellParams, GridCellModesModel, GridCellParams, GridRenderCellParams, GridRowId, GridRowParams, GridRowSelectionModel, GridRowsProp, GridSortModel, GridTreeNodeWithRender, GridColumnHeaderParams, GridEditCellProps, GridInitialState, GridPreProcessEditCellProps, } from './components/DataGrid/DataGrid';
@@ -0,0 +1 @@
1
+ export {};