ronds-metadata 1.2.28 → 1.2.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,6 @@
7
7
  }
8
8
 
9
9
  [data-texty-tooltip] {
10
- margin: 6px 0;
11
10
  padding: 4px 10px;
12
11
  border-radius: 4px;
13
12
  background-color: #222;
@@ -67,7 +67,7 @@ var Canvas = function Canvas() {
67
67
  return /*#__PURE__*/React.createElement("div", {
68
68
  style: {
69
69
  height: '100%',
70
- width: '60%',
70
+ width: '100%',
71
71
  padding: '4px'
72
72
  }
73
73
  }, /*#__PURE__*/React.createElement("div", {
@@ -111,7 +111,7 @@ var Settings = function Settings() {
111
111
  return /*#__PURE__*/React.createElement("div", {
112
112
  style: {
113
113
  height: '100%',
114
- width: '23%',
114
+ width: '100%',
115
115
  padding: '4px'
116
116
  }
117
117
  }, /*#__PURE__*/React.createElement(_Tabs, {
@@ -8,7 +8,7 @@ var Sidebar = function Sidebar() {
8
8
  return /*#__PURE__*/React.createElement("div", {
9
9
  style: {
10
10
  height: '100%',
11
- width: '17%',
11
+ width: '100%',
12
12
  padding: '4px',
13
13
  overflowY: 'auto'
14
14
  }
@@ -4,11 +4,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-04 13:45:31
7
- * @LastEditTime: 2023-03-23 13:53:13
7
+ * @LastEditTime: 2023-04-01 09:37:13
8
8
  */
9
9
  import React from 'react';
10
10
  import { DndProvider } from 'react-dnd';
11
11
  import { HTML5Backend } from 'react-dnd-html5-backend';
12
+ import Split from '../Split';
12
13
  import Canvas from './comps/Canvas';
13
14
  import Settings from './comps/Settings';
14
15
  import Sidebar from './comps/Sidebar';
@@ -42,7 +43,7 @@ var FormGenerator = function FormGenerator(props) {
42
43
  var birthday = robot.date('birthday').label('出身年月').require().valueOf();
43
44
 
44
45
  var detail = robot.object([name, age], 'detail').valueOf();
45
- var arr = robot.create([name, age, address, sex, birthday, detail]);
46
+ var arr = robot.create([name, age, address, sex, birthday, detail]).grid(2).toString();
46
47
  }, []);
47
48
  React.useEffect(function () {
48
49
  if (defaultSchema) {
@@ -77,7 +78,10 @@ var FormGenerator = function FormGenerator(props) {
77
78
  context: window
78
79
  }, /*#__PURE__*/React.createElement("div", {
79
80
  className: "form-generator-container"
80
- }, /*#__PURE__*/React.createElement(Sidebar, null), /*#__PURE__*/React.createElement(Canvas, null), /*#__PURE__*/React.createElement(Settings, null)))));
81
+ }, /*#__PURE__*/React.createElement(Split, {
82
+ sizes: [20, 60, 20],
83
+ gutterSize: 0
84
+ }, /*#__PURE__*/React.createElement(Sidebar, null), /*#__PURE__*/React.createElement(Canvas, null), /*#__PURE__*/React.createElement(Settings, null))))));
81
85
  };
82
86
 
83
87
  export default FormGenerator;
@@ -1,5 +1,4 @@
1
1
  .form-generator-container {
2
- display: flex;
3
2
  width: 100%;
4
3
  height: 100%;
5
4
 
@@ -4,7 +4,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-08 14:45:46
7
- * @LastEditTime: 2023-03-22 11:28:46
7
+ * @LastEditTime: 2023-03-25 11:33:24
8
8
  */
9
9
  import { deepClone } from '../../utils';
10
10
  import { basicComps, complexComps, layoutComps } from './settings';
@@ -90,7 +90,7 @@ export var transFG2Schema = function transFG2Schema(nodes, settings, _types, sch
90
90
  props.push(_prop);
91
91
  }
92
92
 
93
- schema[0].properties = [].concat(props);
93
+ schema[0].properties = [].concat(props); // 整个表格的扩展规则
94
94
 
95
95
  if (settings && (settings === null || settings === void 0 ? void 0 : settings.formSetting)) {
96
96
  schema[0].fields[0].value = deepClone(settings.formSetting);
@@ -17,7 +17,7 @@ import _Input from "antd/es/input";
17
17
  /*
18
18
  * @Author: wangxian
19
19
  * @Date: 2021-09-18 14:15:04
20
- * @LastEditTime: 2023-03-08 15:50:12
20
+ * @LastEditTime: 2023-04-04 09:20:39
21
21
  */
22
22
  import React from 'react';
23
23
  import { UploadOutlined } from '@ant-design/icons';
@@ -76,6 +76,8 @@ function Index(props) {
76
76
 
77
77
  case 'textarea':
78
78
  return /*#__PURE__*/React.createElement(TextArea, {
79
+ showCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.showCount,
80
+ maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
79
81
  rows: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.textareaRows) || 4,
80
82
  disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
81
83
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
@@ -114,6 +116,8 @@ function Index(props) {
114
116
  value: v
115
117
  }, v);
116
118
  }))) : undefined,
119
+ showCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.showCount,
120
+ maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
117
121
  disabled: (_extraInfo$disabled6 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled6 !== void 0 ? _extraInfo$disabled6 : disabled,
118
122
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
119
123
  allowClear: true,
@@ -23,6 +23,10 @@ import "antd/es/tree-select/style";
23
23
  import _TreeSelect from "antd/es/tree-select";
24
24
  import "antd/es/cascader/style";
25
25
  import _Cascader from "antd/es/cascader";
26
+ import "antd/es/tooltip/style";
27
+ import _Tooltip from "antd/es/tooltip";
28
+ import "antd/es/tag/style";
29
+ import _Tag from "antd/es/tag";
26
30
  import _typeof from "@babel/runtime/helpers/esm/typeof";
27
31
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
28
32
  import _regeneratorRuntime from "@babel/runtime/regenerator";
@@ -34,7 +38,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
34
38
  /*
35
39
  * @Author:wangxian
36
40
  * @Date: 2021-09-18 14:15:04
37
- * @LastEditTime: 2023-03-10 11:38:33
41
+ * @LastEditTime: 2023-04-03 15:47:01
38
42
  */
39
43
  import React from 'react';
40
44
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -417,6 +421,23 @@ function Index(props) {
417
421
  }
418
422
  };
419
423
 
424
+ var maxTagPlaceholder = function maxTagPlaceholder(omittedValues) {
425
+ if (omittedValues) {
426
+ return /*#__PURE__*/React.createElement(_Tooltip, {
427
+ title: omittedValues.map(function (it) {
428
+ return /*#__PURE__*/React.createElement("div", {
429
+ key: it.key,
430
+ style: {
431
+ paddingBottom: '8px'
432
+ }
433
+ }, /*#__PURE__*/React.createElement(_Tag, null, it === null || it === void 0 ? void 0 : it.label));
434
+ })
435
+ }, "+ ", omittedValues.length, " ...");
436
+ } else {
437
+ return '...';
438
+ }
439
+ };
440
+
420
441
  var processSelectType = function processSelectType(isCascader, isTreeSelect, isPagination) {
421
442
  if (isCascader) {
422
443
  var _extraInfo$disabled;
@@ -453,11 +474,10 @@ function Index(props) {
453
474
  treeData: treeData,
454
475
  allowClear: true,
455
476
  disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
456
- placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder // treeDefaultExpandAll
457
- ,
477
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
458
478
  maxTagCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagCount,
459
479
  maxTagTextLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagTextLength,
460
- maxTagPlaceholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagPlaceholder
480
+ maxTagPlaceholder: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagPlaceholder) || maxTagPlaceholder
461
481
  });
462
482
  } else if (isPagination) {
463
483
  var _extraInfo$disabled3;
@@ -545,7 +565,7 @@ function Index(props) {
545
565
  onChange: onSelectChange,
546
566
  maxTagCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagCount,
547
567
  maxTagTextLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagTextLength,
548
- maxTagPlaceholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagPlaceholder
568
+ maxTagPlaceholder: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagPlaceholder) || maxTagPlaceholder
549
569
  });
550
570
  }
551
571
  };
@@ -121,7 +121,7 @@ var MetadataForm = function MetadataForm(props) {
121
121
  if (firstLoadValue.current) {
122
122
  firstLoadValue.current = false;
123
123
  stream$.next({
124
- type: 'onValuesChange',
124
+ type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
125
125
  payload: {
126
126
  val: vals,
127
127
  allVals: vals,
@@ -13,6 +13,12 @@
13
13
  padding: 0 0 2px !important;
14
14
  }
15
15
 
16
+ // .ant-select-selection-overflow {
17
+ // flex-wrap: nowrap;
18
+ // overflow: hidden !important;
19
+ // min-height: 26px;
20
+ // }
21
+
16
22
  .ant-input-number,
17
23
  .ant-picker {
18
24
  width: 100%;
@@ -0,0 +1,25 @@
1
+ import React, { ReactNode } from 'react';
2
+ import './index.less';
3
+ interface IPrpos {
4
+ sizes?: number[];
5
+ minSize?: number | number[];
6
+ expandToMin?: boolean;
7
+ gutterSize?: number;
8
+ gutterAlign?: 'center' | 'start' | 'end';
9
+ snapOffset?: number;
10
+ dragInterval?: number;
11
+ direction?: 'horizontal' | 'vertical';
12
+ cursor?: string;
13
+ gutter?: (index: number, direction: any) => HTMLElement;
14
+ elementStyle?: (dimension: 'width' | 'height', elementSize: number, gutterSize: number, index: number) => Partial<CSSStyleDeclaration>;
15
+ gutterStyle?: (dimension: 'width' | 'height', gutterSize: number, index: number) => Partial<CSSStyleDeclaration>;
16
+ onDrag?: (sizes: number[]) => void;
17
+ onDragStart?: (sizes: number[]) => void;
18
+ onDragEnd?: (sizes: number[]) => void;
19
+ className?: string;
20
+ style?: React.CSSProperties;
21
+ children: ReactNode;
22
+ }
23
+ /** antd的card不能直接放在children里 外层套一个div */
24
+ declare const Index: (props: IPrpos) => JSX.Element;
25
+ export default Index;
@@ -0,0 +1,52 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2023-03-25 09:31:21
4
+ * @LastEditTime: 2023-03-25 10:22:21
5
+ */
6
+ import React from 'react';
7
+ import Split from 'react-split';
8
+ import './index.less';
9
+ import classNames from 'classnames';
10
+ /** antd的card不能直接放在children里 外层套一个div */
11
+
12
+ var Index = function Index(props) {
13
+ var className = props.className,
14
+ style = props.style,
15
+ _props$sizes = props.sizes,
16
+ sizes = _props$sizes === void 0 ? [20, 80] : _props$sizes,
17
+ _props$gutterSize = props.gutterSize,
18
+ gutterSize = _props$gutterSize === void 0 ? 5 : _props$gutterSize,
19
+ _props$dragInterval = props.dragInterval,
20
+ dragInterval = _props$dragInterval === void 0 ? 1 : _props$dragInterval,
21
+ _props$minSize = props.minSize,
22
+ minSize = _props$minSize === void 0 ? 0 : _props$minSize,
23
+ children = props.children,
24
+ _props$direction = props.direction,
25
+ direction = _props$direction === void 0 ? 'horizontal' : _props$direction,
26
+ _props$cursor = props.cursor,
27
+ cursor = _props$cursor === void 0 ? 'col-resize' : _props$cursor,
28
+ gutter = props.gutter,
29
+ elementStyle = props.elementStyle,
30
+ gutterStyle = props.gutterStyle,
31
+ onDrag = props.onDrag,
32
+ onDragStart = props.onDragStart,
33
+ onDragEnd = props.onDragEnd;
34
+ return /*#__PURE__*/React.createElement(Split, {
35
+ className: classNames('split-panel', className),
36
+ dragInterval: dragInterval,
37
+ gutterSize: gutterSize,
38
+ sizes: sizes,
39
+ minSize: minSize,
40
+ direction: direction,
41
+ style: style,
42
+ cursor: cursor,
43
+ gutter: gutter,
44
+ elementStyle: elementStyle,
45
+ gutterStyle: gutterStyle,
46
+ onDrag: onDrag,
47
+ onDragStart: onDragStart,
48
+ onDragEnd: onDragEnd
49
+ }, children);
50
+ };
51
+
52
+ export default Index;
@@ -0,0 +1,29 @@
1
+ .split-panel {
2
+ width: 100%;
3
+ height: 100%;
4
+ overflow: hidden;
5
+
6
+ .gutter {
7
+ width: 100%;
8
+ height: 100%;
9
+
10
+ background-color: #bebebe;
11
+ background-repeat: no-repeat;
12
+ background-position: 50%;
13
+
14
+ .gutter-vertical {
15
+ cursor: row-resize;
16
+ }
17
+
18
+ .gutter-horizontal {
19
+ cursor: col-resize;
20
+ }
21
+ }
22
+
23
+ > * {
24
+ height: 100%;
25
+ width: 100%;
26
+ float: left;
27
+ position: relative;
28
+ }
29
+ }
@@ -0,0 +1 @@
1
+ export default function (): JSX.Element;
@@ -0,0 +1,115 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import React, { useState } from 'react';
4
+ import { from, of } from 'rxjs';
5
+ import { debounceTime, map, startWith, switchMap, endWith, catchError } from 'rxjs/operators';
6
+ import { useRxObservable, useRxStore, useRxEffect } from '../hooks';
7
+ export default function () {
8
+ // 创建一个可观察的对象
9
+ var store = useRxStore({
10
+ initialValue: {
11
+ a: 1,
12
+ b: 2,
13
+ c: 0,
14
+ loading: ''
15
+ }
16
+ });
17
+ var storeVal = useRxObservable(function () {
18
+ return store.select(function (p) {
19
+ return p;
20
+ });
21
+ }); // console.log('storeVal', storeVal);
22
+ // 将流转换为state
23
+
24
+ var a = useRxObservable(function () {
25
+ return store.select(function (p) {
26
+ return p.a;
27
+ });
28
+ });
29
+ var c1 = useRxObservable(function () {
30
+ return store.select(function (p) {
31
+ return p.c;
32
+ });
33
+ });
34
+ var b = useRxObservable(function () {
35
+ return store.valueChanges.pipe(map(function (p) {
36
+ return p.b;
37
+ }));
38
+ });
39
+ var c = useRxObservable(function () {
40
+ return store.select(function (p) {
41
+ return {
42
+ a: p.a,
43
+ b: p.b
44
+ };
45
+ }).pipe(debounceTime(1000), map(function (p) {
46
+ return store.value.a * store.value.b;
47
+ }));
48
+ });
49
+ var d = useRxEffect(function (event$) {
50
+ event$.pipe(debounceTime(100)).subscribe(function (p) {
51
+ store.update(function (pre) {
52
+ return _objectSpread(_objectSpread({}, pre), {}, {
53
+ b: pre.b + 100
54
+ });
55
+ });
56
+ });
57
+ });
58
+
59
+ var _useState = useState(1),
60
+ _useState2 = _slicedToArray(_useState, 2),
61
+ count = _useState2[0],
62
+ setCount = _useState2[1];
63
+
64
+ var getData = function getData() {
65
+ return new Promise(function (resolve, reject) {
66
+ setTimeout(function () {
67
+ resolve(store.value.a * store.value.b); // reject('dddd');
68
+ }, 3000);
69
+ });
70
+ };
71
+
72
+ var e = useRxEffect(function (event$) {
73
+ return event$.pipe( // debounceTime(1000),
74
+ // distinctUntilChanged(),
75
+ switchMap(function (p) {
76
+ return from(getData()).pipe(map(function (p) {
77
+ store.update(function (a) {
78
+ return _objectSpread(_objectSpread({}, a), {}, {
79
+ c: p,
80
+ loading: 'success'
81
+ });
82
+ });
83
+ return p;
84
+ }), startWith(function () {
85
+ return store.updatePartial({
86
+ loading: 'start'
87
+ });
88
+ }), endWith(function () {
89
+ return store.updatePartial({
90
+ loading: 'end'
91
+ });
92
+ }), catchError(function (ex) {
93
+ return of(store.updatePartial({
94
+ loading: 'error'
95
+ }));
96
+ }));
97
+ }));
98
+ }, [count]);
99
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", {
100
+ onClick: function onClick(e) {
101
+ store.update(function (pre) {
102
+ return _objectSpread(_objectSpread({}, pre), {}, {
103
+ a: pre.a + 1
104
+ });
105
+ });
106
+ setCount(function (pre) {
107
+ return pre + 1000;
108
+ });
109
+ }
110
+ }, "a+"), "a:", a, ' ', "b:", b, ' c:', c, ' ', "loading: ", storeVal === null || storeVal === void 0 ? void 0 : storeVal.loading, "state c: ", c1, /*#__PURE__*/React.createElement("button", {
111
+ onClick: d
112
+ }, "b+"), /*#__PURE__*/React.createElement("button", {
113
+ onClick: e
114
+ }, "ajax test"));
115
+ }
@@ -0,0 +1,54 @@
1
+ import { Observable, BehaviorSubject } from 'rxjs';
2
+ import { DependencyList } from 'react';
3
+ import { Store, StoreInitOptions } from './store';
4
+ export declare type RestrictArray<T> = T extends any[] ? T : [];
5
+ export declare type VoidAsNull<T> = T extends void ? null : T;
6
+ export declare type Not<P, T, F> = P extends false ? T : F;
7
+ /**
8
+ * 将对象转换为常量
9
+ */
10
+ export declare function useConstant<T>(fn: () => T): T;
11
+ export declare type InputFactory<State> = (state$: Observable<State>) => Observable<State>;
12
+ export declare type InputFactoryWithInputs<State, Inputs> = (state$: Observable<State>, inputs$: Observable<RestrictArray<Inputs>>) => Observable<State>;
13
+ /**
14
+ *
15
+ *
16
+ * @export
17
+ * @template State
18
+ * @param {InputFactory<State>} inputFactory
19
+ * @returns {(State | null)}
20
+ */
21
+ export declare function useRxObservable<State>(inputFactory: InputFactory<State>): State | null;
22
+ export declare function useRxObservable<State>(inputFactory: InputFactory<State>, initialState: State): State;
23
+ export declare function useRxObservable<State, Inputs>(inputFactory: InputFactoryWithInputs<State, Inputs>, initialState: State, inputs: RestrictArray<Inputs>): State;
24
+ export declare type VoidableEventCallback<EventValue> = EventValue extends void ? () => void : (e: EventValue) => void;
25
+ export declare type EventCallbackState<EventValue, State, Inputs = void> = [
26
+ VoidableEventCallback<EventValue>,
27
+ [
28
+ State extends void ? null : State,
29
+ BehaviorSubject<State | null>,
30
+ BehaviorSubject<RestrictArray<Inputs> | null>
31
+ ]
32
+ ];
33
+ export declare type ReturnedState<EventValue, State, Inputs> = [
34
+ EventCallbackState<EventValue, State, Inputs>[0],
35
+ EventCallbackState<EventValue, State, Inputs>[1][0]
36
+ ];
37
+ export declare type EventCallback<EventValue, State, Inputs> = Not<Inputs extends void ? true : false, (eventSource$: Observable<EventValue>, state$: Observable<State>, inputs$: Observable<RestrictArray<Inputs>>) => Observable<State>, (eventSource$: Observable<EventValue>, state$: Observable<State>) => Observable<State>>;
38
+ export declare function useEventCallback<EventValue>(callback: EventCallback<EventValue, void, void>): ReturnedState<EventValue, void | null, void>;
39
+ export declare function useEventCallback<EventValue, State>(callback: EventCallback<EventValue, State, void>, initialState: State): ReturnedState<EventValue, State, void>;
40
+ export declare function useEventCallback<EventValue, State, Inputs>(callback: EventCallback<EventValue, State, Inputs>, initialState: State, inputs: RestrictArray<Inputs>): ReturnedState<EventValue, State, Inputs>;
41
+ /**
42
+ * 创建一个可监听的对象
43
+ */
44
+ export declare function useRxStore<T>(options: StoreInitOptions<T>): Store<T>;
45
+ /** 处理副作用 */
46
+ export declare function useRxEffect<EventValue>(factory: ((event$: Observable<EventValue>) => void) | ((event$: Observable<EventValue>) => Observable<any>), deps?: DependencyList): (e: EventValue) => void;
47
+ /** 创建一个单例的store */
48
+ export declare function createSingletonStore<T>(options: StoreInitOptions<T>, key: string): Store<T>;
49
+ /** 通过key获取store */
50
+ export declare function getStoreByKey<T>(key: string): Store<T>;
51
+ /**
52
+ * 转换State到Observable
53
+ */
54
+ export declare function useRxObservableState<T>(v: T): void;
@@ -0,0 +1,201 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { Observable, BehaviorSubject, Subject } from 'rxjs';
3
+ import { useState, useEffect, useRef, useCallback } from 'react';
4
+ import { Store } from './store';
5
+ /**
6
+ * 将对象转换为常量
7
+ */
8
+
9
+ export function useConstant(fn) {
10
+ var ref = useRef();
11
+
12
+ if (!ref.current) {
13
+ ref.current = {
14
+ v: fn()
15
+ };
16
+ }
17
+
18
+ return ref.current.v;
19
+ }
20
+ export function useRxObservable(inputFactory, initialState, inputs) {
21
+ var _useState = useState(typeof initialState !== 'undefined' ? initialState : null),
22
+ _useState2 = _slicedToArray(_useState, 2),
23
+ state = _useState2[0],
24
+ setState = _useState2[1];
25
+
26
+ var state$ = useConstant(function () {
27
+ return new BehaviorSubject(initialState);
28
+ });
29
+ var inputs$ = useConstant(function () {
30
+ return new BehaviorSubject(inputs);
31
+ });
32
+ useEffect(function () {
33
+ inputs$.next(inputs);
34
+ }, inputs || []);
35
+ useEffect(function () {
36
+ var output$;
37
+
38
+ if (inputs) {
39
+ output$ = inputFactory(state$, inputs$);
40
+ } else {
41
+ output$ = inputFactory(state$);
42
+ } // console.log('output', output$);
43
+
44
+
45
+ var subscription = output$.subscribe(function (value) {
46
+ state$.next(value);
47
+ setState(value);
48
+ });
49
+ return function () {
50
+ subscription.unsubscribe();
51
+ inputs$.complete();
52
+ state$.complete();
53
+ };
54
+ }, []); // immutable forever
55
+
56
+ return state;
57
+ }
58
+ export function useEventCallback(callback, initialState, inputs) {
59
+ var initialValue = typeof initialState !== 'undefined' ? initialState : null;
60
+
61
+ var _useState3 = useState(initialValue),
62
+ _useState4 = _slicedToArray(_useState3, 2),
63
+ state = _useState4[0],
64
+ setState = _useState4[1];
65
+
66
+ var event$ = useConstant(function () {
67
+ return new Subject();
68
+ });
69
+ var state$ = useConstant(function () {
70
+ return new BehaviorSubject(initialValue);
71
+ });
72
+ var inputs$ = useConstant(function () {
73
+ return new BehaviorSubject(typeof inputs === 'undefined' ? null : inputs);
74
+ });
75
+
76
+ function eventCallback(e) {
77
+ return event$.next(e);
78
+ }
79
+
80
+ var returnedCallback = useCallback(eventCallback, []);
81
+ useEffect(function () {
82
+ inputs$.next(inputs);
83
+ }, inputs || []);
84
+ useEffect(function () {
85
+ setState(initialValue);
86
+ var value$;
87
+
88
+ if (!inputs) {
89
+ value$ = callback(event$, state$);
90
+ } else {
91
+ value$ = callback(event$, state$, inputs$);
92
+ }
93
+
94
+ var subscription = value$.subscribe(function (value) {
95
+ state$.next(value);
96
+ setState(value);
97
+ });
98
+ return function () {
99
+ subscription.unsubscribe();
100
+ state$.complete();
101
+ inputs$.complete();
102
+ event$.complete();
103
+ };
104
+ }, []);
105
+ return [returnedCallback, state];
106
+ }
107
+ /**
108
+ * 创建一个可监听的对象
109
+ */
110
+
111
+ export function useRxStore(options) {
112
+ var store = useConstant(function () {
113
+ return new Store(options);
114
+ });
115
+ useEffect(function () {
116
+ return function () {
117
+ return store.dispose();
118
+ };
119
+ }, []);
120
+ return store;
121
+ }
122
+ var storeFactory = {};
123
+ /** 处理副作用 */
124
+
125
+ export function useRxEffect(factory, deps) {
126
+ // const event$ = useConstant(() => new Subject<EventValue>());
127
+ var event$ = useConstant(function () {
128
+ return new Subject();
129
+ });
130
+
131
+ var eventCallback = function eventCallback(e) {
132
+ event$.next(e);
133
+ };
134
+
135
+ var returnedCallback = useCallback(eventCallback, []);
136
+ useEffect(function () {
137
+ var res = factory(event$);
138
+ var subscription;
139
+
140
+ if (res instanceof Observable) {
141
+ subscription = res.subscribe(function (p) {
142
+ // console.log('subscribe', p);
143
+ if (typeof p === 'function') {
144
+ p();
145
+ }
146
+ });
147
+ }
148
+
149
+ return function () {
150
+ var _subscription;
151
+
152
+ (_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.unsubscribe(); // event$.unsubscribe();
153
+ };
154
+ }, deps ? deps : []);
155
+ useEffect(function () {
156
+ return function () {
157
+ event$.unsubscribe();
158
+ };
159
+ }, []);
160
+ return returnedCallback;
161
+ }
162
+ /** 创建一个单例的store */
163
+
164
+ export function createSingletonStore(options, key) {
165
+ if (key) {
166
+ if (storeFactory[key]) {
167
+ return storeFactory[key];
168
+ }
169
+ }
170
+
171
+ var store = new Store(options);
172
+
173
+ if (key) {
174
+ storeFactory[key] = store;
175
+ }
176
+
177
+ return store;
178
+ }
179
+ /** 通过key获取store */
180
+
181
+ export function getStoreByKey(key) {
182
+ return storeFactory[key];
183
+ }
184
+ /**
185
+ * 转换State到Observable
186
+ */
187
+
188
+ export function useRxObservableState(v) {
189
+ var value$ = useConstant(function () {
190
+ return new BehaviorSubject(v);
191
+ });
192
+ useEffect(function () {
193
+ value$.next(v);
194
+ }, [v]);
195
+ useEffect(function () {
196
+ return function () {
197
+ value$.unsubscribe();
198
+ value$.complete();
199
+ };
200
+ }, []);
201
+ }
@@ -0,0 +1,2 @@
1
+ export { useConstant, useEventCallback, useRxObservable, useRxStore } from './hooks';
2
+ export { Store } from './store';
@@ -0,0 +1,2 @@
1
+ export { useConstant, useEventCallback, useRxObservable, useRxStore } from './hooks';
2
+ export { Store } from './store';
@@ -0,0 +1,39 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare type StoreUpdateChange<T> = {
3
+ previousValue: T;
4
+ currentValue: T;
5
+ label?: string;
6
+ };
7
+ export declare type StoreOnUpdateFn<T> = (change: StoreUpdateChange<T>) => void;
8
+ export declare type StoreInitOptions<T> = {
9
+ initialValue: T;
10
+ };
11
+ export declare type CommandOptions = {
12
+ label?: string;
13
+ };
14
+ export declare const RESET = "store/reset";
15
+ /**
16
+ * 创建一个可监听的对象
17
+ */
18
+ export declare class Store<T> {
19
+ private valueSubject;
20
+ private storeUpdateChangeSubject;
21
+ private initialValue;
22
+ get valueChanges(): Observable<T>;
23
+ get value(): T;
24
+ get storeUpdateChanges(): Observable<StoreUpdateChange<T>>;
25
+ dispose(): void;
26
+ constructor(initOptions: StoreInitOptions<T>);
27
+ /** 全量更新 */
28
+ update(command: T | ((state: T) => T), options?: CommandOptions): void;
29
+ /** 分布更新 */
30
+ updatePartial(value: Partial<T> | T, options?: CommandOptions): void;
31
+ /**
32
+ * 监听一部分属性
33
+ */
34
+ select<V>(selectFn: (state: T) => V): Observable<V>;
35
+ /**
36
+ * 重置到初始值
37
+ */
38
+ reset(options?: CommandOptions): void;
39
+ }
@@ -0,0 +1,108 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import { BehaviorSubject, Subject } from 'rxjs';
6
+ import { distinctUntilChanged, map } from 'rxjs/operators';
7
+ export var RESET = 'store/reset';
8
+ /**
9
+ * 创建一个可监听的对象
10
+ */
11
+
12
+ export var Store = /*#__PURE__*/function () {
13
+ function Store(initOptions) {
14
+ _classCallCheck(this, Store);
15
+
16
+ this.valueSubject = void 0;
17
+ this.storeUpdateChangeSubject = void 0;
18
+ this.initialValue = void 0;
19
+ this.valueSubject = new BehaviorSubject(initOptions.initialValue);
20
+ this.storeUpdateChangeSubject = new Subject();
21
+ this.initialValue = initOptions.initialValue;
22
+ }
23
+ /** 全量更新 */
24
+
25
+
26
+ _createClass(Store, [{
27
+ key: "valueChanges",
28
+ get: function get() {
29
+ return this.valueSubject.asObservable();
30
+ }
31
+ }, {
32
+ key: "value",
33
+ get: function get() {
34
+ return this.valueSubject.getValue();
35
+ }
36
+ }, {
37
+ key: "storeUpdateChanges",
38
+ get: function get() {
39
+ return this.storeUpdateChangeSubject.asObservable();
40
+ }
41
+ }, {
42
+ key: "dispose",
43
+ value: function dispose() {
44
+ var _this$valueSubject;
45
+
46
+ (_this$valueSubject = this.valueSubject) === null || _this$valueSubject === void 0 ? void 0 : _this$valueSubject.unsubscribe();
47
+ this.valueSubject = null;
48
+ this.storeUpdateChangeSubject.unsubscribe();
49
+ this.storeUpdateChangeSubject = null;
50
+ this.initialValue = null;
51
+ }
52
+ }, {
53
+ key: "update",
54
+ value: function update(command) {
55
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
56
+ var previousValue = this.valueSubject.getValue();
57
+ var currentValue = typeof command === 'function' ? command(previousValue) : command;
58
+ this.valueSubject.next(currentValue);
59
+ this.storeUpdateChangeSubject.next({
60
+ previousValue: previousValue,
61
+ currentValue: currentValue,
62
+ label: options.label
63
+ });
64
+ }
65
+ /** 分布更新 */
66
+
67
+ }, {
68
+ key: "updatePartial",
69
+ value: function updatePartial(value) {
70
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
71
+ var previousValue = this.valueSubject.getValue();
72
+ var currentValue = _typeof(value) === 'object' ? _objectSpread(_objectSpread({}, previousValue), value) : value;
73
+ this.valueSubject.next(currentValue);
74
+ this.storeUpdateChangeSubject.next({
75
+ previousValue: previousValue,
76
+ currentValue: currentValue,
77
+ label: options.label
78
+ });
79
+ }
80
+ /**
81
+ * 监听一部分属性
82
+ */
83
+
84
+ }, {
85
+ key: "select",
86
+ value: function select(selectFn) {
87
+ return this.valueSubject.pipe(map(selectFn), distinctUntilChanged());
88
+ }
89
+ /**
90
+ * 重置到初始值
91
+ */
92
+
93
+ }, {
94
+ key: "reset",
95
+ value: function reset() {
96
+ var _this = this;
97
+
98
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
99
+ label: RESET
100
+ };
101
+ this.update(function () {
102
+ return _this.initialValue;
103
+ }, options);
104
+ }
105
+ }]);
106
+
107
+ return Store;
108
+ }();
@@ -33,6 +33,16 @@ interface IReturnMethod {
33
33
  valueOf(): void;
34
34
  toString(): void;
35
35
  }
36
+ declare type ICreateData = {
37
+ /**
38
+ * 表单的属性集合
39
+ */
40
+ nodes: FG.Node[];
41
+ /**
42
+ * 整个表单的扩展规则
43
+ */
44
+ setting: {};
45
+ };
36
46
  export declare type IFormRobot = ICreate & IComps;
37
47
  /**
38
48
  * 链式调用 组件元数据表单的机器人
@@ -41,12 +51,12 @@ export declare class FormRobot implements IFormRobot {
41
51
  /**
42
52
  * 构建每个字段的值
43
53
  */
44
- _data: FG.Node | FG.Node[];
54
+ _data: FG.Node | ICreateData;
45
55
  /**
46
56
  * 用来判断是否已经初始化过数据
47
57
  */
48
58
  _hasInitData: boolean;
49
- constructor(data?: FG.Node | FG.Node[]);
59
+ constructor(data?: FG.Node | ICreateData);
50
60
  /**
51
61
  * 创建表单的入口
52
62
  * @param arr
@@ -1,8 +1,7 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
-
5
- /* eslint-disable */
6
5
  import { transFG2Schema } from '../../comps/FormGenerator/transformer';
7
6
  import { renderBasicFormProps, renderLayoutFormProps, renderSetting } from './utils';
8
7
  /**
@@ -46,10 +45,15 @@ export var FormRobot = /*#__PURE__*/function () {
46
45
  _createClass(FormRobot, [{
47
46
  key: "create",
48
47
  value: function create(arr) {
49
- var _init = this._hasInitData ? this._data : [];
50
-
51
- var _data = [].concat(_toConsumableArray(_init), _toConsumableArray(arr));
52
-
48
+ var _init = this._hasInitData ? this._data : {
49
+ nodes: [],
50
+ setting: {}
51
+ };
52
+
53
+ var _data = {
54
+ nodes: [].concat(_toConsumableArray(_init.nodes), _toConsumableArray(arr)),
55
+ setting: _init.setting
56
+ };
53
57
  return new FormRobot(_data);
54
58
  } //*********************************表单基本类型__START************************************//
55
59
 
@@ -264,10 +268,17 @@ export var FormRobot = /*#__PURE__*/function () {
264
268
  }, {
265
269
  key: "grid",
266
270
  value: function grid(_vaule) {
267
- var _init = this._hasInitData ? this._data : {};
268
-
269
- var _data = renderSetting(_init, 'colSpan', _vaule);
270
-
271
+ var _init = this._hasInitData ? this._data : {
272
+ nodes: [],
273
+ setting: {}
274
+ };
275
+
276
+ var _data = {
277
+ nodes: _toConsumableArray(_init.nodes),
278
+ setting: _objectSpread(_objectSpread({}, _init.setting), {}, {
279
+ colSpan: 24 / _vaule
280
+ })
281
+ };
271
282
  return new FormRobot(_data);
272
283
  } //*********************************表单布局的扩展规则__END************************************//
273
284
  //*********************************拿到最终的数据方法__START************************************//
@@ -275,9 +286,13 @@ export var FormRobot = /*#__PURE__*/function () {
275
286
  }, {
276
287
  key: "valueOf",
277
288
  value: function valueOf() {
278
- if (Array.isArray(this._data)) {
289
+ var _this$_data, _this$_data2;
290
+
291
+ if (((_this$_data = this._data) === null || _this$_data === void 0 ? void 0 : _this$_data.nodes) && Array.isArray((_this$_data2 = this._data) === null || _this$_data2 === void 0 ? void 0 : _this$_data2.nodes)) {
279
292
  //是数组,说明是create方法,需要转换成元数据
280
- return transFG2Schema(this._data);
293
+ return transFG2Schema(this._data.nodes, {
294
+ formSetting: this._data.setting
295
+ });
281
296
  } else {
282
297
  return this._data;
283
298
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-30 10:12:11
4
- * @LastEditTime: 2022-07-14 08:33:58
4
+ * @LastEditTime: 2023-04-03 09:30:52
5
5
  */
6
6
  import React from 'react';
7
7
 
@@ -14,7 +14,7 @@ var useObservable = function useObservable(fn) {
14
14
  fn(p);
15
15
  }));
16
16
  return function () {
17
- return subscription && subscription.unsubscribe();
17
+ subscription && subscription.unsubscribe(); // dep[0] && dep[0].complete();
18
18
  };
19
19
  }, dep);
20
20
  };
package/es/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export { default as FormGenerator } from './comps/FormGenerator';
13
13
  export { default as DynamicPorts } from './comps/DynamicPorts';
14
14
  export { default as DragNode } from './comps/DynamicPorts/comps/DragNode';
15
15
  export { default as Icon } from './comps/Icons';
16
+ export { default as Split } from './comps/Split';
16
17
  export * from './framework/metadata/index';
17
18
  export { default as http, addInterceptor } from './framework/http/index';
18
19
  export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject';
package/es/index.js CHANGED
@@ -18,6 +18,7 @@ export { default as FormGenerator } from './comps/FormGenerator';
18
18
  export { default as DynamicPorts } from './comps/DynamicPorts';
19
19
  export { default as DragNode } from './comps/DynamicPorts/comps/DragNode';
20
20
  export { default as Icon } from './comps/Icons';
21
+ export { default as Split } from './comps/Split';
21
22
  export * from './framework/metadata/index';
22
23
  export { default as http, addInterceptor } from './framework/http/index';
23
24
  export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject';
package/es/theme.less CHANGED
@@ -1,77 +1,77 @@
1
- .ronds-metadata-dark {
2
- --ronds-metadata-color-border-1: #314162;
3
- --ronds-metadata-color-border-2: #0d9af3;
4
- --ronds-metadata-color-bg-2: #0d1f40;
5
- --ronds-metadata-color-bg-3: #021125;
6
- --ronds-metadata-color-bg-4: #1c3771;
7
- --ronds-metadata-color-text-1: #ffffff;
8
- --ronds-metadata-color-text-2: #ffffff;
9
- --ronds-metadata-color-text-3: #ffffff;
10
-
11
- ::-webkit-scrollbar {
12
- width: 6px;
13
- height: 6px;
14
- overflow: auto;
15
- }
16
- ::-webkit-scrollbar-corner {
17
- background-color: transparent;
18
- color: transparent;
19
- }
20
-
21
- ::-webkit-scrollbar-thumb {
22
- box-shadow: inset 0 0 5px var(--scrollbar-bg-color);
23
- background: var(--scrollbar-color);
24
- min-height: 25px;
25
- min-width: 25px;
26
- border-radius: 3px;
27
-
28
- &:hover {
29
- border-radius: 2px;
30
- // box-shadow: inset 0 0 5px var(--scrollbar-color-hover);
31
- background: var(--scrollbar-color-hover);
32
- }
33
-
34
- &:active {
35
- // box-shadow: inset 0 0 5px var(--scrollbar-bg-color);
36
- background: var(--scrollbar-color-hover);
37
- }
38
- }
39
- }
40
-
41
- .ronds-metadata-normal {
42
- --ronds-metadata-color-border-1: #d9d9d9;
43
- --ronds-metadata-color-border-2: #165dff;
44
- --ronds-metadata-color-bg-2: rgba(229, 238, 255, 0.85);
45
- --ronds-metadata-color-bg-3: #f6f5f6;
46
- --ronds-metadata-color-bg-4: #ffffff;
47
- --ronds-metadata-color-text-1: #1d2129;
48
- --ronds-metadata-color-text-2: #24292f;
49
- --ronds-metadata-color-text-3: #f2f3f5;
50
-
51
- ::-webkit-scrollbar {
52
- width: 6px;
53
- height: 6px;
54
- overflow: auto;
55
- }
56
-
57
- ::-webkit-scrollbar-thumb {
58
- background-color: var(--scrollbar-color);
59
- min-height: 25px;
60
- min-width: 25px;
61
- border-radius: 3px;
62
-
63
- &:hover {
64
- background-color: #a8a8a8;
65
- }
66
-
67
- &:active {
68
- background-color: #787878;
69
- }
70
-
71
- /* border: 1px solid #e0e0e0; */
72
- }
73
-
74
- ::-webkit-scrollbar-track {
75
- background-color: #f7f7f7;
76
- }
77
- }
1
+ .ronds-metadata-dark {
2
+ --ronds-metadata-color-border-1: #314162;
3
+ --ronds-metadata-color-border-2: #0d9af3;
4
+ --ronds-metadata-color-bg-2: #0d1f40;
5
+ --ronds-metadata-color-bg-3: #021125;
6
+ --ronds-metadata-color-bg-4: #1c3771;
7
+ --ronds-metadata-color-text-1: #ffffff;
8
+ --ronds-metadata-color-text-2: #ffffff;
9
+ --ronds-metadata-color-text-3: #ffffff;
10
+
11
+ ::-webkit-scrollbar {
12
+ width: 6px;
13
+ height: 6px;
14
+ overflow: auto;
15
+ }
16
+ ::-webkit-scrollbar-corner {
17
+ background-color: transparent;
18
+ color: transparent;
19
+ }
20
+
21
+ ::-webkit-scrollbar-thumb {
22
+ box-shadow: inset 0 0 5px var(--scrollbar-bg-color);
23
+ background: var(--scrollbar-color);
24
+ min-height: 25px;
25
+ min-width: 25px;
26
+ border-radius: 3px;
27
+
28
+ &:hover {
29
+ border-radius: 2px;
30
+ // box-shadow: inset 0 0 5px var(--scrollbar-color-hover);
31
+ background: var(--scrollbar-color-hover);
32
+ }
33
+
34
+ &:active {
35
+ // box-shadow: inset 0 0 5px var(--scrollbar-bg-color);
36
+ background: var(--scrollbar-color-hover);
37
+ }
38
+ }
39
+ }
40
+
41
+ .ronds-metadata-normal {
42
+ --ronds-metadata-color-border-1: #d9d9d9;
43
+ --ronds-metadata-color-border-2: #165dff;
44
+ --ronds-metadata-color-bg-2: rgba(229, 238, 255, 0.85);
45
+ --ronds-metadata-color-bg-3: #f6f5f6;
46
+ --ronds-metadata-color-bg-4: #ffffff;
47
+ --ronds-metadata-color-text-1: #1d2129;
48
+ --ronds-metadata-color-text-2: #24292f;
49
+ --ronds-metadata-color-text-3: #f2f3f5;
50
+
51
+ ::-webkit-scrollbar {
52
+ width: 6px;
53
+ height: 6px;
54
+ overflow: auto;
55
+ }
56
+
57
+ ::-webkit-scrollbar-thumb {
58
+ background-color: var(--scrollbar-color);
59
+ min-height: 25px;
60
+ min-width: 25px;
61
+ border-radius: 3px;
62
+
63
+ &:hover {
64
+ background-color: #a8a8a8;
65
+ }
66
+
67
+ &:active {
68
+ background-color: #787878;
69
+ }
70
+
71
+ /* border: 1px solid #e0e0e0; */
72
+ }
73
+
74
+ ::-webkit-scrollbar-track {
75
+ background-color: #f7f7f7;
76
+ }
77
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.2.28",
4
+ "version": "1.2.30",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -58,6 +58,7 @@
58
58
  "react-markdown": "^8.0.3",
59
59
  "react-markdown-editor-lite": "^1.3.2",
60
60
  "react-popper": "^2.2.3",
61
+ "react-split": "^2.0.14",
61
62
  "react-syntax-highlighter": "^15.5.0",
62
63
  "rehype-raw": "^6.1.1",
63
64
  "remark-gfm": "^3.0.1",