@pequity/squirrel 1.0.20 → 1.0.21-beta.1
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/dist/cjs/chunks/_plugin-vue_export-helper.js +9 -0
- package/dist/cjs/chunks/p-action-bar.js +60 -0
- package/dist/cjs/chunks/p-card.js +28 -0
- package/dist/cjs/chunks/p-checkbox.js +24 -0
- package/dist/cjs/chunks/p-dropdown-select.js +414 -0
- package/dist/cjs/chunks/p-input-percent.js +53 -0
- package/dist/cjs/chunks/p-pagination-info.js +66 -0
- package/dist/cjs/chunks/p-pagination.js +122 -0
- package/dist/cjs/chunks/p-ring-loader.js +81 -0
- package/dist/cjs/chunks/p-select-btn.js +97 -0
- package/dist/cjs/chunks/p-select.js +123 -0
- package/dist/cjs/chunks/p-table-loader.js +70 -0
- package/dist/cjs/chunks/p-tabs.js +52 -0
- package/dist/cjs/config.js +105 -0
- package/dist/cjs/currency.js +9 -0
- package/dist/cjs/dom.js +27 -0
- package/dist/cjs/index.js +976 -0
- package/dist/cjs/inputClassesMixin.js +50 -0
- package/dist/cjs/inputClassesShared.js +76 -0
- package/dist/cjs/listKeyboardNavigation.js +110 -0
- package/dist/cjs/number.js +9 -0
- package/dist/cjs/object.js +4 -0
- package/dist/cjs/p-action-bar.js +3 -0
- package/dist/cjs/p-alert.js +65 -0
- package/dist/cjs/p-avatar.js +71 -0
- package/dist/cjs/p-btn.js +361 -0
- package/dist/cjs/p-card.js +3 -0
- package/dist/cjs/p-checkbox.js +3 -0
- package/dist/cjs/p-chips.js +110 -0
- package/dist/cjs/p-close-btn.js +36 -0
- package/dist/cjs/p-date-picker.js +139 -0
- package/dist/cjs/p-drawer.js +253 -0
- package/dist/cjs/p-dropdown-select.js +3 -0
- package/dist/cjs/p-dropdown.js +138 -0
- package/dist/cjs/p-file-upload.js +21 -0
- package/dist/cjs/p-info-icon.js +35 -0
- package/dist/cjs/p-inline-date-picker.js +142 -0
- package/dist/cjs/p-input-number.js +146 -0
- package/dist/cjs/p-input-percent.js +3 -0
- package/dist/cjs/p-input-search.js +110 -0
- package/dist/cjs/p-input.js +89 -0
- package/dist/cjs/p-loading.js +38 -0
- package/dist/cjs/p-modal.js +369 -0
- package/dist/cjs/p-pagination-info.js +3 -0
- package/dist/cjs/p-pagination.js +3 -0
- package/dist/cjs/p-progress-bar.js +41 -0
- package/dist/cjs/p-ring-loader.js +3 -0
- package/dist/cjs/p-select-btn.js +3 -0
- package/dist/cjs/p-select-list.js +4 -0
- package/dist/cjs/p-select-pill.js +111 -0
- package/dist/cjs/p-select.js +3 -0
- package/dist/cjs/p-skeleton-loader.js +73 -0
- package/dist/cjs/p-table-filter-icon.js +20 -0
- package/dist/cjs/p-table-header-cell.js +75 -0
- package/dist/cjs/p-table-loader.js +3 -0
- package/dist/cjs/p-table-sort.js +8 -0
- package/dist/cjs/p-table-td.js +88 -0
- package/dist/cjs/p-table.js +12 -0
- package/dist/cjs/p-tabs.js +3 -0
- package/dist/cjs/p-textarea.js +73 -0
- package/dist/cjs/p-toggle.js +114 -0
- package/dist/cjs/pagination.js +29 -0
- package/dist/cjs/string.js +12 -0
- package/dist/cjs/tailwind.js +4353 -0
- package/dist/cjs/text.js +16 -0
- package/dist/cjs/useInputClasses.js +44 -0
- package/dist/cjs/usePLoading.js +35 -0
- package/dist/cjs/usePModal.js +21 -0
- package/dist/cjs/usePTableColResize.js +81 -0
- package/dist/cjs/usePTableRowVirtualizer.js +31 -0
- package/dist/cjs/useSelectList.js +256 -0
- package/dist/es/chunks/_plugin-vue_export-helper.js +10 -0
- package/dist/es/chunks/p-action-bar.js +61 -0
- package/dist/es/chunks/p-card.js +29 -0
- package/dist/es/chunks/p-checkbox.js +25 -0
- package/dist/es/chunks/p-dropdown-select.js +415 -0
- package/dist/es/chunks/p-input-percent.js +54 -0
- package/dist/es/chunks/p-pagination-info.js +67 -0
- package/dist/es/chunks/p-pagination.js +123 -0
- package/dist/es/chunks/p-ring-loader.js +82 -0
- package/dist/es/chunks/p-select-btn.js +98 -0
- package/dist/es/chunks/p-select.js +124 -0
- package/dist/es/chunks/p-table-loader.js +71 -0
- package/dist/es/chunks/p-tabs.js +53 -0
- package/dist/es/config.js +105 -0
- package/dist/es/currency.js +9 -0
- package/dist/es/dom.js +27 -0
- package/dist/es/index.js +978 -0
- package/dist/es/inputClassesMixin.js +51 -0
- package/dist/es/inputClassesShared.js +76 -0
- package/dist/es/listKeyboardNavigation.js +110 -0
- package/dist/es/number.js +9 -0
- package/dist/es/object.js +4 -0
- package/dist/es/p-action-bar.js +4 -0
- package/dist/es/p-alert.js +66 -0
- package/dist/es/p-avatar.js +72 -0
- package/dist/es/p-btn.js +362 -0
- package/dist/es/p-card.js +4 -0
- package/dist/es/p-checkbox.js +4 -0
- package/dist/es/p-chips.js +111 -0
- package/dist/es/p-close-btn.js +37 -0
- package/dist/es/p-date-picker.js +140 -0
- package/dist/es/p-drawer.js +254 -0
- package/dist/es/p-dropdown-select.js +4 -0
- package/dist/es/p-dropdown.js +139 -0
- package/dist/es/p-file-upload.js +21 -0
- package/dist/es/p-info-icon.js +36 -0
- package/dist/es/p-inline-date-picker.js +143 -0
- package/dist/es/p-input-number.js +147 -0
- package/dist/es/p-input-percent.js +4 -0
- package/dist/es/p-input-search.js +111 -0
- package/dist/es/p-input.js +90 -0
- package/dist/es/p-loading.js +39 -0
- package/dist/es/p-modal.js +370 -0
- package/dist/es/p-pagination-info.js +4 -0
- package/dist/es/p-pagination.js +4 -0
- package/dist/es/p-progress-bar.js +42 -0
- package/dist/es/p-ring-loader.js +4 -0
- package/dist/es/p-select-btn.js +4 -0
- package/dist/es/p-select-list.js +4 -0
- package/dist/es/p-select-pill.js +112 -0
- package/dist/es/p-select.js +4 -0
- package/dist/es/p-skeleton-loader.js +74 -0
- package/dist/es/p-table-filter-icon.js +21 -0
- package/dist/es/p-table-header-cell.js +76 -0
- package/dist/es/p-table-loader.js +4 -0
- package/dist/es/p-table-sort.js +8 -0
- package/dist/es/p-table-td.js +89 -0
- package/dist/es/p-table.js +12 -0
- package/dist/es/p-tabs.js +4 -0
- package/dist/es/p-textarea.js +74 -0
- package/dist/es/p-toggle.js +115 -0
- package/dist/es/pagination.js +29 -0
- package/dist/es/string.js +12 -0
- package/dist/es/tailwind.js +4353 -0
- package/dist/es/text.js +16 -0
- package/dist/es/useInputClasses.js +44 -0
- package/dist/es/usePLoading.js +35 -0
- package/dist/es/usePModal.js +21 -0
- package/dist/es/usePTableColResize.js +81 -0
- package/dist/es/usePTableRowVirtualizer.js +31 -0
- package/dist/es/useSelectList.js +256 -0
- package/dist/style.css +2124 -1
- package/package.json +26 -24
- package/dist/squirrel.cjs.js +0 -5
- package/dist/squirrel.es.js +0 -8220
package/dist/cjs/text.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const splitStringForHighlight = (textToSearchIn, searchStr) => {
|
|
4
|
+
const str = String(searchStr).trim();
|
|
5
|
+
const text = String(textToSearchIn).trim();
|
|
6
|
+
const index = text.indexOf(str);
|
|
7
|
+
if (index >= 0) {
|
|
8
|
+
const part1 = text.substring(0, index);
|
|
9
|
+
const part2 = text.substring(index, index + str.length);
|
|
10
|
+
const part3 = text.substring(index + str.length);
|
|
11
|
+
return [part1, part2, part3];
|
|
12
|
+
} else {
|
|
13
|
+
return [text];
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.splitStringForHighlight = splitStringForHighlight;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const inputClassesShared = require("./inputClassesShared.js");
|
|
4
|
+
const vue = require("vue");
|
|
5
|
+
const defaults = {
|
|
6
|
+
size: vue.ref("md"),
|
|
7
|
+
errorMsg: vue.ref(""),
|
|
8
|
+
required: vue.ref(false),
|
|
9
|
+
prefix: vue.ref(false),
|
|
10
|
+
suffix: vue.ref(false)
|
|
11
|
+
};
|
|
12
|
+
function useInputClasses(props) {
|
|
13
|
+
const opts = { ...defaults, ...vue.toRefs(props) };
|
|
14
|
+
const { size, errorMsg, required, prefix, suffix } = opts;
|
|
15
|
+
const inputClasses = vue.computed(() => {
|
|
16
|
+
const base = `${inputClassesShared.INPUT_BASE} ${inputClassesShared.INPUT_SIZES[size.value]}`;
|
|
17
|
+
const spacingLeft = prefix.value ? inputClassesShared.SPACING_PREFIX[size.value] : inputClassesShared.SPACING_LEFT[size.value];
|
|
18
|
+
const spacingRight = suffix.value ? inputClassesShared.SPACING_SUFFIX[size.value] : inputClassesShared.SPACING_RIGHT[size.value];
|
|
19
|
+
const res = `${base} ${spacingLeft} ${spacingRight} ${errorMsg.value ? inputClassesShared.INPUT_ERROR : inputClassesShared.INPUT_NORMAL}`;
|
|
20
|
+
return res;
|
|
21
|
+
});
|
|
22
|
+
const labelClasses = vue.computed(() => {
|
|
23
|
+
const base = `${inputClassesShared.LABEL_BASE} ${inputClassesShared.LABEL_SIZES[size.value]}`;
|
|
24
|
+
const res = required.value ? `${base} ${inputClassesShared.LABEL_REQUIRED}` : base;
|
|
25
|
+
return res;
|
|
26
|
+
});
|
|
27
|
+
const selectClasses = vue.computed(() => {
|
|
28
|
+
const res = `${inputClasses.value.replace(` ${inputClassesShared.SPACING_RIGHT[size.value]}`, "")} ${inputClassesShared.SELECT_BASE} ${inputClassesShared.SELECT_ARROW} ${inputClassesShared.SELECT_SIZES[size.value]}`;
|
|
29
|
+
return res;
|
|
30
|
+
});
|
|
31
|
+
const textareaClasses = vue.computed(() => {
|
|
32
|
+
const res = `${inputClasses.value} ${inputClassesShared.TEXTAREA_BASE}`;
|
|
33
|
+
return res;
|
|
34
|
+
});
|
|
35
|
+
const errorMsgClasses = vue.ref(inputClassesShared.ERROR_MSG);
|
|
36
|
+
return {
|
|
37
|
+
inputClasses,
|
|
38
|
+
labelClasses,
|
|
39
|
+
selectClasses,
|
|
40
|
+
textareaClasses,
|
|
41
|
+
errorMsgClasses
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.useInputClasses = useInputClasses;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const lodashEs = require("lodash-es");
|
|
5
|
+
const show = vue.ref(false);
|
|
6
|
+
const loadingIds = [];
|
|
7
|
+
let timer;
|
|
8
|
+
const usePLoading = (options) => {
|
|
9
|
+
const { delay } = { delay: 200, ...options };
|
|
10
|
+
const scope = vue.getCurrentScope();
|
|
11
|
+
const loadingShow = () => {
|
|
12
|
+
if (loadingIds.length === 0 && delay > 0) {
|
|
13
|
+
timer = setTimeout(() => {
|
|
14
|
+
show.value = true;
|
|
15
|
+
}, delay);
|
|
16
|
+
} else {
|
|
17
|
+
show.value = true;
|
|
18
|
+
}
|
|
19
|
+
loadingIds.push(lodashEs.uniqueId());
|
|
20
|
+
};
|
|
21
|
+
const loadingHide = () => {
|
|
22
|
+
if (loadingIds.length === 1) {
|
|
23
|
+
show.value = false;
|
|
24
|
+
}
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
loadingIds.pop();
|
|
27
|
+
};
|
|
28
|
+
if (scope) {
|
|
29
|
+
vue.onScopeDispose(() => {
|
|
30
|
+
loadingHide();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return { show, loadingShow, loadingHide };
|
|
34
|
+
};
|
|
35
|
+
exports.usePLoading = usePLoading;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const state = vue.reactive({
|
|
5
|
+
modals: {}
|
|
6
|
+
});
|
|
7
|
+
const usePModal = () => {
|
|
8
|
+
const show = (name) => {
|
|
9
|
+
state.modals[name] = true;
|
|
10
|
+
};
|
|
11
|
+
const hide = (name) => {
|
|
12
|
+
delete state.modals[name];
|
|
13
|
+
};
|
|
14
|
+
const hideAll = () => {
|
|
15
|
+
Object.keys(state.modals).forEach((modalName) => {
|
|
16
|
+
hide(modalName);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
return { state, show, hide, hideAll };
|
|
20
|
+
};
|
|
21
|
+
exports.usePModal = usePModal;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const pTable = require("./p-table.js");
|
|
4
|
+
const vue = require("vue");
|
|
5
|
+
const usePTableColResize = (options) => {
|
|
6
|
+
const { enabled, ths } = options;
|
|
7
|
+
const isColResizing = vue.ref(false);
|
|
8
|
+
const colResizeHandleLeft = vue.ref("0px");
|
|
9
|
+
const colResizingWidth = vue.ref(0);
|
|
10
|
+
const colResizingIndex = vue.ref(-1);
|
|
11
|
+
const colResize = (e) => {
|
|
12
|
+
colResizeHandleLeft.value = `${e.clientX}px`;
|
|
13
|
+
if (isColResizing.value) {
|
|
14
|
+
document.body.classList.add("cursor-col-resize");
|
|
15
|
+
const th = ths.value[colResizingIndex.value];
|
|
16
|
+
const rect = th.getBoundingClientRect();
|
|
17
|
+
const diff = e.clientX - rect.left - th.offsetWidth;
|
|
18
|
+
const widthToSet = th.offsetWidth + diff;
|
|
19
|
+
setColResizingWidth(widthToSet);
|
|
20
|
+
colResizeHandleLeft.value = e.clientX < rect.left ? "0px" : `${e.clientX}px`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const colResizeStart = (e, i) => {
|
|
24
|
+
if (e.detail === 1) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
isColResizing.value = true;
|
|
27
|
+
colResizingWidth.value = ths.value[i].offsetWidth;
|
|
28
|
+
colResizingIndex.value = i;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const colResizeStop = () => {
|
|
32
|
+
if (!isColResizing.value) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
isColResizing.value = false;
|
|
36
|
+
document.body.classList.remove("cursor-col-resize");
|
|
37
|
+
};
|
|
38
|
+
const colResizeFitToData = (colIndex) => {
|
|
39
|
+
var _a;
|
|
40
|
+
isColResizing.value = true;
|
|
41
|
+
const tds = (_a = ths.value[colIndex].closest("table")) == null ? void 0 : _a.querySelectorAll("tbody tr td:nth-child(" + (colIndex + 1) + ") div.w-max");
|
|
42
|
+
if (!tds) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const maxWidth = [...tds].reduce((max, td) => {
|
|
46
|
+
const width = td.getBoundingClientRect().width;
|
|
47
|
+
return width > max ? width : max;
|
|
48
|
+
}, 0);
|
|
49
|
+
setColResizingWidth(maxWidth);
|
|
50
|
+
vue.nextTick(() => {
|
|
51
|
+
isColResizing.value = false;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const setColResizingWidth = (width) => {
|
|
55
|
+
colResizingWidth.value = width > pTable.MIN_WIDTH_COL_RESIZE ? Math.ceil(width) : pTable.MIN_WIDTH_COL_RESIZE;
|
|
56
|
+
};
|
|
57
|
+
vue.onMounted(() => {
|
|
58
|
+
enabled.value && document.addEventListener("mouseup", colResizeStop);
|
|
59
|
+
});
|
|
60
|
+
vue.onBeforeUnmount(() => {
|
|
61
|
+
enabled.value && document.removeEventListener("mouseup", colResizeStop);
|
|
62
|
+
});
|
|
63
|
+
vue.watch(enabled, (nV) => {
|
|
64
|
+
if (nV) {
|
|
65
|
+
document.addEventListener("mouseup", colResizeStop);
|
|
66
|
+
} else {
|
|
67
|
+
document.removeEventListener("mouseup", colResizeStop);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
isColResizing,
|
|
72
|
+
colResizeHandleLeft,
|
|
73
|
+
colResizingIndex,
|
|
74
|
+
colResizingWidth,
|
|
75
|
+
colResize,
|
|
76
|
+
colResizeStart,
|
|
77
|
+
colResizeStop,
|
|
78
|
+
colResizeFitToData
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
exports.usePTableColResize = usePTableColResize;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const vueVirtual = require("@tanstack/vue-virtual");
|
|
5
|
+
const usePTableRowVirtualizer = (options) => {
|
|
6
|
+
if (!options.value) {
|
|
7
|
+
return {
|
|
8
|
+
virtualizer: null,
|
|
9
|
+
virtualRows: vue.ref([{ key: 0, index: 0 }]),
|
|
10
|
+
paddingTop: vue.ref(0),
|
|
11
|
+
paddingBottom: vue.ref(0),
|
|
12
|
+
measureElement: () => vue.ref(void 0)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const virtualizer = vueVirtual.useVirtualizer(options);
|
|
16
|
+
const virtualRows = vue.computed(() => virtualizer.value.getVirtualItems());
|
|
17
|
+
const paddingTop = vue.computed(() => virtualRows.value.length > 0 ? virtualRows.value[0].start : 0);
|
|
18
|
+
const paddingBottom = vue.computed(
|
|
19
|
+
() => virtualRows.value.length > 0 ? (virtualizer == null ? void 0 : virtualizer.value.getTotalSize()) - virtualRows.value[virtualRows.value.length - 1].end : 0
|
|
20
|
+
);
|
|
21
|
+
const measureElement = (cmp) => {
|
|
22
|
+
const el = vue.isRef(cmp) ? vue.unref(cmp) : cmp == null ? void 0 : cmp.$el;
|
|
23
|
+
if (!el) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
virtualizer.value.measureElement(el);
|
|
27
|
+
return void 0;
|
|
28
|
+
};
|
|
29
|
+
return { virtualizer, virtualRows, paddingTop, paddingBottom, measureElement };
|
|
30
|
+
};
|
|
31
|
+
exports.usePTableRowVirtualizer = usePTableRowVirtualizer;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const listKeyboardNavigation = require("./listKeyboardNavigation.js");
|
|
5
|
+
const lodashEs = require("lodash-es");
|
|
6
|
+
const object = require("./object.js");
|
|
7
|
+
const string = require("./string.js");
|
|
8
|
+
const vueVirtual = require("@tanstack/vue-virtual");
|
|
9
|
+
const createInternalItems = (items) => {
|
|
10
|
+
let arr = Array.isArray(items) ? items.slice() : [];
|
|
11
|
+
if (arr.length && !object.isObject(arr[0])) {
|
|
12
|
+
arr = arr.filter((item, i, self) => self.indexOf(item) === i).map((item) => ({ value: item, text: item }));
|
|
13
|
+
}
|
|
14
|
+
return arr;
|
|
15
|
+
};
|
|
16
|
+
const createInternalValue = (modelValue, valueIsObject, multiple, itemValue, internalItems) => {
|
|
17
|
+
let val = modelValue;
|
|
18
|
+
if (valueIsObject && object.isObject(modelValue)) {
|
|
19
|
+
if (multiple) {
|
|
20
|
+
val = modelValue.map((v) => v[itemValue]);
|
|
21
|
+
} else {
|
|
22
|
+
val = modelValue ? modelValue[itemValue] : modelValue;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const arr = Array.isArray(val) ? val : [val];
|
|
26
|
+
return arr;
|
|
27
|
+
};
|
|
28
|
+
const nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
29
|
+
const nextLoop = (ms) => new Promise((resolve) => setTimeout(resolve, ms || 0));
|
|
30
|
+
const LIST_ITEM_SIZES = { sm: 32, md: 40, lg: 48 };
|
|
31
|
+
const LIST_ITEM_CLASS = "clear-both block w-full cursor-pointer whitespace-nowrap py-1 px-3 text-left text-sm font-medium hover:bg-p-blue-10";
|
|
32
|
+
const LIST_ITEM_ACTIVE_CLASS = "selected";
|
|
33
|
+
const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
|
|
34
|
+
let navigationSvc = null;
|
|
35
|
+
const internalItems = vue.ref([]);
|
|
36
|
+
const internalValue = vue.ref([]);
|
|
37
|
+
const search = vue.ref("");
|
|
38
|
+
const selectedItems = vue.computed(() => {
|
|
39
|
+
return internalItems.value.filter((item) => internalValue.value.includes(item[props.itemValue]));
|
|
40
|
+
});
|
|
41
|
+
const computedItems = vue.computed(() => {
|
|
42
|
+
return lodashEs.cloneDeep(internalItems.value).filter((item) => {
|
|
43
|
+
return String(item[props.itemText]).toLocaleLowerCase().includes(String(search.value).toLocaleLowerCase());
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
const computedItemSize = vue.computed(() => props.itemSize ? props.itemSize : LIST_ITEM_SIZES[props.size]);
|
|
47
|
+
const computedInsideSelected = vue.computed(() => {
|
|
48
|
+
const filteredItems = computedItems.value.map((item) => item[props.itemValue]);
|
|
49
|
+
return filteredItems.every((item) => internalValue.value.includes(item));
|
|
50
|
+
});
|
|
51
|
+
const rowVirtualizer = vueVirtual.useVirtualizer(
|
|
52
|
+
vue.computed(() => {
|
|
53
|
+
return {
|
|
54
|
+
count: computedItems.value.length,
|
|
55
|
+
getScrollElement: () => virtualizerRef.value,
|
|
56
|
+
getItemKey: (index) => string.toString(computedItems.value[index][props.itemValue]),
|
|
57
|
+
estimateSize: () => {
|
|
58
|
+
return props.itemSize ? props.itemSize : LIST_ITEM_SIZES[props.size];
|
|
59
|
+
},
|
|
60
|
+
overscan: 10
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
const getValue = (index) => {
|
|
65
|
+
var _a;
|
|
66
|
+
return (_a = computedItems.value[index]) == null ? void 0 : _a[props.itemValue];
|
|
67
|
+
};
|
|
68
|
+
const getText = (index) => {
|
|
69
|
+
var _a;
|
|
70
|
+
return (_a = computedItems.value[index]) == null ? void 0 : _a[props.itemText];
|
|
71
|
+
};
|
|
72
|
+
vue.watch(
|
|
73
|
+
() => props.modelValue,
|
|
74
|
+
(nV) => {
|
|
75
|
+
internalValue.value = createInternalValue(
|
|
76
|
+
nV,
|
|
77
|
+
props.valueIsObject,
|
|
78
|
+
props.multiple,
|
|
79
|
+
props.itemValue,
|
|
80
|
+
internalItems.value
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
immediate: true,
|
|
85
|
+
deep: true
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
vue.watch(search, async (nV) => {
|
|
89
|
+
await scrollScrollerToTop();
|
|
90
|
+
await nextFrame();
|
|
91
|
+
if (!navigationSvc) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const firstItem = navigationSvc.getItems().filter((item) => item.style.transform.includes("translateY(0px)"))[0];
|
|
95
|
+
if (nV) {
|
|
96
|
+
navigationSvc.setFocusedItem(firstItem);
|
|
97
|
+
} else {
|
|
98
|
+
if (props.multiple) {
|
|
99
|
+
navigationSvc.setFocusedItem(firstItem);
|
|
100
|
+
} else {
|
|
101
|
+
getActiveItemIndex() > -1 ? scrollToActiveItem() : navigationSvc.clearFocusedState();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
vue.onUnmounted(() => {
|
|
106
|
+
navigationSvc == null ? void 0 : navigationSvc.destroy();
|
|
107
|
+
navigationSvc = null;
|
|
108
|
+
});
|
|
109
|
+
const putSelectedItemsOnTop = () => {
|
|
110
|
+
if (props.selectedTopShown) {
|
|
111
|
+
const arr = internalItems.value.reduce(
|
|
112
|
+
(acc, curr) => {
|
|
113
|
+
internalValue.value.includes(curr[props.itemValue]) ? acc[0].push(curr) : acc[1].push(curr);
|
|
114
|
+
return acc;
|
|
115
|
+
},
|
|
116
|
+
[[], []]
|
|
117
|
+
);
|
|
118
|
+
internalItems.value = arr[0].sort(
|
|
119
|
+
(a, b) => String(a[props.itemText]).localeCompare(String(b[props.itemText]), void 0, {
|
|
120
|
+
numeric: true,
|
|
121
|
+
sensitivity: "base"
|
|
122
|
+
})
|
|
123
|
+
).concat(arr[1]);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const select = async (e, val) => {
|
|
127
|
+
var _a, _b;
|
|
128
|
+
const el = e.currentTarget;
|
|
129
|
+
if (props.multiple && props.searchable && document.activeElement !== ((_a = inputSearch.value) == null ? void 0 : _a.$el.querySelector("input"))) {
|
|
130
|
+
(_b = inputSearch.value) == null ? void 0 : _b.$el.querySelector("input").focus();
|
|
131
|
+
}
|
|
132
|
+
if (props.multiple) {
|
|
133
|
+
if (!isSelected(val)) {
|
|
134
|
+
emit("update:modelValue", toArrOfObjIfNeeded([...internalValue.value, val]));
|
|
135
|
+
} else {
|
|
136
|
+
emit("update:modelValue", toArrOfObjIfNeeded(internalValue.value.filter((item) => item !== val)));
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
emit("update:modelValue", props.valueIsObject ? getItemByValue(val) : val);
|
|
140
|
+
}
|
|
141
|
+
await vue.nextTick();
|
|
142
|
+
navigationSvc == null ? void 0 : navigationSvc.setFocusedItem(el.parentElement);
|
|
143
|
+
emit("select", val);
|
|
144
|
+
};
|
|
145
|
+
const toArrOfObjIfNeeded = (arr) => {
|
|
146
|
+
return props.valueIsObject ? arr.map((val) => getItemByValue(val)) : arr;
|
|
147
|
+
};
|
|
148
|
+
const getItemByValue = (value) => {
|
|
149
|
+
return internalItems.value.find((item) => item[props.itemValue] === value);
|
|
150
|
+
};
|
|
151
|
+
const isSelected = (val) => {
|
|
152
|
+
return internalValue.value.includes(val);
|
|
153
|
+
};
|
|
154
|
+
const setupNavigationSvc = () => {
|
|
155
|
+
if (navigationSvc) {
|
|
156
|
+
navigationSvc.init();
|
|
157
|
+
} else {
|
|
158
|
+
navigationSvc = listKeyboardNavigation.setupListKeyboardNavigation({
|
|
159
|
+
itemContainer: virtualizerRef.value,
|
|
160
|
+
itemSelector: "[p-select-list-option]",
|
|
161
|
+
itemSelectSelector: `[p-select-list-option-item]`,
|
|
162
|
+
itemFocusClass: "bg-p-blue-10"
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const destroyNavigationSvc = () => {
|
|
167
|
+
navigationSvc == null ? void 0 : navigationSvc.destroy();
|
|
168
|
+
navigationSvc = null;
|
|
169
|
+
};
|
|
170
|
+
const onFocus = async () => {
|
|
171
|
+
setupNavigationSvc();
|
|
172
|
+
};
|
|
173
|
+
const onMousemove = () => {
|
|
174
|
+
navigationSvc == null ? void 0 : navigationSvc.clearFocusedState();
|
|
175
|
+
};
|
|
176
|
+
const scrollScrollerToTop = async () => {
|
|
177
|
+
rowVirtualizer.value.scrollToOffset(0);
|
|
178
|
+
await nextFrame();
|
|
179
|
+
};
|
|
180
|
+
const scrollToActiveItem = async (options) => {
|
|
181
|
+
var _a;
|
|
182
|
+
if (options == null ? void 0 : options.wait) {
|
|
183
|
+
await nextLoop(options.wait);
|
|
184
|
+
}
|
|
185
|
+
const activeIndex = getActiveItemIndex();
|
|
186
|
+
if (virtualizerRef.value && rowVirtualizer.value && activeIndex > -1) {
|
|
187
|
+
rowVirtualizer.value.scrollToIndex(activeIndex, {
|
|
188
|
+
align: "center"
|
|
189
|
+
});
|
|
190
|
+
await nextLoop();
|
|
191
|
+
await nextFrame();
|
|
192
|
+
const activeEl = (_a = virtualizerRef.value) == null ? void 0 : _a.querySelector(`.${LIST_ITEM_ACTIVE_CLASS}`);
|
|
193
|
+
navigationSvc == null ? void 0 : navigationSvc.setFocusedItem(activeEl == null ? void 0 : activeEl.parentNode);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const getActiveItemIndex = () => {
|
|
197
|
+
return internalItems.value.indexOf(selectedItems.value[0]);
|
|
198
|
+
};
|
|
199
|
+
const selectAll = () => {
|
|
200
|
+
if (!props.multiple) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const selectedItems2 = internalValue.value;
|
|
204
|
+
const filteredItems = computedItems.value.map((item) => item[props.itemValue]);
|
|
205
|
+
const toEmit = lodashEs.uniqBy([...selectedItems2, ...filteredItems], (item) => item);
|
|
206
|
+
emit("update:modelValue", toArrOfObjIfNeeded(toEmit));
|
|
207
|
+
};
|
|
208
|
+
const clearAll = () => {
|
|
209
|
+
search.value = "";
|
|
210
|
+
emit("update:modelValue", []);
|
|
211
|
+
};
|
|
212
|
+
vue.watch(
|
|
213
|
+
() => props.items,
|
|
214
|
+
(nV) => {
|
|
215
|
+
internalItems.value = createInternalItems(nV);
|
|
216
|
+
if (props.multiple && props.items.length && internalValue.value.length) {
|
|
217
|
+
const internalValueFiltered = internalValue.value.filter((item) => {
|
|
218
|
+
return internalItems.value.some((i) => i[props.itemValue] === item);
|
|
219
|
+
});
|
|
220
|
+
if (internalValueFiltered.length !== internalValue.value.length) {
|
|
221
|
+
console.warn(`[p-select-list] Some values in the modelValue are not in the items list.`);
|
|
222
|
+
emit("update:modelValue", toArrOfObjIfNeeded(internalValueFiltered));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
immediate: true
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
return {
|
|
231
|
+
LIST_ITEM_SIZES,
|
|
232
|
+
LIST_ITEM_CLASS,
|
|
233
|
+
LIST_ITEM_ACTIVE_CLASS,
|
|
234
|
+
selectedItems,
|
|
235
|
+
computedItems,
|
|
236
|
+
computedItemSize,
|
|
237
|
+
computedInsideSelected,
|
|
238
|
+
internalItems,
|
|
239
|
+
internalValue,
|
|
240
|
+
search,
|
|
241
|
+
rowVirtualizer,
|
|
242
|
+
getValue,
|
|
243
|
+
getText,
|
|
244
|
+
isSelected,
|
|
245
|
+
setupNavigationSvc,
|
|
246
|
+
destroyNavigationSvc,
|
|
247
|
+
select,
|
|
248
|
+
onFocus,
|
|
249
|
+
onMousemove,
|
|
250
|
+
scrollToActiveItem,
|
|
251
|
+
putSelectedItemsOnTop,
|
|
252
|
+
selectAll,
|
|
253
|
+
clearAll
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
exports.useSelectList = useSelectList;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createElementBlock, createVNode, createElementVNode, toDisplayString, Fragment, renderList, createBlock, withCtx, resolveDynamicComponent, createCommentVNode } from "vue";
|
|
2
|
+
import PBtn from "../p-btn.js";
|
|
3
|
+
import PCloseBtn from "../p-close-btn.js";
|
|
4
|
+
const _hoisted_1 = {
|
|
5
|
+
class: "fixed bottom-6 left-1/2 flex h-12 -translate-x-1/2 select-none flex-row items-center rounded-lg bg-p-purple-60 px-2 text-sm font-medium text-white",
|
|
6
|
+
role: "alertdialog"
|
|
7
|
+
};
|
|
8
|
+
const _hoisted_2 = { class: "px-3" };
|
|
9
|
+
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", { class: "mx-4 h-9 w-0.5 rounded bg-p-purple-50" }, null, -1);
|
|
10
|
+
const _hoisted_4 = { class: "flex" };
|
|
11
|
+
const _hoisted_5 = { class: "flex items-center gap-2 px-1 py-0.5" };
|
|
12
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
|
+
__name: "p-action-bar",
|
|
14
|
+
props: {
|
|
15
|
+
label: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
actions: {
|
|
20
|
+
type: Array,
|
|
21
|
+
required: true
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
emits: ["click:dismiss", "click:action"],
|
|
25
|
+
setup(__props) {
|
|
26
|
+
return (_ctx, _cache) => {
|
|
27
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
28
|
+
createVNode(PCloseBtn, {
|
|
29
|
+
variant: "dark",
|
|
30
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click:dismiss"))
|
|
31
|
+
}),
|
|
32
|
+
createElementVNode("p", _hoisted_2, toDisplayString(__props.label), 1),
|
|
33
|
+
_hoisted_3,
|
|
34
|
+
createElementVNode("div", _hoisted_4, [
|
|
35
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.actions, (action) => {
|
|
36
|
+
return openBlock(), createBlock(PBtn, {
|
|
37
|
+
key: `action-${action.name}`,
|
|
38
|
+
size: "sm",
|
|
39
|
+
type: "secondary-ghost-dark",
|
|
40
|
+
onClick: ($event) => _ctx.$emit("click:action", action.name)
|
|
41
|
+
}, {
|
|
42
|
+
default: withCtx(() => [
|
|
43
|
+
createElementVNode("div", _hoisted_5, [
|
|
44
|
+
action.icon ? (openBlock(), createBlock(resolveDynamicComponent(action.icon), {
|
|
45
|
+
key: 0,
|
|
46
|
+
class: "h-4 w-4"
|
|
47
|
+
})) : createCommentVNode("", true),
|
|
48
|
+
createElementVNode("div", null, toDisplayString(action.label), 1)
|
|
49
|
+
])
|
|
50
|
+
]),
|
|
51
|
+
_: 2
|
|
52
|
+
}, 1032, ["onClick"]);
|
|
53
|
+
}), 128))
|
|
54
|
+
])
|
|
55
|
+
]);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export {
|
|
60
|
+
_sfc_main as _
|
|
61
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createElementBlock, renderSlot, normalizeClass, toDisplayString, createCommentVNode } from "vue";
|
|
2
|
+
const _hoisted_1 = { class: "border border-p-gray-30 bg-surface px-6 pt-6" };
|
|
3
|
+
const titleClass = "text-xl font-medium leading-none text-p-purple-60";
|
|
4
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
...{ name: "PCard" },
|
|
6
|
+
__name: "p-card",
|
|
7
|
+
props: {
|
|
8
|
+
title: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: ""
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
return (_ctx, _cache) => {
|
|
15
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
16
|
+
renderSlot(_ctx.$slots, "title", { titleClass }, () => [
|
|
17
|
+
__props.title ? (openBlock(), createElementBlock("div", {
|
|
18
|
+
key: 0,
|
|
19
|
+
class: normalizeClass(titleClass)
|
|
20
|
+
}, toDisplayString(__props.title), 1)) : createCommentVNode("", true)
|
|
21
|
+
]),
|
|
22
|
+
renderSlot(_ctx.$slots, "default")
|
|
23
|
+
]);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
_sfc_main as _
|
|
29
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createElementBlock } from "vue";
|
|
2
|
+
const _hoisted_1 = ["checked"];
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
__name: "p-checkbox",
|
|
5
|
+
props: {
|
|
6
|
+
modelValue: {
|
|
7
|
+
type: Boolean,
|
|
8
|
+
default: false
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
emits: ["update:modelValue"],
|
|
12
|
+
setup(__props) {
|
|
13
|
+
return (_ctx, _cache) => {
|
|
14
|
+
return openBlock(), createElementBlock("input", {
|
|
15
|
+
type: "checkbox",
|
|
16
|
+
class: "cursor-pointer accent-p-blue-50",
|
|
17
|
+
checked: __props.modelValue,
|
|
18
|
+
onChange: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:modelValue", $event.target.checked))
|
|
19
|
+
}, null, 40, _hoisted_1);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
_sfc_main as _
|
|
25
|
+
};
|