Skip to content

Commit

Permalink
Merge pull request #413 from eduzz/develop
Browse files Browse the repository at this point in the history
Versão 0.58.11
  • Loading branch information
ffernandomoraes authored Aug 12, 2022
2 parents d43257b + b186787 commit 8297d2c
Show file tree
Hide file tree
Showing 30 changed files with 573 additions and 164 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@eduzz/houston-workspaces",
"version": "0.58.10",
"version": "0.58.11",
"workspaces": [
"src/pages/*",
"src/dev",
Expand Down
8 changes: 4 additions & 4 deletions patches/dokz+2.0.9.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ index 95405f6..ead5cc7 100644
}
function makeGithubEditUrl(_a) {
diff --git a/node_modules/dokz/dist/components/Playground.js b/node_modules/dokz/dist/components/Playground.js
index c052028..7d09f8e 100644
index c052028..7f925ae 100644
--- a/node_modules/dokz/dist/components/Playground.js
+++ b/node_modules/dokz/dist/components/Playground.js
@@ -62,6 +62,7 @@ var provider_1 = require("../provider");
Expand All @@ -47,7 +47,7 @@ index c052028..7d09f8e 100644
- // transformCode: (code) => '/** @jsx mdx */' + code,
- scope: __assign(__assign({}, scope), { mdx: react_3.mdx }),
+ transformCode: (code) => {
+ return `<ThemeProvider disableToast disabledFontBase disableCssBaseline><div style={{ padding: 16 }}>${code.startsWith('()') ? `{React.createElement(${code})}` : code}</div></ThemeProvider>`
+ return `<ThemeProvider disableToast disableDialogs disabledFontBase disableCssBaseline><div style={{ padding: 16 }}>${code.startsWith('()') ? `{React.createElement(${code})}` : code}</div></ThemeProvider>`
+ },
+ scope: __assign(__assign({}, scope), { mdx: react_3.mdx, ThemeProvider: ThemeProvider.default }),
};
Expand Down Expand Up @@ -181,7 +181,7 @@ index 3ee818f..897dc4c 100644
}
function makeGithubEditUrl(_a) {
diff --git a/node_modules/dokz/esm/components/Playground.js b/node_modules/dokz/esm/components/Playground.js
index 86a74cf..5f1a929 100644
index 86a74cf..adefb53 100644
--- a/node_modules/dokz/esm/components/Playground.js
+++ b/node_modules/dokz/esm/components/Playground.js
@@ -37,6 +37,7 @@ import { useDokzConfig } from '../provider';
Expand All @@ -199,7 +199,7 @@ index 86a74cf..5f1a929 100644
- // transformCode: (code) => '/** @jsx mdx */' + code,
- scope: __assign(__assign({}, scope), { mdx: mdx }),
+ transformCode: (code) => {
+ return `<ThemeProvider disableToast disabledFontBase disableCssBaseline><div style={{ padding: 16 }}>${code.startsWith('()') ? `{React.createElement(${code})}` : code}</div></ThemeProvider>`
+ return `<ThemeProvider disableToast disableDialogs disabledFontBase disableCssBaseline><div style={{ padding: 16 }}>${code.startsWith('()') ? `{React.createElement(${code})}` : code}</div></ThemeProvider>`
+ },
+ scope: __assign(__assign({}, scope), { mdx: mdx, ThemeProvider: ThemeProvider }),
};
Expand Down
12 changes: 6 additions & 6 deletions src/dev/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@eduzz/houston-dev",
"version": "0.58.10",
"version": "0.58.11",
"private": true,
"dependencies": {
"@eduzz/apps-toolbar-react": "latest",
"@eduzz/houston-experimental": "0.58.10",
"@eduzz/houston-forms": "0.58.10",
"@eduzz/houston-hooks": "0.58.10",
"@eduzz/houston-icons": "0.58.10",
"@eduzz/houston-ui": "0.58.10",
"@eduzz/houston-experimental": "0.58.11",
"@eduzz/houston-forms": "0.58.11",
"@eduzz/houston-hooks": "0.58.11",
"@eduzz/houston-icons": "0.58.11",
"@eduzz/houston-ui": "0.58.11",
"react": "^17",
"react-dom": "^17",
"react-router-dom": "^6.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/dev/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function App() {
tag: 'unity'
}}
>
<Topbar.SupportChat />
{/* <Topbar.SupportChat /> */}

<Topbar.Action icon={<NotificationOutline size={25} />} />
<Topbar.Action icon={<InfoChatOutline size={25} />} />
Expand Down
12 changes: 6 additions & 6 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@eduzz/docs",
"version": "0.58.10",
"version": "0.58.11",
"private": true,
"scripts": {
"start": "next dev",
"build": "next build && next export"
},
"dependencies": {
"@chakra-ui/react": "^1.8.8",
"@eduzz/houston-experimental": "0.58.10",
"@eduzz/houston-forms": "0.58.10",
"@eduzz/houston-hooks": "0.58.10",
"@eduzz/houston-icons": "0.58.10",
"@eduzz/houston-ui": "0.58.10",
"@eduzz/houston-experimental": "0.58.11",
"@eduzz/houston-forms": "0.58.11",
"@eduzz/houston-hooks": "0.58.11",
"@eduzz/houston-icons": "0.58.11",
"@eduzz/houston-ui": "0.58.11",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"dokz": "2.0.9",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eduzz/houston-core",
"version": "0.58.10",
"version": "0.58.11",
"description": "Houston Core",
"main": "index.js",
"types": "./index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/eslint-config-houston",
"private": false,
"version": "0.58.10",
"version": "0.58.11",
"description": "Eduzz Houston Eslint Config",
"author": "Eduzz Team",
"license": "MIT",
Expand Down
10 changes: 5 additions & 5 deletions src/pages/experimental/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-experimental",
"description": "Eduzz Houston Experimental",
"version": "0.58.10",
"version": "0.58.11",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand All @@ -16,9 +16,9 @@
"url": "https://github.com/eduzz/houston/issues"
},
"dependencies": {
"@eduzz/houston-ui": "0.58.10",
"@eduzz/houston-hooks": "0.58.10",
"@eduzz/houston-icons": "0.58.10",
"@eduzz/houston-ui": "0.58.11",
"@eduzz/houston-hooks": "0.58.11",
"@eduzz/houston-icons": "0.58.11",
"@emotion/css": "^11",
"@mui/material": "^5",
"@mui/styles": "^5",
Expand All @@ -27,6 +27,6 @@
"tslib": "^2"
},
"peerDependencies": {
"@eduzz/houston-core": "0.58.10"
"@eduzz/houston-core": "0.58.11"
}
}
8 changes: 4 additions & 4 deletions src/pages/forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eduzz/houston-forms",
"version": "0.58.10",
"version": "0.58.11",
"description": "Houston Forms",
"main": "index.js",
"types": "./index.d.ts",
Expand All @@ -17,16 +17,16 @@
},
"dependencies": {
"formik": "^2.2.9",
"@eduzz/houston-core": "0.58.10",
"@eduzz/houston-hooks": "0.58.10",
"@eduzz/houston-core": "0.58.11",
"@eduzz/houston-hooks": "0.58.11",
"react-hook-form": "^7",
"@hookform/resolvers": "^2",
"@hookform/error-message": "^2.0.0",
"zod": "^3.17.3",
"yup": "^0.32.11"
},
"peerDependencies": {
"@eduzz/houston-core": "0.58.10"
"@eduzz/houston-core": "0.58.11"
},
"devDependencies": {}
}
4 changes: 2 additions & 2 deletions src/pages/hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-hooks",
"description": "Eduzz Houston Hooks",
"version": "0.58.10",
"version": "0.58.11",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand All @@ -16,7 +16,7 @@
"url": "https://github.com/eduzz/houston/issues"
},
"dependencies": {
"@eduzz/houston-core": "0.58.10",
"@eduzz/houston-core": "0.58.11",
"lodash": "^4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/icons/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-icons",
"description": "Eduzz Houston Icons",
"version": "0.58.10",
"version": "0.58.11",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/styles/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-styles",
"description": "Eduzz Houston Style",
"version": "0.58.10",
"version": "0.58.11",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand All @@ -16,7 +16,7 @@
"url": "https://github.com/eduzz/houston/issues"
},
"dependencies": {
"@eduzz/houston-tokens": "0.58.10",
"@eduzz/houston-tokens": "0.58.11",
"@emotion/css": "^11",
"@emotion/react": "^11",
"@emotion/styled": "^11",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tokens/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/houston-tokens",
"description": "Eduzz Houston Tokens",
"version": "0.58.10",
"version": "0.58.11",
"main": "./index.js",
"types": "./index.d.ts",
"author": "Eduzz Team",
Expand Down
6 changes: 5 additions & 1 deletion src/pages/ui-components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import nestedComponent from '../utils/nestedComponent';
import Content from './Content';
import DialogContextProvider from './context';
import Footer from './Footer';
import { showAlert, showConfirm } from './Global';
import Header from './Header';

export type DialogTypes = 'positive' | 'informative' | 'warning' | 'negative';
Expand Down Expand Up @@ -102,5 +103,8 @@ const DialogWrapper = styled(Dialog, { label: 'houston-dialog' })`
export default nestedComponent(React.memo(DialogWrapper), {
Header,
Content,
Footer
Footer,
// Evita referência circular, pois o Global depende do Dialog
alert: (params: Parameters<typeof showAlert>[0]) => showAlert(params),
confirm: (params: Parameters<typeof showConfirm>[0]) => showConfirm(params)
});
116 changes: 116 additions & 0 deletions src/pages/ui-components/Dialog/Global.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { memo, useState, useEffect } from 'react';

import usePromiseCallback from '@eduzz/houston-hooks/usePromiseCallback';

import Button from '../Button';
import Dialog from './Dialog';

export interface DialogShowParams {
message: React.ReactNode;
title?: string;
confirmation?: boolean;
onConfirm?(): Promise<any>;
onCancel?(): Promise<any>;
}

let lastPromise = Promise.resolve(false);
let componentCallback: null | ((params: DialogShowParams) => Promise<boolean>);

const DialogGlobal = memo(() => {
const [opened, setOpened] = useState<boolean>(false);
const [params, setParams] = useState<DialogShowParams>();
const [confirmLoading, setConfirmLoading] = useState<boolean>(false);
const [cancelLoading, setCancelLoading] = useState<boolean>(false);

const onReceiveParams = usePromiseCallback((isSubscribed, params: DialogShowParams): Promise<boolean> => {
const result = new Promise<boolean>((resolve, reject) => {
setOpened(true);
setConfirmLoading(false);
setCancelLoading(false);

setParams({
confirmation: false,
title: undefined,
...params,
onConfirm: async () => {
if (!params.onConfirm) {
resolve(true);
return;
}

try {
isSubscribed() && setConfirmLoading(true);
await Promise.resolve(params.onConfirm());
resolve(true);
} catch (err) {
reject(err);
} finally {
isSubscribed() && setConfirmLoading(false);
}
},
onCancel: async () => {
if (!params.onCancel) {
resolve(true);
return;
}

try {
isSubscribed() && setCancelLoading(true);
await Promise.resolve(params.onCancel());
resolve(false);
} catch (err) {
reject(err);
} finally {
isSubscribed() && setCancelLoading(false);
}
}
});
});

result.finally(() => setOpened(false));
return result;
}, []);

useEffect(() => {
componentCallback = onReceiveParams;
return () => {
componentCallback = null;
};
}, [onReceiveParams]);

return (
<Dialog visible={opened} onClose={params?.onCancel}>
<Dialog.Header>{params?.title ?? (params?.confirmation ? 'Confirmação' : 'Atenção')}</Dialog.Header>
<Dialog.Content>{params?.message}</Dialog.Content>
<Dialog.Footer>
{params?.confirmation && (
<Button onClick={params?.onCancel} variant='text' loading={cancelLoading} disabled={confirmLoading}>
Cancelar
</Button>
)}
<Button onClick={params?.onConfirm} loading={confirmLoading} disabled={cancelLoading}>
OK
</Button>
</Dialog.Footer>
</Dialog>
);
});

function callComponent(params: DialogShowParams): Promise<boolean> {
//prevent an alert to override another
return (lastPromise = lastPromise.finally(async () => {
await new Promise<void>(resolve => setTimeout(() => resolve(), 300));
if (!componentCallback) throw new Error('Please, initialize an DialogGlobal before');
return componentCallback(params);
}));
}

export function showAlert(params: string | Omit<DialogShowParams, 'confirmation' | 'onCancel'>) {
return callComponent(typeof params === 'string' ? { message: params } : params);
}

export function showConfirm(params: string | Omit<DialogShowParams, 'confirmation'>) {
return callComponent({ ...(typeof params === 'string' ? { message: params } : params), confirmation: true });
}

export default DialogGlobal;
Loading

0 comments on commit 8297d2c

Please sign in to comment.