@grapecity/wijmo.react.base 5.20241.9 → 5.20242.21
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/es2015-commonjs.js +2 -2
- package/es2015-esm.js +2 -2
- package/es5-esm.js +2 -2
- package/index.d.ts +108 -66
- package/index.js +2 -2
- package/package.json +2 -2
package/es2015-commonjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20242.21
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function fulfilled(t){try{step(n.next(t))}catch(t){s(t)}}function rejected(t){try{step(n.throw(t))}catch(t){s(t)}}function step(t){t.done?o(t.value):new i((function(e){e(t.value)})).then(fulfilled,rejected)}step((n=n.apply(t,e||[])).next())}))},__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@grapecity/wijmo"),ReactDOM=__importStar(require("react-dom")),React=__importStar(require("react")),flushSyncPolyfill=t=>{t()},createRootPolyfill=()=>{throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill};let reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function*(){try{const t=require("react-dom/client");reactDomClient=t||ReactDOM||ReactDomPolyfill;flushSync=t.flushSync||flushSync}catch(t){reactDomClient=ReactDOM||ReactDomPolyfill}}))}class ComponentBase extends React.Component{constructor(t,e,i){super(t);this._objPropHash={};this._isMounted=!1;this._mountedCBs=[];this._hostRef=t=>this._hostRefValue=t;this._beforeRender=new wijmo_1.Event;this._afterRender=new wijmo_1.Event;this._beforeWillUnmount=new wijmo_1.Event;this._afterWillUnmount=new wijmo_1.Event;this._beforeDidUpdate=new wijmo_1.Event;this._afterDidUpdate=new wijmo_1.Event;if(this._isMounted&&!this._isChild()){clearTimeout(this.timer);return this}if(!ComponentBase._reactMajorVersion){const t=parseInt(React.version);ComponentBase._reactMajorVersion=t;t>=18&&lazyImportDomClient()}this.props=t;this.controlType=e;for(let t of i&&i.objectProps||[])this._objPropHash[t]=!0}render(){this._onBeforeRender();const t=this._renderImpl();this._onAfterRender();this.renderResult=t;if(this._isMounted&&!this._isChild()){clearTimeout(this.timer);return this.renderResult}return t}componentDidMount(){if(this._isMounted){clearTimeout(this.timer);return this.control}if(this._isChild()){let t=this.props[ComponentBase._propsParent];t&&t._mountedCB(()=>{this._setParent(t)})}else this._prepareControl();this._isMounted=!0;return this.control}static selectiveDomRender(t,e,i=!0){if(ComponentBase._reactMajorVersion<18)ReactDOM.render(t,e);else{const i=ComponentBase.elemRootMap.findIndex(t=>t.host===e);let n;if(-1===i){n=reactDomClient.createRoot(e);ComponentBase.elemRootMap.push({host:e,root:n})}else n=ComponentBase.elemRootMap[i].root;flushSync(()=>{n.render(t)})}return e}static selectiveDomUnmount(t){if(ComponentBase._reactMajorVersion<18)ReactDOM.unmountComponentAtNode(t);else{const e=ComponentBase.elemRootMap.findIndex(e=>e.host===t);if(-1!==e){const t=ComponentBase.elemRootMap[e].root;flushSync(()=>{t.unmount();ComponentBase.elemRootMap.splice(e,1)})}}}componentWillUnmount(){this._onBeforeWillUnmount();this._siblingInsertedMO&&this._siblingInsertedMO.disconnect();let t=this.control;if(t)if(this._isChild()){let e=this._getParentProp();if(e){let i=this.parent.control[e];if(wijmo_1.isArray(i)){let e=i.indexOf(t);if(e>-1){const t=i[e];"Sheet"===t.constructor.name&&t._isEmptyGrid||i.splice(e,1)}}}}else t instanceof wijmo_1.Control&&(this.timer=setTimeout(()=>{if(t.hostElement){t._orgOuter=null;t.dispose()}},5));this._onAfterWillUnmount()}shouldComponentUpdate(t){return!0}componentDidUpdate(t){this._onBeforeDidUpdate();var e=this.control;this._copy(e,this.props,t);this._onAfterDidUpdate()}_mountedCB(t){this._isMounted&&!this._isChild()?t():this._isMounted||this._mountedCBs.push(t);setTimeout(()=>{this._mountedCBs.includes(t)||this._mountedCBs.push(t)},wijmo_1.isSafari?200:10)}_renderImpl(){let t={};t[ComponentBase._propsParent]=this;let e=React.Children.map(this.props.children,e=>e&&React.cloneElement(e,t));const i={ref:this._hostRef};this._isChild()&&(i.style={display:"none"});return React.createElement("div",i,e)}_onBeforeRender(t){this._beforeRender.raise(this,t)}_onAfterRender(t){this._afterRender.raise(this,t)}_onBeforeWillUnmount(t){this._beforeWillUnmount.raise(this,t)}_onAfterWillUnmount(t){this._afterWillUnmount.raise(this,t)}_onBeforeDidUpdate(t){this._beforeDidUpdate.raise(this,t)}_onAfterDidUpdate(t){this._afterDidUpdate.raise(this,t)}_createControl(){const t=this._isChild()?this._isParentInCtor()?this.parent.control:void 0:this._getElement();t instanceof Element&&this.props.id&&t.setAttribute("id",this.props.id);const e=new this.controlType(t);e.workingAs="React";return e}_prepareControl(){this._renderImpl();let t=this._getElement(),e=this.props;t&&!this._isChild()&&ComponentBase._copyAttrs(t,e,wijmo_1.Control._rxInputAtts);let i=this.control=this._createControl(),n=i instanceof wijmo_1.Control,o=ComponentBase;t=this._getElement();if(!this._siblingId){null==this.constructor[o._typeSiblingIdProp]&&(this.constructor[o._typeSiblingIdProp]=++o._siblingDirId+"");this._siblingId=this.constructor[o._typeSiblingIdProp]}if(t){t.setAttribute(o._typeSiblingIdProp,this._siblingId);var s={};for(var r in e){let n=e[r];this._ignoreProp(r)||wijmo_1.isUndefined(n)||(r in i?s[r]=n:this._setHostAttribute(t,r,n))}n?i.initialize(s):this._copy(i,s,null,!0);setTimeout(()=>{let t=this._mountedCBs;for(let e in t){t[e]();delete t[e]}wijmo_1.isFunction(e.initialized)&&e.initialized(i);this._isMounted=!0},wijmo_1.isSafari?201:100)}}_initParent(){if(!this._getElement())return;let t=this._getParentProp();if(t){let e=this.parent.control,i=e[t];if(wijmo_1.isArray(i)){let t=this._getSiblingIndex();(t<0||t>=i.length)&&(t=i.length);i.splice(t,0,this.control);const e=this._getElement();this._siblingInsertedMO=new MutationObserver(this._siblingInserted.bind(this));this._siblingInsertedMO.observe(e,{childList:!0})}else e[t]=this.control}}_setParent(t){if(t!==this.parent){if(this.parent)throw"Wijmo child component is already attached to a different parent.";this.parent=t;this._prepareControl();this._initParent()}}_isChild(){return null!=this._parentProp||null!=this._parentInCtor}_isParentInCtor(){return!0===this._parentInCtor}_getParentProp(){return this.props.wjProperty||this._parentProp}_getSiblingIndex(){var t=this._getElement(),e=t.parentElement;if(!e)return-1;for(var i=e.childNodes,n=-1,o=this._siblingId,s=0;s<i.length;s++){var r=i[s];if(1==r.nodeType&&r.getAttribute(ComponentBase._typeSiblingIdProp)==o){++n;if(r===t)return n}}return-1}_siblingInserted(t){for(let e of t)if("childList"===e.type&&e.addedNodes.length>0){if(Array.from(e.addedNodes).some(t=>t===this._getElement())){const t=this._getSiblingIndex(),e=this.control,i=this.parent.control[this._getParentProp()],n=i.indexOf(e);if(t>=0&&n>=0&&t!==n){i.splice(n,1);const o=Math.min(t,i.length);i.splice(o,0,e)}}}}_copy(t,e,i,n=!1){if(!t||!e)return;let o,s=t===this.control;for(var r in e)if(!this._ignoreProp(r)||!s){var l=e[r];if(r in t){if(this._isEvent(t,r))n&&wijmo_1.isFunction(l)&&t[r].addHandler(l);else if(!i||!this._sameValue(i[r],l))if(null==l)t[r]=l;else if(wijmo_1.isPrimitive(l)||wijmo_1.isFunction(l)||this._objPropHash[r]&&t===(o||(o=this.control)))t[r]=l;else if(wijmo_1.isArray(l)&&wijmo_1.isArray(t[r])){let e=t[r],i=l;if(i.length==e.length)for(var a=0;a<i.length;a++){if(i[a]!==e[a])return!1;this._copy(e[a],i[a])}}else wijmo_1.isObject(l)&&this._copy(t[r],e[r])}else this._setHostAttribute(t.hostElement,r,e[r])}}_setHostAttribute(t,e,i){if(t)switch(e){case"className":const n=this._appliedClassName;if(n!==i){wijmo_1.removeClass(t,n);wijmo_1.addClass(t,i);this._appliedClassName=i}break;case"style":wijmo_1.setCss(t,i);break;default:null!=t[e]?t[e]=i:"string"==typeof i&&"$"!==e[0]&&t.setAttribute(e,i)}}_sameValue(t,e){return t==e||wijmo_1.DateTime.equals(t,e)}_isEvent(t,e){let i=t&&t[e];return null!=i&&i instanceof wijmo_1.Event}_getElement(){return this._hostRefValue}_ignoreProp(t){return"children"===t}static _copyAttrs(t,e,i){if(t)for(let n in e)n.match(i)&&t.setAttribute(n,e[n])}static isInStrictMode(t){return!!(t.hasOwnProperty("_reactInternalFiber")&&1&t._reactInternalFiber.mode)}}ComponentBase._propsParent="$parent";ComponentBase._typeSiblingIdProp="_wjSiblingIdProp";ComponentBase._siblingDirId=0;ComponentBase.elemRootMap=[];exports.ComponentBase=ComponentBase;
|
|
14
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function fulfilled(e){try{step(r.next(e))}catch(e){s(e)}}function rejected(e){try{step(r.throw(e))}catch(e){s(e)}}function step(e){e.done?o(e.value):new n((function(t){t(e.value)})).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))},__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@grapecity/wijmo"),ReactDOM=__importStar(require("react-dom")),React=__importStar(require("react")),flushSyncPolyfill=e=>{e()},createRootPolyfill=()=>{throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill};let reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function*(){try{const e=require("react-dom/client");reactDomClient=e||ReactDOM||ReactDomPolyfill;flushSync=e.flushSync||flushSync}catch(e){reactDomClient=ReactDOM||ReactDomPolyfill}}))}let _oldSyncBehavior=!0;function strictStateMode(e=!1){e==_oldSyncBehavior&&(_oldSyncBehavior=!wijmo_1.asBoolean(e,!1))}exports.strictStateMode=strictStateMode;exports.ControlBaseMeta={inputs:["isDisabled","tabOrder"],events:["gotFocus","invalidInput","lostFocus","refreshed","refreshing"]};const alwaysClearProps=new Set(["columns","columnGroups"]),unsuppressedChangedEventProps=new Set(["panes","columnGroups","columns","items"]),specialProps=new Set(["initialized","wjItemTemplate"]);function updateChildProperties(e,t){const n=e.controlRef.current,r={},o={};if(t){const s=wijmo_1.isArray(t)?t.flat(1/0):[t],c=[];let i=0;const l=new Set;for(let e of s){if(e&&e.type&&e.type.$$typeof==Symbol.for("react.forward_ref")){c.push(e.type.render(e.props,e.ref));c[c.length-1].$index=i;c[c.length-1].$key=e.key}else if(e&&wijmo_1.isFunction(e.type)){c.push(e.type(e.props));c[c.length-1].$index=i;c[c.length-1].$key=e.key}e||l.add(i);i++}const a=[];for(let e of c)if(e.assignedToParent){if(e.wjProperty){e.parentProp=wijmo_1.asString(e.wjProperty);e.isParentPropArray=n[e.parentProp]&&wijmo_1.isArray(n[e.parentProp])}e.isParentPropArray&&!r[e.parentProp]&&(r[e.parentProp]=[]);e.isParentPropArray?r[e.parentProp].push({getInstance:e.getInstance,props:e.props,$key:e.$key,$index:e.$index}):r[e.parentProp]={getInstance:e.getInstance,props:e.props}}else a.push(e);const u=e.childInfo;for(let e in r)if(wijmo_1.isArray(r[e])){let t=!1;if(n[e]&&null!=n[e]._updating&&!unsuppressedChangedEventProps.has(e)){n[e]._updating++;t=!0}let s=u[e];o[e]=[];if(!u[e]){s=[];n[e]&&n[e].clear?n[e].clear():n[e]||(n[e]=new wijmo_1.ObservableArray)}!_oldSyncBehavior&&alwaysClearProps.has(e)&&n[e]&&n[e].clear&&n[e].clear();if(_oldSyncBehavior)for(let t=s.length-1;t>=0;t--)if(l.has(s[t].$index)){n[e].remove(s[t].instance);s.splice(t,1)}const c=[],i={};for(let e of s)null!=e.$key?i[""+e.$key]=e:c.push(e);let a=0;const getExistingInstance=(e=null)=>{if(null!=e){let t=i[e];null!=t&&delete i[e];return t}return c[a++]};for(let t=0;t<r[e].length;t++){let s=getExistingInstance(r[e][t].$key),c=!1;if(s)s.updateProps(r[e][t].props);else{s=r[e][t].getInstance(n);c=!0}s.$index=r[e][t].$index;s.$key=r[e][t].$key;(!_oldSyncBehavior&&alwaysClearProps.has(e)||c)&&(n[e].length==t?n[e].push(s.instance):n[e].splice(t,0,s.instance));o[e].push(s)}for(let t of Object.keys(i))n[e].remove(i[t].instance);for(;!_oldSyncBehavior&&n[e].length>o[e].length;)n[e].pop();if(t){n[e]._updating--;u[e]&&u[e].length==r[e].length||n[e]._raiseCollectionChanged&&n[e]._raiseCollectionChanged()}}else{let t=u[e];if(t)t.updateProps(r[e].props);else{t=r[e].getInstance(n);n[e]=t.instance}o[e]=t}const p=[];for(let e of u.$_nonassignable||[])l.has(e.$index)?e.instance&&e.instance.dispose&&wijmo_1.isFunction(e.instance.dispose)&&e.instance.dispose():p.push(e);const f=[];let d=0;for(;d<a.length;d++){let e=p[d];e?e.updateProps(a[d].props):e=a[d].getInstance(n);e.$index=a[d].$index;f.push(e)}o.$_nonassignable=f;for(;d<p.length;d++)p[d].instance&&p[d].instance.dispose&&wijmo_1.isFunction(p[d].instance.dispose)&&p[d].instance.dispose()}if(_oldSyncBehavior)for(let t of Object.keys(e.childInfo))if(wijmo_1.isArray(e.childInfo[t])&&!r[t]&&n[t]&&n[t].remove)for(let r of e.childInfo[t])n[t].remove(r.instance);return o}function getPropsAccordingToSyncMode(e,t,n=null){if(!t||!_oldSyncBehavior){return Object.assign({},e)}let r={};for(let o in e){let s=!1;n&&(s=n.knowProperties.has(o)||n.knowEvents.has(o)||n.knowCustomProps.has(o));(n&&!s||e[o]!==t[o])&&(r[o]=e[o])}return r}function useWjComponentBase(e){const t=React.useRef({}),n=React.useRef(),r=React.useRef(),o=React.useRef(),s=React.useRef(),c=React.useRef({}),i=React.useRef(!1);e.customProps||(e.customProps={});if(!n.current){n.current={};n.current.knowProperties=new Set(e.properties);n.current.knowEvents=new Set(e.events);n.current.knowCustomProps=new Set(Object.keys(e.customProps))}let l=e.props;if(s.current){l=getPropsAccordingToSyncMode(e.props,t.current,n.current);t.current=e.props}const a={},u={},p={},f={},d=e.ref||null;for(let t in l)if(n.current.knowProperties.has(t))a[t]=l[t];else if(n.current.knowEvents.has(t)){u[t]=l[t];a[t]=l[t]}else e.customProps[t]?f[t]=l[t]:specialProps.has(t)||(p[t]=l[t]);if(s.current&&_oldSyncBehavior)for(let e in u)delete a[e];const updateProps=()=>{d&&d.current&&(d.current.props=e.props);updateChildProps();let t=[],n=a;if(o.current&&s.current&&!_oldSyncBehavior){for(let e in o.current)if(s.current[e]){if(s.current[e]._handlersChanged){s.current[e]._cachedHandlersChanged=s.current[e]._handlersChanged;s.current[e]._handlersChanged=null;t.push(s.current[e])}s.current[e].removeHandler(o.current[e])}n=Object.assign({},a);for(let e in u){delete n[e];s.current[e].addHandler(u[e])}}else if(!o.current){n=Object.assign({},a);for(let e in u)delete n[e]}o.current=u;if(s.current){wijmo_1.copy(s.current,n,!1,!0);for(let t in f)e.customProps[t](s.current,f[t]);(()=>{for(let e of t)if(e._cachedHandlersChanged){e._handlersChanged=e._cachedHandlersChanged;e._cachedHandlersChanged=null}t=[]})()}},updateChildProps=()=>{c.current=updateChildProperties({controlRef:s,childInfo:c.current},e.props.children)};React.useLayoutEffect(()=>{if(r.current&&!s.current){s.current=new e.constructor(r.current,a);e.prePropsInit&&e.prePropsInit(s.current);d&&(wijmo_1.isFunction(d)?d({control:s.current,props:e.props}):d.current&&d.current.control==s.current||(d.current={control:s.current,props:e.props}));updateProps();e.initControl&&e.initControl(s.current);e.props.initialized&&setTimeout(()=>{s.current&&e.props.initialized(s.current)})}else i.current&&(i.current=!1);return()=>{if(s.current){const e=s.current;i.current=!0;queueMicrotask(()=>{if(i.current){e.dispose();s.current=null;c.current={};i.current=!1}})}}},[]);s.current&&updateProps();return{renderResult:React.createElement("div",Object.assign({ref:r},p),[]),wjControl:s.current}}exports.useWjComponentBase=useWjComponentBase;function filterKnownProps(e,t,n){const r={};for(let o in e)(t.has(o)||n.has(o))&&(r[o]=e[o]);return r}function clearAndGetEvents(e,t,n,r){const o=r.current,s={};for(let e in t)n.has(e)&&(s[e]=t[e]);for(let n in o)e[n]&&(!_oldSyncBehavior||t[n]?e[n].removeHandler(o[n]):s[n]=o[n]);return s}function getCustomPropsData(e,t){const n={};for(let r in t)void 0!==e[r]&&(n[r]=e[r]);return n}function useWjComponentChildBase(e){const t={};t.knowProperties=new Set(e.properties);t.knowEvents=new Set(e.events);e.customProps||(e.customProps={});return{getInstance:n=>{const r={current:{}},o={current:{}},s={current:{}},c=getPropsAccordingToSyncMode(e.props,r.current),i=filterKnownProps(c,t.knowProperties,t.knowEvents),l=getCustomPropsData(c,e.customProps||{}),a=e.customConstructor?e.customConstructor(n,i,l):new e.constructor(e.needParentInstance?n:i,e.needParentInstance?i:void 0);e.ref&&(wijmo_1.isFunction(e.ref)?e.ref({control:a,props:e.props}):e.ref.current&&e.ref.current.control==a||(e.ref.current={control:a,props:e.props}));s.current=clearAndGetEvents(a,c,t.knowEvents,s);const updateProps=n=>{const c=getPropsAccordingToSyncMode(n,r.current);r.current=n;e.ref&&e.ref.current&&(e.ref.current.props=n);s.current=clearAndGetEvents(a,c,t.knowEvents,s);const i=filterKnownProps(c,t.knowProperties,t.knowEvents);a.initialize?a.initialize(i):wijmo_1.copy(a,i,!1,!0);for(let t in e.customProps)void 0!==c[t]&&e.customProps[t](a,c[t]);(e=>{o.current=updateChildProperties({controlRef:{current:a},childInfo:o.current},e)})(n.children||[])};updateProps(e.props||[]);e.props.initialized&&wijmo_1.isFunction(e.props.initialized)&&e.props.initialized(a);return{instance:a,updateProps:updateProps}},props:e.props,parentProp:e.parentProp,wjProperty:e.props.wjProperty,isParentPropArray:e.isParentPropArray,assignedToParent:e.assignedToParent}}exports.useWjComponentChildBase=useWjComponentChildBase;let _reactMajorVersion,elemRootMap=[];if(!_reactMajorVersion){const e=parseInt(React.version);_reactMajorVersion=e;e>=18&&lazyImportDomClient()}const flushSyncStateCache={isReactRendering:null};function isReactRendering(){if(null==flushSyncStateCache.isReactRendering)try{const e=console.error;let t=!1;console.error=function(){const e=arguments[0]||"";e.includes("flushSync")&&(t=!0)};flushSync(()=>{});console.error=e;flushSyncStateCache.isReactRendering=t}catch(e){}finally{queueMicrotask(()=>{flushSyncStateCache.isReactRendering=null})}return!!flushSyncStateCache.isReactRendering}function getReactDOM(){return ReactDOM}function selectiveDomRender(e,t,n=!1){if(_reactMajorVersion<18){(0,getReactDOM().render)(e,t)}else{isReactRendering()&&(n=!0);const r=elemRootMap.findIndex(e=>e.host===t);let o;if(-1===r){o=reactDomClient.createRoot(t);elemRootMap.push({host:t,root:o})}else o=elemRootMap[r].root;o.__scheduledForUnmount=!1;n?queueMicrotask(()=>{flushSync(()=>{o.render(e)})}):flushSync(()=>{o.render(e)})}return t}exports.selectiveDomRender=selectiveDomRender;function unmountSafely(e){const t=e._internalRoot&&e._internalRoot.containerInfo.firstChild,n=e._internalRoot&&e._internalRoot.current&&e._internalRoot.current.child&&e._internalRoot.current.child.stateNode;n&&t==n?e.unmount():e._internalRoot=null;e.__scheduledForUnmount=null}function selectiveDomUnmount(e){if(_reactMajorVersion<18){(0,getReactDOM().unmountComponentAtNode)(e)}else{const t=elemRootMap.findIndex(t=>t.host===e);if(-1!==t){const e=elemRootMap[t].root;if(isReactRendering()){e.__scheduledForUnmount=!0;queueMicrotask(()=>{e.__scheduledForUnmount&&flushSync(()=>{unmountSafely(e);elemRootMap.splice(t,1)})})}else flushSync(()=>{unmountSafely(e);elemRootMap.splice(t,1)})}}}exports.selectiveDomUnmount=selectiveDomUnmount;function baseFlushSync(){flushSync(()=>{})}exports.baseFlushSync=baseFlushSync;
|
package/es2015-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20242.21
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(s,o){function fulfilled(t){try{step(n.next(t))}catch(t){o(t)}}function rejected(t){try{step(n.throw(t))}catch(t){o(t)}}function step(t){t.done?s(t.value):new i((function(e){e(t.value)})).then(fulfilled,rejected)}step((n=n.apply(t,e||[])).next())}))};import{Control,Event,isArray,addClass,removeClass,setCss,isFunction,isPrimitive,isObject,DateTime,isUndefined,isSafari}from"@grapecity/wijmo";import*as ReactDOM from"react-dom";import*as React from"react";const flushSyncPolyfill=t=>{t()},createRootPolyfill=()=>{throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill};let reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function*(){try{const t=require("react-dom/client");reactDomClient=t||ReactDOM||ReactDomPolyfill;flushSync=t.flushSync||flushSync}catch(t){reactDomClient=ReactDOM||ReactDomPolyfill}}))}export class ComponentBase extends React.Component{constructor(t,e,i){super(t);this._objPropHash={};this._isMounted=!1;this._mountedCBs=[];this._hostRef=t=>this._hostRefValue=t;this._beforeRender=new Event;this._afterRender=new Event;this._beforeWillUnmount=new Event;this._afterWillUnmount=new Event;this._beforeDidUpdate=new Event;this._afterDidUpdate=new Event;if(this._isMounted&&!this._isChild()){clearTimeout(this.timer);return this}if(!ComponentBase._reactMajorVersion){const t=parseInt(React.version);ComponentBase._reactMajorVersion=t;t>=18&&lazyImportDomClient()}this.props=t;this.controlType=e;for(let t of i&&i.objectProps||[])this._objPropHash[t]=!0}render(){this._onBeforeRender();const t=this._renderImpl();this._onAfterRender();this.renderResult=t;if(this._isMounted&&!this._isChild()){clearTimeout(this.timer);return this.renderResult}return t}componentDidMount(){if(this._isMounted){clearTimeout(this.timer);return this.control}if(this._isChild()){let t=this.props[ComponentBase._propsParent];t&&t._mountedCB(()=>{this._setParent(t)})}else this._prepareControl();this._isMounted=!0;return this.control}static selectiveDomRender(t,e,i=!0){if(ComponentBase._reactMajorVersion<18)ReactDOM.render(t,e);else{const i=ComponentBase.elemRootMap.findIndex(t=>t.host===e);let n;if(-1===i){n=reactDomClient.createRoot(e);ComponentBase.elemRootMap.push({host:e,root:n})}else n=ComponentBase.elemRootMap[i].root;flushSync(()=>{n.render(t)})}return e}static selectiveDomUnmount(t){if(ComponentBase._reactMajorVersion<18)ReactDOM.unmountComponentAtNode(t);else{const e=ComponentBase.elemRootMap.findIndex(e=>e.host===t);if(-1!==e){const t=ComponentBase.elemRootMap[e].root;flushSync(()=>{t.unmount();ComponentBase.elemRootMap.splice(e,1)})}}}componentWillUnmount(){this._onBeforeWillUnmount();this._siblingInsertedMO&&this._siblingInsertedMO.disconnect();let t=this.control;if(t)if(this._isChild()){let e=this._getParentProp();if(e){let i=this.parent.control[e];if(isArray(i)){let e=i.indexOf(t);if(e>-1){const t=i[e];"Sheet"===t.constructor.name&&t._isEmptyGrid||i.splice(e,1)}}}}else t instanceof Control&&(this.timer=setTimeout(()=>{if(t.hostElement){t._orgOuter=null;t.dispose()}},5));this._onAfterWillUnmount()}shouldComponentUpdate(t){return!0}componentDidUpdate(t){this._onBeforeDidUpdate();var e=this.control;this._copy(e,this.props,t);this._onAfterDidUpdate()}_mountedCB(t){this._isMounted&&!this._isChild()?t():this._isMounted||this._mountedCBs.push(t);setTimeout(()=>{this._mountedCBs.includes(t)||this._mountedCBs.push(t)},isSafari?200:10)}_renderImpl(){let t={};t[ComponentBase._propsParent]=this;let e=React.Children.map(this.props.children,e=>e&&React.cloneElement(e,t));const i={ref:this._hostRef};this._isChild()&&(i.style={display:"none"});return React.createElement("div",i,e)}_onBeforeRender(t){this._beforeRender.raise(this,t)}_onAfterRender(t){this._afterRender.raise(this,t)}_onBeforeWillUnmount(t){this._beforeWillUnmount.raise(this,t)}_onAfterWillUnmount(t){this._afterWillUnmount.raise(this,t)}_onBeforeDidUpdate(t){this._beforeDidUpdate.raise(this,t)}_onAfterDidUpdate(t){this._afterDidUpdate.raise(this,t)}_createControl(){const t=this._isChild()?this._isParentInCtor()?this.parent.control:void 0:this._getElement();t instanceof Element&&this.props.id&&t.setAttribute("id",this.props.id);const e=new this.controlType(t);e.workingAs="React";return e}_prepareControl(){this._renderImpl();let t=this._getElement(),e=this.props;t&&!this._isChild()&&ComponentBase._copyAttrs(t,e,Control._rxInputAtts);let i=this.control=this._createControl(),n=i instanceof Control,s=ComponentBase;t=this._getElement();if(!this._siblingId){null==this.constructor[s._typeSiblingIdProp]&&(this.constructor[s._typeSiblingIdProp]=++s._siblingDirId+"");this._siblingId=this.constructor[s._typeSiblingIdProp]}if(t){t.setAttribute(s._typeSiblingIdProp,this._siblingId);var o={};for(var r in e){let n=e[r];this._ignoreProp(r)||isUndefined(n)||(r in i?o[r]=n:this._setHostAttribute(t,r,n))}n?i.initialize(o):this._copy(i,o,null,!0);setTimeout(()=>{let t=this._mountedCBs;for(let e in t){t[e]();delete t[e]}isFunction(e.initialized)&&e.initialized(i);this._isMounted=!0},isSafari?201:100)}}_initParent(){if(!this._getElement())return;let t=this._getParentProp();if(t){let e=this.parent.control,i=e[t];if(isArray(i)){let t=this._getSiblingIndex();(t<0||t>=i.length)&&(t=i.length);i.splice(t,0,this.control);const e=this._getElement();this._siblingInsertedMO=new MutationObserver(this._siblingInserted.bind(this));this._siblingInsertedMO.observe(e,{childList:!0})}else e[t]=this.control}}_setParent(t){if(t!==this.parent){if(this.parent)throw"Wijmo child component is already attached to a different parent.";this.parent=t;this._prepareControl();this._initParent()}}_isChild(){return null!=this._parentProp||null!=this._parentInCtor}_isParentInCtor(){return!0===this._parentInCtor}_getParentProp(){return this.props.wjProperty||this._parentProp}_getSiblingIndex(){var t=this._getElement(),e=t.parentElement;if(!e)return-1;for(var i=e.childNodes,n=-1,s=this._siblingId,o=0;o<i.length;o++){var r=i[o];if(1==r.nodeType&&r.getAttribute(ComponentBase._typeSiblingIdProp)==s){++n;if(r===t)return n}}return-1}_siblingInserted(t){for(let e of t)if("childList"===e.type&&e.addedNodes.length>0){if(Array.from(e.addedNodes).some(t=>t===this._getElement())){const t=this._getSiblingIndex(),e=this.control,i=this.parent.control[this._getParentProp()],n=i.indexOf(e);if(t>=0&&n>=0&&t!==n){i.splice(n,1);const s=Math.min(t,i.length);i.splice(s,0,e)}}}}_copy(t,e,i,n=!1){if(!t||!e)return;let s,o=t===this.control;for(var r in e)if(!this._ignoreProp(r)||!o){var l=e[r];if(r in t){if(this._isEvent(t,r))n&&isFunction(l)&&t[r].addHandler(l);else if(!i||!this._sameValue(i[r],l))if(null==l)t[r]=l;else if(isPrimitive(l)||isFunction(l)||this._objPropHash[r]&&t===(s||(s=this.control)))t[r]=l;else if(isArray(l)&&isArray(t[r])){let e=t[r],i=l;if(i.length==e.length)for(var a=0;a<i.length;a++){if(i[a]!==e[a])return!1;this._copy(e[a],i[a])}}else isObject(l)&&this._copy(t[r],e[r])}else this._setHostAttribute(t.hostElement,r,e[r])}}_setHostAttribute(t,e,i){if(t)switch(e){case"className":const n=this._appliedClassName;if(n!==i){removeClass(t,n);addClass(t,i);this._appliedClassName=i}break;case"style":setCss(t,i);break;default:null!=t[e]?t[e]=i:"string"==typeof i&&"$"!==e[0]&&t.setAttribute(e,i)}}_sameValue(t,e){return t==e||DateTime.equals(t,e)}_isEvent(t,e){let i=t&&t[e];return null!=i&&i instanceof Event}_getElement(){return this._hostRefValue}_ignoreProp(t){return"children"===t}static _copyAttrs(t,e,i){if(t)for(let n in e)n.match(i)&&t.setAttribute(n,e[n])}static isInStrictMode(t){return!!(t.hasOwnProperty("_reactInternalFiber")&&1&t._reactInternalFiber.mode)}}ComponentBase._propsParent="$parent";ComponentBase._typeSiblingIdProp="_wjSiblingIdProp";ComponentBase._siblingDirId=0;ComponentBase.elemRootMap=[];
|
|
14
|
+
var __awaiter=this&&this.__awaiter||function(e,n,r,t){return new(r||(r=Promise))((function(o,s){function fulfilled(e){try{step(t.next(e))}catch(e){s(e)}}function rejected(e){try{step(t.throw(e))}catch(e){s(e)}}function step(e){e.done?o(e.value):new r((function(n){n(e.value)})).then(fulfilled,rejected)}step((t=t.apply(e,n||[])).next())}))};import{ObservableArray,asString,copy,isArray,isFunction,asBoolean}from"@grapecity/wijmo";import*as ReactDOM from"react-dom";import*as React from"react";const flushSyncPolyfill=e=>{e()},createRootPolyfill=()=>{throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill};let reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function*(){try{const e=require("react-dom/client");reactDomClient=e||ReactDOM||ReactDomPolyfill;flushSync=e.flushSync||flushSync}catch(e){reactDomClient=ReactDOM||ReactDomPolyfill}}))}let _oldSyncBehavior=!0;export function strictStateMode(e=!1){e==_oldSyncBehavior&&(_oldSyncBehavior=!asBoolean(e,!1))}export const ControlBaseMeta={inputs:["isDisabled","tabOrder"],events:["gotFocus","invalidInput","lostFocus","refreshed","refreshing"]};const alwaysClearProps=new Set(["columns","columnGroups"]),unsuppressedChangedEventProps=new Set(["panes","columnGroups","columns","items"]),specialProps=new Set(["initialized","wjItemTemplate"]);function updateChildProperties(e,n){const r=e.controlRef.current,t={},o={};if(n){const s=isArray(n)?n.flat(1/0):[n],c=[];let i=0;const l=new Set;for(let e of s){if(e&&e.type&&e.type.$$typeof==Symbol.for("react.forward_ref")){c.push(e.type.render(e.props,e.ref));c[c.length-1].$index=i;c[c.length-1].$key=e.key}else if(e&&isFunction(e.type)){c.push(e.type(e.props));c[c.length-1].$index=i;c[c.length-1].$key=e.key}e||l.add(i);i++}const a=[];for(let e of c)if(e.assignedToParent){if(e.wjProperty){e.parentProp=asString(e.wjProperty);e.isParentPropArray=r[e.parentProp]&&isArray(r[e.parentProp])}e.isParentPropArray&&!t[e.parentProp]&&(t[e.parentProp]=[]);e.isParentPropArray?t[e.parentProp].push({getInstance:e.getInstance,props:e.props,$key:e.$key,$index:e.$index}):t[e.parentProp]={getInstance:e.getInstance,props:e.props}}else a.push(e);const u=e.childInfo;for(let e in t)if(isArray(t[e])){let n=!1;if(r[e]&&null!=r[e]._updating&&!unsuppressedChangedEventProps.has(e)){r[e]._updating++;n=!0}let s=u[e];o[e]=[];if(!u[e]){s=[];r[e]&&r[e].clear?r[e].clear():r[e]||(r[e]=new ObservableArray)}!_oldSyncBehavior&&alwaysClearProps.has(e)&&r[e]&&r[e].clear&&r[e].clear();if(_oldSyncBehavior)for(let n=s.length-1;n>=0;n--)if(l.has(s[n].$index)){r[e].remove(s[n].instance);s.splice(n,1)}const c=[],i={};for(let e of s)null!=e.$key?i[""+e.$key]=e:c.push(e);let a=0;const getExistingInstance=(e=null)=>{if(null!=e){let n=i[e];null!=n&&delete i[e];return n}return c[a++]};for(let n=0;n<t[e].length;n++){let s=getExistingInstance(t[e][n].$key),c=!1;if(s)s.updateProps(t[e][n].props);else{s=t[e][n].getInstance(r);c=!0}s.$index=t[e][n].$index;s.$key=t[e][n].$key;(!_oldSyncBehavior&&alwaysClearProps.has(e)||c)&&(r[e].length==n?r[e].push(s.instance):r[e].splice(n,0,s.instance));o[e].push(s)}for(let n of Object.keys(i))r[e].remove(i[n].instance);for(;!_oldSyncBehavior&&r[e].length>o[e].length;)r[e].pop();if(n){r[e]._updating--;u[e]&&u[e].length==t[e].length||r[e]._raiseCollectionChanged&&r[e]._raiseCollectionChanged()}}else{let n=u[e];if(n)n.updateProps(t[e].props);else{n=t[e].getInstance(r);r[e]=n.instance}o[e]=n}const p=[];for(let e of u.$_nonassignable||[])l.has(e.$index)?e.instance&&e.instance.dispose&&isFunction(e.instance.dispose)&&e.instance.dispose():p.push(e);const f=[];let d=0;for(;d<a.length;d++){let e=p[d];e?e.updateProps(a[d].props):e=a[d].getInstance(r);e.$index=a[d].$index;f.push(e)}o.$_nonassignable=f;for(;d<p.length;d++)p[d].instance&&p[d].instance.dispose&&isFunction(p[d].instance.dispose)&&p[d].instance.dispose()}if(_oldSyncBehavior)for(let n of Object.keys(e.childInfo))if(isArray(e.childInfo[n])&&!t[n]&&r[n]&&r[n].remove)for(let t of e.childInfo[n])r[n].remove(t.instance);return o}function getPropsAccordingToSyncMode(e,n,r=null){if(!n||!_oldSyncBehavior){return Object.assign({},e)}let t={};for(let o in e){let s=!1;r&&(s=r.knowProperties.has(o)||r.knowEvents.has(o)||r.knowCustomProps.has(o));(r&&!s||e[o]!==n[o])&&(t[o]=e[o])}return t}export function useWjComponentBase(e){const n=React.useRef({}),r=React.useRef(),t=React.useRef(),o=React.useRef(),s=React.useRef(),c=React.useRef({}),i=React.useRef(!1);e.customProps||(e.customProps={});if(!r.current){r.current={};r.current.knowProperties=new Set(e.properties);r.current.knowEvents=new Set(e.events);r.current.knowCustomProps=new Set(Object.keys(e.customProps))}let l=e.props;if(s.current){l=getPropsAccordingToSyncMode(e.props,n.current,r.current);n.current=e.props}const a={},u={},p={},f={},d=e.ref||null;for(let n in l)if(r.current.knowProperties.has(n))a[n]=l[n];else if(r.current.knowEvents.has(n)){u[n]=l[n];a[n]=l[n]}else e.customProps[n]?f[n]=l[n]:specialProps.has(n)||(p[n]=l[n]);if(s.current&&_oldSyncBehavior)for(let e in u)delete a[e];const updateProps=()=>{d&&d.current&&(d.current.props=e.props);updateChildProps();let n=[],r=a;if(o.current&&s.current&&!_oldSyncBehavior){for(let e in o.current)if(s.current[e]){if(s.current[e]._handlersChanged){s.current[e]._cachedHandlersChanged=s.current[e]._handlersChanged;s.current[e]._handlersChanged=null;n.push(s.current[e])}s.current[e].removeHandler(o.current[e])}r=Object.assign({},a);for(let e in u){delete r[e];s.current[e].addHandler(u[e])}}else if(!o.current){r=Object.assign({},a);for(let e in u)delete r[e]}o.current=u;if(s.current){copy(s.current,r,!1,!0);for(let n in f)e.customProps[n](s.current,f[n]);(()=>{for(let e of n)if(e._cachedHandlersChanged){e._handlersChanged=e._cachedHandlersChanged;e._cachedHandlersChanged=null}n=[]})()}},updateChildProps=()=>{c.current=updateChildProperties({controlRef:s,childInfo:c.current},e.props.children)};React.useLayoutEffect(()=>{if(t.current&&!s.current){s.current=new e.constructor(t.current,a);e.prePropsInit&&e.prePropsInit(s.current);d&&(isFunction(d)?d({control:s.current,props:e.props}):d.current&&d.current.control==s.current||(d.current={control:s.current,props:e.props}));updateProps();e.initControl&&e.initControl(s.current);e.props.initialized&&setTimeout(()=>{s.current&&e.props.initialized(s.current)})}else i.current&&(i.current=!1);return()=>{if(s.current){const e=s.current;i.current=!0;queueMicrotask(()=>{if(i.current){e.dispose();s.current=null;c.current={};i.current=!1}})}}},[]);s.current&&updateProps();return{renderResult:React.createElement("div",Object.assign({ref:t},p),[]),wjControl:s.current}}function filterKnownProps(e,n,r){const t={};for(let o in e)(n.has(o)||r.has(o))&&(t[o]=e[o]);return t}function clearAndGetEvents(e,n,r,t){const o=t.current,s={};for(let e in n)r.has(e)&&(s[e]=n[e]);for(let r in o)e[r]&&(!_oldSyncBehavior||n[r]?e[r].removeHandler(o[r]):s[r]=o[r]);return s}function getCustomPropsData(e,n){const r={};for(let t in n)void 0!==e[t]&&(r[t]=e[t]);return r}export function useWjComponentChildBase(e){const n={};n.knowProperties=new Set(e.properties);n.knowEvents=new Set(e.events);e.customProps||(e.customProps={});return{getInstance:r=>{const t={current:{}},o={current:{}},s={current:{}},c=getPropsAccordingToSyncMode(e.props,t.current),i=filterKnownProps(c,n.knowProperties,n.knowEvents),l=getCustomPropsData(c,e.customProps||{}),a=e.customConstructor?e.customConstructor(r,i,l):new e.constructor(e.needParentInstance?r:i,e.needParentInstance?i:void 0);e.ref&&(isFunction(e.ref)?e.ref({control:a,props:e.props}):e.ref.current&&e.ref.current.control==a||(e.ref.current={control:a,props:e.props}));s.current=clearAndGetEvents(a,c,n.knowEvents,s);const updateProps=r=>{const c=getPropsAccordingToSyncMode(r,t.current);t.current=r;e.ref&&e.ref.current&&(e.ref.current.props=r);s.current=clearAndGetEvents(a,c,n.knowEvents,s);const i=filterKnownProps(c,n.knowProperties,n.knowEvents);a.initialize?a.initialize(i):copy(a,i,!1,!0);for(let n in e.customProps)void 0!==c[n]&&e.customProps[n](a,c[n]);(e=>{o.current=updateChildProperties({controlRef:{current:a},childInfo:o.current},e)})(r.children||[])};updateProps(e.props||[]);e.props.initialized&&isFunction(e.props.initialized)&&e.props.initialized(a);return{instance:a,updateProps:updateProps}},props:e.props,parentProp:e.parentProp,wjProperty:e.props.wjProperty,isParentPropArray:e.isParentPropArray,assignedToParent:e.assignedToParent}}let _reactMajorVersion,elemRootMap=[];if(!_reactMajorVersion){const e=parseInt(React.version);_reactMajorVersion=e;e>=18&&lazyImportDomClient()}const flushSyncStateCache={isReactRendering:null};function isReactRendering(){if(null==flushSyncStateCache.isReactRendering)try{const e=console.error;let n=!1;console.error=function(){const e=arguments[0]||"";e.includes("flushSync")&&(n=!0)};flushSync(()=>{});console.error=e;flushSyncStateCache.isReactRendering=n}catch(e){}finally{queueMicrotask(()=>{flushSyncStateCache.isReactRendering=null})}return!!flushSyncStateCache.isReactRendering}function getReactDOM(){return ReactDOM}export function selectiveDomRender(e,n,r=!1){if(_reactMajorVersion<18){(0,getReactDOM().render)(e,n)}else{isReactRendering()&&(r=!0);const t=elemRootMap.findIndex(e=>e.host===n);let o;if(-1===t){o=reactDomClient.createRoot(n);elemRootMap.push({host:n,root:o})}else o=elemRootMap[t].root;o.__scheduledForUnmount=!1;r?queueMicrotask(()=>{flushSync(()=>{o.render(e)})}):flushSync(()=>{o.render(e)})}return n}function unmountSafely(e){const n=e._internalRoot&&e._internalRoot.containerInfo.firstChild,r=e._internalRoot&&e._internalRoot.current&&e._internalRoot.current.child&&e._internalRoot.current.child.stateNode;r&&n==r?e.unmount():e._internalRoot=null;e.__scheduledForUnmount=null}export function selectiveDomUnmount(e){if(_reactMajorVersion<18){(0,getReactDOM().unmountComponentAtNode)(e)}else{const n=elemRootMap.findIndex(n=>n.host===e);if(-1!==n){const e=elemRootMap[n].root;if(isReactRendering()){e.__scheduledForUnmount=!0;queueMicrotask(()=>{e.__scheduledForUnmount&&flushSync(()=>{unmountSafely(e);elemRootMap.splice(n,1)})})}else flushSync(()=>{unmountSafely(e);elemRootMap.splice(n,1)})}}}export function baseFlushSync(){flushSync(()=>{})}
|
package/es5-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20242.21
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}(),__awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function fulfilled(t){try{step(o.next(t))}catch(t){r(t)}}function rejected(t){try{step(o.throw(t))}catch(t){r(t)}}function step(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(fulfilled,rejected)}step((o=o.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function verb(r){return function(a){return function step(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;(o=0,i)&&(r=[2&r[0],i.value]);switch(r[0]){case 0:case 1:i=r;break;case 4:s.label++;return{value:r[1],done:!1};case 5:s.label++;o=r[1];r=[0];continue;case 7:r=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1];i=r;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(r);break}i[2]&&s.ops.pop();s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t];o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}};import{Control,Event,isArray,addClass,removeClass,setCss,isFunction,isPrimitive,isObject,DateTime,isUndefined,isSafari}from"@grapecity/wijmo";import*as ReactDOM from"react-dom";import*as React from"react";var flushSyncPolyfill=function(t){t()},createRootPolyfill=function(){throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill},reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){try{t=require("react-dom/client");reactDomClient=t||ReactDOM||ReactDomPolyfill;flushSync=t.flushSync||flushSync}catch(t){reactDomClient=ReactDOM||ReactDomPolyfill}return[2]}))}))}var ComponentBase=function(t){__extends(ComponentBase,t);function ComponentBase(e,n,o){var i=t.call(this,e)||this;i._objPropHash={};i._isMounted=!1;i._mountedCBs=[];i._hostRef=function(t){return i._hostRefValue=t};i._beforeRender=new Event;i._afterRender=new Event;i._beforeWillUnmount=new Event;i._afterWillUnmount=new Event;i._beforeDidUpdate=new Event;i._afterDidUpdate=new Event;if(i._isMounted&&!i._isChild()){clearTimeout(i.timer);return i}if(!ComponentBase._reactMajorVersion){var r=parseInt(React.version);ComponentBase._reactMajorVersion=r;r>=18&&lazyImportDomClient()}i.props=e;i.controlType=n;for(var s=0,a=o&&o.objectProps||[];s<a.length;s++){var p=a[s];i._objPropHash[p]=!0}return i}ComponentBase.prototype.render=function(){this._onBeforeRender();var t=this._renderImpl();this._onAfterRender();this.renderResult=t;if(this._isMounted&&!this._isChild()){clearTimeout(this.timer);return this.renderResult}return t};ComponentBase.prototype.componentDidMount=function(){var t=this;if(this._isMounted){clearTimeout(this.timer);return this.control}if(this._isChild()){var e=this.props[ComponentBase._propsParent];e&&e._mountedCB((function(){t._setParent(e)}))}else this._prepareControl();this._isMounted=!0;return this.control};ComponentBase.selectiveDomRender=function(t,e,n){void 0===n&&(n=!0);if(ComponentBase._reactMajorVersion<18)ReactDOM.render(t,e);else{var o,i=ComponentBase.elemRootMap.findIndex((function(t){return t.host===e}));if(-1===i){o=reactDomClient.createRoot(e);ComponentBase.elemRootMap.push({host:e,root:o})}else o=ComponentBase.elemRootMap[i].root;flushSync((function(){o.render(t)}))}return e};ComponentBase.selectiveDomUnmount=function(t){if(ComponentBase._reactMajorVersion<18)ReactDOM.unmountComponentAtNode(t);else{var e=ComponentBase.elemRootMap.findIndex((function(e){return e.host===t}));if(-1!==e){var n=ComponentBase.elemRootMap[e].root;flushSync((function(){n.unmount();ComponentBase.elemRootMap.splice(e,1)}))}}};ComponentBase.prototype.componentWillUnmount=function(){this._onBeforeWillUnmount();this._siblingInsertedMO&&this._siblingInsertedMO.disconnect();var t=this.control;if(t)if(this._isChild()){var e=this._getParentProp();if(e){var n=this.parent.control[e];if(isArray(n)){var o=n.indexOf(t);if(o>-1){var i=n[o];"Sheet"===i.constructor.name&&i._isEmptyGrid||n.splice(o,1)}}}}else t instanceof Control&&(this.timer=setTimeout((function(){if(t.hostElement){t._orgOuter=null;t.dispose()}}),5));this._onAfterWillUnmount()};ComponentBase.prototype.shouldComponentUpdate=function(t){return!0};ComponentBase.prototype.componentDidUpdate=function(t){this._onBeforeDidUpdate();var e=this.control;this._copy(e,this.props,t);this._onAfterDidUpdate()};ComponentBase.prototype._mountedCB=function(t){var e=this;this._isMounted&&!this._isChild()?t():this._isMounted||this._mountedCBs.push(t);setTimeout((function(){e._mountedCBs.includes(t)||e._mountedCBs.push(t)}),isSafari?200:10)};ComponentBase.prototype._renderImpl=function(){var t={};t[ComponentBase._propsParent]=this;var e=React.Children.map(this.props.children,(function(e){return e&&React.cloneElement(e,t)})),n={ref:this._hostRef};this._isChild()&&(n.style={display:"none"});return React.createElement("div",n,e)};ComponentBase.prototype._onBeforeRender=function(t){this._beforeRender.raise(this,t)};ComponentBase.prototype._onAfterRender=function(t){this._afterRender.raise(this,t)};ComponentBase.prototype._onBeforeWillUnmount=function(t){this._beforeWillUnmount.raise(this,t)};ComponentBase.prototype._onAfterWillUnmount=function(t){this._afterWillUnmount.raise(this,t)};ComponentBase.prototype._onBeforeDidUpdate=function(t){this._beforeDidUpdate.raise(this,t)};ComponentBase.prototype._onAfterDidUpdate=function(t){this._afterDidUpdate.raise(this,t)};ComponentBase.prototype._createControl=function(){var t=this._isChild()?this._isParentInCtor()?this.parent.control:void 0:this._getElement();t instanceof Element&&this.props.id&&t.setAttribute("id",this.props.id);var e=new this.controlType(t);e.workingAs="React";return e};ComponentBase.prototype._prepareControl=function(){var t=this;this._renderImpl();var e=this._getElement(),n=this.props;e&&!this._isChild()&&ComponentBase._copyAttrs(e,n,Control._rxInputAtts);var o=this.control=this._createControl(),i=o instanceof Control,r=ComponentBase;e=this._getElement();if(!this._siblingId){null==this.constructor[r._typeSiblingIdProp]&&(this.constructor[r._typeSiblingIdProp]=++r._siblingDirId+"");this._siblingId=this.constructor[r._typeSiblingIdProp]}if(e){e.setAttribute(r._typeSiblingIdProp,this._siblingId);var s={};for(var a in n){var p=n[a];this._ignoreProp(a)||isUndefined(p)||(a in o?s[a]=p:this._setHostAttribute(e,a,p))}i?o.initialize(s):this._copy(o,s,null,!0);setTimeout((function(){var e=t._mountedCBs;for(var i in e){e[i]();delete e[i]}isFunction(n.initialized)&&n.initialized(o);t._isMounted=!0}),isSafari?201:100)}};ComponentBase.prototype._initParent=function(){if(this._getElement()){var t=this._getParentProp();if(t){var e=this.parent.control,n=e[t];if(isArray(n)){var o=this._getSiblingIndex();(o<0||o>=n.length)&&(o=n.length);n.splice(o,0,this.control);var i=this._getElement();this._siblingInsertedMO=new MutationObserver(this._siblingInserted.bind(this));this._siblingInsertedMO.observe(i,{childList:!0})}else e[t]=this.control}}};ComponentBase.prototype._setParent=function(t){if(t!==this.parent){if(this.parent)throw"Wijmo child component is already attached to a different parent.";this.parent=t;this._prepareControl();this._initParent()}};ComponentBase.prototype._isChild=function(){return null!=this._parentProp||null!=this._parentInCtor};ComponentBase.prototype._isParentInCtor=function(){return!0===this._parentInCtor};ComponentBase.prototype._getParentProp=function(){return this.props.wjProperty||this._parentProp};ComponentBase.prototype._getSiblingIndex=function(){var t=this._getElement(),e=t.parentElement;if(!e)return-1;for(var n=e.childNodes,o=-1,i=this._siblingId,r=0;r<n.length;r++){var s=n[r];if(1==s.nodeType&&s.getAttribute(ComponentBase._typeSiblingIdProp)==i){++o;if(s===t)return o}}return-1};ComponentBase.prototype._siblingInserted=function(t){for(var e=this,n=0,o=t;n<o.length;n++){var i=o[n];if("childList"===i.type&&i.addedNodes.length>0){if(Array.from(i.addedNodes).some((function(t){return t===e._getElement()}))){var r=this._getSiblingIndex(),s=this.control,a=this.parent.control[this._getParentProp()],p=a.indexOf(s);if(r>=0&&p>=0&&r!==p){a.splice(p,1);var l=Math.min(r,a.length);a.splice(l,0,s)}}}}};ComponentBase.prototype._copy=function(t,e,n,o){void 0===o&&(o=!1);if(t&&e){var i,r=t===this.control;for(var s in e)if(!this._ignoreProp(s)||!r){var a=e[s];if(s in t){if(this._isEvent(t,s))o&&isFunction(a)&&t[s].addHandler(a);else if(!n||!this._sameValue(n[s],a))if(null==a)t[s]=a;else if(isPrimitive(a)||isFunction(a)||this._objPropHash[s]&&t===(i||(i=this.control)))t[s]=a;else if(isArray(a)&&isArray(t[s])){var p=t[s],l=a;if(l.length==p.length)for(var c=0;c<l.length;c++){if(l[c]!==p[c])return!1;this._copy(p[c],l[c])}}else isObject(a)&&this._copy(t[s],e[s])}else this._setHostAttribute(t.hostElement,s,e[s])}}};ComponentBase.prototype._setHostAttribute=function(t,e,n){if(t)switch(e){case"className":var o=this._appliedClassName;if(o!==n){removeClass(t,o);addClass(t,n);this._appliedClassName=n}break;case"style":setCss(t,n);break;default:null!=t[e]?t[e]=n:"string"==typeof n&&"$"!==e[0]&&t.setAttribute(e,n)}};ComponentBase.prototype._sameValue=function(t,e){return t==e||DateTime.equals(t,e)};ComponentBase.prototype._isEvent=function(t,e){var n=t&&t[e];return null!=n&&n instanceof Event};ComponentBase.prototype._getElement=function(){return this._hostRefValue};ComponentBase.prototype._ignoreProp=function(t){return"children"===t};ComponentBase._copyAttrs=function(t,e,n){if(t)for(var o in e)o.match(n)&&t.setAttribute(o,e[o])};ComponentBase.isInStrictMode=function(t){return!!(t.hasOwnProperty("_reactInternalFiber")&&1&t._reactInternalFiber.mode)};ComponentBase._propsParent="$parent";ComponentBase._typeSiblingIdProp="_wjSiblingIdProp";ComponentBase._siblingDirId=0;ComponentBase.elemRootMap=[];return ComponentBase}(React.Component);export{ComponentBase};
|
|
14
|
+
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++){r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,r,n,t){return new(n||(n=Promise))((function(o,a){function fulfilled(e){try{step(t.next(e))}catch(e){a(e)}}function rejected(e){try{step(t.throw(e))}catch(e){a(e)}}function step(e){e.done?o(e.value):new n((function(r){r(e.value)})).then(fulfilled,rejected)}step((t=t.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var n,t,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function verb(a){return function(s){return function step(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,t&&(o=2&a[0]?t.return:a[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,a[1])).done)return o;(t=0,o)&&(a=[2&a[0],o.value]);switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:!1};case 5:i.label++;t=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}o[2]&&i.ops.pop();i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e];t=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};import{ObservableArray,asString,copy,isArray,isFunction,asBoolean}from"@grapecity/wijmo";import*as ReactDOM from"react-dom";import*as React from"react";var flushSyncPolyfill=function(e){e()},createRootPolyfill=function(){throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill},reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(r){try{e=require("react-dom/client");reactDomClient=e||ReactDOM||ReactDomPolyfill;flushSync=e.flushSync||flushSync}catch(e){reactDomClient=ReactDOM||ReactDomPolyfill}return[2]}))}))}var _oldSyncBehavior=!0;export function strictStateMode(e){void 0===e&&(e=!1);e==_oldSyncBehavior&&(_oldSyncBehavior=!asBoolean(e,!1))}export var ControlBaseMeta={inputs:["isDisabled","tabOrder"],events:["gotFocus","invalidInput","lostFocus","refreshed","refreshing"]};var alwaysClearProps=new Set(["columns","columnGroups"]),unsuppressedChangedEventProps=new Set(["panes","columnGroups","columns","items"]),specialProps=new Set(["initialized","wjItemTemplate"]);function updateChildProperties(e,r){var n=e.controlRef.current,t={},o={};if(r){for(var a=isArray(r)?r.flat(1/0):[r],i=[],s=0,c=new Set,u=0,l=a;u<l.length;u++){if((P=l[u])&&P.type&&P.type.$$typeof==Symbol.for("react.forward_ref")){i.push(P.type.render(P.props,P.ref));i[i.length-1].$index=s;i[i.length-1].$key=P.key}else if(P&&isFunction(P.type)){i.push(P.type(P.props));i[i.length-1].$index=s;i[i.length-1].$key=P.key}P||c.add(s);s++}for(var p=[],f=0,d=i;f<d.length;f++){if((P=d[f]).assignedToParent){if(P.wjProperty){P.parentProp=asString(P.wjProperty);P.isParentPropArray=n[P.parentProp]&&isArray(n[P.parentProp])}P.isParentPropArray&&!t[P.parentProp]&&(t[P.parentProp]=[]);P.isParentPropArray?t[P.parentProp].push({getInstance:P.getInstance,props:P.props,$key:P.$key,$index:P.$index}):t[P.parentProp]={getInstance:P.getInstance,props:P.props}}else p.push(P)}var h=e.childInfo,_loop_1=function(e){if(isArray(t[e])){var r=!1;if(n[e]&&null!=n[e]._updating&&!unsuppressedChangedEventProps.has(e)){n[e]._updating++;r=!0}var a=h[e];o[e]=[];if(!h[e]){a=[];n[e]&&n[e].clear?n[e].clear():n[e]||(n[e]=new ObservableArray)}!_oldSyncBehavior&&alwaysClearProps.has(e)&&n[e]&&n[e].clear&&n[e].clear();if(_oldSyncBehavior)for(var i=a.length-1;i>=0;i--)if(c.has(a[i].$index)){n[e].remove(a[i].instance);a.splice(i,1)}for(var s=[],u={},l=0,p=a;l<p.length;l++){var f=p[l];null!=f.$key?u[""+f.$key]=f:s.push(f)}for(var d=0,getExistingInstance=function(e){void 0===e&&(e=null);if(null!=e){var r=u[e];null!=r&&delete u[e];return r}return s[d++]},v=0;v<t[e].length;v++){var y=!1;if(_=getExistingInstance(t[e][v].$key))_.updateProps(t[e][v].props);else{_=t[e][v].getInstance(n);y=!0}_.$index=t[e][v].$index;_.$key=t[e][v].$key;(!_oldSyncBehavior&&alwaysClearProps.has(e)||y)&&(n[e].length==v?n[e].push(_.instance):n[e].splice(v,0,_.instance));o[e].push(_)}for(var g=0,m=Object.keys(u);g<m.length;g++){var P=m[g];n[e].remove(u[P].instance)}for(;!_oldSyncBehavior&&n[e].length>o[e].length;)n[e].pop();if(r){n[e]._updating--;h[e]&&h[e].length==t[e].length||n[e]._raiseCollectionChanged&&n[e]._raiseCollectionChanged()}}else{var _;if(_=h[e])_.updateProps(t[e].props);else{_=t[e].getInstance(n);n[e]=_.instance}o[e]=_}};for(var v in t)_loop_1(v);for(var y=[],g=0,m=h.$_nonassignable||[];g<m.length;g++){var P=m[g];c.has(P.$index)?P.instance&&P.instance.dispose&&isFunction(P.instance.dispose)&&P.instance.dispose():y.push(P)}for(var _=[],R=0;R<p.length;R++){var S=y[R];S?S.updateProps(p[R].props):S=p[R].getInstance(n);S.$index=p[R].$index;_.push(S)}o.$_nonassignable=_;for(;R<y.length;R++)y[R].instance&&y[R].instance.dispose&&isFunction(y[R].instance.dispose)&&y[R].instance.dispose()}if(_oldSyncBehavior)for(var w=0,C=Object.keys(e.childInfo);w<C.length;w++){var k=C[w];if(isArray(e.childInfo[k])&&!t[k]&&n[k]&&n[k].remove)for(var b=0,M=e.childInfo[k];b<M.length;b++){var I=M[b];n[k].remove(I.instance)}}return o}function getPropsAccordingToSyncMode(e,r,n){void 0===n&&(n=null);if(!r||!_oldSyncBehavior){return __assign({},e)}var t={};for(var o in e){var a=!1;n&&(a=n.knowProperties.has(o)||n.knowEvents.has(o)||n.knowCustomProps.has(o));(n&&!a||e[o]!==r[o])&&(t[o]=e[o])}return t}export function useWjComponentBase(e){var r=React.useRef({}),n=React.useRef(),t=React.useRef(),o=React.useRef(),a=React.useRef(),i=React.useRef({}),s=React.useRef(!1);e.customProps||(e.customProps={});if(!n.current){n.current={};n.current.knowProperties=new Set(e.properties);n.current.knowEvents=new Set(e.events);n.current.knowCustomProps=new Set(Object.keys(e.customProps))}var c=e.props;if(a.current){c=getPropsAccordingToSyncMode(e.props,r.current,n.current);r.current=e.props}var u={},l={},p={},f={},d=e.ref||null;for(var h in c)if(n.current.knowProperties.has(h))u[h]=c[h];else if(n.current.knowEvents.has(h)){l[h]=c[h];u[h]=c[h]}else e.customProps[h]?f[h]=c[h]:specialProps.has(h)||(p[h]=c[h]);if(a.current&&_oldSyncBehavior)for(var h in l)delete u[h];var updateProps=function(){d&&d.current&&(d.current.props=e.props);updateChildProps();var r=[],n=u;if(o.current&&a.current&&!_oldSyncBehavior){for(var t in o.current)if(a.current[t]){if(a.current[t]._handlersChanged){a.current[t]._cachedHandlersChanged=a.current[t]._handlersChanged;a.current[t]._handlersChanged=null;r.push(a.current[t])}a.current[t].removeHandler(o.current[t])}n=__assign({},u);for(var i in l){delete n[i];a.current[i].addHandler(l[i])}}else if(!o.current){n=__assign({},u);for(var i in l)delete n[i]}o.current=l;if(a.current){copy(a.current,n,!1,!0);for(var s in f)e.customProps[s](a.current,f[s]);!function(){for(var e=0,n=r;e<n.length;e++){var t=n[e];if(t._cachedHandlersChanged){t._handlersChanged=t._cachedHandlersChanged;t._cachedHandlersChanged=null}}r=[]}()}},updateChildProps=function(){i.current=updateChildProperties({controlRef:a,childInfo:i.current},e.props.children)};React.useLayoutEffect((function(){if(t.current&&!a.current){a.current=new e.constructor(t.current,u);e.prePropsInit&&e.prePropsInit(a.current);d&&(isFunction(d)?d({control:a.current,props:e.props}):d.current&&d.current.control==a.current||(d.current={control:a.current,props:e.props}));updateProps();e.initControl&&e.initControl(a.current);e.props.initialized&&setTimeout((function(){a.current&&e.props.initialized(a.current)}))}else s.current&&(s.current=!1);return function(){if(a.current){var e=a.current;s.current=!0;queueMicrotask((function(){if(s.current){e.dispose();a.current=null;i.current={};s.current=!1}}))}}}),[]);a.current&&updateProps();return{renderResult:React.createElement("div",__assign({ref:t},p),[]),wjControl:a.current}}function filterKnownProps(e,r,n){var t={};for(var o in e)(r.has(o)||n.has(o))&&(t[o]=e[o]);return t}function clearAndGetEvents(e,r,n,t){var o=t.current,a={};for(var i in r)n.has(i)&&(a[i]=r[i]);for(var s in o)e[s]&&(!_oldSyncBehavior||r[s]?e[s].removeHandler(o[s]):a[s]=o[s]);return a}function getCustomPropsData(e,r){var n={};for(var t in r)void 0!==e[t]&&(n[t]=e[t]);return n}export function useWjComponentChildBase(e){var r={};r.knowProperties=new Set(e.properties);r.knowEvents=new Set(e.events);e.customProps||(e.customProps={});return{getInstance:function(n){var t={current:{}},o={current:{}},a={current:{}},i=getPropsAccordingToSyncMode(e.props,t.current),s=filterKnownProps(i,r.knowProperties,r.knowEvents),c=getCustomPropsData(i,e.customProps||{}),u=e.customConstructor?e.customConstructor(n,s,c):new e.constructor(e.needParentInstance?n:s,e.needParentInstance?s:void 0);e.ref&&(isFunction(e.ref)?e.ref({control:u,props:e.props}):e.ref.current&&e.ref.current.control==u||(e.ref.current={control:u,props:e.props}));a.current=clearAndGetEvents(u,i,r.knowEvents,a);var updateProps=function(n){var i=getPropsAccordingToSyncMode(n,t.current);t.current=n;e.ref&&e.ref.current&&(e.ref.current.props=n);a.current=clearAndGetEvents(u,i,r.knowEvents,a);var s,c=filterKnownProps(i,r.knowProperties,r.knowEvents);u.initialize?u.initialize(c):copy(u,c,!1,!0);for(var l in e.customProps)void 0!==i[l]&&e.customProps[l](u,i[l]);s=n.children||[],o.current=updateChildProperties({controlRef:{current:u},childInfo:o.current},s)};updateProps(e.props||[]);e.props.initialized&&isFunction(e.props.initialized)&&e.props.initialized(u);return{instance:u,updateProps:updateProps}},props:e.props,parentProp:e.parentProp,wjProperty:e.props.wjProperty,isParentPropArray:e.isParentPropArray,assignedToParent:e.assignedToParent}}var _reactMajorVersion,elemRootMap=[];if(!_reactMajorVersion){var version=parseInt(React.version);_reactMajorVersion=version;version>=18&&lazyImportDomClient()}var flushSyncStateCache={isReactRendering:null};function isReactRendering(){if(null==flushSyncStateCache.isReactRendering)try{var e=console.error,r=!1;console.error=function(){var e=arguments[0]||"";e.includes("flushSync")&&(r=!0)};flushSync((function(){}));console.error=e;flushSyncStateCache.isReactRendering=r}catch(e){}finally{queueMicrotask((function(){flushSyncStateCache.isReactRendering=null}))}return!!flushSyncStateCache.isReactRendering}function getReactDOM(){return ReactDOM}export function selectiveDomRender(e,r,n){void 0===n&&(n=!1);if(_reactMajorVersion<18){(0,getReactDOM().render)(e,r)}else{isReactRendering()&&(n=!0);var t,o=elemRootMap.findIndex((function(e){return e.host===r}));if(-1===o){t=reactDomClient.createRoot(r);elemRootMap.push({host:r,root:t})}else t=elemRootMap[o].root;t.__scheduledForUnmount=!1;n?queueMicrotask((function(){flushSync((function(){t.render(e)}))})):flushSync((function(){t.render(e)}))}return r}function unmountSafely(e){var r=e._internalRoot&&e._internalRoot.containerInfo.firstChild,n=e._internalRoot&&e._internalRoot.current&&e._internalRoot.current.child&&e._internalRoot.current.child.stateNode;n&&r==n?e.unmount():e._internalRoot=null;e.__scheduledForUnmount=null}export function selectiveDomUnmount(e){if(_reactMajorVersion<18){(0,getReactDOM().unmountComponentAtNode)(e)}else{var r=elemRootMap.findIndex((function(r){return r.host===e}));if(-1!==r){var n=elemRootMap[r].root;if(isReactRendering()){n.__scheduledForUnmount=!0;queueMicrotask((function(){n.__scheduledForUnmount&&flushSync((function(){unmountSafely(n);elemRootMap.splice(r,1)}))}))}else flushSync((function(){unmountSafely(n);elemRootMap.splice(r,1)}))}}}export function baseFlushSync(){flushSync((function(){}))}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20242.21
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,77 +11,119 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
|
-
* {@module wijmo.react.base}
|
|
14
|
+
* {@module wijmo.react.base}
|
|
15
15
|
* Contains base classes for all Wijmo for React directives.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
export declare var ___keepComment: any;
|
|
21
|
-
import {
|
|
22
|
-
import * as React from 'react';
|
|
21
|
+
import { CancelEventArgs, Control, EventArgs, IEventHandler } from '@grapecity/wijmo';
|
|
23
22
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
* From 5.20241.19, React interop now supports strict state mode.
|
|
24
|
+
* This means that on each re-render cycle, all of the component properties
|
|
25
|
+
* get synced with their values provided in the JSX.
|
|
26
|
+
* Setting properties via JSX will make that prop externally controlled, and
|
|
27
|
+
* changing its value will be allowed only by updating the state variables passed in JSX.
|
|
28
|
+
*
|
|
29
|
+
* By default, this option is set to false to maintain compatibility with existing user applications.
|
|
30
|
+
* If users want to utilize the Wijmo API in accordance with React's state management philosophy,
|
|
31
|
+
* they can set **strictStateMode** to true.
|
|
32
|
+
*
|
|
33
|
+
* When the strictStateMode flag is false, the value of the underlying component gets synced only when
|
|
34
|
+
* the prop value changes and not when the component re-renders. This makes it possible for JSX to become
|
|
35
|
+
* out of sync with the rendered state.
|
|
36
|
+
*
|
|
37
|
+
* Consider the following: if you set the value on an input control like {@link InputDate} and if strictStateMode
|
|
38
|
+
* is false, it is possible to select a different value in the control. After the value is selected,
|
|
39
|
+
* there is a mismatch between the React-provided state and the rendered state. This leads to potential bugs.
|
|
40
|
+
* That is why React recommends using controlled components. In controlled components, once the value is
|
|
41
|
+
* provided externally via JSX, the control value is not allowed to change unless the externally provided value
|
|
42
|
+
* is changed itself. So in the above scenario (for strictStateMode = true), to be able to change the value,
|
|
43
|
+
* we need to handle the valueChanged event and update the state variable to update the controlled value.
|
|
44
|
+
*
|
|
45
|
+
* ```typescript
|
|
46
|
+
* function App() {
|
|
47
|
+
* const [date, setDate] = useState(new Date());
|
|
48
|
+
*
|
|
49
|
+
* return (
|
|
50
|
+
* <div>
|
|
51
|
+
* <InputDate value={date} valueChanged={(s) => setDate(s.value)} />
|
|
52
|
+
* </div>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param value Whether to use the strict state mode or not
|
|
58
|
+
*/
|
|
59
|
+
export declare function strictStateMode(value?: boolean): void;
|
|
60
|
+
export declare type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
61
|
+
export declare type WjRef<T> = {
|
|
62
|
+
control: T;
|
|
63
|
+
props: any;
|
|
64
|
+
};
|
|
65
|
+
export declare type ControlBaseEvents<T> = {
|
|
66
|
+
gotFocus?: IEventHandler<T, EventArgs>;
|
|
67
|
+
invalidInput?: IEventHandler<T, CancelEventArgs>;
|
|
68
|
+
lostFocus?: IEventHandler<T, EventArgs>;
|
|
69
|
+
refreshed?: IEventHandler<T, EventArgs>;
|
|
70
|
+
refreshing?: IEventHandler<T, EventArgs>;
|
|
71
|
+
};
|
|
72
|
+
export declare type ControlBaseInputs = {
|
|
73
|
+
isDisabled?: boolean;
|
|
74
|
+
tabOrder?: number;
|
|
75
|
+
initialized?: any;
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
children?: any;
|
|
78
|
+
};
|
|
79
|
+
export declare type BaseInputs = {
|
|
80
|
+
initialized?: any;
|
|
81
|
+
ref?: any;
|
|
82
|
+
};
|
|
83
|
+
export declare const ControlBaseMeta: {
|
|
84
|
+
inputs: string[];
|
|
85
|
+
events: string[];
|
|
86
|
+
};
|
|
87
|
+
export declare function useWjComponentBase(initInfo: {
|
|
88
|
+
properties: string[];
|
|
89
|
+
events: string[];
|
|
90
|
+
customProps?: {
|
|
91
|
+
[key: string]: (control: any, value: any) => void;
|
|
92
|
+
};
|
|
93
|
+
constructor: typeof Control;
|
|
36
94
|
props: any;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
protected _siblingId: string;
|
|
42
|
-
protected _hostRef: (ref: any) => any;
|
|
43
|
-
protected _hostRefValue: HTMLElement;
|
|
44
|
-
timer: any;
|
|
95
|
+
ref?: any;
|
|
96
|
+
prePropsInit?: (control: any) => void;
|
|
97
|
+
initControl?: (control: any) => void;
|
|
98
|
+
}): {
|
|
45
99
|
renderResult: any;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
private _getParentProp;
|
|
77
|
-
private _getSiblingIndex;
|
|
78
|
-
private _siblingInserted;
|
|
79
|
-
private _copy;
|
|
80
|
-
private _setHostAttribute;
|
|
81
|
-
private _sameValue;
|
|
82
|
-
private _isEvent;
|
|
83
|
-
protected _getElement(): HTMLElement;
|
|
84
|
-
private _ignoreProp;
|
|
85
|
-
private static _copyAttrs;
|
|
86
|
-
static isInStrictMode(component: any): boolean;
|
|
87
|
-
}
|
|
100
|
+
wjControl: any;
|
|
101
|
+
};
|
|
102
|
+
export declare function useWjComponentChildBase(initInfo: {
|
|
103
|
+
ref?: any;
|
|
104
|
+
properties: string[];
|
|
105
|
+
events: string[];
|
|
106
|
+
constructor: any;
|
|
107
|
+
props: any;
|
|
108
|
+
needParentInstance: boolean;
|
|
109
|
+
parentProp: string;
|
|
110
|
+
isParentPropArray: boolean;
|
|
111
|
+
assignedToParent: boolean;
|
|
112
|
+
customConstructor?: (parent: any, initData: any, customPropData?: any) => any;
|
|
113
|
+
customProps?: {
|
|
114
|
+
[key: string]: (control: any, value: any) => void;
|
|
115
|
+
};
|
|
116
|
+
}): {
|
|
117
|
+
getInstance: (parentProp?: any) => {
|
|
118
|
+
instance: any;
|
|
119
|
+
updateProps: (props: any) => void;
|
|
120
|
+
};
|
|
121
|
+
props: any;
|
|
122
|
+
parentProp: string;
|
|
123
|
+
wjProperty: any;
|
|
124
|
+
isParentPropArray: boolean;
|
|
125
|
+
assignedToParent: boolean;
|
|
126
|
+
};
|
|
127
|
+
export declare function selectiveDomRender(component: any, host: HTMLElement, useMicroTask?: boolean): HTMLElement;
|
|
128
|
+
export declare function selectiveDomUnmount(host?: HTMLElement): void;
|
|
129
|
+
export declare function baseFlushSync(): void;
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20242.21
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}(),__awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function fulfilled(t){try{step(o.next(t))}catch(t){r(t)}}function rejected(t){try{step(o.throw(t))}catch(t){r(t)}}function step(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(fulfilled,rejected)}step((o=o.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function verb(r){return function(a){return function step(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=2&r[0]?o.return:r[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,r[1])).done)return i;(o=0,i)&&(r=[2&r[0],i.value]);switch(r[0]){case 0:case 1:i=r;break;case 4:s.label++;return{value:r[1],done:!1};case 5:s.label++;o=r[1];r=[0];continue;case 7:r=s.ops.pop();s.trys.pop();continue;default:if(!(i=s.trys,i=i.length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1];i=r;break}if(i&&s.label<i[2]){s.label=i[2];s.ops.push(r);break}i[2]&&s.ops.pop();s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t];o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@grapecity/wijmo"),ReactDOM=__importStar(require("react-dom")),React=__importStar(require("react")),flushSyncPolyfill=function(t){t()},createRootPolyfill=function(){throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill},reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){try{t=require("react-dom/client");reactDomClient=t||ReactDOM||ReactDomPolyfill;flushSync=t.flushSync||flushSync}catch(t){reactDomClient=ReactDOM||ReactDomPolyfill}return[2]}))}))}var ComponentBase=function(t){__extends(ComponentBase,t);function ComponentBase(e,n,o){var i=t.call(this,e)||this;i._objPropHash={};i._isMounted=!1;i._mountedCBs=[];i._hostRef=function(t){return i._hostRefValue=t};i._beforeRender=new wijmo_1.Event;i._afterRender=new wijmo_1.Event;i._beforeWillUnmount=new wijmo_1.Event;i._afterWillUnmount=new wijmo_1.Event;i._beforeDidUpdate=new wijmo_1.Event;i._afterDidUpdate=new wijmo_1.Event;if(i._isMounted&&!i._isChild()){clearTimeout(i.timer);return i}if(!ComponentBase._reactMajorVersion){var r=parseInt(React.version);ComponentBase._reactMajorVersion=r;r>=18&&lazyImportDomClient()}i.props=e;i.controlType=n;for(var s=0,a=o&&o.objectProps||[];s<a.length;s++){var p=a[s];i._objPropHash[p]=!0}return i}ComponentBase.prototype.render=function(){this._onBeforeRender();var t=this._renderImpl();this._onAfterRender();this.renderResult=t;if(this._isMounted&&!this._isChild()){clearTimeout(this.timer);return this.renderResult}return t};ComponentBase.prototype.componentDidMount=function(){var t=this;if(this._isMounted){clearTimeout(this.timer);return this.control}if(this._isChild()){var e=this.props[ComponentBase._propsParent];e&&e._mountedCB((function(){t._setParent(e)}))}else this._prepareControl();this._isMounted=!0;return this.control};ComponentBase.selectiveDomRender=function(t,e,n){void 0===n&&(n=!0);if(ComponentBase._reactMajorVersion<18)ReactDOM.render(t,e);else{var o,i=ComponentBase.elemRootMap.findIndex((function(t){return t.host===e}));if(-1===i){o=reactDomClient.createRoot(e);ComponentBase.elemRootMap.push({host:e,root:o})}else o=ComponentBase.elemRootMap[i].root;flushSync((function(){o.render(t)}))}return e};ComponentBase.selectiveDomUnmount=function(t){if(ComponentBase._reactMajorVersion<18)ReactDOM.unmountComponentAtNode(t);else{var e=ComponentBase.elemRootMap.findIndex((function(e){return e.host===t}));if(-1!==e){var n=ComponentBase.elemRootMap[e].root;flushSync((function(){n.unmount();ComponentBase.elemRootMap.splice(e,1)}))}}};ComponentBase.prototype.componentWillUnmount=function(){this._onBeforeWillUnmount();this._siblingInsertedMO&&this._siblingInsertedMO.disconnect();var t=this.control;if(t)if(this._isChild()){var e=this._getParentProp();if(e){var n=this.parent.control[e];if(wijmo_1.isArray(n)){var o=n.indexOf(t);if(o>-1){var i=n[o];"Sheet"===i.constructor.name&&i._isEmptyGrid||n.splice(o,1)}}}}else t instanceof wijmo_1.Control&&(this.timer=setTimeout((function(){if(t.hostElement){t._orgOuter=null;t.dispose()}}),5));this._onAfterWillUnmount()};ComponentBase.prototype.shouldComponentUpdate=function(t){return!0};ComponentBase.prototype.componentDidUpdate=function(t){this._onBeforeDidUpdate();var e=this.control;this._copy(e,this.props,t);this._onAfterDidUpdate()};ComponentBase.prototype._mountedCB=function(t){var e=this;this._isMounted&&!this._isChild()?t():this._isMounted||this._mountedCBs.push(t);setTimeout((function(){e._mountedCBs.includes(t)||e._mountedCBs.push(t)}),wijmo_1.isSafari?200:10)};ComponentBase.prototype._renderImpl=function(){var t={};t[ComponentBase._propsParent]=this;var e=React.Children.map(this.props.children,(function(e){return e&&React.cloneElement(e,t)})),n={ref:this._hostRef};this._isChild()&&(n.style={display:"none"});return React.createElement("div",n,e)};ComponentBase.prototype._onBeforeRender=function(t){this._beforeRender.raise(this,t)};ComponentBase.prototype._onAfterRender=function(t){this._afterRender.raise(this,t)};ComponentBase.prototype._onBeforeWillUnmount=function(t){this._beforeWillUnmount.raise(this,t)};ComponentBase.prototype._onAfterWillUnmount=function(t){this._afterWillUnmount.raise(this,t)};ComponentBase.prototype._onBeforeDidUpdate=function(t){this._beforeDidUpdate.raise(this,t)};ComponentBase.prototype._onAfterDidUpdate=function(t){this._afterDidUpdate.raise(this,t)};ComponentBase.prototype._createControl=function(){var t=this._isChild()?this._isParentInCtor()?this.parent.control:void 0:this._getElement();t instanceof Element&&this.props.id&&t.setAttribute("id",this.props.id);var e=new this.controlType(t);e.workingAs="React";return e};ComponentBase.prototype._prepareControl=function(){var t=this;this._renderImpl();var e=this._getElement(),n=this.props;e&&!this._isChild()&&ComponentBase._copyAttrs(e,n,wijmo_1.Control._rxInputAtts);var o=this.control=this._createControl(),i=o instanceof wijmo_1.Control,r=ComponentBase;e=this._getElement();if(!this._siblingId){null==this.constructor[r._typeSiblingIdProp]&&(this.constructor[r._typeSiblingIdProp]=++r._siblingDirId+"");this._siblingId=this.constructor[r._typeSiblingIdProp]}if(e){e.setAttribute(r._typeSiblingIdProp,this._siblingId);var s={};for(var a in n){var p=n[a];this._ignoreProp(a)||wijmo_1.isUndefined(p)||(a in o?s[a]=p:this._setHostAttribute(e,a,p))}i?o.initialize(s):this._copy(o,s,null,!0);setTimeout((function(){var e=t._mountedCBs;for(var i in e){e[i]();delete e[i]}wijmo_1.isFunction(n.initialized)&&n.initialized(o);t._isMounted=!0}),wijmo_1.isSafari?201:100)}};ComponentBase.prototype._initParent=function(){if(this._getElement()){var t=this._getParentProp();if(t){var e=this.parent.control,n=e[t];if(wijmo_1.isArray(n)){var o=this._getSiblingIndex();(o<0||o>=n.length)&&(o=n.length);n.splice(o,0,this.control);var i=this._getElement();this._siblingInsertedMO=new MutationObserver(this._siblingInserted.bind(this));this._siblingInsertedMO.observe(i,{childList:!0})}else e[t]=this.control}}};ComponentBase.prototype._setParent=function(t){if(t!==this.parent){if(this.parent)throw"Wijmo child component is already attached to a different parent.";this.parent=t;this._prepareControl();this._initParent()}};ComponentBase.prototype._isChild=function(){return null!=this._parentProp||null!=this._parentInCtor};ComponentBase.prototype._isParentInCtor=function(){return!0===this._parentInCtor};ComponentBase.prototype._getParentProp=function(){return this.props.wjProperty||this._parentProp};ComponentBase.prototype._getSiblingIndex=function(){var t=this._getElement(),e=t.parentElement;if(!e)return-1;for(var n=e.childNodes,o=-1,i=this._siblingId,r=0;r<n.length;r++){var s=n[r];if(1==s.nodeType&&s.getAttribute(ComponentBase._typeSiblingIdProp)==i){++o;if(s===t)return o}}return-1};ComponentBase.prototype._siblingInserted=function(t){for(var e=this,n=0,o=t;n<o.length;n++){var i=o[n];if("childList"===i.type&&i.addedNodes.length>0){if(Array.from(i.addedNodes).some((function(t){return t===e._getElement()}))){var r=this._getSiblingIndex(),s=this.control,a=this.parent.control[this._getParentProp()],p=a.indexOf(s);if(r>=0&&p>=0&&r!==p){a.splice(p,1);var l=Math.min(r,a.length);a.splice(l,0,s)}}}}};ComponentBase.prototype._copy=function(t,e,n,o){void 0===o&&(o=!1);if(t&&e){var i,r=t===this.control;for(var s in e)if(!this._ignoreProp(s)||!r){var a=e[s];if(s in t){if(this._isEvent(t,s))o&&wijmo_1.isFunction(a)&&t[s].addHandler(a);else if(!n||!this._sameValue(n[s],a))if(null==a)t[s]=a;else if(wijmo_1.isPrimitive(a)||wijmo_1.isFunction(a)||this._objPropHash[s]&&t===(i||(i=this.control)))t[s]=a;else if(wijmo_1.isArray(a)&&wijmo_1.isArray(t[s])){var p=t[s],l=a;if(l.length==p.length)for(var u=0;u<l.length;u++){if(l[u]!==p[u])return!1;this._copy(p[u],l[u])}}else wijmo_1.isObject(a)&&this._copy(t[s],e[s])}else this._setHostAttribute(t.hostElement,s,e[s])}}};ComponentBase.prototype._setHostAttribute=function(t,e,n){if(t)switch(e){case"className":var o=this._appliedClassName;if(o!==n){wijmo_1.removeClass(t,o);wijmo_1.addClass(t,n);this._appliedClassName=n}break;case"style":wijmo_1.setCss(t,n);break;default:null!=t[e]?t[e]=n:"string"==typeof n&&"$"!==e[0]&&t.setAttribute(e,n)}};ComponentBase.prototype._sameValue=function(t,e){return t==e||wijmo_1.DateTime.equals(t,e)};ComponentBase.prototype._isEvent=function(t,e){var n=t&&t[e];return null!=n&&n instanceof wijmo_1.Event};ComponentBase.prototype._getElement=function(){return this._hostRefValue};ComponentBase.prototype._ignoreProp=function(t){return"children"===t};ComponentBase._copyAttrs=function(t,e,n){if(t)for(var o in e)o.match(n)&&t.setAttribute(o,e[o])};ComponentBase.isInStrictMode=function(t){return!!(t.hasOwnProperty("_reactInternalFiber")&&1&t._reactInternalFiber.mode)};ComponentBase._propsParent="$parent";ComponentBase._typeSiblingIdProp="_wjSiblingIdProp";ComponentBase._siblingDirId=0;ComponentBase.elemRootMap=[];return ComponentBase}(React.Component);exports.ComponentBase=ComponentBase;
|
|
14
|
+
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++){r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,r,n,t){return new(n||(n=Promise))((function(o,i){function fulfilled(e){try{step(t.next(e))}catch(e){i(e)}}function rejected(e){try{step(t.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):new n((function(r){r(e.value)})).then(fulfilled,rejected)}step((t=t.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var n,t,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(a){return function step(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,t&&(o=2&i[0]?t.return:i[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,i[1])).done)return o;(t=0,o)&&(i=[2&i[0],o.value]);switch(i[0]){case 0:case 1:o=i;break;case 4:s.label++;return{value:i[1],done:!1};case 5:s.label++;t=i[1];i=[0];continue;case 7:i=s.ops.pop();s.trys.pop();continue;default:if(!(o=s.trys,o=o.length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1];o=i;break}if(o&&s.label<o[2]){s.label=o[2];s.ops.push(i);break}o[2]&&s.ops.pop();s.trys.pop();continue}i=r.call(e,s)}catch(e){i=[6,e];t=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(r[n]=e[n]);r.default=e;return r};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@grapecity/wijmo"),ReactDOM=__importStar(require("react-dom")),React=__importStar(require("react")),flushSyncPolyfill=function(e){e()},createRootPolyfill=function(){throw"Wijmo: React dependencies not loaded properly"},ReactDomPolyfill={flushSync:flushSyncPolyfill,createRoot:createRootPolyfill},reactDomClient=ReactDOM||ReactDomPolyfill,flushSync=reactDomClient.flushSync;function lazyImportDomClient(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(r){try{e=require("react-dom/client");reactDomClient=e||ReactDOM||ReactDomPolyfill;flushSync=e.flushSync||flushSync}catch(e){reactDomClient=ReactDOM||ReactDomPolyfill}return[2]}))}))}var _oldSyncBehavior=!0;function strictStateMode(e){void 0===e&&(e=!1);e==_oldSyncBehavior&&(_oldSyncBehavior=!wijmo_1.asBoolean(e,!1))}exports.strictStateMode=strictStateMode;exports.ControlBaseMeta={inputs:["isDisabled","tabOrder"],events:["gotFocus","invalidInput","lostFocus","refreshed","refreshing"]};var alwaysClearProps=new Set(["columns","columnGroups"]),unsuppressedChangedEventProps=new Set(["panes","columnGroups","columns","items"]),specialProps=new Set(["initialized","wjItemTemplate"]);function updateChildProperties(e,r){var n=e.controlRef.current,t={},o={};if(r){for(var i=wijmo_1.isArray(r)?r.flat(1/0):[r],s=[],a=0,c=new Set,u=0,l=i;u<l.length;u++){if((g=l[u])&&g.type&&g.type.$$typeof==Symbol.for("react.forward_ref")){s.push(g.type.render(g.props,g.ref));s[s.length-1].$index=a;s[s.length-1].$key=g.key}else if(g&&wijmo_1.isFunction(g.type)){s.push(g.type(g.props));s[s.length-1].$index=a;s[s.length-1].$key=g.key}g||c.add(a);a++}for(var p=[],f=0,d=s;f<d.length;f++){if((g=d[f]).assignedToParent){if(g.wjProperty){g.parentProp=wijmo_1.asString(g.wjProperty);g.isParentPropArray=n[g.parentProp]&&wijmo_1.isArray(n[g.parentProp])}g.isParentPropArray&&!t[g.parentProp]&&(t[g.parentProp]=[]);g.isParentPropArray?t[g.parentProp].push({getInstance:g.getInstance,props:g.props,$key:g.$key,$index:g.$index}):t[g.parentProp]={getInstance:g.getInstance,props:g.props}}else p.push(g)}var h=e.childInfo,_loop_1=function(e){if(wijmo_1.isArray(t[e])){var r=!1;if(n[e]&&null!=n[e]._updating&&!unsuppressedChangedEventProps.has(e)){n[e]._updating++;r=!0}var i=h[e];o[e]=[];if(!h[e]){i=[];n[e]&&n[e].clear?n[e].clear():n[e]||(n[e]=new wijmo_1.ObservableArray)}!_oldSyncBehavior&&alwaysClearProps.has(e)&&n[e]&&n[e].clear&&n[e].clear();if(_oldSyncBehavior)for(var s=i.length-1;s>=0;s--)if(c.has(i[s].$index)){n[e].remove(i[s].instance);i.splice(s,1)}for(var a=[],u={},l=0,p=i;l<p.length;l++){var f=p[l];null!=f.$key?u[""+f.$key]=f:a.push(f)}for(var d=0,getExistingInstance=function(e){void 0===e&&(e=null);if(null!=e){var r=u[e];null!=r&&delete u[e];return r}return a[d++]},v=0;v<t[e].length;v++){var y=!1;if(P=getExistingInstance(t[e][v].$key))P.updateProps(t[e][v].props);else{P=t[e][v].getInstance(n);y=!0}P.$index=t[e][v].$index;P.$key=t[e][v].$key;(!_oldSyncBehavior&&alwaysClearProps.has(e)||y)&&(n[e].length==v?n[e].push(P.instance):n[e].splice(v,0,P.instance));o[e].push(P)}for(var m=0,_=Object.keys(u);m<_.length;m++){var g=_[m];n[e].remove(u[g].instance)}for(;!_oldSyncBehavior&&n[e].length>o[e].length;)n[e].pop();if(r){n[e]._updating--;h[e]&&h[e].length==t[e].length||n[e]._raiseCollectionChanged&&n[e]._raiseCollectionChanged()}}else{var P;if(P=h[e])P.updateProps(t[e].props);else{P=t[e].getInstance(n);n[e]=P.instance}o[e]=P}};for(var v in t)_loop_1(v);for(var y=[],m=0,_=h.$_nonassignable||[];m<_.length;m++){var g=_[m];c.has(g.$index)?g.instance&&g.instance.dispose&&wijmo_1.isFunction(g.instance.dispose)&&g.instance.dispose():y.push(g)}for(var P=[],w=0;w<p.length;w++){var R=y[w];R?R.updateProps(p[w].props):R=p[w].getInstance(n);R.$index=p[w].$index;P.push(R)}o.$_nonassignable=P;for(;w<y.length;w++)y[w].instance&&y[w].instance.dispose&&wijmo_1.isFunction(y[w].instance.dispose)&&y[w].instance.dispose()}if(_oldSyncBehavior)for(var S=0,C=Object.keys(e.childInfo);S<C.length;S++){var j=C[S];if(wijmo_1.isArray(e.childInfo[j])&&!t[j]&&n[j]&&n[j].remove)for(var k=0,b=e.childInfo[j];k<b.length;k++){var M=b[k];n[j].remove(M.instance)}}return o}function getPropsAccordingToSyncMode(e,r,n){void 0===n&&(n=null);if(!r||!_oldSyncBehavior){return __assign({},e)}var t={};for(var o in e){var i=!1;n&&(i=n.knowProperties.has(o)||n.knowEvents.has(o)||n.knowCustomProps.has(o));(n&&!i||e[o]!==r[o])&&(t[o]=e[o])}return t}function useWjComponentBase(e){var r=React.useRef({}),n=React.useRef(),t=React.useRef(),o=React.useRef(),i=React.useRef(),s=React.useRef({}),a=React.useRef(!1);e.customProps||(e.customProps={});if(!n.current){n.current={};n.current.knowProperties=new Set(e.properties);n.current.knowEvents=new Set(e.events);n.current.knowCustomProps=new Set(Object.keys(e.customProps))}var c=e.props;if(i.current){c=getPropsAccordingToSyncMode(e.props,r.current,n.current);r.current=e.props}var u={},l={},p={},f={},d=e.ref||null;for(var h in c)if(n.current.knowProperties.has(h))u[h]=c[h];else if(n.current.knowEvents.has(h)){l[h]=c[h];u[h]=c[h]}else e.customProps[h]?f[h]=c[h]:specialProps.has(h)||(p[h]=c[h]);if(i.current&&_oldSyncBehavior)for(var h in l)delete u[h];var updateProps=function(){d&&d.current&&(d.current.props=e.props);updateChildProps();var r=[],n=u;if(o.current&&i.current&&!_oldSyncBehavior){for(var t in o.current)if(i.current[t]){if(i.current[t]._handlersChanged){i.current[t]._cachedHandlersChanged=i.current[t]._handlersChanged;i.current[t]._handlersChanged=null;r.push(i.current[t])}i.current[t].removeHandler(o.current[t])}n=__assign({},u);for(var s in l){delete n[s];i.current[s].addHandler(l[s])}}else if(!o.current){n=__assign({},u);for(var s in l)delete n[s]}o.current=l;if(i.current){wijmo_1.copy(i.current,n,!1,!0);for(var a in f)e.customProps[a](i.current,f[a]);!function(){for(var e=0,n=r;e<n.length;e++){var t=n[e];if(t._cachedHandlersChanged){t._handlersChanged=t._cachedHandlersChanged;t._cachedHandlersChanged=null}}r=[]}()}},updateChildProps=function(){s.current=updateChildProperties({controlRef:i,childInfo:s.current},e.props.children)};React.useLayoutEffect((function(){if(t.current&&!i.current){i.current=new e.constructor(t.current,u);e.prePropsInit&&e.prePropsInit(i.current);d&&(wijmo_1.isFunction(d)?d({control:i.current,props:e.props}):d.current&&d.current.control==i.current||(d.current={control:i.current,props:e.props}));updateProps();e.initControl&&e.initControl(i.current);e.props.initialized&&setTimeout((function(){i.current&&e.props.initialized(i.current)}))}else a.current&&(a.current=!1);return function(){if(i.current){var e=i.current;a.current=!0;queueMicrotask((function(){if(a.current){e.dispose();i.current=null;s.current={};a.current=!1}}))}}}),[]);i.current&&updateProps();return{renderResult:React.createElement("div",__assign({ref:t},p),[]),wjControl:i.current}}exports.useWjComponentBase=useWjComponentBase;function filterKnownProps(e,r,n){var t={};for(var o in e)(r.has(o)||n.has(o))&&(t[o]=e[o]);return t}function clearAndGetEvents(e,r,n,t){var o=t.current,i={};for(var s in r)n.has(s)&&(i[s]=r[s]);for(var a in o)e[a]&&(!_oldSyncBehavior||r[a]?e[a].removeHandler(o[a]):i[a]=o[a]);return i}function getCustomPropsData(e,r){var n={};for(var t in r)void 0!==e[t]&&(n[t]=e[t]);return n}function useWjComponentChildBase(e){var r={};r.knowProperties=new Set(e.properties);r.knowEvents=new Set(e.events);e.customProps||(e.customProps={});return{getInstance:function(n){var t={current:{}},o={current:{}},i={current:{}},s=getPropsAccordingToSyncMode(e.props,t.current),a=filterKnownProps(s,r.knowProperties,r.knowEvents),c=getCustomPropsData(s,e.customProps||{}),u=e.customConstructor?e.customConstructor(n,a,c):new e.constructor(e.needParentInstance?n:a,e.needParentInstance?a:void 0);e.ref&&(wijmo_1.isFunction(e.ref)?e.ref({control:u,props:e.props}):e.ref.current&&e.ref.current.control==u||(e.ref.current={control:u,props:e.props}));i.current=clearAndGetEvents(u,s,r.knowEvents,i);var updateProps=function(n){var s=getPropsAccordingToSyncMode(n,t.current);t.current=n;e.ref&&e.ref.current&&(e.ref.current.props=n);i.current=clearAndGetEvents(u,s,r.knowEvents,i);var a,c=filterKnownProps(s,r.knowProperties,r.knowEvents);u.initialize?u.initialize(c):wijmo_1.copy(u,c,!1,!0);for(var l in e.customProps)void 0!==s[l]&&e.customProps[l](u,s[l]);a=n.children||[],o.current=updateChildProperties({controlRef:{current:u},childInfo:o.current},a)};updateProps(e.props||[]);e.props.initialized&&wijmo_1.isFunction(e.props.initialized)&&e.props.initialized(u);return{instance:u,updateProps:updateProps}},props:e.props,parentProp:e.parentProp,wjProperty:e.props.wjProperty,isParentPropArray:e.isParentPropArray,assignedToParent:e.assignedToParent}}exports.useWjComponentChildBase=useWjComponentChildBase;var _reactMajorVersion,elemRootMap=[];if(!_reactMajorVersion){var version=parseInt(React.version);_reactMajorVersion=version;version>=18&&lazyImportDomClient()}var flushSyncStateCache={isReactRendering:null};function isReactRendering(){if(null==flushSyncStateCache.isReactRendering)try{var e=console.error,r=!1;console.error=function(){var e=arguments[0]||"";e.includes("flushSync")&&(r=!0)};flushSync((function(){}));console.error=e;flushSyncStateCache.isReactRendering=r}catch(e){}finally{queueMicrotask((function(){flushSyncStateCache.isReactRendering=null}))}return!!flushSyncStateCache.isReactRendering}function getReactDOM(){return ReactDOM}function selectiveDomRender(e,r,n){void 0===n&&(n=!1);if(_reactMajorVersion<18){(0,getReactDOM().render)(e,r)}else{isReactRendering()&&(n=!0);var t,o=elemRootMap.findIndex((function(e){return e.host===r}));if(-1===o){t=reactDomClient.createRoot(r);elemRootMap.push({host:r,root:t})}else t=elemRootMap[o].root;t.__scheduledForUnmount=!1;n?queueMicrotask((function(){flushSync((function(){t.render(e)}))})):flushSync((function(){t.render(e)}))}return r}exports.selectiveDomRender=selectiveDomRender;function unmountSafely(e){var r=e._internalRoot&&e._internalRoot.containerInfo.firstChild,n=e._internalRoot&&e._internalRoot.current&&e._internalRoot.current.child&&e._internalRoot.current.child.stateNode;n&&r==n?e.unmount():e._internalRoot=null;e.__scheduledForUnmount=null}function selectiveDomUnmount(e){if(_reactMajorVersion<18){(0,getReactDOM().unmountComponentAtNode)(e)}else{var r=elemRootMap.findIndex((function(r){return r.host===e}));if(-1!==r){var n=elemRootMap[r].root;if(isReactRendering()){n.__scheduledForUnmount=!0;queueMicrotask((function(){n.__scheduledForUnmount&&flushSync((function(){unmountSafely(n);elemRootMap.splice(r,1)}))}))}else flushSync((function(){unmountSafely(n);elemRootMap.splice(r,1)}))}}}exports.selectiveDomUnmount=selectiveDomUnmount;function baseFlushSync(){flushSync((function(){}))}exports.baseFlushSync=baseFlushSync;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grapecity/wijmo.react.base",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20242.21",
|
|
4
4
|
"description": "UI library for pure JS, Angular, React, Vue and more...",
|
|
5
5
|
"author": "MESCIUS inc",
|
|
6
6
|
"license": "Commercial",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./index.d.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@grapecity/wijmo": "5.
|
|
10
|
+
"@grapecity/wijmo": "5.20242.21"
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://developer.mescius.com/wijmo",
|
|
13
13
|
"bugs": {
|