hys-ui 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +137 -1
- package/README.md +18 -6
- package/dist/components/HysAccordion/HysAccordion.vue.js +1 -1
- package/dist/components/HysAccordion/HysAccordion2.vue.js +181 -47
- package/dist/components/HysAlert/HysAlert.vue.js +14 -14
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +23 -20
- package/dist/components/HysAutocomplete/HysAutocomplete.vue.js +7 -0
- package/dist/components/HysAutocomplete/HysAutocomplete2.vue.js +627 -0
- package/dist/components/HysAvatar/HysAvatar.vue.js +5 -35
- package/dist/components/HysAvatar/HysAvatar2.vue.js +221 -2
- package/dist/components/HysAvatarGroup/HysAvatarGroup.vue.js +7 -0
- package/dist/components/HysAvatarGroup/HysAvatarGroup2.vue.js +252 -0
- package/dist/components/HysBadge/HysBadge.vue.js +2 -2
- package/dist/components/HysBadge/HysBadge2.vue.js +154 -26
- package/dist/components/HysBreadcrumb/HysBreadcrumb.vue.js +5 -38
- package/dist/components/HysBreadcrumb/HysBreadcrumb2.vue.js +74 -2
- package/dist/components/HysButton/HysButton.vue.js +2 -2
- package/dist/components/HysButton/HysButton2.vue.js +29 -28
- package/dist/components/HysCalendar/HysCalendar.vue.js +5 -84
- package/dist/components/HysCalendar/HysCalendar2.vue.js +803 -2
- package/dist/components/HysCard/HysCard.vue.js +1 -1
- package/dist/components/HysCard/HysCard2.vue.js +177 -44
- package/dist/components/HysCascader/HysCascader.vue.js +5 -182
- package/dist/components/HysCascader/HysCascader2.vue.js +760 -2
- package/dist/components/HysCascader/HysCascaderColumn.vue.js +7 -0
- package/dist/components/HysCascader/HysCascaderColumn2.vue.js +232 -0
- package/dist/components/HysCheckbox/HysCheckbox.vue.js +5 -39
- package/dist/components/HysCheckbox/HysCheckbox2.vue.js +200 -2
- package/dist/components/HysCheckboxGroup/HysCheckboxGroup.vue.js +7 -0
- package/dist/components/HysCheckboxGroup/HysCheckboxGroup2.vue.js +237 -0
- package/dist/components/HysColorPicker/HysColorPicker.vue.js +2 -2
- package/dist/components/HysColorPicker/HysColorPicker2.vue.js +107 -106
- package/dist/components/HysCommandPalette/HysCommandPalette.vue.js +52 -51
- package/dist/components/HysCommentEditor/HysCommentEditor.vue.js +17 -17
- package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
- package/dist/components/HysDataGrid/HysDataGrid2.vue.js +397 -390
- package/dist/components/HysDatePicker/HysDatePicker.vue.js +268 -139
- package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +7 -0
- package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +807 -0
- package/dist/components/HysDatePicker/HysDatePickerPanel.vue.js +7 -0
- package/dist/components/HysDatePicker/HysDatePickerPanel2.vue.js +357 -0
- package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +268 -158
- package/dist/components/HysDivider/HysDivider.vue.js +2 -2
- package/dist/components/HysDivider/HysDivider2.vue.js +33 -13
- package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
- package/dist/components/HysDrawer/HysDrawer2.vue.js +55 -54
- package/dist/components/HysFileManager/HysFileManager.vue.js +5 -63
- package/dist/components/HysFileManager/HysFileManager2.vue.js +86 -2
- package/dist/components/HysForm/HysForm.vue.js +3 -3
- package/dist/components/HysForm/HysForm2.vue.js +580 -92
- package/dist/components/HysFormItem/HysFormItem.vue.js +5 -69
- package/dist/components/HysFormItem/HysFormItem2.vue.js +521 -2
- package/dist/components/HysGantt/HysGantt.vue.js +5 -264
- package/dist/components/HysGantt/HysGantt2.vue.js +1399 -2
- package/dist/components/HysInput/HysInput.vue.js +2 -2
- package/dist/components/HysInput/HysInput2.vue.js +468 -120
- package/dist/components/HysMention/HysMention.vue.js +2 -2
- package/dist/components/HysMention/HysMention2.vue.js +89 -88
- package/dist/components/HysModal/HysModal.vue.js +2 -2
- package/dist/components/HysModal/HysModal2.vue.js +35 -35
- package/dist/components/HysNotificationCenter/HysNotificationCenter.vue.js +37 -36
- package/dist/components/HysNumberInput/HysNumberInput.vue.js +2 -2
- package/dist/components/HysNumberInput/HysNumberInput2.vue.js +561 -70
- package/dist/components/HysOrgTree/HysOrgTree.vue.js +41 -36
- package/dist/components/HysPagination/HysPagination.vue.js +2 -2
- package/dist/components/HysPagination/HysPagination2.vue.js +93 -91
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix.vue.js +5 -41
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix2.vue.js +101 -2
- package/dist/components/HysRadio/HysRadio.vue.js +7 -0
- package/dist/components/HysRadio/HysRadio2.vue.js +180 -0
- package/dist/components/HysRadioGroup/HysRadioGroup.vue.js +5 -40
- package/dist/components/HysRadioGroup/HysRadioGroup2.vue.js +205 -2
- package/dist/components/HysRating/HysRating.vue.js +1 -1
- package/dist/components/HysRating/HysRating2.vue.js +288 -68
- package/dist/components/HysResizablePanel/HysResizablePanel.vue.js +46 -28
- package/dist/components/HysRichTextEditor/HysRichTextEditor.vue.js +2 -2
- package/dist/components/HysRichTextEditor/HysRichTextEditor2.vue.js +87 -67
- package/dist/components/HysSearch/HysSearch.vue.js +50 -38
- package/dist/components/HysSegmented/HysSegmented.vue.js +5 -58
- package/dist/components/HysSegmented/HysSegmented2.vue.js +273 -2
- package/dist/components/HysSelect/HysSelect.vue.js +3 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +859 -164
- package/dist/components/HysSkeleton/HysSkeleton.vue.js +2 -2
- package/dist/components/HysSkeleton/HysSkeleton2.vue.js +126 -29
- package/dist/components/HysSlider/HysSlider.vue.js +2 -2
- package/dist/components/HysSlider/HysSlider2.vue.js +532 -59
- package/dist/components/HysSlider/SliderTooltip.vue.js +7 -0
- package/dist/components/HysSlider/SliderTooltip2.vue.js +156 -0
- package/dist/components/HysSplitPane/HysSplitPane.vue.js +48 -42
- package/dist/components/HysSteps/HysSteps.vue.js +2 -2
- package/dist/components/HysSteps/HysSteps2.vue.js +111 -36
- package/dist/components/HysSwitch/HysSwitch.vue.js +2 -2
- package/dist/components/HysSwitch/HysSwitch2.vue.js +235 -42
- package/dist/components/HysTable/HysTable.vue.js +1 -1
- package/dist/components/HysTable/HysTable2.vue.js +1471 -82
- package/dist/components/HysTable/HysTableFilterOptions.vue.js +7 -0
- package/dist/components/HysTable/HysTableFilterOptions2.vue.js +133 -0
- package/dist/components/HysTabs/HysTabs.vue.js +2 -2
- package/dist/components/HysTabs/HysTabs2.vue.js +262 -66
- package/dist/components/HysTagInput/HysTagInput.vue.js +43 -42
- package/dist/components/HysTextarea/HysTextarea.vue.js +137 -66
- package/dist/components/HysToast/HysToast.vue.js +2 -2
- package/dist/components/HysToast/HysToast2.vue.js +121 -38
- package/dist/components/HysTour/HysTour.vue.js +47 -42
- package/dist/components/HysTransfer/HysTransfer.vue.js +5 -207
- package/dist/components/HysTransfer/HysTransfer2.vue.js +416 -2
- package/dist/components/HysTransfer/HysTransferPanel.vue.js +7 -0
- package/dist/components/HysTransfer/HysTransferPanel2.vue.js +454 -0
- package/dist/components/HysTree/HysTree.vue.js +2 -3
- package/dist/components/HysTree/HysTree2.vue.js +641 -301
- package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +5 -129
- package/dist/components/HysTreeSelect/HysTreeSelect2.vue.js +558 -2
- package/dist/components/HysTreeSelect/HysTreeSelectPanel.vue.js +7 -0
- package/dist/components/HysTreeSelect/HysTreeSelectPanel2.vue.js +323 -0
- package/dist/components/HysUpload/HysUpload.vue.js +2 -2
- package/dist/components/HysUpload/HysUpload2.vue.js +97 -78
- package/dist/composables/autocomplete.js +50 -0
- package/dist/composables/avatar.js +57 -0
- package/dist/composables/calendar.js +96 -0
- package/dist/composables/cascader.js +79 -0
- package/dist/composables/choice.js +38 -0
- package/dist/composables/choiceModel.js +67 -0
- package/dist/composables/datePicker.js +227 -0
- package/dist/composables/formContext.js +94 -3
- package/dist/composables/formLayout.js +57 -0
- package/dist/composables/formValidation.js +240 -0
- package/dist/composables/ganttConflicts.js +143 -0
- package/dist/composables/numberInput.js +91 -0
- package/dist/composables/rating.js +16 -0
- package/dist/composables/selectOptions.js +54 -0
- package/dist/composables/table.js +150 -0
- package/dist/composables/textInput.js +34 -0
- package/dist/composables/toastEscape.js +16 -0
- package/dist/composables/transfer.js +63 -0
- package/dist/composables/tree.js +118 -0
- package/dist/composables/treeSelect.js +71 -0
- package/dist/composables/useCascader.js +438 -0
- package/dist/composables/useDatePicker.js +425 -0
- package/dist/composables/useDialog.js +16 -16
- package/dist/composables/useFloating.js +98 -52
- package/dist/composables/useGanttDependencies.js +306 -0
- package/dist/composables/useGanttHistory.js +157 -0
- package/dist/composables/useGanttLabelResize.js +100 -0
- package/dist/composables/useHysToast.js +148 -0
- package/dist/composables/useTable.js +474 -0
- package/dist/composables/useTextareaSize.js +72 -0
- package/dist/composables/useTransfer.js +257 -0
- package/dist/composables/useTree.js +439 -0
- package/dist/composables/useTreeSelect.js +361 -0
- package/dist/config.js +18 -15
- package/dist/index.js +149 -136
- package/dist/style.css +1 -1
- package/dist/types/components/HysAccordion/HysAccordion.vue.d.ts +61 -22
- package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +201 -0
- package/dist/types/components/HysAvatar/HysAvatar.vue.d.ts +28 -15
- package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +99 -0
- package/dist/types/components/HysBadge/HysBadge.vue.d.ts +41 -4
- package/dist/types/components/HysBreadcrumb/HysBreadcrumb.vue.d.ts +38 -10
- package/dist/types/components/HysButton/HysButton.vue.d.ts +0 -1
- package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +119 -29
- package/dist/types/components/HysCard/HysCard.vue.d.ts +57 -5
- package/dist/types/components/HysCascader/HysCascader.vue.d.ts +129 -41
- package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +55 -0
- package/dist/types/components/HysCheckbox/HysCheckbox.vue.d.ts +55 -27
- package/dist/types/components/HysCheckboxGroup/HysCheckboxGroup.vue.d.ts +73 -0
- package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +1 -1
- package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +66 -14
- package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +90 -0
- package/dist/types/components/HysDatePicker/HysDatePickerPanel.vue.d.ts +93 -0
- package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +66 -14
- package/dist/types/components/HysDivider/HysDivider.vue.d.ts +8 -3
- package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -0
- package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +8 -4
- package/dist/types/components/HysForm/HysForm.vue.d.ts +110 -18
- package/dist/types/components/HysFormItem/HysFormItem.vue.d.ts +108 -2
- package/dist/types/components/HysGantt/HysGantt.vue.d.ts +88 -4
- package/dist/types/components/HysInput/HysInput.vue.d.ts +52 -29
- package/dist/types/components/HysMention/HysMention.vue.d.ts +2 -2
- package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +93 -33
- package/dist/types/components/HysOrgTree/HysOrgTree.vue.d.ts +4 -1
- package/dist/types/components/HysPagination/HysPagination.vue.d.ts +1 -1
- package/dist/types/components/HysPermissionMatrix/HysPermissionMatrix.vue.d.ts +8 -1
- package/dist/types/components/HysPopover/HysPopover.vue.d.ts +3 -3
- package/dist/types/components/HysProgress/HysProgress.vue.d.ts +1 -1
- package/dist/types/components/HysRadio/HysRadio.vue.d.ts +56 -0
- package/dist/types/components/HysRadioGroup/HysRadioGroup.vue.d.ts +62 -17
- package/dist/types/components/HysRating/HysRating.vue.d.ts +85 -5
- package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +6 -0
- package/dist/types/components/HysRichTextEditor/HysRichTextEditor.vue.d.ts +4 -4
- package/dist/types/components/HysSearch/HysSearch.vue.d.ts +2 -2
- package/dist/types/components/HysSegmented/HysSegmented.vue.d.ts +64 -32
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +120 -14
- package/dist/types/components/HysSkeleton/HysSkeleton.vue.d.ts +30 -2
- package/dist/types/components/HysSlider/HysSlider.vue.d.ts +66 -9
- package/dist/types/components/HysSlider/SliderTooltip.vue.d.ts +22 -0
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +6 -0
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +65 -9
- package/dist/types/components/HysSwitch/HysSwitch.vue.d.ts +76 -17
- package/dist/types/components/HysTable/HysTable.vue.d.ts +206 -32
- package/dist/types/components/HysTable/HysTableFilterOptions.vue.d.ts +18 -0
- package/dist/types/components/HysTabs/HysTabs.vue.d.ts +76 -23
- package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +5 -5
- package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +44 -27
- package/dist/types/components/HysToast/HysToast.vue.d.ts +55 -7
- package/dist/types/components/HysTour/HysTour.vue.d.ts +5 -3
- package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +55 -30
- package/dist/types/components/HysTransfer/HysTransferPanel.vue.d.ts +105 -0
- package/dist/types/components/HysTree/HysTree.vue.d.ts +140 -73
- package/dist/types/components/HysTreeSelect/HysTreeSelect.vue.d.ts +102 -23
- package/dist/types/components/HysTreeSelect/HysTreeSelectPanel.vue.d.ts +56 -0
- package/dist/types/composables/autocomplete.d.ts +106 -0
- package/dist/types/composables/avatar.d.ts +70 -0
- package/dist/types/composables/calendar.d.ts +66 -0
- package/dist/types/composables/cascader.d.ts +192 -0
- package/dist/types/composables/choice.d.ts +110 -0
- package/dist/types/composables/choiceModel.d.ts +11 -0
- package/dist/types/composables/datePicker.d.ts +247 -0
- package/dist/types/composables/formContext.d.ts +138 -8
- package/dist/types/composables/formLayout.d.ts +11 -0
- package/dist/types/composables/formValidation.d.ts +13 -0
- package/dist/types/composables/gantt.d.ts +68 -0
- package/dist/types/composables/ganttConflicts.d.ts +30 -0
- package/dist/types/composables/numberInput.d.ts +45 -0
- package/dist/types/composables/rating.d.ts +18 -0
- package/dist/types/composables/segmented.d.ts +15 -0
- package/dist/types/composables/selectOptions.d.ts +44 -0
- package/dist/types/composables/slider.d.ts +21 -0
- package/dist/types/composables/table.d.ts +309 -0
- package/dist/types/composables/textInput.d.ts +76 -0
- package/dist/types/composables/toastEscape.d.ts +1 -0
- package/dist/types/composables/transfer.d.ts +180 -0
- package/dist/types/composables/tree.d.ts +237 -0
- package/dist/types/composables/treeSelect.d.ts +167 -0
- package/dist/types/composables/useCascader.d.ts +162 -0
- package/dist/types/composables/useDatePicker.d.ts +79 -0
- package/dist/types/composables/useFloating.d.ts +8 -5
- package/dist/types/composables/useGanttDependencies.d.ts +83 -0
- package/dist/types/composables/useGanttHistory.d.ts +42 -0
- package/dist/types/composables/useGanttLabelResize.d.ts +23 -0
- package/dist/types/composables/useHysToast.d.ts +50 -0
- package/dist/types/composables/useTable.d.ts +60 -0
- package/dist/types/composables/useTextareaSize.d.ts +3 -0
- package/dist/types/composables/useTransfer.d.ts +58 -0
- package/dist/types/composables/useTree.d.ts +77 -0
- package/dist/types/composables/useTreeSelect.d.ts +117 -0
- package/dist/types/index.d.ts +38 -7
- package/package.json +47 -11
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { shallowRef as x, ref as le, computed as T, onMounted as se, onActivated as ce, onDeactivated as ve, onBeforeUnmount as pe, watch as fe, nextTick as z } from "vue";
|
|
2
|
+
const J = {
|
|
3
|
+
missing: "找不到对应任务或依赖关系",
|
|
4
|
+
disabled: "该任务不可编辑依赖关系",
|
|
5
|
+
self: "任务不能依赖自身",
|
|
6
|
+
duplicate: "这条前置依赖已存在",
|
|
7
|
+
cycle: "该连接会形成循环依赖",
|
|
8
|
+
rejected: "依赖更新请求未被接受",
|
|
9
|
+
busy: "上一项修改尚未完成,请稍后再试"
|
|
10
|
+
};
|
|
11
|
+
function ye(r, a, p = 46) {
|
|
12
|
+
const v = r.x + r.w, d = v + 14, y = a.x - 4;
|
|
13
|
+
if (a.x === v && a.y === r.y) return "";
|
|
14
|
+
const A = y >= d + 12 ? `V ${a.y} H ${y}` : `V ${a.y + (a.y < r.y ? 1 : -1) * p / 2} H ${y - 16} V ${a.y} H ${y}`;
|
|
15
|
+
return `M ${v} ${r.y} H ${d} ${A} M ${y - 5} ${a.y - 4} L ${y} ${a.y} L ${y - 5} ${a.y + 4}`;
|
|
16
|
+
}
|
|
17
|
+
function Ie(r, a, p = 46) {
|
|
18
|
+
const v = r.x + r.w + 14, d = a.x - 4, y = a.y + (a.y < r.y ? 1 : -1) * p / 2;
|
|
19
|
+
return `M ${r.x + r.w} ${r.y} H ${v} V ${y}` + (d >= v + 12 ? "" : ` H ${d - 16}`);
|
|
20
|
+
}
|
|
21
|
+
function we(r) {
|
|
22
|
+
const a = x(), p = x(), v = le(""), d = T(() => new Map(r.items().map((e) => [e.id, e]))), y = T(() => {
|
|
23
|
+
var e;
|
|
24
|
+
return (e = a.value) == null ? void 0 : e.sourceId;
|
|
25
|
+
});
|
|
26
|
+
function A(e) {
|
|
27
|
+
var o, i;
|
|
28
|
+
const t = /* @__PURE__ */ new Set(), n = [...((o = d.value.get(e)) == null ? void 0 : o.dependencies) ?? []];
|
|
29
|
+
for (; n.length; ) {
|
|
30
|
+
const u = n.pop();
|
|
31
|
+
if (!t.has(u)) {
|
|
32
|
+
t.add(u);
|
|
33
|
+
for (const c of ((i = d.value.get(u)) == null ? void 0 : i.dependencies) ?? [])
|
|
34
|
+
n.push(c);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
}
|
|
39
|
+
const O = T(
|
|
40
|
+
() => y.value === void 0 ? /* @__PURE__ */ new Set() : A(y.value)
|
|
41
|
+
), $ = T(() => {
|
|
42
|
+
var t, n;
|
|
43
|
+
const e = p.value;
|
|
44
|
+
return e && ((n = (t = d.value.get(e.targetId)) == null ? void 0 : t.dependencies) != null && n.includes(e.sourceId)) ? e : void 0;
|
|
45
|
+
});
|
|
46
|
+
function E(e) {
|
|
47
|
+
var o, i;
|
|
48
|
+
const t = d.value.get(e.sourceId), n = d.value.get(e.targetId);
|
|
49
|
+
return !n || e.type === "add" && !t ? "missing" : !r.enabled.value || n.disabled || e.type === "add" && (t != null && t.disabled) ? "disabled" : e.type === "remove" ? (o = n.dependencies) != null && o.includes(e.sourceId) ? null : "missing" : e.sourceId === e.targetId ? "self" : (i = n.dependencies) != null && i.includes(e.sourceId) ? "duplicate" : (y.value === e.sourceId ? O.value : A(e.sourceId)).has(e.targetId) ? "cycle" : null;
|
|
50
|
+
}
|
|
51
|
+
function b(e, t) {
|
|
52
|
+
v.value = J[t], r.live() && r.invalid({ ...e, reason: t });
|
|
53
|
+
}
|
|
54
|
+
async function j(e) {
|
|
55
|
+
var c, s, g;
|
|
56
|
+
if (!r.live()) return !1;
|
|
57
|
+
const t = E(e);
|
|
58
|
+
if (t)
|
|
59
|
+
return b(e, t), !1;
|
|
60
|
+
const n = d.value.get(e.targetId), o = {
|
|
61
|
+
...n,
|
|
62
|
+
dependencies: e.type === "add" ? [.../* @__PURE__ */ new Set([...n.dependencies ?? [], e.sourceId])] : (n.dependencies ?? []).filter((w) => w !== e.sourceId)
|
|
63
|
+
};
|
|
64
|
+
if (!r.update(
|
|
65
|
+
r.items().map((w) => w.id === o.id ? o : w),
|
|
66
|
+
e
|
|
67
|
+
))
|
|
68
|
+
return b(e, "busy"), !1;
|
|
69
|
+
if (r.change(o), await z(), !r.live()) return !1;
|
|
70
|
+
const i = d.value.get(e.targetId);
|
|
71
|
+
return !!i && !!((c = i.dependencies) != null && c.includes(e.sourceId)) == (e.type === "add") ? (v.value = e.type === "add" ? "前置依赖已建立" : "前置依赖已移除", e.type === "add" ? r.added(e, i) : (((s = p.value) == null ? void 0 : s.sourceId) === e.sourceId && ((g = p.value) == null ? void 0 : g.targetId) === e.targetId && (p.value = void 0), r.removed(e, i)), !0) : (b(e, "rejected"), !1);
|
|
72
|
+
}
|
|
73
|
+
const F = (e, t) => j({ sourceId: e, targetId: t, type: "add" }), R = (e, t) => j({ sourceId: e, targetId: t, type: "remove" });
|
|
74
|
+
function M(e) {
|
|
75
|
+
const t = E({
|
|
76
|
+
sourceId: e.sourceId,
|
|
77
|
+
targetId: e.previousTargetId,
|
|
78
|
+
type: "remove"
|
|
79
|
+
});
|
|
80
|
+
return t || (e.previousTargetId === e.targetId ? null : E({
|
|
81
|
+
sourceId: e.sourceId,
|
|
82
|
+
targetId: e.targetId,
|
|
83
|
+
type: "add"
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
async function G(e, t, n) {
|
|
87
|
+
var w, S;
|
|
88
|
+
if (!r.live()) return !1;
|
|
89
|
+
const o = {
|
|
90
|
+
sourceId: e,
|
|
91
|
+
previousTargetId: t,
|
|
92
|
+
targetId: n,
|
|
93
|
+
type: "move"
|
|
94
|
+
}, i = M(o);
|
|
95
|
+
if (i)
|
|
96
|
+
return b(o, i), !1;
|
|
97
|
+
if (t === n) return !0;
|
|
98
|
+
const u = {
|
|
99
|
+
...d.value.get(t),
|
|
100
|
+
dependencies: (d.value.get(t).dependencies ?? []).filter((m) => m !== e)
|
|
101
|
+
}, c = {
|
|
102
|
+
...d.value.get(n),
|
|
103
|
+
dependencies: [
|
|
104
|
+
.../* @__PURE__ */ new Set([
|
|
105
|
+
...d.value.get(n).dependencies ?? [],
|
|
106
|
+
e
|
|
107
|
+
])
|
|
108
|
+
]
|
|
109
|
+
};
|
|
110
|
+
if (!r.update(
|
|
111
|
+
r.items().map(
|
|
112
|
+
(m) => m.id === t ? u : m.id === n ? c : m
|
|
113
|
+
),
|
|
114
|
+
o
|
|
115
|
+
))
|
|
116
|
+
return b(o, "busy"), !1;
|
|
117
|
+
if (r.change(u), r.change(c), await z(), !r.live()) return !1;
|
|
118
|
+
const s = d.value.get(t), g = d.value.get(n);
|
|
119
|
+
return !s || !g || (w = s.dependencies) != null && w.includes(e) || !((S = g.dependencies) != null && S.includes(e)) ? (b(o, "rejected"), !1) : (p.value = { sourceId: e, targetId: n, type: "remove" }, v.value = "前置依赖的终点已修改", r.moved(o, g, s), !0);
|
|
120
|
+
}
|
|
121
|
+
let h, P, l, D, I, k = !1, H = 0;
|
|
122
|
+
function Q() {
|
|
123
|
+
var n;
|
|
124
|
+
I !== void 0 && cancelAnimationFrame(I), I = void 0;
|
|
125
|
+
const e = h, t = P;
|
|
126
|
+
h = void 0, P = void 0, l = D = void 0, e !== void 0 && ((n = t == null ? void 0 : t.hasPointerCapture) != null && n.call(t, e)) && t.releasePointerCapture(e);
|
|
127
|
+
}
|
|
128
|
+
function f(e = !0) {
|
|
129
|
+
h !== void 0 && (H = performance.now() + 350), a.value = void 0, Q(), e && (v.value = "");
|
|
130
|
+
}
|
|
131
|
+
function X(e, t) {
|
|
132
|
+
var c, s;
|
|
133
|
+
const n = a.value;
|
|
134
|
+
if (!n) return;
|
|
135
|
+
const o = e === void 0 ? null : n.previousTargetId === void 0 ? E({ sourceId: n.sourceId, targetId: e, type: "add" }) : M({
|
|
136
|
+
sourceId: n.sourceId,
|
|
137
|
+
previousTargetId: n.previousTargetId,
|
|
138
|
+
targetId: e
|
|
139
|
+
}), i = e === void 0 ? void 0 : r.position(e), u = i ? { x: i.x, y: i.y } : t;
|
|
140
|
+
(n.targetId !== e || n.reason !== o || n.point.x !== u.x || n.point.y !== u.y) && (a.value = { ...n, targetId: e, point: u, reason: o }), v.value = o ? J[o] : e === void 0 ? "拖到后置任务,释放建立前置依赖" : `${((c = d.value.get(n.sourceId)) == null ? void 0 : c.title) ?? n.sourceId} → ${((s = d.value.get(e)) == null ? void 0 : s.title) ?? e},释放或按 Enter 确认`;
|
|
141
|
+
}
|
|
142
|
+
function Y() {
|
|
143
|
+
I === void 0 && (I = requestAnimationFrame(U));
|
|
144
|
+
}
|
|
145
|
+
function U(e, t = !0) {
|
|
146
|
+
var m;
|
|
147
|
+
I = void 0;
|
|
148
|
+
const n = a.value, o = r.viewport.value, i = r.grid.value;
|
|
149
|
+
if (!r.live() || !r.enabled.value || (n == null ? void 0 : n.mode) !== "pointer" || !l || !o || !i)
|
|
150
|
+
return;
|
|
151
|
+
const u = o.getBoundingClientRect(), c = i.getBoundingClientRect(), s = document.elementFromPoint(l.x, l.y), g = l.x >= u.left && l.x <= u.right && l.y >= u.top && l.y <= u.bottom, w = (s == null ? void 0 : s.closest(".hys-ui-pg-gantt")) === r.root.value;
|
|
152
|
+
let S;
|
|
153
|
+
if (g && w && l.y >= u.top + 66) {
|
|
154
|
+
const L = s == null ? void 0 : s.closest("[data-row-index]"), V = L ? Number(L.dataset.rowIndex) : Math.floor((l.y - c.top) / r.rowHeight());
|
|
155
|
+
S = (m = r.rows()[V]) == null ? void 0 : m.id;
|
|
156
|
+
}
|
|
157
|
+
if (X(S, { x: l.x - c.left, y: l.y - c.top }), t && g && k) {
|
|
158
|
+
const L = o.scrollTop, V = o.scrollLeft, ue = l.y < u.top + 94 ? -12 : l.y > u.bottom - 28 ? 12 : 0, _ = u.left + r.labelWidth(), de = l.x < _ ? 0 : l.x < _ + 28 ? -12 : l.x > u.right - 28 ? 12 : 0;
|
|
159
|
+
o.scrollTop += ue, o.scrollLeft += de, (o.scrollTop !== L || o.scrollLeft !== V) && Y();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function Z(e, t, n) {
|
|
163
|
+
var i;
|
|
164
|
+
if (!r.live() || !r.enabled.value || e.button !== 0 || (i = d.value.get(t)) != null && i.disabled || !r.viewport.value)
|
|
165
|
+
return;
|
|
166
|
+
f(), r.cancelTask(), p.value = void 0;
|
|
167
|
+
const o = r.position(t);
|
|
168
|
+
o && (l = D = { x: e.clientX, y: e.clientY }, k = !1, a.value = {
|
|
169
|
+
sourceId: t,
|
|
170
|
+
previousTargetId: n,
|
|
171
|
+
targetId: n,
|
|
172
|
+
mode: "pointer",
|
|
173
|
+
point: n === void 0 ? { x: o.x + o.w, y: o.y } : r.position(n) ?? {
|
|
174
|
+
x: o.x + o.w,
|
|
175
|
+
y: o.y
|
|
176
|
+
},
|
|
177
|
+
reason: null
|
|
178
|
+
}, h = e.pointerId, P = r.viewport.value, P.setPointerCapture(e.pointerId), P.focus({ preventScroll: !0 }), v.value = n === void 0 ? "拖到后置任务,释放建立前置依赖" : "拖到新的后置任务,释放修改终点;Esc 保留原连接");
|
|
179
|
+
}
|
|
180
|
+
function ee(e) {
|
|
181
|
+
h !== e.pointerId || !a.value || (l = { x: e.clientX, y: e.clientY }, k = k || !!D && Math.hypot(l.x - D.x, l.y - D.y) > 4, k && Y());
|
|
182
|
+
}
|
|
183
|
+
async function B(e) {
|
|
184
|
+
const t = a.value, n = e ?? (t == null ? void 0 : t.targetId);
|
|
185
|
+
if (!t || n === void 0)
|
|
186
|
+
return v.value = "请选择一个后置任务", !1;
|
|
187
|
+
const o = t.previousTargetId === void 0 ? {
|
|
188
|
+
sourceId: t.sourceId,
|
|
189
|
+
targetId: n,
|
|
190
|
+
type: "add"
|
|
191
|
+
} : {
|
|
192
|
+
sourceId: t.sourceId,
|
|
193
|
+
previousTargetId: t.previousTargetId,
|
|
194
|
+
targetId: n,
|
|
195
|
+
type: "move"
|
|
196
|
+
}, i = o.type === "move" ? M(o) : E(o);
|
|
197
|
+
return i ? (b(o, i), t.mode === "pointer" && f(!1), !1) : (f(!1), o.type === "move" ? G(o.sourceId, o.previousTargetId, o.targetId) : F(o.sourceId, o.targetId));
|
|
198
|
+
}
|
|
199
|
+
function te(e) {
|
|
200
|
+
var t, n, o;
|
|
201
|
+
if (h === e.pointerId)
|
|
202
|
+
if (k)
|
|
203
|
+
I !== void 0 && cancelAnimationFrame(I), I = void 0, l = { x: e.clientX, y: e.clientY }, U(void 0, !1), H = performance.now() + 350, B(), ((t = a.value) == null ? void 0 : t.mode) === "pointer" && f(!1);
|
|
204
|
+
else {
|
|
205
|
+
const i = (n = a.value) == null ? void 0 : n.sourceId, u = (o = a.value) == null ? void 0 : o.previousTargetId;
|
|
206
|
+
f(), H = performance.now() + 350, i !== void 0 && C(i, u);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function ne(e) {
|
|
210
|
+
h === e.pointerId && f();
|
|
211
|
+
}
|
|
212
|
+
function C(e, t) {
|
|
213
|
+
var o, i, u;
|
|
214
|
+
if (!r.live() || !r.enabled.value || (o = d.value.get(e)) != null && o.disabled)
|
|
215
|
+
return;
|
|
216
|
+
if (((i = a.value) == null ? void 0 : i.mode) === "keyboard" && a.value.sourceId === e && a.value.previousTargetId === t) {
|
|
217
|
+
f();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
f(), r.cancelTask(), p.value = void 0;
|
|
221
|
+
const n = r.position(e);
|
|
222
|
+
n && (a.value = {
|
|
223
|
+
sourceId: e,
|
|
224
|
+
previousTargetId: t,
|
|
225
|
+
targetId: t,
|
|
226
|
+
mode: "keyboard",
|
|
227
|
+
point: t === void 0 ? { x: n.x + n.w, y: n.y } : r.position(t) ?? {
|
|
228
|
+
x: n.x + n.w,
|
|
229
|
+
y: n.y
|
|
230
|
+
},
|
|
231
|
+
reason: null
|
|
232
|
+
}, v.value = t === void 0 ? "点击后置任务,或用上下键选择后按 Enter 确认;Esc 取消" : "选择新的后置任务后按 Enter 确认;Esc 保留原连接", (u = r.viewport.value) == null || u.focus({ preventScroll: !0 }));
|
|
233
|
+
}
|
|
234
|
+
function re(e, t, n) {
|
|
235
|
+
performance.now() < H || C(t, n);
|
|
236
|
+
}
|
|
237
|
+
function oe(e) {
|
|
238
|
+
var t;
|
|
239
|
+
if (!e.defaultPrevented) {
|
|
240
|
+
if (e.key === "Escape" && (a.value || $.value)) {
|
|
241
|
+
e.preventDefault(), e.stopPropagation(), f(), p.value = void 0;
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (((t = a.value) == null ? void 0 : t.mode) === "keyboard" && ["ArrowDown", "ArrowUp", "Enter", " "].includes(e.key)) {
|
|
245
|
+
if (e.preventDefault(), e.stopPropagation(), e.key === "Enter" || e.key === " ") {
|
|
246
|
+
B();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const n = r.rows(), o = a.value.targetId ?? a.value.sourceId, i = n.findIndex((c) => c.id === o), u = e.key === "ArrowDown" ? 1 : -1;
|
|
250
|
+
for (let c = i + u; c >= 0 && c < n.length; c += u) {
|
|
251
|
+
const s = n[c];
|
|
252
|
+
if (s.id === a.value.sourceId || s.disabled) continue;
|
|
253
|
+
const g = r.position(s.id);
|
|
254
|
+
g && (X(s.id, { x: g.x, y: g.y }), r.locate(s.id, { block: "nearest" }));
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
$.value && ["Delete", "Backspace"].includes(e.key) && (e.target instanceof SVGElement || e.target === r.viewport.value) && (e.preventDefault(), e.stopPropagation(), R($.value.sourceId, $.value.targetId));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function ae(e, t, n) {
|
|
263
|
+
var o, i;
|
|
264
|
+
!r.enabled.value || !r.live() || (f(), p.value = { sourceId: t, targetId: n, type: "remove" }, v.value = `${((o = d.value.get(t)) == null ? void 0 : o.title) ?? t} → ${((i = d.value.get(n)) == null ? void 0 : i.title) ?? n},拖动终点可改接;Delete 可移除`, e.currentTarget instanceof SVGElement && e.currentTarget.focus());
|
|
265
|
+
}
|
|
266
|
+
const ie = T(() => {
|
|
267
|
+
const e = a.value, t = e && r.position(e.sourceId);
|
|
268
|
+
return e && t ? ye(t, e.point, r.rowHeight()) : "";
|
|
269
|
+
}), q = () => {
|
|
270
|
+
const e = !!$.value;
|
|
271
|
+
p.value = void 0, e && !a.value && (v.value = "");
|
|
272
|
+
};
|
|
273
|
+
function K() {
|
|
274
|
+
f();
|
|
275
|
+
}
|
|
276
|
+
const N = () => window.addEventListener("blur", K), W = () => {
|
|
277
|
+
window.removeEventListener("blur", K), f();
|
|
278
|
+
};
|
|
279
|
+
return se(N), ce(N), ve(W), pe(W), fe(r.enabled, (e) => {
|
|
280
|
+
e || (f(), q());
|
|
281
|
+
}), {
|
|
282
|
+
draft: a,
|
|
283
|
+
selected: $,
|
|
284
|
+
message: v,
|
|
285
|
+
path: ie,
|
|
286
|
+
add: F,
|
|
287
|
+
remove: R,
|
|
288
|
+
moveTarget: G,
|
|
289
|
+
cancel: f,
|
|
290
|
+
beginPointer: Z,
|
|
291
|
+
move: ee,
|
|
292
|
+
end: te,
|
|
293
|
+
lost: ne,
|
|
294
|
+
clickSource: re,
|
|
295
|
+
beginKeyboard: C,
|
|
296
|
+
key: oe,
|
|
297
|
+
selectEdge: ae,
|
|
298
|
+
clearSelected: q,
|
|
299
|
+
submit: B
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
export {
|
|
303
|
+
ye as ganttDependencyPath,
|
|
304
|
+
Ie as ganttDependencyPickPath,
|
|
305
|
+
we as useGanttDependencies
|
|
306
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { shallowRef as N, ref as L, computed as R, watch as O, onDeactivated as P, onBeforeUnmount as Q, onActivated as W, nextTick as T } from "vue";
|
|
2
|
+
const J = ["start", "end", "dependencies"], V = (e, a) => Array.isArray(e) && Array.isArray(a) ? e.length === a.length && e.every((s, r) => s === a[r]) : e === a, z = (e) => Array.isArray(e) ? [...e] : e;
|
|
3
|
+
function S(e) {
|
|
4
|
+
return e.map((a) => ({
|
|
5
|
+
id: a.id,
|
|
6
|
+
start: a.start,
|
|
7
|
+
end: a.end,
|
|
8
|
+
dependencies: a.dependencies ? [...a.dependencies] : void 0
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
function I(e, a) {
|
|
12
|
+
return e.length === a.length && e.every(
|
|
13
|
+
(s, r) => s.id === a[r].id && J.every((d) => V(s[d], a[r][d]))
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function X(e) {
|
|
17
|
+
return { ...e.info, taskIds: [...e.info.taskIds] };
|
|
18
|
+
}
|
|
19
|
+
function Z(e) {
|
|
20
|
+
const a = N([]), s = N([]), r = L(!1), d = L(!0), m = L(""), y = R(
|
|
21
|
+
() => Number.isFinite(e.limit()) ? Math.max(0, Math.min(1e3, Math.floor(e.limit()))) : 50
|
|
22
|
+
), p = R(() => e.enabled() && y.value > 0), g = R(() => S(e.items()));
|
|
23
|
+
let U = g.value, c, b = 0;
|
|
24
|
+
function H(n, t) {
|
|
25
|
+
if (!n || !p.value || !d.value || !e.live() || r.value)
|
|
26
|
+
return !1;
|
|
27
|
+
const A = new Map(e.items().map((u) => [u.id, u]));
|
|
28
|
+
return n.patches.every((u) => {
|
|
29
|
+
const v = A.get(u.id);
|
|
30
|
+
return v && e.allowed(
|
|
31
|
+
v,
|
|
32
|
+
u.fields,
|
|
33
|
+
t === "undo" ? u.before : u.after
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const q = R(() => H(a.value.at(-1), "undo")), B = R(() => H(s.value.at(-1), "redo")), D = R(() => {
|
|
38
|
+
var n, t;
|
|
39
|
+
return {
|
|
40
|
+
canUndo: q.value,
|
|
41
|
+
canRedo: B.value,
|
|
42
|
+
undoCount: a.value.length,
|
|
43
|
+
redoCount: s.value.length,
|
|
44
|
+
undoLabel: ((n = a.value.at(-1)) == null ? void 0 : n.info.label) ?? "",
|
|
45
|
+
redoLabel: ((t = s.value.at(-1)) == null ? void 0 : t.info.label) ?? "",
|
|
46
|
+
pending: r.value
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
O(D, (n) => {
|
|
50
|
+
d.value && e.live() && e.state({ ...n });
|
|
51
|
+
});
|
|
52
|
+
function k() {
|
|
53
|
+
b++, c = void 0, r.value = !1, a.value = [], s.value = [], m.value = "";
|
|
54
|
+
}
|
|
55
|
+
O(
|
|
56
|
+
g,
|
|
57
|
+
(n) => {
|
|
58
|
+
if (I(n, U) || (U = n, c && I(n, c))) return;
|
|
59
|
+
const t = a.value.length > 0 || s.value.length > 0;
|
|
60
|
+
k(), e.external(), t && (m.value = "外部排期已更新,历史记录已清空");
|
|
61
|
+
},
|
|
62
|
+
{ flush: "post" }
|
|
63
|
+
), O([p, y], () => {
|
|
64
|
+
if (!p.value) {
|
|
65
|
+
k();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
a.value = a.value.slice(-y.value), s.value = s.value.slice(-y.value);
|
|
69
|
+
});
|
|
70
|
+
function K(n, t) {
|
|
71
|
+
if (!d.value || !e.live() || r.value) return !1;
|
|
72
|
+
const A = p.value, u = g.value, v = S(n);
|
|
73
|
+
if (I(u, v))
|
|
74
|
+
return e.send(n), !0;
|
|
75
|
+
if (u.length !== v.length)
|
|
76
|
+
return k(), e.send(n), !0;
|
|
77
|
+
const h = [];
|
|
78
|
+
for (let f = 0; f < u.length; f++) {
|
|
79
|
+
const M = u[f], l = v[f];
|
|
80
|
+
if (!l || l.id !== M.id)
|
|
81
|
+
return k(), e.send(n), !0;
|
|
82
|
+
const o = J.filter(
|
|
83
|
+
(i) => !V(M[i], l[i])
|
|
84
|
+
);
|
|
85
|
+
o.length && h.push({
|
|
86
|
+
id: M.id,
|
|
87
|
+
fields: o,
|
|
88
|
+
before: Object.fromEntries(
|
|
89
|
+
o.map((i) => [i, z(M[i])])
|
|
90
|
+
),
|
|
91
|
+
after: Object.fromEntries(
|
|
92
|
+
o.map((i) => [i, z(l[i])])
|
|
93
|
+
)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const C = {
|
|
97
|
+
info: { ...t, taskIds: h.map((f) => f.id) },
|
|
98
|
+
patches: h
|
|
99
|
+
}, E = ++b;
|
|
100
|
+
return c = v, r.value = !0, e.send(n), T().then(() => {
|
|
101
|
+
if (E !== b || !d.value || !e.live()) return;
|
|
102
|
+
const f = I(g.value, v);
|
|
103
|
+
c = void 0, r.value = !1, U = g.value, !(!f || !A || !p.value) && (a.value = [...a.value, C].slice(-y.value), s.value = [], m.value = "");
|
|
104
|
+
}), !0;
|
|
105
|
+
}
|
|
106
|
+
function w(n, t) {
|
|
107
|
+
return e.live() && d.value && e.invalid({ action: n, reason: t }), m.value = t === "rejected" ? "宿主未接受历史恢复请求" : t === "disabled" ? "当前权限不允许恢复此操作" : t === "busy" ? "上一项修改尚未完成" : t === "stale" ? "排期已变化,无法恢复旧记录" : "没有可恢复的记录", !1;
|
|
108
|
+
}
|
|
109
|
+
async function F(n) {
|
|
110
|
+
if (!d.value || !e.live()) return !1;
|
|
111
|
+
if (r.value) return w(n, "busy");
|
|
112
|
+
const t = n === "undo" ? a : s, A = n === "undo" ? s : a, u = t.value.at(-1);
|
|
113
|
+
if (!p.value) return w(n, "disabled");
|
|
114
|
+
if (!u) return w(n, "missing");
|
|
115
|
+
if (!H(u, n)) return w(n, "disabled");
|
|
116
|
+
const v = new Map(e.items().map((l) => [l.id, l]));
|
|
117
|
+
if (!u.patches.every((l) => {
|
|
118
|
+
const o = v.get(l.id), i = n === "undo" ? l.after : l.before;
|
|
119
|
+
return o && l.fields.every((j) => V(o[j], i[j]));
|
|
120
|
+
}))
|
|
121
|
+
return k(), w(n, "stale");
|
|
122
|
+
e.beforeReplay();
|
|
123
|
+
const h = /* @__PURE__ */ new Map();
|
|
124
|
+
for (const l of u.patches) {
|
|
125
|
+
const o = { ...v.get(l.id) }, i = n === "undo" ? l.before : l.after;
|
|
126
|
+
for (const j of l.fields)
|
|
127
|
+
j === "dependencies" ? i.dependencies === void 0 ? delete o.dependencies : o.dependencies = [...i.dependencies] : o[j] = i[j];
|
|
128
|
+
h.set(l.id, o);
|
|
129
|
+
}
|
|
130
|
+
const C = e.items().map((l) => h.get(l.id) ?? l), E = S(C), f = ++b;
|
|
131
|
+
c = E, r.value = !0, e.send(C);
|
|
132
|
+
for (const l of h.values()) e.change(l);
|
|
133
|
+
if (await T(), f !== b || !d.value || !e.live()) return !1;
|
|
134
|
+
const M = I(g.value, E);
|
|
135
|
+
return c = void 0, r.value = !1, U = g.value, M ? (t.value = t.value.slice(0, -1), A.value = [...A.value, u].slice(-y.value), m.value = (n === "undo" ? "已撤销:" : "已重做:") + u.info.label, e.replay(n, X(u)), !0) : w(n, "rejected");
|
|
136
|
+
}
|
|
137
|
+
function G() {
|
|
138
|
+
d.value = !1, b++, c = void 0, r.value = !1;
|
|
139
|
+
}
|
|
140
|
+
return P(G), Q(G), W(() => {
|
|
141
|
+
d.value = !0;
|
|
142
|
+
}), {
|
|
143
|
+
capture: K,
|
|
144
|
+
clear: k,
|
|
145
|
+
undo: () => F("undo"),
|
|
146
|
+
redo: () => F("redo"),
|
|
147
|
+
state: D,
|
|
148
|
+
canUndo: q,
|
|
149
|
+
canRedo: B,
|
|
150
|
+
pending: r,
|
|
151
|
+
enabled: p,
|
|
152
|
+
message: m
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
Z as useGanttHistory
|
|
157
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ref as I, computed as b, watch as y, onMounted as F, onActivated as C, onDeactivated as D, onBeforeUnmount as X } from "vue";
|
|
2
|
+
function H(t) {
|
|
3
|
+
const u = (e, a) => Number.isFinite(e) && e > 0 ? e : a, v = u(t.width(), 270), s = I(v), h = I(!1), o = b(
|
|
4
|
+
() => Math.floor(
|
|
5
|
+
Math.min(
|
|
6
|
+
Math.max(u(t.min(), 120), u(t.max(), 600)),
|
|
7
|
+
t.available.value > 0 ? Math.max(
|
|
8
|
+
40,
|
|
9
|
+
t.available.value - Math.max(80, Math.min(160, t.available.value / 2))
|
|
10
|
+
) : 1 / 0
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
), w = b(
|
|
14
|
+
() => Math.min(u(t.min(), 120), o.value)
|
|
15
|
+
), p = (e) => Math.round(Math.min(o.value, Math.max(w.value, e))), n = b(() => p(s.value));
|
|
16
|
+
y(t.width, (e) => s.value = u(e, 270));
|
|
17
|
+
let i, l, d = v;
|
|
18
|
+
const m = (e) => {
|
|
19
|
+
const a = p(e);
|
|
20
|
+
a !== n.value && (s.value = a, t.update(a));
|
|
21
|
+
};
|
|
22
|
+
function x() {
|
|
23
|
+
l = void 0, i && t.live() && m(d);
|
|
24
|
+
}
|
|
25
|
+
function f() {
|
|
26
|
+
var a, c;
|
|
27
|
+
l !== void 0 && cancelAnimationFrame(l), l = void 0;
|
|
28
|
+
const e = i;
|
|
29
|
+
i = void 0, h.value = !1, (c = e == null ? void 0 : (a = e.element).hasPointerCapture) != null && c.call(a, e.pointerId) && e.element.releasePointerCapture(e.pointerId);
|
|
30
|
+
}
|
|
31
|
+
function r() {
|
|
32
|
+
const e = i == null ? void 0 : i.width;
|
|
33
|
+
f(), e !== void 0 && m(e);
|
|
34
|
+
}
|
|
35
|
+
function A(e) {
|
|
36
|
+
if (!t.enabled() || !t.live() || e.button !== 0) return;
|
|
37
|
+
t.start(), f();
|
|
38
|
+
const a = e.currentTarget;
|
|
39
|
+
i = {
|
|
40
|
+
element: a,
|
|
41
|
+
pointerId: e.pointerId,
|
|
42
|
+
x: e.clientX,
|
|
43
|
+
width: n.value
|
|
44
|
+
}, d = n.value, h.value = !0, a.setPointerCapture(e.pointerId), a.focus({ preventScroll: !0 });
|
|
45
|
+
}
|
|
46
|
+
function g(e) {
|
|
47
|
+
!i || e.pointerId !== i.pointerId || (d = i.width + e.clientX - i.x, l === void 0 && (l = requestAnimationFrame(x)));
|
|
48
|
+
}
|
|
49
|
+
function k(e) {
|
|
50
|
+
if (!i || e.pointerId !== i.pointerId) return;
|
|
51
|
+
if (e.type === "pointercancel") {
|
|
52
|
+
r();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const a = i.width;
|
|
56
|
+
d = a + e.clientX - i.x, l !== void 0 && cancelAnimationFrame(l), x(), f(), n.value !== a && t.commit(n.value);
|
|
57
|
+
}
|
|
58
|
+
function E(e) {
|
|
59
|
+
if (e.key === "Escape" && i) {
|
|
60
|
+
e.preventDefault(), e.stopPropagation(), r();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!t.enabled() || !t.live() || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key))
|
|
64
|
+
return;
|
|
65
|
+
e.preventDefault(), e.stopPropagation(), t.start();
|
|
66
|
+
const a = n.value, c = e.shiftKey ? 50 : 10;
|
|
67
|
+
m(
|
|
68
|
+
e.key === "Home" ? w.value : e.key === "End" ? o.value : a + (e.key === "ArrowLeft" ? -c : c)
|
|
69
|
+
), n.value !== a && t.commit(n.value);
|
|
70
|
+
}
|
|
71
|
+
function L() {
|
|
72
|
+
if (!t.enabled() || !t.live()) return;
|
|
73
|
+
t.start(), r();
|
|
74
|
+
const e = n.value;
|
|
75
|
+
m(v), n.value !== e && t.commit(n.value);
|
|
76
|
+
}
|
|
77
|
+
y(t.enabled, (e) => {
|
|
78
|
+
e || r();
|
|
79
|
+
});
|
|
80
|
+
const M = () => window.addEventListener("blur", r), P = () => {
|
|
81
|
+
window.removeEventListener("blur", r), r();
|
|
82
|
+
};
|
|
83
|
+
return F(M), C(M), D(P), X(() => {
|
|
84
|
+
window.removeEventListener("blur", r), f();
|
|
85
|
+
}), {
|
|
86
|
+
width: n,
|
|
87
|
+
minimum: w,
|
|
88
|
+
maximum: o,
|
|
89
|
+
resizing: h,
|
|
90
|
+
down: A,
|
|
91
|
+
move: g,
|
|
92
|
+
up: k,
|
|
93
|
+
cancel: r,
|
|
94
|
+
key: E,
|
|
95
|
+
reset: L
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
H as useGanttLabelResize
|
|
100
|
+
};
|