init component

This commit is contained in:
Robin COuret
2026-02-16 17:28:37 +01:00
parent 460c7a25e0
commit e0e50af706
4557 changed files with 666911 additions and 8 deletions

View File

@@ -0,0 +1,34 @@
import { Eq } from 'fp-ts/lib/Eq';
import { IO } from 'fp-ts/lib/IO';
import { VNode } from 'vue';
import { Transition, TransitionClasses } from '../../types/Transition';
export interface PopupOptions {
transition: Transition;
render: IO<VNode[]>;
}
export interface Popup extends PopupOptions {
transition: TransitionClasses;
id: number;
}
export declare const eqPopup: Eq<Popup>;
export declare const removePopup: (a: Popup, as: Popup[]) => Popup[];
declare const BPopupContainer: import("vue").DefineComponent<{}, {
showPopup: (options: PopupOptions) => IO<void>;
popups: {
transition: {
css?: boolean | undefined;
name?: string | undefined;
'enter-from-class'?: string | undefined;
'enter-active-class'?: string | undefined;
'enter-to-class'?: string | undefined;
'leave-from-class'?: string | undefined;
'leave-active-class'?: string | undefined;
'leave-to-class'?: string | undefined;
};
id: number;
render: IO<VNode[]>;
}[];
rootZ: import("vue").ComputedRef<-1 | 999>;
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {}>, {}>;
export declare type PopupContainer = InstanceType<typeof BPopupContainer>;
export default BPopupContainer;

View File

@@ -0,0 +1,66 @@
import { eq, eqNumber } from 'fp-ts/lib/Eq';
import { defineComponent, h, Transition as transition, reactive, computed, nextTick } from 'vue';
import { formatTransition } from '../../composables/transition';
import { constEmptyArray, removeListItem } from '../../utils/helpers';
export const eqPopup = eq.contramap(eqNumber, popup => popup.id);
export const removePopup = removeListItem(eqPopup);
const z = 999;
let id = 0;
function generatePopup(popup, index) {
return h('div', {
key: popup.id,
style: {
'z-index': z + index + 1
}
}, [h(transition, popup.transition, popup.render)]);
}
const BPopupContainer = defineComponent({
name: 'b-popup-container',
setup() {
const popups = reactive([]);
function showPopup(options) {
const nid = id++;
const popup = reactive({
id: nid,
render: constEmptyArray,
transition: formatTransition(options.transition)
});
popups.push(popup);
nextTick().then(() => {
popup.render = options.render;
});
return () => {
popup.render = constEmptyArray;
setTimeout(() => {
const index = popups.findIndex(p => p.id === nid);
if (index > 0) {
popups.splice(index, 1);
}
}, 250);
};
}
const rootZ = computed(() => popups.length ? z : -1);
return {
showPopup,
popups,
rootZ
};
},
render() {
return h('div', {
style: {
'z-index': this.rootZ
}
}, this.rootZ ? this.popups.map(generatePopup) : undefined);
}
});
export default BPopupContainer;
//# sourceMappingURL=BPopupContainer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/popupContainer/BPopupContainer.ts"],"names":[],"mappings":"AAAA,SAAa,EAAb,EAAiB,QAAjB,QAAiC,cAAjC;AAEA,SAAgB,eAAhB,EAAiC,CAAjC,EAAoC,UAAU,IAAI,UAAlD,EAA8D,QAA9D,EAAwE,QAAxE,EAAkF,QAAlF,QAAkG,KAAlG;AACA,SAAS,gBAAT,QAAiC,8BAAjC;AAEA,SAAS,eAAT,EAA0B,cAA1B,QAAgD,qBAAhD;AAYA,OAAO,MAAM,OAAO,GAAc,EAAE,CAAC,SAAH,CAAa,QAAb,EAAuB,KAAK,IAAI,KAAK,CAAC,EAAtC,CAA3B;AAEP,OAAO,MAAM,WAAW,GAAG,cAAc,CAAC,OAAD,CAAlC;AAEP,MAAM,CAAC,GAAG,GAAV;AAEA,IAAI,EAAE,GAAG,CAAT;;AAEA,SAAS,aAAT,CAAuB,KAAvB,EAAqC,KAArC,EAAkD;AAChD,SAAO,CAAC,CAAC,KAAD,EAAQ;AAAE,IAAA,GAAG,EAAE,KAAK,CAAC,EAAb;AAAiB,IAAA,KAAK,EAAE;AAAE,iBAAW,CAAC,GAAG,KAAJ,GAAY;AAAzB;AAAxB,GAAR,EAAgE,CACtE,CAAC,CAAC,UAAD,EAAa,KAAK,CAAC,UAAnB,EAA+B,KAAK,CAAC,MAArC,CADqE,CAAhE,CAAR;AAGD;;AAED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AgB,aAAhB,CAAb,GAA8C,SAA5F,CAAR;AACD;;AAlCqC,CAAD,CAAvC;AAuCA,eAAe,eAAf","sourcesContent":["import { Eq, eq, eqNumber } from 'fp-ts/lib/Eq';\nimport { IO } from 'fp-ts/lib/IO';\nimport { VNode, defineComponent, h, Transition as transition, reactive, computed, nextTick } from 'vue';\nimport { formatTransition } from '../../composables/transition';\nimport { Transition, TransitionClasses } from '../../types/Transition';\nimport { constEmptyArray, removeListItem } from '../../utils/helpers';\n\nexport interface PopupOptions {\n transition: Transition;\n render: IO<VNode[]>;\n}\n\nexport interface Popup extends PopupOptions {\n transition: TransitionClasses;\n id: number;\n}\n\nexport const eqPopup: Eq<Popup> = eq.contramap(eqNumber, popup => popup.id);\n\nexport const removePopup = removeListItem(eqPopup);\n\nconst z = 999;\n\nlet id = 0;\n\nfunction generatePopup(popup: Popup, index: number): VNode {\n return h('div', { key: popup.id, style: { 'z-index': z + index + 1 } }, [\n h(transition, popup.transition, popup.render)\n ]);\n}\n\nconst BPopupContainer = defineComponent({\n name: 'b-popup-container',\n setup() {\n const popups = reactive<Popup[]>([]);\n function showPopup(options: PopupOptions): IO<void> {\n const nid = id++;\n const popup = reactive({\n id: nid,\n render: constEmptyArray as IO<VNode[]>,\n transition: formatTransition(options.transition)\n });\n popups.push(popup);\n nextTick().then(() => {\n popup.render = options.render;\n });\n return () => {\n popup.render = constEmptyArray;\n setTimeout(() => {\n const index = popups.findIndex(p => p.id === nid);\n if (index > 0) {\n popups.splice(index, 1);\n }\n }, 250);\n };\n }\n const rootZ = computed(() => (popups.length ? z : -1));\n return {\n showPopup,\n popups,\n rootZ\n };\n },\n render(): VNode {\n return h('div', { style: { 'z-index': this.rootZ } }, this.rootZ ? this.popups.map(generatePopup) : undefined);\n }\n});\n\nexport type PopupContainer = InstanceType<typeof BPopupContainer>;\n\nexport default BPopupContainer;\n"],"sourceRoot":"","file":"BPopupContainer.js"}

View File

@@ -0,0 +1,3 @@
import BPopupContainer from './BPopupContainer';
export { BPopupContainer };
export default BPopupContainer;

View File

@@ -0,0 +1,4 @@
import BPopupContainer from './BPopupContainer';
export { BPopupContainer };
export default BPopupContainer;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/popupContainer/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAP,MAA4B,mBAA5B;AAEA,SAAS,eAAT;AAEA,eAAe,eAAf","sourcesContent":["import BPopupContainer from './BPopupContainer';\n\nexport { BPopupContainer };\n\nexport default BPopupContainer;\n"],"sourceRoot":"","file":"index.js"}