@chaomingd/design 0.0.68
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/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/esm/CheckGroup/context.d.ts +9 -0
- package/dist/esm/CheckGroup/context.js +6 -0
- package/dist/esm/CheckGroup/hooks/useCheckGroup.d.ts +21 -0
- package/dist/esm/CheckGroup/hooks/useCheckGroup.js +180 -0
- package/dist/esm/CheckGroup/index.d.ts +9 -0
- package/dist/esm/CheckGroup/index.js +79 -0
- package/dist/esm/CheckGroup/type.d.ts +28 -0
- package/dist/esm/CheckGroup/type.js +1 -0
- package/dist/esm/Grid/index.d.ts +15 -0
- package/dist/esm/Grid/index.js +64 -0
- package/dist/esm/Grid/index.less +7 -0
- package/dist/esm/KaTeXRenderer/index.d.ts +9 -0
- package/dist/esm/KaTeXRenderer/index.js +33 -0
- package/dist/esm/KaTeXRenderer/index.less +0 -0
- package/dist/esm/PixelPlayer/index.d.ts +28 -0
- package/dist/esm/PixelPlayer/index.js +118 -0
- package/dist/esm/PixelPlayer/index.less +29 -0
- package/dist/esm/PixelPlayer/lib/peer-stream.d.ts +62 -0
- package/dist/esm/PixelPlayer/lib/peer-stream.js +876 -0
- package/dist/esm/PixelPlayer/useAutoLayoutContainer.d.ts +2 -0
- package/dist/esm/PixelPlayer/useAutoLayoutContainer.js +53 -0
- package/dist/esm/PixelPlayer/useVideoWithCustomEvent.d.ts +5 -0
- package/dist/esm/PixelPlayer/useVideoWithCustomEvent.js +37 -0
- package/dist/esm/Resizer/index.d.ts +17 -0
- package/dist/esm/Resizer/index.js +73 -0
- package/dist/esm/Resizer/index.less +73 -0
- package/dist/esm/SetupAntApp/index.d.ts +1 -0
- package/dist/esm/SetupAntApp/index.js +10 -0
- package/dist/esm/Transition/index.d.ts +4 -0
- package/dist/esm/Transition/index.js +132 -0
- package/dist/esm/Transition/type.d.ts +33 -0
- package/dist/esm/Transition/type.js +12 -0
- package/dist/esm/Transition/utils.d.ts +6 -0
- package/dist/esm/Transition/utils.js +15 -0
- package/dist/esm/UploadFile/components/IconButton/index.d.ts +11 -0
- package/dist/esm/UploadFile/components/IconButton/index.js +26 -0
- package/dist/esm/UploadFile/components/IconButton/index.less +58 -0
- package/dist/esm/UploadFile/components/Slash.d.ts +2 -0
- package/dist/esm/UploadFile/components/Slash.js +15 -0
- package/dist/esm/UploadFile/components/SvgIcons.d.ts +11 -0
- package/dist/esm/UploadFile/components/SvgIcons.js +141 -0
- package/dist/esm/UploadFile/hooks/useUploadModel.d.ts +16 -0
- package/dist/esm/UploadFile/hooks/useUploadModel.js +376 -0
- package/dist/esm/UploadFile/index.d.ts +4 -0
- package/dist/esm/UploadFile/index.js +277 -0
- package/dist/esm/UploadFile/index.less +274 -0
- package/dist/esm/UploadFile/type.d.ts +63 -0
- package/dist/esm/UploadFile/type.js +1 -0
- package/dist/esm/UploadFile/utils/formatBitString.d.ts +1 -0
- package/dist/esm/UploadFile/utils/formatBitString.js +9 -0
- package/dist/esm/UploadFile/utils/getExt.d.ts +1 -0
- package/dist/esm/UploadFile/utils/getExt.js +6 -0
- package/dist/esm/UploadFile/utils/isImage.d.ts +1 -0
- package/dist/esm/UploadFile/utils/isImage.js +8 -0
- package/dist/esm/UploadFile/utils/normalizeExt.d.ts +1 -0
- package/dist/esm/UploadFile/utils/normalizeExt.js +4 -0
- package/dist/esm/UploadFile/utils/validateFileTypes.d.ts +13 -0
- package/dist/esm/UploadFile/utils/validateFileTypes.js +83 -0
- package/dist/esm/UploadFile/utils/validateRule.d.ts +3 -0
- package/dist/esm/UploadFile/utils/validateRule.js +22 -0
- package/dist/esm/UploadFile/utils/validateUpload.d.ts +5 -0
- package/dist/esm/UploadFile/utils/validateUpload.js +35 -0
- package/dist/esm/constant/index.d.ts +7 -0
- package/dist/esm/constant/index.js +18 -0
- package/dist/esm/constants/cssPrefix.d.ts +1 -0
- package/dist/esm/constants/cssPrefix.js +1 -0
- package/dist/esm/getAntApp/index.d.ts +8 -0
- package/dist/esm/getAntApp/index.js +17 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/interface.d.ts +1 -0
- package/dist/esm/interface.js +1 -0
- package/dist/esm/styles/cssVar.less +28 -0
- package/dist/esm/styles/reset.css +3 -0
- package/dist/esm/styles/var.d.ts +1 -0
- package/dist/esm/styles/var.js +1 -0
- package/dist/esm/styles/var.less +2 -0
- package/dist/esm/variable.less +52 -0
- package/dist/lib/CheckGroup/context.d.ts +9 -0
- package/dist/lib/CheckGroup/context.js +12 -0
- package/dist/lib/CheckGroup/hooks/useCheckGroup.d.ts +21 -0
- package/dist/lib/CheckGroup/hooks/useCheckGroup.js +164 -0
- package/dist/lib/CheckGroup/index.d.ts +9 -0
- package/dist/lib/CheckGroup/index.js +93 -0
- package/dist/lib/CheckGroup/type.d.ts +28 -0
- package/dist/lib/CheckGroup/type.js +5 -0
- package/dist/lib/Grid/index.d.ts +15 -0
- package/dist/lib/Grid/index.js +77 -0
- package/dist/lib/Grid/index.less +7 -0
- package/dist/lib/KaTeXRenderer/index.d.ts +9 -0
- package/dist/lib/KaTeXRenderer/index.js +41 -0
- package/dist/lib/KaTeXRenderer/index.less +0 -0
- package/dist/lib/PixelPlayer/index.d.ts +28 -0
- package/dist/lib/PixelPlayer/index.js +108 -0
- package/dist/lib/PixelPlayer/index.less +29 -0
- package/dist/lib/PixelPlayer/lib/peer-stream.d.ts +62 -0
- package/dist/lib/PixelPlayer/lib/peer-stream.js +707 -0
- package/dist/lib/PixelPlayer/useAutoLayoutContainer.d.ts +2 -0
- package/dist/lib/PixelPlayer/useAutoLayoutContainer.js +60 -0
- package/dist/lib/PixelPlayer/useVideoWithCustomEvent.d.ts +5 -0
- package/dist/lib/PixelPlayer/useVideoWithCustomEvent.js +35 -0
- package/dist/lib/Resizer/index.d.ts +17 -0
- package/dist/lib/Resizer/index.js +75 -0
- package/dist/lib/Resizer/index.less +73 -0
- package/dist/lib/SetupAntApp/index.d.ts +1 -0
- package/dist/lib/SetupAntApp/index.js +16 -0
- package/dist/lib/Transition/index.d.ts +4 -0
- package/dist/lib/Transition/index.js +128 -0
- package/dist/lib/Transition/type.d.ts +33 -0
- package/dist/lib/Transition/type.js +18 -0
- package/dist/lib/Transition/utils.d.ts +6 -0
- package/dist/lib/Transition/utils.js +22 -0
- package/dist/lib/UploadFile/components/IconButton/index.d.ts +11 -0
- package/dist/lib/UploadFile/components/IconButton/index.js +29 -0
- package/dist/lib/UploadFile/components/IconButton/index.less +58 -0
- package/dist/lib/UploadFile/components/Slash.d.ts +2 -0
- package/dist/lib/UploadFile/components/Slash.js +22 -0
- package/dist/lib/UploadFile/components/SvgIcons.d.ts +11 -0
- package/dist/lib/UploadFile/components/SvgIcons.js +158 -0
- package/dist/lib/UploadFile/hooks/useUploadModel.d.ts +16 -0
- package/dist/lib/UploadFile/hooks/useUploadModel.js +306 -0
- package/dist/lib/UploadFile/index.d.ts +4 -0
- package/dist/lib/UploadFile/index.js +280 -0
- package/dist/lib/UploadFile/index.less +274 -0
- package/dist/lib/UploadFile/type.d.ts +63 -0
- package/dist/lib/UploadFile/type.js +5 -0
- package/dist/lib/UploadFile/utils/formatBitString.d.ts +1 -0
- package/dist/lib/UploadFile/utils/formatBitString.js +15 -0
- package/dist/lib/UploadFile/utils/getExt.d.ts +1 -0
- package/dist/lib/UploadFile/utils/getExt.js +12 -0
- package/dist/lib/UploadFile/utils/isImage.d.ts +1 -0
- package/dist/lib/UploadFile/utils/isImage.js +14 -0
- package/dist/lib/UploadFile/utils/normalizeExt.d.ts +1 -0
- package/dist/lib/UploadFile/utils/normalizeExt.js +10 -0
- package/dist/lib/UploadFile/utils/validateFileTypes.d.ts +13 -0
- package/dist/lib/UploadFile/utils/validateFileTypes.js +87 -0
- package/dist/lib/UploadFile/utils/validateRule.d.ts +3 -0
- package/dist/lib/UploadFile/utils/validateRule.js +28 -0
- package/dist/lib/UploadFile/utils/validateUpload.d.ts +5 -0
- package/dist/lib/UploadFile/utils/validateUpload.js +31 -0
- package/dist/lib/constant/index.d.ts +7 -0
- package/dist/lib/constant/index.js +24 -0
- package/dist/lib/constants/cssPrefix.d.ts +1 -0
- package/dist/lib/constants/cssPrefix.js +7 -0
- package/dist/lib/getAntApp/index.d.ts +8 -0
- package/dist/lib/getAntApp/index.js +27 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.js +69 -0
- package/dist/lib/interface.d.ts +1 -0
- package/dist/lib/interface.js +5 -0
- package/dist/lib/styles/cssVar.less +28 -0
- package/dist/lib/styles/reset.css +3 -0
- package/dist/lib/styles/var.d.ts +1 -0
- package/dist/lib/styles/var.js +7 -0
- package/dist/lib/styles/var.less +2 -0
- package/dist/lib/variable.less +52 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @chaomingd/design
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@chaomingd/design)
|
|
4
|
+
[](https://npmjs.com/package/@chaomingd/design)
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
$ pnpm install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
$ npm run dev
|
|
14
|
+
$ npm run build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Options
|
|
18
|
+
|
|
19
|
+
TODO
|
|
20
|
+
|
|
21
|
+
## LICENSE
|
|
22
|
+
|
|
23
|
+
MIT
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckGroupModel } from './hooks/useCheckGroup';
|
|
3
|
+
import { CheckGroupProps } from './type';
|
|
4
|
+
type CheckGroupContextType = {
|
|
5
|
+
model: CheckGroupModel<any>;
|
|
6
|
+
props: CheckGroupProps<any>;
|
|
7
|
+
};
|
|
8
|
+
export declare const CheckGroupContext: import("react").Context<CheckGroupContextType>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Model } from '@chaomingd/store';
|
|
2
|
+
import { CheckGroupProps, CheckGroupState, Key } from '../type';
|
|
3
|
+
export declare class CheckGroupModel<K extends Key> extends Model<CheckGroupState<K>> {
|
|
4
|
+
keys: K[];
|
|
5
|
+
timer: any;
|
|
6
|
+
props: CheckGroupProps<K>;
|
|
7
|
+
useGroupKeys: boolean;
|
|
8
|
+
constructor();
|
|
9
|
+
getCheckAllInfo(checkMap?: Map<Key, boolean>): {
|
|
10
|
+
isCheckAll: boolean;
|
|
11
|
+
indeterminate: boolean;
|
|
12
|
+
};
|
|
13
|
+
handleToggleCheckAll: () => void;
|
|
14
|
+
handleToggleCheck: (key: K) => void;
|
|
15
|
+
handleCheckOne: (key: K) => void;
|
|
16
|
+
registerKey(key: K): void;
|
|
17
|
+
setKeys(keys: K[]): void;
|
|
18
|
+
unRegisterKey(key: K): void;
|
|
19
|
+
__updateKeys(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare function useCheckGroup<K extends Key>(props: CheckGroupProps<K>): CheckGroupModel<K>;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { Model } from '@chaomingd/store';
|
|
10
|
+
import { useCreation } from 'ahooks';
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
export var CheckGroupModel = /*#__PURE__*/function (_Model) {
|
|
13
|
+
_inherits(CheckGroupModel, _Model);
|
|
14
|
+
var _super = _createSuper(CheckGroupModel);
|
|
15
|
+
function CheckGroupModel() {
|
|
16
|
+
var _this;
|
|
17
|
+
_classCallCheck(this, CheckGroupModel);
|
|
18
|
+
_this = _super.call(this, {
|
|
19
|
+
autoInit: false,
|
|
20
|
+
state: {
|
|
21
|
+
value: [],
|
|
22
|
+
valueMap: new Map(),
|
|
23
|
+
keys: [],
|
|
24
|
+
isCheckAll: false,
|
|
25
|
+
indeterminate: false
|
|
26
|
+
},
|
|
27
|
+
computed: [{
|
|
28
|
+
keys: ['value'],
|
|
29
|
+
hander: function hander(_ref) {
|
|
30
|
+
var value = _ref.value;
|
|
31
|
+
var m = new Map();
|
|
32
|
+
value.forEach(function (k) {
|
|
33
|
+
m.set(k, true);
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
valueMap: m
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
keys: ['value', 'keys'],
|
|
41
|
+
hander: function hander(_ref2) {
|
|
42
|
+
var valueMap = _ref2.valueMap;
|
|
43
|
+
return _objectSpread({}, _this.getCheckAllInfo(valueMap));
|
|
44
|
+
}
|
|
45
|
+
}]
|
|
46
|
+
});
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "keys", []);
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "timer", void 0);
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "props", {});
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "useGroupKeys", false);
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "handleToggleCheckAll", function () {
|
|
52
|
+
var _this$props$onChange, _this$props;
|
|
53
|
+
var _this$getState = _this.getState(),
|
|
54
|
+
isCheckAll = _this$getState.isCheckAll;
|
|
55
|
+
var newKeys;
|
|
56
|
+
if (isCheckAll) {
|
|
57
|
+
newKeys = [];
|
|
58
|
+
} else {
|
|
59
|
+
newKeys = _toConsumableArray(_this.keys);
|
|
60
|
+
}
|
|
61
|
+
if (!('value' in _this.props)) {
|
|
62
|
+
_this.setState({
|
|
63
|
+
value: newKeys
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 || _this$props$onChange.call(_this$props, newKeys);
|
|
67
|
+
});
|
|
68
|
+
_defineProperty(_assertThisInitialized(_this), "handleToggleCheck", function (key) {
|
|
69
|
+
var _this$props$onChange2, _this$props2;
|
|
70
|
+
var _this$getState2 = _this.getState(),
|
|
71
|
+
valueMap = _this$getState2.valueMap,
|
|
72
|
+
value = _this$getState2.value;
|
|
73
|
+
var isCheck = valueMap.get(key);
|
|
74
|
+
var newKeys = _toConsumableArray(value);
|
|
75
|
+
if (isCheck) {
|
|
76
|
+
newKeys = newKeys.filter(function (k) {
|
|
77
|
+
return k !== key;
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
newKeys.push(key);
|
|
81
|
+
}
|
|
82
|
+
if (!('value' in _this.props)) {
|
|
83
|
+
_this.setState({
|
|
84
|
+
value: newKeys
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
(_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 || _this$props$onChange2.call(_this$props2, newKeys);
|
|
88
|
+
});
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this), "handleCheckOne", function (key) {
|
|
90
|
+
var _this$props$onChange3, _this$props3;
|
|
91
|
+
var newKeys = [key];
|
|
92
|
+
if (!('value' in _this.props)) {
|
|
93
|
+
_this.setState({
|
|
94
|
+
value: newKeys
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
(_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 || _this$props$onChange3.call(_this$props3, newKeys);
|
|
98
|
+
});
|
|
99
|
+
_this.init();
|
|
100
|
+
return _this;
|
|
101
|
+
}
|
|
102
|
+
_createClass(CheckGroupModel, [{
|
|
103
|
+
key: "getCheckAllInfo",
|
|
104
|
+
value: function getCheckAllInfo(checkMap) {
|
|
105
|
+
var _this$getState3 = this.getState(),
|
|
106
|
+
valueMap = _this$getState3.valueMap;
|
|
107
|
+
var ckMap = checkMap || valueMap;
|
|
108
|
+
var keys = this.keys;
|
|
109
|
+
var indeterminate = false;
|
|
110
|
+
var isCheckAll = true;
|
|
111
|
+
keys.forEach(function (k) {
|
|
112
|
+
var isCheck = ckMap.get(k);
|
|
113
|
+
if (isCheck) {
|
|
114
|
+
indeterminate = true;
|
|
115
|
+
} else {
|
|
116
|
+
isCheckAll = false;
|
|
117
|
+
}
|
|
118
|
+
return isCheck;
|
|
119
|
+
});
|
|
120
|
+
if (isCheckAll) {
|
|
121
|
+
indeterminate = false;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
isCheckAll: isCheckAll,
|
|
125
|
+
indeterminate: indeterminate
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "registerKey",
|
|
130
|
+
value: function registerKey(key) {
|
|
131
|
+
if (!this.keys.includes(key)) {
|
|
132
|
+
this.keys.push(key);
|
|
133
|
+
}
|
|
134
|
+
this.__updateKeys();
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "setKeys",
|
|
138
|
+
value: function setKeys(keys) {
|
|
139
|
+
this.keys = keys;
|
|
140
|
+
this.__updateKeys();
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "unRegisterKey",
|
|
144
|
+
value: function unRegisterKey(key) {
|
|
145
|
+
this.keys = this.keys.filter(function (k) {
|
|
146
|
+
return k !== key;
|
|
147
|
+
});
|
|
148
|
+
this.__updateKeys();
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "__updateKeys",
|
|
152
|
+
value: function __updateKeys() {
|
|
153
|
+
var _this2 = this;
|
|
154
|
+
clearTimeout(this.timer);
|
|
155
|
+
this.timer = setTimeout(function () {
|
|
156
|
+
_this2.setState({
|
|
157
|
+
keys: _toConsumableArray(_this2.keys)
|
|
158
|
+
});
|
|
159
|
+
}, 10);
|
|
160
|
+
}
|
|
161
|
+
}]);
|
|
162
|
+
return CheckGroupModel;
|
|
163
|
+
}(Model);
|
|
164
|
+
export function useCheckGroup(props) {
|
|
165
|
+
var hasValue = ('value' in props);
|
|
166
|
+
var model = useCreation(function () {
|
|
167
|
+
return new CheckGroupModel();
|
|
168
|
+
}, []);
|
|
169
|
+
model.props = props;
|
|
170
|
+
useMemo(function () {
|
|
171
|
+
if (hasValue) {
|
|
172
|
+
model.setState({
|
|
173
|
+
value: props.value || []
|
|
174
|
+
}, {
|
|
175
|
+
silent: true
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}, [props.value, model, hasValue]);
|
|
179
|
+
return model;
|
|
180
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckGroupProps, CheckItemProps, Key } from './type';
|
|
3
|
+
declare const CheckItem: <K extends Key>(props: CheckItemProps<K>) => import("react").ReactNode;
|
|
4
|
+
declare const CheckAllItem: <K extends Key>(props: CheckItemProps<K>) => import("react").ReactNode;
|
|
5
|
+
declare const CheckGroup: (<K extends Key>(props: CheckGroupProps<K>) => import("react/jsx-runtime").JSX.Element) & {
|
|
6
|
+
CheckItem: typeof CheckItem;
|
|
7
|
+
CheckAllItem: typeof CheckAllItem;
|
|
8
|
+
};
|
|
9
|
+
export default CheckGroup;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useContext, useEffect, useMemo } from 'react';
|
|
2
|
+
import { CheckGroupContext } from "./context";
|
|
3
|
+
import { useCheckGroup } from "./hooks/useCheckGroup";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
var _CheckGroup = function _CheckGroup(props) {
|
|
6
|
+
var model = useCheckGroup(props);
|
|
7
|
+
var hasKeys = ('keys' in props);
|
|
8
|
+
model.useGroupKeys = hasKeys;
|
|
9
|
+
// model.useUpdate();
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
if (hasKeys) {
|
|
12
|
+
model.setKeys(props.keys || []);
|
|
13
|
+
}
|
|
14
|
+
}, [props.keys, model, hasKeys]);
|
|
15
|
+
var contextValue = useMemo(function () {
|
|
16
|
+
return {
|
|
17
|
+
model: model,
|
|
18
|
+
props: props
|
|
19
|
+
};
|
|
20
|
+
}, [model, props.value]);
|
|
21
|
+
return /*#__PURE__*/_jsx(CheckGroupContext.Provider, {
|
|
22
|
+
value: contextValue,
|
|
23
|
+
children: props.children
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var CheckItem = function CheckItem(props) {
|
|
27
|
+
var value = props.value,
|
|
28
|
+
children = props.children;
|
|
29
|
+
var _useContext = useContext(CheckGroupContext),
|
|
30
|
+
model = _useContext.model;
|
|
31
|
+
var multiple = model.props.multiple;
|
|
32
|
+
var useGroupKeys = model.useGroupKeys;
|
|
33
|
+
var _model$useGetState = model.useGetState(),
|
|
34
|
+
valueMap = _model$useGetState.valueMap,
|
|
35
|
+
indeterminate = _model$useGetState.indeterminate;
|
|
36
|
+
var isCheck = valueMap.get(value) || false;
|
|
37
|
+
useMemo(function () {
|
|
38
|
+
if (!useGroupKeys) {
|
|
39
|
+
model.registerKey(value);
|
|
40
|
+
}
|
|
41
|
+
return function () {
|
|
42
|
+
if (!useGroupKeys) {
|
|
43
|
+
model.unRegisterKey(value);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, [model, value, useGroupKeys]);
|
|
47
|
+
if (typeof children === 'function') {
|
|
48
|
+
var onChange = function onChange() {
|
|
49
|
+
multiple ? model.handleToggleCheck(value) : model.handleCheckOne(value);
|
|
50
|
+
};
|
|
51
|
+
return children({
|
|
52
|
+
checked: isCheck,
|
|
53
|
+
indeterminate: indeterminate,
|
|
54
|
+
onChange: onChange
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return children;
|
|
58
|
+
};
|
|
59
|
+
var CheckAllItem = function CheckAllItem(props) {
|
|
60
|
+
var children = props.children;
|
|
61
|
+
var _useContext2 = useContext(CheckGroupContext),
|
|
62
|
+
model = _useContext2.model;
|
|
63
|
+
var _model$useGetState2 = model.useGetState(),
|
|
64
|
+
isCheckAll = _model$useGetState2.isCheckAll,
|
|
65
|
+
indeterminate = _model$useGetState2.indeterminate;
|
|
66
|
+
if (typeof children === 'function') {
|
|
67
|
+
return children({
|
|
68
|
+
checked: isCheckAll,
|
|
69
|
+
indeterminate: indeterminate,
|
|
70
|
+
onChange: model.handleToggleCheckAll
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return children;
|
|
74
|
+
};
|
|
75
|
+
var _component = _CheckGroup;
|
|
76
|
+
var CheckGroup = _component;
|
|
77
|
+
CheckGroup.CheckItem = CheckItem;
|
|
78
|
+
CheckGroup.CheckAllItem = CheckAllItem;
|
|
79
|
+
export default CheckGroup;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type Key = string | number | symbol;
|
|
3
|
+
export interface CheckGroupProps<K extends Key> {
|
|
4
|
+
value?: K[];
|
|
5
|
+
onChange?: (val: K[]) => void;
|
|
6
|
+
children?: ReactNode | ReactNode[];
|
|
7
|
+
keys?: K[];
|
|
8
|
+
multiple?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface CheckGroupState<K extends Key> {
|
|
11
|
+
value: K[];
|
|
12
|
+
valueMap: Map<K, boolean>;
|
|
13
|
+
keys: K[];
|
|
14
|
+
isCheckAll: boolean;
|
|
15
|
+
indeterminate: boolean;
|
|
16
|
+
}
|
|
17
|
+
type CheckItemChildren = ReactNode | ReactNode[] | ((props: {
|
|
18
|
+
checked: boolean;
|
|
19
|
+
indeterminate: boolean;
|
|
20
|
+
onChange: () => void;
|
|
21
|
+
}) => ReactNode | ReactNode[]);
|
|
22
|
+
export interface CheckItemProps<K extends Key> {
|
|
23
|
+
value: K;
|
|
24
|
+
children?: CheckItemChildren;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
onChange?: (val: K) => void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
export interface GridProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
gap?: number | [number, number];
|
|
5
|
+
col: number;
|
|
6
|
+
pxTransform?: (n: number) => string;
|
|
7
|
+
}
|
|
8
|
+
declare const Grid: React.ForwardRefExoticComponent<GridProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
9
|
+
declare const GridItem: ({ className, children }: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
type GridType = typeof Grid;
|
|
11
|
+
interface IGrid extends GridType {
|
|
12
|
+
Item: typeof GridItem;
|
|
13
|
+
}
|
|
14
|
+
declare const GridCom: IGrid;
|
|
15
|
+
export default GridCom;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import React, { createContext, forwardRef, useContext } from 'react';
|
|
3
|
+
import "./index.less";
|
|
4
|
+
import { CSS_PREFIX } from "../styles/var";
|
|
5
|
+
import { pxtorem } from '@chaomingd/utils';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
var GridContext = /*#__PURE__*/createContext({});
|
|
8
|
+
function toMarginPadding(gap, type, pxTransform) {
|
|
9
|
+
if (!gap) return undefined;
|
|
10
|
+
var gaps;
|
|
11
|
+
if (Array.isArray(gap)) {
|
|
12
|
+
gaps = gap;
|
|
13
|
+
} else {
|
|
14
|
+
gaps = [gap, gap];
|
|
15
|
+
}
|
|
16
|
+
if (type === 'margin') {
|
|
17
|
+
return "".concat(pxTransform(-gaps[0] / 2), " ").concat(pxTransform(-gaps[1] / 2));
|
|
18
|
+
}
|
|
19
|
+
return "".concat(pxTransform(gaps[0] / 2), " ").concat(pxTransform(gaps[1] / 2));
|
|
20
|
+
}
|
|
21
|
+
var Grid = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
22
|
+
var className = props.className,
|
|
23
|
+
children = props.children,
|
|
24
|
+
gap = props.gap,
|
|
25
|
+
pxTransform = props.pxTransform,
|
|
26
|
+
col = props.col;
|
|
27
|
+
if (!col) return null;
|
|
28
|
+
return /*#__PURE__*/_jsx(GridContext.Provider, {
|
|
29
|
+
value: props,
|
|
30
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
31
|
+
ref: ref,
|
|
32
|
+
className: classNames(className, "".concat(CSS_PREFIX, "-grid")),
|
|
33
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
34
|
+
style: {
|
|
35
|
+
margin: toMarginPadding(gap, 'margin', pxTransform || pxtorem)
|
|
36
|
+
},
|
|
37
|
+
className: "".concat(CSS_PREFIX, "-grid-wrapper"),
|
|
38
|
+
children: children
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// export interface GridItemProps extends HTMLAttributes<HTMLDivElement> {}
|
|
45
|
+
|
|
46
|
+
var GridItem = function GridItem(_ref) {
|
|
47
|
+
var className = _ref.className,
|
|
48
|
+
children = _ref.children;
|
|
49
|
+
var gridProps = useContext(GridContext);
|
|
50
|
+
var gap = gridProps.gap,
|
|
51
|
+
col = gridProps.col,
|
|
52
|
+
pxTransform = gridProps.pxTransform;
|
|
53
|
+
return /*#__PURE__*/_jsx("div", {
|
|
54
|
+
style: {
|
|
55
|
+
padding: toMarginPadding(gap, 'padding', pxTransform || pxtorem),
|
|
56
|
+
width: "".concat(100 / col, "%")
|
|
57
|
+
},
|
|
58
|
+
className: classNames(className, "".concat(CSS_PREFIX, "-grid-item")),
|
|
59
|
+
children: children
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
var GridCom = Grid;
|
|
63
|
+
GridCom.Item = GridItem;
|
|
64
|
+
export default GridCom;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'katex/dist/katex.min.css';
|
|
3
|
+
interface KaTeXRendererProps {
|
|
4
|
+
expression: string;
|
|
5
|
+
errorMessage?: string;
|
|
6
|
+
displayMode?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const KaTeXRenderer: React.FC<KaTeXRendererProps>;
|
|
9
|
+
export default KaTeXRenderer;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
// KaTeXRenderer.tsx
|
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
|
5
|
+
import katex from 'katex';
|
|
6
|
+
import 'katex/dist/katex.min.css'; // 引入 KaTeX 的样式
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
var KaTeXRenderer = function KaTeXRenderer(_ref) {
|
|
9
|
+
var expression = _ref.expression,
|
|
10
|
+
_ref$errorMessage = _ref.errorMessage,
|
|
11
|
+
errorMessage = _ref$errorMessage === void 0 ? 'Invalid LaTeX expression' : _ref$errorMessage,
|
|
12
|
+
_ref$displayMode = _ref.displayMode,
|
|
13
|
+
displayMode = _ref$displayMode === void 0 ? false : _ref$displayMode;
|
|
14
|
+
var containerRef = useRef(null);
|
|
15
|
+
console.log('expression', expression);
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
if (containerRef.current) {
|
|
18
|
+
try {
|
|
19
|
+
katex.render(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ""])), expression), containerRef.current, {
|
|
20
|
+
throwOnError: false,
|
|
21
|
+
displayMode: displayMode
|
|
22
|
+
});
|
|
23
|
+
} catch (error) {
|
|
24
|
+
containerRef.current.innerHTML = "<span style=\"color: red;\">".concat(errorMessage, "</span>");
|
|
25
|
+
console.error('KaTeX render error:', error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, [expression, displayMode, errorMessage]);
|
|
29
|
+
return /*#__PURE__*/_jsx("div", {
|
|
30
|
+
ref: containerRef
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export default KaTeXRenderer;
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
interface CommonProps {
|
|
4
|
+
disablePictureInPicture?: boolean;
|
|
5
|
+
reconnectCount?: number;
|
|
6
|
+
poster?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VideoHandler {
|
|
9
|
+
play: () => void;
|
|
10
|
+
stop: () => void;
|
|
11
|
+
pause: () => void;
|
|
12
|
+
status: Status;
|
|
13
|
+
}
|
|
14
|
+
type Status = 'playing' | 'paused' | 'stopped' | 'connecting' | 'disconnected' | 'reConnecting';
|
|
15
|
+
export declare const PixelPlayer: React.ForwardRefExoticComponent<{
|
|
16
|
+
disablePictureInPicture?: boolean | undefined;
|
|
17
|
+
onConnected?: (() => void) | undefined;
|
|
18
|
+
onDisconnected?: (() => void) | undefined;
|
|
19
|
+
onTryConnect?: (() => void) | undefined;
|
|
20
|
+
onClick?: (() => void) | undefined;
|
|
21
|
+
renderConnectingView?: (() => JSX.Element) | undefined;
|
|
22
|
+
renderDisconnectedView?: (() => JSX.Element) | undefined;
|
|
23
|
+
renderReconnectingView?: (() => JSX.Element) | undefined;
|
|
24
|
+
url: string;
|
|
25
|
+
className?: string | undefined;
|
|
26
|
+
positionOrigin?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | undefined;
|
|
27
|
+
} & CommonProps & React.RefAttributes<VideoHandler>>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useImperativeHandle, forwardRef, useState, useCallback } from 'react';
|
|
4
|
+
import { initialize } from "./lib/peer-stream";
|
|
5
|
+
import { useVideoWithCustomEvent } from "./useVideoWithCustomEvent";
|
|
6
|
+
import { useAutoLayoutContainer } from "./useAutoLayoutContainer";
|
|
7
|
+
import "./index.less";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
initialize({});
|
|
11
|
+
var defaultRenderTextView = function defaultRenderTextView(text) {
|
|
12
|
+
return /*#__PURE__*/_jsx("div", {
|
|
13
|
+
className: "c-pixel-player__placeholder",
|
|
14
|
+
children: /*#__PURE__*/_jsx("p", {
|
|
15
|
+
className: "c-pixel-player__placeholder-text",
|
|
16
|
+
children: text
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export var PixelPlayer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
21
|
+
var _useState = useState('connecting'),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
status = _useState2[0],
|
|
24
|
+
setStatus = _useState2[1];
|
|
25
|
+
var externalOnConnected = props.onConnected,
|
|
26
|
+
externalOnDisconnected = props.onDisconnected,
|
|
27
|
+
externalOnTryConnect = props.onTryConnect,
|
|
28
|
+
onClick = props.onClick,
|
|
29
|
+
_props$renderConnecti = props.renderConnectingView,
|
|
30
|
+
renderConnectingView = _props$renderConnecti === void 0 ? function () {
|
|
31
|
+
return defaultRenderTextView('正在连接中......');
|
|
32
|
+
} : _props$renderConnecti,
|
|
33
|
+
_props$renderReconnec = props.renderReconnectingView,
|
|
34
|
+
renderReconnectingView = _props$renderReconnec === void 0 ? function () {
|
|
35
|
+
return defaultRenderTextView('正在重连中......');
|
|
36
|
+
} : _props$renderReconnec,
|
|
37
|
+
_props$renderDisconne = props.renderDisconnectedView,
|
|
38
|
+
renderDisconnectedView = _props$renderDisconne === void 0 ? function () {
|
|
39
|
+
return defaultRenderTextView('连接已断开');
|
|
40
|
+
} : _props$renderDisconne;
|
|
41
|
+
var onConnected = useCallback(function () {
|
|
42
|
+
setStatus('playing');
|
|
43
|
+
externalOnConnected === null || externalOnConnected === void 0 || externalOnConnected();
|
|
44
|
+
}, [externalOnConnected]);
|
|
45
|
+
var onDisconnected = useCallback(function () {
|
|
46
|
+
setStatus('disconnected');
|
|
47
|
+
externalOnDisconnected === null || externalOnDisconnected === void 0 || externalOnDisconnected();
|
|
48
|
+
}, [externalOnDisconnected]);
|
|
49
|
+
var onTryConnect = useCallback(function () {
|
|
50
|
+
setStatus('reConnecting');
|
|
51
|
+
externalOnTryConnect === null || externalOnTryConnect === void 0 || externalOnTryConnect();
|
|
52
|
+
}, []);
|
|
53
|
+
var filteredEventHandlers = Object.fromEntries(Object.entries({
|
|
54
|
+
onDisconnected: onDisconnected,
|
|
55
|
+
onConnected: onConnected,
|
|
56
|
+
onTryConnect: onTryConnect,
|
|
57
|
+
onClick: onClick
|
|
58
|
+
}).filter(function (_ref) {
|
|
59
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
60
|
+
_ = _ref2[0],
|
|
61
|
+
value = _ref2[1];
|
|
62
|
+
return value !== undefined;
|
|
63
|
+
}));
|
|
64
|
+
var videoRef = useVideoWithCustomEvent(filteredEventHandlers);
|
|
65
|
+
var containerRef = useAutoLayoutContainer(videoRef, props.positionOrigin || 'top-left');
|
|
66
|
+
useImperativeHandle(ref, function () {
|
|
67
|
+
return {
|
|
68
|
+
play: function play() {
|
|
69
|
+
var _videoRef$current;
|
|
70
|
+
// console.log('播放')
|
|
71
|
+
(_videoRef$current = videoRef.current) === null || _videoRef$current === void 0 || _videoRef$current.customPlay();
|
|
72
|
+
// 默认播放成功
|
|
73
|
+
setStatus('playing');
|
|
74
|
+
},
|
|
75
|
+
pause: function pause() {
|
|
76
|
+
var _videoRef$current2;
|
|
77
|
+
// console.log('暂停')
|
|
78
|
+
(_videoRef$current2 = videoRef.current) === null || _videoRef$current2 === void 0 || _videoRef$current2.customPause();
|
|
79
|
+
setStatus('paused');
|
|
80
|
+
},
|
|
81
|
+
stop: function stop() {
|
|
82
|
+
var _videoRef$current3;
|
|
83
|
+
// console.log('停止')
|
|
84
|
+
(_videoRef$current3 = videoRef.current) === null || _videoRef$current3 === void 0 || _videoRef$current3.customStop();
|
|
85
|
+
setStatus('stopped');
|
|
86
|
+
},
|
|
87
|
+
status: status
|
|
88
|
+
// 可以添加其他想要暴露的方法或属性
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
var videoProps = {
|
|
92
|
+
is: 'peer-stream',
|
|
93
|
+
signal: props.url,
|
|
94
|
+
reconnectCount: props.reconnectCount,
|
|
95
|
+
poster: props.poster,
|
|
96
|
+
disablePictureInPicture: true
|
|
97
|
+
};
|
|
98
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
99
|
+
className: ['c-pixel-player__container', props.className].join(' '),
|
|
100
|
+
ref: containerRef,
|
|
101
|
+
children: [function () {
|
|
102
|
+
switch (status) {
|
|
103
|
+
case 'connecting':
|
|
104
|
+
return renderConnectingView();
|
|
105
|
+
case 'disconnected':
|
|
106
|
+
return renderDisconnectedView();
|
|
107
|
+
case 'reConnecting':
|
|
108
|
+
return renderReconnectingView();
|
|
109
|
+
default:
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}(), /*#__PURE__*/_jsx("video", _objectSpread(_objectSpread({
|
|
113
|
+
className: "c-pixel-player__video"
|
|
114
|
+
}, videoProps), {}, {
|
|
115
|
+
ref: videoRef
|
|
116
|
+
}))]
|
|
117
|
+
});
|
|
118
|
+
});
|