Repository: myliang/x-spreadsheet Branch: master Commit: 0c55f3ee1e70 Files: 143 Total size: 998.7 KB Directory structure: gitextract_treep73p/ ├── .babelrc ├── .eslintignore ├── .eslintrc.js ├── .github/ │ └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── LICENSE ├── build/ │ ├── locale_loader.js │ ├── webpack.config.js │ ├── webpack.dev.js │ ├── webpack.locale.js │ └── webpack.prod.js ├── dist/ │ ├── index.html │ ├── locale/ │ │ ├── de.js │ │ ├── en.js │ │ ├── nl.js │ │ └── zh-cn.js │ ├── xspreadsheet.css │ └── xspreadsheet.js ├── docs/ │ ├── dist/ │ │ ├── index.html │ │ ├── locale/ │ │ │ ├── de.js │ │ │ ├── en.js │ │ │ ├── nl.js │ │ │ └── zh-cn.js │ │ ├── xspreadsheet.css │ │ └── xspreadsheet.js │ ├── index.html │ ├── locale/ │ │ ├── de.js │ │ ├── en.js │ │ ├── nl.js │ │ └── zh-cn.js │ ├── xspreadsheet.css │ └── xspreadsheet.js ├── index.html ├── npmx.txt ├── package.json ├── readme.md ├── src/ │ ├── algorithm/ │ │ ├── bitmap.js │ │ └── expression.js │ ├── canvas/ │ │ ├── draw.js │ │ └── draw2.js │ ├── component/ │ │ ├── border_palette.js │ │ ├── bottombar.js │ │ ├── button.js │ │ ├── calendar.js │ │ ├── color_palette.js │ │ ├── contextmenu.js │ │ ├── datepicker.js │ │ ├── dropdown.js │ │ ├── dropdown_align.js │ │ ├── dropdown_border.js │ │ ├── dropdown_color.js │ │ ├── dropdown_font.js │ │ ├── dropdown_fontsize.js │ │ ├── dropdown_format.js │ │ ├── dropdown_formula.js │ │ ├── dropdown_linetype.js │ │ ├── editor.js │ │ ├── element.js │ │ ├── event.js │ │ ├── form_field.js │ │ ├── form_input.js │ │ ├── form_select.js │ │ ├── icon.js │ │ ├── message.js │ │ ├── modal.js │ │ ├── modal_validation.js │ │ ├── print.js │ │ ├── resizer.js │ │ ├── scrollbar.js │ │ ├── selector.js │ │ ├── sheet.js │ │ ├── sort_filter.js │ │ ├── suggest.js │ │ ├── table.js │ │ ├── toolbar/ │ │ │ ├── align.js │ │ │ ├── autofilter.js │ │ │ ├── bold.js │ │ │ ├── border.js │ │ │ ├── clearformat.js │ │ │ ├── dropdown_item.js │ │ │ ├── fill_color.js │ │ │ ├── font.js │ │ │ ├── font_size.js │ │ │ ├── format.js │ │ │ ├── formula.js │ │ │ ├── freeze.js │ │ │ ├── icon_item.js │ │ │ ├── index.js │ │ │ ├── italic.js │ │ │ ├── item.js │ │ │ ├── merge.js │ │ │ ├── more.js │ │ │ ├── paintformat.js │ │ │ ├── print.js │ │ │ ├── redo.js │ │ │ ├── strike.js │ │ │ ├── text_color.js │ │ │ ├── textwrap.js │ │ │ ├── toggle_item.js │ │ │ ├── underline.js │ │ │ ├── undo.js │ │ │ └── valign.js │ │ ├── toolbar.js │ │ └── tooltip.js │ ├── config.js │ ├── core/ │ │ ├── _.prototypes.js │ │ ├── alphabet.js │ │ ├── auto_filter.js │ │ ├── cell.js │ │ ├── cell_range.js │ │ ├── clipboard.js │ │ ├── col.js │ │ ├── data_proxy.js │ │ ├── font.js │ │ ├── format.js │ │ ├── formula.js │ │ ├── helper.js │ │ ├── history.js │ │ ├── merge.js │ │ ├── row.js │ │ ├── scroll.js │ │ ├── selector.js │ │ ├── validation.js │ │ └── validator.js │ ├── index.d.ts │ ├── index.js │ ├── index.less │ └── locale/ │ ├── de.js │ ├── en.js │ ├── locale.js │ ├── nl.js │ └── zh-cn.js └── test/ ├── core/ │ ├── alphabet_test.js │ ├── cell_range_test.js │ ├── cell_test.js │ ├── font_test.js │ ├── format_test.js │ └── formula_test.js ├── helper_test.js ├── index_test.js └── locale/ └── locale_test.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .babelrc ================================================ { "presets": ["@babel/preset-env"], "plugins": ["@babel/plugin-proposal-class-properties"], } ================================================ FILE: .eslintignore ================================================ build dist ================================================ FILE: .eslintrc.js ================================================ module.exports = { "extends": "airbnb-base", "rules": { "no-param-reassign": ["error", { "props": false }], "class-methods-use-this": "off", "no-restricted-syntax": ["error", "WithStatement"], "quotes": ["error", "single", { "allowTemplateLiterals": true }], "no-console": "off" }, }; ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: x-spreadsheet # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .gitignore ================================================ node_modules yarn.lock .nyc_output/* ================================================ FILE: .travis.yml ================================================ language: node_js node_js: - 10.12.0 branches: only: - master install: - npm install -g istanbul - npm install before_script: script: - npm run build - npm run test - npm run coverage after_script: - cp ./dist/* ./docs/ -r ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at liangyuliang0335@126.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 myliang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: build/locale_loader.js ================================================ const path = require('path'); function getLocaleCode(name, code) { return `${code.replace('export default', 'const message =')} if (window && window.x_spreadsheet) { window.x_spreadsheet.$messages = window.x_spreadsheet.$messages || {}; window.x_spreadsheet.$messages['${name}'] = message; } export default message; `; } module.exports = require('babel-loader').custom(babel => { return { result(result, { options }) { // console.log('options:', options); const lang = path.basename(options.filename, '.js'); result.code = getLocaleCode(lang, result.code); return result; }, }; }); ================================================ FILE: build/webpack.config.js ================================================ const path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const resolve = dir => path.join(__dirname, '..', dir); module.exports = { entry: { xspreadsheet: './src/index.js', }, module: { rules: [ { test: /\.js$/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], } }, include: [resolve('src'), resolve('test')], }, { test: /\.css$/, use: [ MiniCssExtractPlugin.loader, 'style-loader', 'css-loader', ], }, { test: /\.less$/, use: [ MiniCssExtractPlugin.loader, 'css-loader', 'less-loader', ], }, { test: /\.(png|svg|jpg|gif)$/, use: [ 'file-loader', ], }, { test: /\.(woff|woff2|eot|ttf|otf)$/, use: [ 'file-loader', ], }, ], }, }; ================================================ FILE: build/webpack.dev.js ================================================ const merge = require('webpack-merge'); const common = require('./webpack.config.js'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = merge(common, { mode: 'development', plugins: [ new CleanWebpackPlugin(['dist']), // you should know that the HtmlWebpackPlugin by default will generate its own index.html new HtmlWebpackPlugin({ template: './index.html', title: 'x-spreadsheet', }), new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output // both options are optional filename: '[name].[contenthash].css', // chunkFilename: devMode ? '[id].[hash].css' : '[id].css', }), ], output: { filename: '[name].[contenthash].js', }, devtool: 'inline-source-map', devServer: { host: 'localhost', contentBase: '../dist', }, }); ================================================ FILE: build/webpack.locale.js ================================================ const path = require('path'); const fs = require('fs'); const localeFiles = fs.readdirSync(path.resolve(__dirname, '../src/locale')); const entry = {}; localeFiles.forEach((file) => { const name = file.split('.')[0]; if (name !== 'locale') { entry[name] = `./src/locale/${file}`; } }); module.exports = { entry, output: { filename: '[name].js', path: path.resolve(__dirname, '../dist/locale'), }, module: { rules: [ { test: /\.js$/, loader: path.resolve(__dirname, 'locale_loader.js'), } ] }, plugins: [ ], }; ================================================ FILE: build/webpack.prod.js ================================================ const path = require('path'); const merge = require('webpack-merge'); const common = require('./webpack.config.js'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = merge(common, { mode: 'production', devtool: 'source-map', plugins: [ new CleanWebpackPlugin(['dist']), // you should know that the HtmlWebpackPlugin by default will generate its own index.html new HtmlWebpackPlugin({ template: './index.html', title: 'x-spreadsheet', }), new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output // both options are optional filename: '[name].css', // chunkFilename: devMode ? '[id].[hash].css' : '[id].css', }), ], output: { filename: '[name].js', path: path.resolve(__dirname, '../dist'), }, }); ================================================ FILE: dist/index.html ================================================ x-spreadsheet
================================================ FILE: dist/locale/de.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Rückgängig machen",redo:"Wiederherstellen",paintformat:"Format kopieren/einfügen",clearformat:"Format löschen",format:"Format",font:"Schriftart",fontSize:"Schriftgrad",fontBold:"Fett",fontItalic:"Kursiv",underline:"Betonen",strike:"Streichen",textColor:"Text Farbe",fillColor:"Füllung Farbe",border:"Umrandung",merge:"Zellen verbinden",align:"Waagrechte Ausrichtung",valign:"Vertikale uitlijning",textwrap:"Textumbruch",freeze:"Zelle sperren",formula:"Funktionen",more:"Mehr"},contextmenu:{copy:"Kopieren",cut:"Ausschneiden",paste:"Einfügen",pasteValue:"Nur Werte einfügen",pasteFormat:"Nur Format einfügen",insertRow:"Zeile einfügen",insertColumn:"Spalte einfügen",deleteRow:"Zeile löschen",deleteColumn:"Spalte löschen",deleteCell:"Zelle löschen",deleteCellText:"Zellentext löschen"},format:{normal:"Regulär",text:"Text",number:"Nummer",percent:"Prozent",rmb:"RMB",usd:"USD",date:"Datum",time:"Termin",datetime:"Datum Termin",duration:"Dauer"},formula:{sum:"Summe",average:"Durchschnittliche",max:"Max",min:"Min",concat:"Concat"}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages.de=r),t.default=r}]); ================================================ FILE: dist/locale/en.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([,function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages.en=r),t.default=r}]); ================================================ FILE: dist/locale/nl.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}({2:function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Ongedaan maken",redo:"Opnieuw uitvoeren",paintformat:"Opmaak kopiëren/plakken",clearformat:"Opmaak wissen",format:"Opmaak",font:"Lettertype",fontSize:"Tekengrootte",fontBold:"Vet",fontItalic:"Cursief",underline:"Onderstrepen",strike:"Doorstrepen",textColor:"Tekstkleur",fillColor:"Opvulkleur",border:"Randen",merge:"Cellen samenvoegen",align:"Horizontale uitlijning",valign:"Verticale uitlijning",textwrap:"Terugloop",freeze:"Cel bevriezen",formula:"Functies",more:"Meer"},contextmenu:{copy:"Kopiëren",cut:"Knippen",paste:"Plakken",pasteValue:"Alleen waarden plakken",pasteFormat:"Alleen opmaak plakken",insertRow:"Rij invoegen",insertColumn:"Kolom invoegen",deleteRow:"Rij verwijderen",deleteColumn:"Kolom verwijderen",deleteCell:"Cel verwijderen",deleteCellText:"Celtekst verwijderen"},format:{normal:"Standaard",text:"Tekst",number:"Nummer",percent:"Percentage",rmb:"RMB",usd:"USD",date:"Datum",time:"Tijdstip",datetime:"Datum tijd",duration:"Duratie"},formula:{sum:"Som",average:"Gemiddelde",max:"Max",min:"Min",concat:"Concat"}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages.nl=r),t.default=r}}); ================================================ FILE: dist/locale/zh-cn.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}({3:function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"撤销",redo:"恢复",print:"打印",paintformat:"格式刷",clearformat:"清除格式",format:"数据格式",fontName:"字体",fontSize:"字号",fontBold:"加粗",fontItalic:"倾斜",underline:"下划线",strike:"删除线",color:"字体颜色",bgcolor:"填充颜色",border:"边框",merge:"合并单元格",align:"水平对齐",valign:"垂直对齐",textwrap:"自动换行",freeze:"冻结",autofilter:"自动筛选",formula:"函数",more:"更多"},contextmenu:{copy:"复制",cut:"剪切",paste:"粘贴",pasteValue:"粘贴数据",pasteFormat:"粘贴格式",hide:"隐藏",insertRow:"插入行",insertColumn:"插入列",deleteSheet:"删除",deleteRow:"删除行",deleteColumn:"删除列",deleteCell:"删除",deleteCellText:"删除数据",validation:"数据验证",cellprintable:"可打印",cellnonprintable:"不可打印",celleditable:"可编辑",cellnoneditable:"不可编辑"},print:{size:"纸张大小",orientation:"方向",orientations:["横向","纵向"]},format:{normal:"正常",text:"文本",number:"数值",percent:"百分比",rmb:"人民币",usd:"美元",eur:"欧元",date:"短日期",time:"时间",datetime:"长日期",duration:"持续时间"},formula:{sum:"求和",average:"求平均值",max:"求最大值",min:"求最小值",concat:"字符拼接",_if:"条件判断",and:"和",or:"或"},validation:{required:"此值必填",notMatch:"此值不匹配验证规则",between:"此值应在 {} 和 {} 之间",notBetween:"此值不应在 {} 和 {} 之间",notIn:"此值不在列表中",equal:"此值应该等于 {}",notEqual:"此值不应该等于 {}",lessThan:"此值应该小于 {}",lessThanEqual:"此值应该小于等于 {}",greaterThan:"此值应该大于 {}",greaterThanEqual:"此值应该大于等于 {}"},error:{pasteForMergedCell:"无法对合并的单元格执行此操作"},calendar:{weeks:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},button:{next:"下一步",cancel:"取消",remove:"删除",save:"保存",ok:"确认"},sort:{desc:"降序",asc:"升序"},filter:{empty:"空白"},dataValidation:{mode:"模式",range:"单元区间",criteria:"条件",modeType:{cell:"单元格",column:"列模式",row:"行模式"},type:{list:"列表",number:"数字",date:"日期",phone:"手机号",email:"电子邮件"},operator:{be:"在区间",nbe:"不在区间",lt:"小于",lte:"小于等于",gt:"大于",gte:"大于等于",eq:"等于",neq:"不等于"}}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages["zh-cn"]=r),t.default=r}}); ================================================ FILE: dist/xspreadsheet.css ================================================ body { margin: 0; } .x-spreadsheet { font-size: 13px; line-height: normal; user-select: none; -moz-user-select: none; font-family: 'Lato', 'Source Sans Pro', Roboto, Helvetica, Arial, sans-serif; box-sizing: content-box; background: #fff; -webkit-font-smoothing: antialiased; } .x-spreadsheet textarea { font: 400 13px Arial, 'Lato', 'Source Sans Pro', Roboto, Helvetica, sans-serif; } .x-spreadsheet-sheet { position: relative; overflow: hidden; } .x-spreadsheet-table { vertical-align: bottom; } .x-spreadsheet-tooltip { font-family: inherit; position: absolute; padding: 5px 10px; color: #fff; border-radius: 1px; background: #000000; font-size: 12px; z-index: 201; } .x-spreadsheet-tooltip:before { pointer-events: none; position: absolute; left: calc(50% - 4px); top: -4px; content: ""; width: 8px; height: 8px; background: inherit; -webkit-transform: rotate(45deg); transform: rotate(45deg); z-index: 1; box-shadow: 1px 1px 3px -1px rgba(0, 0, 0, 0.3); } .x-spreadsheet-color-palette { padding: 5px; } .x-spreadsheet-color-palette table { margin: 0; padding: 0; border-collapse: separate; border-spacing: 2; background: #fff; } .x-spreadsheet-color-palette table td { margin: 0; cursor: pointer; border: 1px solid transparent; } .x-spreadsheet-color-palette table td:hover { border-color: #ddd; } .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell { width: 16px; height: 16px; } .x-spreadsheet-border-palette { padding: 6px; } .x-spreadsheet-border-palette table { margin: 0; padding: 0; border-collapse: separate; border-spacing: 0; background: #fff; table-layout: fixed; } .x-spreadsheet-border-palette table td { margin: 0; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left { border-right: 1px solid #eee; padding-right: 6px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell { width: 30px; height: 30px; cursor: pointer; text-align: center; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell .x-spreadsheet-icon-img { opacity: 0.8; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover { background-color: #eee; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right { padding-left: 6px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-toolbar-btn { margin-top: 0; margin-bottom: 3px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type { position: relative; left: 0; top: -3px; } .x-spreadsheet-dropdown { position: relative; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content { position: absolute; z-index: 200; background: #fff; box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15); } .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content { top: calc(100% + 5px); left: 0; } .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content { top: calc(100% + 5px); right: 0; } .x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content { bottom: calc(100% + 5px); left: 0; } .x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content { bottom: calc(100% + 5px); right: 0; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title { padding: 0 5px; display: inline-block; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-left { margin-left: 4px; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right { width: 10px; margin-right: 4px; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right .arrow-down { left: -130px; } /* resizer **/ .x-spreadsheet-resizer { position: absolute; z-index: 11; } .x-spreadsheet-resizer .x-spreadsheet-resizer-hover { background-color: rgba(75, 137, 255, 0.25); } .x-spreadsheet-resizer .x-spreadsheet-resizer-line { position: absolute; } .x-spreadsheet-resizer.horizontal { cursor: row-resize; } .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line { border-bottom: 2px dashed #4b89ff; left: 0; bottom: 0; } .x-spreadsheet-resizer.vertical { cursor: col-resize; } .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line { border-right: 2px dashed #4b89ff; top: 0; right: 0; } /* scrollbar */ .x-spreadsheet-scrollbar { position: absolute; bottom: 0; right: 0; background-color: #f4f5f8; opacity: 0.9; z-index: 12; } .x-spreadsheet-scrollbar.horizontal { right: 15px; overflow-x: scroll; overflow-y: hidden; } .x-spreadsheet-scrollbar.horizontal > div { height: 1px; background: #ddd; } .x-spreadsheet-scrollbar.vertical { bottom: 15px; overflow-x: hidden; overflow-y: scroll; } .x-spreadsheet-scrollbar.vertical > div { width: 1px; background: #ddd; } /* @{css-prefix}-overlayer */ .x-spreadsheet-overlayer { position: absolute; left: 0; top: 0; z-index: 10; } .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content { position: absolute; overflow: hidden; pointer-events: none; width: 100%; height: 100%; } .x-spreadsheet-editor, .x-spreadsheet-selector { box-sizing: content-box; position: absolute; overflow: hidden; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; } /* @{css-prefix}-selector */ .x-spreadsheet-selector .hide-input { position: absolute; z-index: 0; } .x-spreadsheet-selector .hide-input input { padding: 0; width: 0; border: none!important; } .x-spreadsheet-selector .x-spreadsheet-selector-area { position: absolute; border: 2px solid #4b89ff; background: rgba(75, 137, 255, 0.1); z-index: 5; } .x-spreadsheet-selector .x-spreadsheet-selector-clipboard, .x-spreadsheet-selector .x-spreadsheet-selector-autofill { position: absolute; background: transparent; z-index: 100; } .x-spreadsheet-selector .x-spreadsheet-selector-clipboard { border: 2px dashed #4b89ff; } .x-spreadsheet-selector .x-spreadsheet-selector-autofill { border: 1px dashed rgba(0, 0, 0, 0.45); } .x-spreadsheet-selector .x-spreadsheet-selector-corner { pointer-events: auto; position: absolute; cursor: crosshair; font-size: 0; height: 5px; width: 5px; right: -5px; bottom: -5px; border: 2px solid #ffffff; background: #4b89ff; } .x-spreadsheet-editor { z-index: 20; } .x-spreadsheet-editor .x-spreadsheet-editor-area { position: absolute; text-align: left; border: 2px solid #4b89ff; line-height: 0; z-index: 100; pointer-events: auto; } .x-spreadsheet-editor .x-spreadsheet-editor-area textarea { box-sizing: content-box; border: none; padding: 0 3px; outline: none; resize: none; text-align: start; overflow-y: hidden; font: 400 13px Arial, 'Lato', 'Source Sans Pro', Roboto, Helvetica, sans-serif; color: inherit; white-space: normal; word-wrap: break-word; line-height: 22px; margin: 0; } .x-spreadsheet-editor .x-spreadsheet-editor-area .textline { overflow: hidden; visibility: hidden; position: fixed; top: 0; left: 0; } .x-spreadsheet-item { user-select: none; background: 0; border: 1px solid transparent; outline: none; height: 26px; color: rgba(0, 0, 0, 0.9); line-height: 26px; list-style: none; padding: 2px 10px; cursor: default; text-align: left; overflow: hidden; } .x-spreadsheet-item.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-item:hover, .x-spreadsheet-item.active { background: rgba(0, 0, 0, 0.05); } .x-spreadsheet-item.divider { height: 0; padding: 0; margin: 5px 0; border: none; border-bottom: 1px solid rgba(0, 0, 0, 0.1); } .x-spreadsheet-item .label { float: right; opacity: 0.65; font-size: 1em; } .x-spreadsheet-item.state, .x-spreadsheet-header.state { padding-left: 35px!important; position: relative; } .x-spreadsheet-item.state:before, .x-spreadsheet-header.state:before { content: ''; position: absolute; width: 10px; height: 10px; left: 12px; top: calc(50% - 5px); background: rgba(0, 0, 0, 0.08); border-radius: 2px; } .x-spreadsheet-item.state.checked:before, .x-spreadsheet-header.state.checked:before { background: #4b89ff; } .x-spreadsheet-checkbox { position: relative; display: inline-block; backface-visibility: hidden; outline: 0; vertical-align: baseline; font-style: normal; font-size: 1rem; line-height: 1em; } .x-spreadsheet-checkbox > input { position: absolute; top: 0; left: 0; opacity: 0!important; outline: 0; z-index: -1; } .x-spreadsheet-suggest, .x-spreadsheet-contextmenu, .x-spreadsheet-sort-filter { position: absolute; box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15); background: #fff; z-index: 100; width: 260px; pointer-events: auto; overflow: auto; } .x-spreadsheet-suggest { width: 200px; } .x-spreadsheet-filter { border: 1px solid #e9e9e9; font-size: 12px; margin: 10px; } .x-spreadsheet-filter .x-spreadsheet-header { padding: 0.5em 0.75em; background: #f8f8f9; border-bottom: 1px solid #e9e9e9; border-left: 1px solid transparent; } .x-spreadsheet-filter .x-spreadsheet-body { height: 200px; overflow-y: auto; } .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item { height: 20px; line-height: 20px; } .x-spreadsheet-sort-filter .x-spreadsheet-buttons { margin: 10px; } .x-spreadsheet-toolbar, .x-spreadsheet-bottombar { height: 40px; padding: 0 30px; text-align: left; background: #f5f6f7; display: flex; } .x-spreadsheet-bottombar { position: relative; border-top: 1px solid #e0e2e4; } .x-spreadsheet-bottombar .x-spreadsheet-menu > li { line-height: 40px; height: 40px; padding-top: 0; padding-bottom: 0; vertical-align: middle; border-right: 1px solid #e8eaed; } .x-spreadsheet-menu { list-style: none; margin: 0; padding: 0; user-select: none; } .x-spreadsheet-menu > li { float: left; line-height: 1.25em; padding: 0.785em 1em; margin: 0; vertical-align: middle; text-align: left; font-weight: 400; color: #80868b; white-space: nowrap; cursor: pointer; transition: all 0.3s; font-weight: bold; } .x-spreadsheet-menu > li.active { background-color: #fff; color: rgba(0, 0, 0, 0.65); } .x-spreadsheet-menu > li .x-spreadsheet-icon { margin: 0 6px; } .x-spreadsheet-menu > li .x-spreadsheet-icon .x-spreadsheet-icon-img:hover { opacity: 0.85; } .x-spreadsheet-menu > li .x-spreadsheet-dropdown { display: inline-block; } .x-spreadsheet-toolbar { border-bottom: 1px solid #e0e2e4; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btns { display: inline-flex; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more { padding: 0 6px 6px; text-align: left; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-toolbar-divider { margin-top: 0; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn { flex: 0 0 auto; display: inline-block; border: 1px solid transparent; height: 26px; line-height: 26px; min-width: 26px; margin: 6px 1px 0; padding: 0; text-align: center; border-radius: 2px; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn:hover, .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.active { background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-toolbar-divider { display: inline-block; border-right: 1px solid #e0e2e4; width: 0; vertical-align: middle; height: 18px; margin: 12px 3px 0; } .x-spreadsheet-print { position: absolute; left: 0; top: 0; z-index: 100; width: 100%; height: 100%; display: flex; flex-direction: column; } .x-spreadsheet-print-bar { background: #424242; height: 60px; line-height: 60px; padding: 0 30px; } .x-spreadsheet-print-bar .-title { color: #fff; font-weight: bold; font-size: 1.2em; float: left; } .x-spreadsheet-print-bar .-right { float: right; margin-top: 12px; } .x-spreadsheet-print-content { display: flex; flex: auto; flex-direction: row; background: #d0d0d0; height: calc(100% - 60px); } .x-spreadsheet-print-content .-sider { flex: 0 0 300px; width: 300px; border-left: 2px solid #ccc; background: #fff; } .x-spreadsheet-print-content .-content { flex: auto; overflow-x: auto; overflow-y: scroll; height: 100%; } .x-spreadsheet-canvas-card-wraper { margin: 40px 20px; } .x-spreadsheet-canvas-card { background: #fff; margin: auto; page-break-before: auto; page-break-after: always; box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 3px rgba(0, 0, 0, 0.12), 0 4px 5px 0 rgba(0, 0, 0, 0.2); } .x-spreadsheet-calendar { color: rgba(0, 0, 0, 0.65); background: #ffffff; user-select: none; } .x-spreadsheet-calendar .calendar-header { font-weight: 700; line-height: 30px; text-align: center; width: 100%; float: left; background: #f9fafb; } .x-spreadsheet-calendar .calendar-header .calendar-header-left { padding-left: 5px; float: left; } .x-spreadsheet-calendar .calendar-header .calendar-header-right { float: right; } .x-spreadsheet-calendar .calendar-header .calendar-header-right a { padding: 3px 0; margin-right: 2px; border-radius: 2px; } .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover { background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-calendar .calendar-body { border-collapse: collapse; border-spacing: 0; } .x-spreadsheet-calendar .calendar-body th, .x-spreadsheet-calendar .calendar-body td { width: 14.28571429%; min-width: 32px; text-align: center; font-weight: 700; line-height: 30px; padding: 0; } .x-spreadsheet-calendar .calendar-body td > .cell:hover { background: #ecf6fd; } .x-spreadsheet-calendar .calendar-body td > .cell.active, .x-spreadsheet-calendar .calendar-body td > .cell.active:hover { background: #ecf6fd; color: #2185D0; } .x-spreadsheet-calendar .calendar-body td > .cell.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-datepicker { box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); position: absolute; left: 0; top: calc(100% + 5px); z-index: 10; width: auto; } .x-spreadsheet-buttons { display: flex; justify-content: flex-end; } .x-spreadsheet-buttons .x-spreadsheet-button { margin-left: 8px; } .x-spreadsheet-button { display: inline-block; border-radius: 3px; line-height: 1em; min-height: 1em; white-space: nowrap; text-align: center; cursor: pointer; font-size: 1em; font-weight: 700; padding: 0.75em 1em; color: rgba(0, 0, 0, 0.6); background: #E0E1E2; text-decoration: none; font-family: "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif; outline: none; vertical-align: baseline; zoom: 1; user-select: none; transition: all 0.1s linear; } .x-spreadsheet-button.active, .x-spreadsheet-button:hover { background-color: #C0C1C2; color: rgba(0, 0, 0, 0.8); } .x-spreadsheet-button.primary { color: #fff; background-color: #2185D0; } .x-spreadsheet-button.primary:hover, .x-spreadsheet-button.primary.active { color: #fff; background-color: #1678c2; } .x-spreadsheet-form-input { font-size: 1em; position: relative; font-weight: 400; display: inline-flex; color: rgba(0, 0, 0, 0.87); } .x-spreadsheet-form-input input { z-index: 1; margin: 0; max-width: 100%; flex: 1 0 auto; outline: 0; -webkit-tap-highlight-color: rgba(255, 255, 255, 0); text-align: left; line-height: 30px; height: 30px; padding: 0 8px; background: #fff; border: 1px solid #e9e9e9; border-radius: 3px; transition: box-shadow 0.1s ease, border-color 0.1s ease; box-shadow: inset 0 1px 2px hsla(0, 0%, 4%, 0.06); } .x-spreadsheet-form-input input:focus { border-color: #4b89ff; box-shadow: inset 0 1px 2px rgba(75, 137, 255, 0.2); } .x-spreadsheet-form-select { position: relative; display: inline-block; background: #fff; border: 1px solid #e9e9e9; border-radius: 2px; cursor: pointer; color: rgba(0, 0, 0, 0.87); user-select: none; box-shadow: inset 0 1px 2px hsla(0, 0%, 4%, 0.06); } .x-spreadsheet-form-select .input-text { text-overflow: ellipsis; white-space: nowrap; min-width: 60px; width: auto; height: 30px; line-height: 30px; padding: 0 8px; } .x-spreadsheet-form-fields { display: flex; flex-direction: row; flex-wrap: wrap; } .x-spreadsheet-form-fields .x-spreadsheet-form-field { flex: 0 1 auto; } .x-spreadsheet-form-fields .x-spreadsheet-form-field .label { display: inline-block; margin: 0 10px 0 0; } .x-spreadsheet-form-field { display: block; vertical-align: middle; margin-left: 10px; margin-bottom: 10px; } .x-spreadsheet-form-field:first-child { margin-left: 0; } .x-spreadsheet-form-field.error .x-spreadsheet-form-select, .x-spreadsheet-form-field.error input { border-color: #f04134; } .x-spreadsheet-form-field .tip { color: #f04134; font-size: 0.9em; } .x-spreadsheet-dimmer { display: none; position: absolute; top: 0 !important; left: 0 !important; width: 100%; height: 100%; text-align: center; vertical-align: middle; background-color: rgba(0, 0, 0, 0.6); opacity: 0; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration: 0.5s; animation-duration: 0.5s; transition: background-color 0.5s linear; user-select: none; z-index: 1000; } .x-spreadsheet-dimmer.active { display: block; opacity: 1; } form fieldset { border: none; } form fieldset label { display: block; margin-bottom: 0.5em; font-size: 1em; color: #666; } form fieldset select { font-size: 1.1em; width: 100%; background-color: #fff; border: none; border-bottom: 2px solid #ddd; padding: 0.5em 0.85em; border-radius: 2px; } .x-spreadsheet-modal, .x-spreadsheet-toast { font-size: 13px; position: fixed; z-index: 1001; text-align: left; line-height: 1.25em; min-width: 360px; color: rgba(0, 0, 0, 0.87); font-family: 'Lato', 'Source Sans Pro', Roboto, Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.1); background-color: #fff; background-clip: padding-box; box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 8px; } .x-spreadsheet-toast { background-color: rgba(255, 255, 255, 0.85); } .x-spreadsheet-modal-header, .x-spreadsheet-toast-header { font-weight: 600; background-clip: padding-box; background-color: rgba(255, 255, 255, 0.85); border-bottom: 1px solid rgba(0, 0, 0, 0.05); border-radius: 4px 4px 0 0; } .x-spreadsheet-modal-header .x-spreadsheet-icon, .x-spreadsheet-toast-header .x-spreadsheet-icon { position: absolute; right: 0.8em; top: 0.65em; border-radius: 18px; } .x-spreadsheet-modal-header .x-spreadsheet-icon:hover, .x-spreadsheet-toast-header .x-spreadsheet-icon:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-toast-header { color: #F2711C; } .x-spreadsheet-modal-header { border-bottom: 1px solid #e0e2e4; background: rgba(0, 0, 0, 0.08); font-size: 1.0785em; } .x-spreadsheet-modal-header, .x-spreadsheet-modal-content, .x-spreadsheet-toast-header, .x-spreadsheet-toast-content { padding: 0.75em 1em; } @media screen and (min-width: 320px) and (max-width: 480px) { .x-spreadsheet-toolbar { display: none; } } .x-spreadsheet-icon { width: 18px; height: 18px; margin: 1px 1px 2px 1px; text-align: center; vertical-align: middle; user-select: none; overflow: hidden; position: relative; display: inline-block; line-height: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img { background-image: url(58eaeb4e52248a5c75936c6f4c33a370.svg); position: absolute; width: 262px; height: 444px; opacity: 0.56; } .x-spreadsheet-icon .x-spreadsheet-icon-img.undo { left: 0; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.redo { left: -18px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.print { left: -36px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.paintformat { left: -54px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.clearformat { left: -72px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.font-bold { left: -90px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.font-italic { left: -108px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.underline { left: -126px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.strike { left: -144px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.color { left: -162px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.bgcolor { left: -180px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.merge { left: -198px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-left { left: -216px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-center { left: -234px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-right { left: 0; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-top { left: -18px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-middle { left: -36px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-bottom { left: -54px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.textwrap { left: -72px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.autofilter { left: -90px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.formula { left: -108px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-down { left: -126px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-right { left: -144px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.link { left: -162px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chart { left: -180px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.freeze { left: -198px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.ellipsis { left: -216px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.add { left: -234px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-all { left: 0; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-inside { left: -18px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-horizontal { left: -36px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-vertical { left: -54px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-outside { left: -72px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-left { left: -90px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-top { left: -108px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-right { left: -126px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-bottom { left: -144px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-none { left: -162px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.line-color { left: -180px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.line-type { left: -198px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.close { left: -234px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-down { left: 0; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-up { left: -18px; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-left { left: -36px; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-right { left: -54px; top: -54px; } /*# sourceMappingURL=xspreadsheet.css.map*/ ================================================ FILE: dist/xspreadsheet.js ================================================ !function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){},function(t,e,n){},function(t,e,n){"use strict";function r(t){return function(t){if(Array.isArray(t))return t}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:"";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e?(this.el=document.createElement(e),this.el.className=n):this.el=e,this.data={}}var e,n,o;return e=t,(n=[{key:"data",value:function(t,e){return void 0!==e?(this.data[t]=e,this):this.data[t]}},{key:"on",value:function(t,e){var n=r(t.split(".")),i=n[0],o=n.slice(1),a=i;return"mousewheel"===a&&/Firefox/i.test(window.navigator.userAgent)&&(a="DOMMouseScroll"),this.el.addEventListener(a,function(t){e(t);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"active";return this.toggleClass(t)}},{key:"toggleClass",value:function(t){return this.el.classList.toggle(t)}},{key:"active",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"active";return t?this.addClass(e):this.removeClass(e),this}},{key:"checked",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.active(t,"checked"),this}},{key:"disabled",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return t?this.addClass("disabled"):this.removeClass("disabled"),this}},{key:"attr",value:function(t,e){var n=this;if(void 0!==e)this.el.setAttribute(t,e);else{if("string"==typeof t)return this.el.getAttribute(t);Object.keys(t).forEach(function(e){n.el.setAttribute(e,t[e])})}return this}},{key:"removeAttr",value:function(t){return this.el.removeAttribute(t),this}},{key:"html",value:function(t){return void 0!==t?(this.el.innerHTML=t,this):this.el.innerHTML}},{key:"val",value:function(t){return void 0!==t?(this.el.value=t,this):this.el.value}},{key:"focus",value:function(){this.el.focus()}},{key:"cssRemoveKeys",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:"";return new o(t,e)};n(0);function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var c=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function s(t){for(var e="",n=t;n>=c.length;)n/=c.length,n-=1,e+=c[parseInt(n,10)%c.length];var r=t%c.length;return e+=c[r]}function u(t){for(var e=0,n=0;n="0"&&t.charAt(r)<="9"?n+=t.charAt(r):e+=t.charAt(r);return[u(e),parseInt(n,10)-1]}function h(t,e){return"".concat(s(t)).concat(e+1)}function p(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){return!0};if(0===e&&0===n)return t;var i=l(f(t),2),o=i[0],a=i[1];return r(o,a)?h(o+e,a+n):t}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function y(t,e){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sri=e,this.sci=n,this.eri=r,this.eci=i,this.w=o,this.h=a}var e,n,r;return e=t,r=[{key:"valueOf",value:function(e){var n=e.split(":"),r=d(f(n[0]),2),i=r[0],o=r[1],a=o,l=i;if(n.length>1){var c=d(f(n[1]),2);l=c[0],a=c[1]}return new t(o,i,a,l)}}],(n=[{key:"set",value:function(t,e,n,r){this.sri=t,this.sci=e,this.eri=n,this.eci=r}},{key:"multiple",value:function(){return this.eri-this.sri>0||this.eci-this.sci>0}},{key:"includes",value:function(){for(var t=0,e=0,n=arguments.length,r=new Array(n),i=0;i1&&void 0!==arguments[1]?arguments[1]:function(){return!0},n=this.sri,r=this.sci,i=this.eri,o=this.eci,a=n;a<=i;a+=1)if(e(a))for(var l=r;l<=o;l+=1)t(a,l)}},{key:"contains",value:function(t){return this.sri<=t.sri&&this.sci<=t.sci&&this.eri>=t.eri&&this.eci>=t.eci}},{key:"within",value:function(t){return this.sri>=t.sri&&this.sci>=t.sci&&this.eri<=t.eri&&this.eci<=t.eci}},{key:"disjoint",value:function(t){return this.sri>t.eri||this.sci>t.eci||t.sri>this.eri||t.sci>this.eci}},{key:"intersects",value:function(t){return this.sri<=t.eri&&this.sci<=t.eci&&t.sri<=this.eri&&t.sci<=this.eci}},{key:"union",value:function(e){var n=this.sri,r=this.sci,i=this.eri,o=this.eci;return new t(e.srii?e.eri:i,e.eci>o?e.eci:o)}},{key:"difference",value:function(e){var n=[],r=function(e,r,i,o){n.push(new t(e,r,i,o))},i=this.sri,o=this.sci,a=this.eri,l=this.eci,c=e.sri-i,s=e.sci-o,u=a-e.eri,f=l-e.eci;return c>0?(r(i,o,e.sri-1,l),u>0?(r(e.eri+1,o,a,l),s>0&&r(e.sri,o,e.eri,e.sci-1),f>0&&r(e.sri,e.eci+1,e.eri,l)):(s>0&&r(e.sri,o,a,e.sci-1),f>0&&r(e.sri,e.eci+1,a,l))):u>0&&(r(e.eri+1,o,a,l),s>0&&r(i,o,e.eri,e.sci-1),f>0&&r(i,e.eci+1,e.eri,l)),s>0?(r(i,o,a,e.sci-1),f>0?(r(i,e.eri+1,a,l),c>0&&r(i,e.sci,e.sri-1,e.eci),u>0&&r(e.sri+1,e.sci,a,e.eci)):(c>0&&r(i,e.sci,e.sri-1,l),u>0&&r(e.sri+1,e.sci,a,l))):f>0&&(r(a,e.eci+1,a,l),c>0&&r(i,o,e.sri-1,e.eci),u>0&&r(e.eri+1,o,a,e.eci)),n}},{key:"size",value:function(){return[this.eri-this.sri+1,this.eci-this.sci+1]}},{key:"toString",value:function(){var t=this.sri,e=this.sci,n=this.eri,r=this.eci,i=h(e,t);return this.multiple()&&(i="".concat(i,":").concat(h(r,n))),i}},{key:"clone",value:function(){return new t(this.sri,this.sci,this.eri,this.eci,this.w,this.h)}},{key:"equals",value:function(t){return this.eri===t.eri&&this.eci===t.eci&&this.sri===t.sri&&this.sci===t.sci}}])&&y(e.prototype,n),r&&y(e,r),t}();function b(t,e){for(var n=0;n0}},{key:"canRedo",value:function(){return this.redoItems.length>0}},{key:"undo",value:function(t,e){var n=this.undoItems,r=this.redoItems;this.canUndo()&&(r.push(JSON.stringify(t)),e(JSON.parse(n.pop())))}},{key:"redo",value:function(t,e){var n=this.undoItems,r=this.redoItems;this.canRedo()&&(n.push(JSON.stringify(t)),e(JSON.parse(r.pop())))}}])&&w(e.prototype,n),r&&w(e,r),t}();function O(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._=e}var e,n,r;return e=t,(n=[{key:"forEach",value:function(t){this._.forEach(t)}},{key:"deleteWithin",value:function(t){this._=this._.filter(function(e){return!e.within(t)})}},{key:"getFirstIncludes",value:function(t,e){for(var n=0;n=e?(s.sri+=n,s.eri+=n):o=e?(s.sci+=n,s.eci+=n):a0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length,r=new Array(n>1?n-1:0),i=1;i5?l.toFixed(2):l;return l.toFixed(Math.max(r,i))}var z={cloneDeep:function(t){return JSON.parse(JSON.stringify(t))},merge:function(){for(var t=arguments.length,e=new Array(t),n=0;n1&&void 0!==arguments[1]?arguments[1]:function(t){return t},n=0,r=0;return Object.keys(t).forEach(function(i){n+=e(t[i],i),r+=1}),[n,r]},rangeEach:function(t,e,n){for(var r=t;ri);c+=1)a+=l=o(c);return[c,a-l,l]},deleteProperty:function(t,e){var n=t["".concat(e)];return delete t["".concat(e)],n},numberCalc:I};function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function M(t,e){for(var n=0;n0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}},{key:"isHide",value:function(t){var e=this.get(t);return e&&e.hide}},{key:"setHide",value:function(t,e){var n=this.getOrNew(t);!0===e?n.hide=!0:delete n.hide}},{key:"setStyle",value:function(t,e){this.getOrNew(t).style=e}},{key:"sumHeight",value:function(t,e,n){var r=this;return z.rangeSum(t,e,function(t){return n&&n.has(t)?0:r.getHeight(t)})}},{key:"totalHeight",value:function(){return this.sumHeight(0,this.len)}},{key:"get",value:function(t){return this._[t]}},{key:"getOrNew",value:function(t){return this._[t]=this._[t]||{cells:{}},this._[t]}},{key:"getCell",value:function(t,e){var n=this.get(t);return void 0!==n&&void 0!==n.cells&&void 0!==n.cells[e]?n.cells[e]:null}},{key:"getCellMerge",value:function(t,e){var n=this.getCell(t,e);return n&&n.merge?n.merge:[0,0]}},{key:"getCellOrNew",value:function(t,e){var n=this.getOrNew(t);return n.cells[e]=n.cells[e]||{},n.cells[e]}},{key:"setCell",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"all",i=this.getOrNew(t);"all"===r?i.cells[e]=n:"text"===r?(i.cells[e]=i.cells[e]||{},i.cells[e].text=n.text):"format"===r&&(i.cells[e]=i.cells[e]||{},i.cells[e].style=n.style,n.merge&&(i.cells[e].merge=n.merge))}},{key:"setCellText",value:function(t,e,n){var r=this.getCellOrNew(t,e);!1!==r.editable&&(r.text=n)}},{key:"copyPaste",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},o=t.sri,a=t.sci,l=t.eri,c=t.eci,s=e.sri,u=e.sci,f=e.eri,h=e.eci,d=t.size(),y=H(d,2),v=y[0],b=y[1],g=e.size(),m=H(g,2),w=m[0],k=m[1],O=!0,S=0;(f0&&function(){var t=P.text,e=_-u+(j-s)+2;if(O||(e-=S+1),"="===t[0])P.text=t.replace(/[a-zA-Z]{1,3}\d+/g,function(t){var n=0,r=0;return o===s?n=e-1:r=e-1,/^\d+$/.test(t)?t:p(t,n,r)});else if(v<=1&&b>1&&(s>l||f1&&(u>c||h1&&void 0!==arguments[1]?arguments[1]:1,r={};this.each(function(i,o){var a=parseInt(i,10);a>=t&&(a+=n,e.eachCells(i,function(e,r){r.text&&"="===r.text[0]&&(r.text=r.text.replace(/[a-zA-Z]{1,3}\d+/g,function(e){return p(e,0,n,function(e,n){return n>=t})}))})),r[a]=o}),this._=r,this.len+=n}},{key:"delete",value:function(t,e){var n=this,r=e-t+1,i={};this.each(function(o,a){var l=parseInt(o,10);le&&(i[l-r]=a,n.eachCells(o,function(t,n){n.text&&"="===n.text[0]&&(n.text=n.text.replace(/[a-zA-Z]{1,3}\d+/g,function(t){return p(t,0,-r,function(t,n){return n>e})}))}))}),this._=i,this.len-=r}},{key:"insertColumn",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.each(function(r,i){var o={};e.eachCells(r,function(e,r){var i=parseInt(e,10);i>=t&&(i+=n,r.text&&"="===r.text[0]&&(r.text=r.text.replace(/[a-zA-Z]{1,3}\d+/g,function(e){return p(e,n,0,function(e){return e>=t})}))),o[i]=r}),i.cells=o})}},{key:"deleteColumn",value:function(t,e){var n=this,r=e-t+1;this.each(function(i,o){var a={};n.eachCells(i,function(n,i){var o=parseInt(n,10);oe&&(a[o-r]=i,i.text&&"="===i.text[0]&&(i.text=i.text.replace(/[a-zA-Z]{1,3}\d+/g,function(t){return p(t,-r,0,function(t){return t>e})})))}),o.cells=a})}},{key:"deleteCells",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t.each(function(t,r){e.deleteCell(t,r,n)})}},{key:"deleteCell",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=this.get(t);if(null!==r){var i=this.getCell(t,e);null!==i&&!1!==i.editable&&("all"===n?delete r.cells[e]:"text"===n?(i.text&&delete i.text,i.value&&delete i.value):"format"===n?(void 0!==i.style&&delete i.style,i.merge&&delete i.merge):"merge"===n&&i.merge&&delete i.merge)}}},{key:"maxCell",value:function(){var t=Object.keys(this._),e=t[t.length-1],n=this._[e];if(n){var r=n.cells,i=Object.keys(r),o=i[i.length-1];return[parseInt(e,10),parseInt(o,10)]}return[0,0]}},{key:"each",value:function(t){Object.entries(this._).forEach(function(e){var n=H(e,2),r=n[0],i=n[1];t(r,i)})}},{key:"eachCells",value:function(t,e){this._[t]&&this._[t].cells&&Object.entries(this._[t].cells).forEach(function(t){var n=H(t,2),r=n[0],i=n[1];e(r,i)})}},{key:"setData",value:function(t){t.len&&(this.len=t.len,delete t.len),this._=t}},{key:"getData",value:function(){var t=this.len;return Object.assign({len:t},this._)}}])&&M(e.prototype,n),r&&M(e,r),t}();function F(t,e){for(var n=0;n0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}},{key:"isHide",value:function(t){var e=this._[t];return e&&e.hide}},{key:"setHide",value:function(t,e){var n=this.getOrNew(t);!0===e?n.hide=!0:delete n.hide}},{key:"setStyle",value:function(t,e){this.getOrNew(t).style=e}},{key:"sumWidth",value:function(t,e){var n=this;return z.rangeSum(t,e,function(t){return n.getWidth(t)})}},{key:"totalWidth",value:function(){return this.sumWidth(0,this.len)}}])&&F(e.prototype,n),r&&F(e,r),t}(),V=["en"],q={en:{toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}}};function B(t,e){if(e)for(var n=0,r=V;n2&&void 0!==arguments[2]&&arguments[2]?V=[t]:V.unshift(t),e&&(q[t]=e)}function $(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function X(t,e){for(var n=0;n2?r-2:0),o=2;o=this.parseValue(l)&&o<=this.parseValue(c),"between",l,c)}if("nbe"===n){var s=$(r,2),u=s[0],f=s[1];return K(othis.parseValue(f),"notBetween",u,f)}if("eq"===n)return K(o===this.parseValue(r),"equal",r);if("neq"===n)return K(o!==this.parseValue(r),"notEqual",r);if("lt"===n)return K(othis.parseValue(r),"greaterThan",r);if("gte"===n)return K(o>=this.parseValue(r),"greaterThanEqual",r)}return[!0]}}])&&X(e.prototype,n),r&&X(e,r),t}();function G(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Q(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tt(t,e){for(var n=0;n0}).map(function(t){return t.getData()})}},{key:"setData",value:function(t){this._=t.map(function(t){return nt.valueOf(t)})}}]),t}();function it(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:function(){},r=this.merges,i=e.clone(),o=at(t.size(),2),a=o[0],l=o[1],c=at(e.size(),2),s=c[0],u=c[1];return a>s&&(i.eri=e.sri+a-1),l>u&&(i.eci=e.sci+l-1),!r.intersects(i)||(n(L("error.pasteForMergedCell")),!1)}function ut(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this.rows,o=this.merges;"all"!==n&&"format"!==n||(i.deleteCells(e,n),o.deleteWithin(e)),i.copyPaste(t,e,n,r,function(t,e,n){if(n&&n.merge){var r=at(n.merge,2),i=r[0],a=r[1];if(i<=0&&a<=0)return;o.add(new v(t,e,t+i,e+a))}})}function ft(t,e){var n=this.clipboard,r=this.rows,i=this.merges;r.cutPaste(t,e),i.move(t,e.sri-t.sri,e.sci-t.sci),n.clear()}function ht(t,e,n){var r=this.styles,i=this.rows.getCellOrNew(t,e),o={};void 0!==i.style&&(o=z.cloneDeep(r[i.style])),o=z.merge(o,{border:n}),i.style=this.addStyle(o)}var pt=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=z.merge(lt,n||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new A,this.rows=new N(this.settings.row),this.cols=new W(this.settings.col),this.validations=new rt,this.hyperlinks={},this.comments={},this.selector=new g,this.scroll=new m,this.history=new k,this.clipboard=new S,this.autoFilter=new T,this.change=function(){},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}var e,n,r;return e=t,(n=[{key:"addValidation",value:function(t,e,n){var r=this;this.changeData(function(){r.validations.add(t,e,n)})}},{key:"removeValidation",value:function(){var t=this,e=this.selector.range;this.changeData(function(){t.validations.remove(e)})}},{key:"getSelectedValidator",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=this.validations.get(e,n);return r?r.validator:null}},{key:"getSelectedValidation",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=t.range,i=this.validations.get(e,n),o={ref:r.toString()};return null!==i&&(o.mode=i.mode,o.validator=i.validator),o}},{key:"canUndo",value:function(){return this.history.canUndo()}},{key:"canRedo",value:function(){return this.history.canRedo()}},{key:"undo",value:function(){var t=this;this.history.undo(this.getData(),function(e){t.setData(e)})}},{key:"redo",value:function(){var t=this;this.history.redo(this.getData(),function(e){t.setData(e)})}},{key:"copy",value:function(){this.clipboard.copy(this.selector.range)}},{key:"copyToSystemClipboard",value:function(){if(void 0!==navigator.clipboard){for(var t="",e=this.rows.getData(),n=this.selector.range.sri;n<=this.selector.range.eri;n+=1){if(ct(e,n)){for(var r=this.selector.range.sci;r<=this.selector.range.eci;r+=1)if(r>this.selector.range.sci&&(t+="\t"),ct(e[n].cells,r)){var i=String(e[n].cells[r].text);-1===i.indexOf("\n")&&-1===i.indexOf("\t")&&-1===i.indexOf('"')?t+=i:t+='"'.concat(i,'"')}}else for(var o=this.selector.range.sci;o<=this.selector.range.eci;o+=1)t+="\t";t+="\n"}navigator.clipboard.writeText(t).then(function(){},function(e){console.log("text copy to the system clipboard error ",t,e)})}}},{key:"cut",value:function(){this.clipboard.cut(this.selector.range)}},{key:"paste",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=this.clipboard,i=this.selector;return!r.isClear()&&(!!st.call(this,r.range,i.range,n)&&(this.changeData(function(){r.isCopy()?ut.call(t,r.range,i.range,e):r.isCut()&&ft.call(t,r.range,i.range)}),!0))}},{key:"pasteFromText",value:function(t){var e=t.split("\r\n").map(function(t){return t.replace(/"/g,"").split("\t")});e.length>0&&(e.length-=1);var n=this.rows,r=this.selector;this.changeData(function(){n.paste(e,r.range)})}},{key:"autofill",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=this.selector.range;return!!st.call(this,i,t,r)&&(this.changeData(function(){ut.call(n,i,t,e,!0)}),!0)}},{key:"clearClipboard",value:function(){this.clipboard.clear()}},{key:"calSelectedRangeByEnd",value:function(t,e){var n=this.selector,r=this.rows,i=this.cols,o=this.merges,a=n.range,l=a.sri,c=a.sci,s=a.eri,u=a.eci,f=n.ri,h=n.ci,p=t,d=e;return t<0&&(p=r.len-1),e<0&&(d=i.len-1),p>f?(l=f,s=p):(l=p,s=f),d>h?(c=h,u=d):(c=d,u=h),n.range=o.union(new v(l,c,s,u)),n.range=o.union(n.range),n.range}},{key:"calSelectedRangeByStart",value:function(t,e){var n=this.selector,r=this.rows,i=this.cols,o=this.merges.getFirstIncludes(t,e);return null===o&&(o=new v(t,e,t,e),-1===t&&(o.sri=0,o.eri=r.len-1),-1===e&&(o.sci=0,o.eci=i.len-1)),n.range=o,o}},{key:"setSelectedCellAttr",value:function(t,e){var n=this;this.changeData(function(){var r=n.selector,i=n.styles,o=n.rows;if("merge"===t)e?n.merge():n.unmerge();else if("border"===t)(function(t){var e=this,n=t.mode,r=t.style,i=t.color,o=this.styles,a=this.selector,l=this.rows,c=a.range,s=c.sri,u=c.sci,f=c.eri,h=c.eci,p=!this.isSingleSelected();if(p||"inside"!==n&&"horizontal"!==n&&"vertical"!==n)if("outside"!==n||p){if("none"===n)a.range.each(function(t,n){var r=l.getCell(t,n);if(r&&void 0!==r.style){var i=z.cloneDeep(o[r.style]);delete i.border,r.style=e.addStyle(i)}});else if("all"===n||"inside"===n||"outside"===n||"horizontal"===n||"vertical"===n)!function(){for(var t=[],o=s;o<=f;o+=1)for(var a=u;a<=h;a+=1){for(var c=[],d=0;dh)break;var w=l.getCell(o,a),k=0,O=0;if(w&&w.merge){var S=at(w.merge,2);k=S[0],O=S[1],t.push([o,a,k,O])}var x=k>0&&o+k===f,E=O>0&&a+O===h,j={};"all"===n?j={bottom:[r,i],top:[r,i],left:[r,i],right:[r,i]}:"inside"===n?(!E&&a0&&ht.call(e,o,a,j),a+=O}}();else if("top"===n||"bottom"===n)for(var d=u;d<=h;d+=1)"top"===n&&(ht.call(this,s,d,{top:[r,i]}),d+=l.getCellMerge(s,d)[1]),"bottom"===n&&(ht.call(this,f,d,{bottom:[r,i]}),d+=l.getCellMerge(f,d)[1]);else if("left"===n||"right"===n)for(var y=s;y<=f;y+=1)"left"===n&&(ht.call(this,y,u,{left:[r,i]}),y+=l.getCellMerge(y,u)[0]),"right"===n&&(ht.call(this,y,h,{right:[r,i]}),y+=l.getCellMerge(y,h)[0])}else ht.call(this,s,u,{top:[r,i],bottom:[r,i],left:[r,i],right:[r,i]})}).call(n,e);else if("formula"===t){var a=r.ri,l=r.ci,c=r.range;if(r.multiple()){var s=at(r.size(),2),u=s[0],f=s[1],p=c.sri,d=c.sci,y=c.eri,v=c.eci;if(u>1)for(var b=d;b<=v;b+=1){o.getCellOrNew(y+1,b).text="=".concat(e,"(").concat(h(b,p),":").concat(h(b,y),")")}else if(f>1){o.getCellOrNew(a,v+1).text="=".concat(e,"(").concat(h(d,a),":").concat(h(v,a),")")}}else{o.getCellOrNew(a,l).text="=".concat(e,"()")}}else r.range.each(function(r,a){var l=o.getCellOrNew(r,a),c={};if(void 0!==l.style&&(c=z.cloneDeep(i[l.style])),"format"===t)c.format=e,l.style=n.addStyle(c);else if("font-bold"===t||"font-italic"===t||"font-name"===t||"font-size"===t){var s={};s[t.split("-")[1]]=e,c.font=Object.assign(c.font||{},s),l.style=n.addStyle(c)}else"strike"===t||"textwrap"===t||"underline"===t||"align"===t||"valign"===t||"color"===t||"bgcolor"===t?(c[t]=e,l.style=n.addStyle(c)):l[t]=e})})}},{key:"setSelectedCellText",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"input",n=this.autoFilter,r=this.selector,i=this.rows,o=r.ri,a=r.ci,l=o;this.unsortedRowMap.has(o)&&(l=this.unsortedRowMap.get(o));var c=i.getCell(l,a),s=c?c.text:"";if(this.setCellText(l,a,t,e),n.active()){var u=n.getFilter(a);if(u){var f=u.value.findIndex(function(t){return t===s});f>=0&&u.value.splice(f,1,t)}}}},{key:"getSelectedCell",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=e;return this.unsortedRowMap.has(e)&&(r=this.unsortedRowMap.get(e)),this.rows.getCell(r,n)}},{key:"xyInSelectedRect",value:function(t,e){var n=this.getSelectedRect(),r=n.left,i=n.top,o=n.width,a=n.height,l=t-this.cols.indexWidth,c=e-this.rows.height;return l>r&&li&&c0&&v>s&&(p=s),y>0&&y>u&&(d=u),{l:s,t:u,left:p,top:d,height:f,width:h,scroll:e}}},{key:"getCellRectByXY",value:function(t,e){var n=this.scroll,r=this.merges,i=this.rows,o=this.cols,a=function(t,e){var n=this.rows,r=this.freezeTotalHeight(),i=n.height;r+n.heightt);a+=1)o.has(a)||(l+=c=n.getHeight(a));return(l-=c)<=0?{ri:-1,top:0,height:c}:{ri:a-1,top:l,height:c}}.call(this,e,n.y),l=a.ri,c=a.top,s=a.height,u=function(t,e){var n=this.cols,r=this.freezeTotalWidth(),i=n.indexWidth;r+n.indexWidth=0||f>=0){var d=r.getFirstIncludes(l,f);if(d){l=d.sri,f=d.sci;var y=this.cellRect(l,f);h=y.left,c=y.top,p=y.width,s=y.height}}return{ri:l,ci:f,left:h,top:c,width:p,height:s}}},{key:"isSingleSelected",value:function(){var t=this.selector.range,e=t.sri,n=t.sci,r=t.eri,i=t.eci,o=this.getCell(e,n);if(o&&o.merge){var a=at(o.merge,2),l=a[0],c=a[1];if(e+l===r&&n+c===i)return!0}return!this.selector.multiple()}},{key:"canUnmerge",value:function(){var t=this.selector.range,e=t.sri,n=t.sci,r=t.eri,i=t.eci,o=this.getCell(e,n);if(o&&o.merge){var a=at(o.merge,2),l=a[0],c=a[1];if(e+l===r&&n+c===i)return!0}return!1}},{key:"merge",value:function(){var t=this,e=this.selector,n=this.rows;if(!this.isSingleSelected()){var r=at(e.size(),2),i=r[0],o=r[1];if(i>1||o>1){var a=e.range,l=a.sri,c=a.sci;this.changeData(function(){var r=n.getCellOrNew(l,c);r.merge=[i-1,o-1],t.merges.add(e.range),t.rows.deleteCells(e.range),t.rows.setCell(l,c,r)})}}}},{key:"unmerge",value:function(){var t=this,e=this.selector;if(this.isSingleSelected()){var n=e.range,r=n.sri,i=n.sci;this.changeData(function(){t.rows.deleteCell(r,i,"merge"),t.merges.deleteWithin(e.range)})}}},{key:"canAutofilter",value:function(){return!this.autoFilter.active()}},{key:"autofilter",value:function(){var t=this,e=this.autoFilter,n=this.selector;this.changeData(function(){e.active()?(e.clear(),t.exceptRowSet=new Set,t.sortedRowMap=new Map,t.unsortedRowMap=new Map):e.ref=n.range.toString()})}},{key:"setAutoFilter",value:function(t,e,n,r){var i=this.autoFilter;i.addFilter(t,n,r),i.setSort(t,e),this.resetAutoFilter()}},{key:"resetAutoFilter",value:function(){var t=this,e=this.autoFilter,n=this.rows;if(e.active()){var r=e.sort,i=e.filteredRows(function(t,e){return n.getCell(t,e)}),o=i.rset,a=i.fset,l=Array.from(a),c=Array.from(a);r&&l.sort(function(t,e){return"asc"===r.order?t-e:"desc"===r.order?e-t:0}),this.exceptRowSet=o,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,l.forEach(function(e,n){t.sortedRowMap.set(c[n],e),t.unsortedRowMap.set(e,c[n])})}}},{key:"deleteCell",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",n=this.selector;this.changeData(function(){t.rows.deleteCells(n.range,e),"all"!==e&&"format"!==e||t.merges.deleteWithin(n.range)})}},{key:"insert",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.changeData(function(){var r=e.selector.range,i=r.sri,o=r.sci,a=e.rows,l=e.merges,c=e.cols,s=i;"row"===t?a.insert(i,n):"column"===t&&(a.insertColumn(o,n),s=o,c.len+=1),l.shift(t,s,n,function(t,e,n,r){var i=a.getCell(t,e);i.merge[0]+=n,i.merge[1]+=r})})}},{key:"delete",value:function(t){var e=this;this.changeData(function(){var n=e.rows,r=e.merges,i=e.selector,o=e.cols,a=i.range,l=i.range,c=l.sri,s=l.sci,u=l.eri,f=l.eci,h=at(i.range.size(),2),p=h[0],d=h[1],y=c,v=p;"row"===t?n.delete(c,u):"column"===t&&(n.deleteColumn(s,f),y=a.sci,v=d,o.len-=f-s+1),r.shift(t,y,-v,function(t,e,r,i){var o=n.getCell(t,e);o.merge[0]+=r,o.merge[1]+=i,0===o.merge[0]&&0===o.merge[1]&&delete o.merge})})}},{key:"scrollx",value:function(t,e){var n=this.scroll,r=this.freeze,i=this.cols,o=at(r,2)[1],a=at(z.rangeReduceIf(o,i.len,0,0,t,function(t){return i.getWidth(t)}),3),l=a[0],c=a[1],s=a[2],u=c;t>0&&(u+=s),n.x!==u&&(n.ci=t>0?l:0,n.x=u,e())}},{key:"scrolly",value:function(t,e){var n=this.scroll,r=this.freeze,i=this.rows,o=at(r,1)[0],a=at(z.rangeReduceIf(o,i.len,0,0,t,function(t){return i.getHeight(t)}),3),l=a[0],c=a[1],s=a[2],u=c;t>0&&(u+=s),n.y!==u&&(n.ri=t>0?l:0,n.y=u,e())}},{key:"cellRect",value:function(t,e){var n=this.rows,r=this.cols,i=r.sumWidth(0,e),o=n.sumHeight(0,t),a=n.getCell(t,e),l=r.getWidth(e),c=n.getHeight(t);if(null!==a&&a.merge){var s=at(a.merge,2),u=s[0],f=s[1];if(u>0)for(var h=1;h<=u;h+=1)c+=n.getHeight(t+h);if(f>0)for(var p=1;p<=f;p+=1)l+=r.getWidth(e+p)}return{left:i,top:o,width:l,height:c,cell:a}}},{key:"getCell",value:function(t,e){return this.rows.getCell(t,e)}},{key:"getCellTextOrDefault",value:function(t,e){var n=this.getCell(t,e);return n&&n.text?n.text:""}},{key:"getCellStyle",value:function(t,e){var n=this.getCell(t,e);return n&&void 0!==n.style?this.styles[n.style]:null}},{key:"getCellStyleOrDefault",value:function(t,e){var n=this.styles,r=this.rows.getCell(t,e),i=r&&void 0!==r.style?n[r.style]:{};return z.merge(this.defaultStyle(),i)}},{key:"getSelectedCellStyle",value:function(){var t=this.selector,e=t.ri,n=t.ci;return this.getCellStyleOrDefault(e,n)}},{key:"setCellText",value:function(t,e,n,r){var i=this.rows,o=this.history,a=this.validations;"finished"===r?(i.setCellText(t,e,""),o.add(this.getData()),i.setCellText(t,e,n)):(i.setCellText(t,e,n),this.change(this.getData())),a.validate(t,e,n)}},{key:"freezeIsActive",value:function(){var t=at(this.freeze,2),e=t[0],n=t[1];return e>0||n>0}},{key:"setFreeze",value:function(t,e){var n=this;this.changeData(function(){n.freeze=[t,e]})}},{key:"freezeTotalWidth",value:function(){return this.cols.sumWidth(0,this.freeze[1])}},{key:"freezeTotalHeight",value:function(){return this.rows.sumHeight(0,this.freeze[0])}},{key:"setRowHeight",value:function(t,e){var n=this;this.changeData(function(){n.rows.setHeight(t,e)})}},{key:"setColWidth",value:function(t,e){var n=this;this.changeData(function(){n.cols.setWidth(t,e)})}},{key:"viewHeight",value:function(){var t=this.settings,e=t.view,n=t.showToolbar,r=t.showBottomBar,i=e.height();return r&&(i-=41),n&&(i-=41),i}},{key:"viewWidth",value:function(){return this.settings.view.width()}},{key:"freezeViewRange",value:function(){var t=at(this.freeze,2),e=t[0],n=t[1];return new v(0,0,e-1,n-1,this.freezeTotalWidth(),this.freezeTotalHeight())}},{key:"contentRange",value:function(){var t=this.rows,e=this.cols,n=at(t.maxCell(),2),r=n[0],i=n[1],o=t.sumHeight(0,r+1),a=e.sumWidth(0,i+1);return new v(0,0,r,i,a,o)}},{key:"exceptRowTotalHeight",value:function(t,e){var n=this.exceptRowSet,r=this.rows,i=Array.from(n),o=0;return i.forEach(function(n){if(ne){var i=r.getHeight(n);o+=i}}),o}},{key:"viewRange",value:function(){var t=this.scroll,e=this.rows,n=this.cols,r=this.freeze,i=this.exceptRowSet,o=t.ri,a=t.ci;o<=0&&(o=at(r,1)[0]);a<=0&&(a=at(r,2)[1]);for(var l=0,c=0,s=[e.len,n.len],u=s[0],f=s[1],h=o;hthis.viewHeight()));h+=1);for(var p=a;pthis.viewWidth()));p+=1);return new v(o,a,u,f,l,c)}},{key:"eachMergesInView",value:function(t,e){this.merges.filterIntersects(t).forEach(function(t){return e(t)})}},{key:"hideRowsOrCols",value:function(){var t=this.rows,e=this.cols,n=this.selector,r=at(n.size(),2),i=r[0],o=r[1],a=n.range,l=a.sri,c=a.sci,s=a.eri,u=a.eci;if(i===t.len)for(var f=c;f<=u;f+=1)e.setHide(f,!0);else if(o===e.len)for(var h=l;h<=s;h+=1)t.setHide(h,!0)}},{key:"unhideRowsOrCols",value:function(t,e){this["".concat(t,"s")].unhide(e)}},{key:"rowEach",value:function(t,e,n){for(var r=0,i=this.rows,o=this.exceptRowSet,a=it(o),l=0,c=0;c0&&(n(s,r,u),(r+=u)>this.viewHeight()))break}}},{key:"colEach",value:function(t,e,n){for(var r=0,i=this.cols,o=t;o<=e;o+=1){var a=i.getWidth(o);if(a>0&&(n(o,r,a),(r+=a)>this.viewWidth()))break}}},{key:"defaultStyle",value:function(){return this.settings.style}},{key:"addStyle",value:function(t){for(var e=this.styles,n=0;nMath.abs(e)?r(t>0?"right":"left",t,n):r(e>0?"down":"up",e,n)}var kt="x-spreadsheet";window.devicePixelRatio;function Ot(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1?arguments[1]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.moving=!1,this.vertical=n,this.el=a("div","".concat(kt,"-resizer ").concat(n?"vertical":"horizontal")).children(this.unhideHoverEl=a("div","".concat(kt,"-resizer-hover")).on("dblclick.stop",function(t){return e.mousedblclickHandler(t)}).css("position","absolute").hide(),this.hoverEl=a("div","".concat(kt,"-resizer-hover")).on("mousedown.stop",function(t){return e.mousedownHandler(t)}),this.lineEl=a("div","".concat(kt,"-resizer-line")).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=r,this.unhideFn=function(){}}var e,n,r;return e=t,(n=[{key:"showUnhide",value:function(t){this.unhideIndex=t,this.unhideHoverEl.show()}},{key:"hideUnhide",value:function(){this.unhideHoverEl.hide()}},{key:"show",value:function(t,e){var n=this.moving,r=this.vertical,i=this.hoverEl,o=this.lineEl,a=this.el,l=this.unhideHoverEl;if(!n){this.cRect=t;var c=t.left,s=t.top,u=t.width,f=t.height;a.offset({left:r?c+u-5:c,top:r?s:s+f-5}).show(),i.offset({width:r?5:u,height:r?f:5}),o.offset({width:r?0:e.width,height:r?e.height:0}),l.offset({left:r?5-u:c,top:r?s:5-f,width:r?5:u,height:r?f:5})}}},{key:"hide",value:function(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}},{key:"mousedblclickHandler",value:function(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}},{key:"mousedownHandler",value:function(t){var e=this,n=t,r=this.el,i=this.lineEl,o=this.cRect,a=this.vertical,l=this.minDistance,c=a?o.width:o.height;i.show(),mt(window,function(t){e.moving=!0,null!==n&&1===t.buttons&&(a?(c+=t.movementX)>l&&r.css("left","".concat(o.left+c,"px")):(c+=t.movementY)>l&&r.css("top","".concat(o.top+c,"px")),n=t)},function(){n=null,i.hide(),e.moving=!1,e.hide(),e.finishedFn&&(cn){var r=this.vertical?"height":"width";this.el.css(r,"".concat(n-15,"px")).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(r,"".concat(e,"px"))}else this.el.hide();return this}}])&&xt(e.prototype,n),r&&xt(e,r),t}();function jt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _t(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];jt(this,t),this.useHideInput=n,this.inputChange=function(){},this.cornerEl=a("div","".concat(kt,"-selector-corner")),this.areaEl=a("div","".concat(kt,"-selector-area")).child(this.cornerEl).hide(),this.clipboardEl=a("div","".concat(kt,"-selector-clipboard")).hide(),this.autofillEl=a("div","".concat(kt,"-selector-autofill")).hide(),this.el=a("div","".concat(kt,"-selector")).css("z-index","".concat(Tt)).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),n&&(this.hideInput=a("input","").on("compositionend",function(t){e.inputChange(t.target.value)}),this.el.child(this.hideInputDiv=a("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=a("div","hide-input").child(this.hideInput))),Tt+=1}return Ct(t,[{key:"setOffset",value:function(t){return this.el.offset(t).show(),this}},{key:"hide",value:function(){return this.el.hide(),this}},{key:"setAreaOffset",value:function(t){var e=t.left,n=t.top,r={width:t.width-3+.8,height:t.height-3+.8,left:e-.8,top:n-.8};this.areaEl.offset(r).show(),this.useHideInput&&(this.hideInputDiv.offset(r),this.hideInput.val("").focus())}},{key:"setClipboardOffset",value:function(t){var e=t.left,n=t.top,r=t.width,i=t.height;this.clipboardEl.offset({left:e,top:n,width:r-5,height:i-5})}},{key:"showAutofill",value:function(t){var e=t.left,n=t.top,r=t.width,i=t.height;this.autofillEl.offset({width:r-3,height:i-3,left:e,top:n}).show()}},{key:"hideAutofill",value:function(){this.autofillEl.hide()}},{key:"showClipboard",value:function(){this.clipboardEl.show()}},{key:"hideClipboard",value:function(){this.clipboardEl.hide()}}]),t}();function At(t){var e=this.data,n=t.left,r=t.top,i=t.width,o=t.height,a=t.scroll,l=t.l,c=t.t,s=e.freezeTotalWidth(),u=e.freezeTotalHeight(),f=n-s;s>l&&(f-=a.x);var h=r-u;return u>c&&(h-=a.y),{left:f,top:h,width:i,height:o}}function Rt(t){var e=this.data,n=t.left,r=t.width,i=t.height,o=t.l,a=t.t,l=t.scroll,c=e.freezeTotalWidth(),s=n-c;return c>o&&(s-=l.x),{left:s,top:a,width:r,height:i}}function Dt(t){var e=this.data,n=t.top,r=t.width,i=t.height,o=t.l,a=t.t,l=t.scroll,c=e.freezeTotalHeight(),s=n-c;return c>a&&(s-=l.y),{left:o,top:s,width:r,height:i}}function It(t){this.br.setAreaOffset(At.call(this,t))}function zt(t){this.t.setAreaOffset(Rt.call(this,t))}function Ht(t){this.l.setAreaOffset(Dt.call(this,t))}function Mt(t){this.l.setClipboardOffset(Dt.call(this,t))}function Nt(t){this.br.setClipboardOffset(At.call(this,t))}function Ft(t){this.t.setClipboardOffset(Rt.call(this,t))}function Wt(t){It.call(this,t),function(t){this.tl.setAreaOffset(t)}.call(this,t),zt.call(this,t),Ht.call(this,t)}function Vt(t){Nt.call(this,t),function(t){this.tl.setClipboardOffset(t)}.call(this,t),Ft.call(this,t),Mt.call(this,t)}var qt=function(){function t(e){var n=this;jt(this,t),this.inputChange=function(){},this.data=e,this.br=new Pt(!0),this.t=new Pt,this.l=new Pt,this.tl=new Pt,this.br.inputChange=function(t){n.inputChange(t)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=a("div","".concat(kt,"-selectors")).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,Tt+=1}return Ct(t,[{key:"resetData",value:function(t){this.data=t,this.range=t.selector.range,this.resetAreaOffset()}},{key:"hide",value:function(){this.el.hide()}},{key:"resetOffset",value:function(){var t=this.data,e=this.tl,n=this.t,r=this.l,i=this.br,o=t.freezeTotalHeight(),a=t.freezeTotalWidth();o>0||a>0?(e.setOffset({width:a,height:o}),n.setOffset({left:a,height:o}),r.setOffset({top:o,width:a}),i.setOffset({left:a,top:o})):(e.hide(),n.hide(),r.hide(),i.setOffset({left:0,top:0}))}},{key:"resetAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();Wt.call(this,t),Vt.call(this,e),this.resetOffset()}},{key:"resetBRTAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();It.call(this,t),zt.call(this,t),Nt.call(this,e),Ft.call(this,e),this.resetOffset()}},{key:"resetBRLAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();It.call(this,t),Ht.call(this,t),Nt.call(this,e),Mt.call(this,e),this.resetOffset()}},{key:"set",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.data,i=r.calSelectedRangeByStart(t,e),o=i.sri,a=i.sci;if(n){var l=t,c=e;t<0&&(l=0),e<0&&(c=0),r.selector.setIndexes(l,c),this.indexes=[l,c]}this.moveIndexes=[o,a],this.range=i,this.resetAreaOffset(),this.el.show()}},{key:"setEnd",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.data,i=this.lastri,o=this.lastci;if(n){if(t===i&&e===o)return;this.lastri=t,this.lastci=e}this.range=r.calSelectedRangeByEnd(t,e),Wt.call(this,this.data.getSelectedRect())}},{key:"reset",value:function(){var t=this.data.selector.range,e=t.eri,n=t.eci;this.setEnd(e,n)}},{key:"showAutofill",value:function(t,e){if(-1!==t||-1!==e){var n=this.range,r=n.sri,i=n.sci,o=n.eri,a=n.eci,l=t,c=e,s=r-t,u=o-t,f=a-e;if(i-e>0)this.arange=new v(r,c,o,i-1);else if(s>0)this.arange=new v(l,i,r-1,a);else if(f<0)this.arange=new v(r,a+1,o,c);else{if(!(u<0))return void(this.arange=null);this.arange=new v(o+1,i,l,a)}if(null!==this.arange){var h=this.data.getRect(this.arange);h.width+=2,h.height+=2;var p=this.br,d=this.l,y=this.t,b=this.tl;p.showAutofill(At.call(this,h)),d.showAutofill(Dt.call(this,h)),y.showAutofill(Rt.call(this,h)),b.showAutofill(h)}}}},{key:"hideAutofill",value:function(){var t=this;["br","l","t","tl"].forEach(function(e){t[e].hideAutofill()})}},{key:"showClipboard",value:function(){var t=this,e=this.data.getClipboardRect();Vt.call(this,e),["br","l","t","tl"].forEach(function(e){t[e].showClipboard()})}},{key:"hideClipboard",value:function(){var t=this;["br","l","t","tl"].forEach(function(e){t[e].hideClipboard()})}}]),t}();function Bt(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:"200px";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.filterItems=[],this.items=e,this.el=a("div","".concat(kt,"-suggest")).css("width",r).hide(),this.itemClick=n,this.itemIndex=-1}var e,n,r;return e=t,(n=[{key:"setOffset",value:function(t){this.el.cssRemoveKeys("top","bottom").offset(t)}},{key:"hide",value:function(){var t=this.el;this.filterItems=[],this.itemIndex=-1,t.hide(),bt(this.el.parent())}},{key:"setItems",value:function(t){this.items=t}},{key:"search",value:function(t){var e,n=this,r=this.items;if(/^\s*$/.test(t)||(r=r.filter(function(e){return(e.key||e).startsWith(t.toUpperCase())})),r=r.map(function(t){var e=t.title;e?"function"==typeof e&&(e=e()):e=t;var r=a("div","".concat(kt,"-item")).child(e).on("click.stop",function(){n.itemClick(t),n.hide()});return t.label&&r.child(a("div","label").html(t.label)),r}),this.filterItems=r,!(r.length<=0)){var i=this.el;(e=i.html("")).children.apply(e,Bt(r)).show(),gt(i.parent(),function(){n.hide()})}}},{key:"bindInputEvents",value:function(t){var e=this;t.on("keydown",function(t){return function(t){var e=t.keyCode;switch(t.ctrlKey&&t.stopPropagation(),e){case 37:t.stopPropagation();break;case 38:(function(t){t.preventDefault(),t.stopPropagation();var e=this.filterItems;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}).call(this,t);break;case 39:t.stopPropagation();break;case 40:(function(t){t.stopPropagation();var e=this.filterItems;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}).call(this,t);break;case 13:case 9:Ut.call(this,t);break;default:t.stopPropagation()}}.call(e,t)})}}])&&Lt(e.prototype,n),r&&Lt(e,r),t}();function $t(t){return($t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Xt(t,e){for(var n=0;nr.width){var u=l;l>c&&(u=c,s+=parseInt(l/c,10),s+=l%c>0?1:0),n.css("width","".concat(u,"px"))}(s*=this.rowHeight)>r.height&&n.css("height","".concat(s,"px"))}}function se(t){var e=t.keyCode,n=t.altKey;13!==e&&9!==e&&t.stopPropagation(),13===e&&n&&(function(t,e){var n=t.target,r=n.value,i=n.selectionEnd,o="".concat(r.slice(0,i)).concat(e).concat(r.slice(i));n.value=o,n.setSelectionRange(i+1,i+1),this.inputText=o,this.textlineEl.html(o),ce.call(this)}.call(this,t,"\n"),t.stopPropagation()),13!==e||n||t.preventDefault()}function ue(t,e){var n=this.textEl,r=this.textlineEl;n.el.blur(),n.val(t),r.html(t),function(t){var e=this.textEl.el;setTimeout(function(){e.focus(),e.setSelectionRange(t,t)},0)}.call(this,e)}var fe=function(){function t(e,n,r){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.viewFn=n,this.rowHeight=r,this.formulas=e,this.suggest=new Yt(e,function(t){(function(t){var e=this.inputText,n=this.validator,r=0;if(n&&"list"===n.type)this.inputText=t,r=this.inputText.length;else{var i=e.lastIndexOf("="),o=e.substring(0,i+1),a=e.substring(i+1);a=-1!==a.indexOf(")")?a.substring(a.indexOf(")")):"",this.inputText="".concat(o+t.key,"("),r=this.inputText.length,this.inputText+=")".concat(a)}ue.call(this,this.inputText,r)}).call(i,t)}),this.datepicker=new oe,this.datepicker.change(function(t){i.setText(function(t){var e=t.getMonth()+1,n=t.getDate();return e<10&&(e="0".concat(e)),n<10&&(n="0".concat(n)),"".concat(t.getFullYear(),"-").concat(e,"-").concat(n)}(t)),i.clear()}),this.areaEl=a("div","".concat(kt,"-editor-area")).children(this.textEl=a("textarea","").on("input",function(t){return function(t){var e=t.target.value,n=this.suggest,r=this.textlineEl,i=this.validator,o=this.cell;if(null!==o)if("editable"in o&&!0===o.editable||void 0===o.editable){if(this.inputText=e,i)"list"===i.type?n.search(e):n.hide();else{var a=e.lastIndexOf("=");-1!==a?n.search(e.substring(a+1)):n.hide()}r.html(e),ce.call(this),this.change("input",e)}else t.target.value=o.text;else{if(this.inputText=e,i)"list"===i.type?n.search(e):n.hide();else{var l=e.lastIndexOf("=");-1!==l?n.search(e.substring(l+1)):n.hide()}r.html(e),ce.call(this),this.change("input",e)}}.call(i,t)}).on("paste.stop",function(){}).on("keydown",function(t){return se.call(i,t)}),this.textlineEl=a("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",function(){}).on("mousedown.stop",function(){}),this.el=a("div","".concat(kt,"-editor")).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=function(){}}var e,n,r;return e=t,(n=[{key:"setFreezeLengths",value:function(t,e){this.freeze.w=t,this.freeze.h=e}},{key:"clear",value:function(){""!==this.inputText&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),function(){this.suggest.setItems(this.formulas)}.call(this),this.datepicker.hide()}},{key:"setOffset",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",n=this.textEl,r=this.areaEl,i=this.suggest,o=this.freeze,a=this.el;if(t){this.areaOffset=t;var l=t.left,c=t.top,s=t.width,u=t.height,f=t.l,h=t.t,p={left:0,top:0};o.w>f&&o.h>h||(o.wf?p.top=o.h:o.h>h&&(p.left=o.w)),a.offset(p),r.offset({left:l-p.left-.8,top:c-p.top-.8}),n.offset({width:s-9+.8,height:u-3+.8});var d={left:0};d[e]=u,i.setOffset(d),i.hide()}}},{key:"setCell",value:function(t,e){var n=this.el,r=this.datepicker,i=this.suggest;n.show(),this.cell=t;var o=t&&t.text||"";if(this.setText(o),this.validator=e,e){var a=e.type;"date"===a&&(r.show(),/^\s*$/.test(o)||r.setValue(o)),"list"===a&&(i.setItems(e.values()),i.search(""))}}},{key:"setText",value:function(t){this.inputText=t,ue.call(this,t,t.length),ce.call(this)}}])&&ae(e.prototype,n),r&&ae(e,r),t}();function he(t){return(he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function pe(t,e){return!e||"object"!==he(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function de(t){return(de=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function ye(t,e){return(ye=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var ve=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=pe(this,de(e).call(this,"div","".concat(kt,"-button ").concat(r)))).child(L("button.".concat(t))),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ye(t,e)}(e,o),e}();function be(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0?e-.5:.5}var je=function(){function t(e,n,r,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;me(this,t),this.x=e,this.y=n,this.width=r,this.height=i,this.padding=o,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}return ke(t,[{key:"setBorders",value:function(t){var e=t.top,n=t.bottom,r=t.left,i=t.right;e&&(this.borderTop=e),i&&(this.borderRight=i),n&&(this.borderBottom=n),r&&(this.borderLeft=r)}},{key:"innerWidth",value:function(){return this.width-2*this.padding-2}},{key:"innerHeight",value:function(){return this.height-2*this.padding-2}},{key:"textx",value:function(t){var e=this.width,n=this.padding,r=this.x;return"left"===t?r+=n:"center"===t?r+=e/2:"right"===t&&(r+=e-n),r}},{key:"texty",value:function(t,e){var n=this.height,r=this.padding,i=this.y;return"top"===t?i+=r:"middle"===t?i+=n/2-e/2:"bottom"===t&&(i+=n-r-e),i}},{key:"topxys",value:function(){var t=this.x,e=this.y;return[[t,e],[t+this.width,e]]}},{key:"rightxys",value:function(){var t=this.x,e=this.y,n=this.width;return[[t+n,e],[t+n,e+this.height]]}},{key:"bottomxys",value:function(){var t=this.x,e=this.y,n=this.width,r=this.height;return[[t,e+r],[t+n,e+r]]}},{key:"leftxys",value:function(){var t=this.x,e=this.y;return[[t,e],[t,e+this.height]]}}]),t}();function _e(t,e,n,r,i,o,a){var l={x:0,y:0};"underline"===t?l.y="bottom"===i?0:"top"===i?-(o+2):-o/2:"strike"===t&&("bottom"===i?l.y=o/2:"top"===i&&(l.y=-(o/2+2))),"center"===r?l.x=a/2:"right"===r&&(l.x=a),this.line([e-l.x,n-l.y],[e-l.x+a,n-l.y])}var Ce=function(){function t(e,n,r){me(this,t),this.el=e,this.ctx=e.getContext("2d"),this.resize(n,r),this.ctx.scale(Oe(),Oe())}return ke(t,[{key:"resize",value:function(t,e){this.el.style.width="".concat(t,"px"),this.el.style.height="".concat(e,"px"),this.el.width=xe(t),this.el.height=xe(e)}},{key:"clear",value:function(){var t=this.el,e=t.width,n=t.height;return this.ctx.clearRect(0,0,e,n),this}},{key:"attr",value:function(t){return Object.assign(this.ctx,t),this}},{key:"save",value:function(){return this.ctx.save(),this.ctx.beginPath(),this}},{key:"restore",value:function(){return this.ctx.restore(),this}},{key:"beginPath",value:function(){return this.ctx.beginPath(),this}},{key:"translate",value:function(t,e){return this.ctx.translate(xe(t),xe(e)),this}},{key:"scale",value:function(t,e){return this.ctx.scale(t,e),this}},{key:"clearRect",value:function(t,e,n,r){return this.ctx.clearRect(t,e,n,r),this}},{key:"fillRect",value:function(t,e,n,r){return this.ctx.fillRect(xe(t)-.5,xe(e)-.5,xe(n),xe(r)),this}},{key:"fillText",value:function(t,e,n){return this.ctx.fillText(t,xe(e),xe(n)),this}},{key:"text",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=this.ctx,a=r.align,l=r.valign,c=r.font,s=r.color,u=r.strike,f=r.underline,h=e.textx(a);o.save(),o.beginPath(),this.attr({textAlign:a,textBaseline:l,font:"".concat(c.italic?"italic":""," ").concat(c.bold?"bold":""," ").concat(xe(c.size),"px ").concat(c.name),fillStyle:s,strokeStyle:s});var p="".concat(t).split("\n"),d=e.innerWidth(),y=[];p.forEach(function(t){var e=o.measureText(t).width;if(i&&e>xe(d)){for(var n={w:0,len:0,start:0},r=0;r=xe(d)&&(y.push(t.substr(n.start,n.len)),n={w:0,len:0,start:r}),n.len+=1,n.w+=o.measureText(t[r]).width+1;n.len>0&&y.push(t.substr(n.start,n.len))}else y.push(t)});var v=(y.length-1)*(c.size+2),b=e.texty(l,v);return y.forEach(function(t){var e=o.measureText(t).width;n.fillText(t,h,b),u&&_e.call(n,"strike",h,b,a,l,c.size,e),f&&_e.call(n,"underline",h,b,a,l,c.size,e),b+=c.size+2}),o.restore(),this}},{key:"border",value:function(t,e){var n=this.ctx;return n.lineWidth=Se,n.strokeStyle=e,"medium"===t?n.lineWidth=xe(2)-.5:"thick"===t?n.lineWidth=xe(3):"dashed"===t?n.setLineDash([xe(3),xe(2)]):"dotted"===t?n.setLineDash([xe(1),xe(1)]):"double"===t&&n.setLineDash([xe(2),0]),this}},{key:"line",value:function(){var t=this.ctx;if(arguments.length>1){t.beginPath();var e=arguments.length<=0?void 0:arguments[0],n=ge(e,2),r=n[0],i=n[1];t.moveTo(Ee(r),Ee(i));for(var o=1;o="a"&&s<="z")r.push(s.toUpperCase());else if(s>="0"&&s<="9"||s>="A"&&s<="Z"||"."===s)r.push(s);else if('"'===s){for(c+=1;'"'!==t.charAt(c);)r.push(t.charAt(c)),c+=1;n.push('"'.concat(r.join(""))),r=[]}else if("-"===s&&/[+\-*/,(]/.test(l))r.push(s);else{if("("!==s&&r.length>0&&n.push(r.join("")),")"===s){var u=e.pop();if(2===i)try{for(var p=Ae(f(n.pop()),2),d=p[0],y=p[1],v=Ae(f(n.pop()),2),b=v[0],g=v[1],m=0,w=b;w<=d;w+=1)for(var k=g;k<=y;k+=1)n.push(h(w,k)),m+=1;n.push([u,m])}catch(t){}else if(1===i||3===i)3===i&&n.push(o),n.push([u,a]),a=1;else for(;"("!==u&&(n.push(u),!(e.length<=0));)u=e.pop();i=0}else if("="===s||">"===s||"<"===s){var O=t.charAt(c+1);o=s,"="!==O&&"-"!==O||(o+=O,c+=1),i=3}else if(":"===s)i=2;else if(","===s)3===i&&n.push(o),i=1,a+=1;else if("("===s&&r.length>0)e.push(r.join(""));else{if(e.length>0&&("+"===s||"-"===s)){var S=e[e.length-1];if("("!==S&&n.push(e.pop()),"*"===S||"/"===S)for(;e.length>0&&"("!==(S=e[e.length-1]);)n.push(e.pop())}else if(e.length>0){var x=e[e.length-1];"*"!==x&&"/"!==x||n.push(e.pop())}e.push(s)}r=[]}l=s}}for(r.length>0&&n.push(r.join(""));e.length>0;)n.push(e.pop());return n},De=function(t,e){var n=Ae(t,1)[0],r=t;if('"'===n)return t.substring(1);var i=1;if("-"===n&&(r=t.substring(1),i=-1),r[0]>="0"&&r[0]<="9")return i*Number(r);var o=Ae(f(r),2);return i*e(o[0],o[1])},Ie=function(t,e,n,r){for(var i=[],o=0;o"===l||"<"===l){var h=i.pop();Number.isNaN(h)||(h=Number(h));var p=i.pop();Number.isNaN(p)||(p=Number(p));var d=!1;"="===l?d=p===h:">"===a?d=p>h:">="===a?d=p>=h:"<"===a?d=p="a"&&l<="z"||l>="A"&&l<="Z")&&r.push(a),i.push(De(a,n)),r.pop()}}return i[0]},ze={render:function t(e,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if("="===e[0]){var o=Re(e.substring(1));return o.length<=0?e:Ie(o,n,function(e,o){return t(r(e,o),n,r,i)},i)}return e}};function He(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Me(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e3&&void 0!==arguments[3]?arguments[3]:0,i=t.cellRect(e,n),o=i.left,a=i.top,l=i.width,c=i.height;return new je(o,a+r,l,c,Ke)}function tn(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=e.sortedRowMap,a=e.rows,l=e.cols;if(!a.isHide(n)&&!l.isHide(r)){var c=n;o.has(n)&&(c=o.get(n));var s=e.getCell(c,r);if(null!==s){var u=!1;"editable"in s&&!1===s.editable&&(u=!0);var f=e.getCellStyleOrDefault(c,r),h=Qe(e,n,r,i);h.bgcolor=f.bgcolor,void 0!==f.border&&(h.setBorders(f.border),t.strokeBorders(h)),t.rect(h,function(){var i="";i=e.settings.evalPaused?s.text||"":ze.render(s.text||"",We,function(t,n){return e.getCellTextOrDefault(n,t)}),f.format&&(i=$e[f.format].render(i));var o=Object.assign({},f.font);o.size=function(t){for(var e=0;e0&&c.rows.isHide(t-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([5,i+5],[n-5,i+5]),l.restore())}),l.line([0,u+h],[n,u+h]),l.line([n,h],[n,u+h])),"all"!==t&&"top"!==t||(c.colEach(e.sci,e.eci,function(t,e,n){var i=p+e,o=t;l.line([i,0],[i,r]),v<=o&&o0&&c.cols.isHide(t-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([i+5,5],[i+5,r-5]),l.restore())}),l.line([f+p,0],[f+p,r]),l.line([0,r],[f+p,r])),l.restore()}function on(t,e,n,r,i){var o=t.sri,a=t.sci,l=t.eri,c=t.eci,s=t.w,u=t.h,f=this.draw,h=this.data,p=h.settings;f.save(),f.attr(Ge).translate(e+r,n+i),p.showGrid?(h.rowEach(o,l,function(t,e,n){t!==o&&f.line([0,e],[s,e]),t===l&&f.line([0,e+n],[s,e+n])}),h.colEach(a,c,function(t,e,n){t!==a&&f.line([e,0],[e,u]),t===c&&f.line([e+n,0],[e+n,u])}),f.restore()):f.restore()}var an=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.el=e,this.draw=new Ce(e,n.viewWidth(),n.viewHeight()),this.data=n}var e,n,r;return e=t,(n=[{key:"resetData",value:function(t){this.data=t,this.render()}},{key:"render",value:function(){var t=this.data,e=t.rows,n=t.cols.indexWidth,r=e.height;this.draw.resize(t.viewWidth(),t.viewHeight()),this.clear();var i=t.viewRange(),o=t.freezeTotalWidth(),a=t.freezeTotalHeight(),l=t.scroll,c=l.x,s=l.y;on.call(this,i,n,r,o,a),en.call(this,i,n,r,-c,-s),rn.call(this,"all",i,n,r,o,a),function(t,e){var n=this.draw;n.save(),n.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,t,e),n.restore()}.call(this,n,r);var u=Xe(t.freeze,2),f=u[0],h=u[1];if(f>0||h>0){if(f>0){var p=i.clone();p.sri=0,p.eri=f-1,p.h=a,on.call(this,p,n,r,o,0),en.call(this,p,n,r,-c,0),rn.call(this,"top",p,n,r,o,0)}if(h>0){var d=i.clone();d.sci=0,d.eci=h-1,d.w=o,on.call(this,d,n,r,0,a),rn.call(this,"left",d,n,r,0,a),en.call(this,d,n,r,0,-s)}var y=t.freezeViewRange();on.call(this,y,n,r,0,0),rn.call(this,"all",y,n,r,0,0),en.call(this,y,n,r,0,0),function(t,e,n,r){var i=this.draw,o=this.data,a=o.viewWidth()-t,l=o.viewHeight()-e;i.save().translate(t,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),i.line([0,r],[a,r]),i.line([n,0],[n,l]),i.restore()}.call(this,n,r,o,a)}}},{key:"clear",value:function(){this.draw.clear()}}])&&Ze(e.prototype,n),r&&Ze(e,r),t}();function ln(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&(h+=(l-s.w)/2);var d=0,y=0;this.contentEl.html(""),this.canvases=[];for(var v={sri:0,sci:0,eri:0,eci:0},b=function(n){var o=0,l=0,u=a("div","".concat(kt,"-canvas-card")),b=a("canvas","".concat(kt,"-canvas"));t.canvases.push(b.el);var g=new Ce(b.el,r,i);for(g.save(),g.translate(h,p),f<1&&g.scale(f,f);d<=s.eri;d+=1){var m=e.rows.getHeight(d);if(!((o+=m)1&&void 0!==arguments[1]&&arguments[1];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.menuItems=bn.call(this),this.el=(n=a("div","".concat(kt,"-contextmenu"))).children.apply(n,dn(this.menuItems)).hide(),this.viewFn=e,this.itemClick=function(){},this.isHide=r,this.setMode("range")}var e,n,r;return e=t,(n=[{key:"setMode",value:function(t){var e=this.menuItems[12];"row-col"===t?e.show():e.hide()}},{key:"hide",value:function(){var t=this.el;t.hide(),bt(t)}},{key:"setPosition",value:function(t,e){if(!this.isHide){var n=this.el,r=n.show().offset().width,i=this.viewFn(),o=i.height/2,a=t;i.width-t<=r&&(a-=r),n.css("left","".concat(a,"px")),e>o?n.css("bottom","".concat(i.height-e,"px")).css("max-height","".concat(e,"px")).css("top","auto"):n.css("top","".concat(e,"px")).css("max-height","".concat(i.height-e,"px")).css("bottom","auto"),gt(n)}}}])&&yn(e.prototype,n),r&&yn(e,r),t}();function mn(t,e){for(var n=0;n4?c-4:0),u=4;u0)&&(t=this.contentEl).children.apply(t,arguments)}},{key:"setTitle",value:function(t){this.title.html(t),this.hide()}},{key:"show",value:function(){var t=this;this.contentEl.show(),this.parent().active(),gt(this.parent(),function(){t.hide()})}},{key:"hide",value:function(){this.parent().active(!1),this.contentEl.hide(),bt(this.parent())}}])&&Tn(n.prototype,r),i&&Tn(n,i),e}();function In(t){return(In="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function zn(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e'],["medium",''],["thick",''],["dashed",''],["dotted",'']],Kr=function(t){function e(t){var n,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var i=new Gt("line-type"),o=0,l=Zr.map(function(e,n){return a("div","".concat(kt,"-item state ").concat(t===e[0]?"checked":"")).on("click",function(){l[o].toggle("checked"),l[n].toggle("checked"),o=n,r.hide(),r.change(e)}).child(a("div","".concat(kt,"-line-type")).html(e[1]))});return r=Yr(this,(n=$r(e)).call.apply(n,[this,i,"auto",!1,"bottom-left"].concat(Ur(l))))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Xr(t,e)}(e,Dn),e}();function Jr(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0?i.show():i.hide()}function Ta(t){var e=this,n=new wn;n.el.on("click",function(){t.onClick&&t.onClick(e.data.getData(),e.data)}),n.tip=t.tip||"";var r=t.el;if(t.icon&&(r=a("img").attr("src",t.icon)),r){var i=a("div","".concat(kt,"-icon"));i.child(r),n.el.child(i)}return n}var Pa=function(){function t(e,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.data=e,this.change=function(){},this.widthFn=n,this.isHide=i;var o=e.defaultStyle();this.items=[[this.undoEl=new oa,this.redoEl=new ta,new ua,this.paintformatEl=new Pi,this.clearformatEl=new xi],_a(),[this.formatEl=new jo],_a(),[this.fontEl=new ho,this.fontSizeEl=new to],_a(),[this.boldEl=new vr,this.italicEl=new kr,this.underlineEl=new Ar,this.strikeEl=new jr,this.textColorEl=new Hi(o.color)],_a(),[this.fillColorEl=new qi(o.bgcolor),this.borderEl=new hi,this.mergeEl=new Zo],_a(),[this.alignEl=new Yn(o.align),this.valignEl=new Gn(o.valign),this.textwrapEl=new ya],_a(),[this.freezeEl=new Bo,this.autofilterEl=new fr,this.formulaEl=new No]];var l=e.settings.extendToolbar,c=void 0===l?{}:l;if(c.left&&c.left.length>0){this.items.unshift(_a());var s=c.left.map(Ta.bind(this));this.items.unshift(s)}if(c.right&&c.right.length>0){this.items.push(_a());var u=c.right.map(Ta.bind(this));this.items.push(u)}this.items.push([this.moreEl=new xa]),this.el=a("div","".concat(kt,"-toolbar")),this.btns=a("div","".concat(kt,"-toolbar-btns")),this.items.forEach(function(t){Array.isArray(t)?t.forEach(function(t){r.btns.child(t.el),t.change=function(){r.change.apply(r,arguments)}}):r.btns.child(t.el)}),this.el.child(this.btns),i?this.el.hide():(this.reset(),setTimeout(function(){(function(){var t=this;this.btns2=[],this.items.forEach(function(e){if(Array.isArray(e))e.forEach(function(e){var n=e.el,r=n.box(),i=n.computedStyle(),o=i.marginLeft,a=i.marginRight;t.btns2.push([n,r.width+parseInt(o,10)+parseInt(a,10)])});else{var n=e.box(),r=e.computedStyle(),i=r.marginLeft,o=r.marginRight;t.btns2.push([e,n.width+parseInt(i,10)+parseInt(o,10)])}})}).call(r),Ca.call(r)},0),yt(window,"resize",function(){Ca.call(r)}))}var e,n,r;return e=t,(n=[{key:"paintformatActive",value:function(){return this.paintformatEl.active()}},{key:"paintformatToggle",value:function(){this.paintformatEl.toggle()}},{key:"trigger",value:function(t){this["".concat(t,"El")].click()}},{key:"resetData",value:function(t){this.data=t,this.reset()}},{key:"reset",value:function(){if(!this.isHide){var t=this.data,e=t.getSelectedCellStyle();this.undoEl.setState(!t.canUndo()),this.redoEl.setState(!t.canRedo()),this.mergeEl.setState(t.canUnmerge(),!t.selector.multiple()),this.autofilterEl.setState(!t.canAutofilter());var n=e.font,r=e.format;this.formatEl.setState(r),this.fontEl.setState(n.name),this.fontSizeEl.setState(n.size),this.boldEl.setState(n.bold),this.italicEl.setState(n.italic),this.underlineEl.setState(e.underline),this.strikeEl.setState(e.strike),this.textColorEl.setState(e.color),this.fillColorEl.setState(e.bgcolor),this.alignEl.setState(e.align),this.valignEl.setState(e.valign),this.textwrapEl.setState(e.textwrap),this.freezeEl.setState(t.freezeIsActive())}}}])&&Ea(e.prototype,n),r&&Ea(e,r),t}();function Aa(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:"600px";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.title=e,this.el=a("div","".concat(kt,"-modal")).css("width",o).children(a("div","".concat(kt,"-modal-header")).children(new Gt("close").on("click.stop",function(){return i.hide()}),this.title),(r=a("div","".concat(kt,"-modal-content"))).children.apply(r,Aa(n))).hide()}var e,n,r;return e=t,(n=[{key:"show",value:function(){var t=this;this.dimmer=a("div","".concat(kt,"-dimmer active")),document.body.appendChild(this.dimmer.el);var e=this.el.show().box(),n=e.width,r=e.height,i=document.documentElement,o=i.clientHeight,l=i.clientWidth;this.el.offset({left:(l-n)/2,top:(o-r)/3}),window.xkeydownEsc=function(e){27===e.keyCode&&t.hide()},yt(window,"keydown",window.xkeydownEsc)}},{key:"hide",value:function(){this.el.hide(),document.body.removeChild(this.dimmer.el),vt(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}])&&Ra(e.prototype,n),r&&Ra(e,r),t}();function Ia(t,e){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:function(t){return t},l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.key=e,this.getTitle=o,this.vchange=function(){},this.el=a("div","".concat(kt,"-form-select")),this.suggest=new Yt(n.map(function(t){return{key:t,title:i.getTitle(t)}}),function(t){i.itemClick(t.key),l(t.key),i.vchange(t.key)},r,this.el),this.el.children(this.itemEl=a("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",function(){return i.show()})}var e,n,r;return e=t,(n=[{key:"show",value:function(){this.suggest.search("")}},{key:"itemClick",value:function(t){this.key=t,this.itemEl.html(this.getTitle(t))}},{key:"val",value:function(t){return void 0!==t?(this.key=t,this.itemEl.html(this.getTitle(t)),this):this.key}}])&&Ha(e.prototype,n),r&&Ha(e,r),t}();function Na(t,e){for(var n=0;n3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(-1!==e||-1!==n){var o=this.table,a=this.selector,l=this.toolbar,c=this.data;this.contextMenu.setMode(-1===e||-1===n?"row-col":"range");var s=c.getCell(e,n);t?(a.setEnd(e,n,i),this.trigger("cells-selected",s,a.range)):(a.set(e,n,r),this.trigger("cell-selected",s,e,n)),l.reset(),o.render()}}function il(t,e){var n=this.selector,r=this.data,i=r.rows,o=r.cols,a=el(n.indexes,2),l=a[0],c=a[1],s=n.range,u=s.eri,f=s.eci;if(t){var h=el(n.moveIndexes,2);l=h[0],c=h[1]}"left"===e?c>0&&(c-=1):"right"===e?(f!==c&&(c=f),c0&&(l-=1):"down"===e?(u!==l&&(l=u),lu.width)n.move({left:i+c-u.width});else{var f=t.freezeTotalWidth();au.height)e.move({top:o+s-u.height-1});else{var h=t.freezeTotalHeight();l0||o>0){var a=e.freezeTotalWidth(),l=e.freezeTotalHeight();n.setFreezeLengths(a,l)}t.resetAreaOffset()}.call(this),r.render(),i.reset(),o.reset()}function cl(){var t=this.data,e=this.selector;t.clearClipboard(),e.hideClipboard()}function sl(){var t=this.data,e=this.selector;"read"!==t.settings.mode&&(t.copy(),t.copyToSystemClipboard(),e.showClipboard())}function ul(){var t=this.data,e=this.selector;"read"!==t.settings.mode&&(t.cut(),e.showClipboard())}function fl(t,e){var n=this.data;if("read"!==n.settings.mode)if(n.paste(t,function(t){return Qa("Tip",t)}))ll.call(this);else if(e){var r=e.clipboardData.getData("text/plain");this.data.pasteFromText(r),ll.call(this)}}function hl(t,e){this.data.unhideRowsOrCols(t,e),ll.call(this)}function pl(t){var e=this,n=this.selector,r=this.data,i=this.table,o=this.sortFilter,a=t.offsetX,l=t.offsetY,c=t.target.className==="".concat(kt,"-selector-corner"),s=r.getCellRectByXY(a,l),u=s.left,f=s.top,h=s.width,p=s.height,d=s.ri,y=s.ci,v=r.autoFilter;if(v.includes(d,y)&&u+h-20n.height/2&&(r="bottom"),t.setOffset(e,r)}function yl(){var t=this.editor,e=this.data;"read"!==e.settings.mode&&(dl.call(this),t.setCell(e.getSelectedCell(),e.getSelectedValidator()),cl.call(this))}function vl(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"finished",n=this.data,r=this.table;if("read"!==n.settings.mode){n.setSelectedCellText(t,e);var i=n.selector,o=i.ri,a=i.ci;"finished"===e?r.render():this.trigger("cell-edited",t,o,a)}}function bl(t){var e=this.data;"read"!==e.settings.mode&&("insert-row"===t?e.insert("row"):"delete-row"===t?e.delete("row"):"insert-column"===t?e.insert("column"):"delete-column"===t?e.delete("column"):"delete-cell"===t?e.deleteCell():"delete-cell-format"===t?e.deleteCell("format"):"delete-cell-text"===t?e.deleteCell("text"):"cell-printable"===t?e.setSelectedCellAttr("printable",!0):"cell-non-printable"===t?e.setSelectedCellAttr("printable",!1):"cell-editable"===t?e.setSelectedCellAttr("editable",!0):"cell-non-editable"===t&&e.setSelectedCellAttr("editable",!1),cl.call(this),ll.call(this))}function gl(t,e){var n=this.data;if("undo"===t)this.undo();else if("redo"===t)this.redo();else if("print"===t)this.print.preview();else if("paintformat"===t)!0===e?sl.call(this):cl.call(this);else if("clearformat"===t)bl.call(this,"delete-cell-format");else if("link"===t);else if("chart"===t);else if("autofilter"===t)(function(){this.data.autofilter(),ll.call(this)}).call(this);else if("freeze"===t)if(e){var r=n.selector,i=r.ri,o=r.ci;this.freeze(i,o)}else this.freeze(0,0);else n.setSelectedCellAttr(t,e),"formula"!==t||n.selector.multiple()||yl.call(this),ll.call(this)}function ml(){var t,e,n,r,i,o,a=this,l=this.selector,c=this.overlayerEl,s=this.rowResizer,u=this.colResizer,f=this.verticalScrollbar,h=this.horizontalScrollbar,p=this.editor,d=this.contextMenu,y=this.toolbar,v=this.modalValidation,b=this.sortFilter;c.on("mousemove",function(t){(function(t){if(0===t.buttons&&t.target.className!=="".concat(kt,"-resizer-hover")){var e=t.offsetX,n=t.offsetY,r=this.rowResizer,i=this.colResizer,o=this.tableEl,a=this.data,l=a.rows,c=a.cols;if(e>c.indexWidth&&n>l.height)return r.hide(),void i.hide();var s=o.box(),u=a.getCellRectByXY(t.offsetX,t.offsetY);u.ri>=0&&-1===u.ci?(u.width=c.indexWidth,r.show(u,{width:s.width}),l.isHide(u.ri-1)?r.showUnhide(u.ri):r.hideUnhide()):r.hide(),-1===u.ri&&u.ci>=0?(u.height=l.height,i.show(u,{height:s.height}),c.isHide(u.ci-1)?i.showUnhide(u.ci):i.hideUnhide()):i.hide()}}).call(a,t)}).on("mousedown",function(t){p.clear(),d.hide(),2===t.buttons?(a.data.xyInSelectedRect(t.offsetX,t.offsetY)?d.setPosition(t.offsetX,t.offsetY):(pl.call(a,t),d.setPosition(t.offsetX,t.offsetY)),t.stopPropagation()):2===t.detail?yl.call(a):pl.call(a,t)}).on("mousewheel.stop",function(t){(function(t){var e=this.verticalScrollbar,n=this.horizontalScrollbar,r=this.data,i=e.scroll().top,o=n.scroll().left,a=r.rows,l=r.cols,c=t.deltaY,s=t.deltaX,u=function(t,e){var n=t,r=0;do{r=e(n),n+=1}while(r<=0);return r},f=function(t){if(t>0){var n=r.scroll.ri+1;if(n=0){var c=u(l,function(t){return a.getHeight(t)});e.move({top:0===l?0:i-c})}}},h=Math.abs(c),p=Math.abs(s),d=Math.max(h,p);/Firefox/i.test(window.navigator.userAgent)&&nl(f(t.detail),50),d===p&&nl(function(t){if(t>0){var e=r.scroll.ci+1;if(e=0){var c=u(a,function(t){return l.getWidth(t)});n.move({left:0===a?0:o-c})}}}(s),50),d===h&&nl(f(c),50)}).call(a,t)}).on("mouseout",function(t){var e=t.offsetX;t.offsetY<=0&&u.hide(),e<=0&&s.hide()}),l.inputChange=function(t){vl.call(a,t,"input"),yl.call(a)},t=c.el,n=(e={move:function(t,e){(function(t,e){var n=this.verticalScrollbar,r=this.horizontalScrollbar,i=n.scroll().top,o=r.scroll().left;"left"===t||"right"===t?r.move({left:o-e}):"up"!==t&&"down"!==t||n.move({top:i-e})}).call(a,t,e)}}).move,r=e.end,i=0,o=0,yt(t,"touchstart",function(t){var e=t.touches[0],n=e.pageX,r=e.pageY;i=n,o=r}),yt(t,"touchmove",function(t){if(n){var e=t.changedTouches[0],r=e.pageX,a=e.pageY,l=r-i,c=a-o;(Math.abs(l)>10||Math.abs(c)>10)&&(wt(l,c,t,n),i=r,o=a),t.preventDefault()}}),yt(t,"touchend",function(t){if(r){var e=t.changedTouches[0],n=e.pageX,a=e.pageY;wt(n-i,a-o,t,r)}}),y.change=function(t,e){return gl.call(a,t,e)},b.ok=function(t,e,n,r){return function(t,e,n,r){this.data.setAutoFilter(t,e,n,r),ll.call(this)}.call(a,t,e,n,r)},s.finishedFn=function(t,e){(function(t,e){var n=t.ri,r=this.table,i=this.selector;this.data.rows.setHeight(n,e),r.render(),i.resetAreaOffset(),ol.call(this),dl.call(this)}).call(a,t,e)},u.finishedFn=function(t,e){(function(t,e){var n=t.ci,r=this.table,i=this.selector;this.data.cols.setWidth(n,e),r.render(),i.resetAreaOffset(),al.call(this),dl.call(this)}).call(a,t,e)},s.unhideFn=function(t){hl.call(a,"row",t)},u.unhideFn=function(t){hl.call(a,"col",t)},f.moveFn=function(t,e){(function(t){var e=this,n=this.data,r=this.table,i=this.selector;n.scrolly(t,function(){i.resetBRLAreaOffset(),dl.call(e),r.render()})}).call(a,t,e)},h.moveFn=function(t,e){(function(t){var e=this,n=this.data,r=this.table,i=this.selector;n.scrollx(t,function(){i.resetBRTAreaOffset(),dl.call(e),r.render()})}).call(a,t,e)},p.change=function(t,e){vl.call(a,e,t)},v.change=function(t){if("save"===t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i=65&&e<=90||e>=48&&e<=57||e>=96&&e<=105||"="===t.key?(vl.call(a,t.key,"input"),yl.call(a)):113===e&&yl.call(a)}}})}var wl=function(){function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.eventMap=function(){var t=new Map;function e(e,n){var r;return t.has(e)&&(r=t.get(e),Array.isArray(r)&&r.push(n)||!1)||t.set(e,[].concat(n))}function n(e,n){var r,i;return t.has(e)&&(r=t.get(e),(i=r.indexOf(n))>=0&&r.splice(i,1)&&0===t.get(e).length&&t.delete(e))}return{get current(){return t},on:e,once:function(t,r){return e(t,function e(){for(var i=arguments.length,o=new Array(i),a=0;a1?n-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:function(){},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};xl(this,t),this.swapFunc=r,this.updateFunc=o,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new Pl(function(t){e.clickSwap2(e.items[t])}),this.contextMenu=new Dl,this.contextMenu.itemClick=i,this.el=a("div","".concat(kt,"-bottombar")).children(this.contextMenu.el,this.menuEl=a("ul","".concat(kt,"-menu")).child(a("li","").children(new Gt("add").on("click",function(){n()}),a("span","").child(this.moreEl))))}return jl(t,[{key:"addItem",value:function(t,e){var n=this;this.dataNames.push(t);var r=a("li",e?"active":"").child(t);r.on("click",function(){n.clickSwap2(r)}).on("contextmenu",function(t){var e=t.target,i=e.offsetLeft,o=e.offsetHeight;n.contextMenu.setOffset({left:i,bottom:o+1}),n.deleteEl=r}).on("dblclick",function(){var t=r.html(),e=new za("auto","");e.val(t),e.input.on("blur",function(e){var r=e.target.value,i=n.dataNames.findIndex(function(e){return e===t});n.renameItem(i,r)}),r.html("").child(e.el),e.focus()}),e&&this.clickSwap(r),this.items.push(r),this.menuEl.child(r),this.moreEl.reset(this.dataNames)}},{key:"renameItem",value:function(t,e){this.dataNames.splice(t,1,e),this.moreEl.reset(this.dataNames),this.items[t].html("").child(e),this.updateFunc(t,e)}},{key:"clear",value:function(){var t=this;this.items.forEach(function(e){t.menuEl.removeChild(e.el)}),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}},{key:"deleteItem",value:function(){var t=this.activeEl,e=this.deleteEl;if(this.items.length>1){var n=this.items.findIndex(function(t){return t===e});if(this.items.splice(n,1),this.dataNames.splice(n,1),this.menuEl.removeChild(e.el),this.moreEl.reset(this.dataNames),t===e){var r=kl(this.items,1)[0];return this.activeEl=r,this.activeEl.toggle(),[n,0]}return[n,-1]}return[-1]}},{key:"clickSwap2",value:function(t){var e=this.items.findIndex(function(e){return e===t});this.clickSwap(t),this.activeEl.toggle(),this.swapFunc(e)}},{key:"clickSwap",value:function(t){null!==this.activeEl&&this.activeEl.toggle(),this.activeEl=t}}]),t}();n(1);function zl(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Hl(t,e){var n=Object.keys(t);return Object.getOwnPropertySymbols&&n.push.apply(n,Object.getOwnPropertySymbols(t)),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n}function Ml(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nl(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=e;this.options=function(t){for(var e=1;e1&&void 0!==arguments[1])||arguments[1],r=t||"sheet".concat(this.sheetIndex),i=new pt(r,this.options);return i.change=function(){for(var t,n=arguments.length,r=new Array(n),i=0;i=0&&(this.datas.splice(e,1),n>=0&&this.sheet.resetData(this.datas[n]))}}},{key:"loadData",value:function(t){var e=Array.isArray(t)?t:[t];if(null!==this.bottombar&&this.bottombar.clear(),this.datas=[],e.length>0)for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:0;return this.datas[r].setCellText(t,e,n,"finished"),this}},{key:"cell",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.datas[n].getCell(t,e)}},{key:"cellStyle",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.datas[n].getCellStyle(t,e)}},{key:"reRender",value:function(){return this.sheet.table.render(),this}},{key:"on",value:function(t,e){return this.sheet.on(t,e),this}},{key:"validate",value:function(){return this.data.validations.errors.size<=0}},{key:"change",value:function(t){return this.sheet.on("change",t),this}}])&&Nl(e.prototype,n),r&&Nl(e,r),t}(),Wl=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Fl(t,e)};window&&(window.x_spreadsheet=Wl,window.x_spreadsheet.locale=function(t,e){return Y(t,e)});e.default=Fl}]); //# sourceMappingURL=xspreadsheet.js.map ================================================ FILE: docs/dist/index.html ================================================ x-spreadsheet
================================================ FILE: docs/dist/locale/de.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Rückgängig machen",redo:"Wiederherstellen",paintformat:"Format kopieren/einfügen",clearformat:"Format löschen",format:"Format",font:"Schriftart",fontSize:"Schriftgrad",fontBold:"Fett",fontItalic:"Kursiv",underline:"Betonen",strike:"Streichen",textColor:"Text Farbe",fillColor:"Füllung Farbe",border:"Umrandung",merge:"Zellen verbinden",align:"Waagrechte Ausrichtung",valign:"Vertikale uitlijning",textwrap:"Textumbruch",freeze:"Zelle sperren",formula:"Funktionen",more:"Mehr"},contextmenu:{copy:"Kopieren",cut:"Ausschneiden",paste:"Einfügen",pasteValue:"Nur Werte einfügen",pasteFormat:"Nur Format einfügen",insertRow:"Zeile einfügen",insertColumn:"Spalte einfügen",deleteRow:"Zeile löschen",deleteColumn:"Spalte löschen",deleteCell:"Zelle löschen",deleteCellText:"Zellentext löschen"},format:{normal:"Regulär",text:"Text",number:"Nummer",percent:"Prozent",rmb:"RMB",usd:"USD",date:"Datum",time:"Termin",datetime:"Datum Termin",duration:"Dauer"},formula:{sum:"Summe",average:"Durchschnittliche",max:"Max",min:"Min",concat:"Concat"}};window&&window.x&&window.x.spreadsheet&&(window.x.spreadsheet.$messages=window.x.spreadsheet.$messages||{},window.x.spreadsheet.$messages.de=r),t.default=r}]); ================================================ FILE: docs/dist/locale/en.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([,function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Undo",redo:"Redo",paintformat:"Paint format",clearformat:"Clear format",format:"Format",font:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",textColor:"Text color",fillColor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",insertRow:"Insert row",insertColumn:"Insert column",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations"},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{cancel:"Cancel",remove:"Remove",save:"Save"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};window&&window.x&&window.x.spreadsheet&&(window.x.spreadsheet.$messages=window.x.spreadsheet.$messages||{},window.x.spreadsheet.$messages.en=r),t.default=r}]); ================================================ FILE: docs/dist/locale/nl.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}({2:function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Ongedaan maken",redo:"Opnieuw uitvoeren",paintformat:"Opmaak kopiëren/plakken",clearformat:"Opmaak wissen",format:"Opmaak",font:"Lettertype",fontSize:"Tekengrootte",fontBold:"Vet",fontItalic:"Cursief",underline:"Onderstrepen",strike:"Doorstrepen",textColor:"Tekstkleur",fillColor:"Opvulkleur",border:"Randen",merge:"Cellen samenvoegen",align:"Horizontale uitlijning",valign:"Verticale uitlijning",textwrap:"Terugloop",freeze:"Cel bevriezen",formula:"Functies",more:"Meer"},contextmenu:{copy:"Kopiëren",cut:"Knippen",paste:"Plakken",pasteValue:"Alleen waarden plakken",pasteFormat:"Alleen opmaak plakken",insertRow:"Rij invoegen",insertColumn:"Kolom invoegen",deleteRow:"Rij verwijderen",deleteColumn:"Kolom verwijderen",deleteCell:"Cel verwijderen",deleteCellText:"Celtekst verwijderen"},format:{normal:"Standaard",text:"Tekst",number:"Nummer",percent:"Percentage",rmb:"RMB",usd:"USD",date:"Datum",time:"Tijdstip",datetime:"Datum tijd",duration:"Duratie"},formula:{sum:"Som",average:"Gemiddelde",max:"Max",min:"Min",concat:"Concat"}};window&&window.x&&window.x.spreadsheet&&(window.x.spreadsheet.$messages=window.x.spreadsheet.$messages||{},window.x.spreadsheet.$messages.nl=r),t.default=r}}); ================================================ FILE: docs/dist/locale/zh-cn.js ================================================ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}({3:function(e,t,r){"use strict";r.r(t);const n={toolbar:{undo:"撤销",redo:"恢复",paintformat:"格式刷",clearformat:"清除格式",format:"数据格式",font:"字体",fontSize:"字号",fontBold:"加粗",fontItalic:"倾斜",underline:"下划线",strike:"删除线",textColor:"字体颜色",fillColor:"填充颜色",border:"边框",merge:"合并单元格",align:"水平对齐",valign:"垂直对齐",textwrap:"自动换行",freeze:"冻结",formula:"函数",more:"更多"},contextmenu:{copy:"复制",cut:"剪切",paste:"粘贴",pasteValue:"粘贴数据",pasteFormat:"粘贴格式",insertRow:"插入行",insertColumn:"插入列",deleteRow:"删除行",deleteColumn:"删除列",deleteCell:"删除",deleteCellText:"删除数据",validation:"数据验证"},format:{normal:"正常",text:"文本",number:"数值",percent:"百分比",rmb:"人民币",usd:"美元",date:"短日期",time:"时间",datetime:"长日期",duration:"持续时间"},formula:{sum:"求和",average:"求平均值",max:"求最大值",min:"求最小值",concat:"字符拼接"},validation:{required:"此值必填",notMatch:"此值不匹配验证规则",between:"此值应在 {} 和 {} 之间",notBetween:"此值不应在 {} 和 {} 之间",notIn:"此值不在列表中",equal:"此值应该等于 {}",notEqual:"此值不应该等于 {}",lessThan:"此值应该小于 {}",lessThanEqual:"此值应该小于等于 {}",greaterThan:"此值应该大于 {}",greaterThanEqual:"此值应该大于等于 {}"},error:{pasteForMergedCell:"无法对合并的单元格执行此操作"},calendar:{weeks:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},button:{cancel:"取消",remove:"删除",save:"保存"},dataValidation:{mode:"模式",range:"单元区间",criteria:"条件",modeType:{cell:"单元格",column:"列模式",row:"行模式"},type:{list:"列表",number:"数字",date:"日期",phone:"手机号",email:"电子邮件"},operator:{be:"在区间",nbe:"不在区间",lt:"小于",lte:"小于等于",gt:"大于",gte:"大于等于",eq:"等于",neq:"不等于"}}};window&&window.x&&window.x.spreadsheet&&(window.x.spreadsheet.$messages=window.x.spreadsheet.$messages||{},window.x.spreadsheet.$messages["zh-cn"]=n),t.default=n}}); ================================================ FILE: docs/dist/xspreadsheet.css ================================================ body { margin: 0; } .x-spreadsheet { font-size: 13px; line-height: normal; user-select: none; -moz-user-select: none; font-family: 'Lato', 'Source Sans Pro', Roboto, Helvetica, Arial, sans-serif; box-sizing: content-box; background: #fff; -webkit-font-smoothing: antialiased; } .x-spreadsheet textarea { font: 400 13px Arial, 'Lato', 'Source Sans Pro', Roboto, Helvetica, sans-serif; } .x-spreadsheet-sheet { position: relative; overflow: hidden; } .x-spreadsheet-table { vertical-align: bottom; } .x-spreadsheet-tooltip { font-family: inherit; position: absolute; padding: 5px 10px; color: #fff; border-radius: 1px; background: #000000; font-size: 12px; z-index: 201; } .x-spreadsheet-tooltip:before { pointer-events: none; position: absolute; left: calc(50% - 4px); top: -4px; content: ""; width: 8px; height: 8px; background: inherit; -webkit-transform: rotate(45deg); transform: rotate(45deg); z-index: 1; box-shadow: 1px 1px 3px -1px rgba(0, 0, 0, 0.3); } .x-spreadsheet-color-palette { padding: 5px; } .x-spreadsheet-color-palette table { margin: 0; padding: 0; border-collapse: separate; border-spacing: 2; background: #fff; } .x-spreadsheet-color-palette table td { margin: 0; cursor: pointer; border: 1px solid transparent; } .x-spreadsheet-color-palette table td:hover { border-color: #ddd; } .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell { width: 16px; height: 16px; } .x-spreadsheet-border-palette { padding: 6px; } .x-spreadsheet-border-palette table { margin: 0; padding: 0; border-collapse: separate; border-spacing: 0; background: #fff; table-layout: fixed; } .x-spreadsheet-border-palette table td { margin: 0; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left { border-right: 1px solid #eee; padding-right: 6px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell { width: 30px; height: 30px; cursor: pointer; text-align: center; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell .x-spreadsheet-icon-img { opacity: 0.8; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover { background-color: #eee; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right { padding-left: 6px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-toolbar-btn { margin-top: 0; margin-bottom: 3px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type { position: relative; left: 0; top: -3px; } .x-spreadsheet-dropdown { position: relative; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content { position: absolute; z-index: 200; background: #fff; box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15); } .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content { top: calc(100% + 5px); left: 0; } .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content { top: calc(100% + 5px); right: 0; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title { padding: 0 5px; display: inline-block; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-left { margin-left: 4px; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right { width: 10px; margin-right: 4px; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right .arrow-down { left: -130px; } /* resizer **/ .x-spreadsheet-resizer { position: absolute; z-index: 11; } .x-spreadsheet-resizer .x-spreadsheet-resizer-hover { background-color: rgba(75, 137, 255, 0.25); } .x-spreadsheet-resizer .x-spreadsheet-resizer-line { position: absolute; } .x-spreadsheet-resizer.horizontal { cursor: row-resize; } .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line { border-bottom: 2px dashed #4b89ff; left: 0; bottom: 0; } .x-spreadsheet-resizer.vertical { cursor: col-resize; } .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line { border-right: 2px dashed #4b89ff; top: 0; right: 0; } /* scrollbar */ .x-spreadsheet-scrollbar { position: absolute; bottom: 0; right: 0; background-color: #f4f5f8; opacity: 0.9; z-index: 12; } .x-spreadsheet-scrollbar.horizontal { right: 15px; overflow-x: scroll; overflow-y: hidden; } .x-spreadsheet-scrollbar.vertical { bottom: 15px; overflow-x: hidden; overflow-y: scroll; } /* @{css-prefix}-overlayer */ .x-spreadsheet-overlayer { position: absolute; left: 0; top: 0; z-index: 10; } .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content { position: absolute; overflow: hidden; pointer-events: none; width: 100%; height: 100%; } .x-spreadsheet-editor, .x-spreadsheet-selector { position: absolute; overflow: hidden; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; } /* @{css-prefix}-selector */ .x-spreadsheet-selector .x-spreadsheet-selector-area { position: absolute; border: 2px solid #4b89ff; background: rgba(75, 137, 255, 0.1); } .x-spreadsheet-selector .x-spreadsheet-selector-clipboard, .x-spreadsheet-selector .x-spreadsheet-selector-autofill { position: absolute; background: transparent; z-index: 100; } .x-spreadsheet-selector .x-spreadsheet-selector-clipboard { border: 2px dashed #4b89ff; } .x-spreadsheet-selector .x-spreadsheet-selector-autofill { border: 1px dashed rgba(0, 0, 0, 0.45); } .x-spreadsheet-selector .x-spreadsheet-selector-corner { pointer-events: auto; position: absolute; cursor: crosshair; font-size: 0; height: 5px; width: 5px; right: -5px; bottom: -5px; border: 2px solid #ffffff; background: #4b89ff; } .x-spreadsheet-editor { z-index: 20; } .x-spreadsheet-editor .x-spreadsheet-editor-area { position: absolute; text-align: left; border: 2px solid #4b89ff; line-height: 0; z-index: 100; pointer-events: auto; } .x-spreadsheet-editor .x-spreadsheet-editor-area textarea { box-sizing: content-box; border: none; padding: 0 3px; outline-width: 0; resize: none; text-align: start; overflow-y: hidden; font: 400 13px Arial, 'Lato', 'Source Sans Pro', Roboto, Helvetica, sans-serif; color: inherit; white-space: normal; word-wrap: break-word; line-height: 22px; margin: 0; } .x-spreadsheet-editor .x-spreadsheet-editor-area .textline { overflow: hidden; visibility: hidden; position: fixed; top: 0; left: 0; } .x-spreadsheet-item { user-select: none; background: 0; border: 1px solid transparent; outline: none; height: 26px; color: rgba(0, 0, 0, 0.9); line-height: 26px; list-style: none; padding: 2px 10px; cursor: default; text-align: left; } .x-spreadsheet-item.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-item:hover, .x-spreadsheet-item.active { background: rgba(0, 0, 0, 0.05); } .x-spreadsheet-item.divider { height: 0; padding: 0; margin: 5px 0; border: none; border-bottom: 1px solid rgba(0, 0, 0, 0.1); } .x-spreadsheet-item .label { float: right; opacity: 0.65; font-size: 1em; } .x-spreadsheet-item.state, .x-spreadsheet-header.state { padding-left: 35px!important; position: relative; } .x-spreadsheet-item.state:before, .x-spreadsheet-header.state:before { content: ''; position: absolute; width: 10px; height: 10px; left: 12px; top: calc(50% - 5px); background: rgba(0, 0, 0, 0.08); border-radius: 2px; } .x-spreadsheet-item.state.checked:before, .x-spreadsheet-header.state.checked:before { background: #4b89ff; } .x-spreadsheet-checkbox { position: relative; display: inline-block; backface-visibility: hidden; outline: 0; vertical-align: baseline; font-style: normal; font-size: 1rem; line-height: 1em; } .x-spreadsheet-checkbox > input { position: absolute; top: 0; left: 0; opacity: 0!important; outline: 0; z-index: -1; } .x-spreadsheet-suggest, .x-spreadsheet-contextmenu, .x-spreadsheet-sort-filter { position: absolute; box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15); background: #fff; z-index: 100; width: 260px; pointer-events: auto; overflow: auto; } .x-spreadsheet-suggest { width: 200px; } .x-spreadsheet-filter { border: 1px solid #e9e9e9; font-size: 12px; margin: 10px; } .x-spreadsheet-filter .x-spreadsheet-header { padding: 0.5em 0.75em; background: #f8f8f9; border-bottom: 1px solid #e9e9e9; border-left: 1px solid transparent; } .x-spreadsheet-filter .x-spreadsheet-body { height: 200px; overflow-y: auto; } .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item { height: 20px; line-height: 20px; } .x-spreadsheet-sort-filter .x-spreadsheet-buttons { margin: 10px; } .x-spreadsheet-toolbar, .x-spreadsheet-bottombar { height: 40px; padding: 0 30px; text-align: left; background: #f5f6f7; display: flex; } .x-spreadsheet-bottombar { border-top: 1px solid #e0e2e4; } .x-spreadsheet-toolbar { border-bottom: 1px solid #e0e2e4; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btns { display: inline-flex; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more { padding: 0 6px 6px; text-align: left; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-toolbar-divider { margin-top: 0; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn { flex: 0 0 auto; display: inline-block; border: 1px solid transparent; height: 26px; line-height: 26px; min-width: 26px; margin: 6px 1px 0; padding: 0; text-align: center; border-radius: 2px; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn:hover, .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.active { background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-toolbar-divider { display: inline-block; border-right: 1px solid #e0e2e4; width: 0; vertical-align: middle; height: 18px; margin: 12px 3px 0; } .x-spreadsheet-calendar { color: rgba(0, 0, 0, 0.65); background: #ffffff; user-select: none; } .x-spreadsheet-calendar .calendar-header { font-weight: 700; line-height: 30px; text-align: center; width: 100%; float: left; background: #f9fafb; } .x-spreadsheet-calendar .calendar-header .calendar-header-left { padding-left: 5px; float: left; } .x-spreadsheet-calendar .calendar-header .calendar-header-right { float: right; } .x-spreadsheet-calendar .calendar-header .calendar-header-right a { padding: 3px 0; margin-right: 2px; border-radius: 2px; } .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover { background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-calendar .calendar-body { border-collapse: collapse; border-spacing: 0; } .x-spreadsheet-calendar .calendar-body th, .x-spreadsheet-calendar .calendar-body td { width: 14.28571429%; min-width: 32px; text-align: center; font-weight: 700; line-height: 30px; padding: 0; } .x-spreadsheet-calendar .calendar-body td > .cell:hover { background: #ecf6fd; } .x-spreadsheet-calendar .calendar-body td > .cell.active, .x-spreadsheet-calendar .calendar-body td > .cell.active:hover { background: #ecf6fd; color: #2185D0; } .x-spreadsheet-calendar .calendar-body td > .cell.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-datepicker { box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); position: absolute; left: 0; top: calc(100% + 5px); z-index: 10; width: auto; } .x-spreadsheet-buttons { display: flex; justify-content: flex-end; } .x-spreadsheet-buttons .x-spreadsheet-button { margin-left: 8px; } .x-spreadsheet-button { display: inline-block; border-radius: 3px; line-height: 1em; min-height: 1em; white-space: nowrap; text-align: center; cursor: pointer; font-size: 1em; font-weight: 700; padding: 0.75em 1em; color: rgba(0, 0, 0, 0.6); background: #E0E1E2; text-decoration: none; font-family: "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif; outline: none; vertical-align: baseline; zoom: 1; user-select: none; transition: all 0.1s linear; } .x-spreadsheet-button.active, .x-spreadsheet-button:hover { background-color: #C0C1C2; color: rgba(0, 0, 0, 0.8); } .x-spreadsheet-button.primary { color: #fff; background-color: #2185D0; } .x-spreadsheet-button.primary:hover, .x-spreadsheet-button.primary.active { color: #fff; background-color: #1678c2; } .x-spreadsheet-form-input { font-size: 1em; position: relative; font-weight: 400; display: inline-flex; color: rgba(0, 0, 0, 0.87); } .x-spreadsheet-form-input input { z-index: 1; margin: 0; max-width: 100%; flex: 1 0 auto; outline: 0; -webkit-tap-highlight-color: rgba(255, 255, 255, 0); text-align: left; line-height: 30px; height: 30px; padding: 0 8px; background: #fff; border: 1px solid #e9e9e9; border-radius: 3px; transition: box-shadow 0.1s ease, border-color 0.1s ease; box-shadow: inset 0 1px 2px hsla(0, 0%, 4%, 0.06); } .x-spreadsheet-form-input input:focus { border-color: #4b89ff; box-shadow: inset 0 1px 2px rgba(75, 137, 255, 0.2); } .x-spreadsheet-form-select { position: relative; display: inline-block; background: #fff; border: 1px solid #e9e9e9; border-radius: 2px; cursor: pointer; color: rgba(0, 0, 0, 0.87); user-select: none; box-shadow: inset 0 1px 2px hsla(0, 0%, 4%, 0.06); } .x-spreadsheet-form-select .input-text { text-overflow: ellipsis; white-space: nowrap; min-width: 60px; width: auto; height: 30px; line-height: 30px; padding: 0 8px; } .x-spreadsheet-form-fields { display: flex; flex-direction: row; flex-wrap: wrap; } .x-spreadsheet-form-fields .x-spreadsheet-form-field { flex: 0 1 auto; } .x-spreadsheet-form-fields .x-spreadsheet-form-field .label { display: inline-block; margin: 0 10px 0 0; } .x-spreadsheet-form-field { display: block; vertical-align: middle; margin-left: 10px; margin-bottom: 10px; } .x-spreadsheet-form-field:first-child { margin-left: 0; } .x-spreadsheet-form-field.error .x-spreadsheet-form-select, .x-spreadsheet-form-field.error input { border-color: #f04134; } .x-spreadsheet-form-field .tip { color: #f04134; font-size: 0.9em; } .x-spreadsheet-dimmer { display: none; position: absolute; top: 0 !important; left: 0 !important; width: 100%; height: 100%; text-align: center; vertical-align: middle; background-color: rgba(0, 0, 0, 0.6); opacity: 0; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration: 0.5s; animation-duration: 0.5s; transition: background-color 0.5s linear; user-select: none; z-index: 1000; } .x-spreadsheet-dimmer.active { display: block; opacity: 1; } .x-spreadsheet-modal, .x-spreadsheet-toast { font-size: 13px; position: fixed; z-index: 1001; text-align: left; line-height: 1.25em; min-width: 360px; color: rgba(0, 0, 0, 0.87); font-family: 'Lato', 'Source Sans Pro', Roboto, Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.1); background-color: #fff; background-clip: padding-box; box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 8px; } .x-spreadsheet-toast { background-color: rgba(255, 255, 255, 0.85); } .x-spreadsheet-modal-header, .x-spreadsheet-toast-header { font-weight: 600; background-clip: padding-box; background-color: rgba(255, 255, 255, 0.85); border-bottom: 1px solid rgba(0, 0, 0, 0.05); border-radius: 4px 4px 0 0; } .x-spreadsheet-modal-header .x-spreadsheet-icon, .x-spreadsheet-toast-header .x-spreadsheet-icon { position: absolute; right: 0.8em; top: 0.65em; border-radius: 18px; } .x-spreadsheet-modal-header .x-spreadsheet-icon:hover, .x-spreadsheet-toast-header .x-spreadsheet-icon:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-toast-header { color: #F2711C; } .x-spreadsheet-modal-header { border-bottom: 1px solid #e0e2e4; background: rgba(0, 0, 0, 0.08); font-size: 1.0785em; } .x-spreadsheet-modal-header, .x-spreadsheet-modal-content, .x-spreadsheet-toast-header, .x-spreadsheet-toast-content { padding: 0.75em 1em; } @media screen and (min-width: 320px) and (max-width: 480px) { .x-spreadsheet-toolbar { display: none; } } .x-spreadsheet-icon { width: 18px; height: 18px; margin: 1px 1px 2px 1px; text-align: center; vertical-align: middle; user-select: none; overflow: hidden; position: relative; display: inline-block; } .x-spreadsheet-icon .x-spreadsheet-icon-img { background-image: url(58eaeb4e52248a5c75936c6f4c33a370.svg); position: absolute; width: 262px; height: 444px; opacity: 0.56; } .x-spreadsheet-icon .x-spreadsheet-icon-img.undo { left: 0; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.redo { left: -18px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.print { left: -36px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.paintformat { left: -54px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.clearformat { left: -72px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.font-bold { left: -90px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.font-italic { left: -108px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.underline { left: -126px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.strike { left: -144px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.color { left: -162px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.bgcolor { left: -180px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.merge { left: -198px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-left { left: -216px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-center { left: -234px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-right { left: 0; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-top { left: -18px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-middle { left: -36px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-bottom { left: -54px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.textwrap { left: -72px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.autofilter { left: -90px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.formula { left: -108px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-down { left: -126px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-right { left: -144px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.link { left: -162px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chart { left: -180px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.freeze { left: -198px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.ellipsis { left: -216px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.add { left: -234px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-all { left: 0; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-inside { left: -18px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-horizontal { left: -36px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-vertical { left: -54px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-outside { left: -72px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-left { left: -90px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-top { left: -108px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-right { left: -126px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-bottom { left: -144px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-none { left: -162px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.line-color { left: -180px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.line-type { left: -198px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.close { left: -234px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-down { left: 0; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-up { left: -18px; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-left { left: -36px; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-right { left: -54px; top: -54px; } /*# sourceMappingURL=xspreadsheet.css.map*/ ================================================ FILE: docs/dist/xspreadsheet.js ================================================ !function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){},function(t,e,n){"use strict";function r(t){return function(t){if(Array.isArray(t))return t}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:"";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e?(this.el=document.createElement(e),this.el.className=n):this.el=e,this.data={}}var e,n,o;return e=t,(n=[{key:"data",value:function(t,e){return void 0!==e?(this.data[t]=e,this):this.data[t]}},{key:"on",value:function(t,e){var n=r(t.split(".")),i=n[0],o=n.slice(1),a=i;return"mousewheel"===a&&/Firefox/i.test(window.navigator.userAgent)&&(a="DOMMouseScroll"),this.el.addEventListener(a,function(t){e(t);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"active";return this.toggleClass(t)}},{key:"toggleClass",value:function(t){return this.el.classList.toggle(t)}},{key:"active",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"active";return t?this.addClass(e):this.removeClass(e),this}},{key:"checked",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.active(t,"checked"),this}},{key:"disabled",value:function(){return!(arguments.length>0&&void 0!==arguments[0])||arguments[0]?this.addClass("disabled"):this.removeClass("disabled"),this}},{key:"attr",value:function(t,e){var n=this;if(void 0!==e)this.el.setAttribute(t,e);else{if("string"==typeof t)return this.el.getAttribute(t);Object.keys(t).forEach(function(e){n.el.setAttribute(e,t[e])})}return this}},{key:"removeAttr",value:function(t){return this.el.removeAttribute(t),this}},{key:"html",value:function(t){return void 0!==t?(this.el.innerHTML=t,this):this.el.innerHTML}},{key:"val",value:function(t){return void 0!==t?(this.el.value=t,this):this.el.value}},{key:"cssRemoveKeys",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:"";return new o(t,e)};function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var c=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function s(t){for(var e="",n=t;n>=c.length;)n/=c.length,n-=1,e+=c[parseInt(n,10)%c.length];var r=t%c.length;return e+=c[r]}function u(t){for(var e=0,n=0;n="0"&&t.charAt(r)<="9"?n+=t.charAt(r):e+=t.charAt(r);return[u(e),parseInt(n,10)-1]}function h(t,e){return"".concat(s(t)).concat(e+1)}function y(t,e,n){var r=l(f(t),2);return h(r[0]+e,r[1]+n)}function p(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function v(t,e){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sri=e,this.sci=n,this.eri=r,this.eci=i,this.w=o,this.h=a}var e,n,r;return e=t,r=[{key:"valueOf",value:function(e){var n=e.split(":"),r=p(f(n[0]),2),i=r[0],o=r[1],a=o,l=i;if(n.length>1){var c=p(f(n[1]),2);l=c[0],a=c[1]}return new t(o,i,a,l)}}],(n=[{key:"set",value:function(t,e,n,r){this.sri=t,this.sci=e,this.eri=n,this.eci=r}},{key:"multiple",value:function(){return this.eri-this.sri>0||this.eci-this.sci>0}},{key:"includes",value:function(){for(var t=0,e=0,n=arguments.length,r=new Array(n),i=0;i1&&void 0!==arguments[1]?arguments[1]:function(){return!0},n=this.sri,r=this.sci,i=this.eri,o=this.eci,a=n;a<=i;a+=1)if(e(a))for(var l=r;l<=o;l+=1)t(a,l)}},{key:"contains",value:function(t){return this.sri<=t.sri&&this.sci<=t.sci&&this.eri>=t.eri&&this.eci>=t.eci}},{key:"within",value:function(t){return this.sri>=t.sri&&this.sci>=t.sci&&this.eri<=t.eri&&this.eci<=t.eci}},{key:"disjoint",value:function(t){return this.sri>t.eri||this.sci>t.eci||t.sri>this.eri||t.sci>this.eci}},{key:"intersects",value:function(t){return this.sri<=t.eri&&this.sci<=t.eci&&t.sri<=this.eri&&t.sci<=this.eci}},{key:"union",value:function(e){var n=this.sri,r=this.sci,i=this.eri,o=this.eci;return new t(e.srii?e.eri:i,e.eci>o?e.eci:o)}},{key:"difference",value:function(e){var n=[],r=function(e,r,i,o){n.push(new t(e,r,i,o))},i=this.sri,o=this.sci,a=this.eri,l=this.eci,c=e.sri-i,s=e.sci-o,u=a-e.eri,f=l-e.eci;return c>0?(r(i,o,e.sri-1,l),u>0?(r(e.eri+1,o,a,l),s>0&&r(e.sri,o,e.eri,e.sci-1),f>0&&r(e.sri,e.eci+1,e.eri,l)):(s>0&&r(e.sri,o,a,e.sci-1),f>0&&r(e.sri,e.eci+1,a,l))):u>0&&(r(e.eri+1,o,a,l),s>0&&r(i,o,e.eri,e.sci-1),f>0&&r(i,e.eci+1,e.eri,l)),s>0?(r(i,o,a,e.sci-1),f>0?(r(i,e.eri+1,a,l),c>0&&r(i,e.sci,e.sri-1,e.eci),u>0&&r(e.sri+1,e.sci,a,e.eci)):(c>0&&r(i,e.sci,e.sri-1,l),u>0&&r(e.sri+1,e.sci,a,l))):f>0&&(r(a,e.eci+1,a,l),c>0&&r(i,o,e.sri-1,e.eci),u>0&&r(e.eri+1,o,a,e.eci)),n}},{key:"size",value:function(){return[this.eri-this.sri+1,this.eci-this.sci+1]}},{key:"toString",value:function(){var t=this.sri,e=this.sci,n=this.eri,r=this.eci,i=h(e,t);return this.multiple()&&(i="".concat(i,":").concat(h(r,n))),i}},{key:"clone",value:function(){return new t(this.sri,this.sci,this.eri,this.eci,this.w,this.h)}},{key:"equals",value:function(t){return this.eri===t.eri&&this.eci===t.eci&&this.sri===t.sri&&this.sci===t.sci}}])&&v(e.prototype,n),r&&v(e,r),t}();function b(t,e){for(var n=0;n0}},{key:"canRedo",value:function(){return this.redoItems.length>0}},{key:"undo",value:function(t,e){var n=this.undoItems,r=this.redoItems;this.canUndo()&&(r.push(JSON.stringify(t)),e(JSON.parse(n.pop())))}},{key:"redo",value:function(t,e){var n=this.undoItems,r=this.redoItems;this.canRedo()&&(n.push(JSON.stringify(t)),e(JSON.parse(r.pop())))}}])&&w(e.prototype,n),r&&w(e,r),t}();function O(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._=e}var e,n,r;return e=t,(n=[{key:"forEach",value:function(t){this._.forEach(t)}},{key:"deleteWithin",value:function(t){this._=this._.filter(function(e){return!e.within(t)})}},{key:"getFirstIncludes",value:function(t,e){for(var n=0;n=e?(s.sri+=n,s.eri+=n):o=e?(s.sci+=n,s.eci+=n):a0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length,r=new Array(n>1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:function(t){return t},n=0,r=0;return Object.keys(t).forEach(function(i){n+=e(t[i],i),r+=1}),[n,r]},rangeEach:function(t,e,n){for(var r=t;ri);c+=1)a+=l=o(c);return[c,a-l,l]},deleteProperty:function(t,e){var n=t["".concat(e)];return delete t["".concat(e)],n}};function D(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function z(t,e){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:"all",i=this.getOrNew(t);"all"===r?i.cells[e]=n:"text"===r?(i.cells[e]=i.cells[e]||{},i.cells[e].text=n.text):"format"===r&&(i.cells[e]=i.cells[e]||{},i.cells[e].style=n.style,n.merge&&(i.cells[e].merge=n.merge))}},{key:"setCellText",value:function(t,e,n){this.getCellOrNew(t,e).text=n}},{key:"copyPaste",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},o=t.sri,a=t.sci,l=t.eri,c=t.eci,s=e.sri,u=e.sci,f=e.eri,h=e.eci,p=D(t.size(),2),v=p[0],d=p[1],b=D(e.size(),2),g=b[0],m=b[1],w=!0,k=0;(f0&&function(){var t=C.text,e=E-u+(x-s)+2;if(w||(e-=k+1),"="===t[0])C.text=t.replace(/\w{1,3}\d/g,function(t){var n=0,r=0;return o===s?n=e-1:r=e-1,y(t,n,r)});else{var n=/[\\.\d]+$/.exec(t);if(null!==n){var r=Number(n[0])+e-1;C.text=t.substring(0,n.index)+r}}}(),this.setCell(j,_,C,n),i(j,_,C)}}},{key:"cutPaste",value:function(t,e){var n=this,r={};this.each(function(i){n.eachCells(i,function(o){var a=parseInt(i,10),l=parseInt(o,10);t.includes(i,o)&&(a=e.sri+(a-t.sri),l=e.sci+(l-t.sci)),r[a]=r[a]||{cells:{}},r[a].cells[l]=n._[i].cells[o]})}),this._=r}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n={};this.each(function(r,i){var o=parseInt(r,10);o>=t&&(o+=e),n[o]=i}),this._=n,this.len+=e}},{key:"delete",value:function(t,e){var n=e-t+1,r={};this.each(function(i,o){var a=parseInt(i,10);ae&&(r[a-n]=o)}),this._=r,this.len-=n}},{key:"insertColumn",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.each(function(r,i){var o={};e.eachCells(r,function(e,r){var i=parseInt(e,10);i>=t&&(i+=n),o[i]=r}),i.cells=o})}},{key:"deleteColumn",value:function(t,e){var n=this,r=e-t+1;this.each(function(i,o){var a={};n.eachCells(i,function(n,i){var o=parseInt(n,10);oe&&(a[o-r]=i)}),o.cells=a})}},{key:"deleteCells",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t.each(function(t,r){e.deleteCell(t,r,n)})}},{key:"deleteCell",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=this.get(t);if(null!==r){var i=this.getCell(t,e);null!==i&&("all"===n?delete r.cells[e]:"text"===n?(i.text&&delete i.text,i.value&&delete i.value):"format"===n?(void 0!==i.style&&delete i.style,i.merge&&delete i.merge):"merge"===n&&i.merge&&delete i.merge)}}},{key:"each",value:function(t){Object.entries(this._).forEach(function(e){var n=D(e,2),r=n[0],i=n[1];t(r,i)})}},{key:"eachCells",value:function(t,e){this._[t]&&this._[t].cells&&Object.entries(this._[t].cells).forEach(function(t){var n=D(t,2),r=n[0],i=n[1];e(r,i)})}},{key:"setData",value:function(t){t.len&&(this.len=t.len,delete t.len),this._=t}},{key:"getData",value:function(){var t=this.len;return Object.assign({len:t},this._)}}])&&z(e.prototype,n),r&&z(e,r),t}();function M(t,e){for(var n=0;n A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}}};function N(t,e){if(e&&e[F])for(var n=e[F],r=t.split("."),i=0;i2?r-2:0),o=2;o=this.parseValue(l)&&o<=this.parseValue(c),"between",l,c)}if("nbe"===n){var s=L(r,2),u=s[0],f=s[1];return $(othis.parseValue(f),"notBetween",u,f)}if("eq"===n)return $(o===this.parseValue(r),"equal",r);if("neq"===n)return $(o!==this.parseValue(r),"notEqual",r);if("lt"===n)return $(othis.parseValue(r),"greaterThan",r);if("gte"===n)return $(o>=this.parseValue(r),"greaterThanEqual",r)}return[!0]}}])&&U(e.prototype,n),r&&U(e,r),t}();function K(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function J(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Z(t,e){for(var n=0;n0}).map(function(t){return t.getData()})}},{key:"setData",value:function(t){this._=t.map(function(t){return Q.valueOf(t)})}}]),t}();function et(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:function(){},r=this.merges,i=e.clone(),o=rt(t.size(),2),a=o[0],l=o[1],c=rt(e.size(),2),s=c[0],u=c[1];return a>s&&(i.eri=e.sri+a-1),l>u&&(i.eci=e.sci+l-1),!r.intersects(i)||(n(V("error.pasteForMergedCell")),!1)}function at(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this.rows,o=this.merges;"all"!==n&&"format"!==n||(i.deleteCells(e,n),o.deleteWithin(e)),i.copyPaste(t,e,n,r,function(t,e,n){if(n&&n.merge){var r=rt(n.merge,2),i=r[0],a=r[1];if(i<=0&&a<=0)return;o.add(new d(t,e,t+i,e+a))}})}function lt(t,e,n){var r=this.styles,i=this.rows.getCellOrNew(t,e),o={};void 0!==i.style&&(o=R.cloneDeep(r[i.style])),Object.assign(o,{border:n}),i.style=this.addStyle(o)}var ct=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=R.merge(it,n||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new A,this.rows=new I(this.settings.row),this.cols=new W(this.settings.col),this.validations=new tt,this.hyperlinks={},this.comments={},this.selector=new g,this.scroll=new m,this.history=new k,this.clipboard=new S,this.autoFilter=new T,this.change=function(){},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}var e,n,r;return e=t,(n=[{key:"addValidation",value:function(t,e,n){var r=this;this.changeData(function(){r.validations.add(t,e,n)})}},{key:"removeValidation",value:function(){var t=this,e=this.selector.range;this.changeData(function(){t.validations.remove(e)})}},{key:"getSelectedValidator",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=this.validations.get(e,n);return r?r.validator:null}},{key:"getSelectedValidation",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=t.range,i=this.validations.get(e,n),o={ref:r.toString()};return null!==i&&(o.mode=i.mode,o.validator=i.validator),o}},{key:"canUndo",value:function(){return this.history.canUndo()}},{key:"canRedo",value:function(){return this.history.canRedo()}},{key:"undo",value:function(){var t=this;this.history.undo(this.getData(),function(e){t.setData(e)})}},{key:"redo",value:function(){var t=this;this.history.redo(this.getData(),function(e){t.setData(e)})}},{key:"copy",value:function(){this.clipboard.copy(this.selector.range)}},{key:"cut",value:function(){this.clipboard.cut(this.selector.range)}},{key:"paste",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=this.clipboard,i=this.selector;return!r.isClear()&&(!!ot.call(this,r.range,i.range,n)&&(this.changeData(function(){r.isCopy()?at.call(t,r.range,i.range,e):r.isCut()&&function(t,e){var n=this.clipboard,r=this.rows,i=this.merges;r.cutPaste(t,e),i.move(t,e.sri-t.sri,e.sci-t.sci),n.clear()}.call(t,r.range,i.range)}),!0))}},{key:"autofill",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=this.selector.range;return!!ot.call(this,i,t,r)&&(this.changeData(function(){at.call(n,i,t,e,!0)}),!0)}},{key:"clearClipboard",value:function(){this.clipboard.clear()}},{key:"calSelectedRangeByEnd",value:function(t,e){var n=this.selector,r=this.rows,i=this.cols,o=this.merges,a=n.range,l=a.sri,c=a.sci,s=a.eri,u=a.eci,f=n.ri,h=n.ci,y=t,p=e;return t<0&&(y=r.len-1),e<0&&(p=i.len-1),y>f?(l=f,s=y):(l=y,s=f),p>h?(c=h,u=p):(c=p,u=h),n.range=o.union(new d(l,c,s,u)),n.range=o.union(n.range),n.range}},{key:"calSelectedRangeByStart",value:function(t,e){var n=this.selector,r=this.rows,i=this.cols,o=this.merges.getFirstIncludes(t,e);return null===o&&(o=new d(t,e,t,e),-1===t&&(o.sri=0,o.eri=r.len-1),-1===e&&(o.sci=0,o.eci=i.len-1)),n.range=o,o}},{key:"setSelectedCellAttr",value:function(t,e){var n=this;this.changeData(function(){var r=n.selector,i=n.styles,o=n.rows;if("merge"===t)e?n.merge():n.unmerge();else if("border"===t)(function(t){var e=this,n=t.mode,r=t.style,i=t.color,o=this.styles,a=this.selector,l=this.rows,c=a.range,s=c.sri,u=c.sci,f=c.eri,h=c.eci,y=!this.isSignleSelected();if(y||"inside"!==n&&"horizontal"!==n&&"vertical"!==n)if("outside"!==n||y){if("none"===n)a.range.each(function(t,n){var r=l.getCell(t,n);if(r&&void 0!==r.style){var i=R.cloneDeep(o[r.style]);delete i.border,r.style=e.addStyle(i)}});else if("all"===n||"inside"===n||"outside"===n||"horizontal"===n||"vertical"===n)!function(){for(var t=[],o=s;o<=f;o+=1)for(var a=u;a<=h;a+=1){for(var c=[],p=0;ph)break;var w=l.getCell(o,a),k=0,O=0;if(w&&w.merge){var S=rt(w.merge,2);k=S[0],O=S[1],t.push([o,a,k,O])}var x=k>0&&o+k===f,E=O>0&&a+O===h,j={};"all"===n?j={bottom:[r,i],top:[r,i],left:[r,i],right:[r,i]}:"inside"===n?(!E&&a0&<.call(e,o,a,j),a+=O}}();else if("top"===n||"bottom"===n)for(var p=u;p<=h;p+=1)"top"===n&&(lt.call(this,s,p,{top:[r,i]}),p+=l.getCellMerge(s,p)[1]),"bottom"===n&&(lt.call(this,f,p,{bottom:[r,i]}),p+=l.getCellMerge(f,p)[1]);else if("left"===n||"right"===n)for(var v=s;v<=f;v+=1)"left"===n&&(lt.call(this,v,u,{left:[r,i]}),v+=l.getCellMerge(v,u)[0]),"right"===n&&(lt.call(this,v,h,{right:[r,i]}),v+=l.getCellMerge(v,h)[0])}else lt.call(this,s,u,{top:[r,i],bottom:[r,i],left:[r,i],right:[r,i]})}).call(n,e);else if("formula"===t){var a=r.ri,l=r.ci,c=r.range;if(r.multiple()){var s=rt(r.size(),2),u=s[0],f=s[1],y=c.sri,p=c.sci,v=c.eri,d=c.eci;if(u>1)for(var b=p;b<=d;b+=1){o.getCellOrNew(v+1,b).text="=".concat(e,"(").concat(h(b,y),":").concat(h(b,v),")")}else if(f>1){o.getCellOrNew(a,d+1).text="=".concat(e,"(").concat(h(p,a),":").concat(h(d,a),")")}}else{o.getCellOrNew(a,l).text="=".concat(e,"()")}}else r.range.each(function(r,a){var l=o.getCellOrNew(r,a),c={};if(void 0!==l.style&&(c=R.cloneDeep(i[l.style])),"format"===t)c.format=e,l.style=n.addStyle(c);else if("font-bold"===t||"font-italic"===t||"font-name"===t||"font-size"===t){var s={};s[t.split("-")[1]]=e,c.font=Object.assign(c.font||{},s),l.style=n.addStyle(c)}else"strike"!==t&&"textwrap"!==t&&"underline"!==t&&"align"!==t&&"valign"!==t&&"color"!==t&&"bgcolor"!==t||(c[t]=e,l.style=n.addStyle(c))})})}},{key:"setSelectedCellText",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"input",n=this.autoFilter,r=this.selector,i=this.rows,o=r.ri,a=r.ci,l=o;this.unsortedRowMap.has(o)&&(l=this.unsortedRowMap.get(o));var c=i.getCell(l,a),s=c?c.text:"";if(this.setCellText(l,a,t,e),n.active()){var u=n.getFilter(a);if(u){var f=u.value.findIndex(function(t){return t===s});f>=0&&u.value.splice(f,1,t)}}}},{key:"getSelectedCell",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=e;return this.unsortedRowMap.has(e)&&(r=this.unsortedRowMap.get(e)),this.rows.getCell(r,n)}},{key:"xyInSelectedRect",value:function(t,e){var n=this.getSelectedRect(),r=n.left,i=n.top,o=n.width,a=n.height,l=t-this.cols.indexWidth,c=e-this.rows.height;return l>r&&li&&c0&&d>s&&(y=s),v>0&&v>u&&(p=u),{l:s,t:u,left:y,top:p,height:f,width:h,scroll:e}}},{key:"getCellRectByXY",value:function(t,e){var n=this.scroll,r=this.merges,i=this.rows,o=this.cols,a=function(t,e){var n=this.rows,r=this.freezeTotalHeight(),i=n.height;r+n.heightt);a+=1)o.has(a)||(l+=c=n.getHeight(a));return(l-=c)<=0?{ri:-1,top:0,height:c}:{ri:a-1,top:l,height:c}}.call(this,e,n.y),l=a.ri,c=a.top,s=a.height,u=function(t,e){var n=this.cols,r=this.freezeTotalWidth(),i=n.indexWidth;r+n.indexWidth=0||f>=0){var p=r.getFirstIncludes(l,f);if(p){l=p.sri,f=p.sci;var v=this.cellRect(l,f);h=v.left,c=v.top,y=v.width,s=v.height}}return{ri:l,ci:f,left:h,top:c,width:y,height:s}}},{key:"isSignleSelected",value:function(){var t=this.selector.range,e=t.sri,n=t.sci,r=t.eri,i=t.eci,o=this.getCell(e,n);if(o&&o.merge){var a=rt(o.merge,2),l=a[0],c=a[1];if(e+l===r&&n+c===i)return!0}return!this.selector.multiple()}},{key:"canUnmerge",value:function(){var t=this.selector.range,e=t.sri,n=t.sci,r=t.eri,i=t.eci,o=this.getCell(e,n);if(o&&o.merge){var a=rt(o.merge,2),l=a[0],c=a[1];if(e+l===r&&n+c===i)return!0}return!1}},{key:"merge",value:function(){var t=this,e=this.selector,n=this.rows;if(!this.isSignleSelected()){var r=rt(e.size(),2),i=r[0],o=r[1];if(i>1||o>1){var a=e.range,l=a.sri,c=a.sci;this.changeData(function(){var r=n.getCellOrNew(l,c);r.merge=[i-1,o-1],t.merges.add(e.range),t.rows.deleteCells(e.range),t.rows.setCell(l,c,r)})}}}},{key:"unmerge",value:function(){var t=this,e=this.selector;if(this.isSignleSelected()){var n=e.range,r=n.sri,i=n.sci;this.changeData(function(){t.rows.deleteCell(r,i,"merge"),t.merges.deleteWithin(e.range)})}}},{key:"canAutofilter",value:function(){return!this.autoFilter.active()}},{key:"autofilter",value:function(){var t=this,e=this.autoFilter,n=this.selector;this.changeData(function(){e.active()?(e.clear(),t.exceptRowSet=new Set,t.sortedRowMap=new Map,t.unsortedRowMap=new Map):e.ref=n.range.toString()})}},{key:"setAutoFilter",value:function(t,e,n,r){var i=this.autoFilter;i.addFilter(t,n,r),i.setSort(t,e),this.resetAutoFilter()}},{key:"resetAutoFilter",value:function(){var t=this,e=this.autoFilter,n=this.rows;if(e.active()){var r=e.sort,i=e.filteredRows(function(t,e){return n.getCell(t,e)}),o=i.rset,a=i.fset,l=Array.from(a),c=Array.from(a);r&&l.sort(function(t,e){return"asc"===r.order?t-e:"desc"===r.order?e-t:0}),this.exceptRowSet=o,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,l.forEach(function(e,n){t.sortedRowMap.set(c[n],e),t.unsortedRowMap.set(e,c[n])})}}},{key:"deleteCell",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",n=this.selector;this.changeData(function(){t.rows.deleteCells(n.range,e),"all"!==e&&"format"!==e||t.merges.deleteWithin(n.range)})}},{key:"insert",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.changeData(function(){var r=e.selector.range,i=r.sri,o=r.sci,a=e.rows,l=e.merges,c=e.cols,s=i;"row"===t?a.insert(i,n):"column"===t&&(a.insertColumn(o,n),s=o,c.len+=1),l.shift(t,s,n,function(t,e,n,r){var i=a.getCell(t,e);i.merge[0]+=n,i.merge[1]+=r})})}},{key:"delete",value:function(t){var e=this;this.changeData(function(){var n=e.rows,r=e.merges,i=e.selector,o=e.cols,a=i.range,l=i.range,c=l.sri,s=l.sci,u=l.eri,f=l.eci,h=rt(i.range.size(),2),y=h[0],p=h[1],v=c,d=y;"row"===t?n.delete(c,u):"column"===t&&(n.deleteColumn(s,f),v=a.sci,d=p,o.len-=1),r.shift(t,v,-d,function(t,e,r,i){var o=n.getCell(t,e);o.merge[0]+=r,o.merge[1]+=i,0===o.merge[0]&&0===o.merge[1]&&delete o.merge})})}},{key:"scrollx",value:function(t,e){var n=this.scroll,r=this.freeze,i=this.cols,o=rt(r,2)[1],a=rt(R.rangeReduceIf(o,i.len,0,0,t,function(t){return i.getWidth(t)}),3),l=a[0],c=a[1],s=a[2],u=c;t>0&&(u+=s),n.x!==u&&(n.ci=t>0?l:0,n.x=u,e())}},{key:"scrolly",value:function(t,e){var n=this.scroll,r=this.freeze,i=this.rows,o=rt(r,1)[0],a=rt(R.rangeReduceIf(o,i.len,0,0,t,function(t){return i.getHeight(t)}),3),l=a[0],c=a[1],s=a[2],u=c;t>0&&(u+=s),n.y!==u&&(n.ri=t>0?l:0,n.y=u,e())}},{key:"cellRect",value:function(t,e){var n=this.rows,r=this.cols,i=r.sumWidth(0,e),o=n.sumHeight(0,t),a=n.getCell(t,e),l=r.getWidth(e),c=n.getHeight(t);if(null!==a&&a.merge){var s=rt(a.merge,2),u=s[0],f=s[1];if(u>0)for(var h=1;h<=u;h+=1)c+=n.getHeight(t+h);if(f>0)for(var y=1;y<=f;y+=1)l+=r.getWidth(e+y)}return{left:i,top:o,width:l,height:c,cell:a}}},{key:"getCell",value:function(t,e){return this.rows.getCell(t,e)}},{key:"getCellTextOrDefault",value:function(t,e){var n=this.getCell(t,e);return n&&n.text?n.text:""}},{key:"getCellStyle",value:function(t,e){var n=this.getCell(t,e);return n&&void 0!==n.style?this.styles[n.style]:null}},{key:"getCellStyleOrDefault",value:function(t,e){var n=this.styles,r=this.rows.getCell(t,e),i=r&&void 0!==r.style?n[r.style]:{};return R.merge(this.defaultStyle(),i)}},{key:"getSelectedCellStyle",value:function(){var t=this.selector,e=t.ri,n=t.ci;return this.getCellStyleOrDefault(e,n)}},{key:"setCellText",value:function(t,e,n,r){var i=this.rows,o=this.history,a=this.validations;"finished"===r?(i.setCellText(t,e,""),o.add(this.getData()),i.setCellText(t,e,n)):(i.setCellText(t,e,n),this.change(this.getData())),a.validate(t,e,n)}},{key:"freezeIsActive",value:function(){var t=rt(this.freeze,2),e=t[0],n=t[1];return e>0||n>0}},{key:"setFreeze",value:function(t,e){var n=this;this.changeData(function(){n.freeze=[t,e]})}},{key:"freezeTotalWidth",value:function(){return this.cols.sumWidth(0,this.freeze[1])}},{key:"freezeTotalHeight",value:function(){return this.rows.sumHeight(0,this.freeze[0])}},{key:"setRowHeight",value:function(t,e){var n=this;this.changeData(function(){n.rows.setHeight(t,e)})}},{key:"setColWidth",value:function(t,e){var n=this;this.changeData(function(){n.cols.setWidth(t,e)})}},{key:"viewHeight",value:function(){var t=this.settings,e=t.view,n=t.showToolbar,r=e.height();return n&&(r-=41),r}},{key:"viewWidth",value:function(){return this.settings.view.width()}},{key:"freezeViewRange",value:function(){var t=rt(this.freeze,2),e=t[0],n=t[1];return new d(0,0,e-1,n-1,this.freezeTotalWidth(),this.freezeTotalHeight())}},{key:"exceptRowTotalHeight",value:function(t,e){var n=this.exceptRowSet,r=this.rows,i=Array.from(n),o=0;return i.forEach(function(n){if(ne){var i=r.getHeight(n);o+=i}}),o}},{key:"viewRange",value:function(){var t=this.scroll,e=this.rows,n=this.cols,r=this.freeze,i=this.exceptRowSet,o=t.ri,a=t.ci;o<=0&&(o=rt(r,1)[0]);a<=0&&(a=rt(r,2)[1]);for(var l=0,c=0,s=[e.len,n.len],u=s[0],f=s[1],h=o;hthis.viewHeight()));h+=1);for(var y=a;ythis.viewWidth()));y+=1);return new d(o,a,u,f,l,c)}},{key:"eachMergesInView",value:function(t,e){this.merges.filterIntersects(t).forEach(function(t){return e(t)})}},{key:"rowEach",value:function(t,e,n){for(var r=0,i=this.rows,o=this.exceptRowSet,a=et(o),l=0,c=0;cthis.viewHeight())break}}},{key:"colEach",value:function(t,e,n){for(var r=0,i=this.cols,o=t;o<=e;o+=1){var a=i.getWidth(o);if(n(o,r,a),(r+=a)>this.viewWidth())break}}},{key:"defaultStyle",value:function(){return this.settings.style}},{key:"addStyle",value:function(t){for(var e=this.styles,n=0;nMath.abs(e)?r(t>0?"right":"left",t,n):r(e>0?"down":"up",e,n)}var vt="x-spreadsheet";window.devicePixelRatio;function dt(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1?arguments[1]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.moving=!1,this.vertical=n,this.el=a("div","".concat(vt,"-resizer ").concat(n?"vertical":"horizontal")).children(this.hoverEl=a("div","".concat(vt,"-resizer-hover")).on("mousedown.stop",function(t){return e.mousedownHandler(t)}),this.lineEl=a("div","".concat(vt,"-resizer-line")).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=r}var e,n,r;return e=t,(n=[{key:"show",value:function(t,e){var n=this.moving,r=this.vertical,i=this.hoverEl,o=this.lineEl,a=this.el;if(!n){this.cRect=t;var l=t.left,c=t.top,s=t.width,u=t.height;a.offset({left:r?l+s-5:l,top:r?c:c+u-5}).show(),i.offset({width:r?5:s,height:r?u:5}),o.offset({width:r?0:e.width,height:r?e.height:0})}}},{key:"hide",value:function(){this.el.offset({left:0,top:0}).hide()}},{key:"mousedownHandler",value:function(t){var e=this,n=t,r=this.el,i=this.lineEl,o=this.cRect,a=this.vertical,l=this.minDistance,c=a?o.width:o.height;i.show(),yt(window,function(t){e.moving=!0,null!==n&&1===t.buttons&&(a?(c+=t.movementX)>l&&r.css("left","".concat(o.left+c,"px")):(c+=t.movementY)>l&&r.css("top","".concat(o.top+c,"px")),n=t)},function(){n=null,i.hide(),e.moving=!1,e.hide(),e.finishedFn&&(cn){var r=this.vertical?"height":"width";this.el.css(r,"".concat(n-15,"px")).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(r,"".concat(e,"px"))}else this.el.hide();return this}}])&>(e.prototype,n),r&>(e,r),t}();function wt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function kt(t,e){for(var n=0;nl&&(f-=a.x);var h=r-u;return u>c&&(h-=a.y),{left:f,top:h,width:i,height:o}}function jt(t){var e=this.data,n=t.left,r=t.width,i=t.height,o=t.l,a=t.t,l=t.scroll,c=e.freezeTotalWidth(),s=n-c;return c>o&&(s-=l.x),{left:s,top:a,width:r,height:i}}function _t(t){var e=this.data,n=t.top,r=t.width,i=t.height,o=t.l,a=t.t,l=t.scroll,c=e.freezeTotalHeight(),s=n-c;return c>a&&(s-=l.y),{left:o,top:s,width:r,height:i}}function Ct(t){this.br.setAreaOffset(Et.call(this,t))}function Tt(t){this.t.setAreaOffset(jt.call(this,t))}function Pt(t){this.l.setAreaOffset(_t.call(this,t))}function At(t){this.l.setClipboardOffset(_t.call(this,t))}function Rt(t){this.br.setClipboardOffset(Et.call(this,t))}function Dt(t){this.t.setClipboardOffset(jt.call(this,t))}function zt(t){Ct.call(this,t),function(t){this.tl.setAreaOffset(t)}.call(this,t),Tt.call(this,t),Pt.call(this,t)}function It(t){Rt.call(this,t),function(t){this.tl.setClipboardOffset(t)}.call(this,t),Dt.call(this,t),At.call(this,t)}var Mt=function(){function t(e){wt(this,t),this.data=e,this.br=new xt,this.t=new xt,this.l=new xt,this.tl=new xt,this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=a("div","".concat(vt,"-selectors")).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,St+=1}return Ot(t,[{key:"hide",value:function(){this.el.hide()}},{key:"resetOffset",value:function(){var t=this.data,e=this.tl,n=this.t,r=this.l,i=this.br,o=t.freezeTotalHeight(),a=t.freezeTotalWidth();o>0||a>0?(e.setOffset({width:a,height:o}),n.setOffset({left:a,height:o}),r.setOffset({top:o,width:a}),i.setOffset({left:a,top:o})):(e.hide(),n.hide(),r.hide(),i.setOffset({left:0,top:0}))}},{key:"resetAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();zt.call(this,t),It.call(this,e),this.resetOffset()}},{key:"resetBRTAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();Ct.call(this,t),Tt.call(this,t),Rt.call(this,e),Dt.call(this,e),this.resetOffset()}},{key:"resetBRLAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();Ct.call(this,t),Pt.call(this,t),Rt.call(this,e),At.call(this,e),this.resetOffset()}},{key:"set",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.data,i=r.calSelectedRangeByStart(t,e),o=i.sri,a=i.sci;if(n){var l=t,c=e;t<0&&(l=0),e<0&&(c=0),r.selector.setIndexes(l,c),this.indexes=[l,c]}this.moveIndexes=[o,a],this.range=i,this.resetAreaOffset(),this.el.show()}},{key:"setEnd",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.data,i=this.lastri,o=this.lastci;if(n){if(t===i&&e===o)return;this.lastri=t,this.lastci=e}this.range=r.calSelectedRangeByEnd(t,e),zt.call(this,this.data.getSelectedRect())}},{key:"reset",value:function(){var t=this.data.selector.range,e=t.eri,n=t.eci;this.setEnd(e,n)}},{key:"showAutofill",value:function(t,e){if(-1!==t||-1!==e){var n=this.range,r=n.sri,i=n.sci,o=n.eri,a=n.eci,l=t,c=e,s=r-t,u=o-t,f=a-e;if(i-e>0)this.arange=new d(r,c,o,i-1);else if(s>0)this.arange=new d(l,i,r-1,a);else if(f<0)this.arange=new d(r,a+1,o,c);else{if(!(u<0))return void(this.arange=null);this.arange=new d(o+1,i,l,a)}if(null!==this.arange){var h=this.data.getRect(this.arange);h.width+=2,h.height+=2;var y=this.br,p=this.l,v=this.t,b=this.tl;y.showAutofill(Et.call(this,h)),p.showAutofill(_t.call(this,h)),v.showAutofill(jt.call(this,h)),b.showAutofill(h)}}}},{key:"hideAutofill",value:function(){var t=this;["br","l","t","tl"].forEach(function(e){t[e].hideAutofill()})}},{key:"showClipboard",value:function(){var t=this,e=this.data.getClipboardRect();It.call(this,e),["br","l","t","tl"].forEach(function(e){t[e].showClipboard()})}},{key:"hideClipboard",value:function(){var t=this;["br","l","t","tl"].forEach(function(e){t[e].hideClipboard()})}}]),t}();function Wt(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:"200px";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.filterItems=[],this.items=e,this.el=a("div","".concat(vt,"-suggest")).css("width",r).hide(),this.itemClick=n,this.itemIndex=-1}var e,n,r;return e=t,(n=[{key:"setOffset",value:function(t){this.el.cssRemoveKeys("top","bottom").offset(t)}},{key:"hide",value:function(){var t=this.el;this.filterItems=[],this.itemIndex=-1,t.hide(),ft(this.el.parent())}},{key:"setItems",value:function(t){this.items=t}},{key:"search",value:function(t){var e,n=this,r=this.items;if(/^\s*$/.test(t)||(r=r.filter(function(e){return(e.key||e).startsWith(t.toUpperCase())})),r=r.map(function(t){var e=t.title;e?"function"==typeof e&&(e=e()):e=t;var r=a("div","".concat(vt,"-item")).child(e).on("click.stop",function(){n.itemClick(t),n.hide()});return t.label&&r.child(a("div","label").html(t.label)),r}),this.filterItems=r,!(r.length<=0)){var i=this.el;(e=i.html("")).children.apply(e,Wt(r)).show(),ht(i.parent(),function(){n.hide()})}}},{key:"bindInputEvents",value:function(t){var e=this;t.on("keydown",function(t){return function(t){var e=t.keyCode;switch(t.ctrlKey&&t.stopPropagation(),e){case 37:t.stopPropagation();break;case 38:(function(t){t.preventDefault(),t.stopPropagation();var e=this.filterItems;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}).call(this,t);break;case 39:t.stopPropagation();break;case 40:(function(t){t.stopPropagation();var e=this.filterItems;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}).call(this,t);break;case 13:case 9:Ht.call(this,t);break;default:t.stopPropagation()}}.call(e,t)})}}])&&Ft(e.prototype,n),r&&Ft(e,r),t}();function Vt(t){return(Vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function qt(t,e){for(var n=0;nn.width){var o=r;if(r>i){o=i;var a=parseInt(r/i,10);a+=r%i>0?1:0,(a*=this.rowHeight)>n.height&&e.css("height","".concat(a,"px"))}e.css("width","".concat(o,"px"))}}}function ne(t,e){var n=this.textEl,r=this.textlineEl;n.el.blur(),n.val(t),r.html(t),function(t){var e=this.textEl.el;setTimeout(function(){e.focus(),e.setSelectionRange(t,t)},0)}.call(this,e)}var re=function(){function t(e,n,r){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.viewFn=n,this.rowHeight=r,this.formulas=e,this.suggest=new Nt(e,function(t){(function(t){var e=this.inputText,n=this.validator,r=0;if(n&&"list"===n.type)this.inputText=t,r=this.inputText.length;else{var i=e.lastIndexOf("="),o=e.substring(0,i+1),a=e.substring(i+1);a=-1!==a.indexOf(")")?a.substring(a.indexOf(")")):"",this.inputText="".concat(o+t.key,"("),r=this.inputText.length,this.inputText+=")".concat(a)}ne.call(this,this.inputText,r)}).call(i,t)}),this.datepicker=new Qt,this.datepicker.change(function(t){i.setText(function(t){var e=t.getMonth()+1,n=t.getDate();return e<10&&(e="0".concat(e)),n<10&&(n="0".concat(n)),"".concat(t.getFullYear(),"-").concat(e,"-").concat(n)}(t)),i.clear()}),this.areaEl=a("div","".concat(vt,"-editor-area")).children(this.textEl=a("textarea","").on("input",function(t){return function(t){var e=t.target.value,n=this.suggest,r=this.textlineEl,i=this.validator;if(this.inputText=e,i)"list"===i.type?n.search(e):n.hide();else{var o=e.lastIndexOf("=");-1!==o?n.search(e.substring(o+1)):n.hide()}r.html(e),ee.call(this),this.change("input",e)}.call(i,t)}),this.textlineEl=a("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",function(){}).on("mousedown.stop",function(){}),this.el=a("div","".concat(vt,"-editor")).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=function(){}}var e,n,r;return e=t,(n=[{key:"setFreezeLengths",value:function(t,e){this.freeze.w=t,this.freeze.h=e}},{key:"clear",value:function(){""!==this.inputText&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),function(){this.suggest.setItems(this.formulas)}.call(this),this.datepicker.hide()}},{key:"setOffset",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",n=this.textEl,r=this.areaEl,i=this.suggest,o=this.freeze,a=this.el;if(t){this.areaOffset=t;var l=t.left,c=t.top,s=t.width,u=t.height,f=t.l,h=t.t,y={left:0,top:0};o.w>f&&o.h>h||(o.wf?y.top=o.h:o.h>h&&(y.left=o.w)),a.offset(y),r.offset({left:l-y.left-.8,top:c-y.top-.8}),n.offset({width:s-9+.8,height:u-3+.8});var p={left:0};p[e]=u,i.setOffset(p),i.hide()}}},{key:"setCell",value:function(t,e){var n=this.el,r=this.datepicker,i=this.suggest;n.show(),this.cell=t;var o=t&&t.text||"";if(this.setText(o),this.validator=e,e){var a=e.type;"date"===a&&(r.show(),/^\s*$/.test(o)||r.setValue(o)),"list"===a&&(i.setItems(e.values()),i.search(""))}}},{key:"setText",value:function(t){this.inputText=t,ne.call(this,t,t.length),ee.call(this)}}])&&te(e.prototype,n),r&&te(e,r),t}();function ie(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&void 0!==arguments[1]&&arguments[1];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.el=(n=a("div","".concat(vt,"-contextmenu"))).children.apply(n,ie(le.call(this))).hide(),this.viewFn=e,this.itemClick=function(){},this.isHide=r}var e,n,r;return e=t,(n=[{key:"hide",value:function(){var t=this.el;t.hide(),ft(t)}},{key:"setPosition",value:function(t,e){if(!this.isHide){var n=this.el,r=n.show().offset(),i=r.height,o=r.width,a=this.viewFn(),l=e,c=t;a.height-e<=i&&(l-=i),a.width-t<=o&&(c-=o),n.offset({left:c,top:l}),ht(n)}}}])&&oe(e.prototype,n),r&&oe(e,r),t}(),se=[{key:"Arial",title:"Arial"},{key:"Helvetica",title:"Helvetica"},{key:"Source Sans Pro",title:"Source Sans Pro"},{key:"Comic Sans MS",title:"Comic Sans MS"},{key:"Courier New",title:"Courier New"},{key:"Verdana",title:"Verdana"},{key:"Lato",title:"Lato"}],ue=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48},{pt:42,px:56}];function fe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var he=function(t,e){if(t[0]>="0"&&t[0]<="9")return Number(t);if('"'===t[0])return t.substring(1);var n=fe(f(t),2);return e(n[0],n[1])},ye={render:function t(e,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if("="===e[0]){var o=function(t){for(var e=[],n=[],r=[],i=0,o=1,a=0;a="a"&&l<="z")r.push(l.toUpperCase());else if(l>="0"&&l<="9"||l>="A"&&l<="Z"||"."===l)r.push(l);else if('"'===l){for(a+=1;'"'!==t.charAt(a);)r.push(t.charAt(a)),a+=1;n.push('"'.concat(r.join(""))),r=[]}else{if("("!==l&&r.length>0&&n.push(r.join("")),")"===l){var c=e.pop();if(2===i)try{for(var s=fe(f(n.pop()),2),u=s[0],y=s[1],p=fe(f(n.pop()),2),v=p[0],d=p[1],b=0,g=v;g<=u;g+=1)for(var m=d;m<=y;m+=1)n.push(h(g,m)),b+=1;n.push([c,b])}catch(t){}else if(1===i)n.push([c,o]),o=1;else for(;"("!==c&&(n.push(c),!(e.length<=0));)c=e.pop();i=0}else if(":"===l)i=2;else if(","===l)i=1,o+=1;else if("("===l&&r.length>0)e.push(r.join(""));else{if(e.length>0&&("+"===l||"-"===l)){var w=e[e.length-1];if("("!==w&&n.push(e.pop()),"*"===w||"/"===w)for(;e.length>0&&"("!==(w=e[e.length-1]);)n.push(e.pop())}e.push(l)}r=[]}}for(r.length>0&&n.push(r.join(""));e.length>0;)n.push(e.pop());return n}(e.substring(1));return o.length<=0?e:function(t,e,n,r){for(var i=[],o=0;o0?e-.5:.5}Se.forEach(function(t){xe[t.key]=t});var ze=function(){function t(e,n,r,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;_e(this,t),this.x=e,this.y=n,this.width=r,this.height=i,this.padding=o,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}return Te(t,[{key:"setBorders",value:function(t){var e=t.top,n=t.bottom,r=t.left,i=t.right;e&&(this.borderTop=e),i&&(this.borderRight=i),n&&(this.borderBottom=n),r&&(this.borderLeft=r)}},{key:"innerWidth",value:function(){return this.width-2*this.padding}},{key:"innerHeight",value:function(){return this.height-2*this.padding}},{key:"textx",value:function(t){var e=this.width,n=this.padding,r=this.x;return"left"===t?r+=n:"center"===t?r+=e/2:"right"===t&&(r+=e-n),r}},{key:"texty",value:function(t,e,n){var r=this.height,i=this.padding,o=this.y;return"top"===t?o+=i:"middle"===t?o=o+r/2-n:"bottom"===t&&(o+=r-2*n-i),o}},{key:"topxys",value:function(){var t=this.x,e=this.y;return[[t,e],[t+this.width,e]]}},{key:"rightxys",value:function(){var t=this.x,e=this.y,n=this.width;return[[t+n,e],[t+n,e+this.height]]}},{key:"bottomxys",value:function(){var t=this.x,e=this.y,n=this.width,r=this.height;return[[t,e+r],[t+n,e+r]]}},{key:"leftxys",value:function(){var t=this.x,e=this.y;return[[t,e],[t,e+this.height]]}}]),t}();function Ie(t,e,n,r,i,o,a){var l={x:0,y:0};"underline"===t?l.y="bottom"===i?0:"top"===i?-(o+2):-o/2:"strike"===t&&("bottom"===i?l.y=o/2:"top"===i&&(l.y=-(o/2+2))),"center"===r?l.x=a/2:"right"===r&&(l.x=a),this.line([e-l.x,n-l.y],[e-l.x+a,n-l.y])}var Me=function(){function t(e,n,r){_e(this,t),this.el=e,this.ctx=e.getContext("2d"),this.resize(n,r),this.ctx.scale(Pe(),Pe())}return Te(t,[{key:"resize",value:function(t,e){this.el.style.width="".concat(t,"px"),this.el.style.height="".concat(e,"px"),this.el.width=Re(t),this.el.height=Re(e)}},{key:"clear",value:function(){var t=this.el,e=t.width,n=t.height;return this.ctx.clearRect(0,0,e,n),this}},{key:"attr",value:function(t){return Object.assign(this.ctx,t),this}},{key:"save",value:function(){return this.ctx.save(),this.ctx.beginPath(),this}},{key:"restore",value:function(){return this.ctx.restore(),this}},{key:"beginPath",value:function(){return this.ctx.beginPath(),this}},{key:"translate",value:function(t,e){return this.ctx.translate(Re(t),Re(e)),this}},{key:"clearRect",value:function(t,e,n,r){return this.ctx.clearRect(t,e,n,r),this}},{key:"fillRect",value:function(t,e,n,r){return this.ctx.fillRect(Re(t)-.5,Re(e)-.5,Re(n),Re(r)),this}},{key:"fillText",value:function(t,e,n){return this.ctx.fillText(t,Re(e),Re(n)),this}},{key:"text",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=this.ctx,o=n.align,a=n.valign,l=n.font,c=n.color,s=n.strike,u=n.underline,f=e.textx(o);i.save(),i.beginPath(),this.attr({textAlign:o,textBaseline:a,font:"".concat(l.italic?"italic":""," ").concat(l.bold?"bold":""," ").concat(Re(l.size),"px ").concat(l.name),fillStyle:c,strokeStyle:c});var h=i.measureText(t).width,y=0;r&&(y=(Math.ceil(h/e.innerWidth())-1)*l.size/2);var p=e.texty(a,l.size,y);if(r&&h>e.innerWidth()){for(var v={len:0,start:0},d=0;d=e.innerWidth()&&(this.fillText(t.substring(v.start,d),f,p),s&&Ie.call(this,"strike",f,p,o,a,l.size,v.len),u&&Ie.call(this,"underline",f,p,o,a,l.size,v.len),p+=l.size+2,v.len=0,v.start=d),v.len+=i.measureText(t[d]).width;v.len>0&&(this.fillText(t.substring(v.start),f,p),s&&Ie.call(this,"strike",f,p,o,a,l.size,v.len),u&&Ie.call(this,"underline",f,p,o,a,l.size,v.len))}else this.fillText(t,f,p),s&&Ie.call(this,"striket",f,p,o,a,l.size,h),u&&Ie.call(this,"underline",f,p,o,a,l.size,h);return i.restore(),this}},{key:"border",value:function(t,e){var n=this.ctx;return n.lineWidth=Ae,n.strokeStyle=e,"medium"===t?n.lineWidth=Re(2)-.5:"thick"===t?n.lineWidth=Re(3):"dashed"===t?n.setLineDash([Re(3),Re(2)]):"dotted"===t?n.setLineDash([Re(1),Re(1)]):"double"===t&&n.setLineDash([Re(2),0]),this}},{key:"line",value:function(){var t=this.ctx;if(arguments.length>1){var e=je(arguments.length<=0?void 0:arguments[0],2),n=e[0],r=e[1];t.moveTo(De(n),De(r));for(var i=1;i0||h>0){if(f>0){var y=i.clone();y.sri=0,y.eri=f-1,y.h=a,$e.call(this,y,n,r,o,0),Le.call(this,y,n,r,-c,0),Ye.call(this,"top",y,n,r,o,0)}if(h>0){var p=i.clone();p.sci=0,p.eci=h-1,p.w=o,$e.call(this,p,n,r,0,a),Ye.call(this,"left",p,n,r,0,a),Le.call(this,p,n,r,0,-s)}var v=t.freezeViewRange();$e.call(this,v,n,r,0,0),Ye.call(this,"all",v,n,r,0,0),Le.call(this,v,n,r,0,0),function(t,e,n,r){var i=this.draw,o=this.data,a=o.viewWidth()-t,l=o.viewHeight()-e;i.save().translate(t,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),i.line([0,r],[a,r]),i.line([n,0],[n,l]),i.restore()}.call(this,n,r,o,a)}}},{key:"clear",value:function(){this.draw.clear()}}])&&Fe(e.prototype,n),r&&Fe(e,r),t}();function Ke(t,e){for(var n=0;n4?c-4:0),u=4;u'],["medium",''],["thick",''],["dashed",''],["dotted",'']],_r=function(t){function e(t){var n,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var i=new Yt("line-type"),o=0,l=jr.map(function(e,n){return a("div","".concat(vt,"-item state ").concat(t===e[0]?"checked":"")).on("click",function(){l[o].toggle("checked"),l[n].toggle("checked"),o=n,r.hide(),r.change(e)}).child(a("div","".concat(vt,"-line-type")).html(e[1]))});return r=Sr(this,(n=xr(e)).call.apply(n,[this,i,"auto",!1,"bottom-left"].concat(Or(l))))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Er(t,e)}(e,un),e}();function Cr(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0?i.show():i.hide()}var ea=function(){function t(e,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.data=e,this.change=function(){},this.widthFn=n,this.isHide=i,!i){var o=e.defaultStyle();this.items=[[this.undoEl=new Mo,this.redoEl=new Ao,this.paintformatEl=new li,this.clearformatEl=new ei],Qo(),[this.formatEl=new no],Qo(),[this.fontEl=new Bi,this.fontSizeEl=new Ai],Qo(),[this.boldEl=new $n,this.italicEl=new Gn,this.underlineEl=new cr,this.strikeEl=new rr,this.textColorEl=new yi(o.color)],Qo(),[this.fillColorEl=new mi(o.bgcolor),this.borderEl=new Br,this.mergeEl=new jo],Qo(),[this.alignEl=new Sn(o.align),this.valignEl=new Tn(o.valign),this.textwrapEl=new Vo],Qo(),[this.freezeEl=new wo,this.autofilterEl=new qn,this.formulaEl=new po,this.moreEl=new Jo]],this.el=a("div","".concat(vt,"-toolbar")),this.btns=a("div","".concat(vt,"-toolbar-btns")),this.items.forEach(function(t){Array.isArray(t)?t.forEach(function(t){r.btns.child(t.el),t.change=function(){r.change.apply(r,arguments)}}):r.btns.child(t.el)}),this.el.child(this.btns),this.reset(),setTimeout(function(){(function(){var t=this;this.btns2=[],this.items.forEach(function(e){if(Array.isArray(e))e.forEach(function(e){var n=e.el,r=n.box(),i=n.computedStyle(),o=i.marginLeft,a=i.marginRight;t.btns2.push([n,r.width+parseInt(o,10)+parseInt(a,10)])});else{var n=e.box(),r=e.computedStyle(),i=r.marginLeft,o=r.marginRight;t.btns2.push([e,n.width+parseInt(i,10)+parseInt(o,10)])}})}).call(r),ta.call(r)},0),st(window,"resize",function(){ta.call(r)})}}var e,n,r;return e=t,(n=[{key:"paintformatActive",value:function(){return this.paintformatEl.active()}},{key:"paintformatToggle",value:function(){this.paintformatEl.toggle()}},{key:"trigger",value:function(t){this["".concat(t,"El")].click()}},{key:"reset",value:function(){if(!this.isHide){var t=this.data,e=t.getSelectedCellStyle(),n=t.getSelectedCell();this.undoEl.setState(!t.canUndo()),this.redoEl.setState(!t.canRedo()),this.mergeEl.setState(t.canUnmerge(),!t.selector.multiple()),this.autofilterEl.setState(!t.canAutofilter());var r=e.font;this.fontEl.setState(r.name),this.fontSizeEl.setState(r.size),this.boldEl.setState(r.bold),this.italicEl.setState(r.italic),this.underlineEl.setState(e.underline),this.strikeEl.setState(e.strike),this.textColorEl.setState(e.color),this.fillColorEl.setState(e.bgcolor),this.alignEl.setState(e.align),this.valignEl.setState(e.valign),this.textwrapEl.setState(e.textwrap),this.freezeEl.setState(t.freezeIsActive()),n&&n.format&&this.formatEl.setState(n.format)}}}])&&Zo(e.prototype,n),r&&Zo(e,r),t}();function na(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:"600px";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.title=e,this.el=a("div","".concat(vt,"-modal")).css("width",o).children(a("div","".concat(vt,"-modal-header")).children(new Yt("close").on("click.stop",function(){return i.hide()}),this.title),(r=a("div","".concat(vt,"-modal-content"))).children.apply(r,na(n))).hide()}var e,n,r;return e=t,(n=[{key:"show",value:function(){var t=this;this.dimmer=a("div","".concat(vt,"-dimmer active")),document.body.appendChild(this.dimmer.el);var e=this.el.show().box(),n=e.width,r=e.height,i=document.documentElement,o=i.clientHeight,l=i.clientWidth;this.el.offset({left:(l-n)/2,top:(o-r)/3}),window.xkeydownEsc=function(e){27===e.keyCode&&t.hide()},st(window,"keydown",window.xkeydownEsc)}},{key:"hide",value:function(){this.el.hide(),document.body.removeChild(this.dimmer.el),ut(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}])&&ra(e.prototype,n),r&&ra(e,r),t}();function oa(t,e){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:function(t){return t},l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.key=e,this.getTitle=o,this.vchange=function(){},this.el=a("div","".concat(vt,"-form-select")),this.suggest=new Nt(n.map(function(t){return{key:t,title:i.getTitle(t)}}),function(t){i.itemClick(t.key),l(t.key),i.vchange(t.key)},r,this.el),this.el.children(this.itemEl=a("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",function(){return i.show()})}var e,n,r;return e=t,(n=[{key:"show",value:function(){this.suggest.search("")}},{key:"itemClick",value:function(t){this.key=t,this.itemEl.html(this.getTitle(t))}},{key:"val",value:function(t){return void 0!==t?(this.key=t,this.itemEl.html(this.getTitle(t)),this):this.key}}])&&la(e.prototype,n),r&&la(e,r),t}();function sa(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:"";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=ya(this,pa(e).call(this,"div","".concat(vt,"-button ").concat(r)))).child(V("button.".concat(t))),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&va(t,e)}(e,o),e}();function ba(t){return(ba="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ga(t,e){for(var n=0;n3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(-1!==e||-1!==n){var o=this.table,a=this.selector,l=this.toolbar;t?a.setEnd(e,n,i):a.set(e,n,r),l.reset(),o.render()}}function Da(t,e){var n=this.selector,r=this.data,i=r.rows,o=r.cols,a=Aa(n.indexes,2),l=a[0],c=a[1],s=n.range,u=s.eri,f=s.eci;if(t){var h=Aa(n.moveIndexes,2);l=h[0],c=h[1]}"left"===e?c>0&&(c-=1):"right"===e?(f!==c&&(c=f),c0&&(l-=1):"down"===e?(u!==l&&(l=u),lu.width)n.move({left:i+c-u.width});else{var f=t.freezeTotalWidth();au.height)e.move({top:o+s-u.height-1});else{var h=t.freezeTotalHeight();l0||o>0){var a=e.freezeTotalWidth(),l=e.freezeTotalHeight();n.setFreezeLengths(a,l)}t.resetAreaOffset()}.call(this),r.render(),i.reset(),o.reset()}function Wa(){var t=this.data,e=this.selector;t.clearClipboard(),e.hideClipboard()}function Fa(){var t=this.data,e=this.selector;t.copy(),e.showClipboard()}function Ha(){var t=this.data,e=this.selector;t.cut(),e.showClipboard()}function Na(t){this.data.paste(t,function(t){return Ta("Tip",t)})&&Ma.call(this)}function Va(t){var e=this,n=this.selector,r=this.data,i=this.table,o=this.sortFilter,a=t.offsetX,l=t.offsetY,c=t.target.className==="".concat(vt,"-selector-corner"),s=r.getCellRectByXY(a,l),u=s.left,f=s.top,h=s.width,y=s.height,p=s.ri,v=s.ci,d=r.autoFilter;if(d.includes(p,v)&&u+h-20n.height/2&&(r="bottom"),t.setOffset(e,r)}function Ba(){var t=this.editor,e=this.data;qa.call(this),t.setCell(e.getSelectedCell(),e.getSelectedValidator()),Wa.call(this)}function La(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"finished",n=this.data,r=this.table;n.setSelectedCellText(t,e),"finished"===e&&r.render()}function Ua(t){var e=this.data;"insert-row"===t?e.insert("row"):"delete-row"===t?e.delete("row"):"insert-column"===t?e.insert("column"):"delete-column"===t?e.delete("column"):"delete-cell"===t?e.deleteCell():"delete-cell-format"===t?e.deleteCell("format"):"delete-cell-text"===t&&e.deleteCell("text"),Wa.call(this),Ma.call(this)}function Ya(t,e){var n=this.data;if("undo"===t)this.undo();else if("redo"===t)this.redo();else if("print"===t);else if("paintformat"===t)!0===e?Fa.call(this):Wa.call(this);else if("clearformat"===t)Ua.call(this,"delete-cell-format");else if("link"===t);else if("chart"===t);else if("autofilter"===t)(function(){this.data.autofilter(),Ma.call(this)}).call(this);else if("freeze"===t)if(e){var r=n.selector,i=r.ri,o=r.ci;this.freeze(i,o)}else this.freeze(0,0);else n.setSelectedCellAttr(t,e),"formula"!==t||n.selector.multiple()||Ba.call(this),Ma.call(this)}function $a(){var t,e,n,r,i,o,a=this,l=this.overlayerEl,c=this.rowResizer,s=this.colResizer,u=this.verticalScrollbar,f=this.horizontalScrollbar,h=this.editor,y=this.contextMenu,p=this.data,v=this.toolbar,d=this.modalValidation,b=this.sortFilter;l.on("mousemove",function(t){(function(t){if(0===t.buttons&&t.target.className!=="".concat(vt,"-resizer-hover")){var e=t.offsetX,n=t.offsetY,r=this.rowResizer,i=this.colResizer,o=this.tableEl,a=this.data,l=a.rows,c=a.cols;if(e>c.indexWidth&&n>l.height)return r.hide(),void i.hide();var s=o.box(),u=a.getCellRectByXY(t.offsetX,t.offsetY);u.ri>=0&&-1===u.ci?(u.width=c.indexWidth,r.show(u,{width:s.width})):r.hide(),-1===u.ri&&u.ci>=0?(u.height=l.height,i.show(u,{height:s.height})):i.hide()}}).call(a,t)}).on("mousedown",function(t){2===t.buttons?p.xyInSelectedRect(t.offsetX,t.offsetY)?(y.setPosition(t.offsetX,t.offsetY),t.stopPropagation()):y.hide():2===t.detail?Ba.call(a):(h.clear(),Va.call(a,t))}).on("mousewheel.stop",function(t){(function(t){var e=this.verticalScrollbar,n=this.data,r=e.scroll().top,i=t.deltaY,o=n.rows;if(t.detail&&(i=40*t.detail),i>0){var a=n.scroll.ri+1;a=0&&e.move({top:0===l?0:r-o.getHeight(l)})}}).call(a,t)}),t=l.el,n=(e={move:function(t,e){(function(t,e){var n=this.verticalScrollbar,r=this.horizontalScrollbar,i=n.scroll().top,o=r.scroll().left;"left"===t||"right"===t?r.move({left:o-e}):"up"!==t&&"down"!==t||n.move({top:i-e})}).call(a,t,e)}}).move,r=e.end,i=0,o=0,st(t,"touchstart",function(t){var e=t.touches[0],n=e.pageX,r=e.pageY;i=n,o=r}),st(t,"touchmove",function(t){if(n){var e=t.changedTouches[0],r=e.pageX,a=e.pageY,l=r-i,c=a-o;(Math.abs(l)>10||Math.abs(c)>10)&&(pt(l,c,t,n),i=r,o=a),t.preventDefault()}}),st(t,"touchend",function(t){if(r){var e=t.changedTouches[0],n=e.pageX,a=e.pageY;pt(n-i,a-o,t,r)}}),v.change=function(t,e){return Ya.call(a,t,e)},b.ok=function(t,e,n,r){return function(t,e,n,r){this.data.setAutoFilter(t,e,n,r),Ma.call(this)}.call(a,t,e,n,r)},c.finishedFn=function(t,e){(function(t,e){var n=t.ri,r=this.table,i=this.selector;this.data.rows.setHeight(n,e),r.render(),i.resetAreaOffset(),za.call(this),qa.call(this)}).call(a,t,e)},s.finishedFn=function(t,e){(function(t,e){var n=t.ci,r=this.table,i=this.selector;this.data.cols.setWidth(n,e),r.render(),i.resetAreaOffset(),Ia.call(this),qa.call(this)}).call(a,t,e)},u.moveFn=function(t,e){(function(t){var e=this,n=this.data,r=this.table,i=this.selector;n.scrolly(t,function(){i.resetBRLAreaOffset(),qa.call(e),r.render()})}).call(a,t,e)},f.moveFn=function(t,e){(function(t){var e=this,n=this.data,r=this.table,i=this.selector;n.scrollx(t,function(){i.resetBRTAreaOffset(),qa.call(e),r.render()})}).call(a,t,e)},h.change=function(t,e){La.call(a,e,t)},d.change=function(t){if("save"===t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r=65&&e<=90||e>=48&&e<=57||e>=96&&e<=105||"="===t.key?(La.call(a,t.key,"input"),Ba.call(a)):113===e&&Ba.call(a)}}})}var Xa=function(){function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=n.settings,o=i.view,l=i.showToolbar,c=i.showContextmenu;this.el=a("div","".concat(vt,"-sheet")),this.toolbar=new ea(n,o.width,!l),e.children(this.toolbar.el,this.el),this.data=n,this.tableEl=a("canvas","".concat(vt,"-table")),this.rowResizer=new bt(!1,n.rows.height),this.colResizer=new bt(!0,n.cols.minWidth),this.verticalScrollbar=new mt(!0),this.horizontalScrollbar=new mt(!1),this.editor=new re(de,function(){return r.getTableOffset()},n.rows.height),this.modalValidation=new Sa,this.contextMenu=new ce(function(){return r.getTableOffset()},!c),this.selector=new Mt(n),this.overlayerCEl=a("div","".concat(vt,"-overlayer-content")).children(this.editor.el,this.selector.el),this.overlayerEl=a("div","".concat(vt,"-overlayer")).child(this.overlayerCEl),this.sortFilter=new Ca,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new Xe(this.tableEl.el,n),$a.call(this),Ma.call(this),Ra.call(this,!1,0,0)}var e,n,r;return e=t,(n=[{key:"loadData",value:function(t){return this.data.setData(t),Ma.call(this),this}},{key:"freeze",value:function(t,e){return this.data.setFreeze(t,e),Ma.call(this),this}},{key:"undo",value:function(){this.data.undo(),Ma.call(this)}},{key:"redo",value:function(){this.data.redo(),Ma.call(this)}},{key:"reload",value:function(){return Ma.call(this),this}},{key:"getRect",value:function(){var t=this.data;return{width:t.viewWidth(),height:t.viewHeight()}}},{key:"getTableOffset",value:function(){var t=this.data,e=t.rows,n=t.cols,r=this.getRect(),i=r.width,o=r.height;return{width:i-n.indexWidth,height:o-e.height,left:n.indexWidth,top:e.height}}}])&&Pa(e.prototype,n),r&&Pa(e,r),t}();n(0);function Ka(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var r=e;"string"==typeof e&&(r=document.querySelector(e)),this.data=new ct("sheet1",n);var i=a("div","".concat(vt)).on("contextmenu",function(t){return t.preventDefault()});r.appendChild(i.el),this.sheet=new Xa(i,this.data)}var e,n,r;return e=t,r=[{key:"locale",value:function(t,e){B(t,e)}}],(n=[{key:"loadData",value:function(t){return this.sheet.loadData(t),this}},{key:"getData",value:function(){return this.data.getData()}},{key:"validate",value:function(){return this.data.validations.errors.size<=0}},{key:"change",value:function(t){return this.data.change=t,this}}])&&Ka(e.prototype,n),r&&Ka(e,r),t}(),Za=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Ja(t,e)};window&&(window.x=window.x||{},window.x.spreadsheet=Za,window.x.spreadsheet.locale=function(t,e){return B(t,e)});e.default=Ja}]); //# sourceMappingURL=xspreadsheet.js.map ================================================ FILE: docs/index.html ================================================ x-spreadsheet
================================================ FILE: docs/locale/de.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Rückgängig machen",redo:"Wiederherstellen",paintformat:"Format kopieren/einfügen",clearformat:"Format löschen",format:"Format",font:"Schriftart",fontSize:"Schriftgrad",fontBold:"Fett",fontItalic:"Kursiv",underline:"Betonen",strike:"Streichen",textColor:"Text Farbe",fillColor:"Füllung Farbe",border:"Umrandung",merge:"Zellen verbinden",align:"Waagrechte Ausrichtung",valign:"Vertikale uitlijning",textwrap:"Textumbruch",freeze:"Zelle sperren",formula:"Funktionen",more:"Mehr"},contextmenu:{copy:"Kopieren",cut:"Ausschneiden",paste:"Einfügen",pasteValue:"Nur Werte einfügen",pasteFormat:"Nur Format einfügen",insertRow:"Zeile einfügen",insertColumn:"Spalte einfügen",deleteRow:"Zeile löschen",deleteColumn:"Spalte löschen",deleteCell:"Zelle löschen",deleteCellText:"Zellentext löschen"},format:{normal:"Regulär",text:"Text",number:"Nummer",percent:"Prozent",rmb:"RMB",usd:"USD",date:"Datum",time:"Termin",datetime:"Datum Termin",duration:"Dauer"},formula:{sum:"Summe",average:"Durchschnittliche",max:"Max",min:"Min",concat:"Concat"}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages.de=r),t.default=r}]); ================================================ FILE: docs/locale/en.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([,function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages.en=r),t.default=r}]); ================================================ FILE: docs/locale/nl.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}({2:function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"Ongedaan maken",redo:"Opnieuw uitvoeren",paintformat:"Opmaak kopiëren/plakken",clearformat:"Opmaak wissen",format:"Opmaak",font:"Lettertype",fontSize:"Tekengrootte",fontBold:"Vet",fontItalic:"Cursief",underline:"Onderstrepen",strike:"Doorstrepen",textColor:"Tekstkleur",fillColor:"Opvulkleur",border:"Randen",merge:"Cellen samenvoegen",align:"Horizontale uitlijning",valign:"Verticale uitlijning",textwrap:"Terugloop",freeze:"Cel bevriezen",formula:"Functies",more:"Meer"},contextmenu:{copy:"Kopiëren",cut:"Knippen",paste:"Plakken",pasteValue:"Alleen waarden plakken",pasteFormat:"Alleen opmaak plakken",insertRow:"Rij invoegen",insertColumn:"Kolom invoegen",deleteRow:"Rij verwijderen",deleteColumn:"Kolom verwijderen",deleteCell:"Cel verwijderen",deleteCellText:"Celtekst verwijderen"},format:{normal:"Standaard",text:"Tekst",number:"Nummer",percent:"Percentage",rmb:"RMB",usd:"USD",date:"Datum",time:"Tijdstip",datetime:"Datum tijd",duration:"Duratie"},formula:{sum:"Som",average:"Gemiddelde",max:"Max",min:"Min",concat:"Concat"}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages.nl=r),t.default=r}}); ================================================ FILE: docs/locale/zh-cn.js ================================================ !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}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(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}({3:function(e,t,n){"use strict";n.r(t);const r={toolbar:{undo:"撤销",redo:"恢复",print:"打印",paintformat:"格式刷",clearformat:"清除格式",format:"数据格式",fontName:"字体",fontSize:"字号",fontBold:"加粗",fontItalic:"倾斜",underline:"下划线",strike:"删除线",color:"字体颜色",bgcolor:"填充颜色",border:"边框",merge:"合并单元格",align:"水平对齐",valign:"垂直对齐",textwrap:"自动换行",freeze:"冻结",autofilter:"自动筛选",formula:"函数",more:"更多"},contextmenu:{copy:"复制",cut:"剪切",paste:"粘贴",pasteValue:"粘贴数据",pasteFormat:"粘贴格式",hide:"隐藏",insertRow:"插入行",insertColumn:"插入列",deleteSheet:"删除",deleteRow:"删除行",deleteColumn:"删除列",deleteCell:"删除",deleteCellText:"删除数据",validation:"数据验证",cellprintable:"可打印",cellnonprintable:"不可打印",celleditable:"可编辑",cellnoneditable:"不可编辑"},print:{size:"纸张大小",orientation:"方向",orientations:["横向","纵向"]},format:{normal:"正常",text:"文本",number:"数值",percent:"百分比",rmb:"人民币",usd:"美元",eur:"欧元",date:"短日期",time:"时间",datetime:"长日期",duration:"持续时间"},formula:{sum:"求和",average:"求平均值",max:"求最大值",min:"求最小值",concat:"字符拼接",_if:"条件判断",and:"和",or:"或"},validation:{required:"此值必填",notMatch:"此值不匹配验证规则",between:"此值应在 {} 和 {} 之间",notBetween:"此值不应在 {} 和 {} 之间",notIn:"此值不在列表中",equal:"此值应该等于 {}",notEqual:"此值不应该等于 {}",lessThan:"此值应该小于 {}",lessThanEqual:"此值应该小于等于 {}",greaterThan:"此值应该大于 {}",greaterThanEqual:"此值应该大于等于 {}"},error:{pasteForMergedCell:"无法对合并的单元格执行此操作"},calendar:{weeks:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},button:{next:"下一步",cancel:"取消",remove:"删除",save:"保存",ok:"确认"},sort:{desc:"降序",asc:"升序"},filter:{empty:"空白"},dataValidation:{mode:"模式",range:"单元区间",criteria:"条件",modeType:{cell:"单元格",column:"列模式",row:"行模式"},type:{list:"列表",number:"数字",date:"日期",phone:"手机号",email:"电子邮件"},operator:{be:"在区间",nbe:"不在区间",lt:"小于",lte:"小于等于",gt:"大于",gte:"大于等于",eq:"等于",neq:"不等于"}}};window&&window.x_spreadsheet&&(window.x_spreadsheet.$messages=window.x_spreadsheet.$messages||{},window.x_spreadsheet.$messages["zh-cn"]=r),t.default=r}}); ================================================ FILE: docs/xspreadsheet.css ================================================ body { margin: 0; } .x-spreadsheet { font-size: 13px; line-height: normal; user-select: none; -moz-user-select: none; font-family: 'Lato', 'Source Sans Pro', Roboto, Helvetica, Arial, sans-serif; box-sizing: content-box; background: #fff; -webkit-font-smoothing: antialiased; } .x-spreadsheet textarea { font: 400 13px Arial, 'Lato', 'Source Sans Pro', Roboto, Helvetica, sans-serif; } .x-spreadsheet-sheet { position: relative; overflow: hidden; } .x-spreadsheet-table { vertical-align: bottom; } .x-spreadsheet-tooltip { font-family: inherit; position: absolute; padding: 5px 10px; color: #fff; border-radius: 1px; background: #000000; font-size: 12px; z-index: 201; } .x-spreadsheet-tooltip:before { pointer-events: none; position: absolute; left: calc(50% - 4px); top: -4px; content: ""; width: 8px; height: 8px; background: inherit; -webkit-transform: rotate(45deg); transform: rotate(45deg); z-index: 1; box-shadow: 1px 1px 3px -1px rgba(0, 0, 0, 0.3); } .x-spreadsheet-color-palette { padding: 5px; } .x-spreadsheet-color-palette table { margin: 0; padding: 0; border-collapse: separate; border-spacing: 2; background: #fff; } .x-spreadsheet-color-palette table td { margin: 0; cursor: pointer; border: 1px solid transparent; } .x-spreadsheet-color-palette table td:hover { border-color: #ddd; } .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell { width: 16px; height: 16px; } .x-spreadsheet-border-palette { padding: 6px; } .x-spreadsheet-border-palette table { margin: 0; padding: 0; border-collapse: separate; border-spacing: 0; background: #fff; table-layout: fixed; } .x-spreadsheet-border-palette table td { margin: 0; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left { border-right: 1px solid #eee; padding-right: 6px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell { width: 30px; height: 30px; cursor: pointer; text-align: center; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell .x-spreadsheet-icon-img { opacity: 0.8; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover { background-color: #eee; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right { padding-left: 6px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-toolbar-btn { margin-top: 0; margin-bottom: 3px; } .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type { position: relative; left: 0; top: -3px; } .x-spreadsheet-dropdown { position: relative; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content { position: absolute; z-index: 200; background: #fff; box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15); } .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content { top: calc(100% + 5px); left: 0; } .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content { top: calc(100% + 5px); right: 0; } .x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content { bottom: calc(100% + 5px); left: 0; } .x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content { bottom: calc(100% + 5px); right: 0; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title { padding: 0 5px; display: inline-block; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-left { margin-left: 4px; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right { width: 10px; margin-right: 4px; } .x-spreadsheet-dropdown .x-spreadsheet-dropdown-header .x-spreadsheet-icon.arrow-right .arrow-down { left: -130px; } /* resizer **/ .x-spreadsheet-resizer { position: absolute; z-index: 11; } .x-spreadsheet-resizer .x-spreadsheet-resizer-hover { background-color: rgba(75, 137, 255, 0.25); } .x-spreadsheet-resizer .x-spreadsheet-resizer-line { position: absolute; } .x-spreadsheet-resizer.horizontal { cursor: row-resize; } .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line { border-bottom: 2px dashed #4b89ff; left: 0; bottom: 0; } .x-spreadsheet-resizer.vertical { cursor: col-resize; } .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line { border-right: 2px dashed #4b89ff; top: 0; right: 0; } /* scrollbar */ .x-spreadsheet-scrollbar { position: absolute; bottom: 0; right: 0; background-color: #f4f5f8; opacity: 0.9; z-index: 12; } .x-spreadsheet-scrollbar.horizontal { right: 15px; overflow-x: scroll; overflow-y: hidden; } .x-spreadsheet-scrollbar.horizontal > div { height: 1px; background: #ddd; } .x-spreadsheet-scrollbar.vertical { bottom: 15px; overflow-x: hidden; overflow-y: scroll; } .x-spreadsheet-scrollbar.vertical > div { width: 1px; background: #ddd; } /* @{css-prefix}-overlayer */ .x-spreadsheet-overlayer { position: absolute; left: 0; top: 0; z-index: 10; } .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content { position: absolute; overflow: hidden; pointer-events: none; width: 100%; height: 100%; } .x-spreadsheet-editor, .x-spreadsheet-selector { box-sizing: content-box; position: absolute; overflow: hidden; pointer-events: none; top: 0; left: 0; width: 100%; height: 100%; } /* @{css-prefix}-selector */ .x-spreadsheet-selector .hide-input { position: absolute; z-index: 0; } .x-spreadsheet-selector .hide-input input { padding: 0; width: 0; border: none!important; } .x-spreadsheet-selector .x-spreadsheet-selector-area { position: absolute; border: 2px solid #4b89ff; background: rgba(75, 137, 255, 0.1); z-index: 5; } .x-spreadsheet-selector .x-spreadsheet-selector-clipboard, .x-spreadsheet-selector .x-spreadsheet-selector-autofill { position: absolute; background: transparent; z-index: 100; } .x-spreadsheet-selector .x-spreadsheet-selector-clipboard { border: 2px dashed #4b89ff; } .x-spreadsheet-selector .x-spreadsheet-selector-autofill { border: 1px dashed rgba(0, 0, 0, 0.45); } .x-spreadsheet-selector .x-spreadsheet-selector-corner { pointer-events: auto; position: absolute; cursor: crosshair; font-size: 0; height: 5px; width: 5px; right: -5px; bottom: -5px; border: 2px solid #ffffff; background: #4b89ff; } .x-spreadsheet-editor { z-index: 20; } .x-spreadsheet-editor .x-spreadsheet-editor-area { position: absolute; text-align: left; border: 2px solid #4b89ff; line-height: 0; z-index: 100; pointer-events: auto; } .x-spreadsheet-editor .x-spreadsheet-editor-area textarea { box-sizing: content-box; border: none; padding: 0 3px; outline: none; resize: none; text-align: start; overflow-y: hidden; font: 400 13px Arial, 'Lato', 'Source Sans Pro', Roboto, Helvetica, sans-serif; color: inherit; white-space: normal; word-wrap: break-word; line-height: 22px; margin: 0; } .x-spreadsheet-editor .x-spreadsheet-editor-area .textline { overflow: hidden; visibility: hidden; position: fixed; top: 0; left: 0; } .x-spreadsheet-item { user-select: none; background: 0; border: 1px solid transparent; outline: none; height: 26px; color: rgba(0, 0, 0, 0.9); line-height: 26px; list-style: none; padding: 2px 10px; cursor: default; text-align: left; overflow: hidden; } .x-spreadsheet-item.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-item:hover, .x-spreadsheet-item.active { background: rgba(0, 0, 0, 0.05); } .x-spreadsheet-item.divider { height: 0; padding: 0; margin: 5px 0; border: none; border-bottom: 1px solid rgba(0, 0, 0, 0.1); } .x-spreadsheet-item .label { float: right; opacity: 0.65; font-size: 1em; } .x-spreadsheet-item.state, .x-spreadsheet-header.state { padding-left: 35px!important; position: relative; } .x-spreadsheet-item.state:before, .x-spreadsheet-header.state:before { content: ''; position: absolute; width: 10px; height: 10px; left: 12px; top: calc(50% - 5px); background: rgba(0, 0, 0, 0.08); border-radius: 2px; } .x-spreadsheet-item.state.checked:before, .x-spreadsheet-header.state.checked:before { background: #4b89ff; } .x-spreadsheet-checkbox { position: relative; display: inline-block; backface-visibility: hidden; outline: 0; vertical-align: baseline; font-style: normal; font-size: 1rem; line-height: 1em; } .x-spreadsheet-checkbox > input { position: absolute; top: 0; left: 0; opacity: 0!important; outline: 0; z-index: -1; } .x-spreadsheet-suggest, .x-spreadsheet-contextmenu, .x-spreadsheet-sort-filter { position: absolute; box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15); background: #fff; z-index: 100; width: 260px; pointer-events: auto; overflow: auto; } .x-spreadsheet-suggest { width: 200px; } .x-spreadsheet-filter { border: 1px solid #e9e9e9; font-size: 12px; margin: 10px; } .x-spreadsheet-filter .x-spreadsheet-header { padding: 0.5em 0.75em; background: #f8f8f9; border-bottom: 1px solid #e9e9e9; border-left: 1px solid transparent; } .x-spreadsheet-filter .x-spreadsheet-body { height: 200px; overflow-y: auto; } .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item { height: 20px; line-height: 20px; } .x-spreadsheet-sort-filter .x-spreadsheet-buttons { margin: 10px; } .x-spreadsheet-toolbar, .x-spreadsheet-bottombar { height: 40px; padding: 0 30px; text-align: left; background: #f5f6f7; display: flex; } .x-spreadsheet-bottombar { position: relative; border-top: 1px solid #e0e2e4; } .x-spreadsheet-bottombar .x-spreadsheet-menu > li { line-height: 40px; height: 40px; padding-top: 0; padding-bottom: 0; vertical-align: middle; border-right: 1px solid #e8eaed; } .x-spreadsheet-menu { list-style: none; margin: 0; padding: 0; user-select: none; } .x-spreadsheet-menu > li { float: left; line-height: 1.25em; padding: 0.785em 1em; margin: 0; vertical-align: middle; text-align: left; font-weight: 400; color: #80868b; white-space: nowrap; cursor: pointer; transition: all 0.3s; font-weight: bold; } .x-spreadsheet-menu > li.active { background-color: #fff; color: rgba(0, 0, 0, 0.65); } .x-spreadsheet-menu > li .x-spreadsheet-icon { margin: 0 6px; } .x-spreadsheet-menu > li .x-spreadsheet-icon .x-spreadsheet-icon-img:hover { opacity: 0.85; } .x-spreadsheet-menu > li .x-spreadsheet-dropdown { display: inline-block; } .x-spreadsheet-toolbar { border-bottom: 1px solid #e0e2e4; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btns { display: inline-flex; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more { padding: 0 6px 6px; text-align: left; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-more .x-spreadsheet-toolbar-divider { margin-top: 0; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn { flex: 0 0 auto; display: inline-block; border: 1px solid transparent; height: 26px; line-height: 26px; min-width: 26px; margin: 6px 1px 0; padding: 0; text-align: center; border-radius: 2px; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn:hover, .x-spreadsheet-toolbar .x-spreadsheet-toolbar-btn.active { background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-toolbar-divider { display: inline-block; border-right: 1px solid #e0e2e4; width: 0; vertical-align: middle; height: 18px; margin: 12px 3px 0; } .x-spreadsheet-print { position: absolute; left: 0; top: 0; z-index: 100; width: 100%; height: 100%; display: flex; flex-direction: column; } .x-spreadsheet-print-bar { background: #424242; height: 60px; line-height: 60px; padding: 0 30px; } .x-spreadsheet-print-bar .-title { color: #fff; font-weight: bold; font-size: 1.2em; float: left; } .x-spreadsheet-print-bar .-right { float: right; margin-top: 12px; } .x-spreadsheet-print-content { display: flex; flex: auto; flex-direction: row; background: #d0d0d0; height: calc(100% - 60px); } .x-spreadsheet-print-content .-sider { flex: 0 0 300px; width: 300px; border-left: 2px solid #ccc; background: #fff; } .x-spreadsheet-print-content .-content { flex: auto; overflow-x: auto; overflow-y: scroll; height: 100%; } .x-spreadsheet-canvas-card-wraper { margin: 40px 20px; } .x-spreadsheet-canvas-card { background: #fff; margin: auto; page-break-before: auto; page-break-after: always; box-shadow: 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 3px rgba(0, 0, 0, 0.12), 0 4px 5px 0 rgba(0, 0, 0, 0.2); } .x-spreadsheet-calendar { color: rgba(0, 0, 0, 0.65); background: #ffffff; user-select: none; } .x-spreadsheet-calendar .calendar-header { font-weight: 700; line-height: 30px; text-align: center; width: 100%; float: left; background: #f9fafb; } .x-spreadsheet-calendar .calendar-header .calendar-header-left { padding-left: 5px; float: left; } .x-spreadsheet-calendar .calendar-header .calendar-header-right { float: right; } .x-spreadsheet-calendar .calendar-header .calendar-header-right a { padding: 3px 0; margin-right: 2px; border-radius: 2px; } .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover { background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-calendar .calendar-body { border-collapse: collapse; border-spacing: 0; } .x-spreadsheet-calendar .calendar-body th, .x-spreadsheet-calendar .calendar-body td { width: 14.28571429%; min-width: 32px; text-align: center; font-weight: 700; line-height: 30px; padding: 0; } .x-spreadsheet-calendar .calendar-body td > .cell:hover { background: #ecf6fd; } .x-spreadsheet-calendar .calendar-body td > .cell.active, .x-spreadsheet-calendar .calendar-body td > .cell.active:hover { background: #ecf6fd; color: #2185D0; } .x-spreadsheet-calendar .calendar-body td > .cell.disabled { pointer-events: none; opacity: 0.5; } .x-spreadsheet-datepicker { box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); position: absolute; left: 0; top: calc(100% + 5px); z-index: 10; width: auto; } .x-spreadsheet-buttons { display: flex; justify-content: flex-end; } .x-spreadsheet-buttons .x-spreadsheet-button { margin-left: 8px; } .x-spreadsheet-button { display: inline-block; border-radius: 3px; line-height: 1em; min-height: 1em; white-space: nowrap; text-align: center; cursor: pointer; font-size: 1em; font-weight: 700; padding: 0.75em 1em; color: rgba(0, 0, 0, 0.6); background: #E0E1E2; text-decoration: none; font-family: "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif; outline: none; vertical-align: baseline; zoom: 1; user-select: none; transition: all 0.1s linear; } .x-spreadsheet-button.active, .x-spreadsheet-button:hover { background-color: #C0C1C2; color: rgba(0, 0, 0, 0.8); } .x-spreadsheet-button.primary { color: #fff; background-color: #2185D0; } .x-spreadsheet-button.primary:hover, .x-spreadsheet-button.primary.active { color: #fff; background-color: #1678c2; } .x-spreadsheet-form-input { font-size: 1em; position: relative; font-weight: 400; display: inline-flex; color: rgba(0, 0, 0, 0.87); } .x-spreadsheet-form-input input { z-index: 1; margin: 0; max-width: 100%; flex: 1 0 auto; outline: 0; -webkit-tap-highlight-color: rgba(255, 255, 255, 0); text-align: left; line-height: 30px; height: 30px; padding: 0 8px; background: #fff; border: 1px solid #e9e9e9; border-radius: 3px; transition: box-shadow 0.1s ease, border-color 0.1s ease; box-shadow: inset 0 1px 2px hsla(0, 0%, 4%, 0.06); } .x-spreadsheet-form-input input:focus { border-color: #4b89ff; box-shadow: inset 0 1px 2px rgba(75, 137, 255, 0.2); } .x-spreadsheet-form-select { position: relative; display: inline-block; background: #fff; border: 1px solid #e9e9e9; border-radius: 2px; cursor: pointer; color: rgba(0, 0, 0, 0.87); user-select: none; box-shadow: inset 0 1px 2px hsla(0, 0%, 4%, 0.06); } .x-spreadsheet-form-select .input-text { text-overflow: ellipsis; white-space: nowrap; min-width: 60px; width: auto; height: 30px; line-height: 30px; padding: 0 8px; } .x-spreadsheet-form-fields { display: flex; flex-direction: row; flex-wrap: wrap; } .x-spreadsheet-form-fields .x-spreadsheet-form-field { flex: 0 1 auto; } .x-spreadsheet-form-fields .x-spreadsheet-form-field .label { display: inline-block; margin: 0 10px 0 0; } .x-spreadsheet-form-field { display: block; vertical-align: middle; margin-left: 10px; margin-bottom: 10px; } .x-spreadsheet-form-field:first-child { margin-left: 0; } .x-spreadsheet-form-field.error .x-spreadsheet-form-select, .x-spreadsheet-form-field.error input { border-color: #f04134; } .x-spreadsheet-form-field .tip { color: #f04134; font-size: 0.9em; } .x-spreadsheet-dimmer { display: none; position: absolute; top: 0 !important; left: 0 !important; width: 100%; height: 100%; text-align: center; vertical-align: middle; background-color: rgba(0, 0, 0, 0.6); opacity: 0; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration: 0.5s; animation-duration: 0.5s; transition: background-color 0.5s linear; user-select: none; z-index: 1000; } .x-spreadsheet-dimmer.active { display: block; opacity: 1; } form fieldset { border: none; } form fieldset label { display: block; margin-bottom: 0.5em; font-size: 1em; color: #666; } form fieldset select { font-size: 1.1em; width: 100%; background-color: #fff; border: none; border-bottom: 2px solid #ddd; padding: 0.5em 0.85em; border-radius: 2px; } .x-spreadsheet-modal, .x-spreadsheet-toast { font-size: 13px; position: fixed; z-index: 1001; text-align: left; line-height: 1.25em; min-width: 360px; color: rgba(0, 0, 0, 0.87); font-family: 'Lato', 'Source Sans Pro', Roboto, Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.1); background-color: #fff; background-clip: padding-box; box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 8px; } .x-spreadsheet-toast { background-color: rgba(255, 255, 255, 0.85); } .x-spreadsheet-modal-header, .x-spreadsheet-toast-header { font-weight: 600; background-clip: padding-box; background-color: rgba(255, 255, 255, 0.85); border-bottom: 1px solid rgba(0, 0, 0, 0.05); border-radius: 4px 4px 0 0; } .x-spreadsheet-modal-header .x-spreadsheet-icon, .x-spreadsheet-toast-header .x-spreadsheet-icon { position: absolute; right: 0.8em; top: 0.65em; border-radius: 18px; } .x-spreadsheet-modal-header .x-spreadsheet-icon:hover, .x-spreadsheet-toast-header .x-spreadsheet-icon:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); } .x-spreadsheet-toast-header { color: #F2711C; } .x-spreadsheet-modal-header { border-bottom: 1px solid #e0e2e4; background: rgba(0, 0, 0, 0.08); font-size: 1.0785em; } .x-spreadsheet-modal-header, .x-spreadsheet-modal-content, .x-spreadsheet-toast-header, .x-spreadsheet-toast-content { padding: 0.75em 1em; } @media screen and (min-width: 320px) and (max-width: 480px) { .x-spreadsheet-toolbar { display: none; } } .x-spreadsheet-icon { width: 18px; height: 18px; margin: 1px 1px 2px 1px; text-align: center; vertical-align: middle; user-select: none; overflow: hidden; position: relative; display: inline-block; } .x-spreadsheet-icon .x-spreadsheet-icon-img { background-image: url(58eaeb4e52248a5c75936c6f4c33a370.svg); position: absolute; width: 262px; height: 444px; opacity: 0.56; } .x-spreadsheet-icon .x-spreadsheet-icon-img.undo { left: 0; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.redo { left: -18px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.print { left: -36px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.paintformat { left: -54px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.clearformat { left: -72px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.font-bold { left: -90px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.font-italic { left: -108px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.underline { left: -126px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.strike { left: -144px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.color { left: -162px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.bgcolor { left: -180px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.merge { left: -198px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-left { left: -216px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-center { left: -234px; top: 0; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-right { left: 0; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-top { left: -18px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-middle { left: -36px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.align-bottom { left: -54px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.textwrap { left: -72px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.autofilter { left: -90px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.formula { left: -108px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-down { left: -126px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.arrow-right { left: -144px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.link { left: -162px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chart { left: -180px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.freeze { left: -198px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.ellipsis { left: -216px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.add { left: -234px; top: -18px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-all { left: 0; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-inside { left: -18px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-horizontal { left: -36px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-vertical { left: -54px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-outside { left: -72px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-left { left: -90px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-top { left: -108px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-right { left: -126px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-bottom { left: -144px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.border-none { left: -162px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.line-color { left: -180px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.line-type { left: -198px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.close { left: -234px; top: -36px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-down { left: 0; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-up { left: -18px; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-left { left: -36px; top: -54px; } .x-spreadsheet-icon .x-spreadsheet-icon-img.chevron-right { left: -54px; top: -54px; } /*# sourceMappingURL=xspreadsheet.css.map*/ ================================================ FILE: docs/xspreadsheet.js ================================================ !function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){},function(t,e,n){},function(t,e,n){"use strict";function r(t){return function(t){if(Array.isArray(t))return t}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:"";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e?(this.el=document.createElement(e),this.el.className=n):this.el=e,this.data={}}var e,n,o;return e=t,(n=[{key:"data",value:function(t,e){return void 0!==e?(this.data[t]=e,this):this.data[t]}},{key:"on",value:function(t,e){var n=r(t.split(".")),i=n[0],o=n.slice(1),a=i;return"mousewheel"===a&&/Firefox/i.test(window.navigator.userAgent)&&(a="DOMMouseScroll"),this.el.addEventListener(a,function(t){e(t);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"active";return this.toggleClass(t)}},{key:"toggleClass",value:function(t){return this.el.classList.toggle(t)}},{key:"active",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"active";return t?this.addClass(e):this.removeClass(e),this}},{key:"checked",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.active(t,"checked"),this}},{key:"disabled",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return t?this.addClass("disabled"):this.removeClass("disabled"),this}},{key:"attr",value:function(t,e){var n=this;if(void 0!==e)this.el.setAttribute(t,e);else{if("string"==typeof t)return this.el.getAttribute(t);Object.keys(t).forEach(function(e){n.el.setAttribute(e,t[e])})}return this}},{key:"removeAttr",value:function(t){return this.el.removeAttribute(t),this}},{key:"html",value:function(t){return void 0!==t?(this.el.innerHTML=t,this):this.el.innerHTML}},{key:"val",value:function(t){return void 0!==t?(this.el.value=t,this):this.el.value}},{key:"focus",value:function(){this.el.focus()}},{key:"cssRemoveKeys",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:"";return new o(t,e)};n(0);function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var c=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function s(t){for(var e="",n=t;n>=c.length;)n/=c.length,n-=1,e+=c[parseInt(n,10)%c.length];var r=t%c.length;return e+=c[r]}function u(t){for(var e=0,n=0;n="0"&&t.charAt(r)<="9"?n+=t.charAt(r):e+=t.charAt(r);return[u(e),parseInt(n,10)-1]}function h(t,e){return"".concat(s(t)).concat(e+1)}function p(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){return!0};if(0===e&&0===n)return t;var i=l(f(t),2),o=i[0],a=i[1];return r(o,a)?h(o+e,a+n):t}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function y(t,e){for(var n=0;n4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.sri=e,this.sci=n,this.eri=r,this.eci=i,this.w=o,this.h=a}var e,n,r;return e=t,r=[{key:"valueOf",value:function(e){var n=e.split(":"),r=d(f(n[0]),2),i=r[0],o=r[1],a=o,l=i;if(n.length>1){var c=d(f(n[1]),2);l=c[0],a=c[1]}return new t(o,i,a,l)}}],(n=[{key:"set",value:function(t,e,n,r){this.sri=t,this.sci=e,this.eri=n,this.eci=r}},{key:"multiple",value:function(){return this.eri-this.sri>0||this.eci-this.sci>0}},{key:"includes",value:function(){for(var t=0,e=0,n=arguments.length,r=new Array(n),i=0;i1&&void 0!==arguments[1]?arguments[1]:function(){return!0},n=this.sri,r=this.sci,i=this.eri,o=this.eci,a=n;a<=i;a+=1)if(e(a))for(var l=r;l<=o;l+=1)t(a,l)}},{key:"contains",value:function(t){return this.sri<=t.sri&&this.sci<=t.sci&&this.eri>=t.eri&&this.eci>=t.eci}},{key:"within",value:function(t){return this.sri>=t.sri&&this.sci>=t.sci&&this.eri<=t.eri&&this.eci<=t.eci}},{key:"disjoint",value:function(t){return this.sri>t.eri||this.sci>t.eci||t.sri>this.eri||t.sci>this.eci}},{key:"intersects",value:function(t){return this.sri<=t.eri&&this.sci<=t.eci&&t.sri<=this.eri&&t.sci<=this.eci}},{key:"union",value:function(e){var n=this.sri,r=this.sci,i=this.eri,o=this.eci;return new t(e.srii?e.eri:i,e.eci>o?e.eci:o)}},{key:"difference",value:function(e){var n=[],r=function(e,r,i,o){n.push(new t(e,r,i,o))},i=this.sri,o=this.sci,a=this.eri,l=this.eci,c=e.sri-i,s=e.sci-o,u=a-e.eri,f=l-e.eci;return c>0?(r(i,o,e.sri-1,l),u>0?(r(e.eri+1,o,a,l),s>0&&r(e.sri,o,e.eri,e.sci-1),f>0&&r(e.sri,e.eci+1,e.eri,l)):(s>0&&r(e.sri,o,a,e.sci-1),f>0&&r(e.sri,e.eci+1,a,l))):u>0&&(r(e.eri+1,o,a,l),s>0&&r(i,o,e.eri,e.sci-1),f>0&&r(i,e.eci+1,e.eri,l)),s>0?(r(i,o,a,e.sci-1),f>0?(r(i,e.eri+1,a,l),c>0&&r(i,e.sci,e.sri-1,e.eci),u>0&&r(e.sri+1,e.sci,a,e.eci)):(c>0&&r(i,e.sci,e.sri-1,l),u>0&&r(e.sri+1,e.sci,a,l))):f>0&&(r(a,e.eci+1,a,l),c>0&&r(i,o,e.sri-1,e.eci),u>0&&r(e.eri+1,o,a,e.eci)),n}},{key:"size",value:function(){return[this.eri-this.sri+1,this.eci-this.sci+1]}},{key:"toString",value:function(){var t=this.sri,e=this.sci,n=this.eri,r=this.eci,i=h(e,t);return this.multiple()&&(i="".concat(i,":").concat(h(r,n))),i}},{key:"clone",value:function(){return new t(this.sri,this.sci,this.eri,this.eci,this.w,this.h)}},{key:"equals",value:function(t){return this.eri===t.eri&&this.eci===t.eci&&this.sri===t.sri&&this.sci===t.sci}}])&&y(e.prototype,n),r&&y(e,r),t}();function b(t,e){for(var n=0;n0}},{key:"canRedo",value:function(){return this.redoItems.length>0}},{key:"undo",value:function(t,e){var n=this.undoItems,r=this.redoItems;this.canUndo()&&(r.push(JSON.stringify(t)),e(JSON.parse(n.pop())))}},{key:"redo",value:function(t,e){var n=this.undoItems,r=this.redoItems;this.canRedo()&&(n.push(JSON.stringify(t)),e(JSON.parse(r.pop())))}}])&&w(e.prototype,n),r&&w(e,r),t}();function O(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._=e}var e,n,r;return e=t,(n=[{key:"forEach",value:function(t){this._.forEach(t)}},{key:"deleteWithin",value:function(t){this._=this._.filter(function(e){return!e.within(t)})}},{key:"getFirstIncludes",value:function(t,e){for(var n=0;n=e?(s.sri+=n,s.eri+=n):o=e?(s.sci+=n,s.eci+=n):a0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length,r=new Array(n>1?n-1:0),i=1;i5?l.toFixed(2):l;return l.toFixed(Math.max(r,i))}var z={cloneDeep:function(t){return JSON.parse(JSON.stringify(t))},merge:function(){for(var t=arguments.length,e=new Array(t),n=0;n1&&void 0!==arguments[1]?arguments[1]:function(t){return t},n=0,r=0;return Object.keys(t).forEach(function(i){n+=e(t[i],i),r+=1}),[n,r]},rangeEach:function(t,e,n){for(var r=t;ri);c+=1)a+=l=o(c);return[c,a-l,l]},deleteProperty:function(t,e){var n=t["".concat(e)];return delete t["".concat(e)],n},numberCalc:D};function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function M(t,e){for(var n=0;n0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}},{key:"isHide",value:function(t){var e=this.get(t);return e&&e.hide}},{key:"setHide",value:function(t,e){var n=this.getOrNew(t);!0===e?n.hide=!0:delete n.hide}},{key:"setStyle",value:function(t,e){this.getOrNew(t).style=e}},{key:"sumHeight",value:function(t,e,n){var r=this;return z.rangeSum(t,e,function(t){return n&&n.has(t)?0:r.getHeight(t)})}},{key:"totalHeight",value:function(){return this.sumHeight(0,this.len)}},{key:"get",value:function(t){return this._[t]}},{key:"getOrNew",value:function(t){return this._[t]=this._[t]||{cells:{}},this._[t]}},{key:"getCell",value:function(t,e){var n=this.get(t);return void 0!==n&&void 0!==n.cells&&void 0!==n.cells[e]?n.cells[e]:null}},{key:"getCellMerge",value:function(t,e){var n=this.getCell(t,e);return n&&n.merge?n.merge:[0,0]}},{key:"getCellOrNew",value:function(t,e){var n=this.getOrNew(t);return n.cells[e]=n.cells[e]||{},n.cells[e]}},{key:"setCell",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"all",i=this.getOrNew(t);"all"===r?i.cells[e]=n:"text"===r?(i.cells[e]=i.cells[e]||{},i.cells[e].text=n.text):"format"===r&&(i.cells[e]=i.cells[e]||{},i.cells[e].style=n.style,n.merge&&(i.cells[e].merge=n.merge))}},{key:"setCellText",value:function(t,e,n){this.getCellOrNew(t,e).text=n}},{key:"copyPaste",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},o=t.sri,a=t.sci,l=t.eri,c=t.eci,s=e.sri,u=e.sci,f=e.eri,h=e.eci,d=t.size(),y=H(d,2),v=y[0],b=y[1],g=e.size(),m=H(g,2),w=m[0],k=m[1],O=!0,S=0;(f0&&function(){var t=P.text,e=_-u+(j-s)+2;if(O||(e-=S+1),"="===t[0])P.text=t.replace(/[a-zA-Z]{1,3}\d+/g,function(t){var n=0,r=0;return o===s?n=e-1:r=e-1,/^\d+$/.test(t)?t:p(t,n,r)});else if(v<=1&&b>1&&(s>l||f1&&(u>c||h1&&void 0!==arguments[1]?arguments[1]:1,r={};this.each(function(i,o){var a=parseInt(i,10);a>=t&&(a+=n,e.eachCells(i,function(e,r){r.text&&"="===r.text[0]&&(r.text=r.text.replace(/[a-zA-Z]{1,3}\d+/g,function(e){return p(e,0,n,function(e,n){return n>=t})}))})),r[a]=o}),this._=r,this.len+=n}},{key:"delete",value:function(t,e){var n=this,r=e-t+1,i={};this.each(function(o,a){var l=parseInt(o,10);le&&(i[l-r]=a,n.eachCells(o,function(t,n){n.text&&"="===n.text[0]&&(n.text=n.text.replace(/[a-zA-Z]{1,3}\d+/g,function(t){return p(t,0,-r,function(t,n){return n>e})}))}))}),this._=i,this.len-=r}},{key:"insertColumn",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.each(function(r,i){var o={};e.eachCells(r,function(e,r){var i=parseInt(e,10);i>=t&&(i+=n,r.text&&"="===r.text[0]&&(r.text=r.text.replace(/[a-zA-Z]{1,3}\d+/g,function(e){return p(e,n,0,function(e){return e>=t})}))),o[i]=r}),i.cells=o})}},{key:"deleteColumn",value:function(t,e){var n=this,r=e-t+1;this.each(function(i,o){var a={};n.eachCells(i,function(n,i){var o=parseInt(n,10);oe&&(a[o-r]=i,i.text&&"="===i.text[0]&&(i.text=i.text.replace(/[a-zA-Z]{1,3}\d+/g,function(t){return p(t,-r,0,function(t){return t>e})})))}),o.cells=a})}},{key:"deleteCells",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t.each(function(t,r){e.deleteCell(t,r,n)})}},{key:"deleteCell",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=this.get(t);if(null!==r){var i=this.getCell(t,e);null!==i&&("all"===n?delete r.cells[e]:"text"===n?(i.text&&delete i.text,i.value&&delete i.value):"format"===n?(void 0!==i.style&&delete i.style,i.merge&&delete i.merge):"merge"===n&&i.merge&&delete i.merge)}}},{key:"maxCell",value:function(){var t=Object.keys(this._),e=t[t.length-1],n=this._[e];if(n){var r=n.cells,i=Object.keys(r),o=i[i.length-1];return[parseInt(e,10),parseInt(o,10)]}return[0,0]}},{key:"each",value:function(t){Object.entries(this._).forEach(function(e){var n=H(e,2),r=n[0],i=n[1];t(r,i)})}},{key:"eachCells",value:function(t,e){this._[t]&&this._[t].cells&&Object.entries(this._[t].cells).forEach(function(t){var n=H(t,2),r=n[0],i=n[1];e(r,i)})}},{key:"setData",value:function(t){t.len&&(this.len=t.len,delete t.len),this._=t}},{key:"getData",value:function(){var t=this.len;return Object.assign({len:t},this._)}}])&&M(e.prototype,n),r&&M(e,r),t}();function F(t,e){for(var n=0;n0&&(e-=1,this.isHide(e));)this.setHide(e,!1)}},{key:"isHide",value:function(t){var e=this._[t];return e&&e.hide}},{key:"setHide",value:function(t,e){var n=this.getOrNew(t);!0===e?n.hide=!0:delete n.hide}},{key:"setStyle",value:function(t,e){this.getOrNew(t).style=e}},{key:"sumWidth",value:function(t,e){var n=this;return z.rangeSum(t,e,function(t){return n.getWidth(t)})}},{key:"totalWidth",value:function(){return this.sumWidth(0,this.len)}}])&&F(e.prototype,n),r&&F(e,r),t}(),V="en",q={en:{toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}}};function B(t,e){if(e&&e[V])for(var n=e[V],r=t.split("."),i=0;i2?r-2:0),o=2;o=this.parseValue(l)&&o<=this.parseValue(c),"between",l,c)}if("nbe"===n){var s=$(r,2),u=s[0],f=s[1];return K(othis.parseValue(f),"notBetween",u,f)}if("eq"===n)return K(o===this.parseValue(r),"equal",r);if("neq"===n)return K(o!==this.parseValue(r),"notEqual",r);if("lt"===n)return K(othis.parseValue(r),"greaterThan",r);if("gte"===n)return K(o>=this.parseValue(r),"greaterThanEqual",r)}return[!0]}}])&&X(e.prototype,n),r&&X(e,r),t}();function G(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Q(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tt(t,e){for(var n=0;n0}).map(function(t){return t.getData()})}},{key:"setData",value:function(t){this._=t.map(function(t){return nt.valueOf(t)})}}]),t}();function it(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:function(){},r=this.merges,i=e.clone(),o=at(t.size(),2),a=o[0],l=o[1],c=at(e.size(),2),s=c[0],u=c[1];return a>s&&(i.eri=e.sri+a-1),l>u&&(i.eci=e.sci+l-1),!r.intersects(i)||(n(L("error.pasteForMergedCell")),!1)}function st(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this.rows,o=this.merges;"all"!==n&&"format"!==n||(i.deleteCells(e,n),o.deleteWithin(e)),i.copyPaste(t,e,n,r,function(t,e,n){if(n&&n.merge){var r=at(n.merge,2),i=r[0],a=r[1];if(i<=0&&a<=0)return;o.add(new v(t,e,t+i,e+a))}})}function ut(t,e){var n=this.clipboard,r=this.rows,i=this.merges;r.cutPaste(t,e),i.move(t,e.sri-t.sri,e.sci-t.sci),n.clear()}function ft(t,e,n){var r=this.styles,i=this.rows.getCellOrNew(t,e),o={};void 0!==i.style&&(o=z.cloneDeep(r[i.style])),o=z.merge(o,{border:n}),i.style=this.addStyle(o)}var ht=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.settings=z.merge(lt,n||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new A,this.rows=new N(this.settings.row),this.cols=new W(this.settings.col),this.validations=new rt,this.hyperlinks={},this.comments={},this.selector=new g,this.scroll=new m,this.history=new k,this.clipboard=new S,this.autoFilter=new T,this.change=function(){},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}var e,n,r;return e=t,(n=[{key:"addValidation",value:function(t,e,n){var r=this;this.changeData(function(){r.validations.add(t,e,n)})}},{key:"removeValidation",value:function(){var t=this,e=this.selector.range;this.changeData(function(){t.validations.remove(e)})}},{key:"getSelectedValidator",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=this.validations.get(e,n);return r?r.validator:null}},{key:"getSelectedValidation",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=t.range,i=this.validations.get(e,n),o={ref:r.toString()};return null!==i&&(o.mode=i.mode,o.validator=i.validator),o}},{key:"canUndo",value:function(){return this.history.canUndo()}},{key:"canRedo",value:function(){return this.history.canRedo()}},{key:"undo",value:function(){var t=this;this.history.undo(this.getData(),function(e){t.setData(e)})}},{key:"redo",value:function(){var t=this;this.history.redo(this.getData(),function(e){t.setData(e)})}},{key:"copy",value:function(){this.clipboard.copy(this.selector.range)}},{key:"cut",value:function(){this.clipboard.cut(this.selector.range)}},{key:"paste",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=this.clipboard,i=this.selector;return!r.isClear()&&(!!ct.call(this,r.range,i.range,n)&&(this.changeData(function(){r.isCopy()?st.call(t,r.range,i.range,e):r.isCut()&&ut.call(t,r.range,i.range)}),!0))}},{key:"pasteFromText",value:function(t){var e=t.split("\r\n").map(function(t){return t.replace(/"/g,"").split("\t")});e.length>0&&(e.length-=1);var n=this.rows,r=this.selector;this.changeData(function(){n.paste(e,r.range)})}},{key:"autofill",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=this.selector.range;return!!ct.call(this,i,t,r)&&(this.changeData(function(){st.call(n,i,t,e,!0)}),!0)}},{key:"clearClipboard",value:function(){this.clipboard.clear()}},{key:"calSelectedRangeByEnd",value:function(t,e){var n=this.selector,r=this.rows,i=this.cols,o=this.merges,a=n.range,l=a.sri,c=a.sci,s=a.eri,u=a.eci,f=n.ri,h=n.ci,p=t,d=e;return t<0&&(p=r.len-1),e<0&&(d=i.len-1),p>f?(l=f,s=p):(l=p,s=f),d>h?(c=h,u=d):(c=d,u=h),n.range=o.union(new v(l,c,s,u)),n.range=o.union(n.range),n.range}},{key:"calSelectedRangeByStart",value:function(t,e){var n=this.selector,r=this.rows,i=this.cols,o=this.merges.getFirstIncludes(t,e);return null===o&&(o=new v(t,e,t,e),-1===t&&(o.sri=0,o.eri=r.len-1),-1===e&&(o.sci=0,o.eci=i.len-1)),n.range=o,o}},{key:"setSelectedCellAttr",value:function(t,e){var n=this;this.changeData(function(){var r=n.selector,i=n.styles,o=n.rows;if("merge"===t)e?n.merge():n.unmerge();else if("border"===t)(function(t){var e=this,n=t.mode,r=t.style,i=t.color,o=this.styles,a=this.selector,l=this.rows,c=a.range,s=c.sri,u=c.sci,f=c.eri,h=c.eci,p=!this.isSignleSelected();if(p||"inside"!==n&&"horizontal"!==n&&"vertical"!==n)if("outside"!==n||p){if("none"===n)a.range.each(function(t,n){var r=l.getCell(t,n);if(r&&void 0!==r.style){var i=z.cloneDeep(o[r.style]);delete i.border,r.style=e.addStyle(i)}});else if("all"===n||"inside"===n||"outside"===n||"horizontal"===n||"vertical"===n)!function(){for(var t=[],o=s;o<=f;o+=1)for(var a=u;a<=h;a+=1){for(var c=[],d=0;dh)break;var w=l.getCell(o,a),k=0,O=0;if(w&&w.merge){var S=at(w.merge,2);k=S[0],O=S[1],t.push([o,a,k,O])}var x=k>0&&o+k===f,E=O>0&&a+O===h,j={};"all"===n?j={bottom:[r,i],top:[r,i],left:[r,i],right:[r,i]}:"inside"===n?(!E&&a0&&ft.call(e,o,a,j),a+=O}}();else if("top"===n||"bottom"===n)for(var d=u;d<=h;d+=1)"top"===n&&(ft.call(this,s,d,{top:[r,i]}),d+=l.getCellMerge(s,d)[1]),"bottom"===n&&(ft.call(this,f,d,{bottom:[r,i]}),d+=l.getCellMerge(f,d)[1]);else if("left"===n||"right"===n)for(var y=s;y<=f;y+=1)"left"===n&&(ft.call(this,y,u,{left:[r,i]}),y+=l.getCellMerge(y,u)[0]),"right"===n&&(ft.call(this,y,h,{right:[r,i]}),y+=l.getCellMerge(y,h)[0])}else ft.call(this,s,u,{top:[r,i],bottom:[r,i],left:[r,i],right:[r,i]})}).call(n,e);else if("formula"===t){var a=r.ri,l=r.ci,c=r.range;if(r.multiple()){var s=at(r.size(),2),u=s[0],f=s[1],p=c.sri,d=c.sci,y=c.eri,v=c.eci;if(u>1)for(var b=d;b<=v;b+=1){o.getCellOrNew(y+1,b).text="=".concat(e,"(").concat(h(b,p),":").concat(h(b,y),")")}else if(f>1){o.getCellOrNew(a,v+1).text="=".concat(e,"(").concat(h(d,a),":").concat(h(v,a),")")}}else{o.getCellOrNew(a,l).text="=".concat(e,"()")}}else r.range.each(function(r,a){var l=o.getCellOrNew(r,a),c={};if(void 0!==l.style&&(c=z.cloneDeep(i[l.style])),"format"===t)c.format=e,l.style=n.addStyle(c);else if("font-bold"===t||"font-italic"===t||"font-name"===t||"font-size"===t){var s={};s[t.split("-")[1]]=e,c.font=Object.assign(c.font||{},s),l.style=n.addStyle(c)}else"strike"===t||"textwrap"===t||"underline"===t||"align"===t||"valign"===t||"color"===t||"bgcolor"===t?(c[t]=e,l.style=n.addStyle(c)):l[t]=e})})}},{key:"setSelectedCellText",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"input",n=this.autoFilter,r=this.selector,i=this.rows,o=r.ri,a=r.ci,l=o;this.unsortedRowMap.has(o)&&(l=this.unsortedRowMap.get(o));var c=i.getCell(l,a),s=c?c.text:"";if(this.setCellText(l,a,t,e),n.active()){var u=n.getFilter(a);if(u){var f=u.value.findIndex(function(t){return t===s});f>=0&&u.value.splice(f,1,t)}}}},{key:"getSelectedCell",value:function(){var t=this.selector,e=t.ri,n=t.ci,r=e;return this.unsortedRowMap.has(e)&&(r=this.unsortedRowMap.get(e)),this.rows.getCell(r,n)}},{key:"xyInSelectedRect",value:function(t,e){var n=this.getSelectedRect(),r=n.left,i=n.top,o=n.width,a=n.height,l=t-this.cols.indexWidth,c=e-this.rows.height;return l>r&&li&&c0&&v>s&&(p=s),y>0&&y>u&&(d=u),{l:s,t:u,left:p,top:d,height:f,width:h,scroll:e}}},{key:"getCellRectByXY",value:function(t,e){var n=this.scroll,r=this.merges,i=this.rows,o=this.cols,a=function(t,e){var n=this.rows,r=this.freezeTotalHeight(),i=n.height;r+n.heightt);a+=1)o.has(a)||(l+=c=n.getHeight(a));return(l-=c)<=0?{ri:-1,top:0,height:c}:{ri:a-1,top:l,height:c}}.call(this,e,n.y),l=a.ri,c=a.top,s=a.height,u=function(t,e){var n=this.cols,r=this.freezeTotalWidth(),i=n.indexWidth;r+n.indexWidth=0||f>=0){var d=r.getFirstIncludes(l,f);if(d){l=d.sri,f=d.sci;var y=this.cellRect(l,f);h=y.left,c=y.top,p=y.width,s=y.height}}return{ri:l,ci:f,left:h,top:c,width:p,height:s}}},{key:"isSignleSelected",value:function(){var t=this.selector.range,e=t.sri,n=t.sci,r=t.eri,i=t.eci,o=this.getCell(e,n);if(o&&o.merge){var a=at(o.merge,2),l=a[0],c=a[1];if(e+l===r&&n+c===i)return!0}return!this.selector.multiple()}},{key:"canUnmerge",value:function(){var t=this.selector.range,e=t.sri,n=t.sci,r=t.eri,i=t.eci,o=this.getCell(e,n);if(o&&o.merge){var a=at(o.merge,2),l=a[0],c=a[1];if(e+l===r&&n+c===i)return!0}return!1}},{key:"merge",value:function(){var t=this,e=this.selector,n=this.rows;if(!this.isSignleSelected()){var r=at(e.size(),2),i=r[0],o=r[1];if(i>1||o>1){var a=e.range,l=a.sri,c=a.sci;this.changeData(function(){var r=n.getCellOrNew(l,c);r.merge=[i-1,o-1],t.merges.add(e.range),t.rows.deleteCells(e.range),t.rows.setCell(l,c,r)})}}}},{key:"unmerge",value:function(){var t=this,e=this.selector;if(this.isSignleSelected()){var n=e.range,r=n.sri,i=n.sci;this.changeData(function(){t.rows.deleteCell(r,i,"merge"),t.merges.deleteWithin(e.range)})}}},{key:"canAutofilter",value:function(){return!this.autoFilter.active()}},{key:"autofilter",value:function(){var t=this,e=this.autoFilter,n=this.selector;this.changeData(function(){e.active()?(e.clear(),t.exceptRowSet=new Set,t.sortedRowMap=new Map,t.unsortedRowMap=new Map):e.ref=n.range.toString()})}},{key:"setAutoFilter",value:function(t,e,n,r){var i=this.autoFilter;i.addFilter(t,n,r),i.setSort(t,e),this.resetAutoFilter()}},{key:"resetAutoFilter",value:function(){var t=this,e=this.autoFilter,n=this.rows;if(e.active()){var r=e.sort,i=e.filteredRows(function(t,e){return n.getCell(t,e)}),o=i.rset,a=i.fset,l=Array.from(a),c=Array.from(a);r&&l.sort(function(t,e){return"asc"===r.order?t-e:"desc"===r.order?e-t:0}),this.exceptRowSet=o,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,l.forEach(function(e,n){t.sortedRowMap.set(c[n],e),t.unsortedRowMap.set(e,c[n])})}}},{key:"deleteCell",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all",n=this.selector;this.changeData(function(){t.rows.deleteCells(n.range,e),"all"!==e&&"format"!==e||t.merges.deleteWithin(n.range)})}},{key:"insert",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.changeData(function(){var r=e.selector.range,i=r.sri,o=r.sci,a=e.rows,l=e.merges,c=e.cols,s=i;"row"===t?a.insert(i,n):"column"===t&&(a.insertColumn(o,n),s=o,c.len+=1),l.shift(t,s,n,function(t,e,n,r){var i=a.getCell(t,e);i.merge[0]+=n,i.merge[1]+=r})})}},{key:"delete",value:function(t){var e=this;this.changeData(function(){var n=e.rows,r=e.merges,i=e.selector,o=e.cols,a=i.range,l=i.range,c=l.sri,s=l.sci,u=l.eri,f=l.eci,h=at(i.range.size(),2),p=h[0],d=h[1],y=c,v=p;"row"===t?n.delete(c,u):"column"===t&&(n.deleteColumn(s,f),y=a.sci,v=d,o.len-=1),r.shift(t,y,-v,function(t,e,r,i){var o=n.getCell(t,e);o.merge[0]+=r,o.merge[1]+=i,0===o.merge[0]&&0===o.merge[1]&&delete o.merge})})}},{key:"scrollx",value:function(t,e){var n=this.scroll,r=this.freeze,i=this.cols,o=at(r,2)[1],a=at(z.rangeReduceIf(o,i.len,0,0,t,function(t){return i.getWidth(t)}),3),l=a[0],c=a[1],s=a[2],u=c;t>0&&(u+=s),n.x!==u&&(n.ci=t>0?l:0,n.x=u,e())}},{key:"scrolly",value:function(t,e){var n=this.scroll,r=this.freeze,i=this.rows,o=at(r,1)[0],a=at(z.rangeReduceIf(o,i.len,0,0,t,function(t){return i.getHeight(t)}),3),l=a[0],c=a[1],s=a[2],u=c;t>0&&(u+=s),n.y!==u&&(n.ri=t>0?l:0,n.y=u,e())}},{key:"cellRect",value:function(t,e){var n=this.rows,r=this.cols,i=r.sumWidth(0,e),o=n.sumHeight(0,t),a=n.getCell(t,e),l=r.getWidth(e),c=n.getHeight(t);if(null!==a&&a.merge){var s=at(a.merge,2),u=s[0],f=s[1];if(u>0)for(var h=1;h<=u;h+=1)c+=n.getHeight(t+h);if(f>0)for(var p=1;p<=f;p+=1)l+=r.getWidth(e+p)}return{left:i,top:o,width:l,height:c,cell:a}}},{key:"getCell",value:function(t,e){return this.rows.getCell(t,e)}},{key:"getCellTextOrDefault",value:function(t,e){var n=this.getCell(t,e);return n&&n.text?n.text:""}},{key:"getCellStyle",value:function(t,e){var n=this.getCell(t,e);return n&&void 0!==n.style?this.styles[n.style]:null}},{key:"getCellStyleOrDefault",value:function(t,e){var n=this.styles,r=this.rows.getCell(t,e),i=r&&void 0!==r.style?n[r.style]:{};return z.merge(this.defaultStyle(),i)}},{key:"getSelectedCellStyle",value:function(){var t=this.selector,e=t.ri,n=t.ci;return this.getCellStyleOrDefault(e,n)}},{key:"setCellText",value:function(t,e,n,r){var i=this.rows,o=this.history,a=this.validations;"finished"===r?(i.setCellText(t,e,""),o.add(this.getData()),i.setCellText(t,e,n)):(i.setCellText(t,e,n),this.change(this.getData())),a.validate(t,e,n)}},{key:"freezeIsActive",value:function(){var t=at(this.freeze,2),e=t[0],n=t[1];return e>0||n>0}},{key:"setFreeze",value:function(t,e){var n=this;this.changeData(function(){n.freeze=[t,e]})}},{key:"freezeTotalWidth",value:function(){return this.cols.sumWidth(0,this.freeze[1])}},{key:"freezeTotalHeight",value:function(){return this.rows.sumHeight(0,this.freeze[0])}},{key:"setRowHeight",value:function(t,e){var n=this;this.changeData(function(){n.rows.setHeight(t,e)})}},{key:"setColWidth",value:function(t,e){var n=this;this.changeData(function(){n.cols.setWidth(t,e)})}},{key:"viewHeight",value:function(){var t=this.settings,e=t.view,n=t.showToolbar,r=e.height();return r-=41,n&&(r-=41),r}},{key:"viewWidth",value:function(){return this.settings.view.width()}},{key:"freezeViewRange",value:function(){var t=at(this.freeze,2),e=t[0],n=t[1];return new v(0,0,e-1,n-1,this.freezeTotalWidth(),this.freezeTotalHeight())}},{key:"contentRange",value:function(){var t=this.rows,e=this.cols,n=at(t.maxCell(),2),r=n[0],i=n[1],o=t.sumHeight(0,r+1),a=e.sumWidth(0,i+1);return new v(0,0,r,i,a,o)}},{key:"exceptRowTotalHeight",value:function(t,e){var n=this.exceptRowSet,r=this.rows,i=Array.from(n),o=0;return i.forEach(function(n){if(ne){var i=r.getHeight(n);o+=i}}),o}},{key:"viewRange",value:function(){var t=this.scroll,e=this.rows,n=this.cols,r=this.freeze,i=this.exceptRowSet,o=t.ri,a=t.ci;o<=0&&(o=at(r,1)[0]);a<=0&&(a=at(r,2)[1]);for(var l=0,c=0,s=[e.len,n.len],u=s[0],f=s[1],h=o;hthis.viewHeight()));h+=1);for(var p=a;pthis.viewWidth()));p+=1);return new v(o,a,u,f,l,c)}},{key:"eachMergesInView",value:function(t,e){this.merges.filterIntersects(t).forEach(function(t){return e(t)})}},{key:"hideRowsOrCols",value:function(){var t=this.rows,e=this.cols,n=this.selector,r=at(n.size(),2),i=r[0],o=r[1],a=n.range,l=a.sri,c=a.sci,s=a.eri,u=a.eci;if(i===t.len)for(var f=c;f<=u;f+=1)e.setHide(f,!0);else if(o===e.len)for(var h=l;h<=s;h+=1)t.setHide(h,!0)}},{key:"unhideRowsOrCols",value:function(t,e){this["".concat(t,"s")].unhide(e)}},{key:"rowEach",value:function(t,e,n){for(var r=0,i=this.rows,o=this.exceptRowSet,a=it(o),l=0,c=0;c0&&(n(s,r,u),(r+=u)>this.viewHeight()))break}}},{key:"colEach",value:function(t,e,n){for(var r=0,i=this.cols,o=t;o<=e;o+=1){var a=i.getWidth(o);if(a>0&&(n(o,r,a),(r+=a)>this.viewWidth()))break}}},{key:"defaultStyle",value:function(){return this.settings.style}},{key:"addStyle",value:function(t){for(var e=this.styles,n=0;nMath.abs(e)?r(t>0?"right":"left",t,n):r(e>0?"down":"up",e,n)}var mt="x-spreadsheet";window.devicePixelRatio;function wt(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1?arguments[1]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.moving=!1,this.vertical=n,this.el=a("div","".concat(mt,"-resizer ").concat(n?"vertical":"horizontal")).children(this.unhideHoverEl=a("div","".concat(mt,"-resizer-hover")).on("dblclick.stop",function(t){return e.mousedblclickHandler(t)}).css("position","absolute").hide(),this.hoverEl=a("div","".concat(mt,"-resizer-hover")).on("mousedown.stop",function(t){return e.mousedownHandler(t)}),this.lineEl=a("div","".concat(mt,"-resizer-line")).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=r,this.unhideFn=function(){}}var e,n,r;return e=t,(n=[{key:"showUnhide",value:function(t){this.unhideIndex=t,this.unhideHoverEl.show()}},{key:"hideUnhide",value:function(){this.unhideHoverEl.hide()}},{key:"show",value:function(t,e){var n=this.moving,r=this.vertical,i=this.hoverEl,o=this.lineEl,a=this.el,l=this.unhideHoverEl;if(!n){this.cRect=t;var c=t.left,s=t.top,u=t.width,f=t.height;a.offset({left:r?c+u-5:c,top:r?s:s+f-5}).show(),i.offset({width:r?5:u,height:r?f:5}),o.offset({width:r?0:e.width,height:r?e.height:0}),l.offset({left:r?5-u:c,top:r?s:5-f,width:r?5:u,height:r?f:5})}}},{key:"hide",value:function(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}},{key:"mousedblclickHandler",value:function(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}},{key:"mousedownHandler",value:function(t){var e=this,n=t,r=this.el,i=this.lineEl,o=this.cRect,a=this.vertical,l=this.minDistance,c=a?o.width:o.height;i.show(),bt(window,function(t){e.moving=!0,null!==n&&1===t.buttons&&(a?(c+=t.movementX)>l&&r.css("left","".concat(o.left+c,"px")):(c+=t.movementY)>l&&r.css("top","".concat(o.top+c,"px")),n=t)},function(){n=null,i.hide(),e.moving=!1,e.hide(),e.finishedFn&&(cn){var r=this.vertical?"height":"width";this.el.css(r,"".concat(n-15,"px")).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(r,"".concat(e,"px"))}else this.el.hide();return this}}])&&Ot(e.prototype,n),r&&Ot(e,r),t}();function xt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Et(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];xt(this,t),this.useHideInput=n,this.inputChange=function(){},this.cornerEl=a("div","".concat(mt,"-selector-corner")),this.areaEl=a("div","".concat(mt,"-selector-area")).child(this.cornerEl).hide(),this.clipboardEl=a("div","".concat(mt,"-selector-clipboard")).hide(),this.autofillEl=a("div","".concat(mt,"-selector-autofill")).hide(),this.el=a("div","".concat(mt,"-selector")).css("z-index","".concat(_t)).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),n&&(this.hideInput=a("input","").on("compositionend",function(t){e.inputChange(t.target.value)}),this.el.child(this.hideInputDiv=a("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=a("div","hide-input").child(this.hideInput))),_t+=1}return jt(t,[{key:"setOffset",value:function(t){return this.el.offset(t).show(),this}},{key:"hide",value:function(){return this.el.hide(),this}},{key:"setAreaOffset",value:function(t){var e=t.left,n=t.top,r={width:t.width-3+.8,height:t.height-3+.8,left:e-.8,top:n-.8};this.areaEl.offset(r).show(),this.useHideInput&&(this.hideInputDiv.offset(r),this.hideInput.val("").focus())}},{key:"setClipboardOffset",value:function(t){var e=t.left,n=t.top,r=t.width,i=t.height;this.clipboardEl.offset({left:e,top:n,width:r-5,height:i-5})}},{key:"showAutofill",value:function(t){var e=t.left,n=t.top,r=t.width,i=t.height;this.autofillEl.offset({width:r-3,height:i-3,left:e,top:n}).show()}},{key:"hideAutofill",value:function(){this.autofillEl.hide()}},{key:"showClipboard",value:function(){this.clipboardEl.show()}},{key:"hideClipboard",value:function(){this.clipboardEl.hide()}}]),t}();function Tt(t){var e=this.data,n=t.left,r=t.top,i=t.width,o=t.height,a=t.scroll,l=t.l,c=t.t,s=e.freezeTotalWidth(),u=e.freezeTotalHeight(),f=n-s;s>l&&(f-=a.x);var h=r-u;return u>c&&(h-=a.y),{left:f,top:h,width:i,height:o}}function Pt(t){var e=this.data,n=t.left,r=t.width,i=t.height,o=t.l,a=t.t,l=t.scroll,c=e.freezeTotalWidth(),s=n-c;return c>o&&(s-=l.x),{left:s,top:a,width:r,height:i}}function At(t){var e=this.data,n=t.top,r=t.width,i=t.height,o=t.l,a=t.t,l=t.scroll,c=e.freezeTotalHeight(),s=n-c;return c>a&&(s-=l.y),{left:o,top:s,width:r,height:i}}function Rt(t){this.br.setAreaOffset(Tt.call(this,t))}function It(t){this.t.setAreaOffset(Pt.call(this,t))}function Dt(t){this.l.setAreaOffset(At.call(this,t))}function zt(t){this.l.setClipboardOffset(At.call(this,t))}function Ht(t){this.br.setClipboardOffset(Tt.call(this,t))}function Mt(t){this.t.setClipboardOffset(Pt.call(this,t))}function Nt(t){Rt.call(this,t),function(t){this.tl.setAreaOffset(t)}.call(this,t),It.call(this,t),Dt.call(this,t)}function Ft(t){Ht.call(this,t),function(t){this.tl.setClipboardOffset(t)}.call(this,t),Mt.call(this,t),zt.call(this,t)}var Wt=function(){function t(e){var n=this;xt(this,t),this.inputChange=function(){},this.data=e,this.br=new Ct(!0),this.t=new Ct,this.l=new Ct,this.tl=new Ct,this.br.inputChange=function(t){n.inputChange(t)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=a("div","".concat(mt,"-selectors")).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,_t+=1}return jt(t,[{key:"resetData",value:function(t){this.data=t,this.range=t.selector.range,this.resetAreaOffset()}},{key:"hide",value:function(){this.el.hide()}},{key:"resetOffset",value:function(){var t=this.data,e=this.tl,n=this.t,r=this.l,i=this.br,o=t.freezeTotalHeight(),a=t.freezeTotalWidth();o>0||a>0?(e.setOffset({width:a,height:o}),n.setOffset({left:a,height:o}),r.setOffset({top:o,width:a}),i.setOffset({left:a,top:o})):(e.hide(),n.hide(),r.hide(),i.setOffset({left:0,top:0}))}},{key:"resetAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();Nt.call(this,t),Ft.call(this,e),this.resetOffset()}},{key:"resetBRTAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();Rt.call(this,t),It.call(this,t),Ht.call(this,e),Mt.call(this,e),this.resetOffset()}},{key:"resetBRLAreaOffset",value:function(){var t=this.data.getSelectedRect(),e=this.data.getClipboardRect();Rt.call(this,t),Dt.call(this,t),Ht.call(this,e),zt.call(this,e),this.resetOffset()}},{key:"set",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.data,i=r.calSelectedRangeByStart(t,e),o=i.sri,a=i.sci;if(n){var l=t,c=e;t<0&&(l=0),e<0&&(c=0),r.selector.setIndexes(l,c),this.indexes=[l,c]}this.moveIndexes=[o,a],this.range=i,this.resetAreaOffset(),this.el.show()}},{key:"setEnd",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.data,i=this.lastri,o=this.lastci;if(n){if(t===i&&e===o)return;this.lastri=t,this.lastci=e}this.range=r.calSelectedRangeByEnd(t,e),Nt.call(this,this.data.getSelectedRect())}},{key:"reset",value:function(){var t=this.data.selector.range,e=t.eri,n=t.eci;this.setEnd(e,n)}},{key:"showAutofill",value:function(t,e){if(-1!==t||-1!==e){var n=this.range,r=n.sri,i=n.sci,o=n.eri,a=n.eci,l=t,c=e,s=r-t,u=o-t,f=a-e;if(i-e>0)this.arange=new v(r,c,o,i-1);else if(s>0)this.arange=new v(l,i,r-1,a);else if(f<0)this.arange=new v(r,a+1,o,c);else{if(!(u<0))return void(this.arange=null);this.arange=new v(o+1,i,l,a)}if(null!==this.arange){var h=this.data.getRect(this.arange);h.width+=2,h.height+=2;var p=this.br,d=this.l,y=this.t,b=this.tl;p.showAutofill(Tt.call(this,h)),d.showAutofill(At.call(this,h)),y.showAutofill(Pt.call(this,h)),b.showAutofill(h)}}}},{key:"hideAutofill",value:function(){var t=this;["br","l","t","tl"].forEach(function(e){t[e].hideAutofill()})}},{key:"showClipboard",value:function(){var t=this,e=this.data.getClipboardRect();Ft.call(this,e),["br","l","t","tl"].forEach(function(e){t[e].showClipboard()})}},{key:"hideClipboard",value:function(){var t=this;["br","l","t","tl"].forEach(function(e){t[e].hideClipboard()})}}]),t}();function Vt(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:"200px";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.filterItems=[],this.items=e,this.el=a("div","".concat(mt,"-suggest")).css("width",r).hide(),this.itemClick=n,this.itemIndex=-1}var e,n,r;return e=t,(n=[{key:"setOffset",value:function(t){this.el.cssRemoveKeys("top","bottom").offset(t)}},{key:"hide",value:function(){var t=this.el;this.filterItems=[],this.itemIndex=-1,t.hide(),yt(this.el.parent())}},{key:"setItems",value:function(t){this.items=t}},{key:"search",value:function(t){var e,n=this,r=this.items;if(/^\s*$/.test(t)||(r=r.filter(function(e){return(e.key||e).startsWith(t.toUpperCase())})),r=r.map(function(t){var e=t.title;e?"function"==typeof e&&(e=e()):e=t;var r=a("div","".concat(mt,"-item")).child(e).on("click.stop",function(){n.itemClick(t),n.hide()});return t.label&&r.child(a("div","label").html(t.label)),r}),this.filterItems=r,!(r.length<=0)){var i=this.el;(e=i.html("")).children.apply(e,Vt(r)).show(),vt(i.parent(),function(){n.hide()})}}},{key:"bindInputEvents",value:function(t){var e=this;t.on("keydown",function(t){return function(t){var e=t.keyCode;switch(t.ctrlKey&&t.stopPropagation(),e){case 37:t.stopPropagation();break;case 38:(function(t){t.preventDefault(),t.stopPropagation();var e=this.filterItems;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}).call(this,t);break;case 39:t.stopPropagation();break;case 40:(function(t){t.stopPropagation();var e=this.filterItems;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}).call(this,t);break;case 13:case 9:Bt.call(this,t);break;default:t.stopPropagation()}}.call(e,t)})}}])&&qt(e.prototype,n),r&&qt(e,r),t}();function Ut(t){return(Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Yt(t,e){for(var n=0;nr.width){var u=l;l>c&&(u=c,s+=parseInt(l/c,10),s+=l%c>0?1:0),n.css("width","".concat(u,"px"))}(s*=this.rowHeight)>r.height&&n.css("height","".concat(s,"px"))}}function le(t){var e=t.keyCode,n=t.altKey;13!==e&&9!==e&&t.stopPropagation(),13===e&&n&&(function(t,e){var n=t.target,r=n.value,i=n.selectionEnd,o="".concat(r.slice(0,i)).concat(e).concat(r.slice(i));n.value=o,n.setSelectionRange(i+1,i+1),this.inputText=o,this.textlineEl.html(o),ae.call(this)}.call(this,t,"\n"),t.stopPropagation()),13!==e||n||t.preventDefault()}function ce(t,e){var n=this.textEl,r=this.textlineEl;n.el.blur(),n.val(t),r.html(t),function(t){var e=this.textEl.el;setTimeout(function(){e.focus(),e.setSelectionRange(t,t)},0)}.call(this,e)}var se=function(){function t(e,n,r){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.viewFn=n,this.rowHeight=r,this.formulas=e,this.suggest=new Lt(e,function(t){(function(t){var e=this.inputText,n=this.validator,r=0;if(n&&"list"===n.type)this.inputText=t,r=this.inputText.length;else{var i=e.lastIndexOf("="),o=e.substring(0,i+1),a=e.substring(i+1);a=-1!==a.indexOf(")")?a.substring(a.indexOf(")")):"",this.inputText="".concat(o+t.key,"("),r=this.inputText.length,this.inputText+=")".concat(a)}ce.call(this,this.inputText,r)}).call(i,t)}),this.datepicker=new re,this.datepicker.change(function(t){i.setText(function(t){var e=t.getMonth()+1,n=t.getDate();return e<10&&(e="0".concat(e)),n<10&&(n="0".concat(n)),"".concat(t.getFullYear(),"-").concat(e,"-").concat(n)}(t)),i.clear()}),this.areaEl=a("div","".concat(mt,"-editor-area")).children(this.textEl=a("textarea","").on("input",function(t){return function(t){var e=t.target.value,n=this.suggest,r=this.textlineEl,i=this.validator,o=this.cell;if(null!==o)if("editable"in o&&!0===o.editable||void 0===o.editable){if(this.inputText=e,i)"list"===i.type?n.search(e):n.hide();else{var a=e.lastIndexOf("=");-1!==a?n.search(e.substring(a+1)):n.hide()}r.html(e),ae.call(this),this.change("input",e)}else t.target.value="";else{if(this.inputText=e,i)"list"===i.type?n.search(e):n.hide();else{var l=e.lastIndexOf("=");-1!==l?n.search(e.substring(l+1)):n.hide()}r.html(e),ae.call(this),this.change("input",e)}}.call(i,t)}).on("paste.stop",function(){}).on("keydown",function(t){return le.call(i,t)}),this.textlineEl=a("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",function(){}).on("mousedown.stop",function(){}),this.el=a("div","".concat(mt,"-editor")).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=function(){}}var e,n,r;return e=t,(n=[{key:"setFreezeLengths",value:function(t,e){this.freeze.w=t,this.freeze.h=e}},{key:"clear",value:function(){""!==this.inputText&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),function(){this.suggest.setItems(this.formulas)}.call(this),this.datepicker.hide()}},{key:"setOffset",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",n=this.textEl,r=this.areaEl,i=this.suggest,o=this.freeze,a=this.el;if(t){this.areaOffset=t;var l=t.left,c=t.top,s=t.width,u=t.height,f=t.l,h=t.t,p={left:0,top:0};o.w>f&&o.h>h||(o.wf?p.top=o.h:o.h>h&&(p.left=o.w)),a.offset(p),r.offset({left:l-p.left-.8,top:c-p.top-.8}),n.offset({width:s-9+.8,height:u-3+.8});var d={left:0};d[e]=u,i.setOffset(d),i.hide()}}},{key:"setCell",value:function(t,e){var n=this.el,r=this.datepicker,i=this.suggest;n.show(),this.cell=t;var o=t&&t.text||"";if(this.setText(o),this.validator=e,e){var a=e.type;"date"===a&&(r.show(),/^\s*$/.test(o)||r.setValue(o)),"list"===a&&(i.setItems(e.values()),i.search(""))}}},{key:"setText",value:function(t){this.inputText=t,ce.call(this,t,t.length),ae.call(this)}}])&&ie(e.prototype,n),r&&ie(e,r),t}();function ue(t){return(ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function fe(t,e){return!e||"object"!==ue(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function he(t){return(he=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function pe(t,e){return(pe=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var de=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=fe(this,he(e).call(this,"div","".concat(mt,"-button ").concat(r)))).child(L("button.".concat(t))),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&pe(t,e)}(e,o),e}();function ye(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0?e-.5:.5}var xe=function(){function t(e,n,r,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;be(this,t),this.x=e,this.y=n,this.width=r,this.height=i,this.padding=o,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}return me(t,[{key:"setBorders",value:function(t){var e=t.top,n=t.bottom,r=t.left,i=t.right;e&&(this.borderTop=e),i&&(this.borderRight=i),n&&(this.borderBottom=n),r&&(this.borderLeft=r)}},{key:"innerWidth",value:function(){return this.width-2*this.padding-2}},{key:"innerHeight",value:function(){return this.height-2*this.padding-2}},{key:"textx",value:function(t){var e=this.width,n=this.padding,r=this.x;return"left"===t?r+=n:"center"===t?r+=e/2:"right"===t&&(r+=e-n),r}},{key:"texty",value:function(t,e){var n=this.height,r=this.padding,i=this.y;return"top"===t?i+=r:"middle"===t?i+=n/2-e/2:"bottom"===t&&(i+=n-r-e),i}},{key:"topxys",value:function(){var t=this.x,e=this.y;return[[t,e],[t+this.width,e]]}},{key:"rightxys",value:function(){var t=this.x,e=this.y,n=this.width;return[[t+n,e],[t+n,e+this.height]]}},{key:"bottomxys",value:function(){var t=this.x,e=this.y,n=this.width,r=this.height;return[[t,e+r],[t+n,e+r]]}},{key:"leftxys",value:function(){var t=this.x,e=this.y;return[[t,e],[t,e+this.height]]}}]),t}();function Ee(t,e,n,r,i,o,a){var l={x:0,y:0};"underline"===t?l.y="bottom"===i?0:"top"===i?-(o+2):-o/2:"strike"===t&&("bottom"===i?l.y=o/2:"top"===i&&(l.y=-(o/2+2))),"center"===r?l.x=a/2:"right"===r&&(l.x=a),this.line([e-l.x,n-l.y],[e-l.x+a,n-l.y])}var je=function(){function t(e,n,r){be(this,t),this.el=e,this.ctx=e.getContext("2d"),this.resize(n,r),this.ctx.scale(we(),we())}return me(t,[{key:"resize",value:function(t,e){this.el.style.width="".concat(t,"px"),this.el.style.height="".concat(e,"px"),this.el.width=Oe(t),this.el.height=Oe(e)}},{key:"clear",value:function(){var t=this.el,e=t.width,n=t.height;return this.ctx.clearRect(0,0,e,n),this}},{key:"attr",value:function(t){return Object.assign(this.ctx,t),this}},{key:"save",value:function(){return this.ctx.save(),this.ctx.beginPath(),this}},{key:"restore",value:function(){return this.ctx.restore(),this}},{key:"beginPath",value:function(){return this.ctx.beginPath(),this}},{key:"translate",value:function(t,e){return this.ctx.translate(Oe(t),Oe(e)),this}},{key:"scale",value:function(t,e){return this.ctx.scale(t,e),this}},{key:"clearRect",value:function(t,e,n,r){return this.ctx.clearRect(t,e,n,r),this}},{key:"fillRect",value:function(t,e,n,r){return this.ctx.fillRect(Oe(t)-.5,Oe(e)-.5,Oe(n),Oe(r)),this}},{key:"fillText",value:function(t,e,n){return this.ctx.fillText(t,Oe(e),Oe(n)),this}},{key:"text",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=this.ctx,a=r.align,l=r.valign,c=r.font,s=r.color,u=r.strike,f=r.underline,h=e.textx(a);o.save(),o.beginPath(),this.attr({textAlign:a,textBaseline:l,font:"".concat(c.italic?"italic":""," ").concat(c.bold?"bold":""," ").concat(Oe(c.size),"px ").concat(c.name),fillStyle:s,strokeStyle:s});var p="".concat(t).split("\n"),d=e.innerWidth(),y=[];p.forEach(function(t){var e=o.measureText(t).width;if(i&&e>Oe(d)){for(var n={w:0,len:0,start:0},r=0;r=Oe(d)&&(y.push(t.substr(n.start,n.len)),n={w:0,len:0,start:r}),n.len+=1,n.w+=o.measureText(t[r]).width+1;n.len>0&&y.push(t.substr(n.start,n.len))}else y.push(t)});var v=(y.length-1)*(c.size+2),b=e.texty(l,v);return y.forEach(function(t){var e=o.measureText(t).width;n.fillText(t,h,b),u&&Ee.call(n,"strike",h,b,a,l,c.size,e),f&&Ee.call(n,"underline",h,b,a,l,c.size,e),b+=c.size+2}),o.restore(),this}},{key:"border",value:function(t,e){var n=this.ctx;return n.lineWidth=ke,n.strokeStyle=e,"medium"===t?n.lineWidth=Oe(2)-.5:"thick"===t?n.lineWidth=Oe(3):"dashed"===t?n.setLineDash([Oe(3),Oe(2)]):"dotted"===t?n.setLineDash([Oe(1),Oe(1)]):"double"===t&&n.setLineDash([Oe(2),0]),this}},{key:"line",value:function(){var t=this.ctx;if(arguments.length>1){t.beginPath();var e=arguments.length<=0?void 0:arguments[0],n=ve(e,2),r=n[0],i=n[1];t.moveTo(Se(r),Se(i));for(var o=1;o="a"&&s<="z")r.push(s.toUpperCase());else if(s>="0"&&s<="9"||s>="A"&&s<="Z"||"."===s)r.push(s);else if('"'===s){for(c+=1;'"'!==t.charAt(c);)r.push(t.charAt(c)),c+=1;n.push('"'.concat(r.join(""))),r=[]}else if("-"===s&&/[+\-*/,(]/.test(l))r.push(s);else{if("("!==s&&r.length>0&&n.push(r.join("")),")"===s){var u=e.pop();if(2===i)try{for(var p=Te(f(n.pop()),2),d=p[0],y=p[1],v=Te(f(n.pop()),2),b=v[0],g=v[1],m=0,w=b;w<=d;w+=1)for(var k=g;k<=y;k+=1)n.push(h(w,k)),m+=1;n.push([u,m])}catch(t){}else if(1===i||3===i)3===i&&n.push(o),n.push([u,a]),a=1;else for(;"("!==u&&(n.push(u),!(e.length<=0));)u=e.pop();i=0}else if("="===s||">"===s||"<"===s){var O=t.charAt(c+1);o=s,"="!==O&&"-"!==O||(o+=O,c+=1),i=3}else if(":"===s)i=2;else if(","===s)3===i&&n.push(o),i=1,a+=1;else if("("===s&&r.length>0)e.push(r.join(""));else{if(e.length>0&&("+"===s||"-"===s)){var S=e[e.length-1];if("("!==S&&n.push(e.pop()),"*"===S||"/"===S)for(;e.length>0&&"("!==(S=e[e.length-1]);)n.push(e.pop())}else if(e.length>0){var x=e[e.length-1];"*"!==x&&"/"!==x||n.push(e.pop())}e.push(s)}r=[]}l=s}}for(r.length>0&&n.push(r.join(""));e.length>0;)n.push(e.pop());return n},Ae=function(t,e){var n=Te(t,1)[0],r=t;if('"'===n)return t.substring(1);var i=1;if("-"===n&&(r=t.substring(1),i=-1),r[0]>="0"&&r[0]<="9")return i*Number(r);var o=Te(f(r),2);return i*e(o[0],o[1])},Re=function(t,e,n,r){for(var i=[],o=0;o"===l||"<"===l){var h=i.pop();Number.isNaN(h)||(h=Number(h));var p=i.pop();Number.isNaN(p)||(p=Number(p));var d=!1;"="===l?d=p===h:">"===a?d=p>h:">="===a?d=p>=h:"<"===a?d=p="a"&&l<="z"||l>="A"&&l<="Z")&&r.push(a),i.push(Ae(a,n)),r.pop()}}return i[0]},Ie={render:function t(e,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if("="===e[0]){var o=Pe(e.substring(1));return o.length<=0?e:Re(o,n,function(e,o){return t(r(e,o),n,r,i)},i)}return e}};function De(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function ze(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e3&&void 0!==arguments[3]?arguments[3]:0,i=t.cellRect(e,n),o=i.left,a=i.top,l=i.width,c=i.height;return new xe(o,a+r,l,c,Xe)}function Ge(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=e.sortedRowMap,a=e.rows,l=e.cols;if(!a.isHide(n)&&!l.isHide(r)){var c=n;o.has(n)&&(c=o.get(n));var s=e.getCell(c,r);if(null!==s){var u=!1;"editable"in s&&!1===s.editable&&(u=!0);var f=e.getCellStyleOrDefault(c,r),h=Je(e,n,r,i);h.bgcolor=f.bgcolor,void 0!==f.border&&(h.setBorders(f.border),t.strokeBorders(h)),t.rect(h,function(){var i=Ie.render(s.text||"",Ne,function(t,n){return e.getCellTextOrDefault(n,t)});f.format&&(i=Ue[f.format].render(i));var o=Object.assign({},f.font);o.size=function(t){for(var e=0;e0&&c.rows.isHide(t-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([5,i+5],[n-5,i+5]),l.restore())}),l.line([0,u+h],[n,u+h]),l.line([n,h],[n,u+h])),"all"!==t&&"top"!==t||(c.colEach(e.sci,e.eci,function(t,e,n){var i=p+e,o=t;l.line([i,0],[i,r]),v<=o&&o0&&c.cols.isHide(t-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([i+5,5],[i+5,r-5]),l.restore())}),l.line([f+p,0],[f+p,r]),l.line([0,r],[f+p,r])),l.restore()}function nn(t,e,n,r,i){var o=t.sri,a=t.sci,l=t.eri,c=t.eci,s=t.w,u=t.h,f=this.draw,h=this.data,p=h.settings;f.save(),f.attr(Ke).translate(e+r,n+i),f.clearRect(0,0,s,u),p.showGrid?(h.rowEach(o,l,function(t,e,n){t!==o&&f.line([0,e],[s,e]),t===l&&f.line([0,e+n],[s,e+n])}),h.colEach(a,c,function(t,e,n){t!==a&&f.line([e,0],[e,u]),t===c&&f.line([e+n,0],[e+n,u])}),f.restore()):f.restore()}var rn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.el=e,this.draw=new je(e,n.viewWidth(),n.viewHeight()),this.data=n}var e,n,r;return e=t,(n=[{key:"resetData",value:function(t){this.data=t,this.render()}},{key:"render",value:function(){var t=this.data,e=t.rows,n=t.cols.indexWidth,r=e.height;this.draw.resize(t.viewWidth(),t.viewHeight()),this.clear();var i=t.viewRange(),o=t.freezeTotalWidth(),a=t.freezeTotalHeight(),l=t.scroll,c=l.x,s=l.y;nn.call(this,i,n,r,o,a),Qe.call(this,i,n,r,-c,-s),en.call(this,"all",i,n,r,o,a),function(t,e){var n=this.draw;n.save(),n.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,t,e),n.restore()}.call(this,n,r);var u=Ye(t.freeze,2),f=u[0],h=u[1];if(f>0||h>0){if(f>0){var p=i.clone();p.sri=0,p.eri=f-1,p.h=a,nn.call(this,p,n,r,o,0),Qe.call(this,p,n,r,-c,0),en.call(this,"top",p,n,r,o,0)}if(h>0){var d=i.clone();d.sci=0,d.eci=h-1,d.w=o,nn.call(this,d,n,r,0,a),en.call(this,"left",d,n,r,0,a),Qe.call(this,d,n,r,0,-s)}var y=t.freezeViewRange();nn.call(this,y,n,r,0,0),en.call(this,"all",y,n,r,0,0),Qe.call(this,y,n,r,0,0),function(t,e,n,r){var i=this.draw,o=this.data,a=o.viewWidth()-t,l=o.viewHeight()-e;i.save().translate(t,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),i.line([0,r],[a,r]),i.line([n,0],[n,l]),i.restore()}.call(this,n,r,o,a)}}},{key:"clear",value:function(){this.draw.clear()}}])&&$e(e.prototype,n),r&&$e(e,r),t}();function on(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&(h+=(l-s.w)/2);var d=0,y=0;this.contentEl.html(""),this.canvases=[];for(var v={sri:0,sci:0,eri:0,eci:0},b=function(n){var o=0,l=0,u=a("div","".concat(mt,"-canvas-card")),b=a("canvas","".concat(mt,"-canvas"));t.canvases.push(b.el);var g=new je(b.el,r,i);for(g.save(),g.translate(h,p),f<1&&g.scale(f,f);d<=s.eri;d+=1){var m=e.rows.getHeight(d);if(!((o+=m)1&&void 0!==arguments[1]&&arguments[1];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.menuItems=yn.call(this),this.el=(n=a("div","".concat(mt,"-contextmenu"))).children.apply(n,hn(this.menuItems)).hide(),this.viewFn=e,this.itemClick=function(){},this.isHide=r,this.setMode("range")}var e,n,r;return e=t,(n=[{key:"setMode",value:function(t){var e=this.menuItems[12];"row-col"===t?e.show():e.hide()}},{key:"hide",value:function(){var t=this.el;t.hide(),yt(t)}},{key:"setPosition",value:function(t,e){if(!this.isHide){var n=this.el,r=n.show().offset().width,i=this.viewFn(),o=i.height/2,a=t;i.width-t<=r&&(a-=r),n.css("left","".concat(a,"px")),e>o?n.css("bottom","".concat(i.height-e,"px")).css("max-height","".concat(e,"px")).css("top","auto"):n.css("top","".concat(e,"px")).css("max-height","".concat(i.height-e,"px")).css("bottom","auto"),vt(n)}}}])&&pn(e.prototype,n),r&&pn(e,r),t}();function bn(t,e){for(var n=0;n4?c-4:0),u=4;u0)&&(t=this.contentEl).children.apply(t,arguments)}},{key:"setTitle",value:function(t){this.title.html(t),this.hide()}},{key:"show",value:function(){var t=this;this.contentEl.show(),this.parent().active(),vt(this.parent(),function(){t.hide()})}},{key:"hide",value:function(){this.parent().active(!1),this.contentEl.hide(),yt(this.parent())}}])&&_n(n.prototype,r),i&&_n(n,i),e}();function Rn(t){return(Rn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function In(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e'],["medium",''],["thick",''],["dashed",''],["dotted",'']],Xr=function(t){function e(t){var n,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var i=new Kt("line-type"),o=0,l=$r.map(function(e,n){return a("div","".concat(mt,"-item state ").concat(t===e[0]?"checked":"")).on("click",function(){l[o].toggle("checked"),l[n].toggle("checked"),o=n,r.hide(),r.change(e)}).child(a("div","".concat(mt,"-line-type")).html(e[1]))});return r=Lr(this,(n=Ur(e)).call.apply(n,[this,i,"auto",!1,"bottom-left"].concat(Br(l))))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Yr(t,e)}(e,An),e}();function Zr(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0?i.show():i.hide()}var _a=function(){function t(e,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.data=e,this.change=function(){},this.widthFn=n,this.isHide=i;var o=e.defaultStyle();this.items=[[this.undoEl=new ra,this.redoEl=new Go,new ca,this.paintformatEl=new Ci,this.clearformatEl=new Oi],Ea(),[this.formatEl=new xo],Ea(),[this.fontEl=new uo,this.fontSizeEl=new Gi],Ea(),[this.boldEl=new dr,this.italicEl=new mr,this.underlineEl=new Tr,this.strikeEl=new xr,this.textColorEl=new Di(o.color)],Ea(),[this.fillColorEl=new Wi(o.bgcolor),this.borderEl=new ui,this.mergeEl=new $o],Ea(),[this.alignEl=new Ln(o.align),this.valignEl=new Kn(o.valign),this.textwrapEl=new pa],Ea(),[this.freezeEl=new Vo,this.autofilterEl=new sr,this.formulaEl=new Ho,this.moreEl=new Oa]],this.el=a("div","".concat(mt,"-toolbar")),this.btns=a("div","".concat(mt,"-toolbar-btns")),this.items.forEach(function(t){Array.isArray(t)?t.forEach(function(t){r.btns.child(t.el),t.change=function(){r.change.apply(r,arguments)}}):r.btns.child(t.el)}),this.el.child(this.btns),i?this.el.hide():(this.reset(),setTimeout(function(){(function(){var t=this;this.btns2=[],this.items.forEach(function(e){if(Array.isArray(e))e.forEach(function(e){var n=e.el,r=n.box(),i=n.computedStyle(),o=i.marginLeft,a=i.marginRight;t.btns2.push([n,r.width+parseInt(o,10)+parseInt(a,10)])});else{var n=e.box(),r=e.computedStyle(),i=r.marginLeft,o=r.marginRight;t.btns2.push([e,n.width+parseInt(i,10)+parseInt(o,10)])}})}).call(r),ja.call(r)},0),pt(window,"resize",function(){ja.call(r)}))}var e,n,r;return e=t,(n=[{key:"paintformatActive",value:function(){return this.paintformatEl.active()}},{key:"paintformatToggle",value:function(){this.paintformatEl.toggle()}},{key:"trigger",value:function(t){this["".concat(t,"El")].click()}},{key:"resetData",value:function(t){this.data=t,this.reset()}},{key:"reset",value:function(){if(!this.isHide){var t=this.data,e=t.getSelectedCellStyle();this.undoEl.setState(!t.canUndo()),this.redoEl.setState(!t.canRedo()),this.mergeEl.setState(t.canUnmerge(),!t.selector.multiple()),this.autofilterEl.setState(!t.canAutofilter());var n=e.font,r=e.format;this.formatEl.setState(r),this.fontEl.setState(n.name),this.fontSizeEl.setState(n.size),this.boldEl.setState(n.bold),this.italicEl.setState(n.italic),this.underlineEl.setState(e.underline),this.strikeEl.setState(e.strike),this.textColorEl.setState(e.color),this.fillColorEl.setState(e.bgcolor),this.alignEl.setState(e.align),this.valignEl.setState(e.valign),this.textwrapEl.setState(e.textwrap),this.freezeEl.setState(t.freezeIsActive())}}}])&&Sa(e.prototype,n),r&&Sa(e,r),t}();function Ca(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e2&&void 0!==arguments[2]?arguments[2]:"600px";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.title=e,this.el=a("div","".concat(mt,"-modal")).css("width",o).children(a("div","".concat(mt,"-modal-header")).children(new Kt("close").on("click.stop",function(){return i.hide()}),this.title),(r=a("div","".concat(mt,"-modal-content"))).children.apply(r,Ca(n))).hide()}var e,n,r;return e=t,(n=[{key:"show",value:function(){var t=this;this.dimmer=a("div","".concat(mt,"-dimmer active")),document.body.appendChild(this.dimmer.el);var e=this.el.show().box(),n=e.width,r=e.height,i=document.documentElement,o=i.clientHeight,l=i.clientWidth;this.el.offset({left:(l-n)/2,top:(o-r)/3}),window.xkeydownEsc=function(e){27===e.keyCode&&t.hide()},pt(window,"keydown",window.xkeydownEsc)}},{key:"hide",value:function(){this.el.hide(),document.body.removeChild(this.dimmer.el),dt(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}])&&Ta(e.prototype,n),r&&Ta(e,r),t}();function Aa(t,e){for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:function(t){return t},l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.key=e,this.getTitle=o,this.vchange=function(){},this.el=a("div","".concat(mt,"-form-select")),this.suggest=new Lt(n.map(function(t){return{key:t,title:i.getTitle(t)}}),function(t){i.itemClick(t.key),l(t.key),i.vchange(t.key)},r,this.el),this.el.children(this.itemEl=a("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",function(){return i.show()})}var e,n,r;return e=t,(n=[{key:"show",value:function(){this.suggest.search("")}},{key:"itemClick",value:function(t){this.key=t,this.itemEl.html(this.getTitle(t))}},{key:"val",value:function(t){return void 0!==t?(this.key=t,this.itemEl.html(this.getTitle(t)),this):this.key}}])&&Ia(e.prototype,n),r&&Ia(e,r),t}();function za(t,e){for(var n=0;n3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(-1!==e||-1!==n){var o=this.table,a=this.selector,l=this.toolbar,c=this.data;this.contextMenu.setMode(-1===e||-1===n?"row-col":"range");var s=c.getCell(e,n);t?(a.setEnd(e,n,i),this.trigger("cells-selected",s,a.range)):(a.set(e,n,r),this.trigger("cell-selected",s,e,n)),l.reset(),o.render()}}function el(t,e){var n=this.selector,r=this.data,i=r.rows,o=r.cols,a=Ga(n.indexes,2),l=a[0],c=a[1],s=n.range,u=s.eri,f=s.eci;if(t){var h=Ga(n.moveIndexes,2);l=h[0],c=h[1]}"left"===e?c>0&&(c-=1):"right"===e?(f!==c&&(c=f),c0&&(l-=1):"down"===e?(u!==l&&(l=u),lu.width)n.move({left:i+c-u.width});else{var f=t.freezeTotalWidth();au.height)e.move({top:o+s-u.height-1});else{var h=t.freezeTotalHeight();l0||o>0){var a=e.freezeTotalWidth(),l=e.freezeTotalHeight();n.setFreezeLengths(a,l)}t.resetAreaOffset()}.call(this),r.render(),i.reset(),o.reset()}function ol(){var t=this.data,e=this.selector;t.clearClipboard(),e.hideClipboard()}function al(){var t=this.data,e=this.selector;t.copy(),e.showClipboard()}function ll(){var t=this.data,e=this.selector;t.cut(),e.showClipboard()}function cl(t,e){var n=this.data;if("read"!==n.settings.mode)if(n.paste(t,function(t){return Ka("Tip",t)}))il.call(this);else if(e){var r=e.clipboardData.getData("text/plain");this.data.pasteFromText(r),il.call(this)}}function sl(t,e){this.data.unhideRowsOrCols(t,e),il.call(this)}function ul(t){var e=this,n=this.selector,r=this.data,i=this.table,o=this.sortFilter,a=t.offsetX,l=t.offsetY,c=t.target.className==="".concat(mt,"-selector-corner"),s=r.getCellRectByXY(a,l),u=s.left,f=s.top,h=s.width,p=s.height,d=s.ri,y=s.ci,v=r.autoFilter;if(v.includes(d,y)&&u+h-20n.height/2&&(r="bottom"),t.setOffset(e,r)}function hl(){var t=this.editor,e=this.data;"read"!==e.settings.mode&&(fl.call(this),t.setCell(e.getSelectedCell(),e.getSelectedValidator()),ol.call(this))}function pl(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"finished",n=this.data,r=this.table;if("read"!==n.settings.mode){n.setSelectedCellText(t,e);var i=n.selector,o=i.ri,a=i.ci;"finished"===e?r.render():this.trigger("cell-edited",t,o,a)}}function dl(t){var e=this.data;"read"!==e.settings.mode&&("insert-row"===t?e.insert("row"):"delete-row"===t?e.delete("row"):"insert-column"===t?e.insert("column"):"delete-column"===t?e.delete("column"):"delete-cell"===t?e.deleteCell():"delete-cell-format"===t?e.deleteCell("format"):"delete-cell-text"===t?e.deleteCell("text"):"cell-printable"===t?e.setSelectedCellAttr("printable",!0):"cell-non-printable"===t?e.setSelectedCellAttr("printable",!1):"cell-editable"===t?e.setSelectedCellAttr("editable",!0):"cell-non-editable"===t&&e.setSelectedCellAttr("editable",!1),ol.call(this),il.call(this))}function yl(t,e){var n=this.data;if("undo"===t)this.undo();else if("redo"===t)this.redo();else if("print"===t)this.print.preview();else if("paintformat"===t)!0===e?al.call(this):ol.call(this);else if("clearformat"===t)dl.call(this,"delete-cell-format");else if("link"===t);else if("chart"===t);else if("autofilter"===t)(function(){this.data.autofilter(),il.call(this)}).call(this);else if("freeze"===t)if(e){var r=n.selector,i=r.ri,o=r.ci;this.freeze(i,o)}else this.freeze(0,0);else n.setSelectedCellAttr(t,e),"formula"!==t||n.selector.multiple()||hl.call(this),il.call(this)}function vl(){var t,e,n,r,i,o,a=this,l=this.selector,c=this.overlayerEl,s=this.rowResizer,u=this.colResizer,f=this.verticalScrollbar,h=this.horizontalScrollbar,p=this.editor,d=this.contextMenu,y=this.toolbar,v=this.modalValidation,b=this.sortFilter;c.on("mousemove",function(t){(function(t){if(0===t.buttons&&t.target.className!=="".concat(mt,"-resizer-hover")){var e=t.offsetX,n=t.offsetY,r=this.rowResizer,i=this.colResizer,o=this.tableEl,a=this.data,l=a.rows,c=a.cols;if(e>c.indexWidth&&n>l.height)return r.hide(),void i.hide();var s=o.box(),u=a.getCellRectByXY(t.offsetX,t.offsetY);u.ri>=0&&-1===u.ci?(u.width=c.indexWidth,r.show(u,{width:s.width}),l.isHide(u.ri-1)?r.showUnhide(u.ri):r.hideUnhide()):r.hide(),-1===u.ri&&u.ci>=0?(u.height=l.height,i.show(u,{height:s.height}),c.isHide(u.ci-1)?i.showUnhide(u.ci):i.hideUnhide()):i.hide()}}).call(a,t)}).on("mousedown",function(t){p.clear(),d.hide(),2===t.buttons?(a.data.xyInSelectedRect(t.offsetX,t.offsetY)?d.setPosition(t.offsetX,t.offsetY):(ul.call(a,t),d.setPosition(t.offsetX,t.offsetY)),t.stopPropagation()):2===t.detail?hl.call(a):ul.call(a,t)}).on("mousewheel.stop",function(t){(function(t){var e=this.verticalScrollbar,n=this.horizontalScrollbar,r=this.data,i=e.scroll().top,o=n.scroll().left,a=r.rows,l=r.cols,c=t.deltaY,s=t.deltaX,u=function(t,e){var n=t,r=0;do{r=e(n),n+=1}while(r<=0);return r},f=function(t){if(t>0){var n=r.scroll.ri+1;if(n=0){var c=u(l,function(t){return a.getHeight(t)});e.move({top:0===l?0:i-c})}}},h=Math.abs(c),p=Math.abs(s),d=Math.max(h,p);/Firefox/i.test(window.navigator.userAgent)&&Qa(f(t.detail),50),d===p&&Qa(function(t){if(t>0){var e=r.scroll.ci+1;if(e=0){var c=u(a,function(t){return l.getWidth(t)});n.move({left:0===a?0:o-c})}}}(s),50),d===h&&Qa(f(c),50)}).call(a,t)}).on("mouseout",function(t){var e=t.offsetX;t.offsetY<=0&&u.hide(),e<=0&&s.hide()}),l.inputChange=function(t){pl.call(a,t,"input"),hl.call(a)},t=c.el,n=(e={move:function(t,e){(function(t,e){var n=this.verticalScrollbar,r=this.horizontalScrollbar,i=n.scroll().top,o=r.scroll().left;"left"===t||"right"===t?r.move({left:o-e}):"up"!==t&&"down"!==t||n.move({top:i-e})}).call(a,t,e)}}).move,r=e.end,i=0,o=0,pt(t,"touchstart",function(t){var e=t.touches[0],n=e.pageX,r=e.pageY;i=n,o=r}),pt(t,"touchmove",function(t){if(n){var e=t.changedTouches[0],r=e.pageX,a=e.pageY,l=r-i,c=a-o;(Math.abs(l)>10||Math.abs(c)>10)&&(gt(l,c,t,n),i=r,o=a),t.preventDefault()}}),pt(t,"touchend",function(t){if(r){var e=t.changedTouches[0],n=e.pageX,a=e.pageY;gt(n-i,a-o,t,r)}}),y.change=function(t,e){return yl.call(a,t,e)},b.ok=function(t,e,n,r){return function(t,e,n,r){this.data.setAutoFilter(t,e,n,r),il.call(this)}.call(a,t,e,n,r)},s.finishedFn=function(t,e){(function(t,e){var n=t.ri,r=this.table,i=this.selector;this.data.rows.setHeight(n,e),r.render(),i.resetAreaOffset(),nl.call(this),fl.call(this)}).call(a,t,e)},u.finishedFn=function(t,e){(function(t,e){var n=t.ci,r=this.table,i=this.selector;this.data.cols.setWidth(n,e),r.render(),i.resetAreaOffset(),rl.call(this),fl.call(this)}).call(a,t,e)},s.unhideFn=function(t){sl.call(a,"row",t)},u.unhideFn=function(t){sl.call(a,"col",t)},f.moveFn=function(t,e){(function(t){var e=this,n=this.data,r=this.table,i=this.selector;n.scrolly(t,function(){i.resetBRLAreaOffset(),fl.call(e),r.render()})}).call(a,t,e)},h.moveFn=function(t,e){(function(t){var e=this,n=this.data,r=this.table,i=this.selector;n.scrollx(t,function(){i.resetBRTAreaOffset(),fl.call(e),r.render()})}).call(a,t,e)},p.change=function(t,e){pl.call(a,e,t)},v.change=function(t){if("save"===t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i=65&&e<=90||e>=48&&e<=57||e>=96&&e<=105||"="===t.key?(pl.call(a,t.key,"input"),hl.call(a)):113===e&&hl.call(a)}}})}var bl=function(){function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.eventMap=new Map;var i=n.settings,o=i.view,l=i.showToolbar,c=i.showContextmenu;this.el=a("div","".concat(mt,"-sheet")),this.toolbar=new _a(n,o.width,!l),this.print=new fn(n),e.children(this.toolbar.el,this.el,this.print.el),this.data=n,this.tableEl=a("canvas","".concat(mt,"-table")),this.rowResizer=new kt(!1,n.rows.height),this.colResizer=new kt(!0,n.cols.minWidth),this.verticalScrollbar=new St(!0),this.horizontalScrollbar=new St(!1),this.editor=new se(Me,function(){return r.getTableOffset()},n.rows.height),this.modalValidation=new La,this.contextMenu=new vn(function(){return r.getRect()},!c),this.selector=new Wt(n),this.overlayerCEl=a("div","".concat(mt,"-overlayer-content")).children(this.editor.el,this.selector.el),this.overlayerEl=a("div","".concat(mt,"-overlayer")).child(this.overlayerCEl),this.sortFilter=new Za,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new rn(this.tableEl.el,n),vl.call(this),il.call(this),tl.call(this,!1,0,0)}var e,n,r;return e=t,(n=[{key:"on",value:function(t,e){return this.eventMap.set(t,e),this}},{key:"trigger",value:function(t){var e=this.eventMap;if(e.has(t)){for(var n,r=arguments.length,i=new Array(r>1?r-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:function(){},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};kl(this,t),this.swapFunc=r,this.updateFunc=o,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new _l(function(t){e.clickSwap2(e.items[t])}),this.contextMenu=new Pl,this.contextMenu.itemClick=i,this.el=a("div","".concat(mt,"-bottombar")).children(this.contextMenu.el,this.menuEl=a("ul","".concat(mt,"-menu")).child(a("li","").children(new Kt("add").on("click",function(){e.dataNames.length<10?n():Ka("tip","it less than or equal to 10")}),a("span","").child(this.moreEl))))}return Sl(t,[{key:"addItem",value:function(t,e){var n=this;this.dataNames.push(t);var r=a("li",e?"active":"").child(t);r.on("click",function(){n.clickSwap2(r)}).on("contextmenu",function(t){var e=t.target,i=e.offsetLeft,o=e.offsetHeight;n.contextMenu.setOffset({left:i,bottom:o+1}),n.deleteEl=r}).on("dblclick",function(){var t=r.html(),e=new Ra("auto","");e.val(t),e.input.on("blur",function(e){var r=e.target.value,i=n.dataNames.findIndex(function(e){return e===t});n.renameItem(i,r)}),r.html("").child(e.el),e.focus()}),e&&this.clickSwap(r),this.items.push(r),this.menuEl.child(r),this.moreEl.reset(this.dataNames)}},{key:"renameItem",value:function(t,e){this.dataNames.splice(t,1,e),this.moreEl.reset(this.dataNames),this.items[t].html("").child(e),this.updateFunc(t,e)}},{key:"clear",value:function(){var t=this;this.items.forEach(function(e){t.menuEl.removeChild(e.el)}),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}},{key:"deleteItem",value:function(){var t=this.activeEl,e=this.deleteEl;if(this.items.length>1){var n=this.items.findIndex(function(t){return t===e});if(this.items.splice(n,1),this.dataNames.splice(n,1),this.menuEl.removeChild(e.el),this.moreEl.reset(this.dataNames),t===e){var r=gl(this.items,1)[0];return this.activeEl=r,this.activeEl.toggle(),[n,0]}return[n,-1]}return[-1]}},{key:"clickSwap2",value:function(t){var e=this.items.findIndex(function(e){return e===t});this.clickSwap(t),this.activeEl.toggle(),this.swapFunc(e)}},{key:"clickSwap",value:function(t){null!==this.activeEl&&this.activeEl.toggle(),this.activeEl=t}}]),t}();n(1);function Rl(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,l=t[Symbol.iterator]();!(r=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==l.return||l.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Il(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var i=e;this.options=r,this.sheetIndex=1,this.datas=[],"string"==typeof e&&(i=document.querySelector(e)),this.bottombar=new Al(function(){var t=n.addSheet();n.sheet.resetData(t)},function(t){var e=n.datas[t];n.sheet.resetData(e)},function(){n.deleteSheet()},function(t,e){n.datas[t].name=e}),this.data=this.addSheet();var o=a("div","".concat(mt)).on("contextmenu",function(t){return t.preventDefault()});i.appendChild(o.el),this.sheet=new bl(o,this.data),o.child(this.bottombar.el)}var e,n,r;return e=t,r=[{key:"locale",value:function(t,e){Y(t,e)}}],(n=[{key:"addSheet",value:function(t){var e=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t||"sheet".concat(this.sheetIndex),i=new ht(r,this.options);return i.change=function(){for(var t,n=arguments.length,r=new Array(n),i=0;i=0&&(this.datas.splice(e,1),n>=0&&this.sheet.resetData(this.datas[n]))}},{key:"loadData",value:function(t){var e=Array.isArray(t)?t:[t];if(this.bottombar.clear(),this.datas=[],e.length>0)for(var n=0;n3&&void 0!==arguments[3]?arguments[3]:0;return this.datas[r].setCellText(t,e,n,"finished"),this}},{key:"cell",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.datas[n].getCell(t,e)}},{key:"cellStyle",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.datas[n].getCellStyle(t,e)}},{key:"reRender",value:function(){return this.sheet.table.render(),this}},{key:"on",value:function(t,e){return this.sheet.on(t,e),this}},{key:"validate",value:function(){return this.data.validations.errors.size<=0}},{key:"change",value:function(t){return this.sheet.on("change",t),this}}])&&Il(e.prototype,n),r&&Il(e,r),t}(),zl=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Dl(t,e)};window&&(window.x_spreadsheet=zl,window.x_spreadsheet.locale=function(t,e){return Y(t,e)});e.default=Dl}]); //# sourceMappingURL=xspreadsheet.js.map ================================================ FILE: index.html ================================================ <%= htmlWebpackPlugin.options.title %>
================================================ FILE: npmx.txt ================================================ mkdir x-spreadsheet && cd x-spreadsheet npm init -y npm install webpack webpack-cli --save-dev mkdir dist src touch webpack.config.js npm install --save-dev file-loader css-loader file-loader npm install --save-dev html-webpack-plugin npm install --save-dev clean-webpack-plugin npm install --save-dev webpack-dev-server npm install --save-dev webpack-merge # less npm install less --save-dev npm install less-loader --save-dev npm install eslint --save-dev ./node_modules/.bin/eslint --init # airbnb # test mocha npm install --save-dev mocha # babel npm install --save-dev babel-loader babel-core babel-preset-env # for macha npm install --save-dev babel-register # npm install --save-dev babel-plugin-transform-runtime # npm install --save babel-runtime ================================================ FILE: package.json ================================================ { "name": "x-data-spreadsheet", "version": "1.1.8", "description": "a javascript xpreadsheet", "types": "src/index.d.ts", "main": "src/index.js", "files": [ "assets", "dist", "src" ], "author": "myliang ", "license": "MIT", "repository": { "type": "git", "url": "https://github.com/myliang/x-spreadsheet.git" }, "nyc": { "all": true, "include": [ "src/core/*.js", "src/locale/locale.js" ], "exclude": [ "**/*.spec.js" ] }, "scripts": { "dev": "webpack-dev-server --open --config build/webpack.dev.js", "build": "webpack --config build/webpack.prod.js", "build-locale": "webpack --config build/webpack.locale.js", "lint": "./node_modules/eslint/bin/eslint.js src", "test": "nyc ./node_modules/mocha/bin/mocha --require @babel/register --recursive test", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov -t 31ecdb12-8ecb-46f7-a486-65c2516307dd", "postinstall": "opencollective-postinstall" }, "keywords": [ "javascript", "spreadsheet", "canvas" ], "devDependencies": { "@babel/core": "^7.3.4", "@babel/plugin-proposal-class-properties": "^7.4.4", "@babel/preset-env": "^7.3.4", "@babel/register": "^7.0.0", "babel-loader": "^8.0.5", "clean-webpack-plugin": "^0.1.19", "codecov": "^3.3.0", "css-loader": "^1.0.0", "eslint": "^6.8.0", "eslint-config-airbnb-base": "^13.1.0", "eslint-plugin-import": "^2.14.0", "file-loader": "^2.0.0", "html-webpack-plugin": "^3.2.0", "less": "^3.8.1", "less-loader": "^4.1.0", "mini-css-extract-plugin": "^0.4.4", "mocha": "^5.2.0", "nyc": "^13.3.0", "style-loader": "^0.23.0", "webpack": "^4.29.6", "webpack-cli": "^3.1.0", "webpack-dev-server": "^3.10.2", "webpack-merge": "^4.1.4" }, "dependencies": { "opencollective": "^1.0.3", "opencollective-postinstall": "^2.0.2" }, "collective": { "type": "opencollective", "url": "https://opencollective.com/x-spreadsheet" } } ================================================ FILE: readme.md ================================================ # x-spreadsheet [![npm package](https://img.shields.io/npm/v/x-data-spreadsheet.svg)](https://www.npmjs.org/package/x-data-spreadsheet) [![NPM downloads](http://img.shields.io/npm/dm/x-data-spreadsheet.svg)](https://npmjs.org/package/x-data-spreadsheet) [![NPM downloads](http://img.shields.io/npm/dt/x-data-spreadsheet.svg)](https://npmjs.org/package/x-data-spreadsheet) [![Build passing](https://travis-ci.org/myliang/x-spreadsheet.svg?branch=master)](https://travis-ci.org/myliang/x-spreadsheet) [![codecov](https://codecov.io/gh/myliang/x-spreadsheet/branch/master/graph/badge.svg)](https://codecov.io/gh/myliang/x-spreadsheet) ![GitHub](https://img.shields.io/github/license/myliang/x-spreadsheet.svg) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/myliang/x-spreadsheet.svg) [![Join the chat at https://gitter.im/x-datav/spreadsheet](https://badges.gitter.im/x-datav/spreadsheet.svg)](https://gitter.im/x-datav/spreadsheet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) > A web-based JavaScript spreadsheet

## Document * en * [zh-cn 中文](https://hondrytravis.github.io/x-spreadsheet-doc/) ## CDN ```html ``` ## NPM ```shell npm install x-data-spreadsheet ``` ```html
``` ```javascript import Spreadsheet from "x-data-spreadsheet"; // If you need to override the default options, you can set the override // const options = {}; // new Spreadsheet('#x-spreadsheet-demo', options); const s = new Spreadsheet("#x-spreadsheet-demo") .loadData({}) // load data .change(data => { // save data to db }); // data validation s.validate() ``` ```javascript // default options { mode: 'edit', // edit | read showToolbar: true, showGrid: true, showContextmenu: true, view: { height: () => document.documentElement.clientHeight, width: () => document.documentElement.clientWidth, }, row: { len: 100, height: 25, }, col: { len: 26, width: 100, indexWidth: 60, minWidth: 60, }, style: { bgcolor: '#ffffff', align: 'left', valign: 'middle', textwrap: false, strike: false, underline: false, color: '#0a0a0a', font: { name: 'Helvetica', size: 10, bold: false, italic: false, }, }, } ``` ## import | export xlsx https://github.com/SheetJS/sheetjs/tree/master/demos/xspreadsheet#saving-data thanks https://github.com/SheetJS/sheetjs ## Bind events ```javascript const s = new Spreadsheet("#x-spreadsheet-demo") // event of click on cell s.on('cell-selected', (cell, ri, ci) => {}); s.on('cells-selected', (cell, { sri, sci, eri, eci }) => {}); // edited on cell s.on('cell-edited', (text, ri, ci) => {}); ``` ## update cell-text ```javascript const s = new Spreadsheet("#x-spreadsheet-demo") // cellText(ri, ci, text, sheetIndex = 0) s.cellText(5, 5, 'xxxx').cellText(6, 5, 'yyy').reRender(); ``` ## get cell and cell-style ```javascript const s = new Spreadsheet("#x-spreadsheet-demo") // cell(ri, ci, sheetIndex = 0) s.cell(ri, ci); // cellStyle(ri, ci, sheetIndex = 0) s.cellStyle(ri, ci); ``` ## Internationalization ```javascript // npm import Spreadsheet from 'x-data-spreadsheet'; import zhCN from 'x-data-spreadsheet/dist/locale/zh-cn'; Spreadsheet.locale('zh-cn', zhCN); new Spreadsheet(document.getElementById('xss-demo')); ``` ```html ``` ## Features - Undo & Redo - Paint format - Clear format - Format - Font - Font size - Font bold - Font italic - Underline - Strike - Text color - Fill color - Borders - Merge cells - Align - Text wrapping - Freeze cell - Functions - Resize row-height, col-width - Copy, Cut, Paste - Autofill - Insert row, column - Delete row, column - hide row, column - multiple sheets - print - Data validations ## Development ```sheel git clone https://github.com/myliang/x-spreadsheet.git cd x-spreadsheet npm install npm run dev ``` Open your browser and visit http://127.0.0.1:8080. ## Browser Support Modern browsers(chrome, firefox, Safari). ## LICENSE MIT ================================================ FILE: src/algorithm/bitmap.js ================================================ /* eslint no-bitwise: "off" */ /* v: int value digit: bit len of v flag: true or false */ const bitmap = (v, digit, flag) => { const b = 1 << digit; return flag ? (v | b) : (v ^ b); }; export default bitmap; ================================================ FILE: src/algorithm/expression.js ================================================ // src: include chars: [0-9], +, -, *, / // // 9+(3-1)*3+10/2 => 9 3 1-3*+ 10 2/+ const infix2suffix = (src) => { const operatorStack = []; const stack = []; for (let i = 0; i < src.length; i += 1) { const c = src.charAt(i); if (c !== ' ') { if (c >= '0' && c <= '9') { stack.push(c); } else if (c === ')') { let c1 = operatorStack.pop(); while (c1 !== '(') { stack.push(c1); c1 = operatorStack.pop(); } } else { // priority: */ > +- if (operatorStack.length > 0 && (c === '+' || c === '-')) { const last = operatorStack[operatorStack.length - 1]; if (last === '*' || last === '/') { while (operatorStack.length > 0) { stack.push(operatorStack.pop()); } } } operatorStack.push(c); } } } while (operatorStack.length > 0) { stack.push(operatorStack.pop()); } return stack; }; export default { infix2suffix, }; ================================================ FILE: src/canvas/draw.js ================================================ /* global window */ function dpr() { return window.devicePixelRatio || 1; } function thinLineWidth() { return dpr() - 0.5; } function npx(px) { return parseInt(px * dpr(), 10); } function npxLine(px) { const n = npx(px); return n > 0 ? n - 0.5 : 0.5; } class DrawBox { constructor(x, y, w, h, padding = 0) { this.x = x; this.y = y; this.width = w; this.height = h; this.padding = padding; this.bgcolor = '#ffffff'; // border: [width, style, color] this.borderTop = null; this.borderRight = null; this.borderBottom = null; this.borderLeft = null; } setBorders({ top, bottom, left, right, }) { if (top) this.borderTop = top; if (right) this.borderRight = right; if (bottom) this.borderBottom = bottom; if (left) this.borderLeft = left; } innerWidth() { return this.width - (this.padding * 2) - 2; } innerHeight() { return this.height - (this.padding * 2) - 2; } textx(align) { const { width, padding } = this; let { x } = this; if (align === 'left') { x += padding; } else if (align === 'center') { x += width / 2; } else if (align === 'right') { x += width - padding; } return x; } texty(align, h) { const { height, padding } = this; let { y } = this; if (align === 'top') { y += padding; } else if (align === 'middle') { y += height / 2 - h / 2; } else if (align === 'bottom') { y += height - padding - h; } return y; } topxys() { const { x, y, width } = this; return [[x, y], [x + width, y]]; } rightxys() { const { x, y, width, height, } = this; return [[x + width, y], [x + width, y + height]]; } bottomxys() { const { x, y, width, height, } = this; return [[x, y + height], [x + width, y + height]]; } leftxys() { const { x, y, height, } = this; return [[x, y], [x, y + height]]; } } function drawFontLine(type, tx, ty, align, valign, blheight, blwidth) { const floffset = { x: 0, y: 0 }; if (type === 'underline') { if (valign === 'bottom') { floffset.y = 0; } else if (valign === 'top') { floffset.y = -(blheight + 2); } else { floffset.y = -blheight / 2; } } else if (type === 'strike') { if (valign === 'bottom') { floffset.y = blheight / 2; } else if (valign === 'top') { floffset.y = -((blheight / 2) + 2); } } if (align === 'center') { floffset.x = blwidth / 2; } else if (align === 'right') { floffset.x = blwidth; } this.line( [tx - floffset.x, ty - floffset.y], [tx - floffset.x + blwidth, ty - floffset.y], ); } class Draw { constructor(el, width, height) { this.el = el; this.ctx = el.getContext('2d'); this.resize(width, height); this.ctx.scale(dpr(), dpr()); } resize(width, height) { // console.log('dpr:', dpr); this.el.style.width = `${width}px`; this.el.style.height = `${height}px`; this.el.width = npx(width); this.el.height = npx(height); } clear() { const { width, height } = this.el; this.ctx.clearRect(0, 0, width, height); return this; } attr(options) { Object.assign(this.ctx, options); return this; } save() { this.ctx.save(); this.ctx.beginPath(); return this; } restore() { this.ctx.restore(); return this; } beginPath() { this.ctx.beginPath(); return this; } translate(x, y) { this.ctx.translate(npx(x), npx(y)); return this; } scale(x, y) { this.ctx.scale(x, y); return this; } clearRect(x, y, w, h) { this.ctx.clearRect(x, y, w, h); return this; } fillRect(x, y, w, h) { this.ctx.fillRect(npx(x) - 0.5, npx(y) - 0.5, npx(w), npx(h)); return this; } fillText(text, x, y) { this.ctx.fillText(text, npx(x), npx(y)); return this; } /* txt: render text box: DrawBox attr: { align: left | center | right valign: top | middle | bottom color: '#333333', strike: false, font: { name: 'Arial', size: 14, bold: false, italic: false, } } textWrap: text wrapping */ text(mtxt, box, attr = {}, textWrap = true) { const { ctx } = this; const { align, valign, font, color, strike, underline, } = attr; const tx = box.textx(align); ctx.save(); ctx.beginPath(); this.attr({ textAlign: align, textBaseline: valign, font: `${font.italic ? 'italic' : ''} ${font.bold ? 'bold' : ''} ${npx(font.size)}px ${font.name}`, fillStyle: color, strokeStyle: color, }); const txts = `${mtxt}`.split('\n'); const biw = box.innerWidth(); const ntxts = []; txts.forEach((it) => { const txtWidth = ctx.measureText(it).width; if (textWrap && txtWidth > npx(biw)) { let textLine = { w: 0, len: 0, start: 0 }; for (let i = 0; i < it.length; i += 1) { if (textLine.w >= npx(biw)) { ntxts.push(it.substr(textLine.start, textLine.len)); textLine = { w: 0, len: 0, start: i }; } textLine.len += 1; textLine.w += ctx.measureText(it[i]).width + 1; } if (textLine.len > 0) { ntxts.push(it.substr(textLine.start, textLine.len)); } } else { ntxts.push(it); } }); const txtHeight = (ntxts.length - 1) * (font.size + 2); let ty = box.texty(valign, txtHeight); ntxts.forEach((txt) => { const txtWidth = ctx.measureText(txt).width; this.fillText(txt, tx, ty); if (strike) { drawFontLine.call(this, 'strike', tx, ty, align, valign, font.size, txtWidth); } if (underline) { drawFontLine.call(this, 'underline', tx, ty, align, valign, font.size, txtWidth); } ty += font.size + 2; }); ctx.restore(); return this; } border(style, color) { const { ctx } = this; ctx.lineWidth = thinLineWidth; ctx.strokeStyle = color; // console.log('style:', style); if (style === 'medium') { ctx.lineWidth = npx(2) - 0.5; } else if (style === 'thick') { ctx.lineWidth = npx(3); } else if (style === 'dashed') { ctx.setLineDash([npx(3), npx(2)]); } else if (style === 'dotted') { ctx.setLineDash([npx(1), npx(1)]); } else if (style === 'double') { ctx.setLineDash([npx(2), 0]); } return this; } line(...xys) { const { ctx } = this; if (xys.length > 1) { ctx.beginPath(); const [x, y] = xys[0]; ctx.moveTo(npxLine(x), npxLine(y)); for (let i = 1; i < xys.length; i += 1) { const [x1, y1] = xys[i]; ctx.lineTo(npxLine(x1), npxLine(y1)); } ctx.stroke(); } return this; } strokeBorders(box) { const { ctx } = this; ctx.save(); // border const { borderTop, borderRight, borderBottom, borderLeft, } = box; if (borderTop) { this.border(...borderTop); // console.log('box.topxys:', box.topxys()); this.line(...box.topxys()); } if (borderRight) { this.border(...borderRight); this.line(...box.rightxys()); } if (borderBottom) { this.border(...borderBottom); this.line(...box.bottomxys()); } if (borderLeft) { this.border(...borderLeft); this.line(...box.leftxys()); } ctx.restore(); } dropdown(box) { const { ctx } = this; const { x, y, width, height, } = box; const sx = x + width - 15; const sy = y + height - 15; ctx.save(); ctx.beginPath(); ctx.moveTo(npx(sx), npx(sy)); ctx.lineTo(npx(sx + 8), npx(sy)); ctx.lineTo(npx(sx + 4), npx(sy + 6)); ctx.closePath(); ctx.fillStyle = 'rgba(0, 0, 0, .45)'; ctx.fill(); ctx.restore(); } error(box) { const { ctx } = this; const { x, y, width } = box; const sx = x + width - 1; ctx.save(); ctx.beginPath(); ctx.moveTo(npx(sx - 8), npx(y - 1)); ctx.lineTo(npx(sx), npx(y - 1)); ctx.lineTo(npx(sx), npx(y + 8)); ctx.closePath(); ctx.fillStyle = 'rgba(255, 0, 0, .65)'; ctx.fill(); ctx.restore(); } frozen(box) { const { ctx } = this; const { x, y, width } = box; const sx = x + width - 1; ctx.save(); ctx.beginPath(); ctx.moveTo(npx(sx - 8), npx(y - 1)); ctx.lineTo(npx(sx), npx(y - 1)); ctx.lineTo(npx(sx), npx(y + 8)); ctx.closePath(); ctx.fillStyle = 'rgba(0, 255, 0, .85)'; ctx.fill(); ctx.restore(); } rect(box, dtextcb) { const { ctx } = this; const { x, y, width, height, bgcolor, } = box; ctx.save(); ctx.beginPath(); ctx.fillStyle = bgcolor || '#fff'; ctx.rect(npxLine(x + 1), npxLine(y + 1), npx(width - 2), npx(height - 2)); ctx.clip(); ctx.fill(); dtextcb(); ctx.restore(); } } export default {}; export { Draw, DrawBox, thinLineWidth, npx, }; ================================================ FILE: src/canvas/draw2.js ================================================ class Draw { constructor(el) { this.el = el; this.ctx = el.getContext('2d'); } clear() { const { width, height } = this.el; this.ctx.clearRect(0, 0, width, height); return this; } attr(m) { Object.assign(this.ctx, m); return this; } save() { this.ctx.save(); this.ctx.beginPath(); return this; } restore() { this.ctx.restore(); return this; } beginPath() { this.ctx.beginPath(); return this; } closePath() { this.ctx.closePath(); return this; } measureText(text) { return this.ctx.measureText(text); } rect(x, y, width, height) { this.ctx.rect(x, y, width, height); return this; } scale(x, y) { this.ctx.scale(x, y); return this; } rotate(angle) { this.ctx.rotate(angle); return this; } translate(x, y) { this.ctx.translate(x, y); return this; } transform(a, b, c, d, e) { this.ctx.transform(a, b, c, d, e); return this; } fillRect(x, y, w, h) { this.ctx.fillRect(x, y, w, h); return this; } strokeRect(x, y, w, h) { this.ctx.strokeRect(x, y, w, h); return this; } fillText(text, x, y, maxWidth) { this.ctx.fillText(text, x, y, maxWidth); return this; } strokeText(text, x, y, maxWidth) { this.ctx.strokeText(text, x, y, maxWidth); return this; } } export default {}; export { Draw, }; ================================================ FILE: src/component/border_palette.js ================================================ import { h } from './element'; import Icon from './icon'; import DropdownColor from './dropdown_color'; import DropdownLineType from './dropdown_linetype'; import { cssPrefix } from '../config'; function buildTable(...trs) { return h('table', '').child( h('tbody', '').children(...trs), ); } function buildTd(iconName) { return h('td', '').child( h('div', `${cssPrefix}-border-palette-cell`).child( new Icon(`border-${iconName}`), ).on('click', () => { this.mode = iconName; const { mode, style, color } = this; this.change({ mode, style, color }); }), ); } export default class BorderPalette { constructor() { this.color = '#000'; this.style = 'thin'; this.mode = 'all'; this.change = () => {}; this.ddColor = new DropdownColor('line-color', this.color); this.ddColor.change = (color) => { this.color = color; }; this.ddType = new DropdownLineType(this.style); this.ddType.change = ([s]) => { this.style = s; }; this.el = h('div', `${cssPrefix}-border-palette`); const table = buildTable( h('tr', '').children( h('td', `${cssPrefix}-border-palette-left`).child( buildTable( h('tr', '').children( ...['all', 'inside', 'horizontal', 'vertical', 'outside'].map(it => buildTd.call(this, it)), ), h('tr', '').children( ...['left', 'top', 'right', 'bottom', 'none'].map(it => buildTd.call(this, it)), ), ), ), h('td', `${cssPrefix}-border-palette-right`).children( h('div', `${cssPrefix}-toolbar-btn`).child(this.ddColor.el), h('div', `${cssPrefix}-toolbar-btn`).child(this.ddType.el), ), ), ); this.el.child(table); } } ================================================ FILE: src/component/bottombar.js ================================================ import { h } from './element'; import { bindClickoutside, unbindClickoutside } from './event'; import { cssPrefix } from '../config'; import Icon from './icon'; import FormInput from './form_input'; import Dropdown from './dropdown'; // Record: temp not used // import { xtoast } from './message'; import { tf } from '../locale/locale'; class DropdownMore extends Dropdown { constructor(click) { const icon = new Icon('ellipsis'); super(icon, 'auto', false, 'top-left'); this.contentClick = click; } reset(items) { const eles = items.map((it, i) => h('div', `${cssPrefix}-item`) .css('width', '150px') .css('font-weight', 'normal') .on('click', () => { this.contentClick(i); this.hide(); }) .child(it)); this.setContentChildren(...eles); } setTitle() {} } const menuItems = [ { key: 'delete', title: tf('contextmenu.deleteSheet') }, ]; function buildMenuItem(item) { return h('div', `${cssPrefix}-item`) .child(item.title()) .on('click', () => { this.itemClick(item.key); this.hide(); }); } function buildMenu() { return menuItems.map(it => buildMenuItem.call(this, it)); } class ContextMenu { constructor() { this.el = h('div', `${cssPrefix}-contextmenu`) .css('width', '160px') .children(...buildMenu.call(this)) .hide(); this.itemClick = () => {}; } hide() { const { el } = this; el.hide(); unbindClickoutside(el); } setOffset(offset) { const { el } = this; el.offset(offset); el.show(); bindClickoutside(el); } } export default class Bottombar { constructor(addFunc = () => {}, swapFunc = () => {}, deleteFunc = () => {}, updateFunc = () => {}) { this.swapFunc = swapFunc; this.updateFunc = updateFunc; this.dataNames = []; this.activeEl = null; this.deleteEl = null; this.items = []; this.moreEl = new DropdownMore((i) => { this.clickSwap2(this.items[i]); }); this.contextMenu = new ContextMenu(); this.contextMenu.itemClick = deleteFunc; this.el = h('div', `${cssPrefix}-bottombar`).children( this.contextMenu.el, this.menuEl = h('ul', `${cssPrefix}-menu`).child( h('li', '').children( new Icon('add').on('click', () => { addFunc(); }), h('span', '').child(this.moreEl), ), ), ); } addItem(name, active, options) { this.dataNames.push(name); const item = h('li', active ? 'active' : '').child(name); item.on('click', () => { this.clickSwap2(item); }).on('contextmenu', (evt) => { if (options.mode === 'read') return; const { offsetLeft, offsetHeight } = evt.target; this.contextMenu.setOffset({ left: offsetLeft, bottom: offsetHeight + 1 }); this.deleteEl = item; }).on('dblclick', () => { if (options.mode === 'read') return; const v = item.html(); const input = new FormInput('auto', ''); input.val(v); input.input.on('blur', ({ target }) => { const { value } = target; const nindex = this.dataNames.findIndex(it => it === v); this.renameItem(nindex, value); /* this.dataNames.splice(nindex, 1, value); this.moreEl.reset(this.dataNames); item.html('').child(value); this.updateFunc(nindex, value); */ }); item.html('').child(input.el); input.focus(); }); if (active) { this.clickSwap(item); } this.items.push(item); this.menuEl.child(item); this.moreEl.reset(this.dataNames); } renameItem(index, value) { this.dataNames.splice(index, 1, value); this.moreEl.reset(this.dataNames); this.items[index].html('').child(value); this.updateFunc(index, value); } clear() { this.items.forEach((it) => { this.menuEl.removeChild(it.el); }); this.items = []; this.dataNames = []; this.moreEl.reset(this.dataNames); } deleteItem() { const { activeEl, deleteEl } = this; if (this.items.length > 1) { const index = this.items.findIndex(it => it === deleteEl); this.items.splice(index, 1); this.dataNames.splice(index, 1); this.menuEl.removeChild(deleteEl.el); this.moreEl.reset(this.dataNames); if (activeEl === deleteEl) { const [f] = this.items; this.activeEl = f; this.activeEl.toggle(); return [index, 0]; } return [index, -1]; } return [-1]; } clickSwap2(item) { const index = this.items.findIndex(it => it === item); this.clickSwap(item); this.activeEl.toggle(); this.swapFunc(index); } clickSwap(item) { if (this.activeEl !== null) { this.activeEl.toggle(); } this.activeEl = item; } } ================================================ FILE: src/component/button.js ================================================ import { Element } from './element'; import { cssPrefix } from '../config'; import { t } from '../locale/locale'; export default class Button extends Element { // type: primary constructor(title, type = '') { super('div', `${cssPrefix}-button ${type}`); this.child(t(`button.${title}`)); } } ================================================ FILE: src/component/calendar.js ================================================ import { h } from './element'; import Icon from './icon'; import { t } from '../locale/locale'; function addMonth(date, step) { date.setMonth(date.getMonth() + step); } function weekday(date, index) { const d = new Date(date); d.setDate(index - date.getDay() + 1); return d; } function monthDays(year, month, cdate) { // the first day of month const startDate = new Date(year, month, 1, 23, 59, 59); const datess = [[], [], [], [], [], []]; for (let i = 0; i < 6; i += 1) { for (let j = 0; j < 7; j += 1) { const index = i * 7 + j; const d = weekday(startDate, index); const disabled = d.getMonth() !== month; // console.log('d:', d, ', cdate:', cdate); const active = d.getMonth() === cdate.getMonth() && d.getDate() === cdate.getDate(); datess[i][j] = { d, disabled, active }; } } return datess; } export default class Calendar { constructor(value) { this.value = value; this.cvalue = new Date(value); this.headerLeftEl = h('div', 'calendar-header-left'); this.bodyEl = h('tbody', ''); this.buildAll(); this.el = h('div', 'x-spreadsheet-calendar') .children( h('div', 'calendar-header').children( this.headerLeftEl, h('div', 'calendar-header-right').children( h('a', 'calendar-prev') .on('click.stop', () => this.prev()) .child(new Icon('chevron-left')), h('a', 'calendar-next') .on('click.stop', () => this.next()) .child(new Icon('chevron-right')), ), ), h('table', 'calendar-body').children( h('thead', '').child( h('tr', '').children( ...t('calendar.weeks').map(week => h('th', 'cell').child(week)), ), ), this.bodyEl, ), ); this.selectChange = () => {}; } setValue(value) { this.value = value; this.cvalue = new Date(value); this.buildAll(); } prev() { const { value } = this; addMonth(value, -1); this.buildAll(); } next() { const { value } = this; addMonth(value, 1); this.buildAll(); } buildAll() { this.buildHeaderLeft(); this.buildBody(); } buildHeaderLeft() { const { value } = this; this.headerLeftEl.html(`${t('calendar.months')[value.getMonth()]} ${value.getFullYear()}`); } buildBody() { const { value, cvalue, bodyEl } = this; const mDays = monthDays(value.getFullYear(), value.getMonth(), cvalue); const trs = mDays.map((it) => { const tds = it.map((it1) => { let cls = 'cell'; if (it1.disabled) cls += ' disabled'; if (it1.active) cls += ' active'; return h('td', '').child( h('div', cls) .on('click.stop', () => { this.selectChange(it1.d); }) .child(it1.d.getDate().toString()), ); }); return h('tr', '').children(...tds); }); bodyEl.html('').children(...trs); } } ================================================ FILE: src/component/color_palette.js ================================================ import { h } from './element'; import { cssPrefix } from '../config'; const themeColorPlaceHolders = ['#ffffff', '#000100', '#e7e5e6', '#445569', '#5b9cd6', '#ed7d31', '#a5a5a5', '#ffc001', '#4371c6', '#71ae47']; const themeColors = [ ['#f2f2f2', '#7f7f7f', '#d0cecf', '#d5dce4', '#deeaf6', '#fce5d5', '#ededed', '#fff2cd', '#d9e2f3', '#e3efd9'], ['#d8d8d8', '#595959', '#afabac', '#adb8ca', '#bdd7ee', '#f7ccac', '#dbdbdb', '#ffe59a', '#b3c6e7', '#c5e0b3'], ['#bfbfbf', '#3f3f3f', '#756f6f', '#8596b0', '#9cc2e6', '#f4b184', '#c9c9c9', '#fed964', '#8eaada', '#a7d08c'], ['#a5a5a5', '#262626', '#3a3839', '#333f4f', '#2e75b5', '#c45a10', '#7b7b7b', '#bf8e01', '#2f5596', '#538136'], ['#7f7f7f', '#0c0c0c', '#171516', '#222a35', '#1f4e7a', '#843c0a', '#525252', '#7e6000', '#203864', '#365624'], ]; const standardColors = ['#c00000', '#fe0000', '#fdc101', '#ffff01', '#93d051', '#00b04e', '#01b0f1', '#0170c1', '#012060', '#7030a0']; function buildTd(bgcolor) { return h('td', '').child( h('div', `${cssPrefix}-color-palette-cell`) .on('click.stop', () => this.change(bgcolor)) .css('background-color', bgcolor), ); } export default class ColorPalette { constructor() { this.el = h('div', `${cssPrefix}-color-palette`); this.change = () => {}; const table = h('table', '').children( h('tbody', '').children( h('tr', `${cssPrefix}-theme-color-placeholders`).children( ...themeColorPlaceHolders.map(color => buildTd.call(this, color)), ), ...themeColors.map(it => h('tr', `${cssPrefix}-theme-colors`).children( ...it.map(color => buildTd.call(this, color)), )), h('tr', `${cssPrefix}-standard-colors`).children( ...standardColors.map(color => buildTd.call(this, color)), ), ), ); this.el.child(table); } } ================================================ FILE: src/component/contextmenu.js ================================================ import { h } from './element'; import { bindClickoutside, unbindClickoutside } from './event'; import { cssPrefix } from '../config'; import { tf } from '../locale/locale'; const menuItems = [ { key: 'copy', title: tf('contextmenu.copy'), label: 'Ctrl+C' }, { key: 'cut', title: tf('contextmenu.cut'), label: 'Ctrl+X' }, { key: 'paste', title: tf('contextmenu.paste'), label: 'Ctrl+V' }, { key: 'paste-value', title: tf('contextmenu.pasteValue'), label: 'Ctrl+Shift+V' }, { key: 'paste-format', title: tf('contextmenu.pasteFormat'), label: 'Ctrl+Alt+V' }, { key: 'divider' }, { key: 'insert-row', title: tf('contextmenu.insertRow') }, { key: 'insert-column', title: tf('contextmenu.insertColumn') }, { key: 'divider' }, { key: 'delete-row', title: tf('contextmenu.deleteRow') }, { key: 'delete-column', title: tf('contextmenu.deleteColumn') }, { key: 'delete-cell-text', title: tf('contextmenu.deleteCellText') }, { key: 'hide', title: tf('contextmenu.hide') }, { key: 'divider' }, { key: 'validation', title: tf('contextmenu.validation') }, { key: 'divider' }, { key: 'cell-printable', title: tf('contextmenu.cellprintable') }, { key: 'cell-non-printable', title: tf('contextmenu.cellnonprintable') }, { key: 'divider' }, { key: 'cell-editable', title: tf('contextmenu.celleditable') }, { key: 'cell-non-editable', title: tf('contextmenu.cellnoneditable') }, ]; function buildMenuItem(item) { if (item.key === 'divider') { return h('div', `${cssPrefix}-item divider`); } return h('div', `${cssPrefix}-item`) .on('click', () => { this.itemClick(item.key); this.hide(); }) .children( item.title(), h('div', 'label').child(item.label || ''), ); } function buildMenu() { return menuItems.map(it => buildMenuItem.call(this, it)); } export default class ContextMenu { constructor(viewFn, isHide = false) { this.menuItems = buildMenu.call(this); this.el = h('div', `${cssPrefix}-contextmenu`) .children(...this.menuItems) .hide(); this.viewFn = viewFn; this.itemClick = () => {}; this.isHide = isHide; this.setMode('range'); } // row-col: the whole rows or the whole cols // range: select range setMode(mode) { const hideEl = this.menuItems[12]; if (mode === 'row-col') { hideEl.show(); } else { hideEl.hide(); } } hide() { const { el } = this; el.hide(); unbindClickoutside(el); } setPosition(x, y) { if (this.isHide) return; const { el } = this; const { width } = el.show().offset(); const view = this.viewFn(); const vhf = view.height / 2; let left = x; if (view.width - x <= width) { left -= width; } el.css('left', `${left}px`); if (y > vhf) { el.css('bottom', `${view.height - y}px`) .css('max-height', `${y}px`) .css('top', 'auto'); } else { el.css('top', `${y}px`) .css('max-height', `${view.height - y}px`) .css('bottom', 'auto'); } bindClickoutside(el); } } ================================================ FILE: src/component/datepicker.js ================================================ import Calendar from './calendar'; import { h } from './element'; import { cssPrefix } from '../config'; export default class Datepicker { constructor() { this.calendar = new Calendar(new Date()); this.el = h('div', `${cssPrefix}-datepicker`).child( this.calendar.el, ).hide(); } setValue(date) { // console.log(':::::::', date, typeof date, date instanceof string); const { calendar } = this; if (typeof date === 'string') { // console.log(/^\d{4}-\d{1,2}-\d{1,2}$/.test(date)); if (/^\d{4}-\d{1,2}-\d{1,2}$/.test(date)) { calendar.setValue(new Date(date.replace(new RegExp('-', 'g'), '/'))); } } else if (date instanceof Date) { calendar.setValue(date); } return this; } change(cb) { this.calendar.selectChange = (d) => { cb(d); this.hide(); }; } show() { this.el.show(); } hide() { this.el.hide(); } } ================================================ FILE: src/component/dropdown.js ================================================ import { Element, h } from './element'; import { bindClickoutside, unbindClickoutside } from './event'; import { cssPrefix } from '../config'; export default class Dropdown extends Element { constructor(title, width, showArrow, placement, ...children) { super('div', `${cssPrefix}-dropdown ${placement}`); this.title = title; this.change = () => {}; this.headerClick = () => {}; if (typeof title === 'string') { this.title = h('div', `${cssPrefix}-dropdown-title`).child(title); } else if (showArrow) { this.title.addClass('arrow-left'); } this.contentEl = h('div', `${cssPrefix}-dropdown-content`) .css('width', width) .hide(); this.setContentChildren(...children); this.headerEl = h('div', `${cssPrefix}-dropdown-header`); this.headerEl.on('click', () => { if (this.contentEl.css('display') !== 'block') { this.show(); } else { this.hide(); } }).children( this.title, showArrow ? h('div', `${cssPrefix}-icon arrow-right`).child( h('div', `${cssPrefix}-icon-img arrow-down`), ) : '', ); this.children(this.headerEl, this.contentEl); } setContentChildren(...children) { this.contentEl.html(''); if (children.length > 0) { this.contentEl.children(...children); } } setTitle(title) { this.title.html(title); this.hide(); } show() { const { contentEl } = this; contentEl.show(); this.parent().active(); bindClickoutside(this.parent(), () => { this.hide(); }); } hide() { this.parent().active(false); this.contentEl.hide(); unbindClickoutside(this.parent()); } } ================================================ FILE: src/component/dropdown_align.js ================================================ import Dropdown from './dropdown'; import { h } from './element'; import Icon from './icon'; import { cssPrefix } from '../config'; function buildItemWithIcon(iconName) { return h('div', `${cssPrefix}-item`).child(new Icon(iconName)); } export default class DropdownAlign extends Dropdown { constructor(aligns, align) { const icon = new Icon(`align-${align}`); const naligns = aligns.map(it => buildItemWithIcon(`align-${it}`) .on('click', () => { this.setTitle(it); this.change(it); })); super(icon, 'auto', true, 'bottom-left', ...naligns); } setTitle(align) { this.title.setName(`align-${align}`); this.hide(); } } ================================================ FILE: src/component/dropdown_border.js ================================================ import Dropdown from './dropdown'; import Icon from './icon'; import BorderPalette from './border_palette'; export default class DropdownBorder extends Dropdown { constructor() { const icon = new Icon('border-all'); const borderPalette = new BorderPalette(); borderPalette.change = (v) => { this.change(v); this.hide(); }; super(icon, 'auto', false, 'bottom-left', borderPalette.el); } } ================================================ FILE: src/component/dropdown_color.js ================================================ import Dropdown from './dropdown'; import Icon from './icon'; import ColorPalette from './color_palette'; export default class DropdownColor extends Dropdown { constructor(iconName, color) { const icon = new Icon(iconName) .css('height', '16px') .css('border-bottom', `3px solid ${color}`); const colorPalette = new ColorPalette(); colorPalette.change = (v) => { this.setTitle(v); this.change(v); }; super(icon, 'auto', false, 'bottom-left', colorPalette.el); } setTitle(color) { this.title.css('border-color', color); this.hide(); } } ================================================ FILE: src/component/dropdown_font.js ================================================ import Dropdown from './dropdown'; import { h } from './element'; import { baseFonts } from '../core/font'; import { cssPrefix } from '../config'; export default class DropdownFont extends Dropdown { constructor() { const nfonts = baseFonts.map(it => h('div', `${cssPrefix}-item`) .on('click', () => { this.setTitle(it.title); this.change(it); }) .child(it.title)); super(baseFonts[0].title, '160px', true, 'bottom-left', ...nfonts); } } ================================================ FILE: src/component/dropdown_fontsize.js ================================================ import Dropdown from './dropdown'; import { h } from './element'; import { fontSizes } from '../core/font'; import { cssPrefix } from '../config'; export default class DropdownFontSize extends Dropdown { constructor() { const nfontSizes = fontSizes.map(it => h('div', `${cssPrefix}-item`) .on('click', () => { this.setTitle(`${it.pt}`); this.change(it); }) .child(`${it.pt}`)); super('10', '60px', true, 'bottom-left', ...nfontSizes); } } ================================================ FILE: src/component/dropdown_format.js ================================================ import Dropdown from './dropdown'; import { h } from './element'; import { baseFormats } from '../core/format'; import { cssPrefix } from '../config'; export default class DropdownFormat extends Dropdown { constructor() { let nformats = baseFormats.slice(0); nformats.splice(2, 0, { key: 'divider' }); nformats.splice(8, 0, { key: 'divider' }); nformats = nformats.map((it) => { const item = h('div', `${cssPrefix}-item`); if (it.key === 'divider') { item.addClass('divider'); } else { item.child(it.title()) .on('click', () => { this.setTitle(it.title()); this.change(it); }); if (it.label) item.child(h('div', 'label').html(it.label)); } return item; }); super('Normal', '220px', true, 'bottom-left', ...nformats); } setTitle(key) { for (let i = 0; i < baseFormats.length; i += 1) { if (baseFormats[i].key === key) { this.title.html(baseFormats[i].title()); } } this.hide(); } } ================================================ FILE: src/component/dropdown_formula.js ================================================ import Dropdown from './dropdown'; import Icon from './icon'; import { h } from './element'; import { baseFormulas } from '../core/formula'; import { cssPrefix } from '../config'; export default class DropdownFormula extends Dropdown { constructor() { const nformulas = baseFormulas.map(it => h('div', `${cssPrefix}-item`) .on('click', () => { this.hide(); this.change(it); }) .child(it.key)); super(new Icon('formula'), '180px', true, 'bottom-left', ...nformulas); } } ================================================ FILE: src/component/dropdown_linetype.js ================================================ import Dropdown from './dropdown'; import { h } from './element'; import Icon from './icon'; import { cssPrefix } from '../config'; const lineTypes = [ ['thin', ''], ['medium', ''], ['thick', ''], ['dashed', ''], ['dotted', ''], // ['double', ''], ]; export default class DropdownLineType extends Dropdown { constructor(type) { const icon = new Icon('line-type'); let beforei = 0; const lineTypeEls = lineTypes.map((it, iti) => h('div', `${cssPrefix}-item state ${type === it[0] ? 'checked' : ''}`) .on('click', () => { lineTypeEls[beforei].toggle('checked'); lineTypeEls[iti].toggle('checked'); beforei = iti; this.hide(); this.change(it); }) .child( h('div', `${cssPrefix}-line-type`).html(it[1]), )); super(icon, 'auto', false, 'bottom-left', ...lineTypeEls); } } ================================================ FILE: src/component/editor.js ================================================ //* global window */ import { h } from './element'; import Suggest from './suggest'; import Datepicker from './datepicker'; import { cssPrefix } from '../config'; // import { mouseMoveUp } from '../event'; function resetTextareaSize() { const { inputText } = this; if (!/^\s*$/.test(inputText)) { const { textlineEl, textEl, areaOffset, } = this; const txts = inputText.split('\n'); const maxTxtSize = Math.max(...txts.map(it => it.length)); const tlOffset = textlineEl.offset(); const fontWidth = tlOffset.width / inputText.length; const tlineWidth = (maxTxtSize + 1) * fontWidth + 5; const maxWidth = this.viewFn().width - areaOffset.left - fontWidth; let h1 = txts.length; if (tlineWidth > areaOffset.width) { let twidth = tlineWidth; if (tlineWidth > maxWidth) { twidth = maxWidth; h1 += parseInt(tlineWidth / maxWidth, 10); h1 += (tlineWidth % maxWidth) > 0 ? 1 : 0; } textEl.css('width', `${twidth}px`); } h1 *= this.rowHeight; if (h1 > areaOffset.height) { textEl.css('height', `${h1}px`); } } } function insertText({ target }, itxt) { const { value, selectionEnd } = target; const ntxt = `${value.slice(0, selectionEnd)}${itxt}${value.slice(selectionEnd)}`; target.value = ntxt; target.setSelectionRange(selectionEnd + 1, selectionEnd + 1); this.inputText = ntxt; this.textlineEl.html(ntxt); resetTextareaSize.call(this); } function keydownEventHandler(evt) { const { keyCode, altKey } = evt; if (keyCode !== 13 && keyCode !== 9) evt.stopPropagation(); if (keyCode === 13 && altKey) { insertText.call(this, evt, '\n'); evt.stopPropagation(); } if (keyCode === 13 && !altKey) evt.preventDefault(); } function inputEventHandler(evt) { const v = evt.target.value; // console.log(evt, 'v:', v); const { suggest, textlineEl, validator } = this; const { cell } = this; if (cell !== null) { if (('editable' in cell && cell.editable === true) || (cell.editable === undefined)) { this.inputText = v; if (validator) { if (validator.type === 'list') { suggest.search(v); } else { suggest.hide(); } } else { const start = v.lastIndexOf('='); if (start !== -1) { suggest.search(v.substring(start + 1)); } else { suggest.hide(); } } textlineEl.html(v); resetTextareaSize.call(this); this.change('input', v); } else { evt.target.value = cell.text || ''; } } else { this.inputText = v; if (validator) { if (validator.type === 'list') { suggest.search(v); } else { suggest.hide(); } } else { const start = v.lastIndexOf('='); if (start !== -1) { suggest.search(v.substring(start + 1)); } else { suggest.hide(); } } textlineEl.html(v); resetTextareaSize.call(this); this.change('input', v); } } function setTextareaRange(position) { const { el } = this.textEl; setTimeout(() => { el.focus(); el.setSelectionRange(position, position); }, 0); } function setText(text, position) { const { textEl, textlineEl } = this; // firefox bug textEl.el.blur(); textEl.val(text); textlineEl.html(text); setTextareaRange.call(this, position); } function suggestItemClick(it) { const { inputText, validator } = this; let position = 0; if (validator && validator.type === 'list') { this.inputText = it; position = this.inputText.length; } else { const start = inputText.lastIndexOf('='); const sit = inputText.substring(0, start + 1); let eit = inputText.substring(start + 1); if (eit.indexOf(')') !== -1) { eit = eit.substring(eit.indexOf(')')); } else { eit = ''; } this.inputText = `${sit + it.key}(`; // console.log('inputText:', this.inputText); position = this.inputText.length; this.inputText += `)${eit}`; } setText.call(this, this.inputText, position); } function resetSuggestItems() { this.suggest.setItems(this.formulas); } function dateFormat(d) { let month = d.getMonth() + 1; let date = d.getDate(); if (month < 10) month = `0${month}`; if (date < 10) date = `0${date}`; return `${d.getFullYear()}-${month}-${date}`; } export default class Editor { constructor(formulas, viewFn, rowHeight) { this.viewFn = viewFn; this.rowHeight = rowHeight; this.formulas = formulas; this.suggest = new Suggest(formulas, (it) => { suggestItemClick.call(this, it); }); this.datepicker = new Datepicker(); this.datepicker.change((d) => { // console.log('d:', d); this.setText(dateFormat(d)); this.clear(); }); this.areaEl = h('div', `${cssPrefix}-editor-area`) .children( this.textEl = h('textarea', '') .on('input', evt => inputEventHandler.call(this, evt)) .on('paste.stop', () => {}) .on('keydown', evt => keydownEventHandler.call(this, evt)), this.textlineEl = h('div', 'textline'), this.suggest.el, this.datepicker.el, ) .on('mousemove.stop', () => {}) .on('mousedown.stop', () => {}); this.el = h('div', `${cssPrefix}-editor`) .child(this.areaEl).hide(); this.suggest.bindInputEvents(this.textEl); this.areaOffset = null; this.freeze = { w: 0, h: 0 }; this.cell = null; this.inputText = ''; this.change = () => {}; } setFreezeLengths(width, height) { this.freeze.w = width; this.freeze.h = height; } clear() { // const { cell } = this; // const cellText = (cell && cell.text) || ''; if (this.inputText !== '') { this.change('finished', this.inputText); } this.cell = null; this.areaOffset = null; this.inputText = ''; this.el.hide(); this.textEl.val(''); this.textlineEl.html(''); resetSuggestItems.call(this); this.datepicker.hide(); } setOffset(offset, suggestPosition = 'top') { const { textEl, areaEl, suggest, freeze, el, } = this; if (offset) { this.areaOffset = offset; const { left, top, width, height, l, t, } = offset; // console.log('left:', left, ',top:', top, ', freeze:', freeze); const elOffset = { left: 0, top: 0 }; // top left if (freeze.w > l && freeze.h > t) { // } else if (freeze.w < l && freeze.h < t) { elOffset.left = freeze.w; elOffset.top = freeze.h; } else if (freeze.w > l) { elOffset.top = freeze.h; } else if (freeze.h > t) { elOffset.left = freeze.w; } el.offset(elOffset); areaEl.offset({ left: left - elOffset.left - 0.8, top: top - elOffset.top - 0.8 }); textEl.offset({ width: width - 9 + 0.8, height: height - 3 + 0.8 }); const sOffset = { left: 0 }; sOffset[suggestPosition] = height; suggest.setOffset(sOffset); suggest.hide(); } } setCell(cell, validator) { if (cell && cell.editable === false) return; // console.log('::', validator); const { el, datepicker, suggest } = this; el.show(); this.cell = cell; const text = (cell && cell.text) || ''; this.setText(text); this.validator = validator; if (validator) { const { type } = validator; if (type === 'date') { datepicker.show(); if (!/^\s*$/.test(text)) { datepicker.setValue(text); } } if (type === 'list') { suggest.setItems(validator.values()); suggest.search(''); } } } setText(text) { this.inputText = text; // console.log('text>>:', text); setText.call(this, text, text.length); resetTextareaSize.call(this); } } ================================================ FILE: src/component/element.js ================================================ /* global document */ /* global window */ class Element { constructor(tag, className = '') { if (typeof tag === 'string') { this.el = document.createElement(tag); this.el.className = className; } else { this.el = tag; } this.data = {}; } data(key, value) { if (value !== undefined) { this.data[key] = value; return this; } return this.data[key]; } on(eventNames, handler) { const [fen, ...oen] = eventNames.split('.'); let eventName = fen; if (eventName === 'mousewheel' && /Firefox/i.test(window.navigator.userAgent)) { eventName = 'DOMMouseScroll'; } this.el.addEventListener(eventName, (evt) => { handler(evt); for (let i = 0; i < oen.length; i += 1) { const k = oen[i]; if (k === 'left' && evt.button !== 0) { return; } if (k === 'right' && evt.button !== 2) { return; } if (k === 'stop') { evt.stopPropagation(); } } }); return this; } offset(value) { if (value !== undefined) { Object.keys(value).forEach((k) => { this.css(k, `${value[k]}px`); }); return this; } const { offsetTop, offsetLeft, offsetHeight, offsetWidth, } = this.el; return { top: offsetTop, left: offsetLeft, height: offsetHeight, width: offsetWidth, }; } scroll(v) { const { el } = this; if (v !== undefined) { if (v.left !== undefined) { el.scrollLeft = v.left; } if (v.top !== undefined) { el.scrollTop = v.top; } } return { left: el.scrollLeft, top: el.scrollTop }; } box() { return this.el.getBoundingClientRect(); } parent() { return new Element(this.el.parentNode); } children(...eles) { if (arguments.length === 0) { return this.el.childNodes; } eles.forEach(ele => this.child(ele)); return this; } removeChild(el) { this.el.removeChild(el); } /* first() { return this.el.firstChild; } last() { return this.el.lastChild; } remove(ele) { return this.el.removeChild(ele); } prepend(ele) { const { el } = this; if (el.children.length > 0) { el.insertBefore(ele, el.firstChild); } else { el.appendChild(ele); } return this; } prev() { return this.el.previousSibling; } next() { return this.el.nextSibling; } */ child(arg) { let ele = arg; if (typeof arg === 'string') { ele = document.createTextNode(arg); } else if (arg instanceof Element) { ele = arg.el; } this.el.appendChild(ele); return this; } contains(ele) { return this.el.contains(ele); } className(v) { if (v !== undefined) { this.el.className = v; return this; } return this.el.className; } addClass(name) { this.el.classList.add(name); return this; } hasClass(name) { return this.el.classList.contains(name); } removeClass(name) { this.el.classList.remove(name); return this; } toggle(cls = 'active') { return this.toggleClass(cls); } toggleClass(name) { return this.el.classList.toggle(name); } active(flag = true, cls = 'active') { if (flag) this.addClass(cls); else this.removeClass(cls); return this; } checked(flag = true) { this.active(flag, 'checked'); return this; } disabled(flag = true) { if (flag) this.addClass('disabled'); else this.removeClass('disabled'); return this; } // key, value // key // {k, v}... attr(key, value) { if (value !== undefined) { this.el.setAttribute(key, value); } else { if (typeof key === 'string') { return this.el.getAttribute(key); } Object.keys(key).forEach((k) => { this.el.setAttribute(k, key[k]); }); } return this; } removeAttr(key) { this.el.removeAttribute(key); return this; } html(content) { if (content !== undefined) { this.el.innerHTML = content; return this; } return this.el.innerHTML; } val(v) { if (v !== undefined) { this.el.value = v; return this; } return this.el.value; } focus() { this.el.focus(); } cssRemoveKeys(...keys) { keys.forEach(k => this.el.style.removeProperty(k)); return this; } // css( propertyName ) // css( propertyName, value ) // css( properties ) css(name, value) { if (value === undefined && typeof name !== 'string') { Object.keys(name).forEach((k) => { this.el.style[k] = name[k]; }); return this; } if (value !== undefined) { this.el.style[name] = value; return this; } return this.el.style[name]; } computedStyle() { return window.getComputedStyle(this.el, null); } show() { this.css('display', 'block'); return this; } hide() { this.css('display', 'none'); return this; } } const h = (tag, className = '') => new Element(tag, className); export { Element, h, }; ================================================ FILE: src/component/event.js ================================================ /* global window */ export function bind(target, name, fn) { target.addEventListener(name, fn); } export function unbind(target, name, fn) { target.removeEventListener(name, fn); } export function unbindClickoutside(el) { if (el.xclickoutside) { unbind(window.document.body, 'click', el.xclickoutside); delete el.xclickoutside; } } // the left mouse button: mousedown → mouseup → click // the right mouse button: mousedown → contenxtmenu → mouseup // the right mouse button in firefox(>65.0): mousedown → contenxtmenu → mouseup → click on window export function bindClickoutside(el, cb) { el.xclickoutside = (evt) => { // ignore double click // console.log('evt:', evt); if (evt.detail === 2 || el.contains(evt.target)) return; if (cb) cb(el); else { el.hide(); unbindClickoutside(el); } }; bind(window.document.body, 'click', el.xclickoutside); } export function mouseMoveUp(target, movefunc, upfunc) { bind(target, 'mousemove', movefunc); const t = target; t.xEvtUp = (evt) => { // console.log('mouseup>>>'); unbind(target, 'mousemove', movefunc); unbind(target, 'mouseup', target.xEvtUp); upfunc(evt); }; bind(target, 'mouseup', target.xEvtUp); } function calTouchDirection(spanx, spany, evt, cb) { let direction = ''; // console.log('spanx:', spanx, ', spany:', spany); if (Math.abs(spanx) > Math.abs(spany)) { // horizontal direction = spanx > 0 ? 'right' : 'left'; cb(direction, spanx, evt); } else { // vertical direction = spany > 0 ? 'down' : 'up'; cb(direction, spany, evt); } } // cb = (direction, distance) => {} export function bindTouch(target, { move, end }) { let startx = 0; let starty = 0; bind(target, 'touchstart', (evt) => { const { pageX, pageY } = evt.touches[0]; startx = pageX; starty = pageY; }); bind(target, 'touchmove', (evt) => { if (!move) return; const { pageX, pageY } = evt.changedTouches[0]; const spanx = pageX - startx; const spany = pageY - starty; if (Math.abs(spanx) > 10 || Math.abs(spany) > 10) { // console.log('spanx:', spanx, ', spany:', spany); calTouchDirection(spanx, spany, evt, move); startx = pageX; starty = pageY; } evt.preventDefault(); }); bind(target, 'touchend', (evt) => { if (!end) return; const { pageX, pageY } = evt.changedTouches[0]; const spanx = pageX - startx; const spany = pageY - starty; calTouchDirection(spanx, spany, evt, end); }); } // eventemiter export function createEventEmitter() { const listeners = new Map(); function on(eventName, callback) { const push = () => { const currentListener = listeners.get(eventName); return (Array.isArray(currentListener) && currentListener.push(callback)) || false; }; const create = () => listeners.set(eventName, [].concat(callback)); return (listeners.has(eventName) && push()) || create(); } function fire(eventName, args) { const exec = () => { const currentListener = listeners.get(eventName); for (const callback of currentListener) callback.call(null, ...args); }; return listeners.has(eventName) && exec(); } function removeListener(eventName, callback) { const remove = () => { const currentListener = listeners.get(eventName); const idx = currentListener.indexOf(callback); return (idx >= 0) && currentListener.splice(idx, 1) && listeners.get(eventName).length === 0 && listeners.delete(eventName); }; return listeners.has(eventName) && remove(); } function once(eventName, callback) { const execCalllback = (...args) => { callback.call(null, ...args); removeListener(eventName, execCalllback); }; return on(eventName, execCalllback); } function removeAllListeners() { listeners.clear(); } return { get current() { return listeners; }, on, once, fire, removeListener, removeAllListeners, }; } ================================================ FILE: src/component/form_field.js ================================================ import { h } from './element'; import { cssPrefix } from '../config'; import { t } from '../locale/locale'; const patterns = { number: /(^\d+$)|(^\d+(\.\d{0,4})?$)/, date: /^\d{4}-\d{1,2}-\d{1,2}$/, }; // rule: { required: false, type, pattern: // } export default class FormField { constructor(input, rule, label, labelWidth) { this.label = ''; this.rule = rule; if (label) { this.label = h('label', 'label').css('width', `${labelWidth}px`).html(label); } this.tip = h('div', 'tip').child('tip').hide(); this.input = input; this.input.vchange = () => this.validate(); this.el = h('div', `${cssPrefix}-form-field`) .children(this.label, input.el, this.tip); } isShow() { return this.el.css('display') !== 'none'; } show() { this.el.show(); } hide() { this.el.hide(); return this; } val(v) { return this.input.val(v); } hint(hint) { this.input.hint(hint); } validate() { const { input, rule, tip, el, } = this; const v = input.val(); if (rule.required) { if (/^\s*$/.test(v)) { tip.html(t('validation.required')); el.addClass('error'); return false; } } if (rule.type || rule.pattern) { const pattern = rule.pattern || patterns[rule.type]; if (!pattern.test(v)) { tip.html(t('validation.notMatch')); el.addClass('error'); return false; } } el.removeClass('error'); return true; } } ================================================ FILE: src/component/form_input.js ================================================ import { h } from './element'; import { cssPrefix } from '../config'; export default class FormInput { constructor(width, hint) { this.vchange = () => {}; this.el = h('div', `${cssPrefix}-form-input`); this.input = h('input', '').css('width', width) .on('input', evt => this.vchange(evt)) .attr('placeholder', hint); this.el.child(this.input); } focus() { setTimeout(() => { this.input.el.focus(); }, 10); } hint(v) { this.input.attr('placeholder', v); } val(v) { return this.input.val(v); } } ================================================ FILE: src/component/form_select.js ================================================ import { h } from './element'; import Suggest from './suggest'; import { cssPrefix } from '../config'; export default class FormSelect { constructor(key, items, width, getTitle = it => it, change = () => {}) { this.key = key; this.getTitle = getTitle; this.vchange = () => {}; this.el = h('div', `${cssPrefix}-form-select`); this.suggest = new Suggest(items.map(it => ({ key: it, title: this.getTitle(it) })), (it) => { this.itemClick(it.key); change(it.key); this.vchange(it.key); }, width, this.el); this.el.children( this.itemEl = h('div', 'input-text').html(this.getTitle(key)), this.suggest.el, ).on('click', () => this.show()); } show() { this.suggest.search(''); } itemClick(it) { this.key = it; this.itemEl.html(this.getTitle(it)); } val(v) { if (v !== undefined) { this.key = v; this.itemEl.html(this.getTitle(v)); return this; } return this.key; } } ================================================ FILE: src/component/icon.js ================================================ import { Element, h } from './element'; import { cssPrefix } from '../config'; export default class Icon extends Element { constructor(name) { super('div', `${cssPrefix}-icon`); this.iconNameEl = h('div', `${cssPrefix}-icon-img ${name}`); this.child(this.iconNameEl); } setName(name) { this.iconNameEl.className(`${cssPrefix}-icon-img ${name}`); } } ================================================ FILE: src/component/message.js ================================================ /* global document */ import { h } from './element'; import Icon from './icon'; import { cssPrefix } from '../config'; export function xtoast(title, content) { const el = h('div', `${cssPrefix}-toast`); const dimmer = h('div', `${cssPrefix}-dimmer active`); const remove = () => { document.body.removeChild(el.el); document.body.removeChild(dimmer.el); }; el.children( h('div', `${cssPrefix}-toast-header`).children( new Icon('close').on('click.stop', () => remove()), title, ), h('div', `${cssPrefix}-toast-content`).html(content), ); document.body.appendChild(el.el); document.body.appendChild(dimmer.el); // set offset const { width, height } = el.box(); const { clientHeight, clientWidth } = document.documentElement; el.offset({ left: (clientWidth - width) / 2, top: (clientHeight - height) / 3, }); } export default {}; ================================================ FILE: src/component/modal.js ================================================ /* global document */ /* global window */ import { h } from './element'; import Icon from './icon'; import { cssPrefix } from '../config'; import { bind, unbind } from './event'; export default class Modal { constructor(title, content, width = '600px') { this.title = title; this.el = h('div', `${cssPrefix}-modal`).css('width', width).children( h('div', `${cssPrefix}-modal-header`).children( new Icon('close').on('click.stop', () => this.hide()), this.title, ), h('div', `${cssPrefix}-modal-content`).children(...content), ).hide(); } show() { // dimmer this.dimmer = h('div', `${cssPrefix}-dimmer active`); document.body.appendChild(this.dimmer.el); const { width, height } = this.el.show().box(); const { clientHeight, clientWidth } = document.documentElement; this.el.offset({ left: (clientWidth - width) / 2, top: (clientHeight - height) / 3, }); window.xkeydownEsc = (evt) => { if (evt.keyCode === 27) { this.hide(); } }; bind(window, 'keydown', window.xkeydownEsc); } hide() { this.el.hide(); document.body.removeChild(this.dimmer.el); unbind(window, 'keydown', window.xkeydownEsc); delete window.xkeydownEsc; } } ================================================ FILE: src/component/modal_validation.js ================================================ import Modal from './modal'; import FormInput from './form_input'; import FormSelect from './form_select'; import FormField from './form_field'; import Button from './button'; import { t } from '../locale/locale'; import { h } from './element'; import { cssPrefix } from '../config'; const fieldLabelWidth = 100; export default class ModalValidation extends Modal { constructor() { const mf = new FormField( new FormSelect('cell', ['cell'], // cell|row|column '100%', it => t(`dataValidation.modeType.${it}`)), { required: true }, `${t('dataValidation.range')}:`, fieldLabelWidth, ); const rf = new FormField( new FormInput('120px', 'E3 or E3:F12'), { required: true, pattern: /^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/ }, ); const cf = new FormField( new FormSelect('list', ['list', 'number', 'date', 'phone', 'email'], '100%', it => t(`dataValidation.type.${it}`), it => this.criteriaSelected(it)), { required: true }, `${t('dataValidation.criteria')}:`, fieldLabelWidth, ); // operator const of = new FormField( new FormSelect('be', ['be', 'nbe', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte'], '160px', it => t(`dataValidation.operator.${it}`), it => this.criteriaOperatorSelected(it)), { required: true }, ).hide(); // min, max const minvf = new FormField( new FormInput('70px', '10'), { required: true }, ).hide(); const maxvf = new FormField( new FormInput('70px', '100'), { required: true, type: 'number' }, ).hide(); // value const svf = new FormField( new FormInput('120px', 'a,b,c'), { required: true }, ); const vf = new FormField( new FormInput('70px', '10'), { required: true, type: 'number' }, ).hide(); super(t('contextmenu.validation'), [ h('div', `${cssPrefix}-form-fields`).children( mf.el, rf.el, ), h('div', `${cssPrefix}-form-fields`).children( cf.el, of.el, minvf.el, maxvf.el, vf.el, svf.el, ), h('div', `${cssPrefix}-buttons`).children( new Button('cancel').on('click', () => this.btnClick('cancel')), new Button('remove').on('click', () => this.btnClick('remove')), new Button('save', 'primary').on('click', () => this.btnClick('save')), ), ]); this.mf = mf; this.rf = rf; this.cf = cf; this.of = of; this.minvf = minvf; this.maxvf = maxvf; this.vf = vf; this.svf = svf; this.change = () => {}; } showVf(it) { const hint = it === 'date' ? '2018-11-12' : '10'; const { vf } = this; vf.input.hint(hint); vf.show(); } criteriaSelected(it) { const { of, minvf, maxvf, vf, svf, } = this; if (it === 'date' || it === 'number') { of.show(); minvf.rule.type = it; maxvf.rule.type = it; if (it === 'date') { minvf.hint('2018-11-12'); maxvf.hint('2019-11-12'); } else { minvf.hint('10'); maxvf.hint('100'); } minvf.show(); maxvf.show(); vf.hide(); svf.hide(); } else { if (it === 'list') { svf.show(); } else { svf.hide(); } vf.hide(); of.hide(); minvf.hide(); maxvf.hide(); } } criteriaOperatorSelected(it) { if (!it) return; const { minvf, maxvf, vf, } = this; if (it === 'be' || it === 'nbe') { minvf.show(); maxvf.show(); vf.hide(); } else { const type = this.cf.val(); vf.rule.type = type; if (type === 'date') { vf.hint('2018-11-12'); } else { vf.hint('10'); } vf.show(); minvf.hide(); maxvf.hide(); } } btnClick(action) { if (action === 'cancel') { this.hide(); } else if (action === 'remove') { this.change('remove'); this.hide(); } else if (action === 'save') { // validate const attrs = ['mf', 'rf', 'cf', 'of', 'svf', 'vf', 'minvf', 'maxvf']; for (let i = 0; i < attrs.length; i += 1) { const field = this[attrs[i]]; // console.log('field:', field); if (field.isShow()) { // console.log('it:', it); if (!field.validate()) return; } } const mode = this.mf.val(); const ref = this.rf.val(); const type = this.cf.val(); const operator = this.of.val(); let value = this.svf.val(); if (type === 'number' || type === 'date') { if (operator === 'be' || operator === 'nbe') { value = [this.minvf.val(), this.maxvf.val()]; } else { value = this.vf.val(); } } // console.log(mode, ref, type, operator, value); this.change('save', mode, ref, { type, operator, required: false, value, }); this.hide(); } } // validation: { mode, ref, validator } setValue(v) { if (v) { const { mf, rf, cf, of, svf, vf, minvf, maxvf, } = this; const { mode, ref, validator, } = v; const { type, operator, value, } = validator || { type: 'list' }; mf.val(mode || 'cell'); rf.val(ref); cf.val(type); of.val(operator); if (Array.isArray(value)) { minvf.val(value[0]); maxvf.val(value[1]); } else { svf.val(value || ''); vf.val(value || ''); } this.criteriaSelected(type); this.criteriaOperatorSelected(operator); } this.show(); } } ================================================ FILE: src/component/print.js ================================================ /* global window document */ import { h } from './element'; import { cssPrefix } from '../config'; import Button from './button'; import { Draw } from '../canvas/draw'; import { renderCell } from './table'; import { t } from '../locale/locale'; // resolution: 72 => 595 x 842 // 150 => 1240 x 1754 // 200 => 1654 x 2339 // 300 => 2479 x 3508 // 96 * cm / 2.54 , 96 * cm / 2.54 const PAGER_SIZES = [ ['A3', 11.69, 16.54], ['A4', 8.27, 11.69], ['A5', 5.83, 8.27], ['B4', 9.84, 13.90], ['B5', 6.93, 9.84], ]; const PAGER_ORIENTATIONS = ['landscape', 'portrait']; function inches2px(inc) { return parseInt(96 * inc, 10); } function btnClick(type) { if (type === 'cancel') { this.el.hide(); } else { this.toPrint(); } } function pagerSizeChange(evt) { const { paper } = this; const { value } = evt.target; const ps = PAGER_SIZES[value]; paper.w = inches2px(ps[1]); paper.h = inches2px(ps[2]); // console.log('paper:', ps, paper); this.preview(); } function pagerOrientationChange(evt) { const { paper } = this; const { value } = evt.target; const v = PAGER_ORIENTATIONS[value]; paper.orientation = v; this.preview(); } export default class Print { constructor(data) { this.paper = { w: inches2px(PAGER_SIZES[0][1]), h: inches2px(PAGER_SIZES[0][2]), padding: 50, orientation: PAGER_ORIENTATIONS[0], get width() { return this.orientation === 'landscape' ? this.h : this.w; }, get height() { return this.orientation === 'landscape' ? this.w : this.h; }, }; this.data = data; this.el = h('div', `${cssPrefix}-print`) .children( h('div', `${cssPrefix}-print-bar`) .children( h('div', '-title').child('Print settings'), h('div', '-right').children( h('div', `${cssPrefix}-buttons`).children( new Button('cancel').on('click', btnClick.bind(this, 'cancel')), new Button('next', 'primary').on('click', btnClick.bind(this, 'next')), ), ), ), h('div', `${cssPrefix}-print-content`) .children( this.contentEl = h('div', '-content'), h('div', '-sider').child( h('form', '').children( h('fieldset', '').children( h('label', '').child(`${t('print.size')}`), h('select', '').children( ...PAGER_SIZES.map((it, index) => h('option', '').attr('value', index).child(`${it[0]} ( ${it[1]}''x${it[2]}'' )`)), ).on('change', pagerSizeChange.bind(this)), ), h('fieldset', '').children( h('label', '').child(`${t('print.orientation')}`), h('select', '').children( ...PAGER_ORIENTATIONS.map((it, index) => h('option', '').attr('value', index).child(`${t('print.orientations')[index]}`)), ).on('change', pagerOrientationChange.bind(this)), ), ), ), ), ).hide(); } resetData(data) { this.data = data; } preview() { const { data, paper } = this; const { width, height, padding } = paper; const iwidth = width - padding * 2; const iheight = height - padding * 2; const cr = data.contentRange(); const pages = parseInt(cr.h / iheight, 10) + 1; const scale = iwidth / cr.w; let left = padding; const top = padding; if (scale > 1) { left += (iwidth - cr.w) / 2; } let ri = 0; let yoffset = 0; this.contentEl.html(''); this.canvases = []; const mViewRange = { sri: 0, sci: 0, eri: 0, eci: 0, }; for (let i = 0; i < pages; i += 1) { let th = 0; let yo = 0; const wrap = h('div', `${cssPrefix}-canvas-card`); const canvas = h('canvas', `${cssPrefix}-canvas`); this.canvases.push(canvas.el); const draw = new Draw(canvas.el, width, height); // cell-content draw.save(); draw.translate(left, top); if (scale < 1) draw.scale(scale, scale); // console.log('ri:', ri, cr.eri, yoffset); for (; ri <= cr.eri; ri += 1) { const rh = data.rows.getHeight(ri); th += rh; if (th < iheight) { for (let ci = 0; ci <= cr.eci; ci += 1) { renderCell(draw, data, ri, ci, yoffset); mViewRange.eci = ci; } } else { yo = -(th - rh); break; } } mViewRange.eri = ri; draw.restore(); // merge-cell draw.save(); draw.translate(left, top); if (scale < 1) draw.scale(scale, scale); const yof = yoffset; data.eachMergesInView(mViewRange, ({ sri, sci }) => { renderCell(draw, data, sri, sci, yof); }); draw.restore(); mViewRange.sri = mViewRange.eri; mViewRange.sci = mViewRange.eci; yoffset += yo; this.contentEl.child(h('div', `${cssPrefix}-canvas-card-wraper`).child(wrap.child(canvas))); } this.el.show(); } toPrint() { this.el.hide(); const { paper } = this; const iframe = h('iframe', '').hide(); const { el } = iframe; window.document.body.appendChild(el); const { contentWindow } = el; const idoc = contentWindow.document; const style = document.createElement('style'); style.innerHTML = ` @page { size: ${paper.width}px ${paper.height}px; }; canvas { page-break-before: auto; page-break-after: always; image-rendering: pixelated; }; `; idoc.head.appendChild(style); this.canvases.forEach((it) => { const cn = it.cloneNode(false); const ctx = cn.getContext('2d'); // ctx.imageSmoothingEnabled = true; ctx.drawImage(it, 0, 0); idoc.body.appendChild(cn); }); contentWindow.print(); } } ================================================ FILE: src/component/resizer.js ================================================ /* global window */ import { h } from './element'; import { mouseMoveUp } from './event'; import { cssPrefix } from '../config'; export default class Resizer { constructor(vertical = false, minDistance) { this.moving = false; this.vertical = vertical; this.el = h('div', `${cssPrefix}-resizer ${vertical ? 'vertical' : 'horizontal'}`).children( this.unhideHoverEl = h('div', `${cssPrefix}-resizer-hover`) .on('dblclick.stop', evt => this.mousedblclickHandler(evt)) .css('position', 'absolute').hide(), this.hoverEl = h('div', `${cssPrefix}-resizer-hover`) .on('mousedown.stop', evt => this.mousedownHandler(evt)), this.lineEl = h('div', `${cssPrefix}-resizer-line`).hide(), ).hide(); // cell rect this.cRect = null; this.finishedFn = null; this.minDistance = minDistance; this.unhideFn = () => {}; } showUnhide(index) { this.unhideIndex = index; this.unhideHoverEl.show(); } hideUnhide() { this.unhideHoverEl.hide(); } // rect : {top, left, width, height} // line : {width, height} show(rect, line) { const { moving, vertical, hoverEl, lineEl, el, unhideHoverEl, } = this; if (moving) return; this.cRect = rect; const { left, top, width, height, } = rect; el.offset({ left: vertical ? left + width - 5 : left, top: vertical ? top : top + height - 5, }).show(); hoverEl.offset({ width: vertical ? 5 : width, height: vertical ? height : 5, }); lineEl.offset({ width: vertical ? 0 : line.width, height: vertical ? line.height : 0, }); unhideHoverEl.offset({ left: vertical ? 5 - width : left, top: vertical ? top : 5 - height, width: vertical ? 5 : width, height: vertical ? height : 5, }); } hide() { this.el.offset({ left: 0, top: 0, }).hide(); this.hideUnhide(); } mousedblclickHandler() { if (this.unhideIndex) this.unhideFn(this.unhideIndex); } mousedownHandler(evt) { let startEvt = evt; const { el, lineEl, cRect, vertical, minDistance, } = this; let distance = vertical ? cRect.width : cRect.height; // console.log('distance:', distance); lineEl.show(); mouseMoveUp(window, (e) => { this.moving = true; if (startEvt !== null && e.buttons === 1) { // console.log('top:', top, ', left:', top, ', cRect:', cRect); if (vertical) { distance += e.movementX; if (distance > minDistance) { el.css('left', `${cRect.left + distance}px`); } } else { distance += e.movementY; if (distance > minDistance) { el.css('top', `${cRect.top + distance}px`); } } startEvt = e; } }, () => { startEvt = null; lineEl.hide(); this.moving = false; this.hide(); if (this.finishedFn) { if (distance < minDistance) distance = minDistance; this.finishedFn(cRect, distance); } }); } } ================================================ FILE: src/component/scrollbar.js ================================================ import { h } from './element'; import { cssPrefix } from '../config'; export default class Scrollbar { constructor(vertical) { this.vertical = vertical; this.moveFn = null; this.el = h('div', `${cssPrefix}-scrollbar ${vertical ? 'vertical' : 'horizontal'}`) .child(this.contentEl = h('div', '')) .on('mousemove.stop', () => {}) .on('scroll.stop', (evt) => { const { scrollTop, scrollLeft } = evt.target; // console.log('scrollTop:', scrollTop); if (this.moveFn) { this.moveFn(this.vertical ? scrollTop : scrollLeft, evt); } // console.log('evt:::', evt); }); } move(v) { this.el.scroll(v); return this; } scroll() { return this.el.scroll(); } set(distance, contentDistance) { const d = distance - 1; // console.log('distance:', distance, ', contentDistance:', contentDistance); if (contentDistance > d) { const cssKey = this.vertical ? 'height' : 'width'; // console.log('d:', d); this.el.css(cssKey, `${d - 15}px`).show(); this.contentEl .css(this.vertical ? 'width' : 'height', '1px') .css(cssKey, `${contentDistance}px`); } else { this.el.hide(); } return this; } } ================================================ FILE: src/component/selector.js ================================================ import { h } from './element'; import { cssPrefix } from '../config'; import { CellRange } from '../core/cell_range'; const selectorHeightBorderWidth = 2 * 2 - 1; let startZIndex = 10; class SelectorElement { constructor(useHideInput = false, autoFocus = true) { this.useHideInput = useHideInput; this.autoFocus = autoFocus; this.inputChange = () => {}; this.cornerEl = h('div', `${cssPrefix}-selector-corner`); this.areaEl = h('div', `${cssPrefix}-selector-area`) .child(this.cornerEl).hide(); this.clipboardEl = h('div', `${cssPrefix}-selector-clipboard`).hide(); this.autofillEl = h('div', `${cssPrefix}-selector-autofill`).hide(); this.el = h('div', `${cssPrefix}-selector`) .css('z-index', `${startZIndex}`) .children(this.areaEl, this.clipboardEl, this.autofillEl) .hide(); if (useHideInput) { this.hideInput = h('input', '') .on('compositionend', (evt) => { this.inputChange(evt.target.value); }); this.el.child(this.hideInputDiv = h('div', 'hide-input').child(this.hideInput)); this.el.child(this.hideInputDiv = h('div', 'hide-input').child(this.hideInput)); } startZIndex += 1; } setOffset(v) { this.el.offset(v).show(); return this; } hide() { this.el.hide(); return this; } setAreaOffset(v) { const { left, top, width, height, } = v; const of = { width: width - selectorHeightBorderWidth + 0.8, height: height - selectorHeightBorderWidth + 0.8, left: left - 0.8, top: top - 0.8, }; this.areaEl.offset(of).show(); if (this.useHideInput) { this.hideInputDiv.offset(of); if (this.autoFocus) { this.hideInput.val('').focus(); } else { this.hideInput.val(''); } } } setClipboardOffset(v) { const { left, top, width, height, } = v; this.clipboardEl.offset({ left, top, width: width - 5, height: height - 5, }); } showAutofill(v) { const { left, top, width, height, } = v; this.autofillEl.offset({ width: width - selectorHeightBorderWidth, height: height - selectorHeightBorderWidth, left, top, }).show(); } hideAutofill() { this.autofillEl.hide(); } showClipboard() { this.clipboardEl.show(); } hideClipboard() { this.clipboardEl.hide(); } } function calBRAreaOffset(offset) { const { data } = this; const { left, top, width, height, scroll, l, t, } = offset; const ftwidth = data.freezeTotalWidth(); const ftheight = data.freezeTotalHeight(); let left0 = left - ftwidth; if (ftwidth > l) left0 -= scroll.x; let top0 = top - ftheight; if (ftheight > t) top0 -= scroll.y; return { left: left0, top: top0, width, height, }; } function calTAreaOffset(offset) { const { data } = this; const { left, width, height, l, t, scroll, } = offset; const ftwidth = data.freezeTotalWidth(); let left0 = left - ftwidth; if (ftwidth > l) left0 -= scroll.x; return { left: left0, top: t, width, height, }; } function calLAreaOffset(offset) { const { data } = this; const { top, width, height, l, t, scroll, } = offset; const ftheight = data.freezeTotalHeight(); let top0 = top - ftheight; // console.log('ftheight:', ftheight, ', t:', t); if (ftheight > t) top0 -= scroll.y; return { left: l, top: top0, width, height, }; } function setBRAreaOffset(offset) { const { br } = this; br.setAreaOffset(calBRAreaOffset.call(this, offset)); } function setTLAreaOffset(offset) { const { tl } = this; tl.setAreaOffset(offset); } function setTAreaOffset(offset) { const { t } = this; t.setAreaOffset(calTAreaOffset.call(this, offset)); } function setLAreaOffset(offset) { const { l } = this; l.setAreaOffset(calLAreaOffset.call(this, offset)); } function setLClipboardOffset(offset) { const { l } = this; l.setClipboardOffset(calLAreaOffset.call(this, offset)); } function setBRClipboardOffset(offset) { const { br } = this; br.setClipboardOffset(calBRAreaOffset.call(this, offset)); } function setTLClipboardOffset(offset) { const { tl } = this; tl.setClipboardOffset(offset); } function setTClipboardOffset(offset) { const { t } = this; t.setClipboardOffset(calTAreaOffset.call(this, offset)); } function setAllAreaOffset(offset) { setBRAreaOffset.call(this, offset); setTLAreaOffset.call(this, offset); setTAreaOffset.call(this, offset); setLAreaOffset.call(this, offset); } function setAllClipboardOffset(offset) { setBRClipboardOffset.call(this, offset); setTLClipboardOffset.call(this, offset); setTClipboardOffset.call(this, offset); setLClipboardOffset.call(this, offset); } export default class Selector { constructor(data) { const { autoFocus } = data.settings; this.inputChange = () => {}; this.data = data; this.br = new SelectorElement(true, autoFocus); this.t = new SelectorElement(); this.l = new SelectorElement(); this.tl = new SelectorElement(); this.br.inputChange = (v) => { this.inputChange(v); }; this.br.el.show(); this.offset = null; this.areaOffset = null; this.indexes = null; this.range = null; this.arange = null; this.el = h('div', `${cssPrefix}-selectors`) .children( this.tl.el, this.t.el, this.l.el, this.br.el, ).hide(); // for performance this.lastri = -1; this.lastci = -1; startZIndex += 1; } resetData(data) { this.data = data; this.range = data.selector.range; this.resetAreaOffset(); } hide() { this.el.hide(); } resetOffset() { const { data, tl, t, l, br, } = this; const freezeHeight = data.freezeTotalHeight(); const freezeWidth = data.freezeTotalWidth(); if (freezeHeight > 0 || freezeWidth > 0) { tl.setOffset({ width: freezeWidth, height: freezeHeight }); t.setOffset({ left: freezeWidth, height: freezeHeight }); l.setOffset({ top: freezeHeight, width: freezeWidth }); br.setOffset({ left: freezeWidth, top: freezeHeight }); } else { tl.hide(); t.hide(); l.hide(); br.setOffset({ left: 0, top: 0 }); } } resetAreaOffset() { // console.log('offset:', offset); const offset = this.data.getSelectedRect(); const coffset = this.data.getClipboardRect(); setAllAreaOffset.call(this, offset); setAllClipboardOffset.call(this, coffset); this.resetOffset(); } resetBRTAreaOffset() { const offset = this.data.getSelectedRect(); const coffset = this.data.getClipboardRect(); setBRAreaOffset.call(this, offset); setTAreaOffset.call(this, offset); setBRClipboardOffset.call(this, coffset); setTClipboardOffset.call(this, coffset); this.resetOffset(); } resetBRLAreaOffset() { const offset = this.data.getSelectedRect(); const coffset = this.data.getClipboardRect(); setBRAreaOffset.call(this, offset); setLAreaOffset.call(this, offset); setBRClipboardOffset.call(this, coffset); setLClipboardOffset.call(this, coffset); this.resetOffset(); } set(ri, ci, indexesUpdated = true) { const { data } = this; const cellRange = data.calSelectedRangeByStart(ri, ci); const { sri, sci } = cellRange; if (indexesUpdated) { let [cri, cci] = [ri, ci]; if (ri < 0) cri = 0; if (ci < 0) cci = 0; data.selector.setIndexes(cri, cci); this.indexes = [cri, cci]; } this.moveIndexes = [sri, sci]; // this.sIndexes = sIndexes; // this.eIndexes = eIndexes; this.range = cellRange; this.resetAreaOffset(); this.el.show(); } setEnd(ri, ci, moving = true) { const { data, lastri, lastci } = this; if (moving) { if (ri === lastri && ci === lastci) return; this.lastri = ri; this.lastci = ci; } this.range = data.calSelectedRangeByEnd(ri, ci); setAllAreaOffset.call(this, this.data.getSelectedRect()); } reset() { // console.log('::::', this.data); const { eri, eci } = this.data.selector.range; this.setEnd(eri, eci); } showAutofill(ri, ci) { if (ri === -1 && ci === -1) return; // console.log('ri:', ri, ', ci:', ci); // const [sri, sci] = this.sIndexes; // const [eri, eci] = this.eIndexes; const { sri, sci, eri, eci, } = this.range; const [nri, nci] = [ri, ci]; // const rn = eri - sri; // const cn = eci - sci; const srn = sri - ri; const scn = sci - ci; const ern = eri - ri; const ecn = eci - ci; if (scn > 0) { // left // console.log('left'); this.arange = new CellRange(sri, nci, eri, sci - 1); // this.saIndexes = [sri, nci]; // this.eaIndexes = [eri, sci - 1]; // data.calRangeIndexes2( } else if (srn > 0) { // top // console.log('top'); // nri = sri; this.arange = new CellRange(nri, sci, sri - 1, eci); // this.saIndexes = [nri, sci]; // this.eaIndexes = [sri - 1, eci]; } else if (ecn < 0) { // right // console.log('right'); // nci = eci; this.arange = new CellRange(sri, eci + 1, eri, nci); // this.saIndexes = [sri, eci + 1]; // this.eaIndexes = [eri, nci]; } else if (ern < 0) { // bottom // console.log('bottom'); // nri = eri; this.arange = new CellRange(eri + 1, sci, nri, eci); // this.saIndexes = [eri + 1, sci]; // this.eaIndexes = [nri, eci]; } else { // console.log('else:'); this.arange = null; // this.saIndexes = null; // this.eaIndexes = null; return; } if (this.arange !== null) { // console.log(this.saIndexes, ':', this.eaIndexes); const offset = this.data.getRect(this.arange); offset.width += 2; offset.height += 2; const { br, l, t, tl, } = this; br.showAutofill(calBRAreaOffset.call(this, offset)); l.showAutofill(calLAreaOffset.call(this, offset)); t.showAutofill(calTAreaOffset.call(this, offset)); tl.showAutofill(offset); } } hideAutofill() { ['br', 'l', 't', 'tl'].forEach((property) => { this[property].hideAutofill(); }); } showClipboard() { const coffset = this.data.getClipboardRect(); setAllClipboardOffset.call(this, coffset); ['br', 'l', 't', 'tl'].forEach((property) => { this[property].showClipboard(); }); } hideClipboard() { ['br', 'l', 't', 'tl'].forEach((property) => { this[property].hideClipboard(); }); } } ================================================ FILE: src/component/sheet.js ================================================ /* global window */ import { h } from './element'; import { bind, mouseMoveUp, bindTouch, createEventEmitter, } from './event'; import Resizer from './resizer'; import Scrollbar from './scrollbar'; import Selector from './selector'; import Editor from './editor'; import Print from './print'; import ContextMenu from './contextmenu'; import Table from './table'; import Toolbar from './toolbar/index'; import ModalValidation from './modal_validation'; import SortFilter from './sort_filter'; import { xtoast } from './message'; import { cssPrefix } from '../config'; import { formulas } from '../core/formula'; /** * @desc throttle fn * @param func function * @param wait Delay in milliseconds */ function throttle(func, wait) { let timeout; return (...arg) => { const that = this; const args = arg; if (!timeout) { timeout = setTimeout(() => { timeout = null; func.apply(that, args); }, wait); } }; } function scrollbarMove() { const { data, verticalScrollbar, horizontalScrollbar, } = this; const { l, t, left, top, width, height, } = data.getSelectedRect(); const tableOffset = this.getTableOffset(); // console.log(',l:', l, ', left:', left, ', tOffset.left:', tableOffset.width); if (Math.abs(left) + width > tableOffset.width) { horizontalScrollbar.move({ left: l + width - tableOffset.width }); } else { const fsw = data.freezeTotalWidth(); if (left < fsw) { horizontalScrollbar.move({ left: l - 1 - fsw }); } } // console.log('top:', top, ', height:', height, ', tof.height:', tableOffset.height); if (Math.abs(top) + height > tableOffset.height) { verticalScrollbar.move({ top: t + height - tableOffset.height - 1 }); } else { const fsh = data.freezeTotalHeight(); if (top < fsh) { verticalScrollbar.move({ top: t - 1 - fsh }); } } } function selectorSet(multiple, ri, ci, indexesUpdated = true, moving = false) { if (ri === -1 && ci === -1) return; const { table, selector, toolbar, data, contextMenu, } = this; const cell = data.getCell(ri, ci); if (multiple) { selector.setEnd(ri, ci, moving); this.trigger('cells-selected', cell, selector.range); } else { // trigger click event selector.set(ri, ci, indexesUpdated); this.trigger('cell-selected', cell, ri, ci); } contextMenu.setMode((ri === -1 || ci === -1) ? 'row-col' : 'range'); toolbar.reset(); table.render(); } // multiple: boolean // direction: left | right | up | down | row-first | row-last | col-first | col-last function selectorMove(multiple, direction) { const { selector, data, } = this; const { rows, cols } = data; let [ri, ci] = selector.indexes; const { eri, eci } = selector.range; if (multiple) { [ri, ci] = selector.moveIndexes; } // console.log('selector.move:', ri, ci); if (direction === 'left') { if (ci > 0) ci -= 1; } else if (direction === 'right') { if (eci !== ci) ci = eci; if (ci < cols.len - 1) ci += 1; } else if (direction === 'up') { if (ri > 0) ri -= 1; } else if (direction === 'down') { if (eri !== ri) ri = eri; if (ri < rows.len - 1) ri += 1; } else if (direction === 'row-first') { ci = 0; } else if (direction === 'row-last') { ci = cols.len - 1; } else if (direction === 'col-first') { ri = 0; } else if (direction === 'col-last') { ri = rows.len - 1; } if (multiple) { selector.moveIndexes = [ri, ci]; } selectorSet.call(this, multiple, ri, ci); scrollbarMove.call(this); } // private methods function overlayerMousemove(evt) { // console.log('x:', evt.offsetX, ', y:', evt.offsetY); if (evt.buttons !== 0) return; if (evt.target.className === `${cssPrefix}-resizer-hover`) return; const { offsetX, offsetY } = evt; const { rowResizer, colResizer, tableEl, data, } = this; const { rows, cols } = data; if (offsetX > cols.indexWidth && offsetY > rows.height) { rowResizer.hide(); colResizer.hide(); return; } const tRect = tableEl.box(); const cRect = data.getCellRectByXY(evt.offsetX, evt.offsetY); if (cRect.ri >= 0 && cRect.ci === -1) { cRect.width = cols.indexWidth; rowResizer.show(cRect, { width: tRect.width, }); if (rows.isHide(cRect.ri - 1)) { rowResizer.showUnhide(cRect.ri); } else { rowResizer.hideUnhide(); } } else { rowResizer.hide(); } if (cRect.ri === -1 && cRect.ci >= 0) { cRect.height = rows.height; colResizer.show(cRect, { height: tRect.height, }); if (cols.isHide(cRect.ci - 1)) { colResizer.showUnhide(cRect.ci); } else { colResizer.hideUnhide(); } } else { colResizer.hide(); } } // let scrollThreshold = 15; function overlayerMousescroll(evt) { // scrollThreshold -= 1; // if (scrollThreshold > 0) return; // scrollThreshold = 15; const { verticalScrollbar, horizontalScrollbar, data } = this; const { top } = verticalScrollbar.scroll(); const { left } = horizontalScrollbar.scroll(); // console.log('evt:::', evt.wheelDelta, evt.detail * 40); const { rows, cols } = data; // deltaY for vertical delta const { deltaY, deltaX } = evt; const loopValue = (ii, vFunc) => { let i = ii; let v = 0; do { v = vFunc(i); i += 1; } while (v <= 0); return v; }; // console.log('deltaX', deltaX, 'evt.detail', evt.detail); // if (evt.detail) deltaY = evt.detail * 40; const moveY = (vertical) => { if (vertical > 0) { // up const ri = data.scroll.ri + 1; if (ri < rows.len) { const rh = loopValue(ri, i => rows.getHeight(i)); verticalScrollbar.move({ top: top + rh - 1 }); } } else { // down const ri = data.scroll.ri - 1; if (ri >= 0) { const rh = loopValue(ri, i => rows.getHeight(i)); verticalScrollbar.move({ top: ri === 0 ? 0 : top - rh }); } } }; // deltaX for Mac horizontal scroll const moveX = (horizontal) => { if (horizontal > 0) { // left const ci = data.scroll.ci + 1; if (ci < cols.len) { const cw = loopValue(ci, i => cols.getWidth(i)); horizontalScrollbar.move({ left: left + cw - 1 }); } } else { // right const ci = data.scroll.ci - 1; if (ci >= 0) { const cw = loopValue(ci, i => cols.getWidth(i)); horizontalScrollbar.move({ left: ci === 0 ? 0 : left - cw }); } } }; const tempY = Math.abs(deltaY); const tempX = Math.abs(deltaX); const temp = Math.max(tempY, tempX); // console.log('event:', evt); // detail for windows/mac firefox vertical scroll if (/Firefox/i.test(window.navigator.userAgent)) throttle(moveY(evt.detail), 50); if (temp === tempX) throttle(moveX(deltaX), 50); if (temp === tempY) throttle(moveY(deltaY), 50); } function overlayerTouch(direction, distance) { const { verticalScrollbar, horizontalScrollbar } = this; const { top } = verticalScrollbar.scroll(); const { left } = horizontalScrollbar.scroll(); if (direction === 'left' || direction === 'right') { horizontalScrollbar.move({ left: left - distance }); } else if (direction === 'up' || direction === 'down') { verticalScrollbar.move({ top: top - distance }); } } function verticalScrollbarSet() { const { data, verticalScrollbar } = this; const { height } = this.getTableOffset(); const erth = data.exceptRowTotalHeight(0, -1); // console.log('erth:', erth); verticalScrollbar.set(height, data.rows.totalHeight() - erth); } function horizontalScrollbarSet() { const { data, horizontalScrollbar } = this; const { width } = this.getTableOffset(); if (data) { horizontalScrollbar.set(width, data.cols.totalWidth()); } } function sheetFreeze() { const { selector, data, editor, } = this; const [ri, ci] = data.freeze; if (ri > 0 || ci > 0) { const fwidth = data.freezeTotalWidth(); const fheight = data.freezeTotalHeight(); editor.setFreezeLengths(fwidth, fheight); } selector.resetAreaOffset(); } function sheetReset() { const { tableEl, overlayerEl, overlayerCEl, table, toolbar, selector, el, } = this; const tOffset = this.getTableOffset(); const vRect = this.getRect(); tableEl.attr(vRect); overlayerEl.offset(vRect); overlayerCEl.offset(tOffset); el.css('width', `${vRect.width}px`); verticalScrollbarSet.call(this); horizontalScrollbarSet.call(this); sheetFreeze.call(this); table.render(); toolbar.reset(); selector.reset(); } function clearClipboard() { const { data, selector } = this; data.clearClipboard(); selector.hideClipboard(); } function copy(evt) { const { data, selector } = this; if (data.settings.mode === 'read') return; data.copy(); data.copyToSystemClipboard(evt); selector.showClipboard(); } function cut() { const { data, selector } = this; if (data.settings.mode === 'read') return; data.cut(); selector.showClipboard(); } function paste(what, evt) { const { data } = this; if (data.settings.mode === 'read') return; if (data.clipboard.isClear()) { const resetSheet = () => sheetReset.call(this); const eventTrigger = (rows) => { this.trigger('pasted-clipboard', rows); }; // pastFromSystemClipboard is async operation, need to tell it how to reset sheet and trigger event after it finishes // pasting content from system clipboard data.pasteFromSystemClipboard(resetSheet, eventTrigger); } else if (data.paste(what, msg => xtoast('Tip', msg))) { sheetReset.call(this); } else if (evt) { const cdata = evt.clipboardData.getData('text/plain'); this.data.pasteFromText(cdata); sheetReset.call(this); } } function hideRowsOrCols() { this.data.hideRowsOrCols(); sheetReset.call(this); } function unhideRowsOrCols(type, index) { this.data.unhideRowsOrCols(type, index); sheetReset.call(this); } function autofilter() { const { data } = this; data.autofilter(); sheetReset.call(this); } function toolbarChangePaintformatPaste() { const { toolbar } = this; if (toolbar.paintformatActive()) { paste.call(this, 'format'); clearClipboard.call(this); toolbar.paintformatToggle(); } } function overlayerMousedown(evt) { // console.log(':::::overlayer.mousedown:', evt.detail, evt.button, evt.buttons, evt.shiftKey); // console.log('evt.target.className:', evt.target.className); const { selector, data, table, sortFilter, } = this; const { offsetX, offsetY } = evt; const isAutofillEl = evt.target.className === `${cssPrefix}-selector-corner`; const cellRect = data.getCellRectByXY(offsetX, offsetY); const { left, top, width, height, } = cellRect; let { ri, ci } = cellRect; // sort or filter const { autoFilter } = data; if (autoFilter.includes(ri, ci)) { if (left + width - 20 < offsetX && top + height - 20 < offsetY) { const items = autoFilter.items(ci, (r, c) => data.rows.getCell(r, c)); sortFilter.hide(); sortFilter.set(ci, items, autoFilter.getFilter(ci), autoFilter.getSort(ci)); sortFilter.setOffset({ left, top: top + height + 2 }); return; } } // console.log('ri:', ri, ', ci:', ci); if (!evt.shiftKey) { // console.log('selectorSetStart:::'); if (isAutofillEl) { selector.showAutofill(ri, ci); } else { selectorSet.call(this, false, ri, ci); } // mouse move up mouseMoveUp(window, (e) => { // console.log('mouseMoveUp::::'); ({ ri, ci } = data.getCellRectByXY(e.offsetX, e.offsetY)); if (isAutofillEl) { selector.showAutofill(ri, ci); } else if (e.buttons === 1 && !e.shiftKey) { selectorSet.call(this, true, ri, ci, true, true); } }, () => { if (isAutofillEl && selector.arange && data.settings.mode !== 'read') { if (data.autofill(selector.arange, 'all', msg => xtoast('Tip', msg))) { table.render(); } } selector.hideAutofill(); toolbarChangePaintformatPaste.call(this); }); } if (!isAutofillEl && evt.buttons === 1) { if (evt.shiftKey) { // console.log('shiftKey::::'); selectorSet.call(this, true, ri, ci); } } } function editorSetOffset() { const { editor, data } = this; const sOffset = data.getSelectedRect(); const tOffset = this.getTableOffset(); let sPosition = 'top'; // console.log('sOffset:', sOffset, ':', tOffset); if (sOffset.top > tOffset.height / 2) { sPosition = 'bottom'; } editor.setOffset(sOffset, sPosition); } function editorSet() { const { editor, data } = this; if (data.settings.mode === 'read') return; editorSetOffset.call(this); editor.setCell(data.getSelectedCell(), data.getSelectedValidator()); clearClipboard.call(this); } function verticalScrollbarMove(distance) { const { data, table, selector } = this; data.scrolly(distance, () => { selector.resetBRLAreaOffset(); editorSetOffset.call(this); table.render(); }); } function horizontalScrollbarMove(distance) { const { data, table, selector } = this; data.scrollx(distance, () => { selector.resetBRTAreaOffset(); editorSetOffset.call(this); table.render(); }); } function rowResizerFinished(cRect, distance) { const { ri } = cRect; const { table, selector, data } = this; const { sri, eri } = selector.range; if (ri >= sri && ri <= eri) { for (let row = sri; row <= eri; row += 1) { data.rows.setHeight(row, distance); } } else { data.rows.setHeight(ri, distance); } table.render(); selector.resetAreaOffset(); verticalScrollbarSet.call(this); editorSetOffset.call(this); } function colResizerFinished(cRect, distance) { const { ci } = cRect; const { table, selector, data } = this; const { sci, eci } = selector.range; if (ci >= sci && ci <= eci) { for (let col = sci; col <= eci; col += 1) { data.cols.setWidth(col, distance); } } else { data.cols.setWidth(ci, distance); } table.render(); selector.resetAreaOffset(); horizontalScrollbarSet.call(this); editorSetOffset.call(this); } function dataSetCellText(text, state = 'finished') { const { data, table } = this; // const [ri, ci] = selector.indexes; if (data.settings.mode === 'read') return; data.setSelectedCellText(text, state); const { ri, ci } = data.selector; if (state === 'finished') { table.render(); } else { this.trigger('cell-edited', text, ri, ci); } } function insertDeleteRowColumn(type) { const { data } = this; if (data.settings.mode === 'read') return; if (type === 'insert-row') { data.insert('row'); } else if (type === 'delete-row') { data.delete('row'); } else if (type === 'insert-column') { data.insert('column'); } else if (type === 'delete-column') { data.delete('column'); } else if (type === 'delete-cell') { data.deleteCell(); } else if (type === 'delete-cell-format') { data.deleteCell('format'); } else if (type === 'delete-cell-text') { data.deleteCell('text'); } else if (type === 'cell-printable') { data.setSelectedCellAttr('printable', true); } else if (type === 'cell-non-printable') { data.setSelectedCellAttr('printable', false); } else if (type === 'cell-editable') { data.setSelectedCellAttr('editable', true); } else if (type === 'cell-non-editable') { data.setSelectedCellAttr('editable', false); } clearClipboard.call(this); sheetReset.call(this); } function toolbarChange(type, value) { const { data } = this; if (type === 'undo') { this.undo(); } else if (type === 'redo') { this.redo(); } else if (type === 'print') { this.print.preview(); } else if (type === 'paintformat') { if (value === true) copy.call(this); else clearClipboard.call(this); } else if (type === 'clearformat') { insertDeleteRowColumn.call(this, 'delete-cell-format'); } else if (type === 'link') { // link } else if (type === 'chart') { // chart } else if (type === 'autofilter') { // filter autofilter.call(this); } else if (type === 'freeze') { if (value) { const { ri, ci } = data.selector; this.freeze(ri, ci); } else { this.freeze(0, 0); } } else { data.setSelectedCellAttr(type, value); if (type === 'formula' && !data.selector.multiple()) { editorSet.call(this); } sheetReset.call(this); } } function sortFilterChange(ci, order, operator, value) { // console.log('sort:', sortDesc, operator, value); this.data.setAutoFilter(ci, order, operator, value); sheetReset.call(this); } function sheetInitEvents() { const { selector, overlayerEl, rowResizer, colResizer, verticalScrollbar, horizontalScrollbar, editor, contextMenu, toolbar, modalValidation, sortFilter, } = this; // overlayer overlayerEl .on('mousemove', (evt) => { overlayerMousemove.call(this, evt); }) .on('mousedown', (evt) => { editor.clear(); contextMenu.hide(); // the left mouse button: mousedown → mouseup → click // the right mouse button: mousedown → contenxtmenu → mouseup if (evt.buttons === 2) { if (this.data.xyInSelectedRect(evt.offsetX, evt.offsetY)) { contextMenu.setPosition(evt.offsetX, evt.offsetY); } else { overlayerMousedown.call(this, evt); contextMenu.setPosition(evt.offsetX, evt.offsetY); } evt.stopPropagation(); } else if (evt.detail === 2) { editorSet.call(this); } else { overlayerMousedown.call(this, evt); } }) .on('mousewheel.stop', (evt) => { overlayerMousescroll.call(this, evt); }) .on('mouseout', (evt) => { const { offsetX, offsetY } = evt; if (offsetY <= 0) colResizer.hide(); if (offsetX <= 0) rowResizer.hide(); }); selector.inputChange = (v) => { dataSetCellText.call(this, v, 'input'); editorSet.call(this); }; // slide on mobile bindTouch(overlayerEl.el, { move: (direction, d) => { overlayerTouch.call(this, direction, d); }, }); // toolbar change toolbar.change = (type, value) => toolbarChange.call(this, type, value); // sort filter ok sortFilter.ok = (ci, order, o, v) => sortFilterChange.call(this, ci, order, o, v); // resizer finished callback rowResizer.finishedFn = (cRect, distance) => { rowResizerFinished.call(this, cRect, distance); }; colResizer.finishedFn = (cRect, distance) => { colResizerFinished.call(this, cRect, distance); }; // resizer unhide callback rowResizer.unhideFn = (index) => { unhideRowsOrCols.call(this, 'row', index); }; colResizer.unhideFn = (index) => { unhideRowsOrCols.call(this, 'col', index); }; // scrollbar move callback verticalScrollbar.moveFn = (distance, evt) => { verticalScrollbarMove.call(this, distance, evt); }; horizontalScrollbar.moveFn = (distance, evt) => { horizontalScrollbarMove.call(this, distance, evt); }; // editor editor.change = (state, itext) => { dataSetCellText.call(this, itext, state); }; // modal validation modalValidation.change = (action, ...args) => { if (action === 'save') { this.data.addValidation(...args); } else { this.data.removeValidation(); } }; // contextmenu contextMenu.itemClick = (type) => { // console.log('type:', type); if (type === 'validation') { modalValidation.setValue(this.data.getSelectedValidation()); } else if (type === 'copy') { copy.call(this); } else if (type === 'cut') { cut.call(this); } else if (type === 'paste') { paste.call(this, 'all'); } else if (type === 'paste-value') { paste.call(this, 'text'); } else if (type === 'paste-format') { paste.call(this, 'format'); } else if (type === 'hide') { hideRowsOrCols.call(this); } else { insertDeleteRowColumn.call(this, type); } }; bind(window, 'resize', () => { this.reload(); }); bind(window, 'click', (evt) => { this.focusing = overlayerEl.contains(evt.target); }); bind(window, 'paste', (evt) => { if (!this.focusing) return; paste.call(this, 'all', evt); evt.preventDefault(); }); bind(window, 'copy', (evt) => { if (!this.focusing) return; copy.call(this, evt); evt.preventDefault(); }); // for selector bind(window, 'keydown', (evt) => { if (!this.focusing) return; const keyCode = evt.keyCode || evt.which; const { key, ctrlKey, shiftKey, metaKey, } = evt; // console.log('keydown.evt: ', keyCode); if (ctrlKey || metaKey) { // const { sIndexes, eIndexes } = selector; // let what = 'all'; // if (shiftKey) what = 'text'; // if (altKey) what = 'format'; switch (keyCode) { case 90: // undo: ctrl + z this.undo(); evt.preventDefault(); break; case 89: // redo: ctrl + y this.redo(); evt.preventDefault(); break; case 67: // ctrl + c // => copy // copy.call(this); // evt.preventDefault(); break; case 88: // ctrl + x cut.call(this); evt.preventDefault(); break; case 85: // ctrl + u toolbar.trigger('underline'); evt.preventDefault(); break; case 86: // ctrl + v // => paste // evt.preventDefault(); break; case 37: // ctrl + left selectorMove.call(this, shiftKey, 'row-first'); evt.preventDefault(); break; case 38: // ctrl + up selectorMove.call(this, shiftKey, 'col-first'); evt.preventDefault(); break; case 39: // ctrl + right selectorMove.call(this, shiftKey, 'row-last'); evt.preventDefault(); break; case 40: // ctrl + down selectorMove.call(this, shiftKey, 'col-last'); evt.preventDefault(); break; case 32: // ctrl + space, all cells in col selectorSet.call(this, false, -1, this.data.selector.ci, false); evt.preventDefault(); break; case 66: // ctrl + B toolbar.trigger('bold'); break; case 73: // ctrl + I toolbar.trigger('italic'); break; default: break; } } else { // console.log('evt.keyCode:', evt.keyCode); switch (keyCode) { case 32: if (shiftKey) { // shift + space, all cells in row selectorSet.call(this, false, this.data.selector.ri, -1, false); } break; case 27: // esc contextMenu.hide(); clearClipboard.call(this); break; case 37: // left selectorMove.call(this, shiftKey, 'left'); evt.preventDefault(); break; case 38: // up selectorMove.call(this, shiftKey, 'up'); evt.preventDefault(); break; case 39: // right selectorMove.call(this, shiftKey, 'right'); evt.preventDefault(); break; case 40: // down selectorMove.call(this, shiftKey, 'down'); evt.preventDefault(); break; case 9: // tab editor.clear(); // shift + tab => move left // tab => move right selectorMove.call(this, false, shiftKey ? 'left' : 'right'); evt.preventDefault(); break; case 13: // enter editor.clear(); // shift + enter => move up // enter => move down selectorMove.call(this, false, shiftKey ? 'up' : 'down'); evt.preventDefault(); break; case 8: // backspace insertDeleteRowColumn.call(this, 'delete-cell-text'); evt.preventDefault(); break; default: break; } if (key === 'Delete') { insertDeleteRowColumn.call(this, 'delete-cell-text'); evt.preventDefault(); } else if ((keyCode >= 65 && keyCode <= 90) || (keyCode >= 48 && keyCode <= 57) || (keyCode >= 96 && keyCode <= 105) || evt.key === '=' ) { dataSetCellText.call(this, evt.key, 'input'); editorSet.call(this); } else if (keyCode === 113) { // F2 editorSet.call(this); } } }); } export default class Sheet { constructor(targetEl, data) { this.eventMap = createEventEmitter(); const { view, showToolbar, showContextmenu } = data.settings; this.el = h('div', `${cssPrefix}-sheet`); this.toolbar = new Toolbar(data, view.width, !showToolbar); this.print = new Print(data); targetEl.children(this.toolbar.el, this.el, this.print.el); this.data = data; // table this.tableEl = h('canvas', `${cssPrefix}-table`); // resizer this.rowResizer = new Resizer(false, data.rows.height); this.colResizer = new Resizer(true, data.cols.minWidth); // scrollbar this.verticalScrollbar = new Scrollbar(true); this.horizontalScrollbar = new Scrollbar(false); // editor this.editor = new Editor( formulas, () => this.getTableOffset(), data.rows.height, ); // data validation this.modalValidation = new ModalValidation(); // contextMenu this.contextMenu = new ContextMenu(() => this.getRect(), !showContextmenu); // selector this.selector = new Selector(data); this.overlayerCEl = h('div', `${cssPrefix}-overlayer-content`) .children( this.editor.el, this.selector.el, ); this.overlayerEl = h('div', `${cssPrefix}-overlayer`) .child(this.overlayerCEl); // sortFilter this.sortFilter = new SortFilter(); // root element this.el.children( this.tableEl, this.overlayerEl.el, this.rowResizer.el, this.colResizer.el, this.verticalScrollbar.el, this.horizontalScrollbar.el, this.contextMenu.el, this.modalValidation.el, this.sortFilter.el, ); // table this.table = new Table(this.tableEl.el, data); sheetInitEvents.call(this); sheetReset.call(this); // init selector [0, 0] selectorSet.call(this, false, 0, 0); } on(eventName, func) { this.eventMap.on(eventName, func); return this; } trigger(eventName, ...args) { const { eventMap } = this; eventMap.fire(eventName, args); } resetData(data) { // before this.editor.clear(); // after this.data = data; verticalScrollbarSet.call(this); horizontalScrollbarSet.call(this); this.toolbar.resetData(data); this.print.resetData(data); this.selector.resetData(data); this.table.resetData(data); } loadData(data) { this.data.setData(data); sheetReset.call(this); return this; } // freeze rows or cols freeze(ri, ci) { const { data } = this; data.setFreeze(ri, ci); sheetReset.call(this); return this; } undo() { this.data.undo(); sheetReset.call(this); } redo() { this.data.redo(); sheetReset.call(this); } reload() { sheetReset.call(this); return this; } getRect() { const { data } = this; return { width: data.viewWidth(), height: data.viewHeight() }; } getTableOffset() { const { rows, cols } = this.data; const { width, height } = this.getRect(); return { width: width - cols.indexWidth, height: height - rows.height, left: cols.indexWidth, top: rows.height, }; } } ================================================ FILE: src/component/sort_filter.js ================================================ import { h } from './element'; import Button from './button'; import { bindClickoutside, unbindClickoutside } from './event'; import { cssPrefix } from '../config'; import { t } from '../locale/locale'; function buildMenu(clsName) { return h('div', `${cssPrefix}-item ${clsName}`); } function buildSortItem(it) { return buildMenu('state').child(t(`sort.${it}`)) .on('click.stop', () => this.itemClick(it)); } function buildFilterBody(items) { const { filterbEl, filterValues } = this; filterbEl.html(''); const itemKeys = Object.keys(items); itemKeys.forEach((it, index) => { const cnt = items[it]; const active = filterValues.includes(it) ? 'checked' : ''; filterbEl.child(h('div', `${cssPrefix}-item state ${active}`) .on('click.stop', () => this.filterClick(index, it)) .children(it === '' ? t('filter.empty') : it, h('div', 'label').html(`(${cnt})`))); }); } function resetFilterHeader() { const { filterhEl, filterValues, values } = this; filterhEl.html(`${filterValues.length} / ${values.length}`); filterhEl.checked(filterValues.length === values.length); } export default class SortFilter { constructor() { this.filterbEl = h('div', `${cssPrefix}-body`); this.filterhEl = h('div', `${cssPrefix}-header state`).on('click.stop', () => this.filterClick(0, 'all')); this.el = h('div', `${cssPrefix}-sort-filter`).children( this.sortAscEl = buildSortItem.call(this, 'asc'), this.sortDescEl = buildSortItem.call(this, 'desc'), buildMenu('divider'), h('div', `${cssPrefix}-filter`).children( this.filterhEl, this.filterbEl, ), h('div', `${cssPrefix}-buttons`).children( new Button('cancel').on('click', () => this.btnClick('cancel')), new Button('ok', 'primary').on('click', () => this.btnClick('ok')), ), ).hide(); // this.setFilters(['test1', 'test2', 'text3']); this.ci = null; this.sortDesc = null; this.values = null; this.filterValues = []; } btnClick(it) { if (it === 'ok') { const { ci, sort, filterValues } = this; if (this.ok) { this.ok(ci, sort, 'in', filterValues); } } this.hide(); } itemClick(it) { // console.log('it:', it); this.sort = it; const { sortAscEl, sortDescEl } = this; sortAscEl.checked(it === 'asc'); sortDescEl.checked(it === 'desc'); } filterClick(index, it) { // console.log('index:', index, it); const { filterbEl, filterValues, values } = this; const children = filterbEl.children(); if (it === 'all') { if (children.length === filterValues.length) { this.filterValues = []; children.forEach(i => h(i).checked(false)); } else { this.filterValues = Array.from(values); children.forEach(i => h(i).checked(true)); } } else { const checked = h(children[index]).toggle('checked'); if (checked) { filterValues.push(it); } else { filterValues.splice(filterValues.findIndex(i => i === it), 1); } } resetFilterHeader.call(this); } // v: autoFilter // items: {value: cnt} // sort { ci, order } set(ci, items, filter, sort) { this.ci = ci; const { sortAscEl, sortDescEl } = this; if (sort !== null) { this.sort = sort.order; sortAscEl.checked(sort.asc()); sortDescEl.checked(sort.desc()); } else { this.sortDesc = null; sortAscEl.checked(false); sortDescEl.checked(false); } // this.setFilters(items, filter); this.values = Object.keys(items); this.filterValues = filter ? Array.from(filter.value) : Object.keys(items); buildFilterBody.call(this, items, filter); resetFilterHeader.call(this); } setOffset(v) { this.el.offset(v).show(); let tindex = 1; bindClickoutside(this.el, () => { if (tindex <= 0) { this.hide(); } tindex -= 1; }); } show() { this.el.show(); } hide() { this.el.hide(); unbindClickoutside(this.el); } } ================================================ FILE: src/component/suggest.js ================================================ import { h } from './element'; import { bindClickoutside, unbindClickoutside } from './event'; import { cssPrefix } from '../config'; function inputMovePrev(evt) { evt.preventDefault(); evt.stopPropagation(); const { filterItems } = this; if (filterItems.length <= 0) return; if (this.itemIndex >= 0) filterItems[this.itemIndex].toggle(); this.itemIndex -= 1; if (this.itemIndex < 0) { this.itemIndex = filterItems.length - 1; } filterItems[this.itemIndex].toggle(); } function inputMoveNext(evt) { evt.stopPropagation(); const { filterItems } = this; if (filterItems.length <= 0) return; if (this.itemIndex >= 0) filterItems[this.itemIndex].toggle(); this.itemIndex += 1; if (this.itemIndex > filterItems.length - 1) { this.itemIndex = 0; } filterItems[this.itemIndex].toggle(); } function inputEnter(evt) { evt.preventDefault(); const { filterItems } = this; if (filterItems.length <= 0) return; evt.stopPropagation(); if (this.itemIndex < 0) this.itemIndex = 0; filterItems[this.itemIndex].el.click(); this.hide(); } function inputKeydownHandler(evt) { const { keyCode } = evt; if (evt.ctrlKey) { evt.stopPropagation(); } switch (keyCode) { case 37: // left evt.stopPropagation(); break; case 38: // up inputMovePrev.call(this, evt); break; case 39: // right evt.stopPropagation(); break; case 40: // down inputMoveNext.call(this, evt); break; case 13: // enter inputEnter.call(this, evt); break; case 9: inputEnter.call(this, evt); break; default: evt.stopPropagation(); break; } } export default class Suggest { constructor(items, itemClick, width = '200px') { this.filterItems = []; this.items = items; this.el = h('div', `${cssPrefix}-suggest`).css('width', width).hide(); this.itemClick = itemClick; this.itemIndex = -1; } setOffset(v) { this.el.cssRemoveKeys('top', 'bottom') .offset(v); } hide() { const { el } = this; this.filterItems = []; this.itemIndex = -1; el.hide(); unbindClickoutside(this.el.parent()); } setItems(items) { this.items = items; // this.search(''); } search(word) { let { items } = this; if (!/^\s*$/.test(word)) { items = items.filter(it => (it.key || it).startsWith(word.toUpperCase())); } items = items.map((it) => { let { title } = it; if (title) { if (typeof title === 'function') { title = title(); } } else { title = it; } const item = h('div', `${cssPrefix}-item`) .child(title) .on('click.stop', () => { this.itemClick(it); this.hide(); }); if (it.label) { item.child(h('div', 'label').html(it.label)); } return item; }); this.filterItems = items; if (items.length <= 0) { return; } const { el } = this; // items[0].toggle(); el.html('').children(...items).show(); bindClickoutside(el.parent(), () => { this.hide(); }); } bindInputEvents(input) { input.on('keydown', evt => inputKeydownHandler.call(this, evt)); } } ================================================ FILE: src/component/table.js ================================================ import { stringAt } from '../core/alphabet'; import { getFontSizePxByPt } from '../core/font'; import _cell from '../core/cell'; import { formulam } from '../core/formula'; import { formatm } from '../core/format'; import { Draw, DrawBox, thinLineWidth, npx, } from '../canvas/draw'; // gobal var const cellPaddingWidth = 5; const tableFixedHeaderCleanStyle = { fillStyle: '#f4f5f8' }; const tableGridStyle = { fillStyle: '#fff', lineWidth: thinLineWidth, strokeStyle: '#e6e6e6', }; function tableFixedHeaderStyle() { return { textAlign: 'center', textBaseline: 'middle', font: `500 ${npx(12)}px Source Sans Pro`, fillStyle: '#585757', lineWidth: thinLineWidth(), strokeStyle: '#e6e6e6', }; } function getDrawBox(data, rindex, cindex, yoffset = 0) { const { left, top, width, height, } = data.cellRect(rindex, cindex); return new DrawBox(left, top + yoffset, width, height, cellPaddingWidth); } /* function renderCellBorders(bboxes, translateFunc) { const { draw } = this; if (bboxes) { const rset = new Set(); // console.log('bboxes:', bboxes); bboxes.forEach(({ ri, ci, box }) => { if (!rset.has(ri)) { rset.add(ri); translateFunc(ri); } draw.strokeBorders(box); }); } } */ export function renderCell(draw, data, rindex, cindex, yoffset = 0) { const { sortedRowMap, rows, cols } = data; if (rows.isHide(rindex) || cols.isHide(cindex)) return; let nrindex = rindex; if (sortedRowMap.has(rindex)) { nrindex = sortedRowMap.get(rindex); } const cell = data.getCell(nrindex, cindex); if (cell === null) return; let frozen = false; if ('editable' in cell && cell.editable === false) { frozen = true; } const style = data.getCellStyleOrDefault(nrindex, cindex); const dbox = getDrawBox(data, rindex, cindex, yoffset); dbox.bgcolor = style.bgcolor; if (style.border !== undefined) { dbox.setBorders(style.border); // bboxes.push({ ri: rindex, ci: cindex, box: dbox }); draw.strokeBorders(dbox); } draw.rect(dbox, () => { // render text let cellText = ''; if (!data.settings.evalPaused) { cellText = _cell.render(cell.text || '', formulam, (y, x) => (data.getCellTextOrDefault(x, y))); } else { cellText = cell.text || ''; } if (style.format) { // console.log(data.formatm, '>>', cell.format); cellText = formatm[style.format].render(cellText); } const font = Object.assign({}, style.font); font.size = getFontSizePxByPt(font.size); // console.log('style:', style); draw.text(cellText, dbox, { align: style.align, valign: style.valign, font, color: style.color, strike: style.strike, underline: style.underline, }, style.textwrap); // error const error = data.validations.getError(rindex, cindex); if (error) { // console.log('error:', rindex, cindex, error); draw.error(dbox); } if (frozen) { draw.frozen(dbox); } }); } function renderAutofilter(viewRange) { const { data, draw } = this; if (viewRange) { const { autoFilter } = data; if (!autoFilter.active()) return; const afRange = autoFilter.hrange(); if (viewRange.intersects(afRange)) { afRange.each((ri, ci) => { const dbox = getDrawBox(data, ri, ci); draw.dropdown(dbox); }); } } } function renderContent(viewRange, fw, fh, tx, ty) { const { draw, data } = this; draw.save(); draw.translate(fw, fh) .translate(tx, ty); const { exceptRowSet } = data; // const exceptRows = Array.from(exceptRowSet); const filteredTranslateFunc = (ri) => { const ret = exceptRowSet.has(ri); if (ret) { const height = data.rows.getHeight(ri); draw.translate(0, -height); } return !ret; }; const exceptRowTotalHeight = data.exceptRowTotalHeight(viewRange.sri, viewRange.eri); // 1 render cell draw.save(); draw.translate(0, -exceptRowTotalHeight); viewRange.each((ri, ci) => { renderCell(draw, data, ri, ci); }, ri => filteredTranslateFunc(ri)); draw.restore(); // 2 render mergeCell const rset = new Set(); draw.save(); draw.translate(0, -exceptRowTotalHeight); data.eachMergesInView(viewRange, ({ sri, sci, eri }) => { if (!exceptRowSet.has(sri)) { renderCell(draw, data, sri, sci); } else if (!rset.has(sri)) { rset.add(sri); const height = data.rows.sumHeight(sri, eri + 1); draw.translate(0, -height); } }); draw.restore(); // 3 render autofilter renderAutofilter.call(this, viewRange); draw.restore(); } function renderSelectedHeaderCell(x, y, w, h) { const { draw } = this; draw.save(); draw.attr({ fillStyle: 'rgba(75, 137, 255, 0.08)' }) .fillRect(x, y, w, h); draw.restore(); } // viewRange // type: all | left | top // w: the fixed width of header // h: the fixed height of header // tx: moving distance on x-axis // ty: moving distance on y-axis function renderFixedHeaders(type, viewRange, w, h, tx, ty) { const { draw, data } = this; const sumHeight = viewRange.h; // rows.sumHeight(viewRange.sri, viewRange.eri + 1); const sumWidth = viewRange.w; // cols.sumWidth(viewRange.sci, viewRange.eci + 1); const nty = ty + h; const ntx = tx + w; draw.save(); // draw rect background draw.attr(tableFixedHeaderCleanStyle); if (type === 'all' || type === 'left') draw.fillRect(0, nty, w, sumHeight); if (type === 'all' || type === 'top') draw.fillRect(ntx, 0, sumWidth, h); const { sri, sci, eri, eci, } = data.selector.range; // console.log(data.selectIndexes); // draw text // text font, align... draw.attr(tableFixedHeaderStyle()); // y-header-text if (type === 'all' || type === 'left') { data.rowEach(viewRange.sri, viewRange.eri, (i, y1, rowHeight) => { const y = nty + y1; const ii = i; draw.line([0, y], [w, y]); if (sri <= ii && ii < eri + 1) { renderSelectedHeaderCell.call(this, 0, y, w, rowHeight); } draw.fillText(ii + 1, w / 2, y + (rowHeight / 2)); if (i > 0 && data.rows.isHide(i - 1)) { draw.save(); draw.attr({ strokeStyle: '#c6c6c6' }); draw.line([5, y + 5], [w - 5, y + 5]); draw.restore(); } }); draw.line([0, sumHeight + nty], [w, sumHeight + nty]); draw.line([w, nty], [w, sumHeight + nty]); } // x-header-text if (type === 'all' || type === 'top') { data.colEach(viewRange.sci, viewRange.eci, (i, x1, colWidth) => { const x = ntx + x1; const ii = i; draw.line([x, 0], [x, h]); if (sci <= ii && ii < eci + 1) { renderSelectedHeaderCell.call(this, x, 0, colWidth, h); } draw.fillText(stringAt(ii), x + (colWidth / 2), h / 2); if (i > 0 && data.cols.isHide(i - 1)) { draw.save(); draw.attr({ strokeStyle: '#c6c6c6' }); draw.line([x + 5, 5], [x + 5, h - 5]); draw.restore(); } }); draw.line([sumWidth + ntx, 0], [sumWidth + ntx, h]); draw.line([0, h], [sumWidth + ntx, h]); } draw.restore(); } function renderFixedLeftTopCell(fw, fh) { const { draw } = this; draw.save(); // left-top-cell draw.attr({ fillStyle: '#f4f5f8' }) .fillRect(0, 0, fw, fh); draw.restore(); } function renderContentGrid({ sri, sci, eri, eci, w, h, }, fw, fh, tx, ty) { const { draw, data } = this; const { settings } = data; draw.save(); draw.attr(tableGridStyle) .translate(fw + tx, fh + ty); // const sumWidth = cols.sumWidth(sci, eci + 1); // const sumHeight = rows.sumHeight(sri, eri + 1); // console.log('sumWidth:', sumWidth); // draw.clearRect(0, 0, w, h); if (!settings.showGrid) { draw.restore(); return; } // console.log('rowStart:', rowStart, ', rowLen:', rowLen); data.rowEach(sri, eri, (i, y, ch) => { // console.log('y:', y); if (i !== sri) draw.line([0, y], [w, y]); if (i === eri) draw.line([0, y + ch], [w, y + ch]); }); data.colEach(sci, eci, (i, x, cw) => { if (i !== sci) draw.line([x, 0], [x, h]); if (i === eci) draw.line([x + cw, 0], [x + cw, h]); }); draw.restore(); } function renderFreezeHighlightLine(fw, fh, ftw, fth) { const { draw, data } = this; const twidth = data.viewWidth() - fw; const theight = data.viewHeight() - fh; draw.save() .translate(fw, fh) .attr({ strokeStyle: 'rgba(75, 137, 255, .6)' }); draw.line([0, fth], [twidth, fth]); draw.line([ftw, 0], [ftw, theight]); draw.restore(); } /** end */ class Table { constructor(el, data) { this.el = el; this.draw = new Draw(el, data.viewWidth(), data.viewHeight()); this.data = data; } resetData(data) { this.data = data; this.render(); } render() { // resize canvas const { data } = this; const { rows, cols } = data; // fixed width of header const fw = cols.indexWidth; // fixed height of header const fh = rows.height; this.draw.resize(data.viewWidth(), data.viewHeight()); this.clear(); const viewRange = data.viewRange(); // renderAll.call(this, viewRange, data.scroll); const tx = data.freezeTotalWidth(); const ty = data.freezeTotalHeight(); const { x, y } = data.scroll; // 1 renderContentGrid.call(this, viewRange, fw, fh, tx, ty); renderContent.call(this, viewRange, fw, fh, -x, -y); renderFixedHeaders.call(this, 'all', viewRange, fw, fh, tx, ty); renderFixedLeftTopCell.call(this, fw, fh); const [fri, fci] = data.freeze; if (fri > 0 || fci > 0) { // 2 if (fri > 0) { const vr = viewRange.clone(); vr.sri = 0; vr.eri = fri - 1; vr.h = ty; renderContentGrid.call(this, vr, fw, fh, tx, 0); renderContent.call(this, vr, fw, fh, -x, 0); renderFixedHeaders.call(this, 'top', vr, fw, fh, tx, 0); } // 3 if (fci > 0) { const vr = viewRange.clone(); vr.sci = 0; vr.eci = fci - 1; vr.w = tx; renderContentGrid.call(this, vr, fw, fh, 0, ty); renderFixedHeaders.call(this, 'left', vr, fw, fh, 0, ty); renderContent.call(this, vr, fw, fh, 0, -y); } // 4 const freezeViewRange = data.freezeViewRange(); renderContentGrid.call(this, freezeViewRange, fw, fh, 0, 0); renderFixedHeaders.call(this, 'all', freezeViewRange, fw, fh, 0, 0); renderContent.call(this, freezeViewRange, fw, fh, 0, 0); // 5 renderFreezeHighlightLine.call(this, fw, fh, tx, ty); } } clear() { this.draw.clear(); } } export default Table; ================================================ FILE: src/component/toolbar/align.js ================================================ import DropdownItem from './dropdown_item'; import DropdownAlign from '../dropdown_align'; export default class Align extends DropdownItem { constructor(value) { super('align', '', value); } dropdown() { const { value } = this; return new DropdownAlign(['left', 'center', 'right'], value); } } ================================================ FILE: src/component/toolbar/autofilter.js ================================================ import ToggleItem from './toggle_item'; export default class Autofilter extends ToggleItem { constructor() { super('autofilter'); } setState() {} } ================================================ FILE: src/component/toolbar/bold.js ================================================ import ToggleItem from './toggle_item'; export default class Bold extends ToggleItem { constructor() { super('font-bold', 'Ctrl+B'); } } ================================================ FILE: src/component/toolbar/border.js ================================================ import DropdownItem from './dropdown_item'; import DropdownBorder from '../dropdown_border'; export default class Border extends DropdownItem { constructor() { super('border'); } dropdown() { return new DropdownBorder(); } } ================================================ FILE: src/component/toolbar/clearformat.js ================================================ import IconItem from './icon_item'; export default class Clearformat extends IconItem { constructor() { super('clearformat'); } } ================================================ FILE: src/component/toolbar/dropdown_item.js ================================================ import Item from './item'; export default class DropdownItem extends Item { dropdown() {} getValue(v) { return v; } element() { const { tag } = this; this.dd = this.dropdown(); this.dd.change = it => this.change(tag, this.getValue(it)); return super.element().child( this.dd, ); } setState(v) { if (v) { this.value = v; this.dd.setTitle(v); } } } ================================================ FILE: src/component/toolbar/fill_color.js ================================================ import DropdownItem from './dropdown_item'; import DropdownColor from '../dropdown_color'; export default class FillColor extends DropdownItem { constructor(color) { super('bgcolor', undefined, color); } dropdown() { const { tag, value } = this; return new DropdownColor(tag, value); } } ================================================ FILE: src/component/toolbar/font.js ================================================ import DropdownItem from './dropdown_item'; import DropdownFont from '../dropdown_font'; export default class Font extends DropdownItem { constructor() { super('font-name'); } getValue(it) { return it.key; } dropdown() { return new DropdownFont(); } } ================================================ FILE: src/component/toolbar/font_size.js ================================================ import DropdownItem from './dropdown_item'; import DropdownFontsize from '../dropdown_fontsize'; export default class Format extends DropdownItem { constructor() { super('font-size'); } getValue(it) { return it.pt; } dropdown() { return new DropdownFontsize(); } } ================================================ FILE: src/component/toolbar/format.js ================================================ import DropdownItem from './dropdown_item'; import DropdownFormat from '../dropdown_format'; export default class Format extends DropdownItem { constructor() { super('format'); } getValue(it) { return it.key; } dropdown() { return new DropdownFormat(); } } ================================================ FILE: src/component/toolbar/formula.js ================================================ import DropdownItem from './dropdown_item'; import DropdownFormula from '../dropdown_formula'; export default class Format extends DropdownItem { constructor() { super('formula'); } getValue(it) { return it.key; } dropdown() { return new DropdownFormula(); } } ================================================ FILE: src/component/toolbar/freeze.js ================================================ import ToggleItem from './toggle_item'; export default class Freeze extends ToggleItem { constructor() { super('freeze'); } } ================================================ FILE: src/component/toolbar/icon_item.js ================================================ import Item from './item'; import Icon from '../icon'; export default class IconItem extends Item { element() { return super.element() .child(new Icon(this.tag)) .on('click', () => this.change(this.tag)); } setState(disabled) { this.el.disabled(disabled); } } ================================================ FILE: src/component/toolbar/index.js ================================================ /* global window */ import Align from './align'; import Valign from './valign'; import Autofilter from './autofilter'; import Bold from './bold'; import Italic from './italic'; import Strike from './strike'; import Underline from './underline'; import Border from './border'; import Clearformat from './clearformat'; import Paintformat from './paintformat'; import TextColor from './text_color'; import FillColor from './fill_color'; import FontSize from './font_size'; import Font from './font'; import Format from './format'; import Formula from './formula'; import Freeze from './freeze'; import Merge from './merge'; import Redo from './redo'; import Undo from './undo'; import Print from './print'; import Textwrap from './textwrap'; import More from './more'; import Item from './item'; import { h } from '../element'; import { cssPrefix } from '../../config'; import { bind } from '../event'; function buildDivider() { return h('div', `${cssPrefix}-toolbar-divider`); } function initBtns2() { this.btns2 = []; this.items.forEach((it) => { if (Array.isArray(it)) { it.forEach(({ el }) => { const rect = el.box(); const { marginLeft, marginRight } = el.computedStyle(); this.btns2.push([el, rect.width + parseInt(marginLeft, 10) + parseInt(marginRight, 10)]); }); } else { const rect = it.box(); const { marginLeft, marginRight } = it.computedStyle(); this.btns2.push([it, rect.width + parseInt(marginLeft, 10) + parseInt(marginRight, 10)]); } }); } function moreResize() { const { el, btns, moreEl, btns2, } = this; const { moreBtns, contentEl } = moreEl.dd; el.css('width', `${this.widthFn()}px`); const elBox = el.box(); let sumWidth = 160; let sumWidth2 = 12; const list1 = []; const list2 = []; btns2.forEach(([it, w], index) => { sumWidth += w; if (index === btns2.length - 1 || sumWidth < elBox.width) { list1.push(it); } else { sumWidth2 += w; list2.push(it); } }); btns.html('').children(...list1); moreBtns.html('').children(...list2); contentEl.css('width', `${sumWidth2}px`); if (list2.length > 0) { moreEl.show(); } else { moreEl.hide(); } } function genBtn(it) { const btn = new Item(); btn.el.on('click', () => { if (it.onClick) it.onClick(this.data.getData(), this.data); }); btn.tip = it.tip || ''; let { el } = it; if (it.icon) { el = h('img').attr('src', it.icon); } if (el) { const icon = h('div', `${cssPrefix}-icon`); icon.child(el); btn.el.child(icon); } return btn; } export default class Toolbar { constructor(data, widthFn, isHide = false) { this.data = data; this.change = () => {}; this.widthFn = widthFn; this.isHide = isHide; const style = data.defaultStyle(); this.items = [ [ this.undoEl = new Undo(), this.redoEl = new Redo(), new Print(), this.paintformatEl = new Paintformat(), this.clearformatEl = new Clearformat(), ], buildDivider(), [ this.formatEl = new Format(), ], buildDivider(), [ this.fontEl = new Font(), this.fontSizeEl = new FontSize(), ], buildDivider(), [ this.boldEl = new Bold(), this.italicEl = new Italic(), this.underlineEl = new Underline(), this.strikeEl = new Strike(), this.textColorEl = new TextColor(style.color), ], buildDivider(), [ this.fillColorEl = new FillColor(style.bgcolor), this.borderEl = new Border(), this.mergeEl = new Merge(), ], buildDivider(), [ this.alignEl = new Align(style.align), this.valignEl = new Valign(style.valign), this.textwrapEl = new Textwrap(), ], buildDivider(), [ this.freezeEl = new Freeze(), this.autofilterEl = new Autofilter(), this.formulaEl = new Formula(), ], ]; const { extendToolbar = {} } = data.settings; if (extendToolbar.left && extendToolbar.left.length > 0) { this.items.unshift(buildDivider()); const btns = extendToolbar.left.map(genBtn.bind(this)); this.items.unshift(btns); } if (extendToolbar.right && extendToolbar.right.length > 0) { this.items.push(buildDivider()); const btns = extendToolbar.right.map(genBtn.bind(this)); this.items.push(btns); } this.items.push([this.moreEl = new More()]); this.el = h('div', `${cssPrefix}-toolbar`); this.btns = h('div', `${cssPrefix}-toolbar-btns`); this.items.forEach((it) => { if (Array.isArray(it)) { it.forEach((i) => { this.btns.child(i.el); i.change = (...args) => { this.change(...args); }; }); } else { this.btns.child(it.el); } }); this.el.child(this.btns); if (isHide) { this.el.hide(); } else { this.reset(); setTimeout(() => { initBtns2.call(this); moreResize.call(this); }, 0); bind(window, 'resize', () => { moreResize.call(this); }); } } paintformatActive() { return this.paintformatEl.active(); } paintformatToggle() { this.paintformatEl.toggle(); } trigger(type) { this[`${type}El`].click(); } resetData(data) { this.data = data; this.reset(); } reset() { if (this.isHide) return; const { data } = this; const style = data.getSelectedCellStyle(); // console.log('canUndo:', data.canUndo()); this.undoEl.setState(!data.canUndo()); this.redoEl.setState(!data.canRedo()); this.mergeEl.setState(data.canUnmerge(), !data.selector.multiple()); this.autofilterEl.setState(!data.canAutofilter()); // this.mergeEl.disabled(); // console.log('selectedCell:', style, cell); const { font, format } = style; this.formatEl.setState(format); this.fontEl.setState(font.name); this.fontSizeEl.setState(font.size); this.boldEl.setState(font.bold); this.italicEl.setState(font.italic); this.underlineEl.setState(style.underline); this.strikeEl.setState(style.strike); this.textColorEl.setState(style.color); this.fillColorEl.setState(style.bgcolor); this.alignEl.setState(style.align); this.valignEl.setState(style.valign); this.textwrapEl.setState(style.textwrap); // console.log('freeze is Active:', data.freezeIsActive()); this.freezeEl.setState(data.freezeIsActive()); } } ================================================ FILE: src/component/toolbar/italic.js ================================================ import ToggleItem from './toggle_item'; export default class Italic extends ToggleItem { constructor() { super('font-italic', 'Ctrl+I'); } } ================================================ FILE: src/component/toolbar/item.js ================================================ import { cssPrefix } from '../../config'; import tooltip from '../tooltip'; import { h } from '../element'; import { t } from '../../locale/locale'; export default class Item { // tooltip // tag: the subclass type // shortcut: shortcut key constructor(tag, shortcut, value) { this.tip = ''; if (tag) this.tip = t(`toolbar.${tag.replace(/-[a-z]/g, c => c[1].toUpperCase())}`); if (shortcut) this.tip += ` (${shortcut})`; this.tag = tag; this.shortcut = shortcut; this.value = value; this.el = this.element(); this.change = () => {}; } element() { const { tip } = this; return h('div', `${cssPrefix}-toolbar-btn`) .on('mouseenter', (evt) => { if (this.tip) tooltip(this.tip, evt.target); }) .attr('data-tooltip', tip); } setState() {} } ================================================ FILE: src/component/toolbar/merge.js ================================================ import ToggleItem from './toggle_item'; export default class Merge extends ToggleItem { constructor() { super('merge'); } setState(active, disabled) { this.el.active(active).disabled(disabled); } } ================================================ FILE: src/component/toolbar/more.js ================================================ import Dropdown from '../dropdown'; import DropdownItem from './dropdown_item'; import { cssPrefix } from '../../config'; import { h } from '../element'; import Icon from '../icon'; class DropdownMore extends Dropdown { constructor() { const icon = new Icon('ellipsis'); const moreBtns = h('div', `${cssPrefix}-toolbar-more`); super(icon, 'auto', false, 'bottom-right', moreBtns); this.moreBtns = moreBtns; this.contentEl.css('max-width', '420px'); } } export default class More extends DropdownItem { constructor() { super('more'); this.el.hide(); } dropdown() { return new DropdownMore(); } show() { this.el.show(); } hide() { this.el.hide(); } } ================================================ FILE: src/component/toolbar/paintformat.js ================================================ import ToggleItem from './toggle_item'; export default class Paintformat extends ToggleItem { constructor() { super('paintformat'); } setState() {} } ================================================ FILE: src/component/toolbar/print.js ================================================ import IconItem from './icon_item'; export default class Print extends IconItem { constructor() { super('print', 'Ctrl+P'); } } ================================================ FILE: src/component/toolbar/redo.js ================================================ import IconItem from './icon_item'; export default class Redo extends IconItem { constructor() { super('redo', 'Ctrl+Y'); } } ================================================ FILE: src/component/toolbar/strike.js ================================================ import ToggleItem from './toggle_item'; export default class Strike extends ToggleItem { constructor() { super('strike', 'Ctrl+U'); } } ================================================ FILE: src/component/toolbar/text_color.js ================================================ import DropdownItem from './dropdown_item'; import DropdownColor from '../dropdown_color'; export default class TextColor extends DropdownItem { constructor(color) { super('color', undefined, color); } dropdown() { const { tag, value } = this; return new DropdownColor(tag, value); } } ================================================ FILE: src/component/toolbar/textwrap.js ================================================ import ToggleItem from './toggle_item'; export default class Textwrap extends ToggleItem { constructor() { super('textwrap'); } } ================================================ FILE: src/component/toolbar/toggle_item.js ================================================ import Item from './item'; import Icon from '../icon'; export default class ToggleItem extends Item { element() { const { tag } = this; return super.element() .child(new Icon(tag)) .on('click', () => this.click()); } click() { this.change(this.tag, this.toggle()); } setState(active) { this.el.active(active); } toggle() { return this.el.toggle(); } active() { return this.el.hasClass('active'); } } ================================================ FILE: src/component/toolbar/underline.js ================================================ import ToggleItem from './toggle_item'; export default class Underline extends ToggleItem { constructor() { super('underline', 'Ctrl+U'); } } ================================================ FILE: src/component/toolbar/undo.js ================================================ import IconItem from './icon_item'; export default class Undo extends IconItem { constructor() { super('undo', 'Ctrl+Z'); } } ================================================ FILE: src/component/toolbar/valign.js ================================================ import DropdownItem from './dropdown_item'; import DropdownAlign from '../dropdown_align'; export default class Valign extends DropdownItem { constructor(value) { super('valign', '', value); } dropdown() { const { value } = this; return new DropdownAlign(['top', 'middle', 'bottom'], value); } } ================================================ FILE: src/component/toolbar.js ================================================ /* global window */ import { h } from './element'; import { bind } from './event'; import tooltip from './tooltip'; import DropdownFont from './dropdown_font'; import DropdownFontSize from './dropdown_fontsize'; import DropdownFormat from './dropdown_format'; import DropdownFormula from './dropdown_formula'; import DropdownColor from './dropdown_color'; import DropdownAlign from './dropdown_align'; import DropdownBorder from './dropdown_border'; import Dropdown from './dropdown'; import Icon from './icon'; import { cssPrefix } from '../config'; import { t } from '../locale/locale'; function buildIcon(name) { return new Icon(name); } function buildButton(tooltipdata) { return h('div', `${cssPrefix}-toolbar-btn`) .on('mouseenter', (evt) => { tooltip(tooltipdata, evt.target); }) .attr('data-tooltip', tooltipdata); } function buildDivider() { return h('div', `${cssPrefix}-toolbar-divider`); } function buildButtonWithIcon(tooltipdata, iconName, change = () => {}) { return buildButton(tooltipdata) .child(buildIcon(iconName)) .on('click', () => change()); } function bindDropdownChange() { this.ddFormat.change = it => this.change('format', it.key); this.ddFont.change = it => this.change('font-name', it.key); this.ddFormula.change = it => this.change('formula', it.key); this.ddFontSize.change = it => this.change('font-size', it.pt); this.ddTextColor.change = it => this.change('color', it); this.ddFillColor.change = it => this.change('bgcolor', it); this.ddAlign.change = it => this.change('align', it); this.ddVAlign.change = it => this.change('valign', it); this.ddBorder.change = it => this.change('border', it); } function toggleChange(type) { let elName = type; const types = type.split('-'); if (types.length > 1) { types.forEach((it, i) => { if (i === 0) elName = it; else elName += it[0].toUpperCase() + it.substring(1); }); } const el = this[`${elName}El`]; el.toggle(); this.change(type, el.hasClass('active')); } class DropdownMore extends Dropdown { constructor() { const icon = new Icon('ellipsis'); const moreBtns = h('div', `${cssPrefix}-toolbar-more`); super(icon, 'auto', false, 'bottom-right', moreBtns); this.moreBtns = moreBtns; this.contentEl.css('max-width', '420px'); } } function initBtns2() { this.btns2 = this.btnChildren.map((it) => { const rect = it.box(); const { marginLeft, marginRight } = it.computedStyle(); return [it, rect.width + parseInt(marginLeft, 10) + parseInt(marginRight, 10)]; }); } function moreResize() { const { el, btns, moreEl, ddMore, btns2, } = this; const { moreBtns, contentEl } = ddMore; el.css('width', `${this.widthFn() - 60}px`); const elBox = el.box(); let sumWidth = 160; let sumWidth2 = 12; const list1 = []; const list2 = []; btns2.forEach(([it, w], index) => { sumWidth += w; if (index === btns2.length - 1 || sumWidth < elBox.width) { list1.push(it); } else { sumWidth2 += w; list2.push(it); } }); btns.html('').children(...list1); moreBtns.html('').children(...list2); contentEl.css('width', `${sumWidth2}px`); if (list2.length > 0) { moreEl.show(); } else { moreEl.hide(); } } export default class Toolbar { constructor(data, widthFn, isHide = false) { this.data = data; this.change = () => {}; this.widthFn = widthFn; const style = data.defaultStyle(); // console.log('data:', data); this.ddFormat = new DropdownFormat(); this.ddFont = new DropdownFont(); this.ddFormula = new DropdownFormula(); this.ddFontSize = new DropdownFontSize(); this.ddTextColor = new DropdownColor('text-color', style.color); this.ddFillColor = new DropdownColor('fill-color', style.bgcolor); this.ddAlign = new DropdownAlign(['left', 'center', 'right'], style.align); this.ddVAlign = new DropdownAlign(['top', 'middle', 'bottom'], style.valign); this.ddBorder = new DropdownBorder(); this.ddMore = new DropdownMore(); this.btnChildren = [ this.undoEl = buildButtonWithIcon(`${t('toolbar.undo')} (Ctrl+Z)`, 'undo', () => this.change('undo')), this.redoEl = buildButtonWithIcon(`${t('toolbar.undo')} (Ctrl+Y)`, 'redo', () => this.change('redo')), // this.printEl = buildButtonWithIcon('Print (Ctrl+P)', 'print', () => this.change('print')), this.paintformatEl = buildButtonWithIcon(`${t('toolbar.paintformat')}`, 'paintformat', () => toggleChange.call(this, 'paintformat')), this.clearformatEl = buildButtonWithIcon(`${t('toolbar.clearformat')}`, 'clearformat', () => this.change('clearformat')), buildDivider(), buildButton(`${t('toolbar.format')}`).child(this.ddFormat.el), buildDivider(), buildButton(`${t('toolbar.font')}`).child(this.ddFont.el), buildButton(`${t('toolbar.fontSize')}`).child(this.ddFontSize.el), buildDivider(), this.fontBoldEl = buildButtonWithIcon(`${t('toolbar.fontBold')} (Ctrl+B)`, 'bold', () => toggleChange.call(this, 'font-bold')), this.fontItalicEl = buildButtonWithIcon(`${t('toolbar.fontItalic')} (Ctrl+I)`, 'italic', () => toggleChange.call(this, 'font-italic')), this.underlineEl = buildButtonWithIcon(`${t('toolbar.underline')} (Ctrl+U)`, 'underline', () => toggleChange.call(this, 'underline')), this.strikeEl = buildButtonWithIcon(`${t('toolbar.strike')}`, 'strike', () => toggleChange.call(this, 'strike')), buildButton(`${t('toolbar.textColor')}`).child(this.ddTextColor.el), buildDivider(), buildButton(`${t('toolbar.fillColor')}`).child(this.ddFillColor.el), buildButton(`${t('toolbar.border')}`).child(this.ddBorder.el), this.mergeEl = buildButtonWithIcon(`${t('toolbar.merge')}`, 'merge', () => toggleChange.call(this, 'merge')), buildDivider(), buildButton(`${t('toolbar.align')}`).child(this.ddAlign.el), buildButton(`${t('toolbar.valign')}`).child(this.ddVAlign.el), this.textwrapEl = buildButtonWithIcon(`${t('toolbar.textwrap')}`, 'textwrap', () => toggleChange.call(this, 'textwrap')), buildDivider(), // this.linkEl = buildButtonWithIcon('Insert link', 'link'), // this.chartEl = buildButtonWithIcon('Insert chart', 'chart'), this.freezeEl = buildButtonWithIcon(`${t('toolbar.freeze')}`, 'freeze', () => toggleChange.call(this, 'freeze')), this.autofilterEl = buildButtonWithIcon(`${t('toolbar.autofilter')}`, 'autofilter', () => toggleChange.call(this, 'autofilter')), buildButton(`${t('toolbar.formula')}`).child(this.ddFormula.el), // buildDivider(), this.moreEl = buildButton(`${t('toolbar.more')}`).child(this.ddMore.el).hide(), ]; this.el = h('div', `${cssPrefix}-toolbar`); this.btns = h('div', `${cssPrefix}-toolbar-btns`).children(...this.btnChildren); this.el.child(this.btns); if (isHide) this.el.hide(); bindDropdownChange.call(this); this.reset(); setTimeout(() => { initBtns2.call(this); moreResize.call(this); }, 0); bind(window, 'resize', () => { moreResize.call(this); }); } paintformatActive() { return this.paintformatEl.hasClass('active'); } paintformatToggle() { this.paintformatEl.toggle(); } trigger(type) { toggleChange.call(this, type); } reset() { const { data } = this; const style = data.getSelectedCellStyle(); const cell = data.getSelectedCell(); // console.log('canUndo:', data.canUndo()); this.undoEl.disabled(!data.canUndo()); this.redoEl.disabled(!data.canRedo()); this.mergeEl.active(data.canUnmerge()) .disabled(!data.selector.multiple()); this.autofilterEl.active(!data.canAutofilter()); // this.mergeEl.disabled(); // console.log('selectedCell:', style, cell); const { font } = style; this.ddFont.setTitle(font.name); this.ddFontSize.setTitle(font.size); this.fontBoldEl.active(font.bold); this.fontItalicEl.active(font.italic); this.underlineEl.active(style.underline); this.strikeEl.active(style.strike); this.ddTextColor.setTitle(style.color); this.ddFillColor.setTitle(style.bgcolor); this.ddAlign.setTitle(style.align); this.ddVAlign.setTitle(style.valign); this.textwrapEl.active(style.textwrap); // console.log('freeze is Active:', data.freezeIsActive()); this.freezeEl.active(data.freezeIsActive()); if (cell) { if (cell.format) { this.ddFormat.setTitle(cell.format); } } } } ================================================ FILE: src/component/tooltip.js ================================================ /* global document */ import { h } from './element'; import { bind } from './event'; import { cssPrefix } from '../config'; export default function tooltip(html, target) { if (target.classList.contains('active')) { return; } const { left, top, width, height, } = target.getBoundingClientRect(); const el = h('div', `${cssPrefix}-tooltip`).html(html).show(); document.body.appendChild(el.el); const elBox = el.box(); // console.log('elBox:', elBox); el.css('left', `${left + (width / 2) - (elBox.width / 2)}px`) .css('top', `${top + height + 2}px`); bind(target, 'mouseleave', () => { if (document.body.contains(el.el)) { document.body.removeChild(el.el); } }); bind(target, 'click', () => { if (document.body.contains(el.el)) { document.body.removeChild(el.el); } }); } ================================================ FILE: src/config.js ================================================ /* global window */ export const cssPrefix = 'x-spreadsheet'; export const dpr = window.devicePixelRatio || 1; export default { cssPrefix, dpr, }; ================================================ FILE: src/core/_.prototypes.js ================================================ // font.js /** * @typedef {number} fontsizePX px for fontSize */ /** * @typedef {number} fontsizePT pt for fontSize */ /** * @typedef {object} BaseFont * @property {string} key inner key * @property {string} title title for display */ /** * @typedef {object} FontSize * @property {fontsizePT} pt * @property {fontsizePX} px */ // alphabet.js /** * @typedef {string} tagA1 A1 tag for XY-tag (0, 0) * @example "A1" */ /** * @typedef {[number, number]} tagXY * @example [0, 0] */ ================================================ FILE: src/core/alphabet.js ================================================ import './_.prototypes'; const alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; /** index number 2 letters * @example stringAt(26) ==> 'AA' * @date 2019-10-10 * @export * @param {number} index * @returns {string} */ export function stringAt(index) { let str = ''; let cindex = index; while (cindex >= alphabets.length) { cindex /= alphabets.length; cindex -= 1; str += alphabets[parseInt(cindex, 10) % alphabets.length]; } const last = index % alphabets.length; str += alphabets[last]; return str; } /** translate letter in A1-tag to number * @date 2019-10-10 * @export * @param {string} str "AA" in A1-tag "AA1" * @returns {number} */ export function indexAt(str) { let ret = 0; for(let i = 0; i !== str.length; ++i) ret = 26 * ret + str.charCodeAt(i) - 64; return ret - 1; } // B10 => x,y /** translate A1-tag to XY-tag * @date 2019-10-10 * @export * @param {tagA1} src * @returns {tagXY} */ export function expr2xy(src) { let x = ''; let y = ''; for (let i = 0; i < src.length; i += 1) { if (src.charAt(i) >= '0' && src.charAt(i) <= '9') { y += src.charAt(i); } else { x += src.charAt(i); } } return [indexAt(x), parseInt(y, 10) - 1]; } /** translate XY-tag to A1-tag * @example x,y => B10 * @date 2019-10-10 * @export * @param {number} x * @param {number} y * @returns {tagA1} */ export function xy2expr(x, y) { return `${stringAt(x)}${y + 1}`; } /** translate A1-tag src by (xn, yn) * @date 2019-10-10 * @export * @param {tagA1} src * @param {number} xn * @param {number} yn * @returns {tagA1} */ export function expr2expr(src, xn, yn, condition = () => true) { if (xn === 0 && yn === 0) return src; const [x, y] = expr2xy(src); if (!condition(x, y)) return src; return xy2expr(x + xn, y + yn); } export default { stringAt, indexAt, expr2xy, xy2expr, expr2expr, }; ================================================ FILE: src/core/auto_filter.js ================================================ import { CellRange } from './cell_range'; // operator: all|eq|neq|gt|gte|lt|lte|in|be // value: // in => [] // be => [min, max] class Filter { constructor(ci, operator, value) { this.ci = ci; this.operator = operator; this.value = value; } set(operator, value) { this.operator = operator; this.value = value; } includes(v) { const { operator, value } = this; if (operator === 'all') { return true; } if (operator === 'in') { return value.includes(v); } return false; } vlength() { const { operator, value } = this; if (operator === 'in') { return value.length; } return 0; } getData() { const { ci, operator, value } = this; return { ci, operator, value }; } } class Sort { constructor(ci, order) { this.ci = ci; this.order = order; } asc() { return this.order === 'asc'; } desc() { return this.order === 'desc'; } } export default class AutoFilter { constructor() { this.ref = null; this.filters = []; this.sort = null; } setData({ ref, filters, sort }) { if (ref != null) { this.ref = ref; this.filters = filters.map(it => new Filter(it.ci, it.operator, it.value)); if (sort) { this.sort = new Sort(sort.ci, sort.order); } } } getData() { if (this.active()) { const { ref, filters, sort } = this; return { ref, filters: filters.map(it => it.getData()), sort }; } return {}; } addFilter(ci, operator, value) { const filter = this.getFilter(ci); if (filter == null) { this.filters.push(new Filter(ci, operator, value)); } else { filter.set(operator, value); } } setSort(ci, order) { this.sort = order ? new Sort(ci, order) : null; } includes(ri, ci) { if (this.active()) { return this.hrange().includes(ri, ci); } return false; } getSort(ci) { const { sort } = this; if (sort && sort.ci === ci) { return sort; } return null; } getFilter(ci) { const { filters } = this; for (let i = 0; i < filters.length; i += 1) { if (filters[i].ci === ci) { return filters[i]; } } return null; } filteredRows(getCell) { // const ary = []; // let lastri = 0; const rset = new Set(); const fset = new Set(); if (this.active()) { const { sri, eri } = this.range(); const { filters } = this; for (let ri = sri + 1; ri <= eri; ri += 1) { for (let i = 0; i < filters.length; i += 1) { const filter = filters[i]; const cell = getCell(ri, filter.ci); const ctext = cell ? cell.text : ''; if (!filter.includes(ctext)) { rset.add(ri); break; } else { fset.add(ri); } } } } return { rset, fset }; } items(ci, getCell) { const m = {}; if (this.active()) { const { sri, eri } = this.range(); for (let ri = sri + 1; ri <= eri; ri += 1) { const cell = getCell(ri, ci); if (cell !== null && !/^\s*$/.test(cell.text)) { const key = cell.text; const cnt = (m[key] || 0) + 1; m[key] = cnt; } else { m[''] = (m[''] || 0) + 1; } } } return m; } range() { return CellRange.valueOf(this.ref); } hrange() { const r = this.range(); r.eri = r.sri; return r; } clear() { this.ref = null; this.filters = []; this.sort = null; } active() { return this.ref !== null; } } ================================================ FILE: src/core/cell.js ================================================ import { expr2xy, xy2expr } from './alphabet'; import { numberCalc } from './helper'; // Converting infix expression to a suffix expression // src: AVERAGE(SUM(A1,A2), B1) + 50 + B20 // return: [A1, A2], SUM[, B1],AVERAGE,50,+,B20,+ const infixExprToSuffixExpr = (src) => { const operatorStack = []; const stack = []; let subStrs = []; // SUM, A1, B2, 50 ... let fnArgType = 0; // 1 => , 2 => : let fnArgOperator = ''; let fnArgsLen = 1; // A1,A2,A3... let oldc = ''; for (let i = 0; i < src.length; i += 1) { const c = src.charAt(i); if (c !== ' ') { if (c >= 'a' && c <= 'z') { subStrs.push(c.toUpperCase()); } else if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c === '.') { subStrs.push(c); } else if (c === '"') { i += 1; while (src.charAt(i) !== '"') { subStrs.push(src.charAt(i)); i += 1; } stack.push(`"${subStrs.join('')}`); subStrs = []; } else if (c === '-' && /[+\-*/,(]/.test(oldc)) { subStrs.push(c); } else { // console.log('subStrs:', subStrs.join(''), stack); if (c !== '(' && subStrs.length > 0) { stack.push(subStrs.join('')); } if (c === ')') { let c1 = operatorStack.pop(); if (fnArgType === 2) { // fn argument range => A1:B5 try { const [ex, ey] = expr2xy(stack.pop()); const [sx, sy] = expr2xy(stack.pop()); // console.log('::', sx, sy, ex, ey); let rangelen = 0; for (let x = sx; x <= ex; x += 1) { for (let y = sy; y <= ey; y += 1) { stack.push(xy2expr(x, y)); rangelen += 1; } } stack.push([c1, rangelen]); } catch (e) { // console.log(e); } } else if (fnArgType === 1 || fnArgType === 3) { if (fnArgType === 3) stack.push(fnArgOperator); // fn argument => A1,A2,B5 stack.push([c1, fnArgsLen]); fnArgsLen = 1; } else { // console.log('c1:', c1, fnArgType, stack, operatorStack); while (c1 !== '(') { stack.push(c1); if (operatorStack.length <= 0) break; c1 = operatorStack.pop(); } } fnArgType = 0; } else if (c === '=' || c === '>' || c === '<') { const nc = src.charAt(i + 1); fnArgOperator = c; if (nc === '=' || nc === '-') { fnArgOperator += nc; i += 1; } fnArgType = 3; } else if (c === ':') { fnArgType = 2; } else if (c === ',') { if (fnArgType === 3) { stack.push(fnArgOperator); } fnArgType = 1; fnArgsLen += 1; } else if (c === '(' && subStrs.length > 0) { // function operatorStack.push(subStrs.join('')); } else { // priority: */ > +- // console.log('xxxx:', operatorStack, c, stack); if (operatorStack.length > 0 && (c === '+' || c === '-')) { let top = operatorStack[operatorStack.length - 1]; if (top !== '(') stack.push(operatorStack.pop()); if (top === '*' || top === '/') { while (operatorStack.length > 0) { top = operatorStack[operatorStack.length - 1]; if (top !== '(') stack.push(operatorStack.pop()); else break; } } } else if (operatorStack.length > 0) { const top = operatorStack[operatorStack.length - 1]; if (top === '*' || top === '/') stack.push(operatorStack.pop()); } operatorStack.push(c); } subStrs = []; } oldc = c; } } if (subStrs.length > 0) { stack.push(subStrs.join('')); } while (operatorStack.length > 0) { stack.push(operatorStack.pop()); } return stack; }; const evalSubExpr = (subExpr, cellRender) => { const [fl] = subExpr; let expr = subExpr; if (fl === '"') { return subExpr.substring(1); } let ret = 1; if (fl === '-') { expr = subExpr.substring(1); ret = -1; } if (expr[0] >= '0' && expr[0] <= '9') { return ret * Number(expr); } const [x, y] = expr2xy(expr); return ret * cellRender(x, y); }; // evaluate the suffix expression // srcStack: <= infixExprToSufixExpr // formulaMap: {'SUM': {}, ...} // cellRender: (x, y) => {} const evalSuffixExpr = (srcStack, formulaMap, cellRender, cellList) => { const stack = []; // console.log(':::::formulaMap:', formulaMap); for (let i = 0; i < srcStack.length; i += 1) { // console.log(':::>>>', srcStack[i]); const expr = srcStack[i]; const fc = expr[0]; if (expr === '+') { const top = stack.pop(); stack.push(numberCalc('+', stack.pop(), top)); } else if (expr === '-') { if (stack.length === 1) { const top = stack.pop(); stack.push(numberCalc('*', top, -1)); } else { const top = stack.pop(); stack.push(numberCalc('-', stack.pop(), top)); } } else if (expr === '*') { stack.push(numberCalc('*', stack.pop(), stack.pop())); } else if (expr === '/') { const top = stack.pop(); stack.push(numberCalc('/', stack.pop(), top)); } else if (fc === '=' || fc === '>' || fc === '<') { let top = stack.pop(); if (!Number.isNaN(top)) top = Number(top); let left = stack.pop(); if (!Number.isNaN(left)) left = Number(left); let ret = false; if (fc === '=') { ret = (left === top); } else if (expr === '>') { ret = (left > top); } else if (expr === '>=') { ret = (left >= top); } else if (expr === '<') { ret = (left < top); } else if (expr === '<=') { ret = (left <= top); } stack.push(ret); } else if (Array.isArray(expr)) { const [formula, len] = expr; const params = []; for (let j = 0; j < len; j += 1) { params.push(stack.pop()); } stack.push(formulaMap[formula].render(params.reverse())); } else { if (cellList.includes(expr)) { return 0; } if ((fc >= 'a' && fc <= 'z') || (fc >= 'A' && fc <= 'Z')) { cellList.push(expr); } stack.push(evalSubExpr(expr, cellRender)); cellList.pop(); } // console.log('stack:', stack); } return stack[0]; }; const cellRender = (src, formulaMap, getCellText, cellList = []) => { if (src[0] === '=') { const stack = infixExprToSuffixExpr(src.substring(1)); if (stack.length <= 0) return src; return evalSuffixExpr( stack, formulaMap, (x, y) => cellRender(getCellText(x, y), formulaMap, getCellText, cellList), cellList, ); } return src; }; export default { render: cellRender, }; export { infixExprToSuffixExpr, }; ================================================ FILE: src/core/cell_range.js ================================================ import { xy2expr, expr2xy } from './alphabet'; class CellRange { constructor(sri, sci, eri, eci, w = 0, h = 0) { this.sri = sri; this.sci = sci; this.eri = eri; this.eci = eci; this.w = w; this.h = h; } set(sri, sci, eri, eci) { this.sri = sri; this.sci = sci; this.eri = eri; this.eci = eci; } multiple() { return this.eri - this.sri > 0 || this.eci - this.sci > 0; } // cell-index: ri, ci // cell-ref: A10 includes(...args) { let [ri, ci] = [0, 0]; if (args.length === 1) { [ci, ri] = expr2xy(args[0]); } else if (args.length === 2) { [ri, ci] = args; } const { sri, sci, eri, eci, } = this; return sri <= ri && ri <= eri && sci <= ci && ci <= eci; } each(cb, rowFilter = () => true) { const { sri, sci, eri, eci, } = this; for (let i = sri; i <= eri; i += 1) { if (rowFilter(i)) { for (let j = sci; j <= eci; j += 1) { cb(i, j); } } } } contains(other) { return this.sri <= other.sri && this.sci <= other.sci && this.eri >= other.eri && this.eci >= other.eci; } // within within(other) { return this.sri >= other.sri && this.sci >= other.sci && this.eri <= other.eri && this.eci <= other.eci; } // disjoint disjoint(other) { return this.sri > other.eri || this.sci > other.eci || other.sri > this.eri || other.sci > this.eci; } // intersects intersects(other) { return this.sri <= other.eri && this.sci <= other.eci && other.sri <= this.eri && other.sci <= this.eci; } // union union(other) { const { sri, sci, eri, eci, } = this; return new CellRange( other.sri < sri ? other.sri : sri, other.sci < sci ? other.sci : sci, other.eri > eri ? other.eri : eri, other.eci > eci ? other.eci : eci, ); } // intersection // intersection(other) {} // Returns Array that represents that part of this that does not intersect with other // difference difference(other) { const ret = []; const addRet = (sri, sci, eri, eci) => { ret.push(new CellRange(sri, sci, eri, eci)); }; const { sri, sci, eri, eci, } = this; const dsr = other.sri - sri; const dsc = other.sci - sci; const der = eri - other.eri; const dec = eci - other.eci; if (dsr > 0) { addRet(sri, sci, other.sri - 1, eci); if (der > 0) { addRet(other.eri + 1, sci, eri, eci); if (dsc > 0) { addRet(other.sri, sci, other.eri, other.sci - 1); } if (dec > 0) { addRet(other.sri, other.eci + 1, other.eri, eci); } } else { if (dsc > 0) { addRet(other.sri, sci, eri, other.sci - 1); } if (dec > 0) { addRet(other.sri, other.eci + 1, eri, eci); } } } else if (der > 0) { addRet(other.eri + 1, sci, eri, eci); if (dsc > 0) { addRet(sri, sci, other.eri, other.sci - 1); } if (dec > 0) { addRet(sri, other.eci + 1, other.eri, eci); } } if (dsc > 0) { addRet(sri, sci, eri, other.sci - 1); if (dec > 0) { addRet(sri, other.eri + 1, eri, eci); if (dsr > 0) { addRet(sri, other.sci, other.sri - 1, other.eci); } if (der > 0) { addRet(other.sri + 1, other.sci, eri, other.eci); } } else { if (dsr > 0) { addRet(sri, other.sci, other.sri - 1, eci); } if (der > 0) { addRet(other.sri + 1, other.sci, eri, eci); } } } else if (dec > 0) { addRet(eri, other.eci + 1, eri, eci); if (dsr > 0) { addRet(sri, sci, other.sri - 1, other.eci); } if (der > 0) { addRet(other.eri + 1, sci, eri, other.eci); } } return ret; } size() { return [ this.eri - this.sri + 1, this.eci - this.sci + 1, ]; } toString() { const { sri, sci, eri, eci, } = this; let ref = xy2expr(sci, sri); if (this.multiple()) { ref = `${ref}:${xy2expr(eci, eri)}`; } return ref; } clone() { const { sri, sci, eri, eci, w, h, } = this; return new CellRange(sri, sci, eri, eci, w, h); } /* toJSON() { return this.toString(); } */ equals(other) { return this.eri === other.eri && this.eci === other.eci && this.sri === other.sri && this.sci === other.sci; } static valueOf(ref) { // B1:B8, B1 => 1 x 1 cell range const refs = ref.split(':'); const [sci, sri] = expr2xy(refs[0]); let [eri, eci] = [sri, sci]; if (refs.length > 1) { [eci, eri] = expr2xy(refs[1]); } return new CellRange(sri, sci, eri, eci); } } export default CellRange; export { CellRange, }; ================================================ FILE: src/core/clipboard.js ================================================ export default class Clipboard { constructor() { this.range = null; // CellRange this.state = 'clear'; } copy(cellRange) { this.range = cellRange; this.state = 'copy'; return this; } cut(cellRange) { this.range = cellRange; this.state = 'cut'; return this; } isCopy() { return this.state === 'copy'; } isCut() { return this.state === 'cut'; } isClear() { return this.state === 'clear'; } clear() { this.range = null; this.state = 'clear'; } } ================================================ FILE: src/core/col.js ================================================ import helper from './helper'; class Cols { constructor({ len, width, indexWidth, minWidth, }) { this._ = {}; this.len = len; this.width = width; this.indexWidth = indexWidth; this.minWidth = minWidth; } setData(d) { if (d.len) { this.len = d.len; delete d.len; } this._ = d; } getData() { const { len } = this; return Object.assign({ len }, this._); } getWidth(i) { if (this.isHide(i)) return 0; const col = this._[i]; if (col && col.width) { return col.width; } return this.width; } getOrNew(ci) { this._[ci] = this._[ci] || {}; return this._[ci]; } setWidth(ci, width) { const col = this.getOrNew(ci); col.width = width; } unhide(idx) { let index = idx; while (index > 0) { index -= 1; if (this.isHide(index)) { this.setHide(index, false); } else break; } } isHide(ci) { const col = this._[ci]; return col && col.hide; } setHide(ci, v) { const col = this.getOrNew(ci); if (v === true) col.hide = true; else delete col.hide; } setStyle(ci, style) { const col = this.getOrNew(ci); col.style = style; } sumWidth(min, max) { return helper.rangeSum(min, max, i => this.getWidth(i)); } totalWidth() { return this.sumWidth(0, this.len); } } export default {}; export { Cols, }; ================================================ FILE: src/core/data_proxy.js ================================================ /* global document */ import Selector from './selector'; import Scroll from './scroll'; import History from './history'; import Clipboard from './clipboard'; import AutoFilter from './auto_filter'; import { Merges } from './merge'; import helper from './helper'; import { Rows } from './row'; import { Cols } from './col'; import { Validations } from './validation'; import { CellRange } from './cell_range'; import { expr2xy, xy2expr } from './alphabet'; import { t } from '../locale/locale'; // private methods /* * { * name: '' * freeze: [0, 0], * formats: [], * styles: [ * { * bgcolor: '', * align: '', * valign: '', * textwrap: false, * strike: false, * underline: false, * color: '', * format: 1, * border: { * left: [style, color], * right: [style, color], * top: [style, color], * bottom: [style, color], * }, * font: { * name: 'Helvetica', * size: 10, * bold: false, * italic: false, * } * } * ], * merges: [ * 'A1:F11', * ... * ], * rows: { * 1: { * height: 50, * style: 1, * cells: { * 1: { * style: 2, * type: 'string', * text: '', * value: '', // cal result * } * } * }, * ... * }, * cols: { * 2: { width: 100, style: 1 } * } * } */ const defaultSettings = { mode: 'edit', // edit | read view: { height: () => document.documentElement.clientHeight, width: () => document.documentElement.clientWidth, }, showGrid: true, showToolbar: true, showContextmenu: true, showBottomBar: true, row: { len: 100, height: 25, }, col: { len: 26, width: 100, indexWidth: 60, minWidth: 60, }, style: { bgcolor: '#ffffff', align: 'left', valign: 'middle', textwrap: false, strike: false, underline: false, color: '#0a0a0a', font: { name: 'Arial', size: 10, bold: false, italic: false, }, format: 'normal', }, }; const toolbarHeight = 41; const bottombarHeight = 41; // src: cellRange // dst: cellRange function canPaste(src, dst, error = () => {}) { const { merges } = this; const cellRange = dst.clone(); const [srn, scn] = src.size(); const [drn, dcn] = dst.size(); if (srn > drn) { cellRange.eri = dst.sri + srn - 1; } if (scn > dcn) { cellRange.eci = dst.sci + scn - 1; } if (merges.intersects(cellRange)) { error(t('error.pasteForMergedCell')); return false; } return true; } function copyPaste(srcCellRange, dstCellRange, what, autofill = false) { const { rows, merges } = this; // delete dest merge if (what === 'all' || what === 'format') { rows.deleteCells(dstCellRange, what); merges.deleteWithin(dstCellRange); } rows.copyPaste(srcCellRange, dstCellRange, what, autofill, (ri, ci, cell) => { if (cell && cell.merge) { // console.log('cell:', ri, ci, cell); const [rn, cn] = cell.merge; if (rn <= 0 && cn <= 0) return; merges.add(new CellRange(ri, ci, ri + rn, ci + cn)); } }); } function cutPaste(srcCellRange, dstCellRange) { const { clipboard, rows, merges } = this; rows.cutPaste(srcCellRange, dstCellRange); merges.move(srcCellRange, dstCellRange.sri - srcCellRange.sri, dstCellRange.sci - srcCellRange.sci); clipboard.clear(); } // bss: { top, bottom, left, right } function setStyleBorder(ri, ci, bss) { const { styles, rows } = this; const cell = rows.getCellOrNew(ri, ci); let cstyle = {}; if (cell.style !== undefined) { cstyle = helper.cloneDeep(styles[cell.style]); } cstyle = helper.merge(cstyle, { border: bss }); cell.style = this.addStyle(cstyle); } function setStyleBorders({ mode, style, color }) { const { styles, selector, rows } = this; const { sri, sci, eri, eci, } = selector.range; const multiple = !this.isSingleSelected(); if (!multiple) { if (mode === 'inside' || mode === 'horizontal' || mode === 'vertical') { return; } } if (mode === 'outside' && !multiple) { setStyleBorder.call(this, sri, sci, { top: [style, color], bottom: [style, color], left: [style, color], right: [style, color], }); } else if (mode === 'none') { selector.range.each((ri, ci) => { const cell = rows.getCell(ri, ci); if (cell && cell.style !== undefined) { const ns = helper.cloneDeep(styles[cell.style]); delete ns.border; // ['bottom', 'top', 'left', 'right'].forEach((prop) => { // if (ns[prop]) delete ns[prop]; // }); cell.style = this.addStyle(ns); } }); } else if (mode === 'all' || mode === 'inside' || mode === 'outside' || mode === 'horizontal' || mode === 'vertical') { const merges = []; for (let ri = sri; ri <= eri; ri += 1) { for (let ci = sci; ci <= eci; ci += 1) { // jump merges -- start const mergeIndexes = []; for (let ii = 0; ii < merges.length; ii += 1) { const [mri, mci, rn, cn] = merges[ii]; if (ri === mri + rn + 1) mergeIndexes.push(ii); if (mri <= ri && ri <= mri + rn) { if (ci === mci) { ci += cn + 1; break; } } } mergeIndexes.forEach(it => merges.splice(it, 1)); if (ci > eci) break; // jump merges -- end const cell = rows.getCell(ri, ci); let [rn, cn] = [0, 0]; if (cell && cell.merge) { [rn, cn] = cell.merge; merges.push([ri, ci, rn, cn]); } const mrl = rn > 0 && ri + rn === eri; const mcl = cn > 0 && ci + cn === eci; let bss = {}; if (mode === 'all') { bss = { bottom: [style, color], top: [style, color], left: [style, color], right: [style, color], }; } else if (mode === 'inside') { if (!mcl && ci < eci) bss.right = [style, color]; if (!mrl && ri < eri) bss.bottom = [style, color]; } else if (mode === 'horizontal') { if (!mrl && ri < eri) bss.bottom = [style, color]; } else if (mode === 'vertical') { if (!mcl && ci < eci) bss.right = [style, color]; } else if (mode === 'outside' && multiple) { if (sri === ri) bss.top = [style, color]; if (mrl || eri === ri) bss.bottom = [style, color]; if (sci === ci) bss.left = [style, color]; if (mcl || eci === ci) bss.right = [style, color]; } if (Object.keys(bss).length > 0) { setStyleBorder.call(this, ri, ci, bss); } ci += cn; } } } else if (mode === 'top' || mode === 'bottom') { for (let ci = sci; ci <= eci; ci += 1) { if (mode === 'top') { setStyleBorder.call(this, sri, ci, { top: [style, color] }); ci += rows.getCellMerge(sri, ci)[1]; } if (mode === 'bottom') { setStyleBorder.call(this, eri, ci, { bottom: [style, color] }); ci += rows.getCellMerge(eri, ci)[1]; } } } else if (mode === 'left' || mode === 'right') { for (let ri = sri; ri <= eri; ri += 1) { if (mode === 'left') { setStyleBorder.call(this, ri, sci, { left: [style, color] }); ri += rows.getCellMerge(ri, sci)[0]; } if (mode === 'right') { setStyleBorder.call(this, ri, eci, { right: [style, color] }); ri += rows.getCellMerge(ri, eci)[0]; } } } } function getCellRowByY(y, scrollOffsety) { const { rows } = this; const fsh = this.freezeTotalHeight(); // console.log('y:', y, ', fsh:', fsh); let inits = rows.height; if (fsh + rows.height < y) inits -= scrollOffsety; // handle ri in autofilter const frset = this.exceptRowSet; let ri = 0; let top = inits; let { height } = rows; for (; ri < rows.len; ri += 1) { if (top > y) break; if (!frset.has(ri)) { height = rows.getHeight(ri); top += height; } } top -= height; // console.log('ri:', ri, ', top:', top, ', height:', height); if (top <= 0) { return { ri: -1, top: 0, height }; } return { ri: ri - 1, top, height }; } function getCellColByX(x, scrollOffsetx) { const { cols } = this; const fsw = this.freezeTotalWidth(); let inits = cols.indexWidth; if (fsw + cols.indexWidth < x) inits -= scrollOffsetx; const [ci, left, width] = helper.rangeReduceIf( 0, cols.len, inits, cols.indexWidth, x, i => cols.getWidth(i), ); if (left <= 0) { return { ci: -1, left: 0, width: cols.indexWidth }; } return { ci: ci - 1, left, width }; } export default class DataProxy { constructor(name, settings) { this.settings = helper.merge(defaultSettings, settings || {}); // save data begin this.name = name || 'sheet'; this.freeze = [0, 0]; this.styles = []; // Array