build: switch from yarn to npm to manage js dependencies and move js contents to root

yarn v1 is being deprecated and starts to have some issues

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-11-14 17:24:42 +01:00
parent 32055122c3
commit 2e72f6faf4
595 changed files with 12078 additions and 7843 deletions

22
src/plugins/dateFns.ts Normal file
View File

@@ -0,0 +1,22 @@
import type { Locale } from "date-fns";
import { App } from "vue";
export const dateFnsPlugin = {
install(app: App, options: { locale: string }) {
function dateFnsfileForLanguage(lang: string) {
const matches: Record<string, string> = {
en: "en-US",
};
return matches[lang] ?? lang.replace("_", "-");
}
import(
`../../node_modules/date-fns/esm/locale/${dateFnsfileForLanguage(
options.locale
)}/index.js`
).then((localeEntity: { default: Locale }) => {
app.provide("dateFnsLocale", localeEntity.default);
app.config.globalProperties.$dateFnsLocale = localeEntity.default;
});
},
};

102
src/plugins/dialog.ts Normal file
View File

@@ -0,0 +1,102 @@
import DialogComponent from "@/components/core/CustomDialog.vue";
import { App } from "vue";
export class Dialog {
private app: App;
constructor(app: App) {
this.app = app;
}
prompt({
title,
message,
confirmText,
cancelText,
variant,
hasIcon,
size,
onConfirm,
onCancel,
inputAttrs,
hasInput,
}: {
title?: string;
message: string;
confirmText?: string;
cancelText?: string;
variant?: string;
hasIcon?: boolean;
size?: string;
onConfirm?: (prompt: string) => void;
onCancel?: (source: string) => void;
inputAttrs?: Record<string, any>;
hasInput?: boolean;
}) {
this.app.config.globalProperties.$oruga.modal.open({
component: DialogComponent,
props: {
title,
message,
confirmText,
cancelText,
variant,
hasIcon,
size,
onConfirm,
onCancel,
inputAttrs,
hasInput,
},
autoFocus: false,
contentClass: "!w-11/12",
});
}
confirm({
title,
message,
confirmText,
cancelText,
variant,
hasIcon,
size,
onConfirm,
onCancel,
}: {
title: string;
message: string;
confirmText?: string;
cancelText?: string;
variant: string;
hasIcon?: boolean;
size?: string;
onConfirm: () => any;
onCancel?: (source: string) => any;
}) {
console.debug("confirming something");
this.app.config.globalProperties.$oruga.modal.open({
component: DialogComponent,
props: {
title,
message,
confirmText,
cancelText,
variant,
hasIcon,
size,
onConfirm,
onCancel,
},
contentClass: "!w-11/12",
});
}
}
export const dialogPlugin = {
install(app: App) {
const dialog = new Dialog(app);
app.config.globalProperties.$dialog = dialog;
app.provide("dialog", dialog);
},
};

39
src/plugins/notifier.ts Normal file
View File

@@ -0,0 +1,39 @@
import { App } from "vue";
export class Notifier {
private app: App;
constructor(app: App) {
this.app = app;
}
success(message: string): void {
this.notification(message, "success");
}
error(message: string): void {
this.notification(message, "danger");
}
info(message: string): void {
this.notification(message, "info");
}
private notification(message: string, type: string) {
this.app.config.globalProperties.$oruga.notification.open({
message,
duration: 5000,
position: "bottom-right",
type,
hasIcon: true,
});
}
}
export const notifierPlugin = {
install(app: App) {
const notifier = new Notifier(app);
app.config.globalProperties.$notifier = notifier;
app.provide("notifier", notifier);
},
};

53
src/plugins/snackbar.ts Normal file
View File

@@ -0,0 +1,53 @@
import SnackbarComponent from "@/components/core/CustomSnackbar.vue";
import { App } from "vue";
export class Snackbar {
private app: App;
constructor(app: App) {
this.app = app;
}
open({
message,
variant,
position,
actionText,
cancelText,
onAction,
}: {
message?: string;
queue?: boolean;
indefinite?: boolean;
variant?: string;
position?: string;
actionText?: string;
cancelText?: string;
onAction?: () => any;
}) {
this.app.config.globalProperties.$oruga.notification.open({
component: SnackbarComponent,
props: {
message,
// queue,
// indefinite,
actionText,
cancelText,
onAction,
position: position ?? "bottom-right",
variant: variant ?? "dark",
},
position: position ?? "bottom-right",
variant: variant ?? "dark",
duration: 5000000,
});
}
}
export const snackbarPlugin = {
install(app: App) {
const snackbar = new Snackbar(app);
app.config.globalProperties.$snackbar = snackbar;
app.provide("snackbar", snackbar);
},
};