From 32008f08d79191d51a14523e5497bf6d9e634f9b Mon Sep 17 00:00:00 2001 From: Nate Weller Date: Fri, 11 Oct 2024 14:50:30 -0600 Subject: [PATCH] Add ThreatsDataView Add support for list view in threats data table Minor adjustments Add badge component and integrate with threats data view Update stories and align auto-fix column Update ThreatDataView list view fixer status (#39854) Update ThreatsDataView to use js-packages IconTooltip (#39856) --- pnpm-lock.yaml | 357 +++++++++++++ .../changelog/add-threats-data-view-component | 4 + .../components/components/badge/index.tsx | 39 ++ .../badge/stories/index.stories.tsx | 22 + .../components/badge/style.module.scss | 25 + .../components/icon-tooltip/index.tsx | 30 +- .../icon-tooltip/stories/index.stories.tsx | 11 + .../components/icon-tooltip/types.ts | 5 + .../threat-severity-badge/index.tsx | 38 +- .../threats-data-views/constants.ts | 18 + .../threats-data-views/fixer-status.tsx | 154 ++++++ .../threats-data-views/icon-tooltip.tsx | 52 ++ .../components/threats-data-views/index.tsx | 505 ++++++++++++++++++ .../stories/index.stories.tsx | 362 +++++++++++++ .../threats-data-views/styles.module.scss | 124 +++++ .../threats-data-views/test/index.test.tsx | 34 ++ .../components/threats-data-views/types.d.ts | 93 ++++ .../components/threats-data-views/utils.ts | 76 +++ projects/js-packages/components/index.ts | 1 + projects/js-packages/components/package.json | 1 + .../scan/changelog/add-threat-types | 4 + .../js-packages/scan/src/types/threat.d.ts | 59 ++ .../changelog/move-components-to-package | 5 + projects/plugins/protect/tsconfig.json | 2 +- 24 files changed, 1995 insertions(+), 26 deletions(-) create mode 100644 projects/js-packages/components/changelog/add-threats-data-view-component create mode 100644 projects/js-packages/components/components/badge/index.tsx create mode 100644 projects/js-packages/components/components/badge/stories/index.stories.tsx create mode 100644 projects/js-packages/components/components/badge/style.module.scss create mode 100644 projects/js-packages/components/components/threats-data-views/constants.ts create mode 100644 projects/js-packages/components/components/threats-data-views/fixer-status.tsx create mode 100644 projects/js-packages/components/components/threats-data-views/icon-tooltip.tsx create mode 100644 projects/js-packages/components/components/threats-data-views/index.tsx create mode 100644 projects/js-packages/components/components/threats-data-views/stories/index.stories.tsx create mode 100644 projects/js-packages/components/components/threats-data-views/styles.module.scss create mode 100644 projects/js-packages/components/components/threats-data-views/test/index.test.tsx create mode 100644 projects/js-packages/components/components/threats-data-views/types.d.ts create mode 100644 projects/js-packages/components/components/threats-data-views/utils.ts create mode 100644 projects/js-packages/scan/changelog/add-threat-types create mode 100644 projects/js-packages/scan/src/types/threat.d.ts create mode 100644 projects/plugins/protect/changelog/move-components-to-package diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 573fa8ff3aeff..a3883be69e5cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -305,6 +305,9 @@ importers: '@wordpress/data': specifier: 10.9.0 version: 10.9.0(react@18.3.1) + '@wordpress/dataviews': + specifier: 4.6.0 + version: 4.6.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@wordpress/date': specifier: 5.9.0 version: 5.9.0 @@ -5680,6 +5683,10 @@ packages: resolution: {integrity: sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==} engines: {node: '>=6.9.0'} + '@babel/runtime@7.25.7': + resolution: {integrity: sha512-FjoyLe754PMiYsFaN5C94ttGiOmBNYTf6pLr4xXHAT5uctHb092PBszndLDR5XA/jghQvn4n7JMHl7dmTgbm9w==} + engines: {node: '>=6.9.0'} + '@babel/template@7.25.7': resolution: {integrity: sha512-wRwtAgI3bAS+JGU2upWNL9lSlDcRCqD05BZ1n3X2ONLH1WilFP6O1otQjeMK/1g0pvYcXC7b/qVUB1keofjtZA==} engines: {node: '>=6.9.0'} @@ -7692,6 +7699,10 @@ packages: webpack-dev-server: optional: true + '@wordpress/a11y@4.10.0': + resolution: {integrity: sha512-fp7C0Ofy95a+jzK126CxAXV+uXSFQs2Clm6PCeE9Y1BowUiL9l7juUCh1R+2NDAKATxH4r3QplxVftDqn+ctUw==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/a11y@4.9.0': resolution: {integrity: sha512-OfM/wnB8ItmGM5I/u+4E4aJdqvy98kg24zrS+CqPLgq3eYG6MNkIQJZov/I3XcsyxGjLkkLsybEM5xEYUN0ZtA==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7767,6 +7778,13 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 + '@wordpress/components@28.10.0': + resolution: {integrity: sha512-w5mteCe9qOBMgD8d80QBVOPk0YAquUkMD9o3jDvdqUwiTcVgxn4QSKjh65NGYotvMhDsgsMTq+qgifAB+ubepg==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + react: ^18.0.0 + react-dom: ^18.0.0 + '@wordpress/components@28.9.0': resolution: {integrity: sha512-/ept6OSWAh4bdZwlhU8TwJe9QM6rqjAXVA08H0wymtjdRbAQiuDsmMfLFKCF1M4hGZeeThAD5YF0ZkBK5iCeCA==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7774,6 +7792,12 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 + '@wordpress/compose@7.10.0': + resolution: {integrity: sha512-/j4+wXthaV/KMt0VANvhhRJEJfPc21c7Tq1ZeLxgsbkq4xmi9qXeDT91cvP/U+Ta3phf15K8vdxMr8MqHHiFoQ==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + react: ^18.0.0 + '@wordpress/compose@7.9.0': resolution: {integrity: sha512-6f1mZLwMD2woFSMLJ5JaCZQZz1kFD2X4gwT5c4IVnzpm+/9A0OqeTdncAi6I6wHRtKN9DzvaMQPuZitQz7HmNA==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7794,6 +7818,12 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 + '@wordpress/data@10.10.0': + resolution: {integrity: sha512-oyYl89p86+U9W6vKDqScKhUGKKzsnETj9rg8zOnT4K9ceOScjGCgdCE+XxcY9exeRg33aSYDjmvnsXXYStBYmA==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + react: ^18.0.0 + '@wordpress/data@10.9.0': resolution: {integrity: sha512-hw8VYSPZuEqlEwRnQnKgqzbwCqoGY4U5kLCZA/1McOYspvkIceTVve4qBC17QUJhu2pLEXEc6p4zBpy+SXfToQ==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7806,6 +7836,16 @@ packages: peerDependencies: react: ^18.0.0 + '@wordpress/dataviews@4.6.0': + resolution: {integrity: sha512-DdlKg1ojGjkgS0z0GHfALOYcsMU7+8Gwzi+GFqRcfGdVOn9SiKY5pMEULFki3RkF3Nh61FEpViRxNczHJhOKCg==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + react: ^18.0.0 + + '@wordpress/date@5.10.0': + resolution: {integrity: sha512-TT9HN0H72Eqhlaiy+XMDyZBlTBf2iZ936Q2tJdxsB4qBlG2ntLT3PviIPa+G44QYYxLomrUqTEYQ6FBxiJaNHg==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/date@5.9.0': resolution: {integrity: sha512-Iywz1bga3cPSrf7k4dh2mYVsACqzu0GXYhfu57ElAM9robGjcUxJdzgbWUZw90v473NOp2UpVYsWCuDEqNDcdw==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7816,14 +7856,26 @@ packages: peerDependencies: webpack: ^5.0.0 + '@wordpress/deprecated@4.10.0': + resolution: {integrity: sha512-lktJKX3AxrskTuLbJuKY/Mzg9De6MYcOzEEL+RUHxfIx8wMtiDnVTAf7epur9XuHVOmdgCCRT6D44I23MoS0sw==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/deprecated@4.9.0': resolution: {integrity: sha512-1PMCLULxTlI0iatsHxpPgtogMfvd/wvAqAOLGHUdkdbBtUEquGrRMo/h+TLU/ne2JDf5JKMA4ntQV6zDNO4+eg==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/dom-ready@4.10.0': + resolution: {integrity: sha512-qpadyGMRvLf7zOe4XtoIo409ZRJ7IrBI36fdEXjRWV8E+Cmcx3ldr5/2iLKJ2cqYg9geQWXDeiykSWOClNJx+w==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/dom-ready@4.9.0': resolution: {integrity: sha512-Kas5YaRl+HebAxFfv9ctB8bdmjbhISIBo747nXCK6KqojQ/Zn2Bctv2XTypR3GMb7OS7KqVMeyCJhjEpuc8Wlw==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/dom@4.10.0': + resolution: {integrity: sha512-1ZRCrDB2TV44GLwaUH9HRGQGQqXcawSEmzVPABQwfwzkUKijfbRdsWqpHrTLqlSZRImHEdp6oSON+1JmCNhXSw==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/dom@4.9.0': resolution: {integrity: sha512-g9jRTxOpSfygEbKNGwYwx21b5GktI2SkwQSAPKpG4mmFAvLbqIzjVc2nkudRO914DKgPWrBsfKsc4Smbtpbkig==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7842,10 +7894,18 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 + '@wordpress/element@6.10.0': + resolution: {integrity: sha512-7zW+14vHqEn45nszSLMUqE5IbzOtvgUUgF56qlMhwabpG4l/zhaj3gO3wLDI19C13ih1vOdSjzPc3At4fB3tRQ==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/element@6.9.0': resolution: {integrity: sha512-G5W29cxfAVc/JQBzkKoXh1t4T+G3HWa1kIgXCqIZksonlYHzCVON1Or+rD/YJZSxT6RDkBVDzdl9p0pGOrccTg==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/escape-html@3.10.0': + resolution: {integrity: sha512-3glY3MhXEHlPP0/hrS3vkRmAOHtutvoHGhkr8vnva6TLg4CsAeo42nYbuFJ+ukVMWdCtmV+28UjOeiYtG/fZOA==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/escape-html@3.9.0': resolution: {integrity: sha512-+/SnVUXzzr+0pgfAqK3pocGveSDS3SHrgJ1BTgV7DA1l6y9mbjnqKgFQkNW/nzca92ZuYg2vjLcq1dqDGz4v1Q==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7887,19 +7947,38 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 + '@wordpress/hooks@4.10.0': + resolution: {integrity: sha512-LcorV5Z9XoJCKyj5Ulgw1HPHyM2mxsSInC7wl5cuIgDFmuwPTfRndUDGWz/v86GX1GnUIB0h/ggd53vx1HiW4A==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/hooks@4.9.0': resolution: {integrity: sha512-nan2w5imPhTaJwWdKjm/0ZMDbWR3P6Vhl4OqnBZZcJqOyNSfwsnJ98I+BWjq0U6SmiCnZQERjN0SjVdmD1tCjw==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/html-entities@4.10.0': + resolution: {integrity: sha512-Bnop0k3yjtRhm4CedbsGG22OMLEeob4mYmTR9z0g0QP7OofEw1TINspizr+kQbOu4n1ubJ6YVC8T13Z2va1j0g==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/html-entities@4.9.0': resolution: {integrity: sha512-RaiMecK8Igqb4yreJncSZEBl6DR1eAj8M3mHwrJASJLiiBLcaWg0oi8iiabUEmgGCsIu2pCeXmV+8WO0FRDO5Q==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/i18n@5.10.0': + resolution: {integrity: sha512-HZ6UcMHsjOocDI0zVAuP4JIl97LRmpGo/lVxzVIreaLoYitmYVDUzji02u1o7sEdRWc1Hpkm2/oO/9275rJg1w==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + hasBin: true + '@wordpress/i18n@5.9.0': resolution: {integrity: sha512-pKFV9S/l0TFlm0mlWLW51hAoRDNmZPGnfEpNXq43VKZkm1cco3Z1E54PHMGk8HdCECHqYNiJuQJOBOlqcYmnVQ==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} hasBin: true + '@wordpress/icons@10.10.0': + resolution: {integrity: sha512-41HaxMtq0WZF37mpZ1RQ1s1J3ia5gHFUd/uGhP9p1dhzEFYALxKVTB0Gy3cJhT0CslKeEwYx2XQIP1ZaCKNakQ==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + react: ^18 + '@wordpress/icons@10.9.0': resolution: {integrity: sha512-mAkqhlbbPiuR6yBOczunqyxQ2Pez1XB7gAZnnsP5DlTKsYnJQ12N0Ql4Oh8f1LI+UeF18VMtHes12sWK/1LQHQ==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7921,6 +8000,10 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 + '@wordpress/is-shallow-equal@5.10.0': + resolution: {integrity: sha512-KOkZzOnmjpH7hzPiaXUjhUlfKIGTzL7qUdNHBC1SFDOYpnRUSw8f1AtWxRpPBHl5dieYVx0x1qjOWjm/DtTOXg==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/is-shallow-equal@5.9.0': resolution: {integrity: sha512-cKqgI6RQ27ZZRo4Zc/jioG3qInDKQqcT3xg5YxsduX2f1b6vQV42p0L4waLFeJZQ8WDUsgsR53AQivdInkO8gA==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7937,6 +8020,10 @@ packages: peerDependencies: react: ^18.0.0 + '@wordpress/keycodes@4.10.0': + resolution: {integrity: sha512-2i+N90HBMqQegtGqeVB8pJz8ZgKAY1eZmQegE9MXczYVac85DDOoxhY/41c44s6Kwl3waJ2Zght6UXE0OUFMxw==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/keycodes@4.9.0': resolution: {integrity: sha512-WO4MPlO+uGaDP5jYB9f4hn0NgBwvlaUvj4MLOIDcQGE0ljElLGFeXvqjVH0KVtnZkIKiZNPK7eoQxTWnxWaTjw==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -7984,20 +8071,40 @@ packages: peerDependencies: prettier: '>=3' + '@wordpress/primitives@4.10.0': + resolution: {integrity: sha512-dmck1VSKbxy7yA5VZhi+jOyb0Hc6QqOxIZ4R139a/Zuzr0xHuuKurh94At/R9UHYP8Dr9YxAlgiF/uQChFzKQg==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + react: ^18.0.0 + '@wordpress/primitives@4.9.0': resolution: {integrity: sha512-vroiqxd+MP/K1+KEJqMAR/B/++4oShY4CisvMOK3gn75DmUV2QB6iQmBSjHRALqw9rqeHf7S0jLHWiFrAR+Dkg==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} peerDependencies: react: ^18.0.0 + '@wordpress/priority-queue@3.10.0': + resolution: {integrity: sha512-Gjbw5NmRLrZ9KkiROJlL4I/s96bMlpd7gGkQbcCyyeLIZduGxQDzI4Jih5s0Xrm7Gj8WFd57wRDe/voZJR0ZsQ==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/priority-queue@3.9.0': resolution: {integrity: sha512-QVfELUL4ei5Uf0DNG9wMVNBILasGWWWogVjVeP1xXqmfSDoeFpPzXpfL9zfANndE2S49DJP9ZoZsCaJHtMrYzA==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/private-apis@1.10.0': + resolution: {integrity: sha512-gH6ZHmkc01MC431nMyjxFmU/77jVliOwjuv6SffQUgHMJyM75LiKC8CU8LEeLWbn3obG87m/n7Quj5p2MjtaeA==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/private-apis@1.9.0': resolution: {integrity: sha512-hZbKVSlo5yOpssMshXwNlUyk83Ev55ZKMfJMVU5nWxiIM9bMCuhpwU+AXQ0GKxOzn2oMayVmtJ00FRbJFg+AMg==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/redux-routine@5.10.0': + resolution: {integrity: sha512-oDqZDjz8H/bt02IEoIZCwsUsL17UOEnMg/heV0PoJxo3k5MTrvqJqzgBLoSC0PFzx/pwOo4TwvwCL+kjjm5gCQ==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + redux: '>=4' + '@wordpress/redux-routine@5.9.0': resolution: {integrity: sha512-eEb/otHMhOwVUydb5kErV3X+1R8qQ2hrLmlWIh+kiiKwFJVCl3ge/xN8Tiy1kEBEqgGRgPqxuLvNPZDd0ySpNg==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -8011,6 +8118,12 @@ packages: react: ^18.0.0 react-dom: ^18.0.0 + '@wordpress/rich-text@7.10.0': + resolution: {integrity: sha512-2sl/KPRq2ygAiRcs/La733OguL9xIT4uKRA5XpCIWNAqTX7f2kzY5YRn05iJfCxDC+GcDKcHl0JX4ZbFxZn5SA==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + peerDependencies: + react: ^18.0.0 + '@wordpress/rich-text@7.9.0': resolution: {integrity: sha512-GN2SGz8bVkdCVVskvJSgul4wKyq/qaXRmEJSrk3LMHuAbxHL5FFkwRHaOhnHScNz+P1bdEehCqgP8DB3yv+IEw==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -8046,6 +8159,10 @@ packages: resolution: {integrity: sha512-mnwh8WcA9//DVwwZVfEaFHfIK1RaNQ8QvhD1fOtjJWjheS12QsQwjdlGTgvBVl66ErP65GdK7BM1pTv6NI0GwA==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/undo-manager@1.10.0': + resolution: {integrity: sha512-WaLwZ+AlfXQm9PhLf6kwCBaD5DoKaIqelRsgAaqa4APjgMBlxktQ1dadime0CO9+e8R2kLwAE3rxQXhGjicRMw==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/undo-manager@1.9.0': resolution: {integrity: sha512-JLrcmeCTqITbChkJy+PeXcE03+6ZgIfQ22cBg1+0mzLQxglx1gndTnhRcnCSebvsXnmOVmxvE4HmJ84lv7liCQ==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -8060,6 +8177,10 @@ packages: peerDependencies: react: ^18.0.0 + '@wordpress/warning@3.10.0': + resolution: {integrity: sha512-IhvIBhhzsNYuLT61ZtKWm7oMg4G0x//eQD8dlnsBA4edP8BiX1VzwA3wCtz9+QdEFzraPJAq9NG4RPxGQas4Nw==} + engines: {node: '>=18.12.0', npm: '>=8.19.2'} + '@wordpress/warning@3.9.0': resolution: {integrity: sha512-c+bEWwDjp3+Q7SAGb47CuZe56giBFNvutoyiAkn34pQZeO8pRjPElRABIkR7oyn4dEusjL1f6OQmU3dSYAMTpg==} engines: {node: '>=18.12.0', npm: '>=8.19.2'} @@ -15206,6 +15327,10 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 + '@babel/runtime@7.25.7': + dependencies: + regenerator-runtime: 0.14.1 + '@babel/template@7.25.7': dependencies: '@babel/code-frame': 7.25.7 @@ -17785,6 +17910,12 @@ snapshots: dependencies: webpack-cli: 4.9.1(webpack@5.94.0) + '@wordpress/a11y@4.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/dom-ready': 4.10.0 + '@wordpress/i18n': 5.10.0 + '@wordpress/a11y@4.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -18220,6 +18351,60 @@ snapshots: - '@types/react-dom' - supports-color + '@wordpress/components@28.10.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@ariakit/react': 0.4.12(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@babel/runtime': 7.25.7 + '@emotion/cache': 11.13.1 + '@emotion/css': 11.13.4 + '@emotion/react': 11.13.3(@types/react@18.3.3)(react@18.3.1) + '@emotion/serialize': 1.3.2 + '@emotion/styled': 11.13.0(@emotion/react@11.13.3(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1) + '@emotion/utils': 1.4.1 + '@floating-ui/react-dom': 2.1.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@types/gradient-parser': 0.1.3 + '@types/highlight-words-core': 1.2.1 + '@use-gesture/react': 10.3.1(react@18.3.1) + '@wordpress/a11y': 4.10.0 + '@wordpress/compose': 7.10.0(react@18.3.1) + '@wordpress/date': 5.10.0 + '@wordpress/deprecated': 4.10.0 + '@wordpress/dom': 4.10.0 + '@wordpress/element': 6.10.0 + '@wordpress/escape-html': 3.10.0 + '@wordpress/hooks': 4.10.0 + '@wordpress/html-entities': 4.10.0 + '@wordpress/i18n': 5.10.0 + '@wordpress/icons': 10.10.0(react@18.3.1) + '@wordpress/is-shallow-equal': 5.10.0 + '@wordpress/keycodes': 4.10.0 + '@wordpress/primitives': 4.10.0(react@18.3.1) + '@wordpress/private-apis': 1.10.0 + '@wordpress/rich-text': 7.10.0(react@18.3.1) + '@wordpress/warning': 3.10.0 + change-case: 4.1.2 + clsx: 2.1.1 + colord: 2.9.3 + date-fns: 3.6.0 + deepmerge: 4.3.1 + fast-deep-equal: 3.1.3 + framer-motion: 11.4.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + gradient-parser: 0.1.5 + highlight-words-core: 1.2.3 + is-plain-object: 5.0.0 + memize: 2.1.0 + path-to-regexp: 6.3.0 + re-resizable: 6.10.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react: 18.3.1 + react-colorful: 5.6.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react-dom: 18.3.1(react@18.3.1) + remove-accents: 0.5.0 + uuid: 9.0.1 + transitivePeerDependencies: + - '@emotion/is-prop-valid' + - '@types/react' + - supports-color + '@wordpress/components@28.9.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@ariakit/react': 0.4.12(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -18328,6 +18513,23 @@ snapshots: - '@types/react' - supports-color + '@wordpress/compose@7.10.0(react@18.3.1)': + dependencies: + '@babel/runtime': 7.25.7 + '@types/mousetrap': 1.6.15 + '@wordpress/deprecated': 4.10.0 + '@wordpress/dom': 4.10.0 + '@wordpress/element': 6.10.0 + '@wordpress/is-shallow-equal': 5.10.0 + '@wordpress/keycodes': 4.10.0 + '@wordpress/priority-queue': 3.10.0 + '@wordpress/undo-manager': 1.10.0 + change-case: 4.1.2 + clipboard: 2.0.11 + mousetrap: 1.6.5 + react: 18.3.1 + use-memo-one: 1.1.3(react@18.3.1) + '@wordpress/compose@7.9.0(react@18.2.0)': dependencies: '@babel/runtime': 7.24.7 @@ -18516,6 +18718,25 @@ snapshots: - supports-color - utf-8-validate + '@wordpress/data@10.10.0(react@18.3.1)': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/compose': 7.10.0(react@18.3.1) + '@wordpress/deprecated': 4.10.0 + '@wordpress/element': 6.10.0 + '@wordpress/is-shallow-equal': 5.10.0 + '@wordpress/priority-queue': 3.10.0 + '@wordpress/private-apis': 1.10.0 + '@wordpress/redux-routine': 5.10.0(redux@4.2.1) + deepmerge: 4.3.1 + equivalent-key-map: 0.2.2 + is-plain-object: 5.0.0 + is-promise: 4.0.0 + react: 18.3.1 + redux: 4.2.1 + rememo: 4.0.2 + use-memo-one: 1.1.3(react@18.3.1) + '@wordpress/data@10.9.0(react@18.2.0)': dependencies: '@babel/runtime': 7.24.7 @@ -18598,6 +18819,35 @@ snapshots: - react-dom - supports-color + '@wordpress/dataviews@4.6.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@ariakit/react': 0.4.12(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@babel/runtime': 7.25.7 + '@wordpress/components': 28.10.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@wordpress/compose': 7.10.0(react@18.3.1) + '@wordpress/data': 10.10.0(react@18.3.1) + '@wordpress/element': 6.10.0 + '@wordpress/i18n': 5.10.0 + '@wordpress/icons': 10.10.0(react@18.3.1) + '@wordpress/primitives': 4.10.0(react@18.3.1) + '@wordpress/private-apis': 1.10.0 + '@wordpress/warning': 3.10.0 + clsx: 2.1.1 + react: 18.3.1 + remove-accents: 0.5.0 + transitivePeerDependencies: + - '@emotion/is-prop-valid' + - '@types/react' + - react-dom + - supports-color + + '@wordpress/date@5.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/deprecated': 4.10.0 + moment: 2.29.4 + moment-timezone: 0.5.46 + '@wordpress/date@5.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -18610,15 +18860,29 @@ snapshots: json2php: 0.0.7 webpack: 5.94.0(webpack-cli@4.9.1) + '@wordpress/deprecated@4.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/hooks': 4.10.0 + '@wordpress/deprecated@4.9.0': dependencies: '@babel/runtime': 7.24.7 '@wordpress/hooks': 4.9.0 + '@wordpress/dom-ready@4.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/dom-ready@4.9.0': dependencies: '@babel/runtime': 7.24.7 + '@wordpress/dom@4.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/deprecated': 4.10.0 + '@wordpress/dom@4.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -18889,6 +19153,17 @@ snapshots: - supports-color - utf-8-validate + '@wordpress/element@6.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@types/react': 18.3.3 + '@types/react-dom': 18.3.0 + '@wordpress/escape-html': 3.10.0 + change-case: 4.1.2 + is-plain-object: 5.0.0 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + '@wordpress/element@6.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -18900,6 +19175,10 @@ snapshots: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) + '@wordpress/escape-html@3.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/escape-html@3.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -19056,14 +19335,31 @@ snapshots: - '@types/react-dom' - supports-color + '@wordpress/hooks@4.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/hooks@4.9.0': dependencies: '@babel/runtime': 7.24.7 + '@wordpress/html-entities@4.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/html-entities@4.9.0': dependencies: '@babel/runtime': 7.24.7 + '@wordpress/i18n@5.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/hooks': 4.10.0 + gettext-parser: 1.4.0 + memize: 2.1.0 + sprintf-js: 1.1.3 + tannin: 1.2.0 + '@wordpress/i18n@5.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -19073,6 +19369,13 @@ snapshots: sprintf-js: 1.1.2 tannin: 1.2.0 + '@wordpress/icons@10.10.0(react@18.3.1)': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/element': 6.10.0 + '@wordpress/primitives': 4.10.0(react@18.3.1) + react: 18.3.1 + '@wordpress/icons@10.9.0(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 @@ -19136,6 +19439,10 @@ snapshots: - '@types/react' - supports-color + '@wordpress/is-shallow-equal@5.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/is-shallow-equal@5.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -19154,6 +19461,11 @@ snapshots: '@wordpress/keycodes': 4.9.0 react: 18.3.1 + '@wordpress/keycodes@4.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/i18n': 5.10.0 + '@wordpress/keycodes@4.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -19339,6 +19651,13 @@ snapshots: dependencies: prettier: wp-prettier@3.0.3 + '@wordpress/primitives@4.10.0(react@18.3.1)': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/element': 6.10.0 + clsx: 2.1.1 + react: 18.3.1 + '@wordpress/primitives@4.9.0(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 @@ -19346,15 +19665,32 @@ snapshots: clsx: 2.1.1 react: 18.3.1 + '@wordpress/priority-queue@3.10.0': + dependencies: + '@babel/runtime': 7.25.7 + requestidlecallback: 0.3.0 + '@wordpress/priority-queue@3.9.0': dependencies: '@babel/runtime': 7.24.7 requestidlecallback: 0.3.0 + '@wordpress/private-apis@1.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/private-apis@1.9.0': dependencies: '@babel/runtime': 7.24.7 + '@wordpress/redux-routine@5.10.0(redux@4.2.1)': + dependencies: + '@babel/runtime': 7.25.7 + is-plain-object: 5.0.0 + is-promise: 4.0.0 + redux: 4.2.1 + rungen: 0.3.2 + '@wordpress/redux-routine@5.9.0(redux@4.2.1)': dependencies: '@babel/runtime': 7.24.7 @@ -19435,6 +19771,20 @@ snapshots: - supports-color - utf-8-validate + '@wordpress/rich-text@7.10.0(react@18.3.1)': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/a11y': 4.10.0 + '@wordpress/compose': 7.10.0(react@18.3.1) + '@wordpress/data': 10.10.0(react@18.3.1) + '@wordpress/deprecated': 4.10.0 + '@wordpress/element': 6.10.0 + '@wordpress/escape-html': 3.10.0 + '@wordpress/i18n': 5.10.0 + '@wordpress/keycodes': 4.10.0 + memize: 2.1.0 + react: 18.3.1 + '@wordpress/rich-text@7.9.0(react@18.3.1)': dependencies: '@babel/runtime': 7.24.7 @@ -19529,6 +19879,11 @@ snapshots: dependencies: '@babel/runtime': 7.24.7 + '@wordpress/undo-manager@1.10.0': + dependencies: + '@babel/runtime': 7.25.7 + '@wordpress/is-shallow-equal': 5.10.0 + '@wordpress/undo-manager@1.9.0': dependencies: '@babel/runtime': 7.24.7 @@ -19547,6 +19902,8 @@ snapshots: '@wordpress/element': 6.9.0 react: 18.3.1 + '@wordpress/warning@3.10.0': {} + '@wordpress/warning@3.9.0': {} '@wordpress/widgets@4.9.0(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': diff --git a/projects/js-packages/components/changelog/add-threats-data-view-component b/projects/js-packages/components/changelog/add-threats-data-view-component new file mode 100644 index 0000000000000..ce943e85a6b6a --- /dev/null +++ b/projects/js-packages/components/changelog/add-threats-data-view-component @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Add ThreatsDataView component diff --git a/projects/js-packages/components/components/badge/index.tsx b/projects/js-packages/components/components/badge/index.tsx new file mode 100644 index 0000000000000..4ca1044e60f6b --- /dev/null +++ b/projects/js-packages/components/components/badge/index.tsx @@ -0,0 +1,39 @@ +import clsx from 'clsx'; +import React from 'react'; +import styles from './style.module.scss'; + +type BadgeProps = { + children?: React.ReactNode; + className?: string; + variant?: 'success' | 'warning' | 'danger'; + [ key: string ]: unknown; +}; + +/** + * Badge component + * + * @param {object} props - The component properties. + * @param {string} props.variant - The badge variant (i.e. 'success', 'warning', 'danger'). + * @param {JSX.Element} props.children - Badge text or content. + * @param {string} props.className - Additional class name to pass to the Badge component. + * + * @return {React.ReactElement} The `Badge` component. + */ +const Badge: React.FC< BadgeProps > = ( { children, className, variant = 'info', ...props } ) => { + const classes = clsx( + styles.badge, + { + [ styles[ 'is-success' ] ]: variant === 'success', + [ styles[ 'is-warning' ] ]: variant === 'warning', + [ styles[ 'is-danger' ] ]: variant === 'danger', + }, + className + ); + return ( + + { children } + + ); +}; + +export default Badge; diff --git a/projects/js-packages/components/components/badge/stories/index.stories.tsx b/projects/js-packages/components/components/badge/stories/index.stories.tsx new file mode 100644 index 0000000000000..c74ac1c476897 --- /dev/null +++ b/projects/js-packages/components/components/badge/stories/index.stories.tsx @@ -0,0 +1,22 @@ +import Badge from '../index'; + +export default { + title: 'JS Packages/Components/Badge', + component: Badge, + argTypes: { + type: { + control: { + type: 'select', + }, + options: [ 'info', 'danger', 'warning', 'success' ], + }, + }, +}; + +const Template = args => ; + +export const _default = Template.bind( {} ); +_default.args = { + type: 'info', + children: 'Hello World', +}; diff --git a/projects/js-packages/components/components/badge/style.module.scss b/projects/js-packages/components/components/badge/style.module.scss new file mode 100644 index 0000000000000..a305d7c2520a0 --- /dev/null +++ b/projects/js-packages/components/components/badge/style.module.scss @@ -0,0 +1,25 @@ +.badge { + display: inline-block; + border-radius: 4px; + background-color: var(--jp-gray-0); + color: var(--jp-gray-80); + padding: 4px 8px; + font-size: 13px; + font-weight: 400; + line-height: 16px; + + &.is-success { + background-color: var(--jp-green-5); + color: var(--jp-green-50); + } + + &.is-warning { + background-color: var(--jp-yellow-5); + color: var(--jp-yellow-60); + } + + &.is-danger { + background-color: var(--jp-red-5); + color: var(--jp-red-70); + } +} diff --git a/projects/js-packages/components/components/icon-tooltip/index.tsx b/projects/js-packages/components/components/icon-tooltip/index.tsx index c64b6e74309dd..c51ec4e125d01 100644 --- a/projects/js-packages/components/components/icon-tooltip/index.tsx +++ b/projects/js-packages/components/components/icon-tooltip/index.tsx @@ -41,9 +41,12 @@ const IconTooltip: React.FC< IconTooltipProps > = ( { wide = false, inline = true, shift = false, + hoverShow = false, } ) => { const POPOVER_HELPER_WIDTH = 124; const [ isVisible, setIsVisible ] = useState( false ); + const [ timeoutId, setTimeoutId ] = useState( null ); + const hideTooltip = useCallback( () => setIsVisible( false ), [ setIsVisible ] ); const toggleTooltip = useCallback( e => { @@ -53,6 +56,26 @@ const IconTooltip: React.FC< IconTooltipProps > = ( { [ isVisible, setIsVisible ] ); + const handleMouseEnter = useCallback( () => { + if ( hoverShow ) { + if ( timeoutId ) { + clearTimeout( timeoutId ); + setTimeoutId( null ); + } + setIsVisible( true ); + } + }, [ hoverShow, timeoutId ] ); + + const handleMouseLeave = useCallback( () => { + if ( hoverShow ) { + const id = setTimeout( () => { + setIsVisible( false ); + setTimeoutId( null ); + }, 100 ); + setTimeoutId( id ); + } + }, [ hoverShow ] ); + const args = { // To be compatible with deprecating prop `position`. position: placementsToPositions( placement ), @@ -79,7 +102,12 @@ const IconTooltip: React.FC< IconTooltipProps > = ( { const isForcedToShow = isAnchorWrapper && forceShow; return ( -
+
{ ! isAnchorWrapper && (