@coveord/plasma-mantine 48.17.5 → 48.18.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/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +9 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/code-editor/CodeEditor.js +15 -3
- package/dist/cjs/components/code-editor/CodeEditor.js.map +1 -1
- package/dist/cjs/components/code-editor/__mocks__/@monaco-editor/react.js +6 -0
- package/dist/cjs/components/code-editor/__mocks__/@monaco-editor/react.js.map +1 -1
- package/dist/cjs/components/code-editor/languages/xml.js +60 -0
- package/dist/cjs/components/code-editor/languages/xml.js.map +1 -0
- package/dist/cjs/components/collection/Collection.js +37 -7
- package/dist/cjs/components/collection/Collection.js.map +1 -1
- package/dist/cjs/components/collection/{Colllection.styles.js → Collection.styles.js} +1 -1
- package/dist/cjs/components/collection/Collection.styles.js.map +1 -0
- package/dist/cjs/components/collection/CollectionItem.js +4 -4
- package/dist/cjs/components/collection/CollectionItem.js.map +1 -1
- package/dist/definitions/components/code-editor/CodeEditor.d.ts +1 -1
- package/dist/definitions/components/code-editor/CodeEditor.d.ts.map +1 -1
- package/dist/definitions/components/code-editor/__mocks__/@monaco-editor/react.d.ts +2 -1
- package/dist/definitions/components/code-editor/__mocks__/@monaco-editor/react.d.ts.map +1 -1
- package/dist/definitions/components/code-editor/languages/xml.d.ts +5 -0
- package/dist/definitions/components/code-editor/languages/xml.d.ts.map +1 -0
- package/dist/definitions/components/collection/Collection.d.ts +3 -3
- package/dist/definitions/components/collection/Collection.d.ts.map +1 -1
- package/dist/definitions/components/collection/{Colllection.styles.d.ts → Collection.styles.d.ts} +1 -1
- package/dist/definitions/components/collection/Collection.styles.d.ts.map +1 -0
- package/dist/definitions/components/collection/CollectionItem.d.ts +1 -1
- package/dist/definitions/components/collection/CollectionItem.d.ts.map +1 -1
- package/dist/esm/components/code-editor/CodeEditor.js +16 -4
- package/dist/esm/components/code-editor/CodeEditor.js.map +1 -1
- package/dist/esm/components/code-editor/__mocks__/@monaco-editor/react.js +3 -0
- package/dist/esm/components/code-editor/__mocks__/@monaco-editor/react.js.map +1 -1
- package/dist/esm/components/code-editor/languages/xml.js +50 -0
- package/dist/esm/components/code-editor/languages/xml.js.map +1 -0
- package/dist/esm/components/collection/Collection.js +37 -7
- package/dist/esm/components/collection/Collection.js.map +1 -1
- package/dist/esm/components/collection/{Colllection.styles.js → Collection.styles.js} +1 -1
- package/dist/esm/components/collection/Collection.styles.js.map +1 -0
- package/dist/esm/components/collection/CollectionItem.js +1 -1
- package/dist/esm/components/collection/CollectionItem.js.map +1 -1
- package/package.json +1 -1
- package/src/components/code-editor/CodeEditor.tsx +14 -4
- package/src/components/code-editor/__mocks__/@monaco-editor/react.tsx +3 -1
- package/src/components/code-editor/__tests__/CodeEditor.spec.tsx +7 -0
- package/src/components/code-editor/languages/xml.ts +43 -0
- package/src/components/collection/{Colllection.styles.ts → Collection.styles.ts} +0 -0
- package/src/components/collection/Collection.tsx +38 -7
- package/src/components/collection/CollectionItem.tsx +1 -1
- package/dist/cjs/components/collection/Colllection.styles.js.map +0 -1
- package/dist/definitions/components/collection/Colllection.styles.d.ts.map +0 -1
- package/dist/esm/components/collection/Colllection.styles.js.map +0 -1
|
@@ -22,6 +22,7 @@ var _hooks = require("@mantine/hooks");
|
|
|
22
22
|
var _react = /*#__PURE__*/ _interopRequireWildcard(require("@monaco-editor/react"));
|
|
23
23
|
var _react1 = require("react");
|
|
24
24
|
var _hooks1 = require("../../hooks");
|
|
25
|
+
var _xml = require("./languages/xml");
|
|
25
26
|
var useStyles = (0, _core.createStyles)(function(theme) {
|
|
26
27
|
return {
|
|
27
28
|
root: {},
|
|
@@ -59,6 +60,8 @@ var CodeEditor = function(props) {
|
|
|
59
60
|
"monacoLoader"
|
|
60
61
|
]);
|
|
61
62
|
var _useState = _slicedToArray((0, _react1.useState)(false), 2), loaded = _useState[0], setLoaded = _useState[1];
|
|
63
|
+
var _useState1 = _slicedToArray((0, _react1.useState)(false), 2), registered = _useState1[0], setRegistered = _useState1[1];
|
|
64
|
+
var monaco = (0, _react.useMonaco)();
|
|
62
65
|
var _useStyles = useStyles(), classes = _useStyles.classes, theme = _useStyles.theme;
|
|
63
66
|
var _useUncontrolled = _slicedToArray((0, _hooks.useUncontrolled)({
|
|
64
67
|
value: value,
|
|
@@ -69,7 +72,7 @@ var CodeEditor = function(props) {
|
|
|
69
72
|
var _useParentHeight = _slicedToArray((0, _hooks1.useParentHeight)(), 2), parentHeight = _useParentHeight[0], ref = _useParentHeight[1];
|
|
70
73
|
var loadLocalMonaco = function() {
|
|
71
74
|
var _ref = _asyncToGenerator(function() {
|
|
72
|
-
var
|
|
75
|
+
var monacoInstance;
|
|
73
76
|
return _tsGenerator(this, function(_state) {
|
|
74
77
|
switch(_state.label){
|
|
75
78
|
case 0:
|
|
@@ -80,9 +83,9 @@ var CodeEditor = function(props) {
|
|
|
80
83
|
})
|
|
81
84
|
];
|
|
82
85
|
case 1:
|
|
83
|
-
|
|
86
|
+
monacoInstance = _state.sent();
|
|
84
87
|
_react.loader.config({
|
|
85
|
-
monaco:
|
|
88
|
+
monaco: monacoInstance
|
|
86
89
|
});
|
|
87
90
|
setLoaded(true);
|
|
88
91
|
return [
|
|
@@ -102,6 +105,15 @@ var CodeEditor = function(props) {
|
|
|
102
105
|
setLoaded(true);
|
|
103
106
|
}
|
|
104
107
|
}, []);
|
|
108
|
+
(0, _react1.useEffect)(function() {
|
|
109
|
+
if (monaco && language === "xml" && !registered) {
|
|
110
|
+
_xml.XML.register(monaco);
|
|
111
|
+
setRegistered(true);
|
|
112
|
+
}
|
|
113
|
+
}, [
|
|
114
|
+
monaco,
|
|
115
|
+
language
|
|
116
|
+
]);
|
|
105
117
|
var _label = label ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Input.Label, _objectSpreadProps(_objectSpread({
|
|
106
118
|
required: required
|
|
107
119
|
}, labelProps), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {CheckSize16Px, CopySize16Px} from '@coveord/plasma-react-icons';\nimport {\n ActionIcon,\n Box,\n Center,\n CopyButton,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n Selectors,\n Space,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState} from 'react';\n\nimport {useParentHeight} from '../../hooks';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n\n const loadLocalMonaco = async () => {\n const monaco = await import('monaco-editor');\n loader.config({monaco});\n setLoaded(true);\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description mt=\"xs\" {...descriptionProps}>\n {description}\n </Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _copyButton = (\n <Group position=\"right\">\n <CopyButton value={_value} timeout={2000}>\n {({copied, copy}) => (\n <Tooltip label={copied ? 'Copied' : 'Copy'} withArrow position=\"right\">\n <ActionIcon color={copied ? 'lime' : 'gray'} onClick={copy}>\n {copied ? <CheckSize16Px height={16} /> : <CopySize16Px height={16} />}\n </ActionIcon>\n </Tooltip>\n )}\n </CopyButton>\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: theme.fontSizes.xs,\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor) => {\n editor.onDidFocusEditorText(onFocus);\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_copyButton}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["CodeEditor","useStyles","createStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","props","useComponentDefaultProps","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","useState","loaded","setLoaded","classes","useUncontrolled","finalValue","_value","handleChange","useParentHeight","parentHeight","ref","loadLocalMonaco","monaco","loader","config","useEffect","_label","Input","Label","_description","Description","mt","_error","Error","Space","h","_header","Box","_copyButton","Group","position","CopyButton","timeout","copied","copy","Tooltip","withArrow","ActionIcon","color","onClick","CheckSize16Px","CopySize16Px","_editor","p","pl","className","Editor","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","Center","Loader","Stack","justify","spacing","sx","Math","max"],"mappings":"AAAA;;;;+BAoFaA;;;eAAAA;;;;;;;;;;;gCApF6B;oBAiBnC;qBACuB;2DACD;sBACwB;sBAEvB;AAE9B,IAAMC,YAAYC,IAAAA,kBAAY,EAAC,SAACC;WA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AQlC,MAAM;kBACzC,cAAA,qBAAC6E,cAAM;YACHC,iBAAiBlE;YACjBd,OAAOA,MAAMS,WAAW,KAAK,UAAU,UAAU,SAAS;YAC1DwE,SAAS;gBACLC,SAAS;oBAACC,SAAS,KAAK;gBAAA;gBACxBC,UAAU;gBACVC,kBAAkB;gBAClBC,sBAAsB,KAAK;gBAC3BC,eAAe,IAAI;gBACnBC,UAAUxF,MAAMyF,SAAS,CAACC,EAAE;gBAC5BC,UAAU5D;gBACV6D,SAAS;YACb;YACAtE,OAAOiB;YACPnB,UAAUoB;YACVqD,SAAS,SAAC3F,QAAW;gBACjBA,OAAO4F,oBAAoB,CAACzE;gBAC5BnB,OAAO6F,mBAAmB,eAAC,kBAAA,WAAY;;;;gCACnC;;oCAAM7F,OAAO8F,SAAS,CAAC,gCAAgCC,GAAG;;;gCAA1D;;;;;;gBACJ;YACJ;;uBAIR,qBAACC,YAAM;QAACpB,WAAW1C,QAAQlC,MAAM;kBAC7B,cAAA,qBAACiG,YAAM;MAEd;IAED,qBACI,sBAACC,WAAK;QACFC,SAAQ;QACRvB,WAAW1C,QAAQnC,IAAI;QACvBqG,SAAS;QACTC,IAAI;YAAC3F,QAAQ4F,KAAKC,GAAG,CAAC/D,cAAczB;YAAYa,WAAAA;QAAS;QACzDa,KAAKA;OACDX;;YAEH2B;YACAE;YACAc;YACApB;;;AAGb"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {CheckSize16Px, CopySize16Px} from '@coveord/plasma-react-icons';\nimport {\n ActionIcon,\n Box,\n Center,\n CopyButton,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n Selectors,\n Space,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader, useMonaco} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState} from 'react';\n\nimport {useParentHeight} from '../../hooks';\nimport {XML} from './languages/xml';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const [registered, setRegistered] = useState(false);\n const monaco = useMonaco();\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n useEffect(() => {\n if (monaco && language === 'xml' && !registered) {\n XML.register(monaco);\n setRegistered(true);\n }\n }, [monaco, language]);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description mt=\"xs\" {...descriptionProps}>\n {description}\n </Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _copyButton = (\n <Group position=\"right\">\n <CopyButton value={_value} timeout={2000}>\n {({copied, copy}) => (\n <Tooltip label={copied ? 'Copied' : 'Copy'} withArrow position=\"right\">\n <ActionIcon color={copied ? 'lime' : 'gray'} onClick={copy}>\n {copied ? <CheckSize16Px height={16} /> : <CopySize16Px height={16} />}\n </ActionIcon>\n </Tooltip>\n )}\n </CopyButton>\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: theme.fontSizes.xs,\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor) => {\n editor.onDidFocusEditorText(onFocus);\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_copyButton}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["CodeEditor","useStyles","createStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","props","useComponentDefaultProps","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","useState","loaded","setLoaded","registered","setRegistered","monaco","useMonaco","classes","useUncontrolled","finalValue","_value","handleChange","useParentHeight","parentHeight","ref","loadLocalMonaco","monacoInstance","loader","config","useEffect","XML","register","_label","Input","Label","_description","Description","mt","_error","Error","Space","h","_header","Box","_copyButton","Group","position","CopyButton","timeout","copied","copy","Tooltip","withArrow","ActionIcon","color","onClick","CheckSize16Px","CopySize16Px","_editor","p","pl","className","Editor","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","Center","Loader","Stack","justify","spacing","sx","Math","max"],"mappings":"AAAA;;;;+BAqFaA;;;eAAAA;;;;;;;;;;;gCArF6B;oBAiBnC;qBACuB;2DACU;sBACa;sBAEvB;mBACZ;AAElB,IAAMC,YAAYC,IAAAA,kBAAY,EAAC,SAACC;WAAW;QACvCC,MAAM,CAAC;QACPC,QAAQ;YACJC,QAAQ,AAAC,aAAiC,OAArBH,MAAMI,MAAM,CAACC,IAAI,CAAC,EAAE;YACzCC,cAAcN,MAAMO,aAAa;YACjCC,iBAAiBR,MAAMS,WAAW,KAAK,UAAUT,MAAMU,KAA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;0BAAM;;;;;;IAQ9F,IAAMqE,UAAU/C,uBACZ,qBAACgC,SAAG;QAACgB,GAAE;QAAKC,IAAG;QAAKC,WAAW5C,QAAQtC,MAAM;kBACzC,cAAA,qBAACmF,cAAM;YACHC,iBAAiBxE;YACjBd,OAAOA,MAAMS,WAAW,KAAK,UAAU,UAAU,SAAS;YAC1D8E,SAAS;gBACLC,SAAS;oBAACC,SAAS,KAAK;gBAAA;gBACxBC,UAAU;gBACVC,kBAAkB;gBAClBC,sBAAsB,KAAK;gBAC3BC,eAAe,IAAI;gBACnBC,UAAU9F,MAAM+F,SAAS,CAACC,EAAE;gBAC5BC,UAAUlE;gBACVmE,SAAS;YACb;YACA5E,OAAOqB;YACPvB,UAAUwB;YACVuD,SAAS,SAACjG,QAAW;gBACjBA,OAAOkG,oBAAoB,CAAC/E;gBAC5BnB,OAAOmG,mBAAmB,eAAC,kBAAA,WAAY;;;;gCACnC;;oCAAMnG,OAAOoG,SAAS,CAAC,gCAAgCC,GAAG;;;gCAA1D;;;;;;gBACJ;YACJ;;uBAIR,qBAACC,YAAM;QAACpB,WAAW5C,QAAQtC,MAAM;kBAC7B,cAAA,qBAACuG,YAAM;MAEd;IAED,qBACI,sBAACC,WAAK;QACFC,SAAQ;QACRvB,WAAW5C,QAAQvC,IAAI;QACvB2G,SAAS;QACTC,IAAI;YAACjG,QAAQkG,KAAKC,GAAG,CAACjE,cAAc7B;YAAYa,WAAAA;QAAS;QACzDiB,KAAKA;OACDf;;YAEHiC;YACAE;YACAc;YACApB;;;AAGb"}
|
|
@@ -14,6 +14,9 @@ _export(exports, {
|
|
|
14
14
|
},
|
|
15
15
|
loader: function() {
|
|
16
16
|
return loader;
|
|
17
|
+
},
|
|
18
|
+
useMonaco: function() {
|
|
19
|
+
return useMonaco;
|
|
17
20
|
}
|
|
18
21
|
});
|
|
19
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -26,5 +29,8 @@ var _default = MockedEditor;
|
|
|
26
29
|
var loader = {
|
|
27
30
|
config: jest.fn()
|
|
28
31
|
};
|
|
32
|
+
var useMonaco = function() {
|
|
33
|
+
return jest.fn();
|
|
34
|
+
};
|
|
29
35
|
|
|
30
36
|
//# sourceMappingURL=react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/code-editor/__mocks__/@monaco-editor/react.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/code-editor/__mocks__/@monaco-editor/react.tsx"],"sourcesContent":["import {EditorProps} from '@monaco-editor/react';\nimport {FunctionComponent} from 'react';\n\nconst MockedEditor: FunctionComponent<EditorProps> = (props) => <div data-testid=\"monaco-editor\" />;\n\nexport default MockedEditor;\n\nexport const loader = {\n config: jest.fn(),\n};\n\nexport const useMonaco = () => jest.fn();\n"],"names":["loader","useMonaco","MockedEditor","props","div","data-testid","config","jest","fn"],"mappings":"AAAA;;;;;;;;;;;IAKA,OAA4B;eAA5B;;IAEaA,MAAM;eAANA;;IAIAC,SAAS;eAATA;;;;AARb,IAAMC,eAA+C,SAACC;yBAAU,qBAACC;QAAIC,eAAY;;;IAEjF,WAAeH;AAER,IAAMF,SAAS;IAClBM,QAAQC,KAAKC,EAAE;AACnB;AAEO,IAAMP,YAAY;WAAMM,KAAKC,EAAE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "XML", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return XML;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default;
|
|
12
|
+
var _tsGenerator = require("@swc/helpers/lib/_ts_generator.js").default;
|
|
13
|
+
var format = function(xml) {
|
|
14
|
+
// https://stackoverflow.com/questions/57039218/doesnt-monaco-editor-support-xml-language-by-default
|
|
15
|
+
var PADDING = " ".repeat(2);
|
|
16
|
+
var reg = /(>)(<)(\/*)/g;
|
|
17
|
+
var pad = 0;
|
|
18
|
+
xml = xml.replace(reg, "$1\r\n$2$3");
|
|
19
|
+
return xml.split("\r\n").map(function(node) {
|
|
20
|
+
var indent = 0;
|
|
21
|
+
if (node.match(/.+<\/\w[^>]*>$/)) {
|
|
22
|
+
indent = 0;
|
|
23
|
+
} else if (node.match(/^<\/\w/) && pad > 0) {
|
|
24
|
+
pad -= 1;
|
|
25
|
+
} else if (node.match(/^<\w[^>]*[^/]>.*$/)) {
|
|
26
|
+
indent = 1;
|
|
27
|
+
} else {
|
|
28
|
+
indent = 0;
|
|
29
|
+
}
|
|
30
|
+
pad += indent;
|
|
31
|
+
return PADDING.repeat(pad - indent) + node;
|
|
32
|
+
}).join("\r\n");
|
|
33
|
+
};
|
|
34
|
+
var register = function(monaco) {
|
|
35
|
+
monaco.languages.registerDocumentFormattingEditProvider("xml", {
|
|
36
|
+
provideDocumentFormattingEdits: function() {
|
|
37
|
+
var _ref = _asyncToGenerator(function(model) {
|
|
38
|
+
return _tsGenerator(this, function(_state) {
|
|
39
|
+
return [
|
|
40
|
+
2,
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
range: model.getFullModelRange(),
|
|
44
|
+
text: format(model.getValue())
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
];
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return function(model) {
|
|
51
|
+
return _ref.apply(this, arguments);
|
|
52
|
+
};
|
|
53
|
+
}()
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var XML = {
|
|
57
|
+
register: register
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=xml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/code-editor/languages/xml.ts"],"sourcesContent":["import {Monaco} from '@monaco-editor/react';\n\nconst format = (xml: string): string => {\n // https://stackoverflow.com/questions/57039218/doesnt-monaco-editor-support-xml-language-by-default\n const PADDING = ' '.repeat(2);\n const reg = /(>)(<)(\\/*)/g;\n let pad = 0;\n\n xml = xml.replace(reg, '$1\\r\\n$2$3');\n\n return xml\n .split('\\r\\n')\n .map((node) => {\n let indent = 0;\n if (node.match(/.+<\\/\\w[^>]*>$/)) {\n indent = 0;\n } else if (node.match(/^<\\/\\w/) && pad > 0) {\n pad -= 1;\n } else if (node.match(/^<\\w[^>]*[^/]>.*$/)) {\n indent = 1;\n } else {\n indent = 0;\n }\n\n pad += indent;\n\n return PADDING.repeat(pad - indent) + node;\n })\n .join('\\r\\n');\n};\n\nconst register = (monaco: Monaco): void => {\n monaco.languages.registerDocumentFormattingEditProvider('xml', {\n provideDocumentFormattingEdits: async (model) => [\n {\n range: model.getFullModelRange(),\n text: format(model.getValue()),\n },\n ],\n });\n};\n\nexport const XML = {register};\n"],"names":["XML","format","xml","PADDING","repeat","reg","pad","replace","split","map","node","indent","match","join","register","monaco","languages","registerDocumentFormattingEditProvider","provideDocumentFormattingEdits","model","range","getFullModelRange","text","getValue"],"mappings":"AAAA;;;;+BA0CaA;;;eAAAA;;;;;AAxCb,IAAMC,SAAS,SAACC,KAAwB;IACpC,oGAAoG;IACpG,IAAMC,UAAU,IAAIC,MAAM,CAAC;IAC3B,IAAMC,MAAM;IACZ,IAAIC,MAAM;IAEVJ,MAAMA,IAAIK,OAAO,CAACF,KAAK;IAEvB,OAAOH,IACFM,KAAK,CAAC,QACNC,GAAG,CAAC,SAACC,MAAS;QACX,IAAIC,SAAS;QACb,IAAID,KAAKE,KAAK,CAAC,mBAAmB;YAC9BD,SAAS;QACb,OAAO,IAAID,KAAKE,KAAK,CAAC,aAAaN,MAAM,GAAG;YACxCA,OAAO;QACX,OAAO,IAAII,KAAKE,KAAK,CAAC,sBAAsB;YACxCD,SAAS;QACb,OAAO;YACHA,SAAS;QACb,CAAC;QAEDL,OAAOK;QAEP,OAAOR,QAAQC,MAAM,CAACE,MAAMK,UAAUD;IAC1C,GACCG,IAAI,CAAC;AACd;AAEA,IAAMC,WAAW,SAACC,QAAyB;IACvCA,OAAOC,SAAS,CAACC,sCAAsC,CAAC,OAAO;QAC3DC,8BAA8B;uBAAE,kBAAA,SAAOC;;oBAAU;;;4BAC7C;gCACIC,OAAOD,MAAME,iBAAiB;gCAC9BC,MAAMrB,OAAOkB,MAAMI,QAAQ;4BAC/B;;;;;4BAJmCJ;;;;IAM3C;AACJ;AAEO,IAAMnB,MAAM;IAACc,UAAAA;AAAQ"}
|
|
@@ -20,7 +20,7 @@ var _hooks = require("@mantine/hooks");
|
|
|
20
20
|
var _reactBeautifulDnd = require("react-beautiful-dnd");
|
|
21
21
|
var _hooks1 = require("../../hooks");
|
|
22
22
|
var _collectionItem = require("./CollectionItem");
|
|
23
|
-
var
|
|
23
|
+
var _collectionStyles = /*#__PURE__*/ _interopRequireDefault(require("./Collection.styles"));
|
|
24
24
|
var defaultProps = {
|
|
25
25
|
draggable: false,
|
|
26
26
|
addLabel: "Add item",
|
|
@@ -30,7 +30,7 @@ var defaultProps = {
|
|
|
30
30
|
required: false
|
|
31
31
|
};
|
|
32
32
|
var Collection = function(props) {
|
|
33
|
-
var _useComponentDefaultProps = (0, _core.useComponentDefaultProps)("Collection", defaultProps, props), value = _useComponentDefaultProps.value, defaultValue = _useComponentDefaultProps.defaultValue, onChange = _useComponentDefaultProps.onChange, onRemoveItem = _useComponentDefaultProps.onRemoveItem, disabled = _useComponentDefaultProps.disabled, draggable = _useComponentDefaultProps.draggable, children = _useComponentDefaultProps.children, spacing = _useComponentDefaultProps.spacing, required = _useComponentDefaultProps.required, newItem = _useComponentDefaultProps.newItem, addLabel = _useComponentDefaultProps.addLabel, addDisabledTooltip = _useComponentDefaultProps.addDisabledTooltip, allowAdd = _useComponentDefaultProps.allowAdd, // Style props
|
|
33
|
+
var _useComponentDefaultProps = (0, _core.useComponentDefaultProps)("Collection", defaultProps, props), value = _useComponentDefaultProps.value, defaultValue = _useComponentDefaultProps.defaultValue, onChange = _useComponentDefaultProps.onChange, onRemoveItem = _useComponentDefaultProps.onRemoveItem, disabled = _useComponentDefaultProps.disabled, draggable = _useComponentDefaultProps.draggable, children = _useComponentDefaultProps.children, spacing = _useComponentDefaultProps.spacing, required = _useComponentDefaultProps.required, newItem = _useComponentDefaultProps.newItem, addLabel = _useComponentDefaultProps.addLabel, addDisabledTooltip = _useComponentDefaultProps.addDisabledTooltip, allowAdd = _useComponentDefaultProps.allowAdd, label = _useComponentDefaultProps.label, labelProps = _useComponentDefaultProps.labelProps, description = _useComponentDefaultProps.description, descriptionProps = _useComponentDefaultProps.descriptionProps, error = _useComponentDefaultProps.error, errorProps = _useComponentDefaultProps.errorProps, // Style props
|
|
34
34
|
classNames = _useComponentDefaultProps.classNames, className = _useComponentDefaultProps.className, styles = _useComponentDefaultProps.styles, unstyled = _useComponentDefaultProps.unstyled, others = _objectWithoutProperties(_useComponentDefaultProps, [
|
|
35
35
|
"value",
|
|
36
36
|
"defaultValue",
|
|
@@ -45,12 +45,18 @@ var Collection = function(props) {
|
|
|
45
45
|
"addLabel",
|
|
46
46
|
"addDisabledTooltip",
|
|
47
47
|
"allowAdd",
|
|
48
|
+
"label",
|
|
49
|
+
"labelProps",
|
|
50
|
+
"description",
|
|
51
|
+
"descriptionProps",
|
|
52
|
+
"error",
|
|
53
|
+
"errorProps",
|
|
48
54
|
"classNames",
|
|
49
55
|
"className",
|
|
50
56
|
"styles",
|
|
51
57
|
"unstyled"
|
|
52
58
|
]);
|
|
53
|
-
var _useStyles = (0,
|
|
59
|
+
var _useStyles = (0, _collectionStyles.default)(null, {
|
|
54
60
|
classNames: classNames,
|
|
55
61
|
name: "Collection",
|
|
56
62
|
styles: styles,
|
|
@@ -69,6 +75,24 @@ var Collection = function(props) {
|
|
|
69
75
|
onRemoveItem === null || onRemoveItem === void 0 ? void 0 : onRemoveItem(index);
|
|
70
76
|
};
|
|
71
77
|
};
|
|
78
|
+
var _label = label ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Input.Label, _objectSpreadProps(_objectSpread({
|
|
79
|
+
required: required
|
|
80
|
+
}, labelProps), {
|
|
81
|
+
children: label
|
|
82
|
+
})) : null;
|
|
83
|
+
var _description = description ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Input.Description, _objectSpreadProps(_objectSpread({}, descriptionProps), {
|
|
84
|
+
children: description
|
|
85
|
+
})) : null;
|
|
86
|
+
var _error = error ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Input.Error, _objectSpreadProps(_objectSpread({}, errorProps), {
|
|
87
|
+
children: error
|
|
88
|
+
})) : null;
|
|
89
|
+
var _header = _label || _description ? /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_core.Stack, {
|
|
90
|
+
spacing: "xs",
|
|
91
|
+
children: [
|
|
92
|
+
_label,
|
|
93
|
+
_description
|
|
94
|
+
]
|
|
95
|
+
}) : null;
|
|
72
96
|
var items = values.map(function(item, index) {
|
|
73
97
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_collectionItem.CollectionItem, {
|
|
74
98
|
disabled: disabled,
|
|
@@ -118,11 +142,17 @@ var Collection = function(props) {
|
|
|
118
142
|
className: cx(classes.root, className)
|
|
119
143
|
}), others), {
|
|
120
144
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_core.Stack, {
|
|
121
|
-
spacing: spacing,
|
|
122
145
|
children: [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
146
|
+
_header,
|
|
147
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_core.Stack, {
|
|
148
|
+
spacing: spacing,
|
|
149
|
+
children: [
|
|
150
|
+
items,
|
|
151
|
+
provided.placeholder,
|
|
152
|
+
_addButton,
|
|
153
|
+
_error
|
|
154
|
+
]
|
|
155
|
+
})
|
|
126
156
|
]
|
|
127
157
|
})
|
|
128
158
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n Button,\n DefaultProps,\n Group,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useId} from '@mantine/hooks';\nimport {ReactNode} from 'react';\nimport {DragDropContext, Droppable} from 'react-beautiful-dnd';\n\nimport {useControlledList} from '../../hooks';\nimport {CollectionItem} from './CollectionItem';\nimport useStyles from './Colllection.styles';\n\ninterface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The default value each new item should have\n */\n newItem: T;\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * The initial items of the collection (for uncontrolled usage only)\n */\n defaultValue?: T[];\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: (values: T[]) => boolean;\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The spacing between the colleciton items\n *\n * @default 'xs'\n */\n spacing?: MantineNumberSize;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n defaultValue,\n onChange,\n onRemoveItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const collectionID = useId('dnd-droppable');\n\n const [values, {append, remove, reorder}] = useControlledList({value, onChange, defaultValue});\n const hasOnlyOneItem = values.length === 1;\n const removeItem = (index: number) => () => {\n remove(index);\n onRemoveItem?.(index);\n };\n\n const items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={removeItem(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(values) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n return (\n <DragDropContext\n onDragEnd={({destination, source}) => reorder({from: source.index, to: destination?.index || 0})}\n >\n <Droppable direction=\"vertical\" droppableId={collectionID}>\n {(provided) => (\n <Box\n {...provided.droppableProps}\n ref={provided.innerRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <Stack spacing={spacing}>\n {items}\n {provided.placeholder}\n {_addButton}\n </Stack>\n </Box>\n )}\n </Droppable>\n </DragDropContext>\n );\n};\n"],"names":["Collection","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","props","useComponentDefaultProps","value","defaultValue","onChange","onRemoveItem","children","newItem","allowAdd","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","collectionID","useId","useControlledList","values","append","remove","reorder","hasOnlyOneItem","length","removeItem","index","items","map","item","CollectionItem","onRemove","removable","addAllowed","_addButton","Group","Tooltip","label","Box","Button","variant","leftIcon","AddSize16Px","height","onClick","DragDropContext","onDragEnd","destination","source","from","to","Droppable","direction","droppableId","provided","droppableProps","ref","innerRef","root","Stack","placeholder"],"mappings":"AAAA;;;;+BAgHaA;;;eAAAA;;;;;;;;;gCAhHa;oBAWnB;qBACa;iCAEqB;sBAET;8BACH;sEACP;AAqFtB,IAAMC,eAAkD;IACpDC,WAAW,KAAK;IAChBC,UAAU;IACVC,oBAAoB;IACpBC,UAAU,KAAK;IACfC,SAAS;IACTC,UAAU,KAAK;AACnB;AAEO,IAAMP,aAAa,SAAKQ,OAA8B;IACzD,IAsBIC,4BAAAA,IAAAA,8BAAwB,EAAC,cAAcR,cAAoCO,QArB3EE,QAqBAD,0BArBAC,OACAC,eAoBAF,0BApBAE,cACAC,WAmBAH,0BAnBAG,UACAC,eAkBAJ,0BAlBAI,cACAR,WAiBAI,0BAjBAJ,UACAH,YAgBAO,0BAhBAP,WACAY,WAeAL,0BAfAK,UACAR,UAcAG,0BAdAH,SACAC,WAaAE,0BAbAF,UACAQ,UAYAN,0BAZAM,SACAZ,WAWAM,0BAXAN,UACAC,qBAUAK,0BAVAL,oBACAY,WASAP,0BATAO,UAEA,cAAc;IACdC,aAMAR,0BANAQ,YACAC,YAKAT,0BALAS,WACAC,SAIAV,0BAJAU,QACAC,WAGAX,0BAHAW,UAEGC,kCACHZ;QArBAC;QACAC;QACAC;QACAC;QACAR;QACAH;QACAY;QACAR;QACAC;QACAQ;QACAZ;QACAC;QACAY;QAGAC;QACAC;QACAC;QACAC;;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AaC,eAAAA;YAAY1B,OAAAA,QAAQ;gBAAC2B,MAAMD,OAAOtB,KAAK;gBAAEwB,IAAIH,CAAAA,wBAAAA,yBAAAA,KAAAA,IAAAA,YAAarB,KAAK,AAAD,KAAK;YAAC;;kBAE9F,cAAA,qBAACyB,4BAAS;YAACC,WAAU;YAAWC,aAAarC;sBACxC,SAACsC;qCACE,qBAAChB,SAAG,wEACIgB,SAASC,cAAc;oBAC3BC,KAAKF,SAASG,QAAQ;oBACtBjD,WAAWO,GAAGD,QAAQ4C,IAAI,EAAElD;oBACxBG;8BAEJ,cAAA,sBAACgD,WAAK;wBAAC/D,SAASA;;4BACX+B;4BACA2B,SAASM,WAAW;4BACpB1B;;;;;;;AAO7B"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {\n Box,\n Button,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useId} from '@mantine/hooks';\nimport {ReactNode} from 'react';\nimport {DragDropContext, Droppable} from 'react-beautiful-dnd';\nimport {useControlledList} from '../../hooks';\nimport {CollectionItem} from './CollectionItem';\nimport useStyles from './Collection.styles';\n\ninterface CollectionProps<T>\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The default value each new item should have\n */\n newItem: T;\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * The initial items of the collection (for uncontrolled usage only)\n */\n defaultValue?: T[];\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: (values: T[]) => boolean;\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The spacing between the colleciton items\n *\n * @default 'xs'\n */\n spacing?: MantineNumberSize;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n defaultValue,\n onChange,\n onRemoveItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n label,\n labelProps,\n description,\n descriptionProps,\n error,\n errorProps,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const collectionID = useId('dnd-droppable');\n\n const [values, {append, remove, reorder}] = useControlledList({value, onChange, defaultValue});\n const hasOnlyOneItem = values.length === 1;\n const removeItem = (index: number) => () => {\n remove(index);\n onRemoveItem?.(index);\n };\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n const _error = error ? <Input.Error {...errorProps}>{error}</Input.Error> : null;\n const _header =\n _label || _description ? (\n <Stack spacing=\"xs\">\n {_label}\n {_description}\n </Stack>\n ) : null;\n\n const items = values.map((item, index) => (\n <CollectionItem\n key={index}\n disabled={disabled}\n draggable={draggable}\n index={index}\n onRemove={removeItem(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(values) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => append(newItem)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n return (\n <DragDropContext\n onDragEnd={({destination, source}) => reorder({from: source.index, to: destination?.index || 0})}\n >\n <Droppable direction=\"vertical\" droppableId={collectionID}>\n {(provided) => (\n <Box\n {...provided.droppableProps}\n ref={provided.innerRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <Stack>\n {_header}\n <Stack spacing={spacing}>\n {items}\n {provided.placeholder}\n {_addButton}\n {_error}\n </Stack>\n </Stack>\n </Box>\n )}\n </Droppable>\n </DragDropContext>\n );\n};\n"],"names":["Collection","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","props","useComponentDefaultProps","value","defaultValue","onChange","onRemoveItem","children","newItem","allowAdd","label","labelProps","description","descriptionProps","error","errorProps","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","collectionID","useId","useControlledList","values","append","remove","reorder","hasOnlyOneItem","length","removeItem","index","_label","Input","Label","_description","Description","_error","Error","_header","Stack","items","map","item","CollectionItem","onRemove","removable","addAllowed","_addButton","Group","Tooltip","Box","Button","variant","leftIcon","AddSize16Px","height","onClick","DragDropContext","onDragEnd","destination","source","from","to","Droppable","direction","droppableId","provided","droppableProps","ref","innerRef","root","placeholder"],"mappings":"AAAA;;;;+BAmHaA;;;eAAAA;;;;;;;;;gCAnHa;oBAanB;qBACa;iCAEqB;sBACT;8BACH;qEACP;AAuFtB,IAAMC,eAAkD;IACpDC,WAAW,KAAK;IAChBC,UAAU;IACVC,oBAAoB;IACpBC,UAAU,KAAK;IACfC,SAAS;IACTC,UAAU,KAAK;AACnB;AAEO,IAAMP,aAAa,SAAKQ,OAA8B;IACzD,IA4BIC,4BAAAA,IAAAA,8BAAwB,EAAC,cAAcR,cAAoCO,QA3B3EE,QA2BAD,0BA3BAC,OACAC,eA0BAF,0BA1BAE,cACAC,WAyBAH,0BAzBAG,UACAC,eAwBAJ,0BAxBAI,cACAR,WAuBAI,0BAvBAJ,UACAH,YAsBAO,0BAtBAP,WACAY,WAqBAL,0BArBAK,UACAR,UAoBAG,0BApBAH,SACAC,WAmBAE,0BAnBAF,UACAQ,UAkBAN,0BAlBAM,SACAZ,WAiBAM,0BAjBAN,UACAC,qBAgBAK,0BAhBAL,oBACAY,WAeAP,0BAfAO,UACAC,QAcAR,0BAdAQ,OACAC,aAaAT,0BAbAS,YACAC,cAYAV,0BAZAU,aACAC,mBAWAX,0BAXAW,kBACAC,QAUAZ,0BAVAY,OACAC,aASAb,0BATAa,YAEA,cAAc;IACdC,aAMAd,0BANAc,YACAC,YAKAf,0BALAe,WACAC,SAIAhB,0BAJAgB,QACAC,WAGAjB,0BAHAiB,UAEGC,kCACHlB;QA3BAC;QACAC;QACAC;QACAC;QACAR;QACAH;QACAY;QACAR;QACAC;QACAQ;QACAZ;QACAC;QACAY;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QAGAC;QACAC;QACAC;QACAC;;IAIJ,IAAsBE,aAAAA,IAAAA,yBAAS,EAAC,IAAI,EAAE;QAACL,YAAAA;QAAYM,MAAM;QAAcJ,QAAAA;QAAQC,UAAAA;IAAQ,IAAhFI,UAAeF,WAAfE,SAASC,K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AAG;0BACA,cAAA,qBAACC,YAAM;oBACHC,SAAQ;oBACRC,wBAAU,qBAACC,6BAAW;wBAACC,QAAQ;;oBAC/BC,SAAS;+BAAMhC,OAAOrB;;oBACtBV,UAAU,CAACqD;8BAEVvD;;;;MAKpB;IAED,qBACI,qBAACkE,kCAAe;QACZC,WAAW;gBAAEC,oBAAAA,aAAaC,eAAAA;YAAYlC,OAAAA,QAAQ;gBAACmC,MAAMD,OAAO9B,KAAK;gBAAEgC,IAAIH,CAAAA,wBAAAA,yBAAAA,KAAAA,IAAAA,YAAa7B,KAAK,AAAD,KAAK;YAAC;;kBAE9F,cAAA,qBAACiC,4BAAS;YAACC,WAAU;YAAWC,aAAa7C;sBACxC,SAAC8C;qCACE,qBAAChB,SAAG,wEACIgB,SAASC,cAAc;oBAC3BC,KAAKF,SAASG,QAAQ;oBACtBzD,WAAWO,GAAGD,QAAQoD,IAAI,EAAE1D;oBACxBG;8BAEJ,cAAA,sBAACwB,WAAK;;4BACDD;0CACD,sBAACC,WAAK;gCAAC7C,SAASA;;oCACX8C;oCACA0B,SAASK,WAAW;oCACpBxB;oCACAX;;;;;;;;;AAQjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/collection/Collection.styles.ts"],"sourcesContent":["import {createStyles} from '@mantine/core';\n\nexport interface CollectionStylesParams {}\n\nexport default createStyles((theme) => ({\n root: {},\n item: {\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n alignItems: 'baseline',\n },\n itemDragging: {\n boxShadow: theme.shadows.sm,\n },\n}));\n"],"names":["createStyles","theme","root","item","backgroundColor","colorScheme","white","black","alignItems","itemDragging","boxShadow","shadows","sm"],"mappings":"AAAA;;;;+BAIA;;;eAAA;;;oBAJ2B;IAI3B,WAAeA,IAAAA,kBAAY,EAAC,SAACC;WAAW;QACpCC,MAAM,CAAC;QACPC,MAAM;YACFC,iBAAiBH,MAAMI,WAAW,KAAK,UAAUJ,MAAMK,KAAK,GAAGL,MAAMM,KAAK;YAC1EC,YAAY;QAChB;QACAC,cAAc;YACVC,WAAWT,MAAMU,OAAO,CAACC,EAAE;QAC/B;IACJ"}
|
|
@@ -17,7 +17,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
17
17
|
var _plasmaReactIcons = require("@coveord/plasma-react-icons");
|
|
18
18
|
var _core = require("@mantine/core");
|
|
19
19
|
var _reactBeautifulDnd = require("react-beautiful-dnd");
|
|
20
|
-
var
|
|
20
|
+
var _collectionStyles = /*#__PURE__*/ _interopRequireDefault(require("./Collection.styles"));
|
|
21
21
|
var RemoveButton = function(param) {
|
|
22
22
|
var onClick = param.onClick;
|
|
23
23
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.ActionIcon, {
|
|
@@ -38,7 +38,7 @@ var RemoveButtonPlaceholder = function() {
|
|
|
38
38
|
};
|
|
39
39
|
var StaticCollectionItem = function(param) {
|
|
40
40
|
var onRemove = param.onRemove, _param_removable = param.removable, removable = _param_removable === void 0 ? true : _param_removable, styles = param.styles, children = param.children;
|
|
41
|
-
var _useStyles = (0,
|
|
41
|
+
var _useStyles = (0, _collectionStyles.default)(null, {
|
|
42
42
|
name: "Collection",
|
|
43
43
|
styles: styles
|
|
44
44
|
}), classes = _useStyles.classes, cx = _useStyles.cx;
|
|
@@ -55,7 +55,7 @@ var StaticCollectionItem = function(param) {
|
|
|
55
55
|
};
|
|
56
56
|
var DisabledCollectionItem = function(param) {
|
|
57
57
|
var children = param.children;
|
|
58
|
-
var _useStyles = (0,
|
|
58
|
+
var _useStyles = (0, _collectionStyles.default)(), classes = _useStyles.classes, cx = _useStyles.cx;
|
|
59
59
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Group, {
|
|
60
60
|
className: cx(classes.item),
|
|
61
61
|
children: children
|
|
@@ -63,7 +63,7 @@ var DisabledCollectionItem = function(param) {
|
|
|
63
63
|
};
|
|
64
64
|
var DraggableCollectionItem = function(param) {
|
|
65
65
|
var index = param.index, onRemove = param.onRemove, _param_removable = param.removable, removable = _param_removable === void 0 ? true : _param_removable, styles = param.styles, children = param.children;
|
|
66
|
-
var _useStyles = (0,
|
|
66
|
+
var _useStyles = (0, _collectionStyles.default)(null, {
|
|
67
67
|
name: "Collection",
|
|
68
68
|
styles: styles
|
|
69
69
|
}), classes = _useStyles.classes, cx = _useStyles.cx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/collection/CollectionItem.tsx"],"sourcesContent":["import {DragAndDropSize16Px, RemoveSize16Px} from '@coveord/plasma-react-icons';\nimport {ActionIcon, DefaultProps, Group, Selectors} from '@mantine/core';\nimport {FunctionComponent, PropsWithChildren} from 'react';\nimport {Draggable} from 'react-beautiful-dnd';\n\nimport useStyles from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/collection/CollectionItem.tsx"],"sourcesContent":["import {DragAndDropSize16Px, RemoveSize16Px} from '@coveord/plasma-react-icons';\nimport {ActionIcon, DefaultProps, Group, Selectors} from '@mantine/core';\nimport {FunctionComponent, PropsWithChildren} from 'react';\nimport {Draggable} from 'react-beautiful-dnd';\n\nimport useStyles from './Collection.styles';\n\ninterface CollectionItemProps extends CollectionItemSharedProps {\n draggable?: boolean;\n disabled: boolean;\n}\n\ninterface CollectionItemSharedProps extends DefaultProps<Selectors<typeof useStyles>> {\n index: number;\n onRemove?: React.MouseEventHandler<HTMLButtonElement>;\n removable?: boolean;\n}\n\nconst RemoveButton: FunctionComponent<{\n onClick: React.MouseEventHandler<HTMLButtonElement>;\n}> = ({onClick}) => (\n <ActionIcon variant=\"subtle\" onClick={onClick} color=\"action\">\n <RemoveSize16Px height={16} />\n </ActionIcon>\n);\n\nconst RemoveButtonPlaceholder = () => <div style={{width: 28}} />;\n\nconst StaticCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = ({\n onRemove,\n removable = true,\n styles,\n children,\n}) => {\n const {classes, cx} = useStyles(null, {name: 'Collection', styles});\n const removeButton = removable && onRemove ? <RemoveButton onClick={onRemove} /> : <RemoveButtonPlaceholder />;\n\n return (\n <Group className={cx(classes.item)}>\n {children}\n {removeButton}\n </Group>\n );\n};\n\nconst DisabledCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = ({children}) => {\n const {classes, cx} = useStyles();\n return <Group className={cx(classes.item)}>{children}</Group>;\n};\n\nconst DraggableCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = ({\n index,\n onRemove,\n removable = true,\n styles,\n children,\n}) => {\n const {classes, cx} = useStyles(null, {name: 'Collection', styles});\n const removeButton = removable && onRemove ? <RemoveButton onClick={onRemove} /> : null;\n\n return (\n <Draggable index={index} draggableId={index.toString()}>\n {(provided, {isDragging}) => (\n <Group\n ref={provided.innerRef}\n {...provided.draggableProps}\n className={cx(classes.item, {[classes.itemDragging]: isDragging})}\n >\n <div {...provided.dragHandleProps}>\n <DragAndDropSize16Px height={16} />\n </div>\n {children}\n {removeButton}\n </Group>\n )}\n </Draggable>\n );\n};\n\nexport const CollectionItem: FunctionComponent<PropsWithChildren<CollectionItemProps>> = ({\n draggable,\n disabled,\n ...otherProps\n}) => {\n if (disabled) {\n return <DisabledCollectionItem {...otherProps} />;\n }\n if (draggable) {\n return <DraggableCollectionItem {...otherProps} />;\n }\n return <StaticCollectionItem {...otherProps} />;\n};\n"],"names":["CollectionItem","RemoveButton","onClick","ActionIcon","variant","color","RemoveSize16Px","height","RemoveButtonPlaceholder","div","style","width","StaticCollectionItem","onRemove","removable","styles","children","useStyles","name","classes","cx","removeButton","Group","className","item","DisabledCollectionItem","DraggableCollectionItem","index","Draggable","draggableId","toString","provided","isDragging","ref","innerRef","draggableProps","itemDragging","dragHandleProps","DragAndDropSize16Px","draggable","disabled","otherProps"],"mappings":"AAAA;;;;+BA+EaA;;;eAAAA;;;;;;;;;gCA/EqC;oBACO;iCAEjC;qEAEF;AAatB,IAAMC,eAED;QAAEC,gBAAAA;yBACH,qBAACC,gBAAU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gBAC3BZ,WAAWH,GAAGD,QAAQK,IAAI,EAAG,oBAACL,QAAQiB,YAAY,EAAGJ;;kCAErD,qBAACvB,4CAAQsB,SAASM,eAAe;kCAC7B,cAAA,qBAACC,qCAAmB;4BAAC/B,QAAQ;;;oBAEhCS;oBACAK;;;;;AAKrB;AAEO,IAAMrB,iBAA4E,iBAInF;QAHFuC,mBAAAA,WACAC,kBAAAA,UACGC;QAFHF;QACAC;;IAGA,IAAIA,UAAU;QACV,qBAAO,qBAACf,0CAA2BgB;IACvC,CAAC;IACD,IAAIF,WAAW;QACX,qBAAO,qBAACb,2CAA4Be;IACxC,CAAC;IACD,qBAAO,qBAAC7B,wCAAyB6B;AACrC"}
|
|
@@ -11,7 +11,7 @@ interface CodeEditorProps extends Omit<InputWrapperBaseProps, 'inputContainer' |
|
|
|
11
11
|
*
|
|
12
12
|
* @default 'plaintext'
|
|
13
13
|
*/
|
|
14
|
-
language?: 'plaintext' | 'json' | 'markdown' | 'python';
|
|
14
|
+
language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';
|
|
15
15
|
/** Default value for uncontrolled input */
|
|
16
16
|
defaultValue?: string;
|
|
17
17
|
/** Value for controlled input */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAMH,YAAY,EAGZ,qBAAqB,EAErB,SAAS,EAKZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,iBAAiB,EAAsB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAMH,YAAY,EAGZ,qBAAqB,EAErB,SAAS,EAKZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,iBAAiB,EAAsB,MAAM,OAAO,CAAC;AAK7D,QAAA,MAAM,SAAS;;;;CAQZ,CAAC;AAEJ,UAAU,eACN,SAAQ,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,GAAG,mBAAmB,CAAC,EACvE,YAAY,CAAC,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;IAChE,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,qDAAqD;IACrD,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;CAClC;AASD,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CA6IzD,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
import {
|
|
2
|
+
import { EditorProps } from '@monaco-editor/react';
|
|
3
3
|
import { FunctionComponent } from 'react';
|
|
4
4
|
declare const MockedEditor: FunctionComponent<EditorProps>;
|
|
5
5
|
export default MockedEditor;
|
|
6
6
|
export declare const loader: {
|
|
7
7
|
config: jest.Mock<any, any>;
|
|
8
8
|
};
|
|
9
|
+
export declare const useMonaco: () => jest.Mock<any, any>;
|
|
9
10
|
//# sourceMappingURL=react.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../../../../src/components/code-editor/__mocks__/@monaco-editor/react.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../../../../src/components/code-editor/__mocks__/@monaco-editor/react.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAExC,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,WAAW,CAAkD,CAAC;AAEpG,eAAe,YAAY,CAAC;AAE5B,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,eAAO,MAAM,SAAS,2BAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../../../../src/components/code-editor/languages/xml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AA0C5C,eAAO,MAAM,GAAG;uBAXU,MAAM,KAAG,IAAI;CAWV,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DefaultProps, MantineNumberSize, Selectors } from '@mantine/core';
|
|
1
|
+
import { DefaultProps, InputWrapperBaseProps, MantineNumberSize, Selectors } from '@mantine/core';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import useStyles from './
|
|
4
|
-
interface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {
|
|
3
|
+
import useStyles from './Collection.styles';
|
|
4
|
+
interface CollectionProps<T> extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>, DefaultProps<Selectors<typeof useStyles>> {
|
|
5
5
|
/**
|
|
6
6
|
* The default value each new item should have
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../../src/components/collection/Collection.tsx"],"names":[],"mappings":"AACA,OAAO,EAGH,YAAY,
|
|
1
|
+
{"version":3,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C5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAWD,eAAO,MAAM,UAAU,+CAqHtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collection.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/collection/Collection.styles.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;CAAG;;;;;;AAE1C,wBASI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DefaultProps, Selectors } from '@mantine/core';
|
|
2
2
|
import { FunctionComponent, PropsWithChildren } from 'react';
|
|
3
|
-
import useStyles from './
|
|
3
|
+
import useStyles from './Collection.styles';
|
|
4
4
|
interface CollectionItemProps extends CollectionItemSharedProps {
|
|
5
5
|
draggable?: boolean;
|
|
6
6
|
disabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionItem.d.ts","sourceRoot":"","sources":["../../../../src/components/collection/CollectionItem.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAS,SAAS,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAG3D,OAAO,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"CollectionItem.d.ts","sourceRoot":"","sources":["../../../../src/components/collection/CollectionItem.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAS,SAAS,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAG3D,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,UAAU,mBAAoB,SAAQ,yBAAyB;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,yBAA0B,SAAQ,YAAY,CAAC,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AA+DD,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAYpF,CAAC"}
|
|
@@ -8,9 +8,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
import { CheckSize16Px, CopySize16Px } from "@coveord/plasma-react-icons";
|
|
9
9
|
import { ActionIcon, Box, Center, CopyButton, createStyles, Group, Input, Loader, Space, Stack, Tooltip, useComponentDefaultProps } from "@mantine/core";
|
|
10
10
|
import { useUncontrolled } from "@mantine/hooks";
|
|
11
|
-
import Editor, { loader } from "@monaco-editor/react";
|
|
11
|
+
import Editor, { loader, useMonaco } from "@monaco-editor/react";
|
|
12
12
|
import { useEffect, useState } from "react";
|
|
13
13
|
import { useParentHeight } from "../../hooks";
|
|
14
|
+
import { XML } from "./languages/xml";
|
|
14
15
|
var useStyles = createStyles(function(theme) {
|
|
15
16
|
return {
|
|
16
17
|
root: {},
|
|
@@ -48,6 +49,8 @@ export var CodeEditor = function(props) {
|
|
|
48
49
|
"monacoLoader"
|
|
49
50
|
]);
|
|
50
51
|
var _useState = _sliced_to_array(useState(false), 2), loaded = _useState[0], setLoaded = _useState[1];
|
|
52
|
+
var _useState1 = _sliced_to_array(useState(false), 2), registered = _useState1[0], setRegistered = _useState1[1];
|
|
53
|
+
var monaco = useMonaco();
|
|
51
54
|
var _useStyles = useStyles(), classes = _useStyles.classes, theme = _useStyles.theme;
|
|
52
55
|
var _useUncontrolled = _sliced_to_array(useUncontrolled({
|
|
53
56
|
value: value,
|
|
@@ -58,7 +61,7 @@ export var CodeEditor = function(props) {
|
|
|
58
61
|
var _useParentHeight = _sliced_to_array(useParentHeight(), 2), parentHeight = _useParentHeight[0], ref = _useParentHeight[1];
|
|
59
62
|
var loadLocalMonaco = function() {
|
|
60
63
|
var _ref = _async_to_generator(function() {
|
|
61
|
-
var
|
|
64
|
+
var monacoInstance;
|
|
62
65
|
return _ts_generator(this, function(_state) {
|
|
63
66
|
switch(_state.label){
|
|
64
67
|
case 0:
|
|
@@ -67,9 +70,9 @@ export var CodeEditor = function(props) {
|
|
|
67
70
|
import("monaco-editor")
|
|
68
71
|
];
|
|
69
72
|
case 1:
|
|
70
|
-
|
|
73
|
+
monacoInstance = _state.sent();
|
|
71
74
|
loader.config({
|
|
72
|
-
monaco:
|
|
75
|
+
monaco: monacoInstance
|
|
73
76
|
});
|
|
74
77
|
setLoaded(true);
|
|
75
78
|
return [
|
|
@@ -89,6 +92,15 @@ export var CodeEditor = function(props) {
|
|
|
89
92
|
setLoaded(true);
|
|
90
93
|
}
|
|
91
94
|
}, []);
|
|
95
|
+
useEffect(function() {
|
|
96
|
+
if (monaco && language === "xml" && !registered) {
|
|
97
|
+
XML.register(monaco);
|
|
98
|
+
setRegistered(true);
|
|
99
|
+
}
|
|
100
|
+
}, [
|
|
101
|
+
monaco,
|
|
102
|
+
language
|
|
103
|
+
]);
|
|
92
104
|
var _label = label ? /*#__PURE__*/ _jsx(Input.Label, _object_spread_props(_object_spread({
|
|
93
105
|
required: required
|
|
94
106
|
}, labelProps), {
|