Tracking de l'application VApp (IHM du jeu)
This commit is contained in:
192
VApp/node_modules/vuetify/lib/composables/nested/nested.mjs
generated
vendored
Normal file
192
VApp/node_modules/vuetify/lib/composables/nested/nested.mjs
generated
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
// Composables
|
||||
import { useProxiedModel } from "../proxiedModel.mjs"; // Utilities
|
||||
import { computed, inject, onBeforeUnmount, provide, ref, shallowRef, toRaw } from 'vue';
|
||||
import { listOpenStrategy, multipleOpenStrategy, singleOpenStrategy } from "./openStrategies.mjs";
|
||||
import { classicSelectStrategy, independentSelectStrategy, independentSingleSelectStrategy, leafSelectStrategy, leafSingleSelectStrategy } from "./selectStrategies.mjs";
|
||||
import { getCurrentInstance, getUid, propsFactory } from "../../util/index.mjs"; // Types
|
||||
export const VNestedSymbol = Symbol.for('vuetify:nested');
|
||||
export const emptyNested = {
|
||||
id: shallowRef(),
|
||||
root: {
|
||||
register: () => null,
|
||||
unregister: () => null,
|
||||
parents: ref(new Map()),
|
||||
children: ref(new Map()),
|
||||
open: () => null,
|
||||
openOnSelect: () => null,
|
||||
select: () => null,
|
||||
opened: ref(new Set()),
|
||||
selected: ref(new Map()),
|
||||
selectedValues: ref([])
|
||||
}
|
||||
};
|
||||
export const makeNestedProps = propsFactory({
|
||||
selectStrategy: [String, Function],
|
||||
openStrategy: [String, Object],
|
||||
opened: Array,
|
||||
selected: Array,
|
||||
mandatory: Boolean
|
||||
}, 'nested');
|
||||
export const useNested = props => {
|
||||
let isUnmounted = false;
|
||||
const children = ref(new Map());
|
||||
const parents = ref(new Map());
|
||||
const opened = useProxiedModel(props, 'opened', props.opened, v => new Set(v), v => [...v.values()]);
|
||||
const selectStrategy = computed(() => {
|
||||
if (typeof props.selectStrategy === 'object') return props.selectStrategy;
|
||||
switch (props.selectStrategy) {
|
||||
case 'single-leaf':
|
||||
return leafSingleSelectStrategy(props.mandatory);
|
||||
case 'leaf':
|
||||
return leafSelectStrategy(props.mandatory);
|
||||
case 'independent':
|
||||
return independentSelectStrategy(props.mandatory);
|
||||
case 'single-independent':
|
||||
return independentSingleSelectStrategy(props.mandatory);
|
||||
case 'classic':
|
||||
default:
|
||||
return classicSelectStrategy(props.mandatory);
|
||||
}
|
||||
});
|
||||
const openStrategy = computed(() => {
|
||||
if (typeof props.openStrategy === 'object') return props.openStrategy;
|
||||
switch (props.openStrategy) {
|
||||
case 'list':
|
||||
return listOpenStrategy;
|
||||
case 'single':
|
||||
return singleOpenStrategy;
|
||||
case 'multiple':
|
||||
default:
|
||||
return multipleOpenStrategy;
|
||||
}
|
||||
});
|
||||
const selected = useProxiedModel(props, 'selected', props.selected, v => selectStrategy.value.in(v, children.value, parents.value), v => selectStrategy.value.out(v, children.value, parents.value));
|
||||
onBeforeUnmount(() => {
|
||||
isUnmounted = true;
|
||||
});
|
||||
function getPath(id) {
|
||||
const path = [];
|
||||
let parent = id;
|
||||
while (parent != null) {
|
||||
path.unshift(parent);
|
||||
parent = parents.value.get(parent);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
const vm = getCurrentInstance('nested');
|
||||
const nested = {
|
||||
id: shallowRef(),
|
||||
root: {
|
||||
opened,
|
||||
selected,
|
||||
selectedValues: computed(() => {
|
||||
const arr = [];
|
||||
for (const [key, value] of selected.value.entries()) {
|
||||
if (value === 'on') arr.push(key);
|
||||
}
|
||||
return arr;
|
||||
}),
|
||||
register: (id, parentId, isGroup) => {
|
||||
parentId && id !== parentId && parents.value.set(id, parentId);
|
||||
isGroup && children.value.set(id, []);
|
||||
if (parentId != null) {
|
||||
children.value.set(parentId, [...(children.value.get(parentId) || []), id]);
|
||||
}
|
||||
},
|
||||
unregister: id => {
|
||||
if (isUnmounted) return;
|
||||
children.value.delete(id);
|
||||
const parent = parents.value.get(id);
|
||||
if (parent) {
|
||||
const list = children.value.get(parent) ?? [];
|
||||
children.value.set(parent, list.filter(child => child !== id));
|
||||
}
|
||||
parents.value.delete(id);
|
||||
opened.value.delete(id);
|
||||
},
|
||||
open: (id, value, event) => {
|
||||
vm.emit('click:open', {
|
||||
id,
|
||||
value,
|
||||
path: getPath(id),
|
||||
event
|
||||
});
|
||||
const newOpened = openStrategy.value.open({
|
||||
id,
|
||||
value,
|
||||
opened: new Set(opened.value),
|
||||
children: children.value,
|
||||
parents: parents.value,
|
||||
event
|
||||
});
|
||||
newOpened && (opened.value = newOpened);
|
||||
},
|
||||
openOnSelect: (id, value, event) => {
|
||||
const newOpened = openStrategy.value.select({
|
||||
id,
|
||||
value,
|
||||
selected: new Map(selected.value),
|
||||
opened: new Set(opened.value),
|
||||
children: children.value,
|
||||
parents: parents.value,
|
||||
event
|
||||
});
|
||||
newOpened && (opened.value = newOpened);
|
||||
},
|
||||
select: (id, value, event) => {
|
||||
vm.emit('click:select', {
|
||||
id,
|
||||
value,
|
||||
path: getPath(id),
|
||||
event
|
||||
});
|
||||
const newSelected = selectStrategy.value.select({
|
||||
id,
|
||||
value,
|
||||
selected: new Map(selected.value),
|
||||
children: children.value,
|
||||
parents: parents.value,
|
||||
event
|
||||
});
|
||||
newSelected && (selected.value = newSelected);
|
||||
nested.root.openOnSelect(id, value, event);
|
||||
},
|
||||
children,
|
||||
parents
|
||||
}
|
||||
};
|
||||
provide(VNestedSymbol, nested);
|
||||
return nested.root;
|
||||
};
|
||||
export const useNestedItem = (id, isGroup) => {
|
||||
const parent = inject(VNestedSymbol, emptyNested);
|
||||
const uidSymbol = Symbol(getUid());
|
||||
const computedId = computed(() => id.value !== undefined ? id.value : uidSymbol);
|
||||
const item = {
|
||||
...parent,
|
||||
id: computedId,
|
||||
open: (open, e) => parent.root.open(computedId.value, open, e),
|
||||
openOnSelect: (open, e) => parent.root.openOnSelect(computedId.value, open, e),
|
||||
isOpen: computed(() => parent.root.opened.value.has(computedId.value)),
|
||||
parent: computed(() => parent.root.parents.value.get(computedId.value)),
|
||||
select: (selected, e) => parent.root.select(computedId.value, selected, e),
|
||||
isSelected: computed(() => parent.root.selected.value.get(toRaw(computedId.value)) === 'on'),
|
||||
isIndeterminate: computed(() => parent.root.selected.value.get(computedId.value) === 'indeterminate'),
|
||||
isLeaf: computed(() => !parent.root.children.value.get(computedId.value)),
|
||||
isGroupActivator: parent.isGroupActivator
|
||||
};
|
||||
!parent.isGroupActivator && parent.root.register(computedId.value, parent.id.value, isGroup);
|
||||
onBeforeUnmount(() => {
|
||||
!parent.isGroupActivator && parent.root.unregister(computedId.value);
|
||||
});
|
||||
isGroup && provide(VNestedSymbol, item);
|
||||
return item;
|
||||
};
|
||||
export const useNestedGroupActivator = () => {
|
||||
const parent = inject(VNestedSymbol, emptyNested);
|
||||
provide(VNestedSymbol, {
|
||||
...parent,
|
||||
isGroupActivator: true
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=nested.mjs.map
|
1
VApp/node_modules/vuetify/lib/composables/nested/nested.mjs.map
generated
vendored
Normal file
1
VApp/node_modules/vuetify/lib/composables/nested/nested.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
67
VApp/node_modules/vuetify/lib/composables/nested/openStrategies.mjs
generated
vendored
Normal file
67
VApp/node_modules/vuetify/lib/composables/nested/openStrategies.mjs
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
export const singleOpenStrategy = {
|
||||
open: _ref => {
|
||||
let {
|
||||
id,
|
||||
value,
|
||||
opened,
|
||||
parents
|
||||
} = _ref;
|
||||
if (value) {
|
||||
const newOpened = new Set();
|
||||
newOpened.add(id);
|
||||
let parent = parents.get(id);
|
||||
while (parent != null) {
|
||||
newOpened.add(parent);
|
||||
parent = parents.get(parent);
|
||||
}
|
||||
return newOpened;
|
||||
} else {
|
||||
opened.delete(id);
|
||||
return opened;
|
||||
}
|
||||
},
|
||||
select: () => null
|
||||
};
|
||||
export const multipleOpenStrategy = {
|
||||
open: _ref2 => {
|
||||
let {
|
||||
id,
|
||||
value,
|
||||
opened,
|
||||
parents
|
||||
} = _ref2;
|
||||
if (value) {
|
||||
let parent = parents.get(id);
|
||||
opened.add(id);
|
||||
while (parent != null && parent !== id) {
|
||||
opened.add(parent);
|
||||
parent = parents.get(parent);
|
||||
}
|
||||
return opened;
|
||||
} else {
|
||||
opened.delete(id);
|
||||
}
|
||||
return opened;
|
||||
},
|
||||
select: () => null
|
||||
};
|
||||
export const listOpenStrategy = {
|
||||
open: multipleOpenStrategy.open,
|
||||
select: _ref3 => {
|
||||
let {
|
||||
id,
|
||||
value,
|
||||
opened,
|
||||
parents
|
||||
} = _ref3;
|
||||
if (!value) return opened;
|
||||
const path = [];
|
||||
let parent = parents.get(id);
|
||||
while (parent != null) {
|
||||
path.push(parent);
|
||||
parent = parents.get(parent);
|
||||
}
|
||||
return new Set(path);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=openStrategies.mjs.map
|
1
VApp/node_modules/vuetify/lib/composables/nested/openStrategies.mjs.map
generated
vendored
Normal file
1
VApp/node_modules/vuetify/lib/composables/nested/openStrategies.mjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"openStrategies.mjs","names":["singleOpenStrategy","open","_ref","id","value","opened","parents","newOpened","Set","add","parent","get","delete","select","multipleOpenStrategy","_ref2","listOpenStrategy","_ref3","path","push"],"sources":["../../../src/composables/nested/openStrategies.ts"],"sourcesContent":["export type OpenStrategyFn = (data: {\n id: unknown\n value: boolean\n opened: Set<unknown>\n children: Map<unknown, unknown[]>\n parents: Map<unknown, unknown>\n event?: Event\n}) => Set<unknown>\n\nexport type OpenSelectStrategyFn = (data: {\n id: unknown\n value: boolean\n opened: Set<unknown>\n selected: Map<unknown, 'on' | 'off' | 'indeterminate'>\n children: Map<unknown, unknown[]>\n parents: Map<unknown, unknown>\n event?: Event\n}) => Set<unknown> | null\n\nexport type OpenStrategy = {\n open: OpenStrategyFn\n select: OpenSelectStrategyFn\n}\n\nexport const singleOpenStrategy: OpenStrategy = {\n open: ({ id, value, opened, parents }) => {\n if (value) {\n const newOpened = new Set<unknown>()\n newOpened.add(id)\n\n let parent = parents.get(id)\n\n while (parent != null) {\n newOpened.add(parent)\n parent = parents.get(parent)\n }\n\n return newOpened\n } else {\n opened.delete(id)\n return opened\n }\n },\n select: () => null,\n}\n\nexport const multipleOpenStrategy: OpenStrategy = {\n open: ({ id, value, opened, parents }) => {\n if (value) {\n let parent = parents.get(id)\n opened.add(id)\n\n while (parent != null && parent !== id) {\n opened.add(parent)\n parent = parents.get(parent)\n }\n\n return opened\n } else {\n opened.delete(id)\n }\n return opened\n },\n select: () => null,\n}\n\nexport const listOpenStrategy: OpenStrategy = {\n open: multipleOpenStrategy.open,\n select: ({ id, value, opened, parents }) => {\n if (!value) return opened\n\n const path: unknown[] = []\n\n let parent = parents.get(id)\n\n while (parent != null) {\n path.push(parent)\n parent = parents.get(parent)\n }\n\n return new Set(path)\n },\n}\n"],"mappings":"AAwBA,OAAO,MAAMA,kBAAgC,GAAG;EAC9CC,IAAI,EAAEC,IAAA,IAAoC;IAAA,IAAnC;MAAEC,EAAE;MAAEC,KAAK;MAAEC,MAAM;MAAEC;IAAQ,CAAC,GAAAJ,IAAA;IACnC,IAAIE,KAAK,EAAE;MACT,MAAMG,SAAS,GAAG,IAAIC,GAAG,CAAU,CAAC;MACpCD,SAAS,CAACE,GAAG,CAACN,EAAE,CAAC;MAEjB,IAAIO,MAAM,GAAGJ,OAAO,CAACK,GAAG,CAACR,EAAE,CAAC;MAE5B,OAAOO,MAAM,IAAI,IAAI,EAAE;QACrBH,SAAS,CAACE,GAAG,CAACC,MAAM,CAAC;QACrBA,MAAM,GAAGJ,OAAO,CAACK,GAAG,CAACD,MAAM,CAAC;MAC9B;MAEA,OAAOH,SAAS;IAClB,CAAC,MAAM;MACLF,MAAM,CAACO,MAAM,CAACT,EAAE,CAAC;MACjB,OAAOE,MAAM;IACf;EACF,CAAC;EACDQ,MAAM,EAAEA,CAAA,KAAM;AAChB,CAAC;AAED,OAAO,MAAMC,oBAAkC,GAAG;EAChDb,IAAI,EAAEc,KAAA,IAAoC;IAAA,IAAnC;MAAEZ,EAAE;MAAEC,KAAK;MAAEC,MAAM;MAAEC;IAAQ,CAAC,GAAAS,KAAA;IACnC,IAAIX,KAAK,EAAE;MACT,IAAIM,MAAM,GAAGJ,OAAO,CAACK,GAAG,CAACR,EAAE,CAAC;MAC5BE,MAAM,CAACI,GAAG,CAACN,EAAE,CAAC;MAEd,OAAOO,MAAM,IAAI,IAAI,IAAIA,MAAM,KAAKP,EAAE,EAAE;QACtCE,MAAM,CAACI,GAAG,CAACC,MAAM,CAAC;QAClBA,MAAM,GAAGJ,OAAO,CAACK,GAAG,CAACD,MAAM,CAAC;MAC9B;MAEA,OAAOL,MAAM;IACf,CAAC,MAAM;MACLA,MAAM,CAACO,MAAM,CAACT,EAAE,CAAC;IACnB;IACA,OAAOE,MAAM;EACf,CAAC;EACDQ,MAAM,EAAEA,CAAA,KAAM;AAChB,CAAC;AAED,OAAO,MAAMG,gBAA8B,GAAG;EAC5Cf,IAAI,EAAEa,oBAAoB,CAACb,IAAI;EAC/BY,MAAM,EAAEI,KAAA,IAAoC;IAAA,IAAnC;MAAEd,EAAE;MAAEC,KAAK;MAAEC,MAAM;MAAEC;IAAQ,CAAC,GAAAW,KAAA;IACrC,IAAI,CAACb,KAAK,EAAE,OAAOC,MAAM;IAEzB,MAAMa,IAAe,GAAG,EAAE;IAE1B,IAAIR,MAAM,GAAGJ,OAAO,CAACK,GAAG,CAACR,EAAE,CAAC;IAE5B,OAAOO,MAAM,IAAI,IAAI,EAAE;MACrBQ,IAAI,CAACC,IAAI,CAACT,MAAM,CAAC;MACjBA,MAAM,GAAGJ,OAAO,CAACK,GAAG,CAACD,MAAM,CAAC;IAC9B;IAEA,OAAO,IAAIF,GAAG,CAACU,IAAI,CAAC;EACtB;AACF,CAAC"}
|
190
VApp/node_modules/vuetify/lib/composables/nested/selectStrategies.mjs
generated
vendored
Normal file
190
VApp/node_modules/vuetify/lib/composables/nested/selectStrategies.mjs
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
/* eslint-disable sonarjs/no-identical-functions */
|
||||
// Utilities
|
||||
import { toRaw } from 'vue';
|
||||
export const independentSelectStrategy = mandatory => {
|
||||
const strategy = {
|
||||
select: _ref => {
|
||||
let {
|
||||
id,
|
||||
value,
|
||||
selected
|
||||
} = _ref;
|
||||
id = toRaw(id);
|
||||
|
||||
// When mandatory and we're trying to deselect when id
|
||||
// is the only currently selected item then do nothing
|
||||
if (mandatory && !value) {
|
||||
const on = Array.from(selected.entries()).reduce((arr, _ref2) => {
|
||||
let [key, value] = _ref2;
|
||||
return value === 'on' ? [...arr, key] : arr;
|
||||
}, []);
|
||||
if (on.length === 1 && on[0] === id) return selected;
|
||||
}
|
||||
selected.set(id, value ? 'on' : 'off');
|
||||
return selected;
|
||||
},
|
||||
in: (v, children, parents) => {
|
||||
let map = new Map();
|
||||
for (const id of v || []) {
|
||||
map = strategy.select({
|
||||
id,
|
||||
value: true,
|
||||
selected: new Map(map),
|
||||
children,
|
||||
parents
|
||||
});
|
||||
}
|
||||
return map;
|
||||
},
|
||||
out: v => {
|
||||
const arr = [];
|
||||
for (const [key, value] of v.entries()) {
|
||||
if (value === 'on') arr.push(key);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
};
|
||||
return strategy;
|
||||
};
|
||||
export const independentSingleSelectStrategy = mandatory => {
|
||||
const parentStrategy = independentSelectStrategy(mandatory);
|
||||
const strategy = {
|
||||
select: _ref3 => {
|
||||
let {
|
||||
selected,
|
||||
id,
|
||||
...rest
|
||||
} = _ref3;
|
||||
id = toRaw(id);
|
||||
const singleSelected = selected.has(id) ? new Map([[id, selected.get(id)]]) : new Map();
|
||||
return parentStrategy.select({
|
||||
...rest,
|
||||
id,
|
||||
selected: singleSelected
|
||||
});
|
||||
},
|
||||
in: (v, children, parents) => {
|
||||
let map = new Map();
|
||||
if (v?.length) {
|
||||
map = parentStrategy.in(v.slice(0, 1), children, parents);
|
||||
}
|
||||
return map;
|
||||
},
|
||||
out: (v, children, parents) => {
|
||||
return parentStrategy.out(v, children, parents);
|
||||
}
|
||||
};
|
||||
return strategy;
|
||||
};
|
||||
export const leafSelectStrategy = mandatory => {
|
||||
const parentStrategy = independentSelectStrategy(mandatory);
|
||||
const strategy = {
|
||||
select: _ref4 => {
|
||||
let {
|
||||
id,
|
||||
selected,
|
||||
children,
|
||||
...rest
|
||||
} = _ref4;
|
||||
id = toRaw(id);
|
||||
if (children.has(id)) return selected;
|
||||
return parentStrategy.select({
|
||||
id,
|
||||
selected,
|
||||
children,
|
||||
...rest
|
||||
});
|
||||
},
|
||||
in: parentStrategy.in,
|
||||
out: parentStrategy.out
|
||||
};
|
||||
return strategy;
|
||||
};
|
||||
export const leafSingleSelectStrategy = mandatory => {
|
||||
const parentStrategy = independentSingleSelectStrategy(mandatory);
|
||||
const strategy = {
|
||||
select: _ref5 => {
|
||||
let {
|
||||
id,
|
||||
selected,
|
||||
children,
|
||||
...rest
|
||||
} = _ref5;
|
||||
id = toRaw(id);
|
||||
if (children.has(id)) return selected;
|
||||
return parentStrategy.select({
|
||||
id,
|
||||
selected,
|
||||
children,
|
||||
...rest
|
||||
});
|
||||
},
|
||||
in: parentStrategy.in,
|
||||
out: parentStrategy.out
|
||||
};
|
||||
return strategy;
|
||||
};
|
||||
export const classicSelectStrategy = mandatory => {
|
||||
const strategy = {
|
||||
select: _ref6 => {
|
||||
let {
|
||||
id,
|
||||
value,
|
||||
selected,
|
||||
children,
|
||||
parents
|
||||
} = _ref6;
|
||||
id = toRaw(id);
|
||||
const original = new Map(selected);
|
||||
const items = [id];
|
||||
while (items.length) {
|
||||
const item = items.shift();
|
||||
selected.set(item, value ? 'on' : 'off');
|
||||
if (children.has(item)) {
|
||||
items.push(...children.get(item));
|
||||
}
|
||||
}
|
||||
let parent = parents.get(id);
|
||||
while (parent) {
|
||||
const childrenIds = children.get(parent);
|
||||
const everySelected = childrenIds.every(cid => selected.get(cid) === 'on');
|
||||
const noneSelected = childrenIds.every(cid => !selected.has(cid) || selected.get(cid) === 'off');
|
||||
selected.set(parent, everySelected ? 'on' : noneSelected ? 'off' : 'indeterminate');
|
||||
parent = parents.get(parent);
|
||||
}
|
||||
|
||||
// If mandatory and planned deselect results in no selected
|
||||
// items then we can't do it, so return original state
|
||||
if (mandatory && !value) {
|
||||
const on = Array.from(selected.entries()).reduce((arr, _ref7) => {
|
||||
let [key, value] = _ref7;
|
||||
return value === 'on' ? [...arr, key] : arr;
|
||||
}, []);
|
||||
if (on.length === 0) return original;
|
||||
}
|
||||
return selected;
|
||||
},
|
||||
in: (v, children, parents) => {
|
||||
let map = new Map();
|
||||
for (const id of v || []) {
|
||||
map = strategy.select({
|
||||
id,
|
||||
value: true,
|
||||
selected: new Map(map),
|
||||
children,
|
||||
parents
|
||||
});
|
||||
}
|
||||
return map;
|
||||
},
|
||||
out: (v, children) => {
|
||||
const arr = [];
|
||||
for (const [key, value] of v.entries()) {
|
||||
if (value === 'on' && !children.has(key)) arr.push(key);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
};
|
||||
return strategy;
|
||||
};
|
||||
//# sourceMappingURL=selectStrategies.mjs.map
|
1
VApp/node_modules/vuetify/lib/composables/nested/selectStrategies.mjs.map
generated
vendored
Normal file
1
VApp/node_modules/vuetify/lib/composables/nested/selectStrategies.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user