@aliretail/cuckoo-official-retailforce-form-icon-bar
Version:
official-retailforce-form-icon-bar
2 lines (1 loc) • 10.4 kB
JavaScript
define("@aliretail/cuckoo-official-retailforce-form-icon-bar", [], function(require, exports, module) {module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function t(){return e.default}:function t(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="./dist/",n(n.s=3)}([function(e,t){e.exports=require("react")},function(e,t,n){var r,o;e.exports=n(6)()},function(e,t){e.exports=require("@alifd/next")},function(e,t,n){e.exports=n(4)},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),a=n(1),i=n.n(a),c=n(2),u=n.n(c),l=n(5),s=n.n(l);function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e){return y(e)||m(e)||b(e)||p()}function p(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function y(e){if(Array.isArray(e))return v(e)}function h(e,t){return O(e)||x(e,t)||b(e,t)||g()}function g(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function b(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,t):void 0}}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(r.push(i.value),!t||r.length!==t);o=!0);}catch(e){a=!0,c=e}finally{try{o||null==n.return||n.return()}finally{if(a)throw c}}return r}}function O(e){if(Array.isArray(e))return e}function S(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function j(e,t,n){return t&&k(e.prototype,t),n&&k(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function D(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P(e,t)}function P(e,t){return(P=Object.setPrototypeOf||function e(t,n){return t.__proto__=n,t})(e,t)}function I(e){var t=_();return function n(){var r=E(e),o;if(t){var a=E(this).constructor;o=Reflect.construct(r,arguments,a)}else o=r.apply(this,arguments);return w(this,o)}}function w(e,t){if(t&&("object"===f(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return R(e)}function R(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)})(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=[{id:"prize",icon:"https://gw.alicdn.com/imgextra/i4/O1CN01N2jkQh1IX9vxzse9c_!!6000000000902-2-tps-84-84.png",text:"\u6211\u7684\u5956\u54c1",link:"prize"},{id:"address",icon:"https://gw.alicdn.com/imgextra/i3/O1CN01wKJCyJ1hB3Cyvj24o_!!6000000004238-2-tps-84-84.png",text:"\u6211\u7684\u5730\u5740",link:"address"},{id:"information",icon:"https://gw.alicdn.com/imgextra/i3/O1CN01Jxs3Bg23ZFgc33umH_!!6000000007269-2-tps-84-84.png",text:"\u6211\u7684\u8d44\u6599",link:"information"},{id:"comment",icon:"https://gw.alicdn.com/imgextra/i3/O1CN014V28nU274nr9tS8Gv_!!6000000007744-2-tps-168-168.png",text:"\u6211\u7684\u8bc4\u4ef7",link:"comment"}],T=function(e){D(n,e);var t=I(n);function n(e){var r;return S(this,n),C(R(r=t.call(this,e)),"formatSortList",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];console.log("\u83b7\u53d6\u5230\u7684list",e,N);var t=JSON.parse(JSON.stringify(N)),n=[];return e&&e.length&&e.forEach((function(e){var r=t.findIndex((function(t){return t.id===e.id})),o,a,i=h(t.splice(r,1),1)[0];i&&n.push(i)})),console.log("\u6839\u636e value \u6392\u5e8f\u540e\u7684\u53ef\u9009\u9879",[].concat(n,d(t))),[].concat(n,d(t))})),C(R(r),"formatValue",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map((function(e){return e.id}))})),C(R(r),"onCheckboxChange",(function(e){var t=[];r.state.sortList.forEach((function(n){var r;e.findIndex((function(e){return e===n.id}))>-1&&t.push(n)})),r.props.change(t),console.log("checkboxValue",e,"dataValue",t),r.setState({checkboxValue:e})})),C(R(r),"handleDragStart",(function(e,t){r.dragItemRef.current=t,console.log("=====handleDragStart",e,r.dragItemRef),e.stopPropagation()})),C(R(r),"handleDragEnd",(function(e){console.log("=====handleDragEnd",e),e.preventDefault()})),C(R(r),"handleDragOver",(function(e){e.preventDefault(),e.stopPropagation();var t=e.target.dataset.id;console.log("======handleDragOver",t),t&&r.setState({activeId:t})})),C(R(r),"handleDrop",(function(e){e.preventDefault(),console.log("======handleDrop",e);var t=r.state.sortList,n=e.target.dataset.id;if(n){var o=r.dragItemRef.current.id||r.dragItemRef.current.id,a=t.findIndex((function(e){return e.id===o})),i=t.filter((function(e){return e.id!==o})),c=i.findIndex((function(e){return e.id===n}));a>c?i.splice(c,0,r.dragItemRef.current):i.splice(c+1,0,r.dragItemRef.current),console.log("filterSortList",i);var u=r.state.checkboxValue,l=[],s=[];console.log(u),i.forEach((function(e){var t;u.findIndex((function(t){return t===e.id}))>-1&&(l.push(e.id),s.push(e))})),r.props.change(s),console.log("checkboxValue",l,"dataValue",s),r.setState({sortList:i,activeId:void 0,checkboxValue:u})}})),r.state={sortList:r.formatSortList(e.moduleData[e.dataName]||e.extension.value||e.extension.defaultValue),activeId:void 0,dataName:e.dataName,checkboxValue:r.formatValue(e.moduleData[e.dataName]||e.extension.value||e.extension.defaultValue),value:e.moduleData[e.dataName]||e.extension.value||e.extension.defaultValue},r.dragItemRef=o.a.createRef(),r.dropAreaRef=o.a.createRef(),r}return j(n,[{key:"componentWillReceiveProps",value:function e(t){var n=this.state.dataName;console.log("componentWillReceiveProps nextProps ->",t),console.log("componentWillReceiveProps this.props ->",this.props),console.log("componentWillReceiveProps state ->",this.state);var r=this.props.moduleData[n],o=t.moduleData[n];console.log({"this.props.moduleData.nav":r,"nextProps.moduleData.nav":o}),r||o?o!==r&&this.setState({value:o}):this.props.change(N)}},{key:"render",value:function e(){var t=this,n=this.state,r=n.checkboxValue,a=n.sortList,i=n.activeId,u=this.props.style;return o.a.createElement("div",{className:"cuk-input-con",ref:this.dropAreaRef,onDragOver:this.handleDragOver,onDragEnd:this.handleDragEnd,onDrop:this.handleDrop,style:u},o.a.createElement(c.Checkbox.Group,{className:"icon-checkbox","aria-labelledby":"groupId",direction:"ver",value:r,onChange:this.onCheckboxChange},a.map((function(e){return o.a.createElement(c.Checkbox,{key:e.id,className:"icon-checkbox-item",id:e.id,value:e.id},o.a.createElement("div",{className:"icon-checkbox-item-context ".concat(i===e.id?"icon-checkbox-item-context-active":""),"data-id":e.id,onDragStart:function n(r){return t.handleDragStart(r,e)},draggable:!0},o.a.createElement("div",{className:"icon-checkbox-item-left","data-id":e.id,draggable:!1},o.a.createElement("img",{className:"icon-checkbox-item-img","data-id":e.id,draggable:!1,src:e.icon}),e.text),o.a.createElement(c.Icon,{type:"drag","data-id":e.id,draggable:!1,size:"xs"})))}))))}}]),n}(o.a.Component);t.default=T,T.propTypes={style:i.a.object,extension:i.a.object,value:i.a.oneOfType([i.a.string,i.a.object,i.a.array,i.a.bool,i.a.number]),change:i.a.func.isRequired},T.defaultProps={style:{},extension:{},value:null}},function(e,t,n){},function(e,t,n){"use strict";var r=n(7);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,i){if(i!==r){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";var r="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=r}]);;if ('default' in module.exports && Object.keys(module.exports).length === 2) { var m = module; m.exports = m.exports.default; m.exports.default = m.exports;}});