Fixed #1040 - Remove mitt

pull/1047/head
Cagatay Civici 2021-03-02 11:54:37 +03:00
parent 72148cbb73
commit d51cc9607d
25 changed files with 52 additions and 68 deletions

View File

@ -48,7 +48,6 @@
"gulp-rename": "^1.2.2", "gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.3", "gulp-uglify": "^1.5.3",
"gulp-uglifycss": "^1.0.6", "gulp-uglifycss": "^1.0.6",
"mitt": "^2.1.0",
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"primeflex": "2.0.0", "primeflex": "2.0.0",
"primeicons": "4.1.0", "primeicons": "4.1.0",

View File

@ -35,7 +35,7 @@ import AppTopBar from '@/AppTopBar.vue';
import AppMenu from '@/AppMenu.vue'; import AppMenu from '@/AppMenu.vue';
import AppFooter from '@/AppFooter.vue'; import AppFooter from '@/AppFooter.vue';
import AppConfigurator from '@/AppConfigurator.vue'; import AppConfigurator from '@/AppConfigurator.vue';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
data() { data() {

View File

@ -350,7 +350,7 @@
</template> </template>
<script> <script>
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
props: { props: {

3
src/AppEventBus.js Normal file
View File

@ -0,0 +1,3 @@
import {EventBus} from 'primevue/utils';
export default EventBus();

View File

@ -1,3 +0,0 @@
import mitt from 'mitt';
const EventBus = mitt();
export default EventBus;

View File

@ -1,4 +1,3 @@
import mitt from 'mitt'; import {EventBus} from 'primevue/utils';
const EventBus = mitt();
export default EventBus; export default EventBus();

View File

@ -1,4 +1,3 @@
import mitt from 'mitt'; import {EventBus} from 'primevue/utils';
const TerminalService = mitt();
export default TerminalService; export default EventBus();

View File

@ -1,4 +1,3 @@
import mitt from 'mitt'; import {EventBus} from 'primevue/utils';
const EventBus = mitt();
export default EventBus; export default EventBus();

View File

@ -0,0 +1,25 @@
export default function handler() {
let eventTarget = document.body.appendChild(document.createComment(''));
let eventListener, eventKey;
return {
on(type, listener, key) {
eventKey = key;
eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener);
},
once(type, listener, key) {
eventKey = key;
eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener, { once: true });
},
off(type, key) {
if (eventListener && eventKey === key) {
eventTarget.removeEventListener(type, eventListener);
}
},
emit(type, detail) {
eventTarget.dispatchEvent(new CustomEvent(type, { detail }));
}
}
}

View File

@ -2,5 +2,6 @@ import ConnectedOverlayScrollHandler from './ConnectedOverlayScrollHandler';
import DomHandler from './DomHandler'; import DomHandler from './DomHandler';
import ObjectUtils from './ObjectUtils'; import ObjectUtils from './ObjectUtils';
import UniqueComponentId from './UniqueComponentId'; import UniqueComponentId from './UniqueComponentId';
import EventBus from './EventBus';
export {ConnectedOverlayScrollHandler,DomHandler,ObjectUtils,UniqueComponentId}; export {ConnectedOverlayScrollHandler,DomHandler,ObjectUtils,UniqueComponentId,EventBus};

View File

@ -223,7 +223,7 @@
</template> </template>
<script> <script>
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
data() { data() {

View File

@ -35,7 +35,7 @@
<script> <script>
import BarChartDoc from './BarChartDoc'; import BarChartDoc from './BarChartDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
mounted() { mounted() {

View File

@ -19,7 +19,7 @@
<script> <script>
import ComboChartDoc from './ComboChartDoc'; import ComboChartDoc from './ComboChartDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
mounted() { mounted() {

View File

@ -19,7 +19,7 @@
<script> <script>
import DoughnutChartDoc from './DoughnutChartDoc'; import DoughnutChartDoc from './DoughnutChartDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
mounted() { mounted() {

View File

@ -30,7 +30,7 @@
<script> <script>
import LineChartDoc from './LineChartDoc'; import LineChartDoc from './LineChartDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
mounted() { mounted() {

View File

@ -19,7 +19,7 @@
<script> <script>
import PieChartDoc from './PieChartDoc'; import PieChartDoc from './PieChartDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
mounted() { mounted() {

View File

@ -19,7 +19,7 @@
<script> <script>
import PolarAreaChartDoc from './PolarAreaChartDoc'; import PolarAreaChartDoc from './PolarAreaChartDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
mounted() { mounted() {

View File

@ -19,7 +19,7 @@
<script> <script>
import RadarChartDoc from './RadarChartDoc'; import RadarChartDoc from './RadarChartDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
mounted() { mounted() {

View File

@ -2,13 +2,6 @@
<div class="content-section documentation"> <div class="content-section documentation">
<TabView> <TabView>
<TabPanel header="Documentation"> <TabPanel header="Documentation">
<h5>Mitt EventBus</h5>
<p>ConfirmDialog requires <a href="https://www.npmjs.com/package/mitt">Mitt</a>, a tiny 200b EventBus implementation.</p>
<pre v-code><code>
npm install mitt --save
</code></pre>
<h5>ConfirmationService</h5> <h5>ConfirmationService</h5>
<p>ConfirmDialog is controlled via the <i>ConfirmationService</i> that needs to be installed globally before the application <p>ConfirmDialog is controlled via the <i>ConfirmationService</i> that needs to be installed globally before the application
instance is created.</p> instance is created.</p>
@ -247,7 +240,7 @@ export default {
</div> </div>
<h5>Dependencies</h5> <h5>Dependencies</h5>
<p>Mitt.</p> <p>None.</p>
</TabPanel> </TabPanel>
<TabPanel header="Source"> <TabPanel header="Source">

View File

@ -2,13 +2,6 @@
<div class="content-section documentation"> <div class="content-section documentation">
<TabView> <TabView>
<TabPanel header="Documentation"> <TabPanel header="Documentation">
<h5>Mitt EventBus</h5>
<p>ConfirmPopup requires <a href="https://www.npmjs.com/package/mitt">Mitt</a>, a tiny 200b EventBus implementation.</p>
<pre v-code><code>
npm install mitt --save
</code></pre>
<h5>ConfirmationService</h5> <h5>ConfirmationService</h5>
<p>ConfirmPopup is controlled via the <i>ConfirmationService</i> that needs to be installed globally before the application <p>ConfirmPopup is controlled via the <i>ConfirmationService</i> that needs to be installed globally before the application
instance is created.</p> instance is created.</p>
@ -247,7 +240,7 @@ export default {
</div> </div>
<h5>Dependencies</h5> <h5>Dependencies</h5>
<p>Mitt.</p> <p>None.</p>
</TabPanel> </TabPanel>
<TabPanel header="Source"> <TabPanel header="Source">

View File

@ -224,8 +224,6 @@ export const router = createRouter({
} }
if(this.toastService) { if(this.toastService) {
extDependencies['mitt'] = "^2.1.0";
imports += `import Toast from "primevue/toast"; imports += `import Toast from "primevue/toast";
import ToastService from "primevue/toastservice"; import ToastService from "primevue/toastservice";
`; `;
@ -242,10 +240,6 @@ import ToastService from "primevue/toastservice";
`; `;
} }
if(this.terminalService) {
extDependencies['mitt'] = "^2.1.0";
}
if(name !== 'ToastDemo' && name !== 'TooltipDemo' && name !== 'RippleDemo' && name !== 'FloatLabelDemo' && name !== 'InputGroupDemo' && name !== 'InvalidDemo' && name !== 'FormLayoutDemo') { if(name !== 'ToastDemo' && name !== 'TooltipDemo' && name !== 'RippleDemo' && name !== 'FloatLabelDemo' && name !== 'InputGroupDemo' && name !== 'InvalidDemo' && name !== 'FormLayoutDemo') {
element += `app.component("${name.slice(0, -4)}", ${name.slice(0, -4)});`; element += `app.component("${name.slice(0, -4)}", ${name.slice(0, -4)});`;
} }

View File

@ -148,10 +148,6 @@ dependencies: {
<td>PrimeFlex</td> <td>PrimeFlex</td>
<td>DataView</td> <td>DataView</td>
</tr> </tr>
<tr>
<td>Toast and Terminal</td>
<td>Mitt</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -128,7 +128,7 @@
<script> <script>
import TabViewDoc from './TabViewDoc'; import TabViewDoc from './TabViewDoc';
import EventBus from '@/EventBus'; import EventBus from '@/AppEventBus';
export default { export default {
data() { data() {

View File

@ -2,13 +2,6 @@
<div class="content-section documentation"> <div class="content-section documentation">
<TabView> <TabView>
<TabPanel header="Documentation"> <TabPanel header="Documentation">
<h5>Mitt EventBus</h5>
<p>Terminal requires <a href="https://www.npmjs.com/package/mitt">Mitt</a>, a tiny 200b EventBus implementation.</p>
<pre v-code><code>
npm install mitt --save
</code></pre>
<h5>Import</h5> <h5>Import</h5>
<pre v-code.script><code> <pre v-code.script><code>
import Terminal from 'primevue/terminal'; import Terminal from 'primevue/terminal';
@ -130,7 +123,7 @@ export default {
</div> </div>
<h5>Dependencies</h5> <h5>Dependencies</h5>
<p>Mitt.</p> <p>None.</p>
</TabPanel> </TabPanel>
<TabPanel header="Source"> <TabPanel header="Source">

View File

@ -2,13 +2,6 @@
<div class="content-section documentation"> <div class="content-section documentation">
<TabView> <TabView>
<TabPanel header="Documentation"> <TabPanel header="Documentation">
<h5>Mitt EventBus</h5>
<p>Toast requires <a href="https://www.npmjs.com/package/mitt">Mitt</a>, a tiny 200b EventBus implementation.</p>
<pre v-code><code>
npm install mitt --save
</code></pre>
<h5>ToastService</h5> <h5>ToastService</h5>
<p>Toast messages are dynamically created using a <i>ToastService</i> that needs to be installed globally before the application <p>Toast messages are dynamically created using a <i>ToastService</i> that needs to be installed globally before the application
instance is created.</p> instance is created.</p>
@ -270,7 +263,7 @@ this.$toast.add({severity:'success', summary: 'Specific Message', group: 'mykey'
</div> </div>
<h5>Dependencies</h5> <h5>Dependencies</h5>
<p>Mitt.</p> <p>None.</p>
</TabPanel> </TabPanel>
<TabPanel header="Source"> <TabPanel header="Source">