diff --git a/package-lock.json b/package-lock.json index dbe4f1a..30272c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "crypto-js": "^4.2.0", "echarts": "^6.0.0", "echarts-for-react": "^3.0.5", + "exceljs": "^4.4.0", "jotai": "^2.16.2", "lodash": "^4.17.21", "lucide-react": "^0.562.0", @@ -447,6 +448,47 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@fast-csv/format": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@fast-csv/format/-/format-4.3.5.tgz", + "integrity": "sha512-8iRn6QF3I8Ak78lNAa+Gdl5MJJBM5vRHivFtMRUWINdevNo00K7OXxS2PshawLKTejVwieIlPmK5YlLu6w4u8A==", + "license": "MIT", + "dependencies": { + "@types/node": "^14.0.1", + "lodash.escaperegexp": "^4.1.2", + "lodash.isboolean": "^3.0.3", + "lodash.isequal": "^4.5.0", + "lodash.isfunction": "^3.0.9", + "lodash.isnil": "^4.0.0" + } + }, + "node_modules/@fast-csv/format/node_modules/@types/node": { + "version": "14.18.63", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz", + "integrity": "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==", + "license": "MIT" + }, + "node_modules/@fast-csv/parse": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/@fast-csv/parse/-/parse-4.3.6.tgz", + "integrity": "sha512-uRsLYksqpbDmWaSmzvJcuApSEe38+6NQZBUsuAyMZKqHxH0g1wcJgsKUvN3WC8tewaqFjBMMGrkHmC+T7k8LvA==", + "license": "MIT", + "dependencies": { + "@types/node": "^14.0.1", + "lodash.escaperegexp": "^4.1.2", + "lodash.groupby": "^4.6.0", + "lodash.isfunction": "^3.0.9", + "lodash.isnil": "^4.0.0", + "lodash.isundefined": "^3.0.1", + "lodash.uniq": "^4.5.0" + } + }, + "node_modules/@fast-csv/parse/node_modules/@types/node": { + "version": "14.18.63", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz", + "integrity": "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==", + "license": "MIT" + }, "node_modules/@floating-ui/core": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.3.tgz", @@ -2958,6 +3000,81 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/archiver": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-5.3.2.tgz", + "integrity": "sha512-+25nxyyznAXF7Nef3y0EbBeqmGZgeN/BxHX29Rs39djAfaFalmQ89SE6CWyDCHzGL0yt/ycBtNOmGTW0FyGWNw==", + "license": "MIT", + "dependencies": { + "archiver-utils": "^2.1.0", + "async": "^3.2.4", + "buffer-crc32": "^0.2.1", + "readable-stream": "^3.6.0", + "readdir-glob": "^1.1.2", + "tar-stream": "^2.2.0", + "zip-stream": "^4.1.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/archiver-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-2.1.0.tgz", + "integrity": "sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==", + "license": "MIT", + "dependencies": { + "glob": "^7.1.4", + "graceful-fs": "^4.2.0", + "lazystream": "^1.0.0", + "lodash.defaults": "^4.2.0", + "lodash.difference": "^4.5.0", + "lodash.flatten": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.union": "^4.6.0", + "normalize-path": "^3.0.0", + "readable-stream": "^2.0.0" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/archiver-utils/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/archiver-utils/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/archiver-utils/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/archiver-utils/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -3143,6 +3260,12 @@ "integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==", "dev": true }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, "node_modules/async-function": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", @@ -3188,8 +3311,27 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" }, "node_modules/baseline-browser-mapping": { "version": "2.9.15", @@ -3199,11 +3341,49 @@ "baseline-browser-mapping": "dist/cli.js" } }, + "node_modules/big-integer": { + "version": "1.6.52", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz", + "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==", + "license": "Unlicense", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/binary": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", + "integrity": "sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==", + "license": "MIT", + "dependencies": { + "buffers": "~0.1.1", + "chainsaw": "~0.1.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "license": "MIT", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/bluebird": { + "version": "3.4.7", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", + "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==", + "license": "MIT" + }, "node_modules/brace-expansion": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3255,6 +3435,56 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/buffer-indexof-polyfill": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz", + "integrity": "sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==", + "license": "MIT", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/buffers": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", + "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==", + "engines": { + "node": ">=0.2.0" + } + }, "node_modules/call-bind": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", @@ -3330,6 +3560,18 @@ } ] }, + "node_modules/chainsaw": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", + "integrity": "sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==", + "license": "MIT/X11", + "dependencies": { + "traverse": ">=0.3.0 <0.4" + }, + "engines": { + "node": "*" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -3390,11 +3632,25 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/compress-commons": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-4.1.2.tgz", + "integrity": "sha512-D3uMHtGc/fcO1Gt1/L7i1e33VOvD4A9hfQLP+6ewd+BvG/gQ84Yh4oftEhAdjSMgBgwGL+jsppT7JYNpo6MHHg==", + "license": "MIT", + "dependencies": { + "buffer-crc32": "^0.2.13", + "crc32-stream": "^4.0.2", + "normalize-path": "^3.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, "node_modules/convert-source-map": { "version": "2.0.0", @@ -3402,6 +3658,37 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "devOptional": true }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "license": "MIT" + }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "license": "Apache-2.0", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/crc32-stream": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-4.0.3.tgz", + "integrity": "sha512-NT7w2JVU7DFroFdYkeq8cywxrgjPHWkdX1wjpRQXPX5Asews3tA+Ght6lddQO5Mkumffp3X7GEqku3epj2toIw==", + "license": "MIT", + "dependencies": { + "crc-32": "^1.2.0", + "readable-stream": "^3.4.0" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -3485,6 +3772,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/dayjs": { + "version": "1.11.19", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", + "integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==", + "license": "MIT" + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -3583,6 +3876,51 @@ "node": ">= 0.4" } }, + "node_modules/duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", + "license": "BSD-3-Clause", + "dependencies": { + "readable-stream": "^2.0.2" + } + }, + "node_modules/duplexer2/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/duplexer2/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/duplexer2/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/duplexer2/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/echarts": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/echarts/-/echarts-6.0.0.tgz", @@ -3625,6 +3963,15 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/enhanced-resolve": { "version": "5.18.4", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.4.tgz", @@ -4234,6 +4581,39 @@ "node": ">=0.10.0" } }, + "node_modules/exceljs": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/exceljs/-/exceljs-4.4.0.tgz", + "integrity": "sha512-XctvKaEMaj1Ii9oDOqbW/6e1gXknSY4g/aLCDicOXqBE4M0nRWkUu0PTp++UPNzoFY12BNHMfs/VadKIS6llvg==", + "license": "MIT", + "dependencies": { + "archiver": "^5.0.0", + "dayjs": "^1.8.34", + "fast-csv": "^4.3.1", + "jszip": "^3.10.1", + "readable-stream": "^3.6.0", + "saxes": "^5.0.1", + "tmp": "^0.2.0", + "unzipper": "^0.10.11", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=8.3.0" + } + }, + "node_modules/fast-csv": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/fast-csv/-/fast-csv-4.3.6.tgz", + "integrity": "sha512-2RNSpuwwsJGP0frGsOmTb9oUF+VkFSM4SyLTDgwf2ciHWTarN0lQTC+F2f/t5J9QjW+c65VFIAAu85GsvMIusw==", + "license": "MIT", + "dependencies": { + "@fast-csv/format": "4.3.5", + "@fast-csv/parse": "4.3.6" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4362,6 +4742,34 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "license": "MIT" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "license": "ISC" + }, + "node_modules/fstream": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", + "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", + "deprecated": "This package is no longer supported.", + "license": "ISC", + "dependencies": { + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" + }, + "engines": { + "node": ">=0.6" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -4493,6 +4901,27 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -4549,7 +4978,6 @@ "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true, "license": "ISC" }, "node_modules/has-bigints": { @@ -4654,6 +5082,26 @@ "hermes-estree": "0.25.1" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -4663,6 +5111,12 @@ "node": ">= 4" } }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "license": "MIT" + }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -4688,6 +5142,23 @@ "node": ">=0.8.19" } }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, "node_modules/internal-slot": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", @@ -5232,6 +5703,54 @@ "node": ">=4.0" } }, + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "license": "(MIT OR GPL-3.0-or-later)", + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, + "node_modules/jszip/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/jszip/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/jszip/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/jszip/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -5259,6 +5778,54 @@ "node": ">=0.10" } }, + "node_modules/lazystream": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.1.tgz", + "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==", + "license": "MIT", + "dependencies": { + "readable-stream": "^2.0.5" + }, + "engines": { + "node": ">= 0.6.3" + } + }, + "node_modules/lazystream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/lazystream/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/lazystream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/lazystream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -5272,6 +5839,15 @@ "node": ">= 0.8.0" } }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "license": "MIT", + "dependencies": { + "immediate": "~3.0.5" + } + }, "node_modules/lightningcss": { "version": "1.31.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.31.0.tgz", @@ -5533,6 +6109,12 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/listenercount": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", + "integrity": "sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==", + "license": "ISC" + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -5554,12 +6136,91 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "license": "MIT" }, + "node_modules/lodash.defaults": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==", + "license": "MIT" + }, + "node_modules/lodash.difference": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.difference/-/lodash.difference-4.5.0.tgz", + "integrity": "sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==", + "license": "MIT" + }, + "node_modules/lodash.escaperegexp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", + "integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==", + "license": "MIT" + }, + "node_modules/lodash.flatten": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", + "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==", + "license": "MIT" + }, + "node_modules/lodash.groupby": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz", + "integrity": "sha512-5dcWxm23+VAoz+awKmBaiBvzox8+RqMgFhi7UvX9DHZr2HdxHXM/Wrf8cfKpsW37RNrvtPn6hSwNqurSILbmJw==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", + "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.", + "license": "MIT" + }, + "node_modules/lodash.isfunction": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz", + "integrity": "sha512-AirXNj15uRIMMPihnkInB4i3NHeb4iBtNg9WRWuK2o31S+ePwwNmDPaTL3o7dTJ+VXNZim7rFs4rxN4YU1oUJw==", + "license": "MIT" + }, + "node_modules/lodash.isnil": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/lodash.isnil/-/lodash.isnil-4.0.0.tgz", + "integrity": "sha512-up2Mzq3545mwVnMhTDMdfoG1OurpA/s5t88JmQX809eH3C8491iu2sfKhTfhQtKY78oPNhiaHJUpT/dUDAAtng==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isundefined": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz", + "integrity": "sha512-MXB1is3s899/cD8jheYYE2V9qTHwKvt+npCwpD+1Sxm3Q3cECXCiYHjeHWXNwr6Q0SOBPrYUDxendrO6goVTEA==", + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lodash.union": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.union/-/lodash.union-4.6.0.tgz", + "integrity": "sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==", + "license": "MIT" + }, + "node_modules/lodash.uniq": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", + "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==", + "license": "MIT" + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -5625,7 +6286,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -5637,11 +6297,22 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "license": "MIT", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -5781,6 +6452,15 @@ "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", "devOptional": true }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -5896,6 +6576,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -5960,6 +6649,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "license": "(MIT AND Zlib)" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -5981,6 +6676,15 @@ "node": ">=8" } }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -6060,6 +6764,12 @@ "node": ">= 0.8.0" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -6196,6 +6906,50 @@ } } }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/readdir-glob": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-1.1.3.tgz", + "integrity": "sha512-v05I2k7xN8zXvPD9N+z/uhXPaj0sUFCe2rcWZIpBsqxfP7xXFQ0tipAd/wjj1YxWyWtUS5IDJpOG82JKt2EAVA==", + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.1.0" + } + }, + "node_modules/readdir-glob/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/readdir-glob/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", @@ -6286,6 +7040,19 @@ "node": ">=0.10.0" } }, + "node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "license": "ISC", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -6328,6 +7095,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/safe-push-apply": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", @@ -6361,6 +7148,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/saxes": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", + "integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==", + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/scheduler": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", @@ -6421,6 +7220,12 @@ "node": ">= 0.4" } }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "license": "MIT" + }, "node_modules/sharp": { "version": "0.34.5", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", @@ -6613,6 +7418,15 @@ "node": ">= 0.4" } }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/string.prototype.includes": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/string.prototype.includes/-/string.prototype.includes-2.0.1.tgz", @@ -6818,6 +7632,22 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "license": "MIT", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", @@ -6864,6 +7694,15 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/tmp": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", + "integrity": "sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==", + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -6876,6 +7715,15 @@ "node": ">=8.0" } }, + "node_modules/traverse": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", + "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==", + "license": "MIT/X11", + "engines": { + "node": "*" + } + }, "node_modules/ts-api-utils": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.4.0.tgz", @@ -7108,6 +7956,60 @@ "@unrs/resolver-binding-win32-x64-msvc": "1.11.1" } }, + "node_modules/unzipper": { + "version": "0.10.14", + "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.14.tgz", + "integrity": "sha512-ti4wZj+0bQTiX2KmKWuwj7lhV+2n//uXEotUmGuQqrbVZSEGFMbI68+c6JCQ8aAmUWYvtHEz2A8K6wXvueR/6g==", + "license": "MIT", + "dependencies": { + "big-integer": "^1.6.17", + "binary": "~0.3.0", + "bluebird": "~3.4.1", + "buffer-indexof-polyfill": "~1.0.0", + "duplexer2": "~0.1.4", + "fstream": "^1.0.12", + "graceful-fs": "^4.2.2", + "listenercount": "~1.0.1", + "readable-stream": "~2.3.6", + "setimmediate": "~1.0.4" + } + }, + "node_modules/unzipper/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/unzipper/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/unzipper/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/unzipper/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/update-browserslist-db": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", @@ -7190,6 +8092,21 @@ } } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -7299,6 +8216,18 @@ "node": ">=0.10.0" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "license": "MIT" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", @@ -7317,6 +8246,41 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/zip-stream": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-4.1.1.tgz", + "integrity": "sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==", + "license": "MIT", + "dependencies": { + "archiver-utils": "^3.0.4", + "compress-commons": "^4.1.2", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/zip-stream/node_modules/archiver-utils": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-3.0.4.tgz", + "integrity": "sha512-KVgf4XQVrTjhyWmx6cte4RxonPLR9onExufI1jhvw/MQ4BB6IsZD5gT8Lq+u/+pRkWna/6JoHpiQioaqFP5Rzw==", + "license": "MIT", + "dependencies": { + "glob": "^7.2.3", + "graceful-fs": "^4.2.0", + "lazystream": "^1.0.0", + "lodash.defaults": "^4.2.0", + "lodash.difference": "^4.5.0", + "lodash.flatten": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.union": "^4.6.0", + "normalize-path": "^3.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/zod": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.5.tgz", diff --git a/package.json b/package.json index 9e57284..1e69e7c 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "crypto-js": "^4.2.0", "echarts": "^6.0.0", "echarts-for-react": "^3.0.5", + "exceljs": "^4.4.0", "jotai": "^2.16.2", "lodash": "^4.17.21", "lucide-react": "^0.562.0", diff --git a/src/app/(pages)/(main)/total/lg-penetration/page.tsx b/src/app/(pages)/(main)/total/lg-penetration/page.tsx index b7520e7..5826bf0 100644 --- a/src/app/(pages)/(main)/total/lg-penetration/page.tsx +++ b/src/app/(pages)/(main)/total/lg-penetration/page.tsx @@ -7,15 +7,31 @@ import { TopChartTable, type TopChartTableRow, } from "@/components/lge-dashboard"; -import { PRODUCT_KEYS, PRODUCTS, YEARS } from "@/const/lgConst"; -import { useMemo } from "react"; -import { apiOwnShareOfTotalPenetration, apiTrendCategories } from "@/config/sample.data"; +import { + LAST_YEAR, + LIFE_STAGE_COLUMNS, + LIFE_STAGE_GROUPS, + PRODUCT_KEY_MAP, + PRODUCT_KEYS, + PRODUCTS, + YEARS +} from "@/const/lgConst"; +import {useEffect, useMemo} from "react"; +import {apiLifeStageByProduct, apiOwnShareOfTotalPenetration, apiTrendCategories} from "@/config/sample.data"; import LifeStageDiv from "@/components/lge-dashboard/combo/LifeStageDiv"; import { useLayoutFilter } from "@/components/layout/LayoutFilterContext"; import { formatRowLabel } from "@/lib/lg-dashboard"; +import { + buildHeader_LifeStageColumns, + buildHeader_ProductKeyMap, + exportDashboardExcel, + Section +} from "@/lib/lg-export-excel"; +import {norm} from "@/lib/utils"; +import {LifeStageGroup, LifeStageRow} from "@/types/lg"; const LGPenetrationPage = () => { - const { isTotal, filterValue } = useLayoutFilter(); + const { isTotal, filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const productTableRows = useMemo(() => { @@ -29,7 +45,7 @@ const LGPenetrationPage = () => { const total: Array> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0)); const focus: Array> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0)); - const yearIndexMap = new Map(YEARS.map((y, i) => [y, i])); + const yearIndexMap = new Map(YEARS.map((y, i) => [y, i])); const totalRows = apiTrendCategories.filter( (r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년") @@ -47,8 +63,8 @@ const LGPenetrationPage = () => { const t = (totalRows[ri] as any)[k]; const v = (r as any)[k]; - total[yi][ci] = typeof t === "number" ? t : 0; - focus[yi][ci] = typeof v === "number" ? v : 0; + total[yi][ci] = Number(t); + focus[yi][ci] = Number(v); } }); @@ -62,6 +78,61 @@ const LGPenetrationPage = () => { }; }, []); + const lifeStageRowsByGroup:LifeStageGroup[] = useMemo(() => { + const pick = (label: string) => apiLifeStageByProduct.find((r) => norm(r.rowLabel) === norm(label)); + + return LIFE_STAGE_GROUPS.map((g) => { + const rows: LifeStageRow[] = g.items.map((label) => { + const r = pick(label); + + return { + item: label, + total: r?.total ?? "", + single: r?.single ?? "", + noKids: r?.noKids ?? "", + preschoolKids: r?.preschoolKids ?? "", + schoolKids: r?.schoolKids ?? "", + adultKids: r?.adultKids ?? "", + independentSenior: r?.independentSenior ?? "", + }; + }); + + return { title: g.title, rows }; + }); + }, []); + + useEffect(() => { + registerExcelExporter(async (payload) => { + const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); + const lifeStageHeader = buildHeader_LifeStageColumns(LIFE_STAGE_COLUMNS); + + type AnyRow = Record; + + const sections: Section[] = [ + { + title: "LG제품 보급률", + header: excelHeader, + rows: apiOwnShareOfTotalPenetration as AnyRow[], + rowGap: 1, + }, + + ...lifeStageRowsByGroup.map((lifeStageRow) => ({ + title: lifeStageRow.title, + header: lifeStageHeader, + rows: lifeStageRow.rows as AnyRow[], + rowGap: 1, + })), + ]; + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(LG제품 보급률).xlsx`, + sheetName: "LG제품 보급률", + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{ signStyle={signStyleGapRow} /> - +
); }; diff --git a/src/app/(pages)/(main)/total/lg-purchase/page.tsx b/src/app/(pages)/(main)/total/lg-purchase/page.tsx index 2b82cea..3044d18 100644 --- a/src/app/(pages)/(main)/total/lg-purchase/page.tsx +++ b/src/app/(pages)/(main)/total/lg-purchase/page.tsx @@ -1,7 +1,7 @@ "use client"; -import { useMemo } from "react"; -import { PRODUCT_KEYS, PRODUCTS, YEARS } from "@/const/lgConst"; +import {useEffect, useMemo} from "react"; +import {LAST_YEAR, PRODUCT_KEY_MAP, PRODUCT_KEYS, PRODUCTS, YEARS} from "@/const/lgConst"; import { GroupedOverlayBar, type GroupedOverlayBarData, @@ -12,9 +12,10 @@ import { import { apiOwnShareOfTotalPurchase, apiTrendBuy } from "@/config/sample.data"; import { useLayoutFilter } from "@/components/layout/LayoutFilterContext"; import { formatRowLabel } from "@/lib/lg-dashboard"; +import {buildHeader_ProductKeyMap, exportDashboardExcel} from "@/lib/lg-export-excel"; const LGPurchasePage = () => { - const { isTotal, filterValue } = useLayoutFilter(); + const { isTotal, filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const purchaseTableRows = useMemo(() => { @@ -28,7 +29,7 @@ const LGPurchasePage = () => { const total: Array> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0)); const focus: Array> = YEARS.map(() => Array(PRODUCT_KEYS.length).fill(0)); - const yearIndexMap = new Map(YEARS.map((y, i) => [y, i])); + const yearIndexMap = new Map(YEARS.map((y, i) => [y, i])); const totalRows = apiTrendBuy.filter( (r) => YEARS.includes(r.year as any) && r.rowLabel.endsWith("년") @@ -47,8 +48,8 @@ const LGPurchasePage = () => { const v = (r as any)[k]; // total은 t 기준으로 체크해야 안전 - total[yi][ci] = typeof t === "number" ? t : 0; - focus[yi][ci] = typeof v === "number" ? v : 0; + total[yi][ci] = Number(t); + focus[yi][ci] = Number(v); } }); @@ -62,6 +63,21 @@ const LGPurchasePage = () => { }; }, []); + useEffect(() => { + registerExcelExporter(async (payload) => { + const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(LG제품 구매율).xlsx`, + sheetName: "LG제품 구매율", + sections: [ + { title: "LG제품 구매율", header: excelHeader, rows: apiOwnShareOfTotalPurchase, rowGap: 1 }, + ], + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{ const { isTotal, filterValue, registerExcelExporter } = useLayoutFilter(); @@ -73,7 +74,15 @@ const PenetrationPage = () => { useEffect(() => { registerExcelExporter(async (payload) => { - // TODO: export + const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(보급률).xlsx`, + sheetName: "전체 보급률", + sections: [ + { title: "전체 보급률", header: excelHeader, rows: apiTrendCategories, rowGap: 1 }, + ], + }); }); return () => registerExcelExporter(null); }, [registerExcelExporter]); diff --git a/src/app/(pages)/(main)/total/purchase/page.tsx b/src/app/(pages)/(main)/total/purchase/page.tsx index ba36504..b6db076 100644 --- a/src/app/(pages)/(main)/total/purchase/page.tsx +++ b/src/app/(pages)/(main)/total/purchase/page.tsx @@ -1,7 +1,7 @@ "use client"; -import { useMemo } from "react"; -import { PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING } from "@/const/lgConst"; +import {useEffect, useMemo} from "react"; +import {PRODUCT_KEYS, PRODUCTS, AXIS_HIDE_STYLE, GRID_X_NOT_PADDING, LAST_YEAR, PRODUCT_KEY_MAP} from "@/const/lgConst"; import { type ChartData, signStyleGapRow, @@ -12,9 +12,10 @@ import { import { apiTrendBuy } from "@/config/sample.data"; import { useLayoutFilter } from "@/components/layout/LayoutFilterContext"; import { formatRowLabel } from "@/lib/lg-dashboard"; +import {buildHeader_ProductKeyMap, exportDashboardExcel} from "@/lib/lg-export-excel"; const PurchasePage = () => { - const { isTotal, filterValue } = useLayoutFilter(); + const { isTotal, filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const purchaseTableRows = useMemo(() => { @@ -36,6 +37,21 @@ const PurchasePage = () => { }; }, []); + useEffect(() => { + registerExcelExporter(async (payload) => { + const excelHeader = buildHeader_ProductKeyMap(PRODUCT_KEY_MAP); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(구매율).xlsx`, + sheetName: "구매율", + sections: [ + { title: "구매율", header: excelHeader, rows: apiTrendBuy, rowGap: 1 }, + ], + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
(url); + await backApi.post(url); + */ + const res = NextResponse.json({ ok: true }); res.cookies.set("access_token", "", { diff --git a/src/components/lge-dashboard/BaseEChart.tsx b/src/components/lge-dashboard/BaseEChart.tsx index 5743c42..c676f95 100644 --- a/src/components/lge-dashboard/BaseEChart.tsx +++ b/src/components/lge-dashboard/BaseEChart.tsx @@ -23,11 +23,12 @@ const BaseEChart = ({ height = CHART_HEIGHTS.DEFAULT, className, notMerge = true, - lazyUpdate = true, + lazyUpdate = false, //이거 켜져있으면 오류남 Cannot read properties of undefined (reading 'getRawIndex') onEvents, }: BaseEChartProps) => { const style = useMemo(() => ({ height }), [height]); + return (
diff --git a/src/components/lge-dashboard/combo/BannerSummary.tsx b/src/components/lge-dashboard/combo/BannerSummary.tsx index 7c66df9..547942c 100644 --- a/src/components/lge-dashboard/combo/BannerSummary.tsx +++ b/src/components/lge-dashboard/combo/BannerSummary.tsx @@ -1,9 +1,22 @@ import {ChartData, DataColumn, DataTable, HorizontalBar, LeftChartTable, SignStyle} from "@/components/lge-dashboard"; import {BannerKey, ServerBannerRow} from "@/types/lg"; import {formatRowLabel, wrapSampleRow} from "@/lib/lg-dashboard"; -import {useMemo} from "react"; -import {BANNER_GROUP, BANNER_KEY_MAP, GRID_Y_NOT_PADDING} from "@/const/lgConst"; +import {useEffect, useMemo} from "react"; +import { + BANNER_GROUP, + BANNER_KEY_MAP, + GRID_Y_NOT_PADDING, + LAST_YEAR, +} from "@/const/lgConst"; import {parseNumber} from "@/lib/utils"; +import { + buildHeader_DataColumn, + exportDashboardExcel, + Section +} from "@/lib/lg-export-excel"; +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; +import {CategoryTargetData} from "@/config/filter.types"; type SectionSpec = { @@ -37,6 +50,7 @@ const buildColumns = (spec: SectionSpec): DataColumn[] => { key: "total", header: "전체", numeric: true, + headRowSpan: 2, headerClassName: SEP_R, cellClassName: SEP_R, width: 80, @@ -68,25 +82,27 @@ type BannerSummaryProps = { }; const BannerSummary = ({ data, useChart }: BannerSummaryProps) => { + const {filterValue, registerExcelExporter } = useLayoutFilter(); + const buildChartData = (rows: ServerBannerRow[], bannerKeys: BannerKey[]): ChartData => { const categories = rows .filter((r) => !r.rowLabel.includes("사례수")) - .map((r) => formatRowLabel(r.rowLabel)); + .map((r) => formatRowLabel(r.rowLabel)) + .reverse(); const series = [ { name:"전체", data: rows .filter((r) => !r.rowLabel.includes("사례수")) - .map((r) => parseNumber(r.total) ?? null), + .map((r) => parseNumber(r.total) ?? null) + .reverse(), } ]; return { categories, series }; }; - const rows = useMemo(() => wrapSampleRow(data), [data]); - const signStyleGap: SignStyle = { rowSelector: (row) => row.rowLabel === "gap", display: "arrow", @@ -95,31 +111,73 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => { zeroText: "-", }; + + const sectionRows = useMemo(() => { + return SECTIONS.map((spec) => { + const specTitle = spec.title; + + const bannerKeys = getSectionBannerKeys(spec); + const columns = buildColumns(spec); + + // rows가 spec마다 다르면 여기서 가져오도록 구성 + const rows = wrapSampleRow(data); + const chartData = buildChartData(rows, bannerKeys); + + return { + spec, + specTitle, + bannerKeys, + columns, + rows, + chartData, + }; + }); + }, [data]); + + useEffect(() => { + registerExcelExporter(async (payload) => { + const targetString =filterValue.target === CategoryTargetData.PROFILE? "Profile" : "보급률 변화" + const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_${targetString}` + + type AnyRow = Record; + const sections: Section[] = + sectionRows.map((sectionRow) => ({ + title: sectionRow.specTitle, + header: buildHeader_DataColumn(sectionRow.columns), + rows: sectionRow.rows as AnyRow[], + rowGap: 1, + })) + ; + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + sheetName: sheetName, + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
- {SECTIONS.map((spec) => { - const bannerKeys = getSectionBannerKeys(spec); - - const columns = buildColumns(spec); - const chartData = buildChartData(rows, bannerKeys); - + {sectionRows.map((sectionRow) => { return ( useChart ? - key={spec.title} - title={spec.title} - columns={columns} - rows={rows} + key={sectionRow.specTitle} + title={sectionRow.specTitle} + columns={sectionRow.columns} + rows={sectionRow.rows} signStyle={signStyleGap} chart={ } chartCell={{ key: "total", startRowIndex: 1 }} @@ -127,10 +185,10 @@ const BannerSummary = ({ data, useChart }: BannerSummaryProps) => { /> : - key={spec.title} - title={spec.title} - columns={columns} - rows={rows} + key={sectionRow.specTitle} + title={sectionRow.specTitle} + columns={sectionRow.columns} + rows={sectionRow.rows} signStyle={signStyleGap} /> ); diff --git a/src/components/lge-dashboard/combo/CategoryByData.tsx b/src/components/lge-dashboard/combo/CategoryByData.tsx index ebc26f2..a878a73 100644 --- a/src/components/lge-dashboard/combo/CategoryByData.tsx +++ b/src/components/lge-dashboard/combo/CategoryByData.tsx @@ -7,7 +7,7 @@ import { } from "@/components/lge-dashboard"; import BannerButtons from "@/components/lge-dashboard/BannerButtons"; import {totalFilters} from "@/config/filter.data"; -import {useMemo, useState} from "react"; +import {useEffect, useMemo, useState} from "react"; import {BannerGroupKey, CategoryChartMode, ServerBannerRow} from "@/types/lg"; import { buildRowLabelSeriesChartData, @@ -17,6 +17,8 @@ import { } from "@/lib/lg-dashboard"; import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR} from "@/const/lgConst"; import {createDefaultGrid, createDefaultLegend, reverseCategories} from "@/lib/chart-options"; +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; type CategoryByDataProps = { title?: string; @@ -90,7 +92,7 @@ const CategoryByData = ({ return isBannerGroupKey(v) ? buildColumns(v) : []; }, [selectedBanner.variable]); - const tableData = useMemo(() => wrapSampleRow(allTableData).filter((row) => row.year === LAST_YEAR), [allTableData, LAST_YEAR]) + const tableData = useMemo(() => wrapSampleRow(allTableData).filter((row) => row.year === LAST_YEAR), [allTableData, LAST_YEAR]); return (
diff --git a/src/components/lge-dashboard/combo/LifeStageDiv.tsx b/src/components/lge-dashboard/combo/LifeStageDiv.tsx index 830419f..f9e330c 100644 --- a/src/components/lge-dashboard/combo/LifeStageDiv.tsx +++ b/src/components/lge-dashboard/combo/LifeStageDiv.tsx @@ -1,54 +1,13 @@ import GaugeCardTable from "./GaugeCardTable"; -import {GaugeColumn} from "@/components/lge-dashboard"; -import {useMemo} from "react"; -import {apiLifeStageByProduct} from "@/config/sample.data"; -import {LifeStageRow} from "@/types/lg"; -import {asNum, norm} from "@/lib/utils"; +import {LIFE_STAGE_COLUMNS} from "@/const/lgConst"; +import {LifeStageGroup} from "@/types/lg"; -const LifeStageDiv = () => { - const LIFE_STAGE_COLUMNS: GaugeColumn[] = [ - { key: "item", header: "", rowHead: true, renderLabel: (r) => r.item }, +type lifeStageDivProps = { + lifeStageRowsByGroup:LifeStageGroup[]; +} - { key: "total", header: "전체", max: 100, align: "left", cellType:"number"}, - { key: "single", header: "미혼", max: 100 , align: "left"}, - - { key: "noKids", header: "무자녀", group: "기혼", max: 100 , align: "left"}, - { key: "preschoolKids", header: "미취학", group: "기혼", max: 100 , align: "left"}, - { key: "schoolKids", header: "취학자녀", group: "기혼", max: 100 , align: "left"}, - { key: "adultKids", header: "성인자녀", group: "기혼", max: 100 , align: "left"}, - - { key: "independentSenior", header: "독립\n시니어", max: 100 , align: "left"}, - ]; - - const LIFE_STAGE_GROUPS = [ - { title: "대형가전 군", items: ["냉장고", "세탁기", "건조기", "에어컨", "TV", "김치 냉장고", "식기세척기", "의류 관리기"] }, - { title: "소형가전 군", items: ["청소기", "공기 청정기", "정수기"] }, - { title: "신가전 군", items: ["로봇 청소기", "음식물처리기"] }, - ] as const; - - const lifeStageRowsByGroup = useMemo(() => { - const pick = (label: string) => apiLifeStageByProduct.find((r) => norm(r.rowLabel) === norm(label)); - - return LIFE_STAGE_GROUPS.map((g) => { - const rows: LifeStageRow[] = g.items.map((label) => { - const r = pick(label); - - return { - item: label, - total: asNum((r as any)?.total), // 서버에 all이 없으면 null로 남음 - single: asNum((r as any)?.single), - noKids: asNum((r as any)?.noKids), - preschoolKids: asNum((r as any)?.preschoolKids), - schoolKids: asNum((r as any)?.schoolKids), - adultKids: asNum((r as any)?.adultKids), - independentSenior: asNum((r as any)?.independentSenior), - }; - }); - - return { title: g.title, rows }; - }); - }, []); +const LifeStageDiv = ({lifeStageRowsByGroup}:lifeStageDivProps) => { return (
diff --git a/src/components/lge-dashboard/sub-page/category-page/Brand.tsx b/src/components/lge-dashboard/sub-page/category-page/Brand.tsx index daa0c2d..3fe11d5 100644 --- a/src/components/lge-dashboard/sub-page/category-page/Brand.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/Brand.tsx @@ -1,18 +1,20 @@ 'use client' -import {useMemo} from "react"; -import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; +import {useEffect, useMemo} from "react"; import {CategoryByData} from "@/components/lge-dashboard"; import {apiBrandShareByYear} from "@/config/sample.data"; import {PageData, ServerBannerRow} from "@/types/lg"; import {buildGapRow} from "@/lib/lg-dashboard"; +import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; +import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; const Brand = () => { - const { filterValue } = useLayoutFilter(); - + const {filterValue, registerExcelExporter} = useLayoutFilter(); const tableDataArray = useMemo[]>(() => { const cleaned = apiBrandShareByYear.filter( - (r) => !(r.year === 26 && r.rowLabel === "gap") + (r) => !(r.year === LAST_YEAR && r.rowLabel === "gap") ); const gapRow = buildGapRow(cleaned, 25, 26, "lg", "gap"); @@ -21,7 +23,7 @@ const Brand = () => { if (gapRow) { const insertIdx = cleaned.findIndex( - (r) => r.year === 26 && r.rowLabel === "lg" + (r) => r.year === LAST_YEAR && r.rowLabel === "lg" ); if (insertIdx >= 0) { @@ -42,6 +44,33 @@ const Brand = () => { ]; }, []); + useEffect(() => { + registerExcelExporter(async (payload) => { + + const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_브랜드` + const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP); + + type AnyRow = Record; + const sections: Section[] = tableDataArray.flatMap((tableData) => { + const years = [YEARS.at(-1), YEARS.at(-2)]; + + return years.map((year) => ({ + title: `${tableData.title}_${year}년`, + header: h3, + rows: tableData.data.filter((d) => d.year === year) as AnyRow[], + rowGap: 1, + })); + }); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + sheetName: sheetName, + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{tableDataArray.map((tableData) => ( diff --git a/src/components/lge-dashboard/sub-page/category-page/OwnershipPath.tsx b/src/components/lge-dashboard/sub-page/category-page/OwnershipPath.tsx index 2caf38a..d2db264 100644 --- a/src/components/lge-dashboard/sub-page/category-page/OwnershipPath.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/OwnershipPath.tsx @@ -1,20 +1,50 @@ 'use client' import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; -import {useMemo} from "react"; +import {useEffect, useMemo} from "react"; import {PageData, ServerBannerRow} from "@/types/lg"; import {apiOwnershipPathByYear, apiOwnershipTriggerByYear} from "@/config/sample.data"; import {CategoryByData} from "@/components/lge-dashboard"; +import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; +import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; const OwnershipPath = () => { - const { filterValue } = useLayoutFilter(); + const { filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const tableDataArray = useMemo[]>(() => [ - {title: "보유 경로", chartMode:"reverseStack", data: apiOwnershipPathByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))}, - {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))}, + {title: "보유 경로", chartMode:"reverseStack", data: apiOwnershipPathByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, + {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, ], []); + useEffect(() => { + registerExcelExporter(async (payload) => { + + const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_보유 경로` + const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP); + + type AnyRow = Record; + const sections: Section[] = tableDataArray.flatMap((tableData) => { + const years = [YEARS.at(-1), YEARS.at(-2)]; + + return years.map((year) => ({ + title: `${tableData.title}_${year}년`, + header: h3, + rows: tableData.data.filter((d) => d.year === year) as AnyRow[], + rowGap: 1, + })); + }); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + sheetName: sheetName, + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{tableDataArray.map((tableData) => ( diff --git a/src/components/lge-dashboard/sub-page/category-page/PaymentMethod.tsx b/src/components/lge-dashboard/sub-page/category-page/PaymentMethod.tsx index 19c133a..5d684b1 100644 --- a/src/components/lge-dashboard/sub-page/category-page/PaymentMethod.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/PaymentMethod.tsx @@ -1,19 +1,49 @@ 'use client' import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; -import {apiOwnershipPathByYear, apiOwnershipTriggerByYear, apiPaymentMethodByYear} from "@/config/sample.data"; -import {useMemo} from "react"; +import {apiPaymentMethodByYear} from "@/config/sample.data"; +import {useEffect, useMemo} from "react"; import {PageData, ServerBannerRow} from "@/types/lg"; import {CategoryByData} from "@/components/lge-dashboard"; +import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; +import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; const PaymentMethod = () => { - const { filterValue } = useLayoutFilter(); + const { filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const tableDataArray = useMemo[]>(() => [ - {title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))}, + {title: "구매 형식", chartMode:"reverseStack", data: apiPaymentMethodByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, ], []); + useEffect(() => { + registerExcelExporter(async (payload) => { + + const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_구매 형식` + const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP); + + type AnyRow = Record; + const sections: Section[] = tableDataArray.flatMap((tableData) => { + const years = [YEARS.at(-1), YEARS.at(-2)]; + + return years.map((year) => ({ + title: `${tableData.title}_${year}년`, + header: h3, + rows: tableData.data.filter((d) => d.year === year) as AnyRow[], + rowGap: 1, + })); + }); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + sheetName: sheetName, + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{tableDataArray.map((tableData) => ( diff --git a/src/components/lge-dashboard/sub-page/category-page/Profile.tsx b/src/components/lge-dashboard/sub-page/category-page/Profile.tsx index f2e96e9..1dbc804 100644 --- a/src/components/lge-dashboard/sub-page/category-page/Profile.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/Profile.tsx @@ -2,7 +2,7 @@ import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; import BannerSummary from "@/components/lge-dashboard/combo/BannerSummary"; -import { useMemo } from "react"; +import {useMemo} from "react"; import {ServerBannerRow} from "@/types/lg"; import {apiOwnershipSummary, apiPurchaseRateKpis} from "@/config/sample.data"; diff --git a/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx b/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx index b553294..0911995 100644 --- a/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/PurchaseBehavior.tsx @@ -1,20 +1,50 @@ 'use client' import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; -import {useMemo} from "react"; +import {useEffect, useMemo} from "react"; import {PageData, ServerBannerRow} from "@/types/lg"; import { apiOwnershipPathByYear, apiOwnershipTriggerByYear} from "@/config/sample.data"; import {CategoryByData} from "@/components/lge-dashboard"; +import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; +import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; const PurchaseBehavior = () => { - const { filterValue } = useLayoutFilter(); + const { filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const tableDataArray = useMemo[]>(() => [ - {title: "보유 경로", chartMode:"horizontal", data: apiOwnershipPathByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))}, - {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap"))}, + {title: "보유 경로", chartMode:"horizontal", data: apiOwnershipPathByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, + {title: "구입 계기", chartMode:"horizontal", data: apiOwnershipTriggerByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap"))}, ], []); + useEffect(() => { + registerExcelExporter(async (payload) => { + + const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_구입 행태` + const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP); + + type AnyRow = Record; + const sections: Section[] = tableDataArray.flatMap((tableData) => { + const years = [YEARS.at(-1), YEARS.at(-2)]; + + return years.map((year) => ({ + title: `${tableData.title}_${year}년`, + header: h3, + rows: tableData.data.filter((d) => d.year === year) as AnyRow[], + rowGap: 1, + })); + }); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + sheetName: sheetName, + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{tableDataArray.map((tableData) => ( diff --git a/src/components/lge-dashboard/sub-page/category-page/PurchaseChannel.tsx b/src/components/lge-dashboard/sub-page/category-page/PurchaseChannel.tsx index 23fe195..707d496 100644 --- a/src/components/lge-dashboard/sub-page/category-page/PurchaseChannel.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/PurchaseChannel.tsx @@ -2,33 +2,61 @@ import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; import { - apiOwnershipPathByYear, - apiOwnershipTriggerByYear, apiPurchaseChannelByYear, apiPurchaseChannelSummaryByYear } from "@/config/sample.data"; -import {useMemo} from "react"; +import {useEffect, useMemo} from "react"; import {PageData, ServerBannerRow} from "@/types/lg"; import {CategoryByData} from "@/components/lge-dashboard"; +import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; +import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; const PurchaseChannel = () => { - const { filterValue } = useLayoutFilter(); + const { filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const tableDataArray = useMemo[]>(() => [ { title: "구매 채널(온/오프라인)", chartMode: "reverseStack", - data: apiPurchaseChannelSummaryByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap")), + data: apiPurchaseChannelSummaryByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")), }, { title: "구매 채널(상세)", chartMode: "horizontal", - data: apiPurchaseChannelByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap")), + data: apiPurchaseChannelByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")), chartHeight: 550, }, ], []); + useEffect(() => { + registerExcelExporter(async (payload) => { + + const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_구매 채널` + const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP); + + type AnyRow = Record; + const sections: Section[] = tableDataArray.flatMap((tableData) => { + const years = [YEARS.at(-1), YEARS.at(-2)]; + + return years.map((year) => ({ + title: `${tableData.title}_${year}년`, + header: h3, + rows: tableData.data.filter((d) => d.year === year) as AnyRow[], + rowGap: 1, + })); + }); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + sheetName: sheetName, + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{tableDataArray.map((tableData) => ( diff --git a/src/components/lge-dashboard/sub-page/category-page/TypeSpec.tsx b/src/components/lge-dashboard/sub-page/category-page/TypeSpec.tsx index d6ecaf8..d3d203b 100644 --- a/src/components/lge-dashboard/sub-page/category-page/TypeSpec.tsx +++ b/src/components/lge-dashboard/sub-page/category-page/TypeSpec.tsx @@ -1,23 +1,53 @@ 'use client' import {useLayoutFilter} from "@/components/layout/LayoutFilterContext"; -import {useMemo} from "react"; +import {useEffect, useMemo} from "react"; import {PageData, ServerBannerRow} from "@/types/lg"; import {apiFridgeDoorTypeByYear} from "@/config/sample.data"; import {CategoryByData} from "@/components/lge-dashboard"; +import {BANNER_GROUP, BANNER_KEY_MAP, LAST_YEAR, YEARS} from "@/const/lgConst"; +import {CategoryTypeValue} from "@/components/layout/CategoryFilter"; +import {buildHeader_Banner, exportDashboardExcel, Section} from "@/lib/lg-export-excel"; const TypeSpec = () => { - const { filterValue } = useLayoutFilter(); + const { filterValue, registerExcelExporter } = useLayoutFilter(); console.log(filterValue); const tableDataArray = useMemo[]>(() => [ { title: "타입", chartMode: "horizontal", - data: apiFridgeDoorTypeByYear.filter(r => !(r.year === 26 && r.rowLabel === "gap")), + data: apiFridgeDoorTypeByYear.filter(r => !(r.year === LAST_YEAR && r.rowLabel === "gap")), }, ], []); + useEffect(() => { + registerExcelExporter(async (payload) => { + + const sheetName = `${filterValue.product}_${(filterValue.type as CategoryTypeValue).label}_타입/스펙` + const h3 = buildHeader_Banner(BANNER_GROUP, BANNER_KEY_MAP); + + type AnyRow = Record; + const sections: Section[] = tableDataArray.flatMap((tableData) => { + const years = [YEARS.at(-1), YEARS.at(-2)]; + + return years.map((year) => ({ + title: `${tableData.title}_${year}년`, + header: h3, + rows: tableData.data.filter((d) => d.year === year) as AnyRow[], + rowGap: 1, + })); + }); + + await exportDashboardExcel({ + fileName: `20${LAST_YEAR}년도 가전 보급률 Dashboard(${sheetName}).xlsx`, + sheetName: sheetName, + sections: sections, + }); + }); + return () => registerExcelExporter(null); + }, [registerExcelExporter]); + return (
{tableDataArray.map((tableData) => ( diff --git a/src/components/lge-dashboard/table/GaugeTable.tsx b/src/components/lge-dashboard/table/GaugeTable.tsx index faba734..c763fba 100644 --- a/src/components/lge-dashboard/table/GaugeTable.tsx +++ b/src/components/lge-dashboard/table/GaugeTable.tsx @@ -1,6 +1,6 @@ "use client"; -import { useMemo } from "react"; +import React, { useMemo } from "react"; import { cn, parseNumber } from "@/lib/utils"; import {GaugeColumn} from "../types"; @@ -37,23 +37,47 @@ const GaugeTable = >({ cellHeight = 26, valueFormatter, }: Props) => { - const hasGroup = columns.some((c) => !!c.group); + const hasGroup = columns.some((c) => !!c.group) || columns.some((c) => c.headRowSpan === 2); const groupCells = useMemo(() => { - if (!hasGroup) return []; - const res: { label: string; span: number }[] = []; + type GroupCell = + | { kind: "rowspan"; label: string; colSpan: 1; rowSpan: 2; className?: string } + | { kind: "group"; label: string; colSpan: number; rowSpan: 1; className?: string } + | { kind: "blank"; label: string; colSpan: 1; rowSpan: 1; className?: string }; + + if (!hasGroup) return [] as GroupCell[]; + + const res: GroupCell[] = []; let i = 0; + while (i < columns.length) { - const g = columns[i].group ?? ""; + const c = columns[i]; + + if (c.headRowSpan === 2) { + res.push({ kind: "rowspan", label: c.header, colSpan: 1, rowSpan: 2 }); + i++; + continue; + } + + const g = c.group; + if (!g) { + // group 미지정: 1칸짜리 blank group 셀 + res.push({ kind: "blank", label: "", colSpan: 1, rowSpan: 1 }); + i++; + continue; + } + + // 같은 group 연속 구간 colSpan let span = 1; let j = i + 1; - while (j < columns.length && (columns[j].group ?? "") === g) { + while (j < columns.length && columns[j].headRowSpan !== 2 && columns[j].group === g) { span++; j++; } - res.push({ label: g, span }); + res.push({ kind: "group", label: g, colSpan: span, rowSpan: 1 }); i = j; } + return res; }, [columns, hasGroup]); @@ -80,14 +104,19 @@ const GaugeTable = >({ {hasGroup && ( {groupCells.map((g, idx) => ( - + {g.label} ))} )} - {columns.map((c) => ( + {columns.filter((c) => c.headRowSpan !== 2).map((c) => ( {c.header} @@ -104,8 +133,8 @@ const GaugeTable = >({ if (c.rowHead) { const raw = row[c.key]; - const label = c.renderLabel - ? c.renderLabel(row) + const label = c.render + ? c.render(row) : raw === null || raw === undefined ? "" : typeof raw === "string" || typeof raw === "number" diff --git a/src/components/lge-dashboard/types.ts b/src/components/lge-dashboard/types.ts index 76e250f..9b803c2 100644 --- a/src/components/lge-dashboard/types.ts +++ b/src/components/lge-dashboard/types.ts @@ -34,7 +34,7 @@ export type GroupedStackBarData = { export type GroupedOverlayBarData = { categories: string[]; // 제품 - years: number[]; // 예: [24,25,26] + years: string[]; // 예: [24,25,26] totalName?: string; // default: "전체" focusName?: string; // default: "LG" total: Array>; // [yearIndex][categoryIndex] @@ -76,10 +76,13 @@ export type GaugeColumn = { width?: number | string; align?: "left" | "center" | "right"; group?: string; + groupKey?:string;// 2단 헤더 그룹 + + headRowSpan?: 1 | 2; rowHead?: boolean; /** 게이지 최대값 기준(기본 100) */ max?: number; - renderLabel?: (row: T) => React.ReactNode; // rowHead에 쓰기 좋음 + render?: (row: T) => React.ReactNode; // rowHead에 쓰기 좋음 cellType?: "gauge" | "number"; // default: "gauge" }; diff --git a/src/config/sample.data.ts b/src/config/sample.data.ts index cf19e1a..ebfa47f 100644 --- a/src/config/sample.data.ts +++ b/src/config/sample.data.ts @@ -32,24 +32,24 @@ const randInt = (r: () => number, min: number, max: number) => type RandRange = { min: number | null; max: number | null }; -const makeProductDist = (seedKey: string, range?: RandRange): Record => { +const makeProductDist = (seedKey: string, range?: RandRange): Record => { const min = range?.min ?? 1; const max = range?.max ?? 60; const seed = (hash32(seedKey) ^ DUMMY_SEED) >>> 0; const r = mulberry32(seed); - const out = {} as Record; - for (const k of PRODUCT_KEYS) out[k] = randInt(r, min, max); + const out = {} as Record; + for (const k of PRODUCT_KEYS) out[k] = String(randInt(r, min, max)); return out; }; const productRow = ( - year: number, + year: string, rowLabel: string, - total: number, + total: string, range: RandRange = { min: null, max: null }, - extra?: Partial>, + extra?: Partial>, ): ServerProductRow => ({ year, rowLabel, @@ -64,33 +64,33 @@ const calcGapRow = (row26: ServerProductRow, row25: ServerProductRow): ServerPro const out: ServerProductRow = { year: row26.year, rowLabel: "gap", - total: row26.total - row25.total, + total: String(Number(row26.total) - Number(row25.total)), }; for (const k of PRODUCT_KEYS) { - const a = row26[k] ?? 0; - const b = row25[k] ?? 0; - out[k] = a - b; + const a = row26[k] ?? "0"; + const b = row25[k] ?? "0"; + out[k] = String(Number(a) - Number(b)); } return out; }; const calcCagrRow = (row24: ServerProductRow, row26: ServerProductRow): ServerProductRow => { const years = 2; // 24 -> 26 - const out: ServerProductRow = { year: row26.year, rowLabel: "CAGR", total: 0 }; + const out: ServerProductRow = { year: row26.year, rowLabel: "CAGR", total: "0" }; // total은 참고용으로만: (26/24) CAGR % out.total = - row24.total > 0 ? round1((Math.pow(row26.total / row24.total, 1 / years) - 1) * 100) : 0; + Number(row24.total) > 0 ? String(round1((Math.pow(Number(row26.total) / Number(row24.total), 1 / years) - 1) * 100)) : "0"; for (const k of PRODUCT_KEYS) { - const v24 = row24[k] ?? 0; - const v26 = row26[k] ?? 0; - out[k] = v24 > 0 ? round1((Math.pow(v26 / v24, 1 / years) - 1) * 100) : 0; + const v24 = row24[k] ?? "0"; + const v26 = row26[k] ?? "0"; + out[k] = Number(v24) > 0 ? String(round1((Math.pow(Number(v26) / Number(v24), 1 / years) - 1) * 100)) : "0"; } return out; }; -const splitTo100 = (r: () => number, n: number, minEach: number, maxEach: number): number[] => { +const splitTo100 = (r: () => number, n: number, minEach: number, maxEach: number): string[] => { // 불가능한 범위 방어 const minSum = n * minEach; const maxSum = n * maxEach; @@ -151,7 +151,7 @@ const splitTo100 = (r: () => number, n: number, minEach: number, maxEach: number // 마지막 보정(이론상 거의 안 탐) out[n - 1] += 100 - sum; } - return out; + return out.map((o) => String(o)); }; const BANNER_GROUPS: Record = { @@ -173,14 +173,14 @@ const BANNER_GROUPS: Record = { }; /** ✅ 기존 상수 대신: 호출할 때마다 “결정적 랜덤” 분포 생성 */ -export const makeBannerDistDefault = (seedKey: string, range?: RandRange): Record => { +export const makeBannerDistDefault = (seedKey: string, range?: RandRange): Record => { const seed = (hash32(seedKey) ^ DUMMY_SEED) >>> 0; const r = mulberry32(seed); const minEach = range?.min ?? 1; const maxEach = range?.max ?? 60; - const out = {} as Record; + const out = {} as Record; (Object.keys(BANNER_GROUPS) as Array).forEach((groupName) => { const keys = BANNER_GROUPS[groupName]; @@ -192,11 +192,11 @@ export const makeBannerDistDefault = (seedKey: string, range?: RandRange): Recor }; export const bannerRow = ( - year: number, + year: string, rowLabel: string, - total: number, + total: string, range: RandRange = { min: null, max: null }, - extra?: Partial>, + extra?: Partial>, ): ServerBannerRow => ({ year, rowLabel, @@ -205,9 +205,9 @@ export const bannerRow = ( ...(extra ?? {}), }); -const TREND_24: ServerProductRow = productRow(24, "24년", 45, {min:70, max:99}); -const TREND_25: ServerProductRow = productRow(25, "25년", 46, {min:70, max:99}); -const TREND_26: ServerProductRow = productRow(26, "26년", 48, {min:70, max:99}); +const TREND_24: ServerProductRow = productRow("24", "24년", "45", {min:70, max:99}); +const TREND_25: ServerProductRow = productRow("25", "25년", "46", {min:70, max:99}); +const TREND_26: ServerProductRow = productRow("26", "26년", "48", {min:70, max:99}); export const apiTrendCategories: ServerProductRow[] = [ calcGapRow(TREND_26, TREND_25), @@ -218,22 +218,22 @@ export const apiTrendCategories: ServerProductRow[] = [ ]; export const apiBrandByYearCategories: ServerProductRow[] = [ - productRow(24, "LG", 1200), - productRow(24, "Samsung", 1300), - productRow(24, "Cbrand", 600), + productRow("24", "LG", "1200"), + productRow("24", "Samsung", "1300"), + productRow("24", "Cbrand", "600"), - productRow(25, "LG", 1250), - productRow(25, "Samsung", 1320), - productRow(25, "Cbrand", 620), + productRow("25", "LG", "1250"), + productRow("25", "Samsung", "1320"), + productRow("25", "Cbrand", "620"), - productRow(26, "LG", 1280), - productRow(26, "Samsung", 1340), - productRow(26, "Cbrand", 640), + productRow("26", "LG", "1280"), + productRow("26", "Samsung", "1340"), + productRow("26", "Cbrand", "640"), ]; -const OWN_PEN_24: ServerProductRow = productRow(24, "24년", 45); -const OWN_PEN_25: ServerProductRow = productRow(25, "25년", 46); -const OWN_PEN_26: ServerProductRow = productRow(26, "26년", 48); +const OWN_PEN_24: ServerProductRow = productRow("24", "24년", "45"); +const OWN_PEN_25: ServerProductRow = productRow("25", "25년", "46"); +const OWN_PEN_26: ServerProductRow = productRow("26", "26년", "48"); export const apiOwnShareOfTotalPenetration: ServerProductRow[] = [ calcGapRow(OWN_PEN_26, OWN_PEN_25), @@ -242,9 +242,9 @@ export const apiOwnShareOfTotalPenetration: ServerProductRow[] = [ OWN_PEN_26, ]; -const BUY_24: ServerProductRow = productRow(24, "24년", 45, {min:20, max:40}); -const BUY_25: ServerProductRow = productRow(25, "25년", 46, {min:20, max:40}); -const BUY_26: ServerProductRow = productRow(26, "26년", 48, {min:20, max:40}); +const BUY_24: ServerProductRow = productRow("24", "24년", "45", {min:20, max:40}); +const BUY_25: ServerProductRow = productRow("25", "25년", "46", {min:20, max:40}); +const BUY_26: ServerProductRow = productRow("26", "26년", "48", {min:20, max:40}); export const apiTrendBuy: ServerProductRow[] = [ calcGapRow(TREND_26, TREND_25), BUY_24, @@ -252,34 +252,34 @@ export const apiTrendBuy: ServerProductRow[] = [ BUY_26, ]; -const OWN_BUY_24: ServerProductRow = productRow(24, "24년", 41, {min:5, max:20}); -const OWN_BUY_25: ServerProductRow = productRow(25, "25년", 42, {min:5, max:20}); -const OWN_BUY_26: ServerProductRow = productRow(26, "26년", 43, {min:5, max:20}); +const OWN_BUY_24: ServerProductRow = productRow("24", "24년", "41", {min:5, max:20}); +const OWN_BUY_25: ServerProductRow = productRow("25", "25년", "42", {min:5, max:20}); +const OWN_BUY_26: ServerProductRow = productRow("26", "26년", "43", {min:5, max:20}); export const apiOwnShareOfTotalPurchase: ServerProductRow[] = [ calcGapRow(OWN_BUY_26, OWN_BUY_25), - productRow(26, "전체 구입율 중 자사제품 비율", 46), + productRow("26", "전체 구입율 중 자사제품 비율", "46"), OWN_BUY_24, OWN_BUY_25, OWN_BUY_26, ]; export const apiLifeStageByProduct: ServerBannerRow[] = [ - bannerRow(26, "냉장고", 97, {min:10, max:99}), - bannerRow(26, "세탁기", 94, {min:10, max:99}), - bannerRow(26, "에어컨", 90, {min:10, max:99}), - bannerRow(26, "건조기", 38, {min:10, max:99}), - bannerRow(26, "TV", 86, {min:10, max:99}), - bannerRow(26, "김치 냉장고", 56, {min:10, max:99}), - bannerRow(26, "식기세척기", 18, {min:10, max:99}), - bannerRow(26, "의류 관리기", 13, {min:10, max:99}), + bannerRow("26", "냉장고", "97", {min:10, max:99}), + bannerRow("26", "세탁기", "94", {min:10, max:99}), + bannerRow("26", "에어컨", "90", {min:10, max:99}), + bannerRow("26", "건조기", "38", {min:10, max:99}), + bannerRow("26", "TV", "86", {min:10, max:99}), + bannerRow("26", "김치 냉장고", "56", {min:10, max:99}), + bannerRow("26", "식기세척기", "18", {min:10, max:99}), + bannerRow("26", "의류 관리기", "13", {min:10, max:99}), - bannerRow(26, "청소기", 78, {min:10, max:99}), - bannerRow(26, "공기 청정기", 52, {min:10, max:99}), - bannerRow(26, "정수기", 42, {min:10, max:99}), + bannerRow("26", "청소기", "78", {min:10, max:99}), + bannerRow("26", "공기 청정기", "52", {min:10, max:99}), + bannerRow("26", "정수기", "42", {min:10, max:99}), - bannerRow(26, "로봇 청소기", 22, {min:10, max:99}), - bannerRow(26, "음식물처리기", 26, {min:10, max:99}), + bannerRow("26", "로봇 청소기", "22", {min:10, max:99}), + bannerRow("26", "음식물처리기", "26", {min:10, max:99}), ]; /** --------------------------- @@ -288,10 +288,10 @@ export const apiLifeStageByProduct: ServerBannerRow[] = [ * 26 사례수 / 보유율 / gap / 보유대수 * -------------------------- */ export const apiOwnershipSummary: ServerBannerRow[] = [ - bannerRow(26, "사례수", 2000), - bannerRow(26, "보유율", 85), - bannerRow(26, "gap", 1), // 26-25 - bannerRow(26, "보유대수", 1.2), + bannerRow("26", "사례수", "2000"), + bannerRow("26", "보유율", "85"), + bannerRow("26", "gap", "1"), // 26-25 + bannerRow("26", "보유대수", "1.2"), ]; /** --------------------------- @@ -303,10 +303,10 @@ export const apiOwnershipSummary: ServerBannerRow[] = [ * 24 24 * -------------------------- */ export const apiYearIndex: ServerBannerRow[] = [ - bannerRow(26, "사례수", 2000), - bannerRow(26, "26", 15), - bannerRow(25, "25", 14), - bannerRow(24, "24", 13), + bannerRow("26", "사례수", "2000"), + bannerRow("26", "26", "15"), + bannerRow("25", "25", "14"), + bannerRow("24", "24", "13"), ]; /** --------------------------- @@ -315,21 +315,21 @@ export const apiYearIndex: ServerBannerRow[] = [ * 25/26 사례수 + 브랜드 * -------------------------- */ export const apiBrandShareByYear: ServerBannerRow[] = [ - bannerRow(25, "사례수", 500), - bannerRow(25, "lg", 48), - bannerRow(25, "삼성", 40), - bannerRow(25, "위니아", 4), - bannerRow(25, "캐리어", 3), - bannerRow(25, "하이얼", 1), - bannerRow(25, "기타", 4), + bannerRow("25", "사례수", "500"), + bannerRow("25", "lg", "48"), + bannerRow("25", "삼성", "40"), + bannerRow("25", "위니아", "4"), + bannerRow("25", "캐리어", "3"), + bannerRow("25", "하이얼", "1"), + bannerRow("25", "기타", "4"), - bannerRow(26, "사례수", 520), - bannerRow(26, "lg", 47), - bannerRow(26, "삼성", 40), - bannerRow(26, "위니아", 5), - bannerRow(26, "캐리어", 3), - bannerRow(26, "하이얼", 1), - bannerRow(26, "기타", 4), + bannerRow("26", "사례수", "520"), + bannerRow("26", "lg", "47"), + bannerRow("26", "삼성", "40"), + bannerRow("26", "위니아", "5"), + bannerRow("26", "캐리어", "3"), + bannerRow("26", "하이얼", "1"), + bannerRow("26", "기타", "4"), ]; /** --------------------------- @@ -338,21 +338,21 @@ export const apiBrandShareByYear: ServerBannerRow[] = [ * 25/26 사례수 + 도어 타입 * -------------------------- */ export const apiFridgeDoorTypeByYear: ServerBannerRow[] = [ - bannerRow(25, "사례수", 480), - bannerRow(25, "1도어", 5), - bannerRow(25, "2도어 상 냉동+하 냉장", 22), - bannerRow(25, "2도어 상 냉장+하 냉동", 8), - bannerRow(25, "2도어 양문형", 36), - bannerRow(25, "4도어", 28), - bannerRow(25, "기타", 1), + bannerRow("25", "사례수", "480"), + bannerRow("25", "1도어", "5"), + bannerRow("25", "2도어 상 냉동+하 냉장", "22"), + bannerRow("25", "2도어 상 냉장+하 냉동", "8"), + bannerRow("25", "2도어 양문형", "36"), + bannerRow("25", "4도어", "28"), + bannerRow("25", "기타", "1"), - bannerRow(26, "사례수", 500), - bannerRow(26, "1도어", 5), - bannerRow(26, "2도어 상 냉동+하 냉장", 23), - bannerRow(26, "2도어 상 냉장+하 냉동", 12), - bannerRow(26, "2도어 양문형", 35), - bannerRow(26, "4도어", 25), - bannerRow(26, "기타", 0), + bannerRow("26", "사례수", "500"), + bannerRow("26", "1도어", "5"), + bannerRow("26", "2도어 상 냉동+하 냉장", "23"), + bannerRow("26", "2도어 상 냉장+하 냉동", "12"), + bannerRow("26", "2도어 양문형", "35"), + bannerRow("26", "4도어", "25"), + bannerRow("26", "기타", "0"), ]; /** --------------------------- @@ -361,41 +361,41 @@ export const apiFridgeDoorTypeByYear: ServerBannerRow[] = [ * 25/26 사례수 + 보유 경로(구매 경로) * -------------------------- */ export const apiOwnershipPathByYear: ServerBannerRow[] = [ - bannerRow(25, "사례수", 520), - bannerRow(25, "신규 구입", 8), - bannerRow(25, "기존 제품 작동하나 신규 구입", 4), - bannerRow(25, "기존 제품 고장으로 신규 구입", 40), - bannerRow(25, "추가 구입", 48), + bannerRow("25", "사례수", "520"), + bannerRow("25", "신규 구입", "8"), + bannerRow("25", "기존 제품 작동하나 신규 구입", "4"), + bannerRow("25", "기존 제품 고장으로 신규 구입", "40"), + bannerRow("25", "추가 구입", "48"), - bannerRow(26, "사례수", 540), - bannerRow(26, "신규 구입", 8), - bannerRow(26, "기존 제품 작동하나 신규 구입", 4), - bannerRow(26, "기존 제품 고장으로 신규 구입", 40), - bannerRow(26, "추가 구입", 48), + bannerRow("26", "사례수", "540"), + bannerRow("26", "신규 구입", "8"), + bannerRow("26", "기존 제품 작동하나 신규 구입", "4"), + bannerRow("26", "기존 제품 고장으로 신규 구입", "40"), + bannerRow("26", "추가 구입", "48"), ]; export const apiOwnershipTriggerByYear: ServerBannerRow[] = [ - bannerRow(25, "사례수", 520), - bannerRow(25, "오래되어 새로운 제품 교체 필요", 23), - bannerRow(25, "이사로 인해 새로 구입", 22), - bannerRow(25, "이전 제품 고장으로 새로 구입", 17), - bannerRow(25, "새로운 기능/기술 사용하고 싶어서", 14), - bannerRow(25, "리모델링, 인테리어 계기로 새로 구입", 7), - bannerRow(25, "혼수로 장만", 7), - bannerRow(25, "(결혼 외) 가구 분가/독립하게 되어서", 6), - bannerRow(25, "가구 구성원이 늘어서", 3), - bannerRow(25, "가구 구성원이 줄어서", 2), + bannerRow("25", "사례수", "520"), + bannerRow("25", "오래되어 새로운 제품 교체 필요", "23"), + bannerRow("25", "이사로 인해 새로 구입", "22"), + bannerRow("25", "이전 제품 고장으로 새로 구입", "17"), + bannerRow("25", "새로운 기능/기술 사용하고 싶어서", "14"), + bannerRow("25", "리모델링, 인테리어 계기로 새로 구입", "7"), + bannerRow("25", "혼수로 장만", "7"), + bannerRow("25", "(결혼 외) 가구 분가/독립하게 되어서", "6"), + bannerRow("25", "가구 구성원이 늘어서", "3"), + bannerRow("25", "가구 구성원이 줄어서", '2'), - bannerRow(26, "사례수", 540), - bannerRow(26, "오래되어 새로운 제품 교체 필요", 23), - bannerRow(26, "이사로 인해 새로 구입", 22), - bannerRow(26, "이전 제품 고장으로 새로 구입", 17), - bannerRow(26, "새로운 기능/기술 사용하고 싶어서", 14), - bannerRow(26, "리모델링, 인테리어 계기로 새로 구입", 7), - bannerRow(26, "혼수로 장만", 7), - bannerRow(26, "(결혼 외) 가구 분가/독립하게 되어서", 6), - bannerRow(26, "가구 구성원이 늘어서", 3), - bannerRow(26, "가구 구성원이 줄어서", 2), + bannerRow("26", "사례수", "540"), + bannerRow("26", "오래되어 새로운 제품 교체 필요", "23"), + bannerRow("26", "이사로 인해 새로 구입", "22"), + bannerRow("26", "이전 제품 고장으로 새로 구입", "17"), + bannerRow("26", "새로운 기능/기술 사용하고 싶어서", "14"), + bannerRow("26", "리모델링, 인테리어 계기로 새로 구입", "7"), + bannerRow("26", "혼수로 장만", "7"), + bannerRow("26", "(결혼 외) 가구 분가/독립하게 되어서", "6"), + bannerRow("26", "가구 구성원이 늘어서", "3"), + bannerRow("26", "가구 구성원이 줄어서", "2"), ]; /** --------------------------- @@ -404,15 +404,15 @@ export const apiOwnershipTriggerByYear: ServerBannerRow[] = [ * 25/26 결제수단 * -------------------------- */ export const apiPaymentMethodByYear: ServerBannerRow[] = [ - bannerRow(25, "사례수", 650), - bannerRow(25, "일시불", 60), - bannerRow(25, "할부", 30), - bannerRow(25, "렌탈", 10), + bannerRow("25", "사례수", "650"), + bannerRow("25", "일시불", "60"), + bannerRow("25", "할부", "30"), + bannerRow("25", "렌탈", "10"), - bannerRow(26, "사례수", 650), - bannerRow(26, "일시불", 58), - bannerRow(26, "할부", 32), - bannerRow(26, "렌탈", 10), + bannerRow("26", "사례수", "650"), + bannerRow("26", "일시불", "58"), + bannerRow("26", "할부", "32"), + bannerRow("26", "렌탈", "10"), ]; /** --------------------------- @@ -421,19 +421,19 @@ export const apiPaymentMethodByYear: ServerBannerRow[] = [ * 26 사례수 / 구매율 / gap * -------------------------- */ export const apiPurchaseRateKpis: ServerBannerRow[] = [ - bannerRow(26, "사례수", 700), - bannerRow(26, "구매율", 35), - bannerRow(26, "gap", 2), // 26-25 + bannerRow("26", "사례수", "700"), + bannerRow("26", "구매율", "35"), + bannerRow("26", "gap", "2"), // 26-25 ]; export const apiPurchaseChannelSummaryByYear: ServerBannerRow[] = [ - bannerRow(25, "사례수", 650), - bannerRow(25, "오프라인", 60), - bannerRow(25, "온라인/홈쇼핑", 40), + bannerRow("25", "사례수", "650"), + bannerRow("25", "오프라인", "60"), + bannerRow("25", "온라인/홈쇼핑", "40"), - bannerRow(26, "사례수", 650), - bannerRow(26, "오프라인", 59), - bannerRow(26, "온라인/홈쇼핑", 41), + bannerRow("26", "사례수", "650"), + bannerRow("26", "오프라인", "59"), + bannerRow("26", "온라인/홈쇼핑", "41"), ] /** --------------------------- @@ -442,33 +442,33 @@ export const apiPurchaseChannelSummaryByYear: ServerBannerRow[] = [ * 25/26 사례수 + 유통채널 * -------------------------- */ export const apiPurchaseChannelByYear: ServerBannerRow[] = [ - bannerRow(25, "사례수", 650), - bannerRow(25, "오프라인 단독 매장", 25), - bannerRow(25, "전자제품 양판점", 20), - bannerRow(25, "대형할인점", 10), - bannerRow(25, "백화점", 5), - bannerRow(25, "오픈마켓", 15), - bannerRow(25, "제조사 공식 홈페이지", 8), - bannerRow(25, "포털 쇼핑채널 입점몰", 4), - bannerRow(25, "백화점 기반 쇼핑몰", 2), - bannerRow(25, "TV 홈쇼핑", 3), - bannerRow(25, "유통사 온라인 쇼핑몰", 4), - bannerRow(25, "라이프스타일 쇼핑몰", 2), - bannerRow(25, "해외 직구/대행 사이트", 1), - bannerRow(25, "중고거래 사이트", 1), + bannerRow("25", "사례수", "650"), + bannerRow("25", "오프라인 단독 매장", "25"), + bannerRow("25", "전자제품 양판점", "20"), + bannerRow("25", "대형할인점", "10"), + bannerRow("25", "백화점", "5"), + bannerRow("25", "오픈마켓", "15"), + bannerRow("25", "제조사 공식 홈페이지", "8"), + bannerRow("25", "포털 쇼핑채널 입점몰", "4"), + bannerRow("25", "백화점 기반 쇼핑몰", "2"), + bannerRow("25", "TV 홈쇼핑", "3"), + bannerRow("25", "유통사 온라인 쇼핑몰", "4"), + bannerRow("25", "라이프스타일 쇼핑몰", "2"), + bannerRow("25", "해외 직구/대행 사이트", "1"), + bannerRow("25", "중고거래 사이트", "1"), - bannerRow(26, "사례수", 680), - bannerRow(26, "오프라인 단독 매장", 24), - bannerRow(26, "전자제품 양판점", 20), - bannerRow(26, "대형할인점", 10), - bannerRow(26, "백화점", 5), - bannerRow(26, "오픈마켓", 16), - bannerRow(26, "제조사 공식 홈페이지", 9), - bannerRow(26, "포털 쇼핑채널 입점몰", 4), - bannerRow(26, "백화점 기반 쇼핑몰", 2), - bannerRow(26, "TV 홈쇼핑", 3), - bannerRow(26, "유통사 온라인 쇼핑몰", 3), - bannerRow(26, "라이프스타일 쇼핑몰", 2), - bannerRow(26, "해외 직구/대행 사이트", 1), - bannerRow(26, "중고거래 사이트", 1), + bannerRow("26", "사례수", "680"), + bannerRow("26", "오프라인 단독 매장", "24"), + bannerRow("26", "전자제품 양판점", "20"), + bannerRow("26", "대형할인점", "10"), + bannerRow("26", "백화점", "5"), + bannerRow("26", "오픈마켓", "16"), + bannerRow("26", "제조사 공식 홈페이지", "9"), + bannerRow("26", "포털 쇼핑채널 입점몰", "4"), + bannerRow("26", "백화점 기반 쇼핑몰", "2"), + bannerRow("26", "TV 홈쇼핑", "3"), + bannerRow("26", "유통사 온라인 쇼핑몰", "3"), + bannerRow("26", "라이프스타일 쇼핑몰", "2"), + bannerRow("26", "해외 직구/대행 사이트", "1"), + bannerRow("26", "중고거래 사이트", "1"), ]; \ No newline at end of file diff --git a/src/const/lgConst.ts b/src/const/lgConst.ts index 57879b3..ad88c1b 100644 --- a/src/const/lgConst.ts +++ b/src/const/lgConst.ts @@ -1,4 +1,5 @@ -import {BannerKey} from "@/types/lg"; +import {BannerKey, LifeStageRow} from "@/types/lg"; +import {GaugeColumn} from "@/components/lge-dashboard"; export const PRODUCT_KEY_MAP = { washingMachine: "세탁기", @@ -91,9 +92,29 @@ export const BANNER_KEY_MAP = { income900Plus: "900만원 이상", } as const; +export const LIFE_STAGE_COLUMNS: GaugeColumn[] = [ + { key: "item", header: "", headRowSpan:2, rowHead: true, render: (r) => r.item }, + + { key: "total", header: "전체", headRowSpan:2, max: 100, align: "left", cellType:"number"}, + { key: "single", header: "미혼", max: 100 , align: "left"}, + + { key: "noKids", header: "무자녀", group: "기혼", max: 100 , align: "left"}, + { key: "preschoolKids", header: "미취학", group: "기혼", max: 100 , align: "left"}, + { key: "schoolKids", header: "취학자녀", group: "기혼", max: 100 , align: "left"}, + { key: "adultKids", header: "성인자녀", group: "기혼", max: 100 , align: "left"}, + + { key: "independentSenior", header: "독립\n시니어", max: 100 , align: "left"}, +]; + +export const LIFE_STAGE_GROUPS = [ + { title: "대형가전 군", items: ["냉장고", "세탁기", "건조기", "에어컨", "TV", "김치 냉장고", "식기세척기", "의류 관리기"] }, + { title: "소형가전 군", items: ["청소기", "공기 청정기", "정수기"] }, + { title: "신가전 군", items: ["로봇 청소기", "음식물처리기"] }, +] as const; + export const PRODUCT_KEYS = Object.keys(PRODUCT_KEY_MAP) as Array; export const PRODUCTS = Object.values(PRODUCT_KEY_MAP) as Array; -export const YEARS = [24, 25, 26]; +export const YEARS = ["24", "25", "26"]; export const LAST_YEAR = YEARS.at(-1); export const BRAND_LIST = ['Cbrand', 'Samsung', 'LG']; diff --git a/src/lib/lg-dashboard.ts b/src/lib/lg-dashboard.ts index 0bc9e7b..b3284f2 100644 --- a/src/lib/lg-dashboard.ts +++ b/src/lib/lg-dashboard.ts @@ -174,7 +174,7 @@ type Opts = { /** 기본: ["사례수", "gap"] 제외 */ excludeRowLabels?: string[]; /** 기본: (y) => `${y}년` */ - yearLabel?: (y: number) => string; + yearLabel?: (y: string) => string; /** StackBar에 넣을 때 "스택 방지"용(연도별 stack 분리) */ splitStackByYear?: boolean; }; @@ -186,7 +186,7 @@ export function buildYearSeriesChartData(rows: ServerBannerRow[], opts: Opts = { splitStackByYear = false, } = opts; - const years = Array.from(new Set(rows.map((r) => r.year))).sort((a, b) => a - b); + const years = Array.from(new Set(rows.map((r) => r.year))).sort((a, b) => Number(a) - Number(b)); // rowLabel 순서: 첫 연도 기준으로 고정(없으면 전체 unique) const baseYear = years[0]; @@ -203,7 +203,7 @@ export function buildYearSeriesChartData(rows: ServerBannerRow[], opts: Opts = { ); // 빠른 조회용: year -> (rowLabel -> total) - const map = new Map>(); + const map = new Map>(); for (const y of years) map.set(y, new Map()); for (const r of rows) { if (excludeRowLabels.includes(r.rowLabel)) continue; @@ -229,7 +229,7 @@ export function buildRowLabelSeriesChartData( yearLabel = (y) => `${y}년`, } = opts; - const years = Array.from(new Set(rows.map((r) => r.year))).sort((a, b) => a - b); + const years = Array.from(new Set(rows.map((r) => r.year))).sort((a, b) => Number(a) - Number(b)); const categories = years.map(yearLabel); const baseYear = years[0]; @@ -246,7 +246,7 @@ export function buildRowLabelSeriesChartData( ); // (year -> (rowLabel -> total)) 맵 - const valueMap = new Map>(); + const valueMap = new Map>(); for (const y of years) valueMap.set(y, new Map()); for (const r of rows) { @@ -270,14 +270,14 @@ export const buildGapRow = ( baseRowLabel: string, gapRowLabel = "gap" ): ServerBannerRow | null => { - const prev = rows.find(r => r.year === prevYear && r.rowLabel === baseRowLabel); - const cur = rows.find(r => r.year === curYear && r.rowLabel === baseRowLabel); + const prev = rows.find(r => Number(r.year) === prevYear && r.rowLabel === baseRowLabel); + const cur = rows.find(r => Number(r.year) === curYear && r.rowLabel === baseRowLabel); if (!prev || !cur) return null; const gap: ServerBannerRow = { - year: curYear, + year: String(curYear), rowLabel: gapRowLabel, - total: (typeof cur.total === "number" ? cur.total : 0) - (typeof prev.total === "number" ? prev.total : 0), + total: String(Number(cur.total) - Number(prev.total)), }; // cur가 가진 모든 key를 돌면서 "숫자 필드"면 diff 계산 @@ -287,10 +287,7 @@ export const buildGapRow = ( const vCur = cur[k]; const vPrev = prev[k]; - const hasNumber = typeof vCur === "number" || typeof vPrev === "number"; - if (!hasNumber) return; - - (gap as any)[k] = (typeof vCur === "number" ? vCur : 0) - (typeof vPrev === "number" ? vPrev : 0); + (gap as any)[k] = String(Number(vCur) - Number(vPrev)); }); return gap; diff --git a/src/lib/lg-export-excel.ts b/src/lib/lg-export-excel.ts new file mode 100644 index 0000000..8b11310 --- /dev/null +++ b/src/lib/lg-export-excel.ts @@ -0,0 +1,831 @@ +// exportDashboardExcel.ts +"use client"; + +import {formatRowLabel, isSampleRow} from "@/lib/lg-dashboard"; +import {DataColumn} from "@/components/lge-dashboard"; + +/** + * 요구사항: + * - 한 파일에 (1) PRODUCT_KEY_MAP 헤더, (2) LIFE_STAGE_COLUMNS 헤더(그룹 머지), (3) BANNER_GROUP 헤더(좌측 2칸 rowspan2 + 그룹 머지) + * - Excel export (한 시트, 섹션 간 1행 띄움) + * - 헤더 스타일: + * group: background = --lg-gray-400 + * header: background = --lg-gray-600 + * font: #fff, bold + */ + +type HeaderStyleKey = "group" | "header"; + +type HeaderCell = { + text: string; + styleKey: HeaderStyleKey; + rowSpan?: number; // default 1 + colSpan?: number; // default 1 + align?: "left" | "center" | "right"; +}; + +type HeaderBlock = { + headerRows: HeaderCell[][]; + leafKeys: string[]; // 실제 데이터 컬럼 key 순서(좌->우) + totalCols: number; +}; + +export type Section> = { + title?: string; + header: HeaderBlock; + rows: T[]; + rowGap?: number; // default 1 + // 옵션 + colWidthByKey?: Record; + numFmtByKey?: Record; // 예: "#,##0", "0.0", "0%" + alignByKey?: Record; + valueGetter?: (row: T, key: string) => any; +}; + +type ExportOptions> = { + fileName?: string; + sheetName?: string; + sections: Section[]; + // CSS 변수(없으면 기본값) + groupBgVar?: string; // default "--lg-gray-400" + headerBgVar?: string; // default "--lg-gray-600" + borderVar?: string; // default "--lg-gray-300" +}; + +/* ========================================================= + * 0) Object.entries 타입 보존 + * ========================================================= */ +const typedEntries = >(obj: T) => + Object.entries(obj) as Array<[keyof T, T[keyof T]]>; + +/* ========================================================= + * 1) CSS var -> Excel ARGB (HSL 토큰 "H S% L%" 지원) + * ========================================================= */ +type RGB = { r: number; g: number; b: number }; + +function clamp255(n: number) { + return Math.max(0, Math.min(255, Math.round(n))); +} + +function hslTokenToRgb(token: string): RGB | null { + const m = token.trim().match(/^([\d.]+)\s+([\d.]+)%\s+([\d.]+)%$/); + if (!m) return null; + const h = parseFloat(m[1]) % 360; + const s = parseFloat(m[2]) / 100; + const l = parseFloat(m[3]) / 100; + + const C = (1 - Math.abs(2 * l - 1)) * s; + const hh = h / 60; + const X = C * (1 - Math.abs((hh % 2) - 1)); + + let r1 = 0, g1 = 0, b1 = 0; + if (0 <= hh && hh < 1) [r1, g1, b1] = [C, X, 0]; + else if (1 <= hh && hh < 2) [r1, g1, b1] = [X, C, 0]; + else if (2 <= hh && hh < 3) [r1, g1, b1] = [0, C, X]; + else if (3 <= hh && hh < 4) [r1, g1, b1] = [0, X, C]; + else if (4 <= hh && hh < 5) [r1, g1, b1] = [X, 0, C]; + else if (5 <= hh && hh < 6) [r1, g1, b1] = [C, 0, X]; + + const m2 = l - C / 2; + return { + r: clamp255((r1 + m2) * 255), + g: clamp255((g1 + m2) * 255), + b: clamp255((b1 + m2) * 255), + }; +} + +function hexToRgb(hex: string): RGB | null { + const v = hex.trim(); + if (!v.startsWith("#")) return null; + const h = v.slice(1); + const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h; + if (full.length !== 6) return null; + return { + r: parseInt(full.slice(0, 2), 16), + g: parseInt(full.slice(2, 4), 16), + b: parseInt(full.slice(4, 6), 16), + }; +} + +function rgbToArgb(rgb: RGB) { + const toHex2 = (n: number) => n.toString(16).padStart(2, "0").toUpperCase(); + return `FF${toHex2(rgb.r)}${toHex2(rgb.g)}${toHex2(rgb.b)}`; +} + +function cssVarToExcelArgb(varName: string, fallbackHex = "#DDDDDD") { + const raw = getComputedStyle(document.documentElement).getPropertyValue(varName).trim(); + const rgb = hslTokenToRgb(raw) ?? hexToRgb(raw) ?? hexToRgb(fallbackHex)!; + return rgbToArgb(rgb); +} + +/* ========================================================= + * 2) 헤더 렌더러 (row/col merge + 스타일) + * ========================================================= */ +type StylePack = { + groupBg: string; // ARGB + headerBg: string; // ARGB + headerFont: string; // ARGB (white) + border: string; // ARGB +}; + +function writeMergedHeader( + ws: any, // ExcelJS.Worksheet + startRow: number, + headerRows: HeaderCell[][], + styles: StylePack +) { + const occupied = new Set(); // "r,c" (0-based within header block) + const isOcc = (r: number, c: number) => occupied.has(`${r},${c}`); + const markOcc = (r: number, c: number) => occupied.add(`${r},${c}`); + + const styleOf = (styleKey: HeaderStyleKey) => { + const bg = styleKey === "group" ? styles.groupBg : styles.headerBg; + return { + fill: { type: "pattern", pattern: "solid", fgColor: { argb: bg } }, + font: { color: { argb: styles.headerFont }, bold: true }, + alignment: { vertical: "middle", wrapText: true }, + border: { + top: { style: "thin", color: { argb: styles.border } }, + left: { style: "thin", color: { argb: styles.border } }, + bottom: { style: "thin", color: { argb: styles.border } }, + right: { style: "thin", color: { argb: styles.border } }, + }, + }; + }; + + const applyStyleRange = (r1: number, c1: number, r2: number, c2: number, st: any) => { + for (let rr = r1; rr <= r2; rr++) { + const row = ws.getRow(rr); + for (let cc = c1; cc <= c2; cc++) { + const cell = row.getCell(cc); + cell.style = { ...(cell.style ?? {}), ...st }; + } + } + }; + + for (let hr = 0; hr < headerRows.length; hr++) { + const rowCells = headerRows[hr]; + let colCursor = 0; + + for (const hc of rowCells) { + const rs = hc.rowSpan ?? 1; + const cs = hc.colSpan ?? 1; + + while (isOcc(hr, colCursor)) colCursor++; + + const topRow = startRow + hr; + const leftCol = colCursor + 1; // excel 1-based + const bottomRow = topRow + rs - 1; + const rightCol = leftCol + cs - 1; + + const cell = ws.getRow(topRow).getCell(leftCol); + cell.value = hc.text; + + const st = styleOf(hc.styleKey); + const horiz = hc.align ?? "center"; + cell.alignment = { ...(st.alignment ?? {}), horizontal: horiz }; + + if (rs > 1 || cs > 1) ws.mergeCells(topRow, leftCol, bottomRow, rightCol); + + applyStyleRange(topRow, leftCol, bottomRow, rightCol, { + ...st, + alignment: { ...(st.alignment ?? {}), horizontal: horiz }, + }); + + for (let r = hr; r < hr + rs; r++) { + for (let c = colCursor; c < colCursor + cs; c++) { + markOcc(r, c); + } + } + + colCursor += cs; + } + + ws.getRow(startRow + hr).height = 20; + } + + return startRow + headerRows.length; +} + +type AutoFitOpt = { + minColWidth?: number; // Excel column width units + maxColWidth?: number; + padding?: number; // width 여유(문자수 기준) + baseRowHeight?: number; // pt + maxRowHeight?: number; // pt + useCanvasMeasure?: boolean; // 브라우저에서 measureText로 더 정확하게 +}; + +function autoFitApprox(ws: any, opt: AutoFitOpt = {}) { + const o: Required = { + minColWidth: opt.minColWidth ?? 8, + maxColWidth: opt.maxColWidth ?? 60, + padding: opt.padding ?? 2, + baseRowHeight: opt.baseRowHeight ?? 15, + maxRowHeight: opt.maxRowHeight ?? 120, + useCanvasMeasure: opt.useCanvasMeasure ?? true, + }; + + // 1) 머지 정보(내부 필드 사용: ExcelJS에서 공식 API가 없어서 근사 구현용) + const mergeMap = buildMergeMap(ws); + + // 2) 컬럼 폭 먼저 계산 + fitColumns(ws, mergeMap, o); + + // 3) 그 다음 row height 계산 (wrapText/줄바꿈 고려) + fitRows(ws, mergeMap, o); +} + +/* --------------------------- + * Column fit + * --------------------------- */ + +function fitColumns(ws: any, mergeMap: Map, o: Required) { + const colCount = ws.columnCount ?? (ws.columns?.length ?? 0); + const widths = new Array(colCount + 1).fill(o.minColWidth); + + ws.eachRow({ includeEmpty: false }, (row: any) => { + row.eachCell({ includeEmpty: false }, (cell: any, colNumber: number) => { + const text = getCellText(cell); + if (!text) return; + + // merged cell의 "master"만 처리 (중복 방지) + const masterAddr = getMasterAddress(cell); + const mi = mergeMap.get(masterAddr); + if (mi && cell.address !== masterAddr) return; + + const w = estimateWidth(text, cell, o); // width in "excel-char-like units" + + if (mi && mi.colSpan > 1) { + // 머지된 텍스트는 span만큼 나눠서 분배(머지 텍스트 때문에 한 컬럼이 과대해지는 현상 방지) + const perCol = w / mi.colSpan; + for (let c = mi.leftCol; c <= mi.rightCol; c++) { + widths[c] = Math.max(widths[c], perCol); + } + } else { + widths[colNumber] = Math.max(widths[colNumber], w); + } + }); + }); + + for (let c = 1; c <= colCount; c++) { + const w = clamp(widths[c] + o.padding, o.minColWidth, o.maxColWidth); + ws.getColumn(c).width = w; + } +} + +/* --------------------------- + * Row fit + * --------------------------- */ + +function fitRows(ws: any, mergeMap: Map, o: Required) { + ws.eachRow({ includeEmpty: false }, (row: any) => { + let maxLines = 1; + + row.eachCell({ includeEmpty: false }, (cell: any, colNumber: number) => { + const text = getCellText(cell); + if (!text) return; + + const masterAddr = getMasterAddress(cell); + const mi = mergeMap.get(masterAddr); + if (mi && cell.address !== masterAddr) return; + + const wrap = !!cell.alignment?.wrapText; + const explicitLines = text.split(/\r?\n/); + + if (!wrap && explicitLines.length <= 1) return; + + // 해당 셀의 사용 가능한 폭(머지면 합산) + const availableWidth = mi + ? sumColumnWidth(ws, mi.leftCol, mi.rightCol, o) + : getColumnWidth(ws, colNumber, o); + + // 각 라인 별로 "줄바꿈이 몇 줄로 늘어나는지" 근사 + let cellLines = 0; + for (const line of explicitLines) { + const lineW = estimateWidth(line, cell, o); + const needed = Math.max(1, Math.ceil(lineW / Math.max(1, availableWidth))); + cellLines += needed; + } + + maxLines = Math.max(maxLines, cellLines); + }); + + const h = clamp(o.baseRowHeight * maxLines, o.baseRowHeight, o.maxRowHeight); + row.height = Math.max(row.height, h); + }); +} + +/* --------------------------- + * Width estimation + * --------------------------- */ + +function estimateWidth(text: string, cell: any, o: Required) { + // 줄바꿈이면 가장 긴 라인 기준(컬럼 폭은 max line) + const lines = text.split(/\r?\n/); + const maxLine = lines.reduce((m, s) => (s.length > m.length ? s : m), ""); + + if (o.useCanvasMeasure && typeof document !== "undefined") { + const px = measureTextPx(maxLine, cell); + // Excel column width 단위는 폰트마다 다르지만 Calibri 11 기준으로 px/7 정도가 근사치로 많이 씀 + return px / 7; + } + + // canvas 못 쓰는 환경(또는 성능 이유) -> 문자폭 가중치 근사 + return estimateByCharWeight(maxLine); +} + +function measureTextPx(text: string, cell: any) { + const canvas = getMeasureCanvas(); + const ctx = canvas.getContext("2d")!; + const fontName = cell.font?.name ?? "Calibri"; + const size = cell.font?.size ?? 11; + const bold = cell.font?.bold ? "bold " : ""; + ctx.font = `${bold}${size}pt ${fontName}`; + return ctx.measureText(text).width; +} + +let __canvas: HTMLCanvasElement | null = null; +function getMeasureCanvas() { + if (!__canvas) __canvas = document.createElement("canvas"); + return __canvas; +} + +// 한글/중국어/일본어 등 wide char 가중치 + 숫자/영문 가중치 +function estimateByCharWeight(s: string) { + let w = 0; + for (const ch of s) { + if (isWideChar(ch)) w += 1.7; // 한글/한자/가나 등 + else if (ch === " ") w += 0.6; + else if (/[A-Z]/.test(ch)) w += 1.1; + else if (/[0-9]/.test(ch)) w += 1.0; + else w += 0.9; + } + return w; +} + +function isWideChar(ch: string) { + const code = ch.codePointAt(0) ?? 0; + // 대략적인 CJK 범위 + return ( + (code >= 0x1100 && code <= 0x11ff) || // Hangul Jamo + (code >= 0x2e80 && code <= 0x9fff) || // CJK, radicals + (code >= 0xac00 && code <= 0xd7af) || // Hangul syllables + (code >= 0x3040 && code <= 0x30ff) || // Hiragana/Katakana + (code >= 0xff00 && code <= 0xffef) // Fullwidth forms + ); +} + +/* --------------------------- + * Helpers: cell text + * --------------------------- */ + +function getCellText(cell: any): string { + const v = cell?.value; + if (v === null || v === undefined) return ""; + + if (typeof v === "string") return v; + if (typeof v === "number" || typeof v === "boolean") return String(v); + if (v instanceof Date) return v.toISOString().slice(0, 10); + + // ExcelJS value object types + if (typeof v === "object") { + if (v.richText) return v.richText.map((t: any) => t.text).join(""); + if (v.text) return String(v.text); + if (v.formula) return v.result != null ? String(v.result) : ""; + if (v.hyperlink) return String(v.text ?? v.hyperlink); + } + + return String(v); +} + +function getMasterAddress(cell: any) { + // merged cell이면 master가 존재 + if (cell?.isMerged && cell?.master?.address) return cell.master.address; + return cell.address; +} + +/* --------------------------- + * Helpers: widths + * --------------------------- */ + +function getColumnWidth(ws: any, col: number, o: Required) { + const w = ws.getColumn(col)?.width; + return typeof w === "number" ? w : o.minColWidth; +} + +function sumColumnWidth(ws: any, left: number, right: number, o: Required) { + let sum = 0; + for (let c = left; c <= right; c++) sum += getColumnWidth(ws, c, o); + return sum; +} + +function clamp(v: number, min: number, max: number) { + return Math.max(min, Math.min(max, v)); +} + +/* --------------------------- + * Merge map (internal _merges parsing) + * --------------------------- */ + +type MergeInfo = { + leftCol: number; + rightCol: number; + topRow: number; + bottomRow: number; + colSpan: number; +}; + +function buildMergeMap(ws: any) { + const map = new Map(); + + const merges = ws?._merges; + if (!merges) return map; + + // ws._merges: Map 형태인 경우가 많음. key가 "A1:C1" 같은 range + const keys: string[] = + merges instanceof Map ? Array.from(merges.keys()) : Object.keys(merges); + + for (const range of keys) { + const parsed = parseRange(range); + if (!parsed) continue; + + const masterAddr = toA1(parsed.leftCol, parsed.topRow); + map.set(masterAddr, { + ...parsed, + colSpan: parsed.rightCol - parsed.leftCol + 1, + }); + } + + return map; +} + +// "A1:C3" -> 좌표 +function parseRange(range: string): Omit | null { + const parts = range.split(":"); + if (parts.length !== 2) return null; + const a = parseA1(parts[0]); + const b = parseA1(parts[1]); + if (!a || !b) return null; + + return { + leftCol: Math.min(a.col, b.col), + rightCol: Math.max(a.col, b.col), + topRow: Math.min(a.row, b.row), + bottomRow: Math.max(a.row, b.row), + }; +} + +function parseA1(a1: string): { col: number; row: number } | null { + const m = a1.match(/^([A-Z]+)(\d+)$/i); + if (!m) return null; + const col = lettersToCol(m[1].toUpperCase()); + const row = parseInt(m[2], 10); + return { col, row }; +} + +function lettersToCol(letters: string) { + let n = 0; + for (const ch of letters) { + n = n * 26 + (ch.charCodeAt(0) - 64); + } + return n; +} + +function toA1(col: number, row: number) { + return `${colToLetters(col)}${row}`; +} + +function colToLetters(col: number) { + let n = col; + let s = ""; + while (n > 0) { + const r = (n - 1) % 26; + s = String.fromCharCode(65 + r) + s; + n = Math.floor((n - 1) / 26); + } + return s; +} + +/* ========================================================= + * 3) 헤더 빌더 3종 + * ========================================================= */ + +/** + * (1) PRODUCT_KEY_MAP: + * - 첫 칸 비움 + * - 나머지는 일반 헤더 + */ +export function buildHeader_ProductKeyMap( + productKeyMap: Record, + rowHeadKey = "rowLabel" +): HeaderBlock { + const entries = typedEntries(productKeyMap); + + const headerRow: HeaderCell[] = [ + { text: "", styleKey: "header", align: "center" }, + ...entries.map(([, label]) => ({ + text: String(label), + styleKey: "header" as const, + align: "center" as const, + })), + ]; + + const leafKeys = [rowHeadKey, ...entries.map(([k]) => String(k))]; + return { headerRows: [headerRow], leafKeys, totalCols: headerRow.length }; +} + +/** + * (2) LIFE_STAGE_COLUMNS: + * - 1행: group 머지(같은 group 연속 구간) + * - 2행: header 텍스트 + * + * group 없는 컬럼은 1행에 빈 셀(그룹 스타일) 1칸 채움 + */ +export type GaugeColumn = { + key: string; + header: string; + rowHead?: boolean; + group?: string; + align?: "left" | "center" | "right"; +}; + +export function buildHeader_LifeStageColumns(cols: GaugeColumn[]): HeaderBlock { + const row1: HeaderCell[] = []; + const row2: HeaderCell[] = []; + const leafKeys = cols.map((c) => c.key); + + let i = 0; + while (i < cols.length) { + const c = cols[i]; + const g = c.group; + + if (!g) { + row1.push({ text: "", styleKey: "group", colSpan: 1, align: "center" }); + i += 1; + continue; + } + + let j = i + 1; + while (j < cols.length && cols[j].group === g) j += 1; + const span = j - i; + + row1.push({ text: g, styleKey: "group", colSpan: span, align: "center" }); + i = j; + } + + for (const c of cols) { + row2.push({ text: c.header ?? "", styleKey: "header", colSpan: 1, align: "center" }); + } + + return { headerRows: [row1, row2], leafKeys, totalCols: cols.length }; +} + +export function buildHeader_DataColumn(cols: DataColumn[]): HeaderBlock { + const row1: HeaderCell[] = []; + const row2: HeaderCell[] = []; + + const leafKeys = cols.map((c) => String(c.key)); + + // 1행: 그룹 머지 / rowspan 처리 + let i = 0; + while (i < cols.length) { + const c = cols[i]; + const rs = c.headRowSpan ?? 1; + + // (A) rowspan=2면: 1행에 header를 올리고(세로머지), 2행은 빈 칸(placeholder) + if (rs === 2) { + row1.push({ + text: c.header ?? "", + styleKey: "header", + colSpan: 1, + rowSpan: 2, + align: c.align ?? "center", + }); + i += 1; + continue; + } + + // (B) 그룹 구간 처리 + const gKey = c.groupKey ?? c.group; + if (gKey) { + let j = i + 1; + while (j < cols.length) { + const cj = cols[j]; + const rsj = cj.headRowSpan ?? 1; + const gKeyJ = cj.groupKey ?? cj.group; + + // rowspan=2가 섞이면 그룹 머지 끊음(안정성) + if (rsj === 2) break; + if (gKeyJ !== gKey) break; + + j += 1; + } + + const span = j - i; + + row1.push({ + text: c.group ?? "", + styleKey: "group", + colSpan: span, + align: "center", + }); + + // 2행: 그룹 구간의 각 컬럼 header + for (let k = i; k < j; k++) { + const ck = cols[k]; + row2.push({ + text: ck.header ?? "", + styleKey: "header", + colSpan: 1, + align: ck.align ?? "center", + }); + } + + i = j; + continue; + } + + // (C) 그룹도 없고 rowspan도 아니면: 1행에 빈 group 셀 1개, 2행에 header + row1.push({ + text: "", + styleKey: "group", + colSpan: 1, + align: "center", + }); + row2.push({ + text: c.header ?? "", + styleKey: "header", + colSpan: 1, + align: c.align ?? "center", + }); + i += 1; + } + + return { + headerRows: [row1, row2], + leafKeys, + totalCols: cols.length, + }; +} + +/** + * (3) BANNER_GROUP + BANNER_KEY_MAP: + * - A1: "" (rowspan2) + * - B1: "전체" (rowspan2) key=total + * - C1~: group(label) (colSpan = keys.length) + * - 2행: 각 key의 라벨(BANNER_KEY_MAP[key]) + */ +export function buildHeader_Banner( + bannerGroup: Record, + bannerKeyMap: Record, + rowHeadKey = "rowLabel", + totalKey = "total" +): HeaderBlock { + const groups = Object.values(bannerGroup); + + const row1: HeaderCell[] = [ + { text: "", styleKey: "header", rowSpan: 2, colSpan: 1, align: "center" }, + { text: "전체", styleKey: "header", rowSpan: 2, colSpan: 1, align: "center" }, + ]; + + const row2: HeaderCell[] = []; + const leafKeys: string[] = [rowHeadKey, totalKey]; + + for (const g of groups) { + row1.push({ text: g.label, styleKey: "group", colSpan: g.keys.length, align: "center" }); + + for (const k of g.keys) { + row2.push({ text: bannerKeyMap[k] ?? k, styleKey: "header", colSpan: 1, align: "center" }); + leafKeys.push(k); + } + } + + const totalCols = 2 + groups.reduce((acc, g) => acc + g.keys.length, 0); + return { headerRows: [row1, row2], leafKeys, totalCols }; +} + +/* ========================================================= + * 4) Export (one sheet, 섹션 간 1행 띄움) + * ========================================================= */ +export async function exportDashboardExcel>(opts: ExportOptions) { + const { + fileName = "export.xlsx", + sheetName = "Export", + sections, + groupBgVar = "--lg-gray-400", + headerBgVar = "--lg-gray-600", + borderVar = "--lg-gray-300", + } = opts; + + // ExcelJS import (환경에 따라 min 빌드가 더 잘 먹는 경우가 있음) + const ExcelJS = await import("exceljs"); + const wb = new ExcelJS.Workbook(); + const ws = wb.addWorksheet(sheetName); + + const stylePack: StylePack = { + groupBg: cssVarToExcelArgb(groupBgVar, "#9CA3AF"), + headerBg: cssVarToExcelArgb(headerBgVar, "#4B5563"), + headerFont: "FFFFFFFF", // #fff + border: cssVarToExcelArgb(borderVar, "#D1D5DB"), + }; + + let rowCursor = 1; + + for (const sec of sections) { + const gap = sec.rowGap ?? 1; + const { header, rows } = sec; + + // (선택) 섹션 타이틀 + if (sec.title) { + const r = ws.getRow(rowCursor); + const c = r.getCell(1); + c.value = sec.title; + c.font = { bold: true, size: 13 }; + r.height = 22; + if (header.totalCols > 1) ws.mergeCells(rowCursor, 1, rowCursor, header.totalCols); + rowCursor += 1; + } + + // 헤더 + rowCursor = writeMergedHeader(ws, rowCursor, header.headerRows, stylePack); + + // 컬럼 width + if (sec.colWidthByKey) { + header.leafKeys.forEach((k, idx) => { + const w = sec.colWidthByKey?.[k]; + if (w) ws.getColumn(idx + 1).width = w; + }); + } else { + // 기본: 첫 컬럼 넓게, 나머지 적당히 + header.leafKeys.forEach((k, idx) => { + ws.getColumn(idx + 1).width = idx === 0 ? 22 : 14; + }); + } + + const valueGetter = sec.valueGetter ?? ((r: T, k: string) => (r as any)[k]); + + // 데이터 + for (const row of rows) { + const excelRow = ws.getRow(rowCursor); + const sampleRow = isSampleRow(valueGetter(row, header.leafKeys.at(0) ?? "")); + + header.leafKeys.forEach((key, idx) => { + const cell = excelRow.getCell(idx + 1); + const v = valueGetter(row, key); + const isColHeader = idx === 0; + + if (v === null || v === undefined || v === "") cell.value = null; + else if (typeof v === "number") cell.value = v; + else if (isColHeader) cell.value = formatRowLabel(String(v)); + else if (sampleRow) cell.value = `(${String(v)})`; + else cell.value = String(v); + + const align = + sec.alignByKey?.[key] ?? + (typeof v === "number" ? "right" : "left"); + + cell.alignment = { vertical: "middle", horizontal: align, wrapText: true }; + + const numFmt = sec.numFmtByKey?.[key]; + if (numFmt) cell.numFmt = numFmt; + + cell.border = { + top: { style: "thin", color: { argb: stylePack.border } }, + left: { style: "thin", color: { argb: stylePack.border } }, + bottom: { style: "thin", color: { argb: stylePack.border } }, + right: { style: "thin", color: { argb: stylePack.border } }, + }; + + if(isColHeader){ + cell.font = { bold: true }; + } + }); + + excelRow.height = 18; + rowCursor += 1; + } + + rowCursor += gap; + } + + autoFitApprox(ws, { + minColWidth: 8, + maxColWidth: 55, + baseRowHeight: 15, + maxRowHeight: 120, + useCanvasMeasure: true, + }); + // 다운로드 + const buf = await wb.xlsx.writeBuffer(); + const blob = new Blob([buf], { + type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + }); + + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = fileName; + a.click(); + URL.revokeObjectURL(url); +} \ No newline at end of file diff --git a/src/types/lg.ts b/src/types/lg.ts index 65e1ef3..e3127f5 100644 --- a/src/types/lg.ts +++ b/src/types/lg.ts @@ -5,32 +5,37 @@ export type BannerKey = keyof typeof BANNER_KEY_MAP; export type ProductsFilterItem = (typeof PRODUCTS_FILTER_ITEM)[number]; export type ServerBaseRow = { - year: number; + year: string; rowLabel: string; - total: number; + total: string; }; // { year, rowLabel, total, ...category } -export type ServerProductRow = ServerBaseRow & Partial>; +export type ServerProductRow = ServerBaseRow & Partial>; // { year, rowLabel, total, ...banner } // (배너는 기본 41개 키 + 차트별 추가 키가 생길 수 있으니 확장 허용) export type ServerBannerRow = ServerBaseRow & - Partial> & { - [k: string]: number | string; + Partial> & { + [k: string]: string; }; export type LifeStageRow = Record & { item: string; - total: number | null; - single: number | null; - noKids: number | null; - preschoolKids: number | null; - schoolKids: number | null; - adultKids: number | null; - independentSenior: number | null; + total: string; + single: string; + noKids: string; + preschoolKids: string; + schoolKids: string; + adultKids: string; + independentSenior: string; }; +export type LifeStageGroup = { + title: string; + rows: LifeStageRow[] +} + export type BannerGroupKey = keyof typeof BANNER_GROUP; export type CategoryChartMode = "stack" | "reverseStack" | "horizontal";