@pushwoosh/dumb-components 1.0.27 → 1.0.29

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { type CodeEditorProps } from './types';
3
+ export declare const CodeEditor: ({ value, onChange, readOnly, width, height, onBlur, extensions, themeOptions, hasError, placeholder, }: CodeEditorProps) => React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ import createTheme from '@uiw/codemirror-themes';
2
+ import React from 'react';
3
+ import { defaultTheme } from './constants';
4
+ import { CodeMirrorStyled } from './styles';
5
+ export const CodeEditor = ({
6
+ value,
7
+ onChange,
8
+ readOnly,
9
+ width,
10
+ height,
11
+ onBlur,
12
+ extensions,
13
+ themeOptions,
14
+ hasError,
15
+ placeholder
16
+ }) => {
17
+ return React.createElement(CodeMirrorStyled, {
18
+ value: value,
19
+ theme: themeOptions ? createTheme(themeOptions) : defaultTheme,
20
+ readOnly: readOnly,
21
+ onChange: onChange,
22
+ onBlur: onBlur,
23
+ width: width,
24
+ height: height,
25
+ extensions: extensions,
26
+ placeholder: placeholder,
27
+ "$danger": hasError
28
+ });
29
+ };
@@ -0,0 +1 @@
1
+ export declare const defaultTheme: import("@codemirror/state").Extension;
@@ -0,0 +1,25 @@
1
+ import { tags } from '@lezer/highlight';
2
+ import createTheme from '@uiw/codemirror-themes';
3
+ import { Color, FontFamily, FontSize } from '@pushwoosh/kit-constants';
4
+ export const defaultTheme = createTheme({
5
+ theme: 'light',
6
+ settings: {
7
+ background: Color.CLEAR,
8
+ backgroundImage: '',
9
+ foreground: Color.MAIN,
10
+ caret: Color.BRIGHT,
11
+ selection: Color.BRIGHT_LIGHT,
12
+ selectionMatch: Color.BRIGHT_LIGHT,
13
+ gutterBackground: Color.SOFT_LIGHT,
14
+ gutterForeground: Color.PHANTOM,
15
+ gutterBorder: Color.FORM,
16
+ gutterActiveForeground: Color.MAIN,
17
+ lineHighlight: Color.SOFT_LIGHT,
18
+ fontFamily: FontFamily.MONO,
19
+ fontSize: FontSize.REGULAR
20
+ },
21
+ styles: [{
22
+ tag: tags.invalid,
23
+ color: Color.PRIMARY
24
+ }]
25
+ });
@@ -0,0 +1,2 @@
1
+ export { CodeEditor } from './CodeEditor';
2
+ export { html, liquid, json } from './languages';
@@ -0,0 +1,2 @@
1
+ export { CodeEditor } from './CodeEditor';
2
+ export { html, liquid, json } from './languages';
@@ -0,0 +1 @@
1
+ export declare const html: import("@codemirror/language").LanguageSupport[];
@@ -0,0 +1,2 @@
1
+ import { html as createHtml } from '@codemirror/lang-html';
2
+ export const html = [createHtml()];
@@ -0,0 +1,3 @@
1
+ export { html } from './html';
2
+ export { json } from './json';
3
+ export { liquid } from './liquid';
@@ -0,0 +1,3 @@
1
+ export { html } from './html';
2
+ export { json } from './json';
3
+ export { liquid } from './liquid';
@@ -0,0 +1 @@
1
+ export declare const json: import("@codemirror/language").LanguageSupport[];
@@ -0,0 +1,2 @@
1
+ import { json as createJson } from '@codemirror/lang-json';
2
+ export const json = [createJson()];
@@ -0,0 +1 @@
1
+ export declare const liquid: import("@codemirror/language").LanguageSupport[];
@@ -0,0 +1,2 @@
1
+ import { liquid as createLiquid } from '@codemirror/lang-liquid';
2
+ export const liquid = [createLiquid()];
@@ -0,0 +1,3 @@
1
+ export declare const CodeMirrorStyled: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@uiw/react-codemirror").ReactCodeMirrorProps & import("react").RefAttributes<import("@uiw/react-codemirror").ReactCodeMirrorRef>>, any, {
2
+ $danger?: boolean;
3
+ }, never>;
@@ -0,0 +1,9 @@
1
+ import CodeMirror from '@uiw/react-codemirror';
2
+ import styled from 'styled-components';
3
+ import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
4
+ export const CodeMirrorStyled = styled(CodeMirror).withConfig({
5
+ displayName: "CodeMirrorStyled",
6
+ componentId: "sc-3i4lgt-0"
7
+ })([".cm-editor{border:1px solid ", ";outline:none;border-radius:", ";overflow:hidden;&.cm-focused{border-color:", ";}}"], ({
8
+ $danger
9
+ }) => $danger ? Color.DANGER : Color.FORM, ShapeRadius.CONTROL, Color.BRIGHT);
@@ -0,0 +1,15 @@
1
+ import { type CreateThemeOptions } from '@uiw/codemirror-themes';
2
+ import { type ViewUpdate, type Extension } from '@uiw/react-codemirror';
3
+ export type Language = 'json' | 'html' | 'liquid';
4
+ export type CodeEditorProps = {
5
+ value: string;
6
+ readOnly?: boolean;
7
+ width?: string;
8
+ height?: string;
9
+ hasError?: boolean;
10
+ extensions: Extension[];
11
+ placeholder?: string;
12
+ themeOptions?: CreateThemeOptions;
13
+ onChange?: (value: string, viewUpdate: ViewUpdate) => void;
14
+ onBlur?: () => void;
15
+ };
@@ -0,0 +1 @@
1
+ export {};
package/index.d.ts CHANGED
@@ -32,4 +32,5 @@ export { ExportResult } from './ExportResult';
32
32
  export { NativeInput, NativeTextarea, NativeSelect } from './native';
33
33
  export { FieldBox } from './FieldBox';
34
34
  export { NumberPicker } from './NumberPicker';
35
+ export { CodeEditor } from './CodeEditor';
35
36
  export { EnhancedInput, SearchInput } from './EnhancedInput';
package/index.js CHANGED
@@ -32,4 +32,5 @@ export { ExportResult } from './ExportResult';
32
32
  export { NativeInput, NativeTextarea, NativeSelect } from './native';
33
33
  export { FieldBox } from './FieldBox';
34
34
  export { NumberPicker } from './NumberPicker';
35
+ export { CodeEditor } from './CodeEditor';
35
36
  export { EnhancedInput, SearchInput } from './EnhancedInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -35,11 +35,17 @@
35
35
  "styled-components": "^5.3.11"
36
36
  },
37
37
  "dependencies": {
38
+ "@codemirror/lang-html": "^6.4.9",
39
+ "@codemirror/lang-json": "^6.0.1",
40
+ "@codemirror/lang-liquid": "^6.2.2",
38
41
  "@floating-ui/react-dom": "^2.1.2",
42
+ "@lezer/highlight": "^1.2.1",
39
43
  "@pushwoosh/kit-helpers": "^4.6.2",
40
44
  "@pushwoosh/kit-icons": "^2.1.1",
41
45
  "@pushwoosh/kit-typography": "^1.7.1",
42
46
  "@tippyjs/react": "^4.2.6",
47
+ "@uiw/codemirror-themes": "^4.23.8",
48
+ "@uiw/react-codemirror": "^4.23.8",
43
49
  "liquidjs": "^10.18.0",
44
50
  "lodash": "^4.17.21",
45
51
  "polished": "^4.3.1",