@pnkx-lib/ui 1.9.178 → 1.9.180
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/dist/style.css +1 -1
- package/es/chunks/AntdIcon-B_SLhOJa.js +1211 -0
- package/es/chunks/_commonjsHelpers-BFTU3MAI.js +7 -0
- package/es/chunks/bundle-mjs-BME7zF0Z.js +2956 -0
- package/es/chunks/common-CocKiHtC.js +3 -0
- package/es/chunks/defineProperty-D53odpB3.js +50 -0
- package/es/chunks/get-C880miVG.js +1726 -0
- package/es/chunks/index-mzHK7Za8.js +90 -0
- package/es/chunks/index.esm-DPdCEbIy.js +2276 -0
- package/es/chunks/jsx-runtime-DFKOoQSG.js +430 -0
- package/es/chunks/layout-B04d5Lfr.js +6094 -0
- package/es/constants/index.js +38 -0
- package/es/fields/CascaderField.js +59 -0
- package/es/fields/Checkbox.js +56 -0
- package/es/fields/DatePicker.js +13030 -0
- package/es/fields/DateRangePicker.js +58 -0
- package/es/fields/Input.js +1379 -0
- package/es/fields/PnkxField.js +19 -0
- package/es/fields/Radio.js +56 -0
- package/es/fields/Select.js +61 -0
- package/es/fields/SliderRanger.js +58 -0
- package/es/fields/SliderSingle.js +58 -0
- package/es/fields/Switch.js +58 -0
- package/es/fields/Textarea.js +66 -0
- package/es/fields/TinyMCE.js +1969 -0
- package/es/fields/Upload.js +113 -0
- package/es/fields/index.js +13 -2
- package/es/hooks/index.js +2 -1
- package/es/hooks/useMessage.js +15 -0
- package/es/{chunks/useMessage-CUPcOtIS.js → hooks/useToast.js} +2 -14
- package/es/index.js +74 -4
- package/es/ui/Alert.js +8 -0
- package/es/ui/Anchor.js +9 -0
- package/es/ui/Appfix.js +8 -0
- package/es/ui/AutoComplete.js +8 -0
- package/es/ui/Badge.js +15 -0
- package/es/ui/BottomPagination.js +57 -0
- package/es/ui/Breadcrumb.js +9 -0
- package/es/ui/BreadcrumbHeading.js +54 -0
- package/es/ui/Button.js +8 -0
- package/es/ui/Card.js +8 -0
- package/es/ui/Cascader.js +21 -0
- package/es/ui/CategoryStatus.js +50 -0
- package/es/ui/Col.js +9 -0
- package/es/ui/Collapse.js +8 -0
- package/es/ui/ColorPicker.js +8 -0
- package/es/ui/ConfigProvider.js +11 -0
- package/es/ui/ConfirmModal.js +119 -0
- package/es/ui/Container.js +12 -0
- package/es/ui/Divider.js +8 -0
- package/es/ui/Drawer.js +19 -0
- package/es/ui/Dropdown.js +9 -0
- package/es/ui/Empty.js +8 -0
- package/es/ui/ErrorBoundary.js +81 -0
- package/es/ui/ErrorMessage.js +14 -0
- package/es/ui/Flex.js +9 -0
- package/es/ui/Footer.js +13 -0
- package/es/ui/Heading.js +67 -0
- package/es/ui/Image.js +8 -0
- package/es/ui/Label.js +14 -0
- package/es/ui/Layout.js +25 -0
- package/es/ui/Menu.js +24 -0
- package/es/ui/Modal.js +8 -0
- package/es/{chunks/PageNotFound-D6b4M484.js → ui/PageNotFound.js} +7 -1865
- package/es/ui/Pagination.js +10 -0
- package/es/ui/Popconfirm.js +8 -0
- package/es/ui/Popover.js +9 -0
- package/es/ui/QRCode.js +8 -0
- package/es/ui/Rate.js +8 -0
- package/es/ui/Result.js +8 -0
- package/es/ui/Row.js +9 -0
- package/es/ui/SearchFilterForm.js +87 -0
- package/es/ui/Segmented.js +8 -0
- package/es/ui/Sidebar.js +342 -0
- package/es/ui/Skeleton.js +34 -0
- package/es/ui/Space.js +11 -0
- package/es/ui/Spin.js +8 -0
- package/es/ui/Splitter.js +11 -0
- package/es/ui/Statistic.js +8 -0
- package/es/ui/Steps.js +11 -0
- package/es/ui/Tabs.js +78 -0
- package/es/ui/Tag.js +12 -0
- package/es/ui/Timeline.js +8 -0
- package/es/ui/Tooltip.js +8 -0
- package/es/ui/Tour.js +8 -0
- package/es/ui/Tree.js +8 -0
- package/es/ui/Typography.js +11 -0
- package/es/ui/UploadImage.js +116 -0
- package/es/ui/Watermark.js +28 -0
- package/es/ui/index.js +5235 -2
- package/package.json +31 -1
- package/types/components/ui/BulkActions/BulkAction.d.ts +1 -1
- package/types/components/ui/BulkActions/index.d.ts +1 -1
- package/types/components/ui/Table/ActionRowTable/index.d.ts +1 -1
- package/types/components/ui/Table/HeadingTable/components/GroupHeadingButton.d.ts +1 -1
- package/types/components/ui/Table/index.d.ts +1 -1
- package/types/fields/CascaderField.d.ts +2 -0
- package/types/fields/Checkbox.d.ts +2 -0
- package/types/fields/DatePicker.d.ts +2 -0
- package/types/fields/DateRangePicker.d.ts +2 -0
- package/types/fields/Input.d.ts +2 -0
- package/types/fields/PnkxField.d.ts +2 -0
- package/types/fields/Radio.d.ts +2 -0
- package/types/fields/Select.d.ts +2 -0
- package/types/fields/SliderRanger.d.ts +2 -0
- package/types/fields/SliderSingle.d.ts +2 -0
- package/types/fields/Switch.d.ts +2 -0
- package/types/fields/Textarea.d.ts +2 -0
- package/types/fields/TinyMCE.d.ts +2 -0
- package/types/fields/Upload.d.ts +2 -0
- package/types/fields/index.d.ts +2 -0
- package/types/hooks/index.d.ts +2 -0
- package/types/hooks/useMessage.d.ts +2 -0
- package/types/hooks/useToast.d.ts +2 -0
- package/types/ui/Alert.d.ts +2 -0
- package/types/ui/Anchor.d.ts +2 -0
- package/types/ui/Appfix.d.ts +2 -0
- package/types/ui/AutoComplete.d.ts +2 -0
- package/types/ui/Badge.d.ts +2 -0
- package/types/ui/BottomPagination.d.ts +2 -0
- package/types/ui/Breadcrumb.d.ts +2 -0
- package/types/ui/BreadcrumbHeading.d.ts +2 -0
- package/types/ui/Button.d.ts +2 -0
- package/types/ui/Card.d.ts +2 -0
- package/types/ui/Cascader.d.ts +2 -0
- package/types/ui/CategoryStatus.d.ts +2 -0
- package/types/ui/Col.d.ts +2 -0
- package/types/ui/Collapse.d.ts +2 -0
- package/types/ui/ColorPicker.d.ts +2 -0
- package/types/ui/ConfigProvider.d.ts +2 -0
- package/types/ui/ConfirmModal.d.ts +2 -0
- package/types/ui/Container.d.ts +2 -0
- package/types/ui/Divider.d.ts +2 -0
- package/types/ui/Drawer.d.ts +2 -0
- package/types/ui/Dropdown.d.ts +2 -0
- package/types/ui/Empty.d.ts +2 -0
- package/types/ui/ErrorBoundary.d.ts +2 -0
- package/types/ui/ErrorMessage.d.ts +2 -0
- package/types/ui/Flex.d.ts +2 -0
- package/types/ui/Footer.d.ts +4 -0
- package/types/ui/Heading.d.ts +2 -0
- package/types/ui/Image.d.ts +2 -0
- package/types/ui/Label.d.ts +2 -0
- package/types/ui/Layout.d.ts +2 -0
- package/types/ui/Menu.d.ts +2 -0
- package/types/ui/Modal.d.ts +2 -0
- package/types/ui/PageNotFound.d.ts +2 -0
- package/types/ui/Pagination.d.ts +2 -0
- package/types/ui/Popconfirm.d.ts +2 -0
- package/types/ui/Popover.d.ts +2 -0
- package/types/ui/QRCode.d.ts +2 -0
- package/types/ui/Rate.d.ts +2 -0
- package/types/ui/Result.d.ts +2 -0
- package/types/ui/Row.d.ts +2 -0
- package/types/ui/SearchFilterForm.d.ts +2 -0
- package/types/ui/Segmented.d.ts +2 -0
- package/types/ui/Sidebar.d.ts +2 -0
- package/types/ui/Skeleton.d.ts +2 -0
- package/types/ui/Space.d.ts +2 -0
- package/types/ui/Spin.d.ts +2 -0
- package/types/ui/Splitter.d.ts +2 -0
- package/types/ui/Statistic.d.ts +2 -0
- package/types/ui/Steps.d.ts +2 -0
- package/types/ui/Tabs.d.ts +2 -0
- package/types/ui/Tag.d.ts +2 -0
- package/types/ui/Timeline.d.ts +2 -0
- package/types/ui/Tooltip.d.ts +2 -0
- package/types/ui/Tour.d.ts +2 -0
- package/types/ui/Tree.d.ts +2 -0
- package/types/ui/Typography.d.ts +2 -0
- package/types/ui/UploadImage.d.ts +2 -0
- package/types/ui/Watermark.d.ts +2 -0
- package/types/ui/index.d.ts +2 -0
- package/es/chunks/SliderRanger-BXe2Nxdo.js +0 -361
- package/es/chunks/UploadImage-x6lE6WbO.js +0 -61133
- package/types/App.d.ts +0 -6
- package/types/DemoInput/DemoInput.d.ts +0 -1
- package/types/DemoTable/FiltersCategoryDemo/components/RenderFilterFields.d.ts +0 -12
- package/types/DemoTable/FiltersCategoryDemo/components/TagsFilter.d.ts +0 -12
- package/types/DemoTable/FiltersCategoryDemo/index.d.ts +0 -8
- package/types/DemoTable/apiUser.d.ts +0 -30
- package/types/DemoTable/hooks/useConvertGroupButton.d.ts +0 -13
- package/types/DemoTable/index.d.ts +0 -2
- package/types/DemoTable/tabDemo.d.ts +0 -2
- package/types/assets/svg/404.d.ts +0 -2
- package/types/assets/svg/Flag.d.ts +0 -2
- package/types/assets/svg/Logout.d.ts +0 -2
- package/types/assets/svg/PageNotFoundIcon.d.ts +0 -3
- package/types/assets/svg/Search.d.ts +0 -2
- package/types/assets/svg/Setting.d.ts +0 -2
- package/types/component-test/category-city.d.ts +0 -2
- package/types/component-test/category-manager.d.ts +0 -2
- package/types/component-test/default-layout.d.ts +0 -6
- package/types/component-test/detail-user.d.ts +0 -2
- package/types/component-test/permistion-user.d.ts +0 -2
- package/types/component-test/user-list.d.ts +0 -2
- package/types/fields.d.ts +0 -2
- package/types/hooks.d.ts +0 -2
- package/types/interface/common.d.ts +0 -14
- package/types/interface/tab.d.ts +0 -5
- package/types/main.d.ts +0 -0
- package/types/stores/tabStore.d.ts +0 -6
- package/types/stories/Input.stories.d.ts +0 -6
- package/types/ui.d.ts +0 -2
- package/types/utils/router.d.ts +0 -35
- package/types/utils/timer.d.ts +0 -7
- package/types/vite-env.d.ts +0 -1
|
@@ -0,0 +1,1969 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from '../chunks/jsx-runtime-DFKOoQSG.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { T as TINY_API } from '../chunks/common-CocKiHtC.js';
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
import { ErrorMessage } from '../ui/ErrorMessage.js';
|
|
6
|
+
import { Label } from '../ui/Label.js';
|
|
7
|
+
|
|
8
|
+
var propTypes = {exports: {}};
|
|
9
|
+
|
|
10
|
+
var reactIs = {exports: {}};
|
|
11
|
+
|
|
12
|
+
var reactIs_production_min = {};
|
|
13
|
+
|
|
14
|
+
/** @license React v16.13.1
|
|
15
|
+
* react-is.production.min.js
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the MIT license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
var hasRequiredReactIs_production_min;
|
|
24
|
+
|
|
25
|
+
function requireReactIs_production_min () {
|
|
26
|
+
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
27
|
+
hasRequiredReactIs_production_min = 1;
|
|
28
|
+
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
29
|
+
Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
|
|
30
|
+
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n;reactIs_production_min.Fragment=e;reactIs_production_min.Lazy=t;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
|
|
31
|
+
reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n};reactIs_production_min.isFragment=function(a){return z(a)===e};reactIs_production_min.isLazy=function(a){return z(a)===t};
|
|
32
|
+
reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
|
|
33
|
+
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
|
|
34
|
+
return reactIs_production_min;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var reactIs_development = {};
|
|
38
|
+
|
|
39
|
+
/** @license React v16.13.1
|
|
40
|
+
* react-is.development.js
|
|
41
|
+
*
|
|
42
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the MIT license found in the
|
|
45
|
+
* LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
var hasRequiredReactIs_development;
|
|
49
|
+
|
|
50
|
+
function requireReactIs_development () {
|
|
51
|
+
if (hasRequiredReactIs_development) return reactIs_development;
|
|
52
|
+
hasRequiredReactIs_development = 1;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if (process.env.NODE_ENV !== "production") {
|
|
57
|
+
(function() {
|
|
58
|
+
|
|
59
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
60
|
+
// nor polyfill, then a plain number is used for performance.
|
|
61
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
62
|
+
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
63
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
64
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
65
|
+
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
66
|
+
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
67
|
+
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
68
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
69
|
+
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
70
|
+
|
|
71
|
+
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
72
|
+
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
73
|
+
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
74
|
+
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
75
|
+
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
76
|
+
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
77
|
+
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
78
|
+
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
79
|
+
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
80
|
+
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
81
|
+
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
82
|
+
|
|
83
|
+
function isValidElementType(type) {
|
|
84
|
+
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
85
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function typeOf(object) {
|
|
89
|
+
if (typeof object === 'object' && object !== null) {
|
|
90
|
+
var $$typeof = object.$$typeof;
|
|
91
|
+
|
|
92
|
+
switch ($$typeof) {
|
|
93
|
+
case REACT_ELEMENT_TYPE:
|
|
94
|
+
var type = object.type;
|
|
95
|
+
|
|
96
|
+
switch (type) {
|
|
97
|
+
case REACT_ASYNC_MODE_TYPE:
|
|
98
|
+
case REACT_CONCURRENT_MODE_TYPE:
|
|
99
|
+
case REACT_FRAGMENT_TYPE:
|
|
100
|
+
case REACT_PROFILER_TYPE:
|
|
101
|
+
case REACT_STRICT_MODE_TYPE:
|
|
102
|
+
case REACT_SUSPENSE_TYPE:
|
|
103
|
+
return type;
|
|
104
|
+
|
|
105
|
+
default:
|
|
106
|
+
var $$typeofType = type && type.$$typeof;
|
|
107
|
+
|
|
108
|
+
switch ($$typeofType) {
|
|
109
|
+
case REACT_CONTEXT_TYPE:
|
|
110
|
+
case REACT_FORWARD_REF_TYPE:
|
|
111
|
+
case REACT_LAZY_TYPE:
|
|
112
|
+
case REACT_MEMO_TYPE:
|
|
113
|
+
case REACT_PROVIDER_TYPE:
|
|
114
|
+
return $$typeofType;
|
|
115
|
+
|
|
116
|
+
default:
|
|
117
|
+
return $$typeof;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
case REACT_PORTAL_TYPE:
|
|
123
|
+
return $$typeof;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return undefined;
|
|
128
|
+
} // AsyncMode is deprecated along with isAsyncMode
|
|
129
|
+
|
|
130
|
+
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
131
|
+
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
132
|
+
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
133
|
+
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
134
|
+
var Element = REACT_ELEMENT_TYPE;
|
|
135
|
+
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
136
|
+
var Fragment = REACT_FRAGMENT_TYPE;
|
|
137
|
+
var Lazy = REACT_LAZY_TYPE;
|
|
138
|
+
var Memo = REACT_MEMO_TYPE;
|
|
139
|
+
var Portal = REACT_PORTAL_TYPE;
|
|
140
|
+
var Profiler = REACT_PROFILER_TYPE;
|
|
141
|
+
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
142
|
+
var Suspense = REACT_SUSPENSE_TYPE;
|
|
143
|
+
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
144
|
+
|
|
145
|
+
function isAsyncMode(object) {
|
|
146
|
+
{
|
|
147
|
+
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
148
|
+
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
149
|
+
|
|
150
|
+
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
155
|
+
}
|
|
156
|
+
function isConcurrentMode(object) {
|
|
157
|
+
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
158
|
+
}
|
|
159
|
+
function isContextConsumer(object) {
|
|
160
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
161
|
+
}
|
|
162
|
+
function isContextProvider(object) {
|
|
163
|
+
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
164
|
+
}
|
|
165
|
+
function isElement(object) {
|
|
166
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
167
|
+
}
|
|
168
|
+
function isForwardRef(object) {
|
|
169
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
170
|
+
}
|
|
171
|
+
function isFragment(object) {
|
|
172
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
173
|
+
}
|
|
174
|
+
function isLazy(object) {
|
|
175
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
176
|
+
}
|
|
177
|
+
function isMemo(object) {
|
|
178
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
179
|
+
}
|
|
180
|
+
function isPortal(object) {
|
|
181
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
182
|
+
}
|
|
183
|
+
function isProfiler(object) {
|
|
184
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
185
|
+
}
|
|
186
|
+
function isStrictMode(object) {
|
|
187
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
188
|
+
}
|
|
189
|
+
function isSuspense(object) {
|
|
190
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
reactIs_development.AsyncMode = AsyncMode;
|
|
194
|
+
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
195
|
+
reactIs_development.ContextConsumer = ContextConsumer;
|
|
196
|
+
reactIs_development.ContextProvider = ContextProvider;
|
|
197
|
+
reactIs_development.Element = Element;
|
|
198
|
+
reactIs_development.ForwardRef = ForwardRef;
|
|
199
|
+
reactIs_development.Fragment = Fragment;
|
|
200
|
+
reactIs_development.Lazy = Lazy;
|
|
201
|
+
reactIs_development.Memo = Memo;
|
|
202
|
+
reactIs_development.Portal = Portal;
|
|
203
|
+
reactIs_development.Profiler = Profiler;
|
|
204
|
+
reactIs_development.StrictMode = StrictMode;
|
|
205
|
+
reactIs_development.Suspense = Suspense;
|
|
206
|
+
reactIs_development.isAsyncMode = isAsyncMode;
|
|
207
|
+
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
208
|
+
reactIs_development.isContextConsumer = isContextConsumer;
|
|
209
|
+
reactIs_development.isContextProvider = isContextProvider;
|
|
210
|
+
reactIs_development.isElement = isElement;
|
|
211
|
+
reactIs_development.isForwardRef = isForwardRef;
|
|
212
|
+
reactIs_development.isFragment = isFragment;
|
|
213
|
+
reactIs_development.isLazy = isLazy;
|
|
214
|
+
reactIs_development.isMemo = isMemo;
|
|
215
|
+
reactIs_development.isPortal = isPortal;
|
|
216
|
+
reactIs_development.isProfiler = isProfiler;
|
|
217
|
+
reactIs_development.isStrictMode = isStrictMode;
|
|
218
|
+
reactIs_development.isSuspense = isSuspense;
|
|
219
|
+
reactIs_development.isValidElementType = isValidElementType;
|
|
220
|
+
reactIs_development.typeOf = typeOf;
|
|
221
|
+
})();
|
|
222
|
+
}
|
|
223
|
+
return reactIs_development;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
var hasRequiredReactIs;
|
|
227
|
+
|
|
228
|
+
function requireReactIs () {
|
|
229
|
+
if (hasRequiredReactIs) return reactIs.exports;
|
|
230
|
+
hasRequiredReactIs = 1;
|
|
231
|
+
|
|
232
|
+
if (process.env.NODE_ENV === 'production') {
|
|
233
|
+
reactIs.exports = /*@__PURE__*/ requireReactIs_production_min();
|
|
234
|
+
} else {
|
|
235
|
+
reactIs.exports = /*@__PURE__*/ requireReactIs_development();
|
|
236
|
+
}
|
|
237
|
+
return reactIs.exports;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/*
|
|
241
|
+
object-assign
|
|
242
|
+
(c) Sindre Sorhus
|
|
243
|
+
@license MIT
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
var objectAssign;
|
|
247
|
+
var hasRequiredObjectAssign;
|
|
248
|
+
|
|
249
|
+
function requireObjectAssign () {
|
|
250
|
+
if (hasRequiredObjectAssign) return objectAssign;
|
|
251
|
+
hasRequiredObjectAssign = 1;
|
|
252
|
+
/* eslint-disable no-unused-vars */
|
|
253
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
254
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
255
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
256
|
+
|
|
257
|
+
function toObject(val) {
|
|
258
|
+
if (val === null || val === undefined) {
|
|
259
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return Object(val);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function shouldUseNative() {
|
|
266
|
+
try {
|
|
267
|
+
if (!Object.assign) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
272
|
+
|
|
273
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
274
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
275
|
+
test1[5] = 'de';
|
|
276
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
281
|
+
var test2 = {};
|
|
282
|
+
for (var i = 0; i < 10; i++) {
|
|
283
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
284
|
+
}
|
|
285
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
286
|
+
return test2[n];
|
|
287
|
+
});
|
|
288
|
+
if (order2.join('') !== '0123456789') {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
293
|
+
var test3 = {};
|
|
294
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
295
|
+
test3[letter] = letter;
|
|
296
|
+
});
|
|
297
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
298
|
+
'abcdefghijklmnopqrst') {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return true;
|
|
303
|
+
} catch (err) {
|
|
304
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
310
|
+
var from;
|
|
311
|
+
var to = toObject(target);
|
|
312
|
+
var symbols;
|
|
313
|
+
|
|
314
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
315
|
+
from = Object(arguments[s]);
|
|
316
|
+
|
|
317
|
+
for (var key in from) {
|
|
318
|
+
if (hasOwnProperty.call(from, key)) {
|
|
319
|
+
to[key] = from[key];
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (getOwnPropertySymbols) {
|
|
324
|
+
symbols = getOwnPropertySymbols(from);
|
|
325
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
326
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
327
|
+
to[symbols[i]] = from[symbols[i]];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return to;
|
|
334
|
+
};
|
|
335
|
+
return objectAssign;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
340
|
+
*
|
|
341
|
+
* This source code is licensed under the MIT license found in the
|
|
342
|
+
* LICENSE file in the root directory of this source tree.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
var ReactPropTypesSecret_1;
|
|
346
|
+
var hasRequiredReactPropTypesSecret;
|
|
347
|
+
|
|
348
|
+
function requireReactPropTypesSecret () {
|
|
349
|
+
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
|
350
|
+
hasRequiredReactPropTypesSecret = 1;
|
|
351
|
+
|
|
352
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
353
|
+
|
|
354
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
355
|
+
return ReactPropTypesSecret_1;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
var has;
|
|
359
|
+
var hasRequiredHas;
|
|
360
|
+
|
|
361
|
+
function requireHas () {
|
|
362
|
+
if (hasRequiredHas) return has;
|
|
363
|
+
hasRequiredHas = 1;
|
|
364
|
+
has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
365
|
+
return has;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
370
|
+
*
|
|
371
|
+
* This source code is licensed under the MIT license found in the
|
|
372
|
+
* LICENSE file in the root directory of this source tree.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
var checkPropTypes_1;
|
|
376
|
+
var hasRequiredCheckPropTypes;
|
|
377
|
+
|
|
378
|
+
function requireCheckPropTypes () {
|
|
379
|
+
if (hasRequiredCheckPropTypes) return checkPropTypes_1;
|
|
380
|
+
hasRequiredCheckPropTypes = 1;
|
|
381
|
+
|
|
382
|
+
var printWarning = function() {};
|
|
383
|
+
|
|
384
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
385
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
386
|
+
var loggedTypeFailures = {};
|
|
387
|
+
var has = /*@__PURE__*/ requireHas();
|
|
388
|
+
|
|
389
|
+
printWarning = function(text) {
|
|
390
|
+
var message = 'Warning: ' + text;
|
|
391
|
+
if (typeof console !== 'undefined') {
|
|
392
|
+
console.error(message);
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
// --- Welcome to debugging React ---
|
|
396
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
397
|
+
// to find the callsite that caused this warning to fire.
|
|
398
|
+
throw new Error(message);
|
|
399
|
+
} catch (x) { /**/ }
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Assert that the values match with the type specs.
|
|
405
|
+
* Error messages are memorized and will only be shown once.
|
|
406
|
+
*
|
|
407
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
408
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
409
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
410
|
+
* @param {string} componentName Name of the component for error messages.
|
|
411
|
+
* @param {?Function} getStack Returns the component stack.
|
|
412
|
+
* @private
|
|
413
|
+
*/
|
|
414
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
415
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
416
|
+
for (var typeSpecName in typeSpecs) {
|
|
417
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
418
|
+
var error;
|
|
419
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
420
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
421
|
+
// After these have been cleaned up, we'll let them throw.
|
|
422
|
+
try {
|
|
423
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
424
|
+
// behavior as without this statement except with a better message.
|
|
425
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
426
|
+
var err = Error(
|
|
427
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
428
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
|
|
429
|
+
'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
|
|
430
|
+
);
|
|
431
|
+
err.name = 'Invariant Violation';
|
|
432
|
+
throw err;
|
|
433
|
+
}
|
|
434
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
435
|
+
} catch (ex) {
|
|
436
|
+
error = ex;
|
|
437
|
+
}
|
|
438
|
+
if (error && !(error instanceof Error)) {
|
|
439
|
+
printWarning(
|
|
440
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
441
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
442
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
443
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
444
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
445
|
+
'shape all require an argument).'
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
449
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
450
|
+
// same error.
|
|
451
|
+
loggedTypeFailures[error.message] = true;
|
|
452
|
+
|
|
453
|
+
var stack = getStack ? getStack() : '';
|
|
454
|
+
|
|
455
|
+
printWarning(
|
|
456
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Resets warning cache when testing.
|
|
466
|
+
*
|
|
467
|
+
* @private
|
|
468
|
+
*/
|
|
469
|
+
checkPropTypes.resetWarningCache = function() {
|
|
470
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
471
|
+
loggedTypeFailures = {};
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
checkPropTypes_1 = checkPropTypes;
|
|
476
|
+
return checkPropTypes_1;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
481
|
+
*
|
|
482
|
+
* This source code is licensed under the MIT license found in the
|
|
483
|
+
* LICENSE file in the root directory of this source tree.
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
var factoryWithTypeCheckers;
|
|
487
|
+
var hasRequiredFactoryWithTypeCheckers;
|
|
488
|
+
|
|
489
|
+
function requireFactoryWithTypeCheckers () {
|
|
490
|
+
if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
|
|
491
|
+
hasRequiredFactoryWithTypeCheckers = 1;
|
|
492
|
+
|
|
493
|
+
var ReactIs = /*@__PURE__*/ requireReactIs();
|
|
494
|
+
var assign = /*@__PURE__*/ requireObjectAssign();
|
|
495
|
+
|
|
496
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
497
|
+
var has = /*@__PURE__*/ requireHas();
|
|
498
|
+
var checkPropTypes = /*@__PURE__*/ requireCheckPropTypes();
|
|
499
|
+
|
|
500
|
+
var printWarning = function() {};
|
|
501
|
+
|
|
502
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
503
|
+
printWarning = function(text) {
|
|
504
|
+
var message = 'Warning: ' + text;
|
|
505
|
+
if (typeof console !== 'undefined') {
|
|
506
|
+
console.error(message);
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
// --- Welcome to debugging React ---
|
|
510
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
511
|
+
// to find the callsite that caused this warning to fire.
|
|
512
|
+
throw new Error(message);
|
|
513
|
+
} catch (x) {}
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function emptyFunctionThatReturnsNull() {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
522
|
+
/* global Symbol */
|
|
523
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
524
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Returns the iterator method function contained on the iterable object.
|
|
528
|
+
*
|
|
529
|
+
* Be sure to invoke the function with the iterable as context:
|
|
530
|
+
*
|
|
531
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
532
|
+
* if (iteratorFn) {
|
|
533
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
534
|
+
* ...
|
|
535
|
+
* }
|
|
536
|
+
*
|
|
537
|
+
* @param {?object} maybeIterable
|
|
538
|
+
* @return {?function}
|
|
539
|
+
*/
|
|
540
|
+
function getIteratorFn(maybeIterable) {
|
|
541
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
542
|
+
if (typeof iteratorFn === 'function') {
|
|
543
|
+
return iteratorFn;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
549
|
+
* supplied to React components. Example usage:
|
|
550
|
+
*
|
|
551
|
+
* var Props = require('ReactPropTypes');
|
|
552
|
+
* var MyArticle = React.createClass({
|
|
553
|
+
* propTypes: {
|
|
554
|
+
* // An optional string prop named "description".
|
|
555
|
+
* description: Props.string,
|
|
556
|
+
*
|
|
557
|
+
* // A required enum prop named "category".
|
|
558
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
559
|
+
*
|
|
560
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
561
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
562
|
+
* },
|
|
563
|
+
* render: function() { ... }
|
|
564
|
+
* });
|
|
565
|
+
*
|
|
566
|
+
* A more formal specification of how these methods are used:
|
|
567
|
+
*
|
|
568
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
569
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
570
|
+
*
|
|
571
|
+
* Each and every declaration produces a function with the same signature. This
|
|
572
|
+
* allows the creation of custom validation functions. For example:
|
|
573
|
+
*
|
|
574
|
+
* var MyLink = React.createClass({
|
|
575
|
+
* propTypes: {
|
|
576
|
+
* // An optional string or URI prop named "href".
|
|
577
|
+
* href: function(props, propName, componentName) {
|
|
578
|
+
* var propValue = props[propName];
|
|
579
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
580
|
+
* !(propValue instanceof URI)) {
|
|
581
|
+
* return new Error(
|
|
582
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
583
|
+
* componentName
|
|
584
|
+
* );
|
|
585
|
+
* }
|
|
586
|
+
* }
|
|
587
|
+
* },
|
|
588
|
+
* render: function() {...}
|
|
589
|
+
* });
|
|
590
|
+
*
|
|
591
|
+
* @internal
|
|
592
|
+
*/
|
|
593
|
+
|
|
594
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
595
|
+
|
|
596
|
+
// Important!
|
|
597
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
598
|
+
var ReactPropTypes = {
|
|
599
|
+
array: createPrimitiveTypeChecker('array'),
|
|
600
|
+
bigint: createPrimitiveTypeChecker('bigint'),
|
|
601
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
602
|
+
func: createPrimitiveTypeChecker('function'),
|
|
603
|
+
number: createPrimitiveTypeChecker('number'),
|
|
604
|
+
object: createPrimitiveTypeChecker('object'),
|
|
605
|
+
string: createPrimitiveTypeChecker('string'),
|
|
606
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
607
|
+
|
|
608
|
+
any: createAnyTypeChecker(),
|
|
609
|
+
arrayOf: createArrayOfTypeChecker,
|
|
610
|
+
element: createElementTypeChecker(),
|
|
611
|
+
elementType: createElementTypeTypeChecker(),
|
|
612
|
+
instanceOf: createInstanceTypeChecker,
|
|
613
|
+
node: createNodeChecker(),
|
|
614
|
+
objectOf: createObjectOfTypeChecker,
|
|
615
|
+
oneOf: createEnumTypeChecker,
|
|
616
|
+
oneOfType: createUnionTypeChecker,
|
|
617
|
+
shape: createShapeTypeChecker,
|
|
618
|
+
exact: createStrictShapeTypeChecker,
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
623
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
624
|
+
*/
|
|
625
|
+
/*eslint-disable no-self-compare*/
|
|
626
|
+
function is(x, y) {
|
|
627
|
+
// SameValue algorithm
|
|
628
|
+
if (x === y) {
|
|
629
|
+
// Steps 1-5, 7-10
|
|
630
|
+
// Steps 6.b-6.e: +0 != -0
|
|
631
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
632
|
+
} else {
|
|
633
|
+
// Step 6.a: NaN == NaN
|
|
634
|
+
return x !== x && y !== y;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/*eslint-enable no-self-compare*/
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
641
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
642
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
643
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
644
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
645
|
+
*/
|
|
646
|
+
function PropTypeError(message, data) {
|
|
647
|
+
this.message = message;
|
|
648
|
+
this.data = data && typeof data === 'object' ? data: {};
|
|
649
|
+
this.stack = '';
|
|
650
|
+
}
|
|
651
|
+
// Make `instanceof Error` still work for returned errors.
|
|
652
|
+
PropTypeError.prototype = Error.prototype;
|
|
653
|
+
|
|
654
|
+
function createChainableTypeChecker(validate) {
|
|
655
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
656
|
+
var manualPropTypeCallCache = {};
|
|
657
|
+
var manualPropTypeWarningCount = 0;
|
|
658
|
+
}
|
|
659
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
660
|
+
componentName = componentName || ANONYMOUS;
|
|
661
|
+
propFullName = propFullName || propName;
|
|
662
|
+
|
|
663
|
+
if (secret !== ReactPropTypesSecret) {
|
|
664
|
+
if (throwOnDirectAccess) {
|
|
665
|
+
// New behavior only for users of `prop-types` package
|
|
666
|
+
var err = new Error(
|
|
667
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
668
|
+
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
669
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
670
|
+
);
|
|
671
|
+
err.name = 'Invariant Violation';
|
|
672
|
+
throw err;
|
|
673
|
+
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
674
|
+
// Old behavior for people using React.PropTypes
|
|
675
|
+
var cacheKey = componentName + ':' + propName;
|
|
676
|
+
if (
|
|
677
|
+
!manualPropTypeCallCache[cacheKey] &&
|
|
678
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
679
|
+
manualPropTypeWarningCount < 3
|
|
680
|
+
) {
|
|
681
|
+
printWarning(
|
|
682
|
+
'You are manually calling a React.PropTypes validation ' +
|
|
683
|
+
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
|
684
|
+
'and will throw in the standalone `prop-types` package. ' +
|
|
685
|
+
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
686
|
+
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
|
687
|
+
);
|
|
688
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
689
|
+
manualPropTypeWarningCount++;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (props[propName] == null) {
|
|
694
|
+
if (isRequired) {
|
|
695
|
+
if (props[propName] === null) {
|
|
696
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
697
|
+
}
|
|
698
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
699
|
+
}
|
|
700
|
+
return null;
|
|
701
|
+
} else {
|
|
702
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
707
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
708
|
+
|
|
709
|
+
return chainedCheckType;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
713
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
714
|
+
var propValue = props[propName];
|
|
715
|
+
var propType = getPropType(propValue);
|
|
716
|
+
if (propType !== expectedType) {
|
|
717
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
718
|
+
// check, but we can offer a more precise error message here rather than
|
|
719
|
+
// 'of type `object`'.
|
|
720
|
+
var preciseType = getPreciseType(propValue);
|
|
721
|
+
|
|
722
|
+
return new PropTypeError(
|
|
723
|
+
'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
|
|
724
|
+
{expectedType: expectedType}
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
return createChainableTypeChecker(validate);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function createAnyTypeChecker() {
|
|
733
|
+
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
737
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
738
|
+
if (typeof typeChecker !== 'function') {
|
|
739
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
740
|
+
}
|
|
741
|
+
var propValue = props[propName];
|
|
742
|
+
if (!Array.isArray(propValue)) {
|
|
743
|
+
var propType = getPropType(propValue);
|
|
744
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
745
|
+
}
|
|
746
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
747
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
|
748
|
+
if (error instanceof Error) {
|
|
749
|
+
return error;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return null;
|
|
753
|
+
}
|
|
754
|
+
return createChainableTypeChecker(validate);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function createElementTypeChecker() {
|
|
758
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
759
|
+
var propValue = props[propName];
|
|
760
|
+
if (!isValidElement(propValue)) {
|
|
761
|
+
var propType = getPropType(propValue);
|
|
762
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
763
|
+
}
|
|
764
|
+
return null;
|
|
765
|
+
}
|
|
766
|
+
return createChainableTypeChecker(validate);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function createElementTypeTypeChecker() {
|
|
770
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
771
|
+
var propValue = props[propName];
|
|
772
|
+
if (!ReactIs.isValidElementType(propValue)) {
|
|
773
|
+
var propType = getPropType(propValue);
|
|
774
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
775
|
+
}
|
|
776
|
+
return null;
|
|
777
|
+
}
|
|
778
|
+
return createChainableTypeChecker(validate);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
782
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
783
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
784
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
785
|
+
var actualClassName = getClassName(props[propName]);
|
|
786
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
787
|
+
}
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
return createChainableTypeChecker(validate);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function createEnumTypeChecker(expectedValues) {
|
|
794
|
+
if (!Array.isArray(expectedValues)) {
|
|
795
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
796
|
+
if (arguments.length > 1) {
|
|
797
|
+
printWarning(
|
|
798
|
+
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
|
799
|
+
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
|
800
|
+
);
|
|
801
|
+
} else {
|
|
802
|
+
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return emptyFunctionThatReturnsNull;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
809
|
+
var propValue = props[propName];
|
|
810
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
811
|
+
if (is(propValue, expectedValues[i])) {
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
817
|
+
var type = getPreciseType(value);
|
|
818
|
+
if (type === 'symbol') {
|
|
819
|
+
return String(value);
|
|
820
|
+
}
|
|
821
|
+
return value;
|
|
822
|
+
});
|
|
823
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
824
|
+
}
|
|
825
|
+
return createChainableTypeChecker(validate);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
829
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
830
|
+
if (typeof typeChecker !== 'function') {
|
|
831
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
832
|
+
}
|
|
833
|
+
var propValue = props[propName];
|
|
834
|
+
var propType = getPropType(propValue);
|
|
835
|
+
if (propType !== 'object') {
|
|
836
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
837
|
+
}
|
|
838
|
+
for (var key in propValue) {
|
|
839
|
+
if (has(propValue, key)) {
|
|
840
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
841
|
+
if (error instanceof Error) {
|
|
842
|
+
return error;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
return createChainableTypeChecker(validate);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
852
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
853
|
+
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
854
|
+
return emptyFunctionThatReturnsNull;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
858
|
+
var checker = arrayOfTypeCheckers[i];
|
|
859
|
+
if (typeof checker !== 'function') {
|
|
860
|
+
printWarning(
|
|
861
|
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
862
|
+
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
|
863
|
+
);
|
|
864
|
+
return emptyFunctionThatReturnsNull;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
869
|
+
var expectedTypes = [];
|
|
870
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
871
|
+
var checker = arrayOfTypeCheckers[i];
|
|
872
|
+
var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
|
873
|
+
if (checkerResult == null) {
|
|
874
|
+
return null;
|
|
875
|
+
}
|
|
876
|
+
if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
|
|
877
|
+
expectedTypes.push(checkerResult.data.expectedType);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
|
|
881
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
|
882
|
+
}
|
|
883
|
+
return createChainableTypeChecker(validate);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
function createNodeChecker() {
|
|
887
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
888
|
+
if (!isNode(props[propName])) {
|
|
889
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
890
|
+
}
|
|
891
|
+
return null;
|
|
892
|
+
}
|
|
893
|
+
return createChainableTypeChecker(validate);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
897
|
+
return new PropTypeError(
|
|
898
|
+
(componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
|
|
899
|
+
'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
904
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
905
|
+
var propValue = props[propName];
|
|
906
|
+
var propType = getPropType(propValue);
|
|
907
|
+
if (propType !== 'object') {
|
|
908
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
909
|
+
}
|
|
910
|
+
for (var key in shapeTypes) {
|
|
911
|
+
var checker = shapeTypes[key];
|
|
912
|
+
if (typeof checker !== 'function') {
|
|
913
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
914
|
+
}
|
|
915
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
916
|
+
if (error) {
|
|
917
|
+
return error;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return null;
|
|
921
|
+
}
|
|
922
|
+
return createChainableTypeChecker(validate);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
926
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
927
|
+
var propValue = props[propName];
|
|
928
|
+
var propType = getPropType(propValue);
|
|
929
|
+
if (propType !== 'object') {
|
|
930
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
931
|
+
}
|
|
932
|
+
// We need to check all keys in case some are required but missing from props.
|
|
933
|
+
var allKeys = assign({}, props[propName], shapeTypes);
|
|
934
|
+
for (var key in allKeys) {
|
|
935
|
+
var checker = shapeTypes[key];
|
|
936
|
+
if (has(shapeTypes, key) && typeof checker !== 'function') {
|
|
937
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
938
|
+
}
|
|
939
|
+
if (!checker) {
|
|
940
|
+
return new PropTypeError(
|
|
941
|
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
|
942
|
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
|
943
|
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
947
|
+
if (error) {
|
|
948
|
+
return error;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return null;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
return createChainableTypeChecker(validate);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function isNode(propValue) {
|
|
958
|
+
switch (typeof propValue) {
|
|
959
|
+
case 'number':
|
|
960
|
+
case 'string':
|
|
961
|
+
case 'undefined':
|
|
962
|
+
return true;
|
|
963
|
+
case 'boolean':
|
|
964
|
+
return !propValue;
|
|
965
|
+
case 'object':
|
|
966
|
+
if (Array.isArray(propValue)) {
|
|
967
|
+
return propValue.every(isNode);
|
|
968
|
+
}
|
|
969
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
970
|
+
return true;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
974
|
+
if (iteratorFn) {
|
|
975
|
+
var iterator = iteratorFn.call(propValue);
|
|
976
|
+
var step;
|
|
977
|
+
if (iteratorFn !== propValue.entries) {
|
|
978
|
+
while (!(step = iterator.next()).done) {
|
|
979
|
+
if (!isNode(step.value)) {
|
|
980
|
+
return false;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
} else {
|
|
984
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
985
|
+
while (!(step = iterator.next()).done) {
|
|
986
|
+
var entry = step.value;
|
|
987
|
+
if (entry) {
|
|
988
|
+
if (!isNode(entry[1])) {
|
|
989
|
+
return false;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
} else {
|
|
995
|
+
return false;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
return true;
|
|
999
|
+
default:
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function isSymbol(propType, propValue) {
|
|
1005
|
+
// Native Symbol.
|
|
1006
|
+
if (propType === 'symbol') {
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// falsy value can't be a Symbol
|
|
1011
|
+
if (!propValue) {
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
1016
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
1017
|
+
return true;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
1021
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
1022
|
+
return true;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
return false;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
1029
|
+
function getPropType(propValue) {
|
|
1030
|
+
var propType = typeof propValue;
|
|
1031
|
+
if (Array.isArray(propValue)) {
|
|
1032
|
+
return 'array';
|
|
1033
|
+
}
|
|
1034
|
+
if (propValue instanceof RegExp) {
|
|
1035
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
1036
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
1037
|
+
// passes PropTypes.object.
|
|
1038
|
+
return 'object';
|
|
1039
|
+
}
|
|
1040
|
+
if (isSymbol(propType, propValue)) {
|
|
1041
|
+
return 'symbol';
|
|
1042
|
+
}
|
|
1043
|
+
return propType;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
1047
|
+
// See `createPrimitiveTypeChecker`.
|
|
1048
|
+
function getPreciseType(propValue) {
|
|
1049
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
1050
|
+
return '' + propValue;
|
|
1051
|
+
}
|
|
1052
|
+
var propType = getPropType(propValue);
|
|
1053
|
+
if (propType === 'object') {
|
|
1054
|
+
if (propValue instanceof Date) {
|
|
1055
|
+
return 'date';
|
|
1056
|
+
} else if (propValue instanceof RegExp) {
|
|
1057
|
+
return 'regexp';
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
return propType;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
1064
|
+
// For example, "undefined" or "of type array"
|
|
1065
|
+
function getPostfixForTypeWarning(value) {
|
|
1066
|
+
var type = getPreciseType(value);
|
|
1067
|
+
switch (type) {
|
|
1068
|
+
case 'array':
|
|
1069
|
+
case 'object':
|
|
1070
|
+
return 'an ' + type;
|
|
1071
|
+
case 'boolean':
|
|
1072
|
+
case 'date':
|
|
1073
|
+
case 'regexp':
|
|
1074
|
+
return 'a ' + type;
|
|
1075
|
+
default:
|
|
1076
|
+
return type;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// Returns class name of the object, if any.
|
|
1081
|
+
function getClassName(propValue) {
|
|
1082
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
1083
|
+
return ANONYMOUS;
|
|
1084
|
+
}
|
|
1085
|
+
return propValue.constructor.name;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
1089
|
+
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
1090
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1091
|
+
|
|
1092
|
+
return ReactPropTypes;
|
|
1093
|
+
};
|
|
1094
|
+
return factoryWithTypeCheckers;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1099
|
+
*
|
|
1100
|
+
* This source code is licensed under the MIT license found in the
|
|
1101
|
+
* LICENSE file in the root directory of this source tree.
|
|
1102
|
+
*/
|
|
1103
|
+
|
|
1104
|
+
var factoryWithThrowingShims;
|
|
1105
|
+
var hasRequiredFactoryWithThrowingShims;
|
|
1106
|
+
|
|
1107
|
+
function requireFactoryWithThrowingShims () {
|
|
1108
|
+
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
|
|
1109
|
+
hasRequiredFactoryWithThrowingShims = 1;
|
|
1110
|
+
|
|
1111
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
1112
|
+
|
|
1113
|
+
function emptyFunction() {}
|
|
1114
|
+
function emptyFunctionWithReset() {}
|
|
1115
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
1116
|
+
|
|
1117
|
+
factoryWithThrowingShims = function() {
|
|
1118
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
1119
|
+
if (secret === ReactPropTypesSecret) {
|
|
1120
|
+
// It is still safe when called from React.
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
var err = new Error(
|
|
1124
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
1125
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
1126
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
1127
|
+
);
|
|
1128
|
+
err.name = 'Invariant Violation';
|
|
1129
|
+
throw err;
|
|
1130
|
+
} shim.isRequired = shim;
|
|
1131
|
+
function getShim() {
|
|
1132
|
+
return shim;
|
|
1133
|
+
} // Important!
|
|
1134
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
1135
|
+
var ReactPropTypes = {
|
|
1136
|
+
array: shim,
|
|
1137
|
+
bigint: shim,
|
|
1138
|
+
bool: shim,
|
|
1139
|
+
func: shim,
|
|
1140
|
+
number: shim,
|
|
1141
|
+
object: shim,
|
|
1142
|
+
string: shim,
|
|
1143
|
+
symbol: shim,
|
|
1144
|
+
|
|
1145
|
+
any: shim,
|
|
1146
|
+
arrayOf: getShim,
|
|
1147
|
+
element: shim,
|
|
1148
|
+
elementType: shim,
|
|
1149
|
+
instanceOf: getShim,
|
|
1150
|
+
node: shim,
|
|
1151
|
+
objectOf: getShim,
|
|
1152
|
+
oneOf: getShim,
|
|
1153
|
+
oneOfType: getShim,
|
|
1154
|
+
shape: getShim,
|
|
1155
|
+
exact: getShim,
|
|
1156
|
+
|
|
1157
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
1158
|
+
resetWarningCache: emptyFunction
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1162
|
+
|
|
1163
|
+
return ReactPropTypes;
|
|
1164
|
+
};
|
|
1165
|
+
return factoryWithThrowingShims;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1170
|
+
*
|
|
1171
|
+
* This source code is licensed under the MIT license found in the
|
|
1172
|
+
* LICENSE file in the root directory of this source tree.
|
|
1173
|
+
*/
|
|
1174
|
+
|
|
1175
|
+
var hasRequiredPropTypes;
|
|
1176
|
+
|
|
1177
|
+
function requirePropTypes () {
|
|
1178
|
+
if (hasRequiredPropTypes) return propTypes.exports;
|
|
1179
|
+
hasRequiredPropTypes = 1;
|
|
1180
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1181
|
+
var ReactIs = /*@__PURE__*/ requireReactIs();
|
|
1182
|
+
|
|
1183
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
1184
|
+
// http://fb.me/prop-types-in-prod
|
|
1185
|
+
var throwOnDirectAccess = true;
|
|
1186
|
+
propTypes.exports = /*@__PURE__*/ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
|
1187
|
+
} else {
|
|
1188
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1189
|
+
// http://fb.me/prop-types-in-prod
|
|
1190
|
+
propTypes.exports = /*@__PURE__*/ requireFactoryWithThrowingShims()();
|
|
1191
|
+
}
|
|
1192
|
+
return propTypes.exports;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
var propTypesExports = /*@__PURE__*/ requirePropTypes();
|
|
1196
|
+
|
|
1197
|
+
var __assign$2 = (undefined && undefined.__assign) || function () {
|
|
1198
|
+
__assign$2 = Object.assign || function(t) {
|
|
1199
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1200
|
+
s = arguments[i];
|
|
1201
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1202
|
+
t[p] = s[p];
|
|
1203
|
+
}
|
|
1204
|
+
return t;
|
|
1205
|
+
};
|
|
1206
|
+
return __assign$2.apply(this, arguments);
|
|
1207
|
+
};
|
|
1208
|
+
var eventPropTypes = {
|
|
1209
|
+
onActivate: propTypesExports.func,
|
|
1210
|
+
onAddUndo: propTypesExports.func,
|
|
1211
|
+
onBeforeAddUndo: propTypesExports.func,
|
|
1212
|
+
onBeforeExecCommand: propTypesExports.func,
|
|
1213
|
+
onBeforeGetContent: propTypesExports.func,
|
|
1214
|
+
onBeforeRenderUI: propTypesExports.func,
|
|
1215
|
+
onBeforeSetContent: propTypesExports.func,
|
|
1216
|
+
onBeforePaste: propTypesExports.func,
|
|
1217
|
+
onBlur: propTypesExports.func,
|
|
1218
|
+
onChange: propTypesExports.func,
|
|
1219
|
+
onClearUndos: propTypesExports.func,
|
|
1220
|
+
onClick: propTypesExports.func,
|
|
1221
|
+
onContextMenu: propTypesExports.func,
|
|
1222
|
+
onCommentChange: propTypesExports.func,
|
|
1223
|
+
onCompositionEnd: propTypesExports.func,
|
|
1224
|
+
onCompositionStart: propTypesExports.func,
|
|
1225
|
+
onCompositionUpdate: propTypesExports.func,
|
|
1226
|
+
onCopy: propTypesExports.func,
|
|
1227
|
+
onCut: propTypesExports.func,
|
|
1228
|
+
onDblclick: propTypesExports.func,
|
|
1229
|
+
onDeactivate: propTypesExports.func,
|
|
1230
|
+
onDirty: propTypesExports.func,
|
|
1231
|
+
onDrag: propTypesExports.func,
|
|
1232
|
+
onDragDrop: propTypesExports.func,
|
|
1233
|
+
onDragEnd: propTypesExports.func,
|
|
1234
|
+
onDragGesture: propTypesExports.func,
|
|
1235
|
+
onDragOver: propTypesExports.func,
|
|
1236
|
+
onDrop: propTypesExports.func,
|
|
1237
|
+
onExecCommand: propTypesExports.func,
|
|
1238
|
+
onFocus: propTypesExports.func,
|
|
1239
|
+
onFocusIn: propTypesExports.func,
|
|
1240
|
+
onFocusOut: propTypesExports.func,
|
|
1241
|
+
onGetContent: propTypesExports.func,
|
|
1242
|
+
onHide: propTypesExports.func,
|
|
1243
|
+
onInit: propTypesExports.func,
|
|
1244
|
+
onInput: propTypesExports.func,
|
|
1245
|
+
onKeyDown: propTypesExports.func,
|
|
1246
|
+
onKeyPress: propTypesExports.func,
|
|
1247
|
+
onKeyUp: propTypesExports.func,
|
|
1248
|
+
onLoadContent: propTypesExports.func,
|
|
1249
|
+
onMouseDown: propTypesExports.func,
|
|
1250
|
+
onMouseEnter: propTypesExports.func,
|
|
1251
|
+
onMouseLeave: propTypesExports.func,
|
|
1252
|
+
onMouseMove: propTypesExports.func,
|
|
1253
|
+
onMouseOut: propTypesExports.func,
|
|
1254
|
+
onMouseOver: propTypesExports.func,
|
|
1255
|
+
onMouseUp: propTypesExports.func,
|
|
1256
|
+
onNodeChange: propTypesExports.func,
|
|
1257
|
+
onObjectResizeStart: propTypesExports.func,
|
|
1258
|
+
onObjectResized: propTypesExports.func,
|
|
1259
|
+
onObjectSelected: propTypesExports.func,
|
|
1260
|
+
onPaste: propTypesExports.func,
|
|
1261
|
+
onPostProcess: propTypesExports.func,
|
|
1262
|
+
onPostRender: propTypesExports.func,
|
|
1263
|
+
onPreProcess: propTypesExports.func,
|
|
1264
|
+
onProgressState: propTypesExports.func,
|
|
1265
|
+
onRedo: propTypesExports.func,
|
|
1266
|
+
onRemove: propTypesExports.func,
|
|
1267
|
+
onReset: propTypesExports.func,
|
|
1268
|
+
onSaveContent: propTypesExports.func,
|
|
1269
|
+
onSelectionChange: propTypesExports.func,
|
|
1270
|
+
onSetAttrib: propTypesExports.func,
|
|
1271
|
+
onSetContent: propTypesExports.func,
|
|
1272
|
+
onShow: propTypesExports.func,
|
|
1273
|
+
onSubmit: propTypesExports.func,
|
|
1274
|
+
onUndo: propTypesExports.func,
|
|
1275
|
+
onVisualAid: propTypesExports.func,
|
|
1276
|
+
onSkinLoadError: propTypesExports.func,
|
|
1277
|
+
onThemeLoadError: propTypesExports.func,
|
|
1278
|
+
onModelLoadError: propTypesExports.func,
|
|
1279
|
+
onPluginLoadError: propTypesExports.func,
|
|
1280
|
+
onIconsLoadError: propTypesExports.func,
|
|
1281
|
+
onLanguageLoadError: propTypesExports.func,
|
|
1282
|
+
onScriptsLoad: propTypesExports.func,
|
|
1283
|
+
onScriptsLoadError: propTypesExports.func,
|
|
1284
|
+
};
|
|
1285
|
+
var EditorPropTypes = __assign$2({ apiKey: propTypesExports.string, licenseKey: propTypesExports.string, id: propTypesExports.string, inline: propTypesExports.bool, init: propTypesExports.object, initialValue: propTypesExports.string, onEditorChange: propTypesExports.func, value: propTypesExports.string, tagName: propTypesExports.string, tabIndex: propTypesExports.number, cloudChannel: propTypesExports.string, plugins: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.array]), toolbar: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.array]), disabled: propTypesExports.bool, readonly: propTypesExports.bool, textareaName: propTypesExports.string, tinymceScriptSrc: propTypesExports.oneOfType([
|
|
1286
|
+
propTypesExports.string,
|
|
1287
|
+
propTypesExports.arrayOf(propTypesExports.string),
|
|
1288
|
+
propTypesExports.arrayOf(propTypesExports.shape({
|
|
1289
|
+
src: propTypesExports.string,
|
|
1290
|
+
async: propTypesExports.bool,
|
|
1291
|
+
defer: propTypesExports.bool
|
|
1292
|
+
}))
|
|
1293
|
+
]), rollback: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.oneOf([false])]), scriptLoading: propTypesExports.shape({
|
|
1294
|
+
async: propTypesExports.bool,
|
|
1295
|
+
defer: propTypesExports.bool,
|
|
1296
|
+
delay: propTypesExports.number
|
|
1297
|
+
}) }, eventPropTypes);
|
|
1298
|
+
|
|
1299
|
+
var getTinymce = function (view) {
|
|
1300
|
+
var global = view;
|
|
1301
|
+
return global && global.tinymce ? global.tinymce : null;
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
var isFunction = function (x) { return typeof x === 'function'; };
|
|
1305
|
+
var isEventProp = function (name) { return name in eventPropTypes; };
|
|
1306
|
+
var eventAttrToEventName = function (attrName) { return attrName.substr(2); };
|
|
1307
|
+
var configHandlers2 = function (handlerLookup, on, off, adapter, prevProps, props, boundHandlers) {
|
|
1308
|
+
var prevEventKeys = Object.keys(prevProps).filter(isEventProp);
|
|
1309
|
+
var currEventKeys = Object.keys(props).filter(isEventProp);
|
|
1310
|
+
var removedKeys = prevEventKeys.filter(function (key) { return props[key] === undefined; });
|
|
1311
|
+
var addedKeys = currEventKeys.filter(function (key) { return prevProps[key] === undefined; });
|
|
1312
|
+
removedKeys.forEach(function (key) {
|
|
1313
|
+
// remove event handler
|
|
1314
|
+
var eventName = eventAttrToEventName(key);
|
|
1315
|
+
var wrappedHandler = boundHandlers[eventName];
|
|
1316
|
+
off(eventName, wrappedHandler);
|
|
1317
|
+
delete boundHandlers[eventName];
|
|
1318
|
+
});
|
|
1319
|
+
addedKeys.forEach(function (key) {
|
|
1320
|
+
var wrappedHandler = adapter(handlerLookup, key);
|
|
1321
|
+
var eventName = eventAttrToEventName(key);
|
|
1322
|
+
boundHandlers[eventName] = wrappedHandler;
|
|
1323
|
+
on(eventName, wrappedHandler);
|
|
1324
|
+
});
|
|
1325
|
+
};
|
|
1326
|
+
var configHandlers = function (editor, prevProps, props, boundHandlers, lookup) {
|
|
1327
|
+
return configHandlers2(lookup, editor.on.bind(editor), editor.off.bind(editor),
|
|
1328
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1329
|
+
function (handlerLookup, key) { return function (e) { var _a; return (_a = handlerLookup(key)) === null || _a === void 0 ? void 0 : _a(e, editor); }; }, prevProps, props, boundHandlers);
|
|
1330
|
+
};
|
|
1331
|
+
var unique = 0;
|
|
1332
|
+
var uuid = function (prefix) {
|
|
1333
|
+
var time = Date.now();
|
|
1334
|
+
var random = Math.floor(Math.random() * 1000000000);
|
|
1335
|
+
unique++;
|
|
1336
|
+
return prefix + '_' + random + unique + String(time);
|
|
1337
|
+
};
|
|
1338
|
+
var isTextareaOrInput = function (element) {
|
|
1339
|
+
return element !== null && (element.tagName.toLowerCase() === 'textarea' || element.tagName.toLowerCase() === 'input');
|
|
1340
|
+
};
|
|
1341
|
+
var normalizePluginArray = function (plugins) {
|
|
1342
|
+
if (typeof plugins === 'undefined' || plugins === '') {
|
|
1343
|
+
return [];
|
|
1344
|
+
}
|
|
1345
|
+
return Array.isArray(plugins) ? plugins : plugins.split(' ');
|
|
1346
|
+
};
|
|
1347
|
+
// eslint-disable-next-line max-len
|
|
1348
|
+
var mergePlugins = function (initPlugins, inputPlugins) { return normalizePluginArray(initPlugins).concat(normalizePluginArray(inputPlugins)); };
|
|
1349
|
+
var isBeforeInputEventAvailable = function () { return window.InputEvent && typeof InputEvent.prototype.getTargetRanges === 'function'; };
|
|
1350
|
+
var isInDoc = function (elem) {
|
|
1351
|
+
if (!('isConnected' in Node.prototype)) {
|
|
1352
|
+
// Fallback for IE and old Edge
|
|
1353
|
+
var current = elem;
|
|
1354
|
+
var parent_1 = elem.parentNode;
|
|
1355
|
+
while (parent_1 != null) {
|
|
1356
|
+
current = parent_1;
|
|
1357
|
+
parent_1 = current.parentNode;
|
|
1358
|
+
}
|
|
1359
|
+
return current === elem.ownerDocument;
|
|
1360
|
+
}
|
|
1361
|
+
return elem.isConnected;
|
|
1362
|
+
};
|
|
1363
|
+
var setMode = function (editor, mode) {
|
|
1364
|
+
if (editor !== undefined) {
|
|
1365
|
+
if (editor.mode != null && typeof editor.mode === 'object' && typeof editor.mode.set === 'function') {
|
|
1366
|
+
editor.mode.set(mode);
|
|
1367
|
+
}
|
|
1368
|
+
else { // support TinyMCE 4
|
|
1369
|
+
editor.setMode(mode);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
var getTinymceOrError = function (view) {
|
|
1374
|
+
var tinymce = getTinymce(view);
|
|
1375
|
+
if (!tinymce) {
|
|
1376
|
+
throw new Error('tinymce should have been loaded into global scope');
|
|
1377
|
+
}
|
|
1378
|
+
return tinymce;
|
|
1379
|
+
};
|
|
1380
|
+
var isDisabledOptionSupported = function (editor) { return editor.options && editor.options.isRegistered('disabled'); };
|
|
1381
|
+
|
|
1382
|
+
var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
1383
|
+
__assign$1 = Object.assign || function(t) {
|
|
1384
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1385
|
+
s = arguments[i];
|
|
1386
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1387
|
+
t[p] = s[p];
|
|
1388
|
+
}
|
|
1389
|
+
return t;
|
|
1390
|
+
};
|
|
1391
|
+
return __assign$1.apply(this, arguments);
|
|
1392
|
+
};
|
|
1393
|
+
var injectScriptTag = function (doc, item, handler) {
|
|
1394
|
+
var _a, _b;
|
|
1395
|
+
var scriptTag = doc.createElement('script');
|
|
1396
|
+
scriptTag.referrerPolicy = 'origin';
|
|
1397
|
+
scriptTag.type = 'application/javascript';
|
|
1398
|
+
scriptTag.id = item.id;
|
|
1399
|
+
scriptTag.src = item.src;
|
|
1400
|
+
scriptTag.async = (_a = item.async) !== null && _a !== void 0 ? _a : false;
|
|
1401
|
+
scriptTag.defer = (_b = item.defer) !== null && _b !== void 0 ? _b : false;
|
|
1402
|
+
var loadHandler = function () {
|
|
1403
|
+
scriptTag.removeEventListener('load', loadHandler);
|
|
1404
|
+
scriptTag.removeEventListener('error', errorHandler);
|
|
1405
|
+
handler(item.src);
|
|
1406
|
+
};
|
|
1407
|
+
var errorHandler = function (err) {
|
|
1408
|
+
scriptTag.removeEventListener('load', loadHandler);
|
|
1409
|
+
scriptTag.removeEventListener('error', errorHandler);
|
|
1410
|
+
handler(item.src, err);
|
|
1411
|
+
};
|
|
1412
|
+
scriptTag.addEventListener('load', loadHandler);
|
|
1413
|
+
scriptTag.addEventListener('error', errorHandler);
|
|
1414
|
+
if (doc.head) {
|
|
1415
|
+
doc.head.appendChild(scriptTag);
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
var createDocumentScriptLoader = function (doc) {
|
|
1419
|
+
var lookup = {};
|
|
1420
|
+
var scriptLoadOrErrorHandler = function (src, err) {
|
|
1421
|
+
var item = lookup[src];
|
|
1422
|
+
item.done = true;
|
|
1423
|
+
item.error = err;
|
|
1424
|
+
for (var _i = 0, _a = item.handlers; _i < _a.length; _i++) {
|
|
1425
|
+
var h = _a[_i];
|
|
1426
|
+
h(src, err);
|
|
1427
|
+
}
|
|
1428
|
+
item.handlers = [];
|
|
1429
|
+
};
|
|
1430
|
+
var loadScripts = function (items, success, failure) {
|
|
1431
|
+
// eslint-disable-next-line no-console
|
|
1432
|
+
var failureOrLog = function (err) { return failure !== undefined ? failure(err) : console.error(err); };
|
|
1433
|
+
if (items.length === 0) {
|
|
1434
|
+
failureOrLog(new Error('At least one script must be provided'));
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
var successCount = 0;
|
|
1438
|
+
var failed = false;
|
|
1439
|
+
var loaded = function (_src, err) {
|
|
1440
|
+
if (failed) {
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
if (err) {
|
|
1444
|
+
failed = true;
|
|
1445
|
+
failureOrLog(err);
|
|
1446
|
+
}
|
|
1447
|
+
else if (++successCount === items.length) {
|
|
1448
|
+
success();
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
|
|
1452
|
+
var item = items_1[_i];
|
|
1453
|
+
var existing = lookup[item.src];
|
|
1454
|
+
if (existing) {
|
|
1455
|
+
if (existing.done) {
|
|
1456
|
+
loaded(item.src, existing.error);
|
|
1457
|
+
}
|
|
1458
|
+
else {
|
|
1459
|
+
existing.handlers.push(loaded);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
else {
|
|
1463
|
+
// create a new entry
|
|
1464
|
+
var id = uuid('tiny-');
|
|
1465
|
+
lookup[item.src] = {
|
|
1466
|
+
id: id,
|
|
1467
|
+
src: item.src,
|
|
1468
|
+
done: false,
|
|
1469
|
+
error: null,
|
|
1470
|
+
handlers: [loaded],
|
|
1471
|
+
};
|
|
1472
|
+
injectScriptTag(doc, __assign$1({ id: id }, item), scriptLoadOrErrorHandler);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
var deleteScripts = function () {
|
|
1477
|
+
var _a;
|
|
1478
|
+
for (var _i = 0, _b = Object.values(lookup); _i < _b.length; _i++) {
|
|
1479
|
+
var item = _b[_i];
|
|
1480
|
+
var scriptTag = doc.getElementById(item.id);
|
|
1481
|
+
if (scriptTag != null && scriptTag.tagName === 'SCRIPT') {
|
|
1482
|
+
(_a = scriptTag.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(scriptTag);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
lookup = {};
|
|
1486
|
+
};
|
|
1487
|
+
var getDocument = function () { return doc; };
|
|
1488
|
+
return {
|
|
1489
|
+
loadScripts: loadScripts,
|
|
1490
|
+
deleteScripts: deleteScripts,
|
|
1491
|
+
getDocument: getDocument
|
|
1492
|
+
};
|
|
1493
|
+
};
|
|
1494
|
+
var createScriptLoader = function () {
|
|
1495
|
+
var cache = [];
|
|
1496
|
+
var getDocumentScriptLoader = function (doc) {
|
|
1497
|
+
var loader = cache.find(function (l) { return l.getDocument() === doc; });
|
|
1498
|
+
if (loader === undefined) {
|
|
1499
|
+
loader = createDocumentScriptLoader(doc);
|
|
1500
|
+
cache.push(loader);
|
|
1501
|
+
}
|
|
1502
|
+
return loader;
|
|
1503
|
+
};
|
|
1504
|
+
var loadList = function (doc, items, delay, success, failure) {
|
|
1505
|
+
var doLoad = function () { return getDocumentScriptLoader(doc).loadScripts(items, success, failure); };
|
|
1506
|
+
if (delay > 0) {
|
|
1507
|
+
setTimeout(doLoad, delay);
|
|
1508
|
+
}
|
|
1509
|
+
else {
|
|
1510
|
+
doLoad();
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
var reinitialize = function () {
|
|
1514
|
+
for (var loader = cache.pop(); loader != null; loader = cache.pop()) {
|
|
1515
|
+
loader.deleteScripts();
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
return {
|
|
1519
|
+
loadList: loadList,
|
|
1520
|
+
reinitialize: reinitialize
|
|
1521
|
+
};
|
|
1522
|
+
};
|
|
1523
|
+
var ScriptLoader = createScriptLoader();
|
|
1524
|
+
|
|
1525
|
+
var __extends = (undefined && undefined.__extends) || (function () {
|
|
1526
|
+
var extendStatics = function (d, b) {
|
|
1527
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1528
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1529
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1530
|
+
return extendStatics(d, b);
|
|
1531
|
+
};
|
|
1532
|
+
return function (d, b) {
|
|
1533
|
+
if (typeof b !== "function" && b !== null)
|
|
1534
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1535
|
+
extendStatics(d, b);
|
|
1536
|
+
function __() { this.constructor = d; }
|
|
1537
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1538
|
+
};
|
|
1539
|
+
})();
|
|
1540
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
1541
|
+
__assign = Object.assign || function(t) {
|
|
1542
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1543
|
+
s = arguments[i];
|
|
1544
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1545
|
+
t[p] = s[p];
|
|
1546
|
+
}
|
|
1547
|
+
return t;
|
|
1548
|
+
};
|
|
1549
|
+
return __assign.apply(this, arguments);
|
|
1550
|
+
};
|
|
1551
|
+
var changeEvents = 'change keyup compositionend setcontent CommentChange';
|
|
1552
|
+
/**
|
|
1553
|
+
* @see {@link https://www.tiny.cloud/docs/tinymce/7/react-ref/ TinyMCE React Technical Reference}
|
|
1554
|
+
*/
|
|
1555
|
+
var Editor = /** @class */ (function (_super) {
|
|
1556
|
+
__extends(Editor, _super);
|
|
1557
|
+
function Editor(props) {
|
|
1558
|
+
var _a, _b, _c;
|
|
1559
|
+
var _this = _super.call(this, props) || this;
|
|
1560
|
+
_this.rollbackTimer = undefined;
|
|
1561
|
+
_this.valueCursor = undefined;
|
|
1562
|
+
_this.rollbackChange = function () {
|
|
1563
|
+
var editor = _this.editor;
|
|
1564
|
+
var value = _this.props.value;
|
|
1565
|
+
if (editor && value && value !== _this.currentContent) {
|
|
1566
|
+
editor.undoManager.ignore(function () {
|
|
1567
|
+
editor.setContent(value);
|
|
1568
|
+
// only restore cursor on inline editors when they are focused
|
|
1569
|
+
// as otherwise it will cause a focus grab
|
|
1570
|
+
if (_this.valueCursor && (!_this.inline || editor.hasFocus())) {
|
|
1571
|
+
try {
|
|
1572
|
+
editor.selection.moveToBookmark(_this.valueCursor);
|
|
1573
|
+
}
|
|
1574
|
+
catch (_e) { /* ignore */ }
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
_this.rollbackTimer = undefined;
|
|
1579
|
+
};
|
|
1580
|
+
_this.handleBeforeInput = function (_evt) {
|
|
1581
|
+
if (_this.props.value !== undefined && _this.props.value === _this.currentContent && _this.editor) {
|
|
1582
|
+
if (!_this.inline || _this.editor.hasFocus()) {
|
|
1583
|
+
try {
|
|
1584
|
+
// getBookmark throws exceptions when the editor has not been focused
|
|
1585
|
+
// possibly only in inline mode but I'm not taking chances
|
|
1586
|
+
_this.valueCursor = _this.editor.selection.getBookmark(3);
|
|
1587
|
+
}
|
|
1588
|
+
catch (_e) { /* ignore */ }
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
_this.handleBeforeInputSpecial = function (evt) {
|
|
1593
|
+
if (evt.key === 'Enter' || evt.key === 'Backspace' || evt.key === 'Delete') {
|
|
1594
|
+
_this.handleBeforeInput(evt);
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
_this.handleEditorChange = function (_evt) {
|
|
1598
|
+
var editor = _this.editor;
|
|
1599
|
+
if (editor && editor.initialized) {
|
|
1600
|
+
var newContent = editor.getContent();
|
|
1601
|
+
if (_this.props.value !== undefined && _this.props.value !== newContent && _this.props.rollback !== false) {
|
|
1602
|
+
// start a timer and revert to the value if not applied in time
|
|
1603
|
+
if (!_this.rollbackTimer) {
|
|
1604
|
+
_this.rollbackTimer = window.setTimeout(_this.rollbackChange, typeof _this.props.rollback === 'number' ? _this.props.rollback : 200);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
if (newContent !== _this.currentContent) {
|
|
1608
|
+
_this.currentContent = newContent;
|
|
1609
|
+
if (isFunction(_this.props.onEditorChange)) {
|
|
1610
|
+
_this.props.onEditorChange(newContent, editor);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
_this.handleEditorChangeSpecial = function (evt) {
|
|
1616
|
+
if (evt.key === 'Backspace' || evt.key === 'Delete') {
|
|
1617
|
+
_this.handleEditorChange(evt);
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
_this.initialise = function (attempts) {
|
|
1621
|
+
var _a, _b, _c;
|
|
1622
|
+
if (attempts === void 0) { attempts = 0; }
|
|
1623
|
+
var target = _this.elementRef.current;
|
|
1624
|
+
if (!target) {
|
|
1625
|
+
return; // Editor has been unmounted
|
|
1626
|
+
}
|
|
1627
|
+
if (!isInDoc(target)) {
|
|
1628
|
+
// this is probably someone trying to help by rendering us offscreen
|
|
1629
|
+
// but we can't do that because the editor iframe must be in the document
|
|
1630
|
+
// in order to have state
|
|
1631
|
+
if (attempts === 0) {
|
|
1632
|
+
// we probably just need to wait for the current events to be processed
|
|
1633
|
+
setTimeout(function () { return _this.initialise(1); }, 1);
|
|
1634
|
+
}
|
|
1635
|
+
else if (attempts < 100) {
|
|
1636
|
+
// wait for ten seconds, polling every tenth of a second
|
|
1637
|
+
setTimeout(function () { return _this.initialise(attempts + 1); }, 100);
|
|
1638
|
+
}
|
|
1639
|
+
else {
|
|
1640
|
+
// give up, at this point it seems that more polling is unlikely to help
|
|
1641
|
+
throw new Error('tinymce can only be initialised when in a document');
|
|
1642
|
+
}
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
var tinymce = getTinymceOrError(_this.view);
|
|
1646
|
+
var finalInit = __assign(__assign(__assign(__assign({}, _this.props.init), { selector: undefined, target: target, disabled: _this.props.disabled, readonly: _this.props.readonly, inline: _this.inline, plugins: mergePlugins((_a = _this.props.init) === null || _a === void 0 ? void 0 : _a.plugins, _this.props.plugins), toolbar: (_b = _this.props.toolbar) !== null && _b !== void 0 ? _b : (_c = _this.props.init) === null || _c === void 0 ? void 0 : _c.toolbar }), (_this.props.licenseKey ? { license_key: _this.props.licenseKey } : {})), { setup: function (editor) {
|
|
1647
|
+
_this.editor = editor;
|
|
1648
|
+
_this.bindHandlers({});
|
|
1649
|
+
// When running in inline mode the editor gets the initial value
|
|
1650
|
+
// from the innerHTML of the element it is initialized on.
|
|
1651
|
+
// However we don't want to take on the responsibility of sanitizing
|
|
1652
|
+
// to remove XSS in the react integration so we have a chicken and egg
|
|
1653
|
+
// problem... We avoid it by sneaking in a set content before the first
|
|
1654
|
+
// "official" setContent and using TinyMCE to do the sanitization.
|
|
1655
|
+
if (_this.inline && !isTextareaOrInput(target)) {
|
|
1656
|
+
editor.once('PostRender', function (_evt) {
|
|
1657
|
+
editor.setContent(_this.getInitialValue(), { no_events: true });
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
if (_this.props.init && isFunction(_this.props.init.setup)) {
|
|
1661
|
+
_this.props.init.setup(editor);
|
|
1662
|
+
}
|
|
1663
|
+
if (_this.props.disabled) {
|
|
1664
|
+
if (isDisabledOptionSupported(_this.editor)) {
|
|
1665
|
+
_this.editor.options.set('disabled', _this.props.disabled);
|
|
1666
|
+
}
|
|
1667
|
+
else {
|
|
1668
|
+
_this.editor.mode.set('readonly');
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
}, init_instance_callback: function (editor) {
|
|
1672
|
+
var _a;
|
|
1673
|
+
// check for changes that happened since tinymce.init() was called
|
|
1674
|
+
var initialValue = _this.getInitialValue();
|
|
1675
|
+
_this.currentContent = (_a = _this.currentContent) !== null && _a !== void 0 ? _a : editor.getContent();
|
|
1676
|
+
if (_this.currentContent !== initialValue) {
|
|
1677
|
+
_this.currentContent = initialValue;
|
|
1678
|
+
// same as resetContent in TinyMCE 5
|
|
1679
|
+
editor.setContent(initialValue);
|
|
1680
|
+
editor.undoManager.clear();
|
|
1681
|
+
editor.undoManager.add();
|
|
1682
|
+
editor.setDirty(false);
|
|
1683
|
+
}
|
|
1684
|
+
// ensure existing init_instance_callback is called
|
|
1685
|
+
if (_this.props.init && isFunction(_this.props.init.init_instance_callback)) {
|
|
1686
|
+
_this.props.init.init_instance_callback(editor);
|
|
1687
|
+
}
|
|
1688
|
+
} });
|
|
1689
|
+
if (!_this.inline) {
|
|
1690
|
+
target.style.visibility = '';
|
|
1691
|
+
}
|
|
1692
|
+
if (isTextareaOrInput(target)) {
|
|
1693
|
+
target.value = _this.getInitialValue();
|
|
1694
|
+
}
|
|
1695
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1696
|
+
tinymce.init(finalInit);
|
|
1697
|
+
};
|
|
1698
|
+
_this.id = _this.props.id || uuid('tiny-react');
|
|
1699
|
+
_this.elementRef = React.createRef();
|
|
1700
|
+
_this.inline = (_c = (_a = _this.props.inline) !== null && _a !== void 0 ? _a : (_b = _this.props.init) === null || _b === void 0 ? void 0 : _b.inline) !== null && _c !== void 0 ? _c : false;
|
|
1701
|
+
_this.boundHandlers = {};
|
|
1702
|
+
return _this;
|
|
1703
|
+
}
|
|
1704
|
+
Object.defineProperty(Editor.prototype, "view", {
|
|
1705
|
+
get: function () {
|
|
1706
|
+
var _a, _b;
|
|
1707
|
+
return (_b = (_a = this.elementRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.defaultView) !== null && _b !== void 0 ? _b : window;
|
|
1708
|
+
},
|
|
1709
|
+
enumerable: false,
|
|
1710
|
+
configurable: true
|
|
1711
|
+
});
|
|
1712
|
+
Editor.prototype.componentDidUpdate = function (prevProps) {
|
|
1713
|
+
var _this = this;
|
|
1714
|
+
var _a, _b;
|
|
1715
|
+
if (this.rollbackTimer) {
|
|
1716
|
+
clearTimeout(this.rollbackTimer);
|
|
1717
|
+
this.rollbackTimer = undefined;
|
|
1718
|
+
}
|
|
1719
|
+
if (this.editor) {
|
|
1720
|
+
this.bindHandlers(prevProps);
|
|
1721
|
+
if (this.editor.initialized) {
|
|
1722
|
+
this.currentContent = (_a = this.currentContent) !== null && _a !== void 0 ? _a : this.editor.getContent();
|
|
1723
|
+
if (typeof this.props.initialValue === 'string' && this.props.initialValue !== prevProps.initialValue) {
|
|
1724
|
+
// same as resetContent in TinyMCE 5
|
|
1725
|
+
this.editor.setContent(this.props.initialValue);
|
|
1726
|
+
this.editor.undoManager.clear();
|
|
1727
|
+
this.editor.undoManager.add();
|
|
1728
|
+
this.editor.setDirty(false);
|
|
1729
|
+
}
|
|
1730
|
+
else if (typeof this.props.value === 'string' && this.props.value !== this.currentContent) {
|
|
1731
|
+
var localEditor_1 = this.editor;
|
|
1732
|
+
localEditor_1.undoManager.transact(function () {
|
|
1733
|
+
// inline editors grab focus when restoring selection
|
|
1734
|
+
// so we don't try to keep their selection unless they are currently focused
|
|
1735
|
+
var cursor;
|
|
1736
|
+
if (!_this.inline || localEditor_1.hasFocus()) {
|
|
1737
|
+
try {
|
|
1738
|
+
// getBookmark throws exceptions when the editor has not been focused
|
|
1739
|
+
// possibly only in inline mode but I'm not taking chances
|
|
1740
|
+
cursor = localEditor_1.selection.getBookmark(3);
|
|
1741
|
+
}
|
|
1742
|
+
catch (_e) { /* ignore */ }
|
|
1743
|
+
}
|
|
1744
|
+
var valueCursor = _this.valueCursor;
|
|
1745
|
+
localEditor_1.setContent(_this.props.value);
|
|
1746
|
+
if (!_this.inline || localEditor_1.hasFocus()) {
|
|
1747
|
+
for (var _i = 0, _a = [cursor, valueCursor]; _i < _a.length; _i++) {
|
|
1748
|
+
var bookmark = _a[_i];
|
|
1749
|
+
if (bookmark) {
|
|
1750
|
+
try {
|
|
1751
|
+
localEditor_1.selection.moveToBookmark(bookmark);
|
|
1752
|
+
_this.valueCursor = bookmark;
|
|
1753
|
+
break;
|
|
1754
|
+
}
|
|
1755
|
+
catch (_e) { /* ignore */ }
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
if (this.props.readonly !== prevProps.readonly) {
|
|
1762
|
+
var readonly = (_b = this.props.readonly) !== null && _b !== void 0 ? _b : false;
|
|
1763
|
+
setMode(this.editor, readonly ? 'readonly' : 'design');
|
|
1764
|
+
}
|
|
1765
|
+
if (this.props.disabled !== prevProps.disabled) {
|
|
1766
|
+
if (isDisabledOptionSupported(this.editor)) {
|
|
1767
|
+
this.editor.options.set('disabled', this.props.disabled);
|
|
1768
|
+
}
|
|
1769
|
+
else {
|
|
1770
|
+
setMode(this.editor, this.props.disabled ? 'readonly' : 'design');
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
Editor.prototype.componentDidMount = function () {
|
|
1777
|
+
var _this = this;
|
|
1778
|
+
var _a, _b, _c, _d, _f;
|
|
1779
|
+
if (getTinymce(this.view) !== null) {
|
|
1780
|
+
this.initialise();
|
|
1781
|
+
}
|
|
1782
|
+
else if (Array.isArray(this.props.tinymceScriptSrc) && this.props.tinymceScriptSrc.length === 0) {
|
|
1783
|
+
(_b = (_a = this.props).onScriptsLoadError) === null || _b === void 0 ? void 0 : _b.call(_a, new Error('No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.'));
|
|
1784
|
+
}
|
|
1785
|
+
else if ((_c = this.elementRef.current) === null || _c === void 0 ? void 0 : _c.ownerDocument) {
|
|
1786
|
+
var successHandler = function () {
|
|
1787
|
+
var _a, _b;
|
|
1788
|
+
(_b = (_a = _this.props).onScriptsLoad) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1789
|
+
_this.initialise();
|
|
1790
|
+
};
|
|
1791
|
+
var errorHandler = function (err) {
|
|
1792
|
+
var _a, _b;
|
|
1793
|
+
(_b = (_a = _this.props).onScriptsLoadError) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
1794
|
+
};
|
|
1795
|
+
ScriptLoader.loadList(this.elementRef.current.ownerDocument, this.getScriptSources(), (_f = (_d = this.props.scriptLoading) === null || _d === void 0 ? void 0 : _d.delay) !== null && _f !== void 0 ? _f : 0, successHandler, errorHandler);
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
Editor.prototype.componentWillUnmount = function () {
|
|
1799
|
+
var _this = this;
|
|
1800
|
+
var editor = this.editor;
|
|
1801
|
+
if (editor) {
|
|
1802
|
+
editor.off(changeEvents, this.handleEditorChange);
|
|
1803
|
+
editor.off(this.beforeInputEvent(), this.handleBeforeInput);
|
|
1804
|
+
editor.off('keypress', this.handleEditorChangeSpecial);
|
|
1805
|
+
editor.off('keydown', this.handleBeforeInputSpecial);
|
|
1806
|
+
editor.off('NewBlock', this.handleEditorChange);
|
|
1807
|
+
Object.keys(this.boundHandlers).forEach(function (eventName) {
|
|
1808
|
+
editor.off(eventName, _this.boundHandlers[eventName]);
|
|
1809
|
+
});
|
|
1810
|
+
this.boundHandlers = {};
|
|
1811
|
+
editor.remove();
|
|
1812
|
+
this.editor = undefined;
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
Editor.prototype.render = function () {
|
|
1816
|
+
return this.inline ? this.renderInline() : this.renderIframe();
|
|
1817
|
+
};
|
|
1818
|
+
Editor.prototype.beforeInputEvent = function () {
|
|
1819
|
+
return isBeforeInputEventAvailable() ? 'beforeinput SelectionChange' : 'SelectionChange';
|
|
1820
|
+
};
|
|
1821
|
+
Editor.prototype.renderInline = function () {
|
|
1822
|
+
var _a = this.props.tagName, tagName = _a === void 0 ? 'div' : _a;
|
|
1823
|
+
return React.createElement(tagName, {
|
|
1824
|
+
ref: this.elementRef,
|
|
1825
|
+
id: this.id,
|
|
1826
|
+
tabIndex: this.props.tabIndex
|
|
1827
|
+
});
|
|
1828
|
+
};
|
|
1829
|
+
Editor.prototype.renderIframe = function () {
|
|
1830
|
+
return React.createElement('textarea', {
|
|
1831
|
+
ref: this.elementRef,
|
|
1832
|
+
style: { visibility: 'hidden' },
|
|
1833
|
+
name: this.props.textareaName,
|
|
1834
|
+
id: this.id,
|
|
1835
|
+
tabIndex: this.props.tabIndex
|
|
1836
|
+
});
|
|
1837
|
+
};
|
|
1838
|
+
Editor.prototype.getScriptSources = function () {
|
|
1839
|
+
var _a, _b;
|
|
1840
|
+
var async = (_a = this.props.scriptLoading) === null || _a === void 0 ? void 0 : _a.async;
|
|
1841
|
+
var defer = (_b = this.props.scriptLoading) === null || _b === void 0 ? void 0 : _b.defer;
|
|
1842
|
+
if (this.props.tinymceScriptSrc !== undefined) {
|
|
1843
|
+
if (typeof this.props.tinymceScriptSrc === 'string') {
|
|
1844
|
+
return [{ src: this.props.tinymceScriptSrc, async: async, defer: defer }];
|
|
1845
|
+
}
|
|
1846
|
+
// multiple scripts can be specified which allows for hybrid mode
|
|
1847
|
+
return this.props.tinymceScriptSrc.map(function (item) {
|
|
1848
|
+
if (typeof item === 'string') {
|
|
1849
|
+
// async does not make sense for multiple items unless
|
|
1850
|
+
// they are not dependent (which will be unlikely)
|
|
1851
|
+
return { src: item, async: async, defer: defer };
|
|
1852
|
+
}
|
|
1853
|
+
else {
|
|
1854
|
+
return item;
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
// fallback to the cloud when the tinymceScriptSrc is not specified
|
|
1859
|
+
var channel = this.props.cloudChannel; // `cloudChannel` is in `defaultProps`, so it's always defined.
|
|
1860
|
+
var apiKey = this.props.apiKey ? this.props.apiKey : 'no-api-key';
|
|
1861
|
+
var cloudTinyJs = "https://cdn.tiny.cloud/1/".concat(apiKey, "/tinymce/").concat(channel, "/tinymce.min.js");
|
|
1862
|
+
return [{ src: cloudTinyJs, async: async, defer: defer }];
|
|
1863
|
+
};
|
|
1864
|
+
Editor.prototype.getInitialValue = function () {
|
|
1865
|
+
if (typeof this.props.initialValue === 'string') {
|
|
1866
|
+
return this.props.initialValue;
|
|
1867
|
+
}
|
|
1868
|
+
else if (typeof this.props.value === 'string') {
|
|
1869
|
+
return this.props.value;
|
|
1870
|
+
}
|
|
1871
|
+
else {
|
|
1872
|
+
return '';
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
Editor.prototype.bindHandlers = function (prevProps) {
|
|
1876
|
+
var _this = this;
|
|
1877
|
+
if (this.editor !== undefined) {
|
|
1878
|
+
// typescript chokes trying to understand the type of the lookup function
|
|
1879
|
+
configHandlers(this.editor, prevProps, this.props, this.boundHandlers, function (key) { return _this.props[key]; });
|
|
1880
|
+
// check if we should monitor editor changes
|
|
1881
|
+
var isValueControlled = function (p) { return p.onEditorChange !== undefined || p.value !== undefined; };
|
|
1882
|
+
var wasControlled = isValueControlled(prevProps);
|
|
1883
|
+
var nowControlled = isValueControlled(this.props);
|
|
1884
|
+
if (!wasControlled && nowControlled) {
|
|
1885
|
+
this.editor.on(changeEvents, this.handleEditorChange);
|
|
1886
|
+
this.editor.on(this.beforeInputEvent(), this.handleBeforeInput);
|
|
1887
|
+
this.editor.on('keydown', this.handleBeforeInputSpecial);
|
|
1888
|
+
this.editor.on('keyup', this.handleEditorChangeSpecial);
|
|
1889
|
+
this.editor.on('NewBlock', this.handleEditorChange);
|
|
1890
|
+
}
|
|
1891
|
+
else if (wasControlled && !nowControlled) {
|
|
1892
|
+
this.editor.off(changeEvents, this.handleEditorChange);
|
|
1893
|
+
this.editor.off(this.beforeInputEvent(), this.handleBeforeInput);
|
|
1894
|
+
this.editor.off('keydown', this.handleBeforeInputSpecial);
|
|
1895
|
+
this.editor.off('keyup', this.handleEditorChangeSpecial);
|
|
1896
|
+
this.editor.off('NewBlock', this.handleEditorChange);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
Editor.propTypes = EditorPropTypes;
|
|
1901
|
+
Editor.defaultProps = {
|
|
1902
|
+
cloudChannel: '7',
|
|
1903
|
+
};
|
|
1904
|
+
return Editor;
|
|
1905
|
+
}(React.Component));
|
|
1906
|
+
|
|
1907
|
+
const TinyMCE = (props) => {
|
|
1908
|
+
//! State
|
|
1909
|
+
const {
|
|
1910
|
+
height,
|
|
1911
|
+
openHidenMenubar,
|
|
1912
|
+
field,
|
|
1913
|
+
formState,
|
|
1914
|
+
label,
|
|
1915
|
+
required,
|
|
1916
|
+
text_patterns,
|
|
1917
|
+
...restProps
|
|
1918
|
+
} = props;
|
|
1919
|
+
const { name, value, onChange } = field || {};
|
|
1920
|
+
const { touchedFields, errors, isSubmitted } = formState || {};
|
|
1921
|
+
const isTouched = get(touchedFields, name);
|
|
1922
|
+
const errorMessage = get(errors, name)?.message;
|
|
1923
|
+
//! Function
|
|
1924
|
+
const renderErrorMessage = () => {
|
|
1925
|
+
if (!errorMessage) return null;
|
|
1926
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1927
|
+
ErrorMessage,
|
|
1928
|
+
{
|
|
1929
|
+
errorMessage,
|
|
1930
|
+
isTouched,
|
|
1931
|
+
isSubmitted
|
|
1932
|
+
}
|
|
1933
|
+
);
|
|
1934
|
+
};
|
|
1935
|
+
//! Render
|
|
1936
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1937
|
+
label && /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { label, required }),
|
|
1938
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1939
|
+
Editor,
|
|
1940
|
+
{
|
|
1941
|
+
value,
|
|
1942
|
+
tinymceScriptSrc: "https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.3/tinymce.min.js",
|
|
1943
|
+
apiKey: TINY_API,
|
|
1944
|
+
init: {
|
|
1945
|
+
height: height || 200,
|
|
1946
|
+
plugins: ["link", "image", "code", "advlist", "lists"],
|
|
1947
|
+
menubar: openHidenMenubar,
|
|
1948
|
+
toolbar: false,
|
|
1949
|
+
inline_styles: true,
|
|
1950
|
+
promotion: false,
|
|
1951
|
+
content_style: `
|
|
1952
|
+
body, span, p, div, h1, h2, h3, h4, h5, h6, li, td, th, a {
|
|
1953
|
+
font-family: 'Times New Roman', Times, serif !important;
|
|
1954
|
+
font-size: 14px !important;
|
|
1955
|
+
}
|
|
1956
|
+
`,
|
|
1957
|
+
// Apply font-family and font-size to all elements
|
|
1958
|
+
...text_patterns ? { text_patterns } : {}
|
|
1959
|
+
},
|
|
1960
|
+
onEditorChange: onChange,
|
|
1961
|
+
...restProps
|
|
1962
|
+
}
|
|
1963
|
+
),
|
|
1964
|
+
renderErrorMessage()
|
|
1965
|
+
] });
|
|
1966
|
+
};
|
|
1967
|
+
TinyMCE.displayName = "TinyMCE";
|
|
1968
|
+
|
|
1969
|
+
export { TinyMCE };
|