@milaboratories/uikit 2.4.28 → 2.4.30
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/.turbo/turbo-build.log +41 -42
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +14 -0
- package/dist/assets/images/required.svg.js +7 -0
- package/dist/assets/images/required.svg.js.map +1 -0
- package/dist/components/DataTable/TableComponent.vue.js +16 -19
- package/dist/components/DataTable/TableComponent.vue.js.map +1 -1
- package/dist/components/PlAccordion/{ExpandTransition.vue2.js → ExpandTransition.vue.js} +1 -1
- package/dist/components/PlAccordion/ExpandTransition.vue.js.map +1 -0
- package/dist/components/PlAccordion/ExpandTransition.vue3.js +1 -1
- package/dist/components/PlAccordion/PlAccordionSection.vue2.js +1 -1
- package/dist/components/PlAutocomplete/PlAutocomplete.vue.js +67 -60
- package/dist/components/PlAutocomplete/PlAutocomplete.vue.js.map +1 -1
- package/dist/components/PlAutocompleteMulti/PlAutocompleteMulti.vue.js +76 -72
- package/dist/components/PlAutocompleteMulti/PlAutocompleteMulti.vue.js.map +1 -1
- package/dist/components/PlDropdown/PlDropdown.vue.js +65 -61
- package/dist/components/PlDropdown/PlDropdown.vue.js.map +1 -1
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue.js +27 -23
- package/dist/components/PlDropdownLegacy/PlDropdownLegacy.vue.js.map +1 -1
- package/dist/components/PlDropdownMulti/PlDropdownMulti.vue.js +65 -61
- package/dist/components/PlDropdownMulti/PlDropdownMulti.vue.js.map +1 -1
- package/dist/components/PlFileInput/PlFileInput.vue.js +47 -43
- package/dist/components/PlFileInput/PlFileInput.vue.js.map +1 -1
- package/dist/components/PlSlideModal/PlPureSlideModal.vue.js +3 -6
- package/dist/components/PlSlideModal/PlPureSlideModal.vue.js.map +1 -1
- package/dist/components/PlTextArea/PlTextArea.vue.js +43 -39
- package/dist/components/PlTextArea/PlTextArea.vue.js.map +1 -1
- package/dist/components/PlTextField/PlTextField.vue.js +41 -37
- package/dist/components/PlTextField/PlTextField.vue.js.map +1 -1
- package/package.json +4 -4
- package/src/components/PlAutocomplete/PlAutocomplete.vue +4 -3
- package/src/components/PlAutocompleteMulti/PlAutocompleteMulti.vue +14 -11
- package/src/components/PlDropdown/PlDropdown.vue +10 -9
- package/src/components/PlDropdownLegacy/PlDropdownLegacy.vue +3 -2
- package/src/components/PlDropdownMulti/PlDropdownMulti.vue +11 -10
- package/src/components/PlFileInput/PlFileInput.vue +6 -3
- package/src/components/PlTextArea/PlTextArea.vue +3 -2
- package/src/components/PlTextField/PlTextField.vue +7 -6
- package/dist/components/PlAccordion/ExpandTransition.vue2.js.map +0 -1
- package/dist/generated/components/svg/images/SvgRequired.vue.d.ts +0 -2
- package/dist/generated/components/svg/images/SvgRequired.vue.js +0 -17
- package/dist/generated/components/svg/images/SvgRequired.vue.js.map +0 -1
- package/dist/generated/components/svg/images/SvgRequired.vue3.js +0 -6
- package/dist/generated/components/svg/images/SvgRequired.vue3.js.map +0 -1
- package/scripts/create-svg-components.js +0 -125
- package/src/generated/components/svg/images/Svg16Add.vue +0 -13
- package/src/generated/components/svg/images/Svg16Attention.vue +0 -13
- package/src/generated/components/svg/images/Svg16Checkmark.vue +0 -13
- package/src/generated/components/svg/images/Svg16CheckmarkDark.vue +0 -13
- package/src/generated/components/svg/images/Svg16ChevronDown.vue +0 -13
- package/src/generated/components/svg/images/Svg16ChevronLeft.vue +0 -13
- package/src/generated/components/svg/images/Svg16ChevronRight.vue +0 -13
- package/src/generated/components/svg/images/Svg16ChevronUp.vue +0 -13
- package/src/generated/components/svg/images/Svg16Clear.vue +0 -13
- package/src/generated/components/svg/images/Svg16Clipboard.vue +0 -13
- package/src/generated/components/svg/images/Svg16Close.vue +0 -13
- package/src/generated/components/svg/images/Svg16Compare.vue +0 -13
- package/src/generated/components/svg/images/Svg16Down.vue +0 -13
- package/src/generated/components/svg/images/Svg16Import.vue +0 -13
- package/src/generated/components/svg/images/Svg16Info.vue +0 -13
- package/src/generated/components/svg/images/Svg16InfoDark.vue +0 -13
- package/src/generated/components/svg/images/Svg16Link.vue +0 -13
- package/src/generated/components/svg/images/Svg16Loading.vue +0 -13
- package/src/generated/components/svg/images/Svg16Maximise.vue +0 -13
- package/src/generated/components/svg/images/Svg16Play.vue +0 -13
- package/src/generated/components/svg/images/Svg16Up.vue +0 -13
- package/src/generated/components/svg/images/Svg24ArrowRight.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxDarkDisabledChecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxDarkDisabledIndeterminate.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxDarkDisabledUnchecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxDarkEnabledChecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxDarkEnabledIndeterminate.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxDarkEnabledUnchecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxLightDisabledChecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxLightDisabledIndeterminate.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxLightDisabledUnchecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxLightEnabledChecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxLightEnabledIndeterminate.vue +0 -13
- package/src/generated/components/svg/images/Svg24CheckboxLightEnabledUnchecked.vue +0 -13
- package/src/generated/components/svg/images/Svg24Clips.vue +0 -13
- package/src/generated/components/svg/images/Svg24Close.vue +0 -13
- package/src/generated/components/svg/images/Svg24Code.vue +0 -13
- package/src/generated/components/svg/images/Svg24Columns.vue +0 -13
- package/src/generated/components/svg/images/Svg24DarkMode.vue +0 -13
- package/src/generated/components/svg/images/Svg24Filters.vue +0 -13
- package/src/generated/components/svg/images/Svg24LightMode.vue +0 -13
- package/src/generated/components/svg/images/Svg24Local.vue +0 -13
- package/src/generated/components/svg/images/Svg24PaperClip.vue +0 -13
- package/src/generated/components/svg/images/Svg24Search.vue +0 -13
- package/src/generated/components/svg/images/Svg24ServerOn.vue +0 -13
- package/src/generated/components/svg/images/Svg24Settings2.vue +0 -13
- package/src/generated/components/svg/images/SvgAddGraphBg.vue +0 -13
- package/src/generated/components/svg/images/SvgColorSliderThumbBig.vue +0 -13
- package/src/generated/components/svg/images/SvgColorSliderThumbSmall.vue +0 -13
- package/src/generated/components/svg/images/SvgEmptyCat.vue +0 -13
- package/src/generated/components/svg/images/SvgNoDataCat.vue +0 -13
- package/src/generated/components/svg/images/SvgRequired.vue +0 -13
- package/src/generated/components/svg/svg-styles.css +0 -5
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(`.pl-dropdown-multi{--contour-color: var(--txt-01);--contour-border-width: 1px;--options-bg: #fff;--option-hover-bg: var(--btn-sec-hover-grey);--label-offset-left-x: 8px;--label-offset-right-x: 8px;--label-color: var(--txt-01);position:relative;outline:none;min-height:var(--control-height);border-radius:6px;font-family:var(--font-family-base);font-size:var(--font-size-base);font-weight:var(--font-weigh-base)}[data-theme=dark] .pl-dropdown-multi{--options-bg: #1B1B1F}.pl-dropdown-multi__envelope{font-family:var(--control-font-family);min-width:160px}.pl-dropdown-multi label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-dropdown-multi label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-dropdown-multi__container{position:absolute;top:0;left:0;right:0;border-radius:6px;min-height:var(--control-height);padding:1px;color:var(--txt-01)}.pl-dropdown-multi__contour{border-radius:var(--border-radius-control);border:var(--contour-border-width) solid var(--contour-color);box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-dropdown-multi__options{position:absolute;z-index:var(--z-dropdown-options);border:1px solid var(--border-color-div-grey);background-color:var(--pl-dropdown-options-bg);border-radius:6px;max-height:244px;box-shadow:0 4px 12px -2px #0f244d14,0 6px 24px -2px #0f244d14;--thumb-color: var(--ic-02);overflow-y:auto}.pl-dropdown-multi__options::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-dropdown-multi__options::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-dropdown-multi__options::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-dropdown-multi__options .nothing-found{padding:0 10px;height:var(--control-height);line-height:20px;background-color:#fff;opacity:.5;font-style:italic}.pl-dropdown-multi__field{position:relative;border-radius:6px;overflow:hidden;background:transparent;padding-left:11px;min-height:var(--control-height);line-height:20px;cursor:pointer;display:flex;flex-direction:row;align-items:center}.pl-dropdown-multi__field .chips-container{position:absolute;top:0;left:0;bottom:0;right:30px;overflow:hidden;padding:0 60px 0 11px;line-height:20px;color:var(--contour-color);display:flex;gap:8px;align-items:center}.pl-dropdown-multi__field input{min-height:calc(var(--control-height) - 2px);line-height:20px;font-family:inherit;font-size:inherit;background-color:transparent;border:none;padding:0;width:calc(100% - 20px);color:var(--txt-01);caret-color:var(--border-color-focus)}.pl-dropdown-multi__field input:focus{outline:none}.pl-dropdown-multi__field input:placeholder-shown{text-overflow:ellipsis}.pl-dropdown-multi__field input::placeholder{color:var(--color-placeholder)}.pl-dropdown-multi__field:hover .clear{display:block}.pl-dropdown-multi__controls{display:flex;flex-direction:row;align-items:center;gap:6px;margin-left:auto}.pl-dropdown-multi__controls .mask-16,.pl-dropdown-multi__controls .mask-24{--icon-color: var(--control-mask-fill);cursor:pointer}.pl-dropdown-multi__controls .mask-loading{--icon-color: var(--ic-accent);animation:spin 2.5s linear infinite}.pl-dropdown-multi__arrow-wrapper{display:flex;align-items:center;min-height:var(--control-height);padding-right:11px}.pl-dropdown-multi .arrow-icon{cursor:pointer}.pl-dropdown-multi .arrow-icon.arrow-icon-default{transition:transform .2s;background-color:var(--control-mask-fill);mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.46967%206.53033L3.53033%205.46967L8%209.93934L12.4697%205.46967L13.5303%206.53033L8%2012.0607L2.46967%206.53033Z'%20fill='%23110529'/%3e%3c/svg%3e");-webkit-mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.46967%206.53033L3.53033%205.46967L8%209.93934L12.4697%205.46967L13.5303%206.53033L8%2012.0607L2.46967%206.53033Z'%20fill='%23110529'/%3e%3c/svg%3e");mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;mask-position:center;-webkit-mask-position:center;mask-size:16px;-webkit-mask-size:16px;width:16px;height:16px}.pl-dropdown-multi__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-dropdown-multi__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-dropdown-multi.open .arrow-icon.arrow-icon-default{background-color:var(--control-mask-fill);transform:rotate(-180deg)}.pl-dropdown-multi .clear{display:none;position:absolute;top:50%;transform:translateY(-50%);right:36px;z-index:1;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_586_7851)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8%2016C12.4183%2016%2016%2012.4183%2016%208C16%203.58172%2012.4183%200%208%200C3.58172%200%200%203.58172%200%208C0%2012.4183%203.58172%2016%208%2016ZM4.46967%205.53033L6.93934%208L4.46967%2010.4697L5.53033%2011.5303L8%209.06066L10.4697%2011.5303L11.5303%2010.4697L9.06066%208L11.5303%205.53033L10.4697%204.46967L8%206.93934L5.53033%204.46967L4.46967%205.53033Z'%20fill='%23CFD1DB'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_586_7851'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e") no-repeat center;width:16px;height:16px;cursor:pointer}.pl-dropdown-multi.open,.pl-dropdown-multi:focus-within{z-index:1}.pl-dropdown-multi.open .pl-dropdown-multi__container .label,.pl-dropdown-multi:focus-within .pl-dropdown-multi__container .label{color:var(--txt-focus)}.pl-dropdown-multi.open .pl-dropdown-multi__container{z-index:1000}.pl-dropdown-multi.open .pl-dropdown-multi__field{border-radius:6px 6px 0 0}.pl-dropdown-multi.open .arrow{background-color:var(--control-mask-fill);mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8%204.93933L13.5303%2010.4697L12.4697%2011.5303L8%207.06065L3.53033%2011.5303L2.46967%2010.4697L8%204.93933Z'%20fill='%23110529'/%3e%3c/svg%3e");-webkit-mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8%204.93933L13.5303%2010.4697L12.4697%2011.5303L8%207.06065L3.53033%2011.5303L2.46967%2010.4697L8%204.93933Z'%20fill='%23110529'/%3e%3c/svg%3e");mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;mask-position:center;-webkit-mask-position:center;mask-size:16px;-webkit-mask-size:16px;width:16px;height:16px}.pl-dropdown-multi:hover{--contour-color: var(--control-hover-color)}.pl-dropdown-multi:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-dropdown-multi:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-dropdown-multi.error{--contour-color: var(--txt-error);--label-color: var(--txt-error)}.pl-dropdown-multi.disabled{--contour-color: var(--color-dis-01);--control-mask-fill: var(--color-dis-01);--label-color: var(--color-dis-01);cursor:not-allowed;pointer-events:none}.pl-dropdown-multi.disabled .mask-loading{animation:spin 2.5s linear infinite;--icon-color: var(--ic-accent)}.pl-dropdown-multi__open-chips-container{padding:12px}.pl-dropdown-multi__open-chips-container .pl-chip{margin-right:4px;margin-bottom:4px}`)),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
-
import { defineComponent as X, useSlots as Y, ref as q, useTemplateRef as Z, reactive as ee, computed as p, unref as s, watch as oe, watchPostEffect as te, createElementBlock as
|
|
3
|
-
|
|
4
|
-
import ae from "
|
|
2
|
+
import { defineComponent as X, useSlots as Y, ref as q, useTemplateRef as Z, reactive as ee, computed as p, unref as s, watch as oe, watchPostEffect as te, createElementBlock as u, openBlock as r, createElementVNode as d, createCommentVNode as f, normalizeClass as le, createBlock as m, createVNode as ne, withDirectives as re, vModelText as se, Fragment as b, renderList as g, withModifiers as C, withCtx as w, createTextVNode as B, toDisplayString as v, renderSlot as I } from "vue";
|
|
3
|
+
import ie from "../../assets/images/required.svg.js";
|
|
4
|
+
import { getErrorMessage as ae } from "../../helpers/error.js";
|
|
5
|
+
import { deepEqual as O, deepIncludes as S } from "../../helpers/objects.js";
|
|
6
|
+
import { normalizeListOptions as ue } from "../../helpers/utils.js";
|
|
7
|
+
import de from "../../utils/DoubleContour.vue.js";
|
|
8
|
+
import ce from "../../utils/DropdownOverlay/DropdownOverlay.vue.js";
|
|
9
|
+
import { useLabelNotch as pe } from "../../utils/useLabelNotch.js";
|
|
10
|
+
import fe from "../DropdownListItem.vue.js";
|
|
5
11
|
import T from "../PlChip/PlChip.vue.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import pe from "../../utils/DropdownOverlay/DropdownOverlay.vue.js";
|
|
12
|
-
import fe from "../PlIcon24/PlIcon24.vue.js";
|
|
13
|
-
import me from "../../generated/components/svg/images/SvgRequired.vue.js";
|
|
14
|
-
import { getErrorMessage as ve } from "../../helpers/error.js";
|
|
15
|
-
const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = { class: "pl-dropdown-multi__field" }, ye = ["disabled", "placeholder"], ke = {
|
|
12
|
+
import me from "../PlIcon24/PlIcon24.vue.js";
|
|
13
|
+
import ve from "../PlSvg/PlSvg.vue.js";
|
|
14
|
+
import he from "../PlTooltip/PlTooltip.vue.js";
|
|
15
|
+
|
|
16
|
+
const _e = ["tabindex"], we = { class: "pl-dropdown-multi__container" }, ye = { class: "pl-dropdown-multi__field" }, ke = ["disabled", "placeholder"], be = {
|
|
16
17
|
key: 0,
|
|
17
18
|
class: "chips-container"
|
|
18
|
-
},
|
|
19
|
+
}, ge = { class: "pl-dropdown-multi__controls" }, Ce = { key: 0 }, Oe = { class: "pl-dropdown-multi__open-chips-container" }, Ve = {
|
|
19
20
|
key: 0,
|
|
20
21
|
class: "nothing-found"
|
|
21
|
-
},
|
|
22
|
+
}, $e = {
|
|
22
23
|
key: 0,
|
|
23
24
|
class: "pl-dropdown-multi__error"
|
|
24
|
-
},
|
|
25
|
+
}, Ae = {
|
|
25
26
|
key: 1,
|
|
26
27
|
class: "pl-dropdown-multi__helper"
|
|
27
|
-
},
|
|
28
|
+
}, Ee = {
|
|
28
29
|
name: "PlDropdownMulti"
|
|
29
|
-
},
|
|
30
|
-
...
|
|
30
|
+
}, Ue = /* @__PURE__ */ X({
|
|
31
|
+
...Ee,
|
|
31
32
|
props: {
|
|
32
33
|
modelValue: { default: () => [] },
|
|
33
34
|
label: { default: void 0 },
|
|
@@ -39,36 +40,36 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
39
40
|
disabled: { type: Boolean, default: !1 }
|
|
40
41
|
},
|
|
41
42
|
emits: ["update:modelValue"],
|
|
42
|
-
setup(
|
|
43
|
-
const
|
|
43
|
+
setup(z, { emit: P }) {
|
|
44
|
+
const x = P, V = (e) => x("update:modelValue", e), U = Y(), i = z, c = q(), $ = q(), h = Z("overlay"), t = ee({
|
|
44
45
|
search: "",
|
|
45
46
|
activeOption: -1,
|
|
46
47
|
open: !1,
|
|
47
48
|
optionsHeight: 0
|
|
48
|
-
}), _ = p(() => Array.isArray(
|
|
49
|
+
}), _ = p(() => Array.isArray(i.modelValue) ? i.modelValue : []), K = p(() => t.open && i.modelValue.length > 0 ? i.placeholder : i.modelValue.length > 0 ? "" : i.placeholder), A = p(() => ue(i.options ?? [])), E = p(() => _.value.map((e) => A.value.find((l) => O(l.value, e))).filter((e) => e !== void 0)), y = p(() => {
|
|
49
50
|
const e = s(_), l = s(A);
|
|
50
51
|
return (t.search ? l.filter((o) => {
|
|
51
52
|
const n = t.search.toLowerCase();
|
|
52
53
|
return o.label.toLowerCase().includes(n) ? !0 : typeof o.value == "string" ? o.value.toLowerCase().includes(n) : o.value === t.search;
|
|
53
54
|
}) : [...l]).map((o) => ({
|
|
54
55
|
...o,
|
|
55
|
-
selected:
|
|
56
|
+
selected: S(e, o.value)
|
|
56
57
|
}));
|
|
57
|
-
}), D = p(() =>
|
|
58
|
+
}), D = p(() => i.options === void 0), k = p(() => D.value ? !0 : i.disabled), H = p(() => k.value ? void 0 : "0"), j = () => {
|
|
58
59
|
t.activeOption = 0;
|
|
59
60
|
}, M = (e) => {
|
|
60
61
|
var o;
|
|
61
62
|
const l = s(_);
|
|
62
|
-
V(
|
|
63
|
+
V(S(l, e) ? l.filter((n) => !O(n, e)) : [...l, e]), t.search = "", (o = c == null ? void 0 : c.value) == null || o.focus();
|
|
63
64
|
}, R = (e) => V(s(_).filter((l) => !O(l, e))), G = () => {
|
|
64
65
|
var e;
|
|
65
66
|
return (e = $.value) == null ? void 0 : e.focus();
|
|
66
67
|
}, J = () => {
|
|
67
68
|
t.open = !t.open, t.open || (t.search = "");
|
|
68
69
|
}, F = (e) => {
|
|
69
|
-
var o, n,
|
|
70
|
+
var o, n, a;
|
|
70
71
|
const l = e.relatedTarget;
|
|
71
|
-
!((o = c.value) != null && o.contains(l)) && !((
|
|
72
|
+
!((o = c.value) != null && o.contains(l)) && !((a = (n = h.value) == null ? void 0 : n.listRef) != null && a.contains(l)) && (t.search = "", t.open = !1);
|
|
72
73
|
}, Q = (e) => {
|
|
73
74
|
var L;
|
|
74
75
|
const { open: l, activeOption: o } = t;
|
|
@@ -77,28 +78,28 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
e.code === "Escape" && (t.open = !1, (L = c.value) == null || L.focus());
|
|
80
|
-
const n = s(y), { length:
|
|
81
|
-
if (!
|
|
81
|
+
const n = s(y), { length: a } = n;
|
|
82
|
+
if (!a)
|
|
82
83
|
return;
|
|
83
84
|
["ArrowDown", "ArrowUp", "Enter"].includes(e.code) && e.preventDefault(), e.code === "Enter" && M(n[o].value);
|
|
84
85
|
const W = e.code === "ArrowDown" ? 1 : e.code === "ArrowUp" ? -1 : 0;
|
|
85
|
-
t.activeOption = Math.abs(o + W +
|
|
86
|
+
t.activeOption = Math.abs(o + W + a) % a, requestAnimationFrame(() => {
|
|
86
87
|
var N;
|
|
87
88
|
return (N = h.value) == null ? void 0 : N.scrollIntoActive();
|
|
88
89
|
});
|
|
89
90
|
};
|
|
90
|
-
return
|
|
91
|
-
() =>
|
|
91
|
+
return pe(c), oe(
|
|
92
|
+
() => i.modelValue,
|
|
92
93
|
() => j(),
|
|
93
94
|
{ immediate: !0 }
|
|
94
95
|
), te(() => {
|
|
95
96
|
var e;
|
|
96
97
|
t.search, t.open && ((e = h.value) == null || e.scrollIntoActive());
|
|
97
|
-
}), (e, l) => (r(),
|
|
98
|
+
}), (e, l) => (r(), u("div", {
|
|
98
99
|
class: "pl-dropdown-multi__envelope",
|
|
99
100
|
onClick: G
|
|
100
101
|
}, [
|
|
101
|
-
|
|
102
|
+
d("div", {
|
|
102
103
|
ref_key: "rootRef",
|
|
103
104
|
ref: c,
|
|
104
105
|
tabindex: H.value,
|
|
@@ -106,9 +107,9 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
106
107
|
onKeydown: Q,
|
|
107
108
|
onFocusout: F
|
|
108
109
|
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
re(
|
|
110
|
+
d("div", we, [
|
|
111
|
+
d("div", ye, [
|
|
112
|
+
re(d("input", {
|
|
112
113
|
ref_key: "input",
|
|
113
114
|
ref: $,
|
|
114
115
|
"onUpdate:modelValue": l[0] || (l[0] = (o) => t.search = o),
|
|
@@ -119,16 +120,16 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
119
120
|
spellcheck: "false",
|
|
120
121
|
autocomplete: "chrome-off",
|
|
121
122
|
onFocus: l[1] || (l[1] = (o) => t.open = !0)
|
|
122
|
-
}, null, 40,
|
|
123
|
+
}, null, 40, ke), [
|
|
123
124
|
[se, t.search]
|
|
124
125
|
]),
|
|
125
|
-
t.open ? f("", !0) : (r(),
|
|
126
|
-
(r(!0),
|
|
126
|
+
t.open ? f("", !0) : (r(), u("div", be, [
|
|
127
|
+
(r(!0), u(b, null, g(E.value, (o, n) => (r(), m(s(T), {
|
|
127
128
|
key: n,
|
|
128
129
|
closeable: "",
|
|
129
130
|
small: "",
|
|
130
|
-
onClick: l[2] || (l[2] = C((
|
|
131
|
-
onClose: (
|
|
131
|
+
onClick: l[2] || (l[2] = C((a) => t.open = !0, ["stop"])),
|
|
132
|
+
onClose: (a) => R(o.value)
|
|
132
133
|
}, {
|
|
133
134
|
default: w(() => [
|
|
134
135
|
B(v(o.label || o.value), 1)
|
|
@@ -136,24 +137,27 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
136
137
|
_: 2
|
|
137
138
|
}, 1032, ["onClose"]))), 128))
|
|
138
139
|
])),
|
|
139
|
-
|
|
140
|
-
D.value ? (r(), m(s(
|
|
140
|
+
d("div", ge, [
|
|
141
|
+
D.value ? (r(), m(s(me), {
|
|
141
142
|
key: 0,
|
|
142
143
|
name: "loading"
|
|
143
144
|
})) : f("", !0),
|
|
144
145
|
I(e.$slots, "append"),
|
|
145
|
-
|
|
146
|
+
d("div", {
|
|
146
147
|
class: "pl-dropdown-multi__arrow-wrapper",
|
|
147
148
|
onClick: C(J, ["stop"])
|
|
148
149
|
}, l[3] || (l[3] = [
|
|
149
|
-
|
|
150
|
+
d("div", { class: "arrow-icon arrow-icon-default" }, null, -1)
|
|
150
151
|
]))
|
|
151
152
|
])
|
|
152
153
|
]),
|
|
153
|
-
e.label ? (r(),
|
|
154
|
-
e.required ? (r(), m(
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
e.label ? (r(), u("label", Ce, [
|
|
155
|
+
e.required ? (r(), m(s(ve), {
|
|
156
|
+
key: 0,
|
|
157
|
+
uri: s(ie)
|
|
158
|
+
}, null, 8, ["uri"])) : f("", !0),
|
|
159
|
+
d("span", null, v(e.label), 1),
|
|
160
|
+
s(U).tooltip ? (r(), m(s(he), {
|
|
157
161
|
key: 1,
|
|
158
162
|
class: "info",
|
|
159
163
|
position: "top"
|
|
@@ -164,7 +168,7 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
164
168
|
_: 3
|
|
165
169
|
})) : f("", !0)
|
|
166
170
|
])) : f("", !0),
|
|
167
|
-
t.open ? (r(), m(
|
|
171
|
+
t.open ? (r(), m(ce, {
|
|
168
172
|
key: 1,
|
|
169
173
|
ref_key: "overlay",
|
|
170
174
|
ref: h,
|
|
@@ -175,12 +179,12 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
175
179
|
onFocusout: F
|
|
176
180
|
}, {
|
|
177
181
|
default: w(() => [
|
|
178
|
-
|
|
179
|
-
(r(!0),
|
|
182
|
+
d("div", Oe, [
|
|
183
|
+
(r(!0), u(b, null, g(E.value, (o, n) => (r(), m(s(T), {
|
|
180
184
|
key: n,
|
|
181
185
|
closeable: "",
|
|
182
186
|
small: "",
|
|
183
|
-
onClose: (
|
|
187
|
+
onClose: (a) => R(o.value)
|
|
184
188
|
}, {
|
|
185
189
|
default: w(() => [
|
|
186
190
|
B(v(o.label || o.value), 1)
|
|
@@ -188,7 +192,7 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
188
192
|
_: 2
|
|
189
193
|
}, 1032, ["onClose"]))), 128))
|
|
190
194
|
]),
|
|
191
|
-
(r(!0),
|
|
195
|
+
(r(!0), u(b, null, g(y.value, (o, n) => (r(), m(fe, {
|
|
192
196
|
key: n,
|
|
193
197
|
option: o,
|
|
194
198
|
"text-item": "text",
|
|
@@ -196,20 +200,20 @@ const he = ["tabindex"], _e = { class: "pl-dropdown-multi__container" }, we = {
|
|
|
196
200
|
"is-hovered": t.activeOption == n,
|
|
197
201
|
size: "medium",
|
|
198
202
|
"use-checkbox": "",
|
|
199
|
-
onClick: C((
|
|
203
|
+
onClick: C((a) => M(o.value), ["stop"])
|
|
200
204
|
}, null, 8, ["option", "is-selected", "is-hovered", "onClick"]))), 128)),
|
|
201
|
-
y.value.length ? f("", !0) : (r(),
|
|
205
|
+
y.value.length ? f("", !0) : (r(), u("div", Ve, "Nothing found"))
|
|
202
206
|
]),
|
|
203
207
|
_: 1
|
|
204
208
|
}, 8, ["root"])) : f("", !0),
|
|
205
|
-
ne(
|
|
209
|
+
ne(de, { class: "pl-dropdown-multi__contour" })
|
|
206
210
|
])
|
|
207
|
-
], 42,
|
|
208
|
-
e.error ? (r(),
|
|
211
|
+
], 42, _e),
|
|
212
|
+
e.error ? (r(), u("div", $e, v(s(ae)(e.error)), 1)) : e.helper ? (r(), u("div", Ae, v(e.helper), 1)) : f("", !0)
|
|
209
213
|
]));
|
|
210
214
|
}
|
|
211
215
|
});
|
|
212
216
|
export {
|
|
213
|
-
|
|
217
|
+
Ue as default
|
|
214
218
|
};
|
|
215
219
|
//# sourceMappingURL=PlDropdownMulti.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlDropdownMulti.vue.js","sources":["../../../src/components/PlDropdownMulti/PlDropdownMulti.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting multiple values from a list of options\n */\nexport default {\n name: 'PlDropdownMulti',\n};\n</script>\n\n<script lang=\"ts\" setup generic=\"M = unknown\">\nimport './pl-dropdown-multi.scss';\nimport { computed, reactive, ref, unref, useSlots, useTemplateRef, watch, watchPostEffect } from 'vue';\nimport { PlTooltip } from '../PlTooltip';\nimport { PlChip } from '../PlChip';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport type { ListOption } from '../../types';\nimport DropdownListItem from '../DropdownListItem.vue';\nimport { deepEqual, deepIncludes } from '../../helpers/objects';\nimport { normalizeListOptions } from '../../helpers/utils';\nimport DropdownOverlay from '../../utils/DropdownOverlay/DropdownOverlay.vue';\nimport { PlMaskIcon24 } from '../PlMaskIcon24';\nimport SvgRequired from '../../generated/components/svg/images/SvgRequired.vue';\nimport { getErrorMessage } from '../../helpers/error.ts';\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', v: M[]): void;\n}>();\n\nconst emitModel = (v: M[]) => emit('update:modelValue', v);\n\nconst slots = useSlots();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected values.\n */\n modelValue: M[];\n /**\n * The label text for the dropdown field (optional)\n */\n label?: string;\n /**\n * List of available options for the dropdown\n */\n options?: Readonly<ListOption<M>[]>;\n /**\n * A helper text displayed below the dropdown when there are no errors (optional).\n */\n helper?: string;\n /**\n * Error message displayed below the dropdown (optional)\n */\n error?: unknown;\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n /**\n * If `true`, the dropdown component is marked as required.\n */\n required?: boolean;\n /**\n * If `true`, the dropdown component is disabled and cannot be interacted with.\n */\n disabled?: boolean;\n }>(),\n {\n modelValue: () => [],\n label: undefined,\n helper: undefined,\n error: undefined,\n placeholder: '...',\n required: false,\n disabled: false,\n options: undefined,\n },\n);\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst input = ref<HTMLInputElement | undefined>();\n\nconst overlay = useTemplateRef('overlay');\n\nconst data = reactive({\n search: '',\n activeOption: -1,\n open: false,\n optionsHeight: 0,\n});\n\nconst selectedValuesRef = computed(() => (Array.isArray(props.modelValue) ? props.modelValue : []));\n\nconst placeholderRef = computed(() => {\n if (data.open && props.modelValue.length > 0) {\n return props.placeholder;\n }\n\n return props.modelValue.length > 0 ? '' : props.placeholder;\n});\n\nconst normalizedOptionsRef = computed(() => normalizeListOptions(props.options ?? []));\n\nconst selectedOptionsRef = computed(() => {\n return selectedValuesRef.value.map((v) => normalizedOptionsRef.value.find((opt) => deepEqual(opt.value, v))).filter((v) => v !== undefined);\n});\n\nconst filteredOptionsRef = computed(() => {\n const selectedValues = unref(selectedValuesRef);\n\n const options = unref(normalizedOptionsRef);\n\n return (\n data.search\n ? options.filter((opt) => {\n const search = data.search.toLowerCase();\n\n if (opt.label.toLowerCase().includes(search)) {\n return true;\n }\n\n if (typeof opt.value === 'string') {\n return opt.value.toLowerCase().includes(search);\n }\n\n return opt.value === data.search;\n })\n : [...options]\n ).map((opt) => ({\n ...opt,\n selected: deepIncludes(selectedValues, opt.value),\n }));\n});\n\nconst isLoadingOptions = computed(() => {\n return props.options === undefined;\n});\n\nconst isDisabled = computed(() => {\n if (isLoadingOptions.value) {\n return true;\n }\n\n return props.disabled;\n});\n\nconst tabindex = computed(() => (isDisabled.value ? undefined : '0'));\n\nconst updateActiveOption = () => {\n data.activeOption = 0;\n};\n\nconst selectOption = (v: M) => {\n const values = unref(selectedValuesRef);\n emitModel(deepIncludes(values, v) ? values.filter((it) => !deepEqual(it, v)) : [...values, v]);\n data.search = '';\n rootRef?.value?.focus();\n};\n\nconst unselectOption = (d: M) => emitModel(unref(selectedValuesRef).filter((v) => !deepEqual(v, d)));\n\nconst setFocusOnInput = () => input.value?.focus();\n\nconst toggleModel = () => {\n data.open = !data.open;\n if (!data.open) {\n data.search = '';\n }\n};\n\nconst onFocusOut = (event: FocusEvent) => {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!rootRef.value?.contains(relatedTarget) && !overlay.value?.listRef?.contains(relatedTarget)) {\n data.search = '';\n data.open = false;\n }\n};\n\nconst handleKeydown = (e: { code: string; preventDefault(): void }) => {\n const { open, activeOption } = data;\n\n if (!open) {\n if (e.code === 'Enter') {\n data.open = true;\n }\n return;\n }\n\n if (e.code === 'Escape') {\n data.open = false;\n rootRef.value?.focus();\n }\n\n const filteredOptions = unref(filteredOptionsRef);\n\n const { length } = filteredOptions;\n\n if (!length) {\n return;\n }\n\n if (['ArrowDown', 'ArrowUp', 'Enter'].includes(e.code)) {\n e.preventDefault();\n }\n\n if (e.code === 'Enter') {\n selectOption(filteredOptions[activeOption].value);\n }\n\n const d = e.code === 'ArrowDown' ? 1 : e.code === 'ArrowUp' ? -1 : 0;\n\n data.activeOption = Math.abs(activeOption + d + length) % length;\n\n requestAnimationFrame(() => overlay.value?.scrollIntoActive());\n};\n\nuseLabelNotch(rootRef);\n\nwatch(\n () => props.modelValue,\n () => updateActiveOption(),\n { immediate: true },\n);\n\nwatchPostEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n data.search;\n\n if (data.open) {\n overlay.value?.scrollIntoActive();\n }\n});\n</script>\n\n<template>\n <div class=\"pl-dropdown-multi__envelope\" @click=\"setFocusOnInput\">\n <div\n ref=\"rootRef\"\n :tabindex=\"tabindex\"\n class=\"pl-dropdown-multi\"\n :class=\"{ open: data.open, error, disabled: isDisabled }\"\n @keydown=\"handleKeydown\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown-multi__container\">\n <div class=\"pl-dropdown-multi__field\">\n <input\n ref=\"input\"\n v-model=\"data.search\"\n type=\"text\"\n tabindex=\"-1\"\n :disabled=\"isDisabled\"\n :placeholder=\"placeholderRef\"\n spellcheck=\"false\"\n autocomplete=\"chrome-off\"\n @focus=\"data.open = true\"\n />\n <div v-if=\"!data.open\" class=\"chips-container\">\n <PlChip v-for=\"(opt, i) in selectedOptionsRef\" :key=\"i\" closeable small @click.stop=\"data.open = true\" @close=\"unselectOption(opt.value)\">\n {{ opt.label || opt.value }}\n </PlChip>\n </div>\n\n <div class=\"pl-dropdown-multi__controls\">\n <PlMaskIcon24 v-if=\"isLoadingOptions\" name=\"loading\" />\n <slot name=\"append\" />\n <div class=\"pl-dropdown-multi__arrow-wrapper\" @click.stop=\"toggleModel\">\n <div class=\"arrow-icon arrow-icon-default\" />\n </div>\n </div>\n </div>\n <label v-if=\"label\">\n <SvgRequired v-if=\"required\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <DropdownOverlay\n v-if=\"data.open\"\n ref=\"overlay\"\n :root=\"rootRef\"\n class=\"pl-dropdown-multi__options\"\n :gap=\"5\"\n tabindex=\"-1\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown-multi__open-chips-container\">\n <PlChip v-for=\"(opt, i) in selectedOptionsRef\" :key=\"i\" closeable small @close=\"unselectOption(opt.value)\">\n {{ opt.label || opt.value }}\n </PlChip>\n </div>\n <DropdownListItem\n v-for=\"(item, index) in filteredOptionsRef\"\n :key=\"index\"\n :option=\"item\"\n :text-item=\"'text'\"\n :is-selected=\"item.selected\"\n :is-hovered=\"data.activeOption == index\"\n size=\"medium\"\n use-checkbox\n @click.stop=\"selectOption(item.value)\"\n />\n <div v-if=\"!filteredOptionsRef.length\" class=\"nothing-found\">Nothing found</div>\n </DropdownOverlay>\n <DoubleContour class=\"pl-dropdown-multi__contour\" />\n </div>\n </div>\n <div v-if=\"error\" class=\"pl-dropdown-multi__error\">{{ getErrorMessage(error) }}</div>\n <div v-else-if=\"helper\" class=\"pl-dropdown-multi__helper\">{{ helper }}</div>\n </div>\n</template>\n"],"names":["__default__","emit","__emit","emitModel","v","slots","useSlots","props","__props","rootRef","ref","input","overlay","useTemplateRef","data","reactive","selectedValuesRef","computed","placeholderRef","normalizedOptionsRef","normalizeListOptions","selectedOptionsRef","opt","deepEqual","filteredOptionsRef","selectedValues","unref","options","search","deepIncludes","isLoadingOptions","isDisabled","tabindex","updateActiveOption","selectOption","values","it","_a","unselectOption","d","setFocusOnInput","toggleModel","onFocusOut","event","relatedTarget","_c","_b","handleKeydown","open","activeOption","filteredOptions","length","useLabelNotch","watch","watchPostEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;GAIAA,KAAe;AAAA,EACb,MAAM;AACR;;;;;;;;;;;;;;AAmBA,UAAMC,IAAOC,GAIPC,IAAY,CAACC,MAAWH,EAAK,qBAAqBG,CAAC,GAEnDC,IAAQC,EAAA,GAERC,IAAQC,GA+CRC,IAAUC,EAAA,GACVC,IAAQD,EAAA,GAERE,IAAUC,EAAe,SAAS,GAElCC,IAAOC,GAAS;AAAA,MACpB,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,MAAM;AAAA,MACN,eAAe;AAAA,IAAA,CAChB,GAEKC,IAAoBC,EAAS,MAAO,MAAM,QAAQV,EAAM,UAAU,IAAIA,EAAM,aAAa,EAAG,GAE5FW,IAAiBD,EAAS,MAC1BH,EAAK,QAAQP,EAAM,WAA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AEnE,MAAAzB,EAAK,eAAe,KAAK,IAAImC,IAAeV,IAAIY,CAAM,IAAIA,GAE1D,sBAAsB,MAAA;;AAAM,gBAAAd,IAAAzB,EAAQ,UAAR,gBAAAyB,EAAe;AAAA,OAAkB;AAAA,IAC/D;AAEA,WAAAe,GAAc3C,CAAO,GAErB4C;AAAA,MACE,MAAM9C,EAAM;AAAA,MACZ,MAAM0B,EAAA;AAAA,MACN,EAAE,WAAW,GAAA;AAAA,IAAK,GAGpBqB,GAAgB,MAAM;;AAEpB,MAAAxC,EAAK,QAEDA,EAAK,UACPuB,IAAAzB,EAAQ,UAAR,QAAAyB,EAAe;AAAA,IAEnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"PlDropdownMulti.vue.js","sources":["../../../src/components/PlDropdownMulti/PlDropdownMulti.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting multiple values from a list of options\n */\nexport default {\n name: 'PlDropdownMulti',\n};\n</script>\n\n<script lang=\"ts\" setup generic=\"M = unknown\">\nimport { computed, reactive, ref, unref, useSlots, useTemplateRef, watch, watchPostEffect } from 'vue';\nimport SvgRequired from '../../assets/images/required.svg?raw';\nimport { getErrorMessage } from '../../helpers/error.ts';\nimport { deepEqual, deepIncludes } from '../../helpers/objects';\nimport { normalizeListOptions } from '../../helpers/utils';\nimport type { ListOption } from '../../types';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport DropdownOverlay from '../../utils/DropdownOverlay/DropdownOverlay.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport DropdownListItem from '../DropdownListItem.vue';\nimport { PlChip } from '../PlChip';\nimport { PlMaskIcon24 } from '../PlMaskIcon24';\nimport { PlSvg } from '../PlSvg';\nimport { PlTooltip } from '../PlTooltip';\nimport './pl-dropdown-multi.scss';\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', v: M[]): void;\n}>();\n\nconst emitModel = (v: M[]) => emit('update:modelValue', v);\n\nconst slots = useSlots();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected values.\n */\n modelValue: M[];\n /**\n * The label text for the dropdown field (optional)\n */\n label?: string;\n /**\n * List of available options for the dropdown\n */\n options?: Readonly<ListOption<M>[]>;\n /**\n * A helper text displayed below the dropdown when there are no errors (optional).\n */\n helper?: string;\n /**\n * Error message displayed below the dropdown (optional)\n */\n error?: unknown;\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n /**\n * If `true`, the dropdown component is marked as required.\n */\n required?: boolean;\n /**\n * If `true`, the dropdown component is disabled and cannot be interacted with.\n */\n disabled?: boolean;\n }>(),\n {\n modelValue: () => [],\n label: undefined,\n helper: undefined,\n error: undefined,\n placeholder: '...',\n required: false,\n disabled: false,\n options: undefined,\n },\n);\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst input = ref<HTMLInputElement | undefined>();\n\nconst overlay = useTemplateRef('overlay');\n\nconst data = reactive({\n search: '',\n activeOption: -1,\n open: false,\n optionsHeight: 0,\n});\n\nconst selectedValuesRef = computed(() => (Array.isArray(props.modelValue) ? props.modelValue : []));\n\nconst placeholderRef = computed(() => {\n if (data.open && props.modelValue.length > 0) {\n return props.placeholder;\n }\n\n return props.modelValue.length > 0 ? '' : props.placeholder;\n});\n\nconst normalizedOptionsRef = computed(() => normalizeListOptions(props.options ?? []));\n\nconst selectedOptionsRef = computed(() => {\n return selectedValuesRef.value.map((v) => normalizedOptionsRef.value.find((opt) => deepEqual(opt.value, v))).filter((v) => v !== undefined);\n});\n\nconst filteredOptionsRef = computed(() => {\n const selectedValues = unref(selectedValuesRef);\n\n const options = unref(normalizedOptionsRef);\n\n return (\n data.search\n ? options.filter((opt) => {\n const search = data.search.toLowerCase();\n\n if (opt.label.toLowerCase().includes(search)) {\n return true;\n }\n\n if (typeof opt.value === 'string') {\n return opt.value.toLowerCase().includes(search);\n }\n\n return opt.value === data.search;\n })\n : [...options]\n ).map((opt) => ({\n ...opt,\n selected: deepIncludes(selectedValues, opt.value),\n }));\n});\n\nconst isLoadingOptions = computed(() => {\n return props.options === undefined;\n});\n\nconst isDisabled = computed(() => {\n if (isLoadingOptions.value) {\n return true;\n }\n\n return props.disabled;\n});\n\nconst tabindex = computed(() => (isDisabled.value ? undefined : '0'));\n\nconst updateActiveOption = () => {\n data.activeOption = 0;\n};\n\nconst selectOption = (v: M) => {\n const values = unref(selectedValuesRef);\n emitModel(deepIncludes(values, v) ? values.filter((it) => !deepEqual(it, v)) : [...values, v]);\n data.search = '';\n rootRef?.value?.focus();\n};\n\nconst unselectOption = (d: M) => emitModel(unref(selectedValuesRef).filter((v) => !deepEqual(v, d)));\n\nconst setFocusOnInput = () => input.value?.focus();\n\nconst toggleModel = () => {\n data.open = !data.open;\n if (!data.open) {\n data.search = '';\n }\n};\n\nconst onFocusOut = (event: FocusEvent) => {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!rootRef.value?.contains(relatedTarget) && !overlay.value?.listRef?.contains(relatedTarget)) {\n data.search = '';\n data.open = false;\n }\n};\n\nconst handleKeydown = (e: { code: string; preventDefault(): void }) => {\n const { open, activeOption } = data;\n\n if (!open) {\n if (e.code === 'Enter') {\n data.open = true;\n }\n return;\n }\n\n if (e.code === 'Escape') {\n data.open = false;\n rootRef.value?.focus();\n }\n\n const filteredOptions = unref(filteredOptionsRef);\n\n const { length } = filteredOptions;\n\n if (!length) {\n return;\n }\n\n if (['ArrowDown', 'ArrowUp', 'Enter'].includes(e.code)) {\n e.preventDefault();\n }\n\n if (e.code === 'Enter') {\n selectOption(filteredOptions[activeOption].value);\n }\n\n const d = e.code === 'ArrowDown' ? 1 : e.code === 'ArrowUp' ? -1 : 0;\n\n data.activeOption = Math.abs(activeOption + d + length) % length;\n\n requestAnimationFrame(() => overlay.value?.scrollIntoActive());\n};\n\nuseLabelNotch(rootRef);\n\nwatch(\n () => props.modelValue,\n () => updateActiveOption(),\n { immediate: true },\n);\n\nwatchPostEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n data.search;\n\n if (data.open) {\n overlay.value?.scrollIntoActive();\n }\n});\n</script>\n\n<template>\n <div class=\"pl-dropdown-multi__envelope\" @click=\"setFocusOnInput\">\n <div\n ref=\"rootRef\"\n :tabindex=\"tabindex\"\n class=\"pl-dropdown-multi\"\n :class=\"{ open: data.open, error, disabled: isDisabled }\"\n @keydown=\"handleKeydown\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown-multi__container\">\n <div class=\"pl-dropdown-multi__field\">\n <input\n ref=\"input\"\n v-model=\"data.search\"\n type=\"text\"\n tabindex=\"-1\"\n :disabled=\"isDisabled\"\n :placeholder=\"placeholderRef\"\n spellcheck=\"false\"\n autocomplete=\"chrome-off\"\n @focus=\"data.open = true\"\n />\n <div v-if=\"!data.open\" class=\"chips-container\">\n <PlChip v-for=\"(opt, i) in selectedOptionsRef\" :key=\"i\" closeable small @click.stop=\"data.open = true\" @close=\"unselectOption(opt.value)\">\n {{ opt.label || opt.value }}\n </PlChip>\n </div>\n\n <div class=\"pl-dropdown-multi__controls\">\n <PlMaskIcon24 v-if=\"isLoadingOptions\" name=\"loading\" />\n <slot name=\"append\" />\n <div class=\"pl-dropdown-multi__arrow-wrapper\" @click.stop=\"toggleModel\">\n <div class=\"arrow-icon arrow-icon-default\" />\n </div>\n </div>\n </div>\n <label v-if=\"label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlTooltip>\n </label>\n <DropdownOverlay\n v-if=\"data.open\"\n ref=\"overlay\"\n :root=\"rootRef\"\n class=\"pl-dropdown-multi__options\"\n :gap=\"5\"\n tabindex=\"-1\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown-multi__open-chips-container\">\n <PlChip v-for=\"(opt, i) in selectedOptionsRef\" :key=\"i\" closeable small @close=\"unselectOption(opt.value)\">\n {{ opt.label || opt.value }}\n </PlChip>\n </div>\n <DropdownListItem\n v-for=\"(item, index) in filteredOptionsRef\"\n :key=\"index\"\n :option=\"item\"\n :text-item=\"'text'\"\n :is-selected=\"item.selected\"\n :is-hovered=\"data.activeOption == index\"\n size=\"medium\"\n use-checkbox\n @click.stop=\"selectOption(item.value)\"\n />\n <div v-if=\"!filteredOptionsRef.length\" class=\"nothing-found\">Nothing found</div>\n </DropdownOverlay>\n <DoubleContour class=\"pl-dropdown-multi__contour\" />\n </div>\n </div>\n <div v-if=\"error\" class=\"pl-dropdown-multi__error\">{{ getErrorMessage(error) }}</div>\n <div v-else-if=\"helper\" class=\"pl-dropdown-multi__helper\">{{ helper }}</div>\n </div>\n</template>\n"],"names":["__default__","emit","__emit","emitModel","v","slots","useSlots","props","__props","rootRef","ref","input","overlay","useTemplateRef","data","reactive","selectedValuesRef","computed","placeholderRef","normalizedOptionsRef","normalizeListOptions","selectedOptionsRef","opt","deepEqual","filteredOptionsRef","selectedValues","unref","options","search","deepIncludes","isLoadingOptions","isDisabled","tabindex","updateActiveOption","selectOption","values","it","_a","unselectOption","d","setFocusOnInput","toggleModel","onFocusOut","event","relatedTarget","_c","_b","handleKeydown","open","activeOption","filteredOptions","length","useLabelNotch","watch","watchPostEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;GAIAA,KAAe;AAAA,EACb,MAAM;AACR;;;;;;;;;;;;;;AAoBA,UAAMC,IAAOC,GAIPC,IAAY,CAACC,MAAWH,EAAK,qBAAqBG,CAAC,GAEnDC,IAAQC,EAAA,GAERC,IAAQC,GA+CRC,IAAUC,EAAA,GACVC,IAAQD,EAAA,GAERE,IAAUC,EAAe,SAAS,GAElCC,IAAOC,GAAS;AAAA,MACpB,QAAQ;AAAA,MACR,cAAc;AAAA,MACd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AO,EAAE,SAAS,EAAE,IAAI,KACnD,EAAE,eAAA,GAGA,EAAE,SAAS,WACbjB,EAAagB,EAAgBD,CAAY,EAAE,KAAK;AAGlD,YAAMV,IAAI,EAAE,SAAS,cAAc,IAAI,EAAE,SAAS,YAAY,KAAK;AAEnE,MAAAzB,EAAK,eAAe,KAAK,IAAImC,IAAeV,IAAIY,CAAM,IAAIA,GAE1D,sBAAsB,MAAA;;AAAM,gBAAAd,IAAAzB,EAAQ,UAAR,gBAAAyB,EAAe;AAAA,OAAkB;AAAA,IAC/D;AAEA,WAAAe,GAAc3C,CAAO,GAErB4C;AAAA,MACE,MAAM9C,EAAM;AAAA,MACZ,MAAM0B,EAAA;AAAA,MACN,EAAE,WAAW,GAAA;AAAA,IAAK,GAGpBqB,GAAgB,MAAM;;AAEpB,MAAAxC,EAAK,QAEDA,EAAK,UACPuB,IAAAzB,EAAQ,UAAR,QAAAyB,EAAe;AAAA,IAEnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".pl-file-input{--contour-color: var(--txt-01);--label-color: var(--txt-01);--text-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--contour-offset: 2px;--icon-color: #000;position:relative;z-index:0;width:100%;height:var(--control-height, 40px);border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none;padding:0 8px;gap:8px;cursor:pointer}.pl-file-input__envelope{font-family:var(--font-family-base);display:flex;flex-direction:column;min-width:160px}.pl-file-input .mask-24{display:block;min-width:24px}.pl-file-input .mask-close{cursor:pointer}.pl-file-input__progress{position:absolute;z-index:-1;top:0;bottom:0;left:0;right:0;background:linear-gradient(90deg,#fff,#d8fac8);pointer-events:none;width:0}.pl-file-input__clear{--icon-color: var(--ic-02)}.pl-file-input__filename{width:100%;border:none;font-size:inherit;background-color:transparent;color:var(--text-color);caret-color:var(--border-color-focus);z-index:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:18px}.pl-file-input__filename:empty:before{color:var(--color-placeholder);content:attr(data-placeholder);color:var(--txt-03);font-size:14px;font-weight:500;line-height:20px}.pl-file-input__stats{white-space:nowrap;z-index:1;font-size:11px;font-weight:600;letter-spacing:.44px;text-transform:uppercase;color:var(--txt-03)}.pl-file-input label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-file-input label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-file-input__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-file-input__prefix{padding-left:12px;white-space:nowrap;margin-right:-12px;color:var(--prefix-color)}.pl-file-input__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input:hover{--contour-color: var(--control-hover-color)}.pl-file-input:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-file-input:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-file-input.dashed .pl-file-input__contour{border-style:dashed}.pl-file-input.nonEmpty{--prefix-color: var(--txt-01)}.pl-file-input.error{--contour-color: var(--txt-error);--label-color: var(--txt-error);--text-color: var(--txt-error);--icon-color: var(--txt-error)}.pl-file-input.error .pl-file-input__progress{display:none}.pl-file-input.disabled{--contour-color: var(--color-dis-01);cursor:not-allowed}.pl-file-input__cell-style{--border-radius-control: 0px;--input-active-color: var(--bg-base-light);--border-color: var(--border-color-div-grey);background-color:var(--input-active-color);padding:4px;height:100%;position:relative}.pl-file-input__cell-style .mask-paper-clip{display:none}.pl-file-input__cell-style .pl-file-input{height:100%!important;position:unset}.pl-file-input__cell-style .pl-file-input .double-contour{top:2px;right:2px;bottom:2px;left:2px}.pl-file-input__cell-style .pl-file-input__contour{border-width:1px;box-shadow:unset!important;border-color:var(--border-color);border-style:dashed}.pl-file-input__cell-style .pl-file-input__filename{text-align:center!important}.pl-file-input__cell-style .pl-file-input__error{margin-top:0;margin-right:8px}.pl-file-input__cell-style:hover{--border-color: var(--border-color-focus);background-color:#d9f8ca}.pl-file-input__cell-style:hover .pl-file-input__filename:before{color:#110529!important}.pl-file-input__cell-style.has-file:hover{background-color:var(--input-active-color)}.pl-file-input__cell-style.has-file{padding-left:0;padding-right:0}.pl-file-input__cell-style.has-file .pl-file-input__contour{border:unset}.pl-file-input__cell-style.has-file .pl-file-input__filename{text-align:left!important}.pl-file-input__cell-style.has-file .mask-paper-clip{display:block}")),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
-
import { defineComponent as q, reactive as R, useSlots as U, computed as s, watch as $, ref as z, createElementBlock as n, openBlock as l, Fragment as D, createElementVNode as c, createVNode as B, normalizeClass as O, createCommentVNode as u, withModifiers as F, withKeys as H, createBlock as i, normalizeStyle as K,
|
|
2
|
+
import { defineComponent as q, reactive as R, useSlots as U, computed as s, watch as $, ref as z, createElementBlock as n, openBlock as l, Fragment as D, createElementVNode as c, createVNode as B, normalizeClass as O, createCommentVNode as u, withModifiers as F, withKeys as H, createBlock as i, normalizeStyle as K, unref as t, toDisplayString as p, withCtx as L, renderSlot as j, createTextVNode as A } from "vue";
|
|
3
|
+
|
|
3
4
|
import { prettyBytes as y } from "@milaboratories/helpers";
|
|
4
5
|
import { getFileNameFromHandle as G, getFilePathFromHandle as J } from "@platforma-sdk/model";
|
|
5
|
-
import Q from "../../
|
|
6
|
-
import
|
|
7
|
-
import X from "../../utils/
|
|
8
|
-
import
|
|
9
|
-
import Z from "../PlFileDialog/PlFileDialog.vue.js";
|
|
6
|
+
import { getErrorMessage as Q } from "../../helpers/error.js";
|
|
7
|
+
import W from "../../utils/DoubleContour.vue.js";
|
|
8
|
+
import { useLabelNotch as X } from "../../utils/useLabelNotch.js";
|
|
9
|
+
import Y from "../PlFileDialog/PlFileDialog.vue.js";
|
|
10
10
|
import f from "../PlIcon24/PlIcon24.vue.js";
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import Z from "../PlTooltip/PlTooltip.vue.js";
|
|
12
|
+
import x from "../../assets/images/required.svg.js";
|
|
13
|
+
import ee from "../PlSvg/PlSvg.vue.js";
|
|
14
|
+
const le = {
|
|
14
15
|
key: 0,
|
|
15
16
|
ref: "label"
|
|
16
|
-
},
|
|
17
|
+
}, oe = ["data-placeholder"], te = {
|
|
17
18
|
key: 5,
|
|
18
19
|
class: "pl-file-input__stats"
|
|
19
|
-
},
|
|
20
|
+
}, re = {
|
|
20
21
|
key: 0,
|
|
21
22
|
class: "pl-file-input__error"
|
|
22
|
-
},
|
|
23
|
+
}, se = {
|
|
23
24
|
key: 1,
|
|
24
25
|
class: "pl-file-input__helper"
|
|
25
|
-
},
|
|
26
|
+
}, he = /* @__PURE__ */ q({
|
|
26
27
|
__name: "PlFileInput",
|
|
27
28
|
props: {
|
|
28
29
|
modelValue: {},
|
|
@@ -39,27 +40,27 @@ const ee = {
|
|
|
39
40
|
fileDialogCloseOnOutsideClick: { type: Boolean, default: !0 }
|
|
40
41
|
},
|
|
41
42
|
emits: ["update:modelValue"],
|
|
42
|
-
setup(N, { emit:
|
|
43
|
+
setup(N, { emit: P }) {
|
|
43
44
|
const a = R({
|
|
44
45
|
fileDialogOpen: !1,
|
|
45
46
|
error: void 0
|
|
46
|
-
}), g = U(), v =
|
|
47
|
+
}), g = U(), v = P, o = N, h = (e, r) => {
|
|
47
48
|
if (e)
|
|
48
49
|
try {
|
|
49
|
-
return
|
|
50
|
+
return r(e);
|
|
50
51
|
} catch (d) {
|
|
51
52
|
return a.error = d instanceof Error ? d.message : String(d), e;
|
|
52
53
|
}
|
|
53
|
-
}, k = s(() => h(o.modelValue, G)), _ = s(() => h(o.modelValue, J)),
|
|
54
|
-
const { status: e, done:
|
|
55
|
-
return !e || !e.bytesTotal ? "" : e.bytesProcessed && !
|
|
54
|
+
}, k = s(() => h(o.modelValue, G)), _ = s(() => h(o.modelValue, J)), E = s(() => o.progress && !o.progress.done), T = s(() => o.progress && o.progress.done), V = s(() => Q(a.error, o.error)), m = s(() => typeof V.value == "string"), b = s(() => {
|
|
55
|
+
const { status: e, done: r } = o.progress ?? {};
|
|
56
|
+
return !e || !e.bytesTotal ? "" : e.bytesProcessed && !r ? y(e.bytesProcessed, {}) + " / " + y(e.bytesTotal, {}) : y(e.bytesTotal, {});
|
|
56
57
|
}), w = s(() => {
|
|
57
|
-
var
|
|
58
|
+
var r;
|
|
58
59
|
const { progress: e } = o;
|
|
59
60
|
return e ? {
|
|
60
|
-
width: e.done ? "100%" : Math.round((((
|
|
61
|
+
width: e.done ? "100%" : Math.round((((r = e.status) == null ? void 0 : r.progress) ?? 0) * 100) + "%"
|
|
61
62
|
} : {};
|
|
62
|
-
}),
|
|
63
|
+
}), S = () => {
|
|
63
64
|
a.fileDialogOpen = !0;
|
|
64
65
|
}, M = (e) => {
|
|
65
66
|
e.files.length && v("update:modelValue", e.files[0]);
|
|
@@ -69,70 +70,73 @@ const ee = {
|
|
|
69
70
|
() => a.error = void 0,
|
|
70
71
|
{ immediate: !0 }
|
|
71
72
|
);
|
|
72
|
-
const
|
|
73
|
-
return o.cellStyle ||
|
|
73
|
+
const C = z();
|
|
74
|
+
return o.cellStyle || X(C), (e, r) => (l(), n(D, null, [
|
|
74
75
|
c("div", {
|
|
75
76
|
class: O([{ "pl-file-input__cell-style": !!e.cellStyle, "has-file": !!k.value }, "pl-file-input__envelope"])
|
|
76
77
|
}, [
|
|
77
78
|
c("div", {
|
|
78
79
|
ref_key: "rootRef",
|
|
79
|
-
ref:
|
|
80
|
+
ref: C,
|
|
80
81
|
class: O([{ dashed: e.dashed, error: m.value }, "pl-file-input"]),
|
|
81
82
|
tabindex: "0",
|
|
82
|
-
onKeyup: H(
|
|
83
|
-
onClick: F(
|
|
83
|
+
onKeyup: H(S, ["enter"]),
|
|
84
|
+
onClick: F(S, ["stop"])
|
|
84
85
|
}, [
|
|
85
86
|
c("div", {
|
|
86
87
|
style: K(w.value),
|
|
87
88
|
class: "pl-file-input__progress"
|
|
88
89
|
}, null, 4),
|
|
89
|
-
!e.cellStyle && e.label ? (l(), n("label",
|
|
90
|
-
e.required ? (l(), i(
|
|
90
|
+
!e.cellStyle && e.label ? (l(), n("label", le, [
|
|
91
|
+
e.required ? (l(), i(t(ee), {
|
|
92
|
+
key: 0,
|
|
93
|
+
uri: t(x)
|
|
94
|
+
}, null, 8, ["uri"])) : u("", !0),
|
|
91
95
|
c("span", null, p(e.label), 1),
|
|
92
|
-
|
|
96
|
+
t(g).tooltip || _.value ? (l(), i(t(Z), {
|
|
93
97
|
key: 1,
|
|
94
98
|
class: "info",
|
|
95
99
|
position: "top"
|
|
96
100
|
}, {
|
|
97
101
|
tooltip: L(() => [
|
|
98
|
-
|
|
102
|
+
t(g).tooltip ? j(e.$slots, "tooltip", { key: 0 }) : (l(), n(D, { key: 1 }, [
|
|
99
103
|
A(p(_.value), 1)
|
|
100
104
|
], 64))
|
|
101
105
|
]),
|
|
102
106
|
_: 3
|
|
103
107
|
})) : u("", !0)
|
|
104
108
|
], 512)) : u("", !0),
|
|
105
|
-
m.value ? (l(), i(
|
|
109
|
+
m.value ? (l(), i(t(f), {
|
|
106
110
|
key: 1,
|
|
107
111
|
name: "restart"
|
|
108
|
-
})) :
|
|
112
|
+
})) : E.value ? (l(), i(t(f), {
|
|
109
113
|
key: 2,
|
|
110
114
|
name: "cloud-upload"
|
|
111
|
-
})) : T.value ? (l(), i(
|
|
115
|
+
})) : T.value ? (l(), i(t(f), {
|
|
112
116
|
key: 3,
|
|
113
117
|
name: "success"
|
|
114
|
-
})) : (l(), i(
|
|
118
|
+
})) : (l(), i(t(f), {
|
|
115
119
|
key: 4,
|
|
116
120
|
name: "paper-clip"
|
|
117
121
|
})),
|
|
118
122
|
c("div", {
|
|
119
123
|
"data-placeholder": e.placeholder ?? "Choose file",
|
|
120
124
|
class: "pl-file-input__filename"
|
|
121
|
-
}, p(k.value), 9,
|
|
122
|
-
b.value ? (l(), n("div",
|
|
123
|
-
e.modelValue ? (l(), i(
|
|
125
|
+
}, p(k.value), 9, oe),
|
|
126
|
+
b.value ? (l(), n("div", te, p(b.value), 1)) : u("", !0),
|
|
127
|
+
e.modelValue ? (l(), i(t(f), {
|
|
124
128
|
key: 6,
|
|
125
129
|
class: "pl-file-input__clear",
|
|
126
130
|
name: "close",
|
|
127
131
|
onClick: F(I, ["stop"])
|
|
128
132
|
})) : u("", !0),
|
|
129
|
-
B(
|
|
133
|
+
B(W, { class: "pl-file-input__contour" })
|
|
130
134
|
], 34),
|
|
131
|
-
m.value ? (l(), n("div",
|
|
135
|
+
m.value ? (l(), n("div", re, p(V.value), 1)) : e.helper ? (l(), n("div", se, p(e.helper), 1)) : u("", !0)
|
|
132
136
|
], 2),
|
|
133
|
-
B(
|
|
137
|
+
B(t(Y), {
|
|
134
138
|
modelValue: a.fileDialogOpen,
|
|
135
|
-
"onUpdate:modelValue":
|
|
139
|
+
"onUpdate:modelValue": r[0] || (r[0] = (d) => a.fileDialogOpen = d),
|
|
136
140
|
"close-on-outside-click": e.fileDialogCloseOnOutsideClick,
|
|
137
141
|
extensions: e.extensions,
|
|
138
142
|
title: e.fileDialogTitle,
|
|
@@ -142,6 +146,6 @@ const ee = {
|
|
|
142
146
|
}
|
|
143
147
|
});
|
|
144
148
|
export {
|
|
145
|
-
|
|
149
|
+
he as default
|
|
146
150
|
};
|
|
147
151
|
//# sourceMappingURL=PlFileInput.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlFileInput.vue.js","sources":["../../../src/components/PlFileInput/PlFileInput.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { prettyBytes } from '@milaboratories/helpers';\nimport type { ImportFileHandle, ImportProgress } from '@platforma-sdk/model';\nimport { getFileNameFromHandle, getFilePathFromHandle } from '@platforma-sdk/model';\nimport { computed, reactive, ref, useSlots, watch } from 'vue';\nimport
|
|
1
|
+
{"version":3,"file":"PlFileInput.vue.js","sources":["../../../src/components/PlFileInput/PlFileInput.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport './pl-file-input.scss';\n\nimport { prettyBytes } from '@milaboratories/helpers';\nimport type { ImportFileHandle, ImportProgress } from '@platforma-sdk/model';\nimport { getFileNameFromHandle, getFilePathFromHandle } from '@platforma-sdk/model';\nimport { computed, reactive, ref, useSlots, watch } from 'vue';\nimport { getErrorMessage } from '../../helpers/error.ts';\nimport type { ImportedFiles } from '../../types';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport { PlFileDialog } from '../PlFileDialog';\nimport { PlMaskIcon24 } from '../PlMaskIcon24';\nimport { PlTooltip } from '../PlTooltip';\n\nimport SvgRequired from '../../assets/images/required.svg?raw';\nimport { PlSvg } from '../PlSvg';\n\nconst data = reactive({\n fileDialogOpen: false,\n error: undefined as undefined | string,\n});\n\nconst slots = useSlots();\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: ImportFileHandle | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current import file handle.\n */\n modelValue: ImportFileHandle | undefined;\n /**\n * The label to display above the input field.\n */\n label?: string;\n /**\n * If `true`, the input field is marked as required.\n */\n required?: boolean;\n /**\n * If `true`, the component border is dashed.\n */\n dashed?: boolean;\n /**\n * Allowed file extensions (should start with `.`)\n */\n extensions?: string[];\n /**\n * Placeholder text\n */\n placeholder?: string;\n /**\n * Import/Upload progress\n */\n progress?: ImportProgress;\n /**\n * An error message to display below the input field.\n */\n error?: unknown;\n /**\n * A helper text to display below the input field when there are no errors.\n */\n helper?: string;\n /**\n * Remove rounded border and change styles\n */\n cellStyle?: boolean;\n /**\n * File dialog title\n */\n fileDialogTitle?: string;\n /**\n * If `true`, the file dialog window closes when clicking outside the modal area (default: `true`)\n */\n fileDialogCloseOnOutsideClick?: boolean;\n }>(),\n {\n label: undefined,\n extensions: undefined,\n fileDialogTitle: undefined,\n placeholder: undefined,\n progress: undefined,\n error: undefined,\n helper: undefined,\n cellStyle: false,\n fileDialogCloseOnOutsideClick: true,\n },\n);\n\nconst tryValue = <T extends ImportFileHandle>(v: T | undefined, cb: (v: T) => string | undefined) => {\n if (!v) {\n return undefined;\n }\n\n try {\n return cb(v);\n } catch (err) {\n data.error = err instanceof Error ? err.message : String(err);\n return v;\n }\n};\n\nconst fileName = computed(() => tryValue(props.modelValue, getFileNameFromHandle));\n\nconst filePath = computed(() => tryValue(props.modelValue, getFilePathFromHandle));\n\nconst isUploading = computed(() => props.progress && !props.progress.done);\n\nconst isUploaded = computed(() => props.progress && props.progress.done);\n\nconst computedErrorMessage = computed(() => getErrorMessage(data.error, props.error));\n\nconst hasErrors = computed(() => typeof computedErrorMessage.value === 'string');\n\nconst uploadStats = computed(() => {\n const { status, done } = props.progress ?? {};\n\n if (!status || !status.bytesTotal) {\n return '';\n }\n\n if (status.bytesProcessed && !done) {\n return prettyBytes(status.bytesProcessed, {}) + ' / ' + prettyBytes(status.bytesTotal, {});\n }\n\n return prettyBytes(status.bytesTotal, {});\n});\n\nconst progressStyle = computed(() => {\n const { progress } = props;\n\n if (!progress) {\n return {};\n }\n\n return {\n width: progress.done ? '100%' : Math.round((progress.status?.progress ?? 0) * 100) + '%',\n };\n});\n\nconst openFileDialog = () => {\n data.fileDialogOpen = true;\n};\n\nconst onImport = (v: ImportedFiles) => {\n if (v.files.length) {\n emit('update:modelValue', v.files[0]);\n }\n};\n\nconst clear = () => emit('update:modelValue', undefined);\n\nwatch(\n () => props.modelValue,\n () => (data.error = undefined),\n { immediate: true },\n);\n\nconst rootRef = ref();\n\nif (!props.cellStyle) {\n useLabelNotch(rootRef);\n}\n</script>\n\n<template>\n <div :class=\"{ 'pl-file-input__cell-style': !!cellStyle, 'has-file': !!fileName }\" class=\"pl-file-input__envelope\">\n <div\n ref=\"rootRef\"\n :class=\"{ dashed, error: hasErrors }\"\n class=\"pl-file-input\"\n tabindex=\"0\"\n @keyup.enter=\"openFileDialog\"\n @click.stop=\"openFileDialog\"\n >\n <div :style=\"progressStyle\" class=\"pl-file-input__progress\" />\n <label v-if=\"!cellStyle && label\" ref=\"label\">\n <PlSvg v-if=\"required\" :uri=\"SvgRequired\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip || filePath\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot v-if=\"slots.tooltip\" name=\"tooltip\" />\n <template v-else>{{ filePath }}</template>\n </template>\n </PlTooltip>\n </label>\n <PlMaskIcon24 v-if=\"hasErrors\" name=\"restart\" />\n <PlMaskIcon24 v-else-if=\"isUploading\" name=\"cloud-upload\" />\n <PlMaskIcon24 v-else-if=\"isUploaded\" name=\"success\" />\n <PlMaskIcon24 v-else name=\"paper-clip\" />\n <div :data-placeholder=\"placeholder ?? 'Choose file'\" class=\"pl-file-input__filename\">\n {{ fileName }}\n </div>\n <div v-if=\"uploadStats\" class=\"pl-file-input__stats\">{{ uploadStats }}</div>\n <PlMaskIcon24 v-if=\"modelValue\" class=\"pl-file-input__clear\" name=\"close\" @click.stop=\"clear\" />\n <DoubleContour class=\"pl-file-input__contour\" />\n </div>\n <div v-if=\"hasErrors\" class=\"pl-file-input__error\">\n {{ computedErrorMessage }}\n </div>\n <div v-else-if=\"helper\" class=\"pl-file-input__helper\">{{ helper }}</div>\n </div>\n <PlFileDialog\n v-model=\"data.fileDialogOpen\"\n :close-on-outside-click=\"fileDialogCloseOnOutsideClick\"\n :extensions=\"extensions\"\n :title=\"fileDialogTitle\"\n @import:files=\"onImport\"\n />\n</template>\n"],"names":["data","reactive","slots","useSlots","emit","__emit","props","__props","tryValue","v","cb","err","fileName","computed","getFileNameFromHandle","filePath","getFilePathFromHandle","isUploading","isUploaded","computedErrorMessage","getErrorMessage","hasErrors","uploadStats","status","done","prettyBytes","progressStyle","progress","_a","openFileDialog","onImport","clear","watch","rootRef","ref","useLabelNotch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,UAAMA,IAAOC,EAAS;AAAA,MACpB,gBAAgB;AAAA,MAChB,OAAO;AAAA,IAAA,CACR,GAEKC,IAAQC,EAAA,GAERC,IAAOC,GAIPC,IAAQC,GAgERC,IAAW,CAA6BC,GAAkBC,MAAqC;AACnG,UAAKD;AAIL,YAAI;AACF,iBAAOC,EAAGD,CAAC;AAAA,QACb,SAASE,GAAK;AACZ,iBAAAX,EAAK,QAAQW,aAAe,QAAQA,EAAI,UAAU,OAAOA,CAAG,GACrDF;AAAA,QACT;AAAA,IACF,GAEMG,IAAWC,EAAS,MAAML,EAASF,EAAM,YAAYQ,CAAqB,CAAC,GAE3EC,IAAWF,EAAS,MAAML,EAASF,EAAM,YAAYU,CAAqB,CAAC,GAE3EC,IAAcJ,EAAS,MAAMP,EAAM,YAAY,CAACA,EAAM,SAAS,IAAI,GAEnEY,IAAaL,EAAS,MAAMP,EAAM,YAAYA,EAAM,SAAS,IAAI,GAEjEa,IAAuBN,EAAS,MAAM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