@nethru/ui 2.1.1 → 2.1.3

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.
@@ -20,6 +20,22 @@ const AddableFormList = /*#__PURE__*/forwardRef(({
20
20
  ...props
21
21
  }, ref) => {
22
22
  const removable = useMemo(() => allowEmpty || forms.length > 1, [allowEmpty, forms.length]);
23
+ const rightMargins = useMemo(() => {
24
+ const margins = [25, 30];
25
+ const counts = forms.map((form, index) => {
26
+ let count = 0;
27
+ if (!readOnly) {
28
+ if (showRemoveButton && renderButton(form, index)[0]) count++;
29
+ if (showAddButton && renderButton(form, index)[1]) count++;
30
+ }
31
+ return count;
32
+ });
33
+ const max = Math.max(...counts);
34
+ return counts.map((count, index) => {
35
+ const diff = max - count;
36
+ if (diff === 2) return margins[0] + margins[1];else if (diff === 1) return margins[count];else return 0;
37
+ });
38
+ }, [showAddButton, showRemoveButton, renderButton, forms, readOnly]);
23
39
  return /*#__PURE__*/_jsx(Stack, {
24
40
  ref: ref,
25
41
  gap: gap,
@@ -34,6 +50,7 @@ const AddableFormList = /*#__PURE__*/forwardRef(({
34
50
  alignItems: "start",
35
51
  gap: 1,
36
52
  marginTop: `${margins[index > 0 ? 1 : 0]}px`,
53
+ marginRight: `${rightMargins[index]}px`,
37
54
  children: [showRemoveButton && renderButton(form, index)[0] && /*#__PURE__*/_jsx(Tooltip, {
38
55
  title: "\uC0AD\uC81C",
39
56
  children: /*#__PURE__*/_jsx(IconButton, {
@@ -7,6 +7,8 @@ import { nScript } from './nScript';
7
7
  import { Decoration, EditorView } from "@codemirror/view";
8
8
  import { RegExpCursor, SearchCursor } from '@codemirror/search';
9
9
  import { StateEffect, StateField } from "@codemirror/state";
10
+ import { keymap as keyMapper } from '@codemirror/view';
11
+ import { defaultKeymap } from '@codemirror/commands';
10
12
  import borderRadius from "../styles/borderRadius";
11
13
  import { blue, grey, red, yellow } from "../colors";
12
14
  import typography from "../styles/typography";
@@ -19,6 +21,7 @@ export default function Editor({
19
21
  error = false,
20
22
  helperText,
21
23
  basicSetup,
24
+ keymap = [],
22
25
  extensions = [],
23
26
  format = 'javascript',
24
27
  keyword,
@@ -139,8 +142,11 @@ export default function Editor({
139
142
  });
140
143
  }
141
144
  }, [format]);
145
+ const keymapExtension = useMemo(() => {
146
+ return [keyMapper.of(keymap), keyMapper.of(defaultKeymap)];
147
+ }, [keymap]);
142
148
  const extensionList = useMemo(() => {
143
- const result = [languageExtension, EditorView.lineWrapping, highlight.extension];
149
+ const result = [languageExtension, EditorView.lineWrapping, highlight.extension, ...keymapExtension];
144
150
  if (onScroll) {
145
151
  result.push(EditorView.domEventHandlers({
146
152
  scroll(event, view) {
@@ -151,7 +157,7 @@ export default function Editor({
151
157
  }
152
158
  result.push(...extensions);
153
159
  return result;
154
- }, [languageExtension, highlight.extension, extensions, onScroll]);
160
+ }, [languageExtension, highlight.extension, keymapExtension, extensions, onScroll]);
155
161
  const handleUpdate = viewUpdate => {
156
162
  setFocused(viewUpdate.view.hasFocus);
157
163
  if (onUpdate) onUpdate(viewUpdate);
@@ -2,6 +2,10 @@ import { grey } from "../../colors";
2
2
  import borderRadius from "../borderRadius";
3
3
  import typography from "../typography";
4
4
  export const styles = {
5
+ defaultProps: {
6
+ variant: 'normal',
7
+ disableRipple: true
8
+ },
5
9
  variants: [{
6
10
  props: {
7
11
  variant: 'normal'
@@ -40,9 +44,6 @@ export const styles = {
40
44
  }
41
45
  }
42
46
  }],
43
- defaultProps: {
44
- variant: 'normal'
45
- },
46
47
  styleOverrides: {
47
48
  root: {
48
49
  fontFamily: typography.fontFamily,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "main": "base/index.js",
5
5
  "files": [
6
6
  "/base"