diff --git a/.storybook/main.js b/.storybook/main.js index 5ffc121ac5..c8284fbe49 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -17,6 +17,8 @@ module.exports = { addons: [ getAbsolutePath('storybook-version'), getAbsolutePath('@storybook/addon-docs'), + getAbsolutePath('@storybook/addon-controls'), + getAbsolutePath('@whitespace/storybook-addon-html'), getAbsolutePath('@storybook/addon-mdx-gfm') ], diff --git a/.storybook/preview.css b/.storybook/preview.css index abd7e4d770..ded9862ccc 100644 --- a/.storybook/preview.css +++ b/.storybook/preview.css @@ -13,6 +13,10 @@ body, padding: 0!important; } +#root-inner { + padding: 16px; +} + .docs-img-centered { display: block; float: none; diff --git a/.storybook/preview.js b/.storybook/preview.js index 4bc5ebe0a7..1fc962db9f 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -11,9 +11,33 @@ import { setCustomElements } from '@storybook/web-components'; import '../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js'; import customElements from '../custom-elements.json'; import { versionInfo } from './versionInfo'; +import { registerMgtComponents } from '../packages/mgt-components/dist/es6/registerMgtComponents'; import { defaultDocsPage } from './story-elements/defaultDocsPage'; + +import { addons } from '@storybook/preview-api'; +import { CLIENTID, SETPROVIDER_EVENT, AUTH_PAGE } from './env'; +import { Providers } from '../packages/mgt-element/dist/es6/providers/Providers'; +import { LoginType, ProviderState } from '../packages/mgt-element/dist/es6/providers/IProvider'; +import { MockProvider } from '../packages/mgt-element/dist/es6/mock/MockProvider'; +import { Msal2Provider } from '../packages/providers/mgt-msal2-provider/dist/es6/Msal2Provider'; import './preview.css'; +registerMgtComponents(); + +Providers.globalProvider = new MockProvider(true); +const channel = addons.getChannel(); +channel.on(SETPROVIDER_EVENT, params => { + if (params.state === ProviderState.SignedIn && params.name === 'MgtMockProvider') { + Providers.globalProvider = new MockProvider(true); + } else if (params.state === ProviderState.SignedIn && params.name === 'MgtMsal2Provider') { + Providers.globalProvider = new Msal2Provider({ + clientId: CLIENTID, + loginType: LoginType.Popup, + redirectUri: `${window.location.origin}/${AUTH_PAGE}` + }); + } +}); + const setCustomElementsManifestWithOptions = (customElements, options) => { let { privateFields = true } = options; if (!privateFields) { @@ -54,12 +78,18 @@ export const parameters = { options: { storySort: { order: ['stories'] + }, + showPanel: false + }, + html: { + removeEmptyComments: true, + transform: code => { + return code.replace(/=""/g, ''); } } }; const req = require.context('../stories', true, /\.(js|mdx)$/); -// configure(req, module); if (module.hot) { module.hot.accept(req.id, () => { const currentLocationHref = window.location.href; diff --git a/.yarn/cache/@babel-runtime-npm-7.23.7-9691b86096-eba85bd24d.zip b/.yarn/cache/@babel-runtime-npm-7.23.7-9691b86096-eba85bd24d.zip new file mode 100644 index 0000000000..dd07209b9e Binary files /dev/null and b/.yarn/cache/@babel-runtime-npm-7.23.7-9691b86096-eba85bd24d.zip differ diff --git a/.yarn/cache/@storybook-addon-controls-npm-7.6.11-8b8a7d8f73-5e0d34b8a4.zip b/.yarn/cache/@storybook-addon-controls-npm-7.6.11-8b8a7d8f73-5e0d34b8a4.zip new file mode 100644 index 0000000000..3436ca1ca0 Binary files /dev/null and b/.yarn/cache/@storybook-addon-controls-npm-7.6.11-8b8a7d8f73-5e0d34b8a4.zip differ diff --git a/.yarn/cache/@storybook-blocks-npm-7.6.11-3dde544fec-726fc513fd.zip b/.yarn/cache/@storybook-blocks-npm-7.6.11-3dde544fec-726fc513fd.zip new file mode 100644 index 0000000000..921cd2836e Binary files /dev/null and b/.yarn/cache/@storybook-blocks-npm-7.6.11-3dde544fec-726fc513fd.zip differ diff --git a/.yarn/cache/@storybook-channels-npm-7.6.11-1ecde7668d-dff5505a71.zip b/.yarn/cache/@storybook-channels-npm-7.6.11-1ecde7668d-dff5505a71.zip new file mode 100644 index 0000000000..b1b302a0d5 Binary files /dev/null and b/.yarn/cache/@storybook-channels-npm-7.6.11-1ecde7668d-dff5505a71.zip differ diff --git a/.yarn/cache/@storybook-client-logger-npm-7.6.11-34737dea83-2e40868f7e.zip b/.yarn/cache/@storybook-client-logger-npm-7.6.11-34737dea83-2e40868f7e.zip new file mode 100644 index 0000000000..6e9138842a Binary files /dev/null and b/.yarn/cache/@storybook-client-logger-npm-7.6.11-34737dea83-2e40868f7e.zip differ diff --git a/.yarn/cache/@storybook-components-npm-7.6.11-b991c026ca-a240a2667a.zip b/.yarn/cache/@storybook-components-npm-7.6.11-b991c026ca-a240a2667a.zip new file mode 100644 index 0000000000..31ab6946dc Binary files /dev/null and b/.yarn/cache/@storybook-components-npm-7.6.11-b991c026ca-a240a2667a.zip differ diff --git a/.yarn/cache/@storybook-core-common-npm-7.6.11-99d4e087de-5c65ac535f.zip b/.yarn/cache/@storybook-core-common-npm-7.6.11-99d4e087de-5c65ac535f.zip new file mode 100644 index 0000000000..ab4fc0a417 Binary files /dev/null and b/.yarn/cache/@storybook-core-common-npm-7.6.11-99d4e087de-5c65ac535f.zip differ diff --git a/.yarn/cache/@storybook-core-events-npm-7.6.11-88d7804a2b-941ef2fa6c.zip b/.yarn/cache/@storybook-core-events-npm-7.6.11-88d7804a2b-941ef2fa6c.zip new file mode 100644 index 0000000000..e7bd23b66c Binary files /dev/null and b/.yarn/cache/@storybook-core-events-npm-7.6.11-88d7804a2b-941ef2fa6c.zip differ diff --git a/.yarn/cache/@storybook-docs-tools-npm-7.6.11-7c99da8dcd-d7189af726.zip b/.yarn/cache/@storybook-docs-tools-npm-7.6.11-7c99da8dcd-d7189af726.zip new file mode 100644 index 0000000000..336adb1837 Binary files /dev/null and b/.yarn/cache/@storybook-docs-tools-npm-7.6.11-7c99da8dcd-d7189af726.zip differ diff --git a/.yarn/cache/@storybook-manager-api-npm-7.6.11-5b5ccf76bf-10a2d90cdc.zip b/.yarn/cache/@storybook-manager-api-npm-7.6.11-5b5ccf76bf-10a2d90cdc.zip new file mode 100644 index 0000000000..21e59031f4 Binary files /dev/null and b/.yarn/cache/@storybook-manager-api-npm-7.6.11-5b5ccf76bf-10a2d90cdc.zip differ diff --git a/.yarn/cache/@storybook-node-logger-npm-7.6.11-395907a479-f758c58539.zip b/.yarn/cache/@storybook-node-logger-npm-7.6.11-395907a479-f758c58539.zip new file mode 100644 index 0000000000..c911821f2d Binary files /dev/null and b/.yarn/cache/@storybook-node-logger-npm-7.6.11-395907a479-f758c58539.zip differ diff --git a/.yarn/cache/@storybook-preview-api-npm-7.6.11-c242488544-4b17981ad5.zip b/.yarn/cache/@storybook-preview-api-npm-7.6.11-c242488544-4b17981ad5.zip new file mode 100644 index 0000000000..e08278104a Binary files /dev/null and b/.yarn/cache/@storybook-preview-api-npm-7.6.11-c242488544-4b17981ad5.zip differ diff --git a/.yarn/cache/@storybook-router-npm-7.6.11-15279987b7-5dfae32818.zip b/.yarn/cache/@storybook-router-npm-7.6.11-15279987b7-5dfae32818.zip new file mode 100644 index 0000000000..d1cee88417 Binary files /dev/null and b/.yarn/cache/@storybook-router-npm-7.6.11-15279987b7-5dfae32818.zip differ diff --git a/.yarn/cache/@storybook-theming-npm-7.6.11-7527822a16-e37c359237.zip b/.yarn/cache/@storybook-theming-npm-7.6.11-7527822a16-e37c359237.zip new file mode 100644 index 0000000000..b41cc3b8ee Binary files /dev/null and b/.yarn/cache/@storybook-theming-npm-7.6.11-7527822a16-e37c359237.zip differ diff --git a/.yarn/cache/@storybook-types-npm-7.6.11-3c1b6d5bbb-6e90906afb.zip b/.yarn/cache/@storybook-types-npm-7.6.11-3c1b6d5bbb-6e90906afb.zip new file mode 100644 index 0000000000..af45bac8be Binary files /dev/null and b/.yarn/cache/@storybook-types-npm-7.6.11-3c1b6d5bbb-6e90906afb.zip differ diff --git a/.yarn/cache/@types-hast-npm-2.3.9-48440fc881-32a742021a.zip b/.yarn/cache/@types-hast-npm-2.3.9-48440fc881-32a742021a.zip new file mode 100644 index 0000000000..e4ddbfaf0d Binary files /dev/null and b/.yarn/cache/@types-hast-npm-2.3.9-48440fc881-32a742021a.zip differ diff --git a/.yarn/cache/@whitespace-storybook-addon-html-npm-5.1.6-9888d34906-6e4374ef5d.zip b/.yarn/cache/@whitespace-storybook-addon-html-npm-5.1.6-9888d34906-6e4374ef5d.zip new file mode 100644 index 0000000000..e804fe1593 Binary files /dev/null and b/.yarn/cache/@whitespace-storybook-addon-html-npm-5.1.6-9888d34906-6e4374ef5d.zip differ diff --git a/.yarn/cache/@whitespace-storybook-addon-html-patch-b3a7598d94-08fe5cb0e3.zip b/.yarn/cache/@whitespace-storybook-addon-html-patch-b3a7598d94-08fe5cb0e3.zip new file mode 100644 index 0000000000..92e39b00cd Binary files /dev/null and b/.yarn/cache/@whitespace-storybook-addon-html-patch-b3a7598d94-08fe5cb0e3.zip differ diff --git a/.yarn/cache/character-entities-legacy-npm-1.1.4-e3e7c8ee55-fe03a82c15.zip b/.yarn/cache/character-entities-legacy-npm-1.1.4-e3e7c8ee55-fe03a82c15.zip new file mode 100644 index 0000000000..2b91ac28ed Binary files /dev/null and b/.yarn/cache/character-entities-legacy-npm-1.1.4-e3e7c8ee55-fe03a82c15.zip differ diff --git a/.yarn/cache/character-entities-npm-1.2.4-a5c359383c-e154571657.zip b/.yarn/cache/character-entities-npm-1.2.4-a5c359383c-e154571657.zip new file mode 100644 index 0000000000..0e5cb4c1d7 Binary files /dev/null and b/.yarn/cache/character-entities-npm-1.2.4-a5c359383c-e154571657.zip differ diff --git a/.yarn/cache/character-reference-invalid-npm-1.1.4-e5e17a1a38-20274574c7.zip b/.yarn/cache/character-reference-invalid-npm-1.1.4-e5e17a1a38-20274574c7.zip new file mode 100644 index 0000000000..825b620d26 Binary files /dev/null and b/.yarn/cache/character-reference-invalid-npm-1.1.4-e5e17a1a38-20274574c7.zip differ diff --git a/.yarn/cache/comma-separated-tokens-npm-1.0.8-00dbbf3418-0adcb07174.zip b/.yarn/cache/comma-separated-tokens-npm-1.0.8-00dbbf3418-0adcb07174.zip new file mode 100644 index 0000000000..cfd4529605 Binary files /dev/null and b/.yarn/cache/comma-separated-tokens-npm-1.0.8-00dbbf3418-0adcb07174.zip differ diff --git a/.yarn/cache/fault-npm-1.0.4-2788bc13e3-5ac610d8b0.zip b/.yarn/cache/fault-npm-1.0.4-2788bc13e3-5ac610d8b0.zip new file mode 100644 index 0000000000..c8a5c570b0 Binary files /dev/null and b/.yarn/cache/fault-npm-1.0.4-2788bc13e3-5ac610d8b0.zip differ diff --git a/.yarn/cache/format-npm-0.2.2-679f3acc64-646a60e133.zip b/.yarn/cache/format-npm-0.2.2-679f3acc64-646a60e133.zip new file mode 100644 index 0000000000..b89681c68d Binary files /dev/null and b/.yarn/cache/format-npm-0.2.2-679f3acc64-646a60e133.zip differ diff --git a/.yarn/cache/hast-util-parse-selector-npm-2.2.5-cd773533ea-22ee4afbd1.zip b/.yarn/cache/hast-util-parse-selector-npm-2.2.5-cd773533ea-22ee4afbd1.zip new file mode 100644 index 0000000000..b48b1abdcd Binary files /dev/null and b/.yarn/cache/hast-util-parse-selector-npm-2.2.5-cd773533ea-22ee4afbd1.zip differ diff --git a/.yarn/cache/hastscript-npm-6.0.0-380b27a9f0-5e50b85af0.zip b/.yarn/cache/hastscript-npm-6.0.0-380b27a9f0-5e50b85af0.zip new file mode 100644 index 0000000000..b6335f5028 Binary files /dev/null and b/.yarn/cache/hastscript-npm-6.0.0-380b27a9f0-5e50b85af0.zip differ diff --git a/.yarn/cache/highlight.js-npm-10.7.3-247e67d5c0-defeafcd54.zip b/.yarn/cache/highlight.js-npm-10.7.3-247e67d5c0-defeafcd54.zip new file mode 100644 index 0000000000..ee7a7453f3 Binary files /dev/null and b/.yarn/cache/highlight.js-npm-10.7.3-247e67d5c0-defeafcd54.zip differ diff --git a/.yarn/cache/is-alphabetical-npm-1.0.4-94e2e7f984-6508cce44f.zip b/.yarn/cache/is-alphabetical-npm-1.0.4-94e2e7f984-6508cce44f.zip new file mode 100644 index 0000000000..6f8808d18b Binary files /dev/null and b/.yarn/cache/is-alphabetical-npm-1.0.4-94e2e7f984-6508cce44f.zip differ diff --git a/.yarn/cache/is-alphanumerical-npm-1.0.4-c96dc6d674-e2e491acc1.zip b/.yarn/cache/is-alphanumerical-npm-1.0.4-c96dc6d674-e2e491acc1.zip new file mode 100644 index 0000000000..5e713498c1 Binary files /dev/null and b/.yarn/cache/is-alphanumerical-npm-1.0.4-c96dc6d674-e2e491acc1.zip differ diff --git a/.yarn/cache/is-decimal-npm-1.0.4-e67dbd40dd-ed483a3875.zip b/.yarn/cache/is-decimal-npm-1.0.4-e67dbd40dd-ed483a3875.zip new file mode 100644 index 0000000000..37ef0e2384 Binary files /dev/null and b/.yarn/cache/is-decimal-npm-1.0.4-e67dbd40dd-ed483a3875.zip differ diff --git a/.yarn/cache/is-hexadecimal-npm-1.0.4-b4091da09e-a452e04758.zip b/.yarn/cache/is-hexadecimal-npm-1.0.4-b4091da09e-a452e04758.zip new file mode 100644 index 0000000000..c90c174c21 Binary files /dev/null and b/.yarn/cache/is-hexadecimal-npm-1.0.4-b4091da09e-a452e04758.zip differ diff --git a/.yarn/cache/lowlight-npm-1.20.0-771a13490e-14a1815d6b.zip b/.yarn/cache/lowlight-npm-1.20.0-771a13490e-14a1815d6b.zip new file mode 100644 index 0000000000..c40f26585c Binary files /dev/null and b/.yarn/cache/lowlight-npm-1.20.0-771a13490e-14a1815d6b.zip differ diff --git a/.yarn/cache/parse-entities-npm-2.0.0-b7b4f46ff6-7addfd3e7d.zip b/.yarn/cache/parse-entities-npm-2.0.0-b7b4f46ff6-7addfd3e7d.zip new file mode 100644 index 0000000000..29f36843cb Binary files /dev/null and b/.yarn/cache/parse-entities-npm-2.0.0-b7b4f46ff6-7addfd3e7d.zip differ diff --git a/.yarn/cache/prismjs-npm-1.27.0-ca4e1667c6-85c7f4a3e9.zip b/.yarn/cache/prismjs-npm-1.27.0-ca4e1667c6-85c7f4a3e9.zip new file mode 100644 index 0000000000..085c0e0a10 Binary files /dev/null and b/.yarn/cache/prismjs-npm-1.27.0-ca4e1667c6-85c7f4a3e9.zip differ diff --git a/.yarn/cache/prismjs-npm-1.29.0-6faa5b04b8-007a8869d4.zip b/.yarn/cache/prismjs-npm-1.29.0-6faa5b04b8-007a8869d4.zip new file mode 100644 index 0000000000..25137aad36 Binary files /dev/null and b/.yarn/cache/prismjs-npm-1.29.0-6faa5b04b8-007a8869d4.zip differ diff --git a/.yarn/cache/property-information-npm-5.6.0-1322d29e0f-fcf87c6542.zip b/.yarn/cache/property-information-npm-5.6.0-1322d29e0f-fcf87c6542.zip new file mode 100644 index 0000000000..43cfe8a343 Binary files /dev/null and b/.yarn/cache/property-information-npm-5.6.0-1322d29e0f-fcf87c6542.zip differ diff --git a/.yarn/cache/react-syntax-highlighter-npm-15.5.0-da5363373b-c082b48f30.zip b/.yarn/cache/react-syntax-highlighter-npm-15.5.0-da5363373b-c082b48f30.zip new file mode 100644 index 0000000000..92a76ca3ac Binary files /dev/null and b/.yarn/cache/react-syntax-highlighter-npm-15.5.0-da5363373b-c082b48f30.zip differ diff --git a/.yarn/cache/refractor-npm-3.6.0-63276910f9-39b01c4168.zip b/.yarn/cache/refractor-npm-3.6.0-63276910f9-39b01c4168.zip new file mode 100644 index 0000000000..5341ebddf2 Binary files /dev/null and b/.yarn/cache/refractor-npm-3.6.0-63276910f9-39b01c4168.zip differ diff --git a/.yarn/patches/@whitespace-storybook-addon-html-npm-5.1.6-9888d34906.patch b/.yarn/patches/@whitespace-storybook-addon-html-npm-5.1.6-9888d34906.patch new file mode 100644 index 0000000000..bf7078612b --- /dev/null +++ b/.yarn/patches/@whitespace-storybook-addon-html-npm-5.1.6-9888d34906.patch @@ -0,0 +1,62 @@ +diff --git a/dist/esm/Panel.js b/dist/esm/Panel.js +index 0d26a69f0fcdf303ddb41d22200dca9fd98d7136..ff82b5530359cae82ad620839d4378ce258a1285 100644 +--- a/dist/esm/Panel.js ++++ b/dist/esm/Panel.js +@@ -10,13 +10,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o = + function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } + function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } + function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } +-import React, { useMemo } from "react"; +-import { useAddonState, useChannel, useParameter } from "@storybook/api"; ++import React, { useState, useEffect } from "react"; ++import { useAddonState, useChannel, useParameter } from "@storybook/manager-api"; + import { AddonPanel } from "@storybook/components"; + import { ADDON_ID, EVENTS, PARAM_KEY } from "./constants"; + import { PanelContent } from "./components/PanelContent"; + import { format as prettierFormat } from "prettier/standalone"; +-import prettierHtml from "prettier/parser-html"; ++import * as prettierHtml from "prettier/plugins/html"; + export var Panel = function Panel(props) { + // https://storybook.js.org/docs/react/addons/addons-api#useaddonstate + var _useAddonState = useAddonState(ADDON_ID, { +@@ -51,9 +51,15 @@ export var Panel = function Panel(props) { + parser: "html", + plugins: [prettierHtml] + }); +- var formattedCode = useMemo(function () { +- return code && prettierFormat(code, prettierConfig); +- }, [code, prettierConfig]); ++ const [formattedCode, setFormattedCode] = useState(null); ++ useEffect(() => { ++ const formatCode = async () => { ++ const prettierFormattedCode = code && await prettierFormat(code, prettierConfig); ++ setFormattedCode(prettierFormattedCode); ++ } ++ formatCode().catch(e => console.error(e)); ++ }, [code, prettierConfig] ++ ); + return /*#__PURE__*/React.createElement(AddonPanel, props, /*#__PURE__*/React.createElement(PanelContent, { + code: formattedCode, + showLineNumbers: showLineNumbers, +diff --git a/package.json b/package.json +index 34ef114920720e922094148145c9f4062ac1a5ac..33b5d71f9a53ef20626c961e2535571f5c317a0b 100644 +--- a/package.json ++++ b/package.json +@@ -63,7 +63,7 @@ + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-react": "^7.31.11", + "npm-run-all": "^4.1.5", +- "prettier": "^2.8.1", ++ "prettier": "^3.0.2", + "prop-types": "^15.8.1", + "react": "^17.0.2", + "react-dom": "^17.0.2", +@@ -79,7 +79,7 @@ + "@storybook/components": "^6.5.8 || ^7.0.12", + "@storybook/core-events": "^6.5.8 || ^7.0.12", + "@storybook/theming": "^6.5.8 || ^7.0.12", +- "prettier": "^2.0.0", ++ "prettier": "^3.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-syntax-highlighter": "^15.0.0" diff --git a/package.json b/package.json index 755ce3f169..b013066580 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "@stackblitz/sdk": "^1.9.0", "@storybook/addon-a11y": "^7.6.7", "@storybook/addon-actions": "^7.6.7", + "@storybook/addon-controls": "^7.6.7", "@storybook/addon-docs": "^7.6.7", "@storybook/addon-knobs": "^7.0.2", "@storybook/addon-links": "^7.6.7", @@ -103,6 +104,7 @@ "@web/test-runner-playwright": "^0.10.2", "@web/test-runner-puppeteer": "^0.14.0", "@webcomponents/webcomponentsjs": "^2.5.0", + "@whitespace/storybook-addon-html": "^5.1.6", "babel-loader": "^8.2.1", "core-js": "^3.31.0", "cpx": "^1.5.0", @@ -134,6 +136,7 @@ "prettier": "3.0.3", "react": "^17.0.1", "react-dom": "^17.0.1", + "react-syntax-highlighter": "^15.5.0", "regenerator-runtime": "^0.13.7", "rollup": "^4.9.6", "rollup-plugin-postcss": "^4.0.2", @@ -158,7 +161,8 @@ } }, "resolutions": { - "responselike": "2.0.0" + "responselike": "2.0.0", + "@whitespace/storybook-addon-html@^5.1.6": "patch:@whitespace/storybook-addon-html@npm%3A5.1.6#./.yarn/patches/@whitespace-storybook-addon-html-npm-5.1.6-9888d34906.patch" }, "packageManager": "yarn@3.6.3" } diff --git a/packages/mgt-components/src/components/mgt-login/mgt-login.ts b/packages/mgt-components/src/components/mgt-login/mgt-login.ts index 5b168c0d73..0d135cb1c8 100644 --- a/packages/mgt-components/src/components/mgt-login/mgt-login.ts +++ b/packages/mgt-components/src/components/mgt-login/mgt-login.ts @@ -612,7 +612,7 @@ export class MgtLogin extends MgtTemplatedTaskComponent { `; diff --git a/packages/mgt-components/src/components/mgt-person/mgt-person.ts b/packages/mgt-components/src/components/mgt-person/mgt-person.ts index 52e4846781..e3cee46407 100644 --- a/packages/mgt-components/src/components/mgt-person/mgt-person.ts +++ b/packages/mgt-components/src/components/mgt-person/mgt-person.ts @@ -74,7 +74,6 @@ export const registerMgtPersonComponent = () => { * @fires {CustomEvent} line4clicked - Fired when line4 is clicked * * @cssprop --person-background-color - {Color} the color of the person component background. - * @cssprop --person-background-border-radius - {Length} the border radius of the person component. Default is 4px. * * @cssprop --person-avatar-size - {Length} the width and height of the avatar. Default is 24px. * @cssprop --person-avatar-border - {String} the border around an avatar. Default is none. @@ -83,7 +82,8 @@ export const registerMgtPersonComponent = () => { * @cssprop --person-initials-text-color - {Color} the color of initials in an avatar. * @cssprop --person-initials-background-color - {Color} the color of the background in an avatar with initials. * - * @cssprop --person-details-spacing - {Length} the space between the avatar and the person details. Default is 12px. + * @cssprop --person-details-left-spacing - {Length} the space between the avatar and the person details. Default is 12px. + * @cssprop --person-details-bottom-spacing - {Length} the space between the bottom of the detail block and the bottom on the component. Default is 0. * * @cssprop --person-line1-font-size - {String} the font-size of the line 1 text. Default is 14px. * @cssprop --person-line1-font-weight - {Length} the font weight of the line 1 text. Default is 600. @@ -239,7 +239,7 @@ export class MgtPerson extends MgtTemplatedTaskComponent { attribute: 'show-presence', type: Boolean }) - public showPresence: boolean; + public showPresence = false; /** * determines person component avatar size and apply presence badge accordingly. @@ -252,7 +252,7 @@ export class MgtPerson extends MgtTemplatedTaskComponent { attribute: 'avatar-size', type: String }) - public avatarSize: AvatarSize; + public avatarSize: AvatarSize = 'auto'; /** * object containing Graph details on person @@ -332,11 +332,10 @@ export class MgtPerson extends MgtTemplatedTaskComponent { attribute: 'fetch-image', type: Boolean }) - public fetchImage: boolean; + public fetchImage = false; /** - * Sets whether to disable the person image fetch - * from the Microsoft Graph + * Sets whether to disable the person image fetch from the Microsoft Graph * * @type {boolean} * @memberof MgtPerson @@ -345,7 +344,7 @@ export class MgtPerson extends MgtTemplatedTaskComponent { attribute: 'disable-image-fetch', type: Boolean }) - public disableImageFetch: boolean; + public disableImageFetch = false; /** * Sets the vertical layout of @@ -398,6 +397,7 @@ export class MgtPerson extends MgtTemplatedTaskComponent { * Valid options are: 'none', 'hover', or 'click' * Set to 'none' to not show the card * + * @default PersonCardInteraction.none * @type {PersonCardInteraction} * @memberof MgtPerson */ @@ -869,16 +869,16 @@ export class MgtPerson extends MgtTemplatedTaskComponent { // Render the line1 template const template = this.renderTemplate('line1', { person }); details.push(html` -
- this.handleLine1Clicked()} role="presentation" aria-label="${line1text}">${template}
- `); +
+ this.handleLine1Clicked()} role="presentation" aria-label="${line1text}">${template}
+`); } else { // Render the line1 property value if (line1text) { details.push(html` -
- this.handleLine1Clicked()} role="presentation" aria-label="${line1text}">${line1text}
- `); +
+ this.handleLine1Clicked()} role="presentation" aria-label="${line1text}">${line1text}
+`); } } @@ -889,16 +889,16 @@ export class MgtPerson extends MgtTemplatedTaskComponent { // Render the line2 template const template = this.renderTemplate('line2', { person }); details.push(html` -
- this.handleLine2Clicked()} role="presentation" aria-label="${text}">${template}
- `); +
+ this.handleLine2Clicked()} role="presentation" aria-label="${text}">${template}
+`); } else { // Render the line2 property value if (text) { details.push(html` -
- this.handleLine2Clicked()} role="presentation" aria-label="${text}">${text}
- `); +
+ this.handleLine2Clicked()} role="presentation" aria-label="${text}">${text}
+`); } } } @@ -910,16 +910,16 @@ export class MgtPerson extends MgtTemplatedTaskComponent { // Render the line3 template const template = this.renderTemplate('line3', { person }); details.push(html` -
- this.handleLine3Clicked()} role="presentation" aria-label="${text}">${template}
+
+ this.handleLine3Clicked()} role="presentation" aria-label="${text}">${template}
`); } else { // Render the line3 property value if (text) { details.push(html` -
- this.handleLine3Clicked()} role="presentation" aria-label="${text}">${text}
- `); +
+ this.handleLine3Clicked()} role="presentation" aria-label="${text}">${text}
+`); } } } diff --git a/packages/mgt-element/src/utils/version.ts b/packages/mgt-element/src/utils/version.ts index 2656ea5067..19794f158e 100644 --- a/packages/mgt-element/src/utils/version.ts +++ b/packages/mgt-element/src/utils/version.ts @@ -8,4 +8,4 @@ // THIS FILE IS AUTO GENERATED // ANY CHANGES WILL BE LOST DURING BUILD -export const PACKAGE_VERSION = '3.1.3'; +export const PACKAGE_VERSION = '4.0.0'; diff --git a/packages/providers/mgt-msal2-provider/src/Msal2Provider.ts b/packages/providers/mgt-msal2-provider/src/Msal2Provider.ts index c4808992b7..6180b45db4 100644 --- a/packages/providers/mgt-msal2-provider/src/Msal2Provider.ts +++ b/packages/providers/mgt-msal2-provider/src/Msal2Provider.ts @@ -24,7 +24,7 @@ import { InteractionRequiredAuthError, SsoSilentRequest, EventMessage, - AuthenticationResult + EventType } from '@azure/msal-browser'; import { AuthenticationProviderOptions } from '@microsoft/microsoft-graph-client'; @@ -423,7 +423,7 @@ export class Msal2Provider extends IProvider { } private readonly handleMsalEvent = (message: EventMessage): void => { - if (message.eventType === 'msal:acquireTokenSuccess' && 'scopes' in message.payload) { + if (message.eventType === EventType.ACQUIRE_TOKEN_SUCCESS && 'scopes' in message.payload) { this.approvedScopes = message.payload.scopes; } }; diff --git a/stories/components/person/person.interactive.stories.js b/stories/components/person/person.interactive.stories.js new file mode 100644 index 0000000000..480e9740d8 --- /dev/null +++ b/stories/components/person/person.interactive.stories.js @@ -0,0 +1,262 @@ +/** + * ------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. + * See License in the project root for license information. + * ------------------------------------------------------------------------------------------- + */ + +import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; + +const objectToStyleRules = obj => { + return Object.keys(obj) + .map(key => `${key}: ${obj[key]}`) + .join(';\n\t'); +}; + +const PersonArgs = { + view: 'twolines', + 'person-query': 'me', + 'show-presence': true +}; + +const PersonArgTypes = { + 'avatar-type': { + options: ['initials', 'photo'], + control: { type: 'select' } + }, + 'avatar-size': { + options: ['auto', 'small', 'large'], + control: { type: 'select' } + }, + view: { + options: ['image', 'oneline', 'twolines', 'threelines', 'fourlines'], + control: { type: 'inline-radio' } + }, + 'person-card': { + options: ['none', 'hover', 'click'], + control: { type: 'inline-radio' } + }, + 'person-query': { control: { type: 'text' } }, + 'person-image': { control: { type: 'text' } }, + 'user-id': { control: { type: 'text' } }, + 'show-presence': { control: { type: 'boolean' } }, + 'vertical-layout': { control: { type: 'boolean' } }, + 'fetch-image': { control: { type: 'boolean' } }, + 'disable-image-fetch': { control: { type: 'boolean' } }, + 'line1-property': { control: { type: 'text' } }, + 'line2-property': { control: { type: 'text' } }, + 'line3-property': { control: { type: 'text' } }, + 'line4-property': { control: { type: 'text' } }, + 'person-details': { control: { type: 'object' } }, + 'fallback-details': { control: { type: 'object' } }, + 'person-presence': { control: { type: 'object' } }, + '--person-background-color': { control: { type: 'color' } }, + '--person-avatar-size': { control: { type: 'text' } }, + '--person-avatar-border': { control: { type: 'text' } }, + '--person-avatar-border-radius': { control: { type: 'text' } }, + '--person-initials-text-color': { control: { type: 'color' } }, + '--person-initials-background-color': { control: { type: 'color' } }, + '--person-line1-font-size': { control: { type: 'text' } }, + '--person-line1-font-weight': { control: { type: 'number', max: 1000, min: 100, step: 100 } }, + '--person-line1-text-color': { control: { type: 'color' } }, + '--person-line1-text-transform': { control: { type: 'text' } }, + '--person-line1-text-line-height': { control: { type: 'text' } }, + '--person-line2-font-size': { control: { type: 'text' } }, + '--person-line2-font-weight': { control: { type: 'number', max: 1000, min: 100, step: 100 } }, + '--person-line2-text-color': { control: { type: 'color' } }, + '--person-line2-text-transform': { control: { type: 'text' } }, + '--person-line2-text-line-height': { control: { type: 'text' } }, + '--person-line3-font-size': { control: { type: 'text' } }, + '--person-line3-font-weight': { control: { type: 'text' } }, + '--person-line3-text-color': { control: { type: 'color' } }, + '--person-line3-text-transform': { control: { type: 'text' } }, + '--person-line3-text-line-height': { control: { type: 'text' } }, + '--person-line4-font-size': { control: { type: 'text' } }, + '--person-line4-font-weight': { control: { type: 'number', max: 1000, min: 100, step: 100 } }, + '--person-line4-text-color': { control: { type: 'color' } }, + '--person-line4-text-transform': { control: { type: 'text' } }, + '--person-line4-text-line-height': { control: { type: 'text' } }, + '--person-details-left-spacing': { control: { type: 'text' } }, + '--person-details-bottom-spacing': { control: { type: 'text' } } +}; + +export default { + title: 'Components / mgt-person / Interactive', + component: 'person', + argTypes: PersonArgTypes, + args: PersonArgs, + parameters: { + controls: { + // this uses the expanded docs from the custom elements manifest to add descriptions to the controls panel + expanded: true, + // use include to trim the list of args in the controls panel + include: Object.keys(PersonArgTypes), + sort: 'requiredFirst' + }, + options: { showPanel: true } + }, + render: ({ + 'avatar-type': avatarType, + 'avatar-size': avatarSize, + view, + 'person-query': personQuery, + 'person-image': personImage, + 'user-id': userId, + 'person-card': personCardInteraction, + 'show-presence': showPresence, + 'vertical-layout': verticalLayout, + 'fetch-image': fetchImage, + 'disable-image-fetch': disableImageFetch, + 'line1-property': line1Property, + 'line2-property': line2Property, + 'line3-property': line3Property, + 'line4-property': line4Property, + 'person-details': personDetails, + 'fallback-details': fallbackDetails, + 'person-presence': personPresence, + '--person-background-color': personBackgroundColor, + '--person-avatar-size': personAvatarSize, + '--person-avatar-border': personAvatarBorder, + '--person-avatar-border-radius': personAvatarBorderRadius, + '--person-initials-text-color': personInitialsTextColor, + '--person-initials-background-color': personInitialsBackgroundColor, + '--person-line1-font-size': personLine1FontSize, + '--person-line1-font-weight': personLine1FontWeight, + '--person-line1-text-color': personLine1TextColor, + '--person-line1-text-transform': personLine1TextTransform, + '--person-line1-text-line-height': personLine1TextLineHeight, + '--person-line2-font-size': personLine2FontSize, + '--person-line2-font-weight': personLine2FontWeight, + '--person-line2-text-color': personLine2TextColor, + '--person-line2-text-transform': personLine2TextTransform, + '--person-line2-text-line-height': personLine2TextLineHeight, + '--person-line3-font-size': personLine3FontSize, + '--person-line3-font-weight': personLine3FontWeight, + '--person-line3-text-color': personLine3TextColor, + '--person-line3-text-transform': personLine3TextTransform, + '--person-line3-text-line-height': personLine3TextLineHeight, + '--person-line4-font-size': personLine4FontSize, + '--person-line4-font-weight': personLine4FontWeight, + '--person-line4-text-color': personLine4TextColor, + '--person-line4-text-transform': personLine4TextTransform, + '--person-line4-text-line-height': personLine4TextLineHeight, + '--person-details-left-spacing': personDetailsLeftSpacing, + '--person-details-bottom-spacing': personDetailsBottomSpacing + }) => { + const styles = {}; + if (personBackgroundColor) { + styles['--person-background-color'] = personBackgroundColor; + } + if (personAvatarSize) { + styles['--person-avatar-size'] = personAvatarSize; + } + if (personAvatarBorder) { + styles['--person-avatar-border'] = personAvatarBorder; + } + if (personAvatarBorderRadius) { + styles['--person-avatar-border-radius'] = personAvatarBorderRadius; + } + if (personInitialsTextColor) { + styles['--person-initials-text-color'] = personInitialsTextColor; + } + if (personInitialsBackgroundColor) { + styles['--person-initials-background-color'] = personInitialsBackgroundColor; + } + if (personLine1FontSize) { + styles['--person-line1-font-size'] = personLine1FontSize; + } + if (personLine1FontWeight) { + styles['--person-line1-font-weight'] = personLine1FontWeight; + } + if (personLine1TextColor) { + styles['--person-line1-text-color'] = personLine1TextColor; + } + if (personLine1TextTransform) { + styles['--person-line1-text-transform'] = personLine1TextTransform; + } + if (personLine1TextLineHeight) { + styles['--person-line1-text-line-height'] = personLine1TextLineHeight; + } + if (personLine2FontSize) { + styles['--person-line2-font-size'] = personLine2FontSize; + } + if (personLine2FontWeight) { + styles['--person-line2-font-weight'] = personLine2FontWeight; + } + if (personLine2TextColor) { + styles['--person-line2-text-color'] = personLine2TextColor; + } + if (personLine2TextTransform) { + styles['--person-line2-text-transform'] = personLine2TextTransform; + } + if (personLine2TextLineHeight) { + styles['--person-line2-text-line-height'] = personLine2TextLineHeight; + } + if (personLine3FontSize) { + styles['--person-line3-font-size'] = personLine3FontSize; + } + if (personLine3FontWeight) { + styles['--person-line3-font-weight'] = personLine3FontWeight; + } + if (personLine3TextColor) { + styles['--person-line3-text-color'] = personLine3TextColor; + } + if (personLine3TextTransform) { + styles['--person-line3-text-transform'] = personLine3TextTransform; + } + if (personLine3TextLineHeight) { + styles['--person-line3-text-line-height'] = personLine3TextLineHeight; + } + if (personLine4FontSize) { + styles['--person-line4-font-size'] = personLine4FontSize; + } + if (personLine4FontWeight) { + styles['--person-line4-font-weight'] = personLine4FontWeight; + } + if (personLine4TextColor) { + styles['--person-line4-text-color'] = personLine4TextColor; + } + if (personLine4TextTransform) { + styles['--person-line4-text-transform'] = personLine4TextTransform; + } + if (personLine4TextLineHeight) { + styles['--person-line4-text-line-height'] = personLine4TextLineHeight; + } + if (personDetailsLeftSpacing) { + styles['--person-details-left-spacing'] = personDetailsLeftSpacing; + } + if (personDetailsBottomSpacing) { + styles['--person-details-bottom-spacing'] = personDetailsBottomSpacing; + } + return html` + + +`; + } +}; + +export const interactive = { args: PersonArgs }; diff --git a/stories/components/person/person.style.stories.js b/stories/components/person/person.style.stories.js index cb6e1d70f4..5a55fbafd5 100644 --- a/stories/components/person/person.style.stories.js +++ b/stories/components/person/person.style.stories.js @@ -18,7 +18,6 @@ export const customCSSProperties = () => html`