@milaboratories/uikit 2.2.95 → 2.2.97
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 +32 -27
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/components/DataTable/TableComponent.vue.js +1 -1
- package/dist/components/PlAccordion/PlAccordionSection.vue2.js +21 -21
- package/dist/components/PlAccordion/PlAccordionSection.vue2.js.map +1 -1
- package/dist/components/PlAutocomplete/PlAutocomplete.vue.js.map +1 -1
- package/dist/components/PlClipboard/PlClipboard.vue.d.ts +1 -1
- package/dist/components/PlDropdown/OptionList.vue.d.ts +77 -0
- package/dist/components/PlDropdown/OptionList.vue.d.ts.map +1 -0
- package/dist/components/PlDropdown/OptionList.vue.js +88 -0
- package/dist/components/PlDropdown/OptionList.vue.js.map +1 -0
- package/dist/components/PlDropdown/OptionList.vue2.js +5 -0
- package/dist/components/PlDropdown/OptionList.vue2.js.map +1 -0
- package/dist/components/PlDropdown/PlDropdown.vue.d.ts.map +1 -1
- package/dist/components/PlDropdown/PlDropdown.vue.js +110 -122
- package/dist/components/PlDropdown/PlDropdown.vue.js.map +1 -1
- package/dist/components/PlDropdown/types.d.ts +7 -0
- package/dist/components/PlDropdown/types.d.ts.map +1 -0
- package/dist/components/PlDropdown/useGroupBy.d.ts +7 -0
- package/dist/components/PlDropdown/useGroupBy.d.ts.map +1 -0
- package/dist/components/PlDropdown/useGroupBy.js +36 -0
- package/dist/components/PlDropdown/useGroupBy.js.map +1 -0
- package/dist/components/PlDropdownRef/PlDropdownRef.vue.d.ts +1 -1
- package/dist/components/PlDropdownRef/PlDropdownRef.vue.d.ts.map +1 -1
- package/dist/components/PlDropdownRef/PlDropdownRef.vue.js +11 -10
- package/dist/components/PlDropdownRef/PlDropdownRef.vue.js.map +1 -1
- package/dist/components/PlElementList/PlElementList.vue.d.ts +19 -27
- package/dist/components/PlElementList/PlElementList.vue.d.ts.map +1 -1
- package/dist/components/PlElementList/PlElementList.vue2.js +155 -174
- package/dist/components/PlElementList/PlElementList.vue2.js.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.vue.d.ts.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.vue2.js +1 -1
- package/dist/components/PlElementList/PlElementListItem.vue2.js.map +1 -1
- package/dist/components/PlElementList/PlElementListItem.vue3.js +24 -24
- package/dist/components/PlElementList/utils.d.ts +0 -1
- package/dist/components/PlElementList/utils.d.ts.map +1 -1
- package/dist/components/PlElementList/utils.js +5 -11
- package/dist/components/PlElementList/utils.js.map +1 -1
- package/dist/components/PlErrorBoundary/PlErrorBoundary.vue.js +8 -8
- package/dist/components/PlFileInput/PlFileInput.vue.js +8 -8
- package/dist/components/PlIcon16/PlIcon16.vue.d.ts +1 -1
- package/dist/components/PlIcon24/PlIcon24.vue.d.ts +1 -1
- package/dist/components/PlSlideModal/PlSlideModal.vue.js +1 -1
- package/dist/components/PlSvg/PlSvg.vue.d.ts +1 -1
- package/dist/components/PlSvg/PlSvg.vue.d.ts.map +1 -1
- package/dist/components/PlSvg/PlSvg.vue2.js +24 -22
- package/dist/components/PlSvg/PlSvg.vue2.js.map +1 -1
- package/dist/composition/useWatchFetch.js +10 -10
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +2 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/lib/util/helpers/dist/index.js +108 -104
- package/dist/lib/util/helpers/dist/index.js.map +1 -1
- package/dist/sdk/model/dist/index.js +1 -1
- package/dist/sdk/model/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/TextLabel.vue.d.ts +18 -0
- package/dist/utils/TextLabel.vue.d.ts.map +1 -0
- package/dist/utils/TextLabel.vue.js +26 -0
- package/dist/utils/TextLabel.vue.js.map +1 -0
- package/dist/utils/TextLabel.vue2.js +13 -0
- package/dist/utils/TextLabel.vue2.js.map +1 -0
- package/package.json +4 -4
- package/src/components/PlAccordion/PlAccordionSection.vue +3 -3
- package/src/components/PlAutocomplete/PlAutocomplete.vue +1 -1
- package/src/components/PlDropdown/OptionList.vue +71 -0
- package/src/components/PlDropdown/PlDropdown.vue +29 -25
- package/src/components/PlDropdown/pl-dropdown.scss +4 -0
- package/src/components/PlDropdown/types.ts +3 -0
- package/src/components/PlDropdown/useGroupBy.ts +63 -0
- package/src/components/PlDropdownRef/PlDropdownRef.vue +1 -0
- package/src/components/PlElementList/PlElementList.vue +116 -135
- package/src/components/PlElementList/PlElementListItem.vue +9 -1
- package/src/components/PlElementList/README.md +325 -72
- package/src/components/PlElementList/utils.ts +0 -9
- package/src/components/PlSvg/PlSvg.vue +2 -2
- package/src/helpers/utils.ts +1 -0
- package/src/types.ts +5 -15
- package/src/utils/TextLabel.vue +43 -0
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(`.pl-dropdown__options{--option-hover-bg: var(--btn-sec-hover-grey);z-index:var(--z-dropdown-options);border:1px solid var(--border-color-div-grey);position:absolute;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__options::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-dropdown__options::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-dropdown__options::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-dropdown__options .nothing-found{padding:0 10px;height:var(--control-height);line-height:var(--control-height);background-color:#fff;opacity:.5;font-style:italic}.pl-dropdown__options .option{position:relative;padding:0 30px 0 10px;height:var(--control-height);line-height:var(--control-height);cursor:pointer;-webkit-user-select:none;user-select:none}.pl-dropdown__options .option .checkmark{position:absolute;display:none;right:10px;top:50%;transform:translateY(-50%)}.pl-dropdown__options .option>span{display:block;overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis}.pl-dropdown__options .option.selected{background-color:var(--color-active-select)}.pl-dropdown__options .option.selected .checkmark{display:block}.pl-dropdown__options .option.active:not(.selected){background-color:var(--option-hover-bg)}.pl-dropdown__options .option:hover{background-color:var(--option-hover-bg)}.pl-dropdown{--contour-color: var(--txt-01);--contour-border-width: 1px;--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)}.pl-dropdown__envelope{font-family:var(--control-font-family);min-width:160px}.pl-dropdown 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 label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-dropdown__container{position:absolute;top:0;left:0;right:0;border-radius:6px;min-height:var(--control-height);color:var(--txt-01)}.pl-dropdown__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__field{position:relative;border-radius:6px;overflow:hidden;background:transparent;padding-left:11px;min-height:var(--control-height);line-height:var(--control-height);display:flex;flex-direction:row;align-items:center;cursor:pointer}.pl-dropdown__field .input-value{position:absolute;top:0;left:0;bottom:0;right:0;display:flex;flex-direction:row;align-items:center;padding:0 60px 0 11px;pointer-events:none;line-height:20px;color:var(--txt-01);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit}.pl-dropdown__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% - 40px);color:var(--txt-01);caret-color:var(--border-color-focus)}.pl-dropdown__field input:focus{outline:none}.pl-dropdown__field input:placeholder-shown{text-overflow:ellipsis}.pl-dropdown__field input::placeholder{color:var(--color-placeholder)}.pl-dropdown__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__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__controls{display:flex;flex-direction:row;align-items:center;gap:6px;margin-left:auto}.pl-dropdown__controls .mask-16,.pl-dropdown__controls .mask-24{--icon-color: var(--control-mask-fill);cursor:pointer}.pl-dropdown__controls .clear{--icon-color: var(--ic-02)}.pl-dropdown__controls .mask-loading{--icon-color: var(--ic-accent);animation:spin 2.5s linear infinite}.pl-dropdown__arrow-wrapper{display:flex;align-items:center;min-height:var(--control-height);padding-right:11px}.pl-dropdown .arrow-icon{cursor:pointer}.pl-dropdown .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.open,.pl-dropdown:focus-within{z-index:1;--label-color: var(--txt-focus)}.pl-dropdown.open .pl-dropdown__container{z-index:1000}.pl-dropdown.open .pl-dropdown__field{border-radius:6px 6px 0 0}.pl-dropdown.open .arrow-icon.arrow-icon-default{background-color:var(--control-mask-fill);transform:rotate(-180deg)}.pl-dropdown:hover{--contour-color: var(--control-hover-color)}.pl-dropdown: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:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-dropdown.error{--contour-color: var(--txt-error);--label-color: var(--txt-error)}.pl-dropdown.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;-webkit-user-select:none;user-select:none}.pl-dropdown.disabled .input-value{color:var(--dis-01)}
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(`.pl-dropdown__options{--option-hover-bg: var(--btn-sec-hover-grey);z-index:var(--z-dropdown-options);border:1px solid var(--border-color-div-grey);position:absolute;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__options::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-dropdown__options::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-dropdown__options::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-dropdown__options .nothing-found{padding:0 10px;height:var(--control-height);line-height:var(--control-height);background-color:#fff;opacity:.5;font-style:italic}.pl-dropdown__options .group-container{padding:4px 0}.pl-dropdown__options .option{position:relative;padding:0 30px 0 10px;height:var(--control-height);line-height:var(--control-height);cursor:pointer;-webkit-user-select:none;user-select:none}.pl-dropdown__options .option .checkmark{position:absolute;display:none;right:10px;top:50%;transform:translateY(-50%)}.pl-dropdown__options .option>span{display:block;overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis}.pl-dropdown__options .option.selected{background-color:var(--color-active-select)}.pl-dropdown__options .option.selected .checkmark{display:block}.pl-dropdown__options .option.active:not(.selected){background-color:var(--option-hover-bg)}.pl-dropdown__options .option:hover{background-color:var(--option-hover-bg)}.pl-dropdown{--contour-color: var(--txt-01);--contour-border-width: 1px;--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)}.pl-dropdown__envelope{font-family:var(--control-font-family);min-width:160px}.pl-dropdown 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 label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-dropdown__container{position:absolute;top:0;left:0;right:0;border-radius:6px;min-height:var(--control-height);color:var(--txt-01)}.pl-dropdown__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__field{position:relative;border-radius:6px;overflow:hidden;background:transparent;padding-left:11px;min-height:var(--control-height);line-height:var(--control-height);display:flex;flex-direction:row;align-items:center;cursor:pointer}.pl-dropdown__field .input-value{position:absolute;top:0;left:0;bottom:0;right:0;display:flex;flex-direction:row;align-items:center;padding:0 60px 0 11px;pointer-events:none;line-height:20px;color:var(--txt-01);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit}.pl-dropdown__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% - 40px);color:var(--txt-01);caret-color:var(--border-color-focus)}.pl-dropdown__field input:focus{outline:none}.pl-dropdown__field input:placeholder-shown{text-overflow:ellipsis}.pl-dropdown__field input::placeholder{color:var(--color-placeholder)}.pl-dropdown__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__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__controls{display:flex;flex-direction:row;align-items:center;gap:6px;margin-left:auto}.pl-dropdown__controls .mask-16,.pl-dropdown__controls .mask-24{--icon-color: var(--control-mask-fill);cursor:pointer}.pl-dropdown__controls .clear{--icon-color: var(--ic-02)}.pl-dropdown__controls .mask-loading{--icon-color: var(--ic-accent);animation:spin 2.5s linear infinite}.pl-dropdown__arrow-wrapper{display:flex;align-items:center;min-height:var(--control-height);padding-right:11px}.pl-dropdown .arrow-icon{cursor:pointer}.pl-dropdown .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.open,.pl-dropdown:focus-within{z-index:1;--label-color: var(--txt-focus)}.pl-dropdown.open .pl-dropdown__container{z-index:1000}.pl-dropdown.open .pl-dropdown__field{border-radius:6px 6px 0 0}.pl-dropdown.open .arrow-icon.arrow-icon-default{background-color:var(--control-mask-fill);transform:rotate(-180deg)}.pl-dropdown:hover{--contour-color: var(--control-hover-color)}.pl-dropdown: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:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-dropdown.error{--contour-color: var(--txt-error);--label-color: var(--txt-error)}.pl-dropdown.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;-webkit-user-select:none;user-select:none}.pl-dropdown.disabled .input-value{color:var(--dis-01)}
|
|
2
2
|
.ui-lt-container{min-width:0;white-space:nowrap;overflow:hidden;position:relative;border-radius:5px}.ui-lt-container span{display:inline-block;overflow:hidden;text-overflow:ellipsis;width:100%;vertical-align:bottom;pointer-events:all!important}.ui-lt-container .ui-lt-animate{position:relative;animation:left-to-right var(--5deba9de) infinite alternate linear;overflow:unset!important;text-overflow:unset!important;width:fit-content!important}@keyframes left-to-right{0%{transform:translate(0);left:0%}to{transform:translate(-101%);left:101%}}`)),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
3
|
-
import { defineComponent as
|
|
3
|
+
import { defineComponent as le, useSlots as se, ref as D, useTemplateRef as ae, reactive as ie, computed as s, unref as f, watch as S, watchPostEffect as de, createElementBlock as a, openBlock as n, createElementVNode as u, createCommentVNode as d, normalizeClass as g, createBlock as v, createVNode as B, withDirectives as ce, vModelText as ue, withCtx as $, createTextVNode as pe, toDisplayString as m, renderSlot as z, withModifiers as M } from "vue";
|
|
4
4
|
|
|
5
|
-
import { tap as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { useLabelNotch as
|
|
9
|
-
import { deepEqual as
|
|
10
|
-
import
|
|
11
|
-
import he from "../LongText.vue.js";
|
|
5
|
+
import { tap as fe } from "../../helpers/functions.js";
|
|
6
|
+
import ve from "../PlTooltip/PlTooltip.vue.js";
|
|
7
|
+
import me from "../../utils/DoubleContour.vue.js";
|
|
8
|
+
import { useLabelNotch as he } from "../../utils/useLabelNotch.js";
|
|
9
|
+
import { deepEqual as I } from "../../helpers/objects.js";
|
|
10
|
+
import we from "../LongText.vue.js";
|
|
12
11
|
|
|
13
12
|
import { normalizeListOptions as _e } from "../../helpers/utils.js";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import ye from "../../utils/DropdownOverlay/DropdownOverlay.vue.js";
|
|
13
|
+
import ke from "../PlIcon16/PlIcon16.vue.js";
|
|
14
|
+
import ye from "../PlIcon24/PlIcon24.vue.js";
|
|
17
15
|
import ge from "../../generated/components/svg/images/SvgRequired.vue2.js";
|
|
18
16
|
import { getErrorMessage as Ie } from "../../helpers/error.js";
|
|
19
|
-
|
|
17
|
+
import be from "./OptionList.vue.js";
|
|
18
|
+
import { useGroupBy as Ve } from "./useGroupBy.js";
|
|
19
|
+
const Le = ["tabindex"], Ce = { class: "pl-dropdown__container" }, Ee = { class: "pl-dropdown__field" }, Re = ["disabled", "placeholder"], Oe = {
|
|
20
20
|
key: 0,
|
|
21
21
|
class: "input-value"
|
|
22
22
|
}, xe = { class: "pl-dropdown__controls" }, Ae = {
|
|
23
23
|
key: 2,
|
|
24
24
|
class: "arrow-icon arrow-icon-default"
|
|
25
|
-
},
|
|
26
|
-
key: 0,
|
|
27
|
-
class: "nothing-found"
|
|
28
|
-
}, $e = {
|
|
25
|
+
}, De = { key: 0 }, Se = {
|
|
29
26
|
key: 0,
|
|
30
27
|
class: "pl-dropdown__error"
|
|
31
|
-
},
|
|
28
|
+
}, Be = {
|
|
32
29
|
key: 1,
|
|
33
30
|
class: "pl-dropdown__helper"
|
|
34
|
-
},
|
|
31
|
+
}, $e = {
|
|
35
32
|
key: 2,
|
|
36
33
|
class: "pl-dropdown__helper"
|
|
37
|
-
},
|
|
34
|
+
}, ze = {
|
|
38
35
|
name: "PlDropdown"
|
|
39
|
-
},
|
|
40
|
-
...
|
|
36
|
+
}, Ze = /* @__PURE__ */ le({
|
|
37
|
+
...ze,
|
|
41
38
|
props: {
|
|
42
39
|
modelValue: {},
|
|
43
40
|
label: { default: "" },
|
|
@@ -54,183 +51,174 @@ const be = ["tabindex"], Ve = { class: "pl-dropdown__container" }, Ce = { class:
|
|
|
54
51
|
optionSize: { default: "small" }
|
|
55
52
|
},
|
|
56
53
|
emits: ["update:modelValue"],
|
|
57
|
-
setup(
|
|
58
|
-
const
|
|
54
|
+
setup(T, { emit: F }) {
|
|
55
|
+
const b = F, r = T, N = se(), i = D(), w = D(), _ = ae("optionListRef"), o = ie({
|
|
59
56
|
search: "",
|
|
60
57
|
activeIndex: -1,
|
|
61
58
|
open: !1,
|
|
62
59
|
optionsHeight: 0
|
|
63
|
-
}), P = () =>
|
|
64
|
-
|
|
60
|
+
}), P = () => fe(
|
|
61
|
+
R.value.findIndex((e) => I(e.value, r.modelValue)),
|
|
65
62
|
(e) => e < 0 ? 0 : e
|
|
66
|
-
), q = () => o.activeIndex = P(),
|
|
67
|
-
if (!
|
|
68
|
-
if (
|
|
69
|
-
return Ie(
|
|
70
|
-
if (
|
|
63
|
+
), q = () => o.activeIndex = P(), h = s(() => r.options === void 0), k = s(() => h.value ? !0 : r.disabled), V = s(() => (r.options ?? []).findIndex((e) => I(e.value, r.modelValue))), L = s(() => {
|
|
64
|
+
if (!h.value) {
|
|
65
|
+
if (r.error)
|
|
66
|
+
return Ie(r.error);
|
|
67
|
+
if (r.modelValue !== void 0 && V.value === -1)
|
|
71
68
|
return "The selected value is not one of the options";
|
|
72
69
|
}
|
|
73
|
-
}),
|
|
74
|
-
() => _e(
|
|
70
|
+
}), C = s(
|
|
71
|
+
() => _e(r.options ?? []).map((e, t) => ({
|
|
75
72
|
...e,
|
|
76
73
|
index: t,
|
|
77
|
-
isSelected: t ===
|
|
74
|
+
isSelected: t === V.value,
|
|
78
75
|
isActive: t === o.activeIndex
|
|
79
76
|
}))
|
|
80
|
-
),
|
|
81
|
-
const t = f(
|
|
82
|
-
return (t == null ? void 0 : t.label) ||
|
|
83
|
-
}), H = s(() => !o.open &&
|
|
84
|
-
const e =
|
|
77
|
+
), E = s(() => {
|
|
78
|
+
const t = f(C).find((l) => I(l.value, r.modelValue));
|
|
79
|
+
return (t == null ? void 0 : t.label) || r.modelValue;
|
|
80
|
+
}), H = s(() => !o.open && r.modelValue ? "" : r.modelValue ? String(E.value) : r.placeholder), U = s(() => r.modelValue !== void 0 && r.modelValue !== null), K = s(() => {
|
|
81
|
+
const e = C.value;
|
|
85
82
|
return o.search ? e.filter((t) => {
|
|
86
|
-
const
|
|
87
|
-
return t.label.toLowerCase().includes(
|
|
83
|
+
const l = o.search.toLowerCase();
|
|
84
|
+
return t.label.toLowerCase().includes(l) || t.description && t.description.toLowerCase().includes(l) ? !0 : typeof t.value == "string" ? t.value.toLowerCase().includes(l) : t.value === o.search;
|
|
88
85
|
}) : e;
|
|
89
|
-
}), K = s(() => k.value ? void 0 : "0"),
|
|
86
|
+
}), { orderedRef: R, groupsRef: G, restRef: W } = Ve(K, "group"), j = s(() => k.value ? void 0 : "0"), O = (e) => {
|
|
90
87
|
var t;
|
|
91
|
-
|
|
92
|
-
},
|
|
88
|
+
b("update:modelValue", e), o.search = "", o.open = !1, (t = i == null ? void 0 : i.value) == null || t.focus();
|
|
89
|
+
}, J = (e) => {
|
|
90
|
+
O(e);
|
|
91
|
+
}, Q = () => b("update:modelValue", void 0), X = () => {
|
|
93
92
|
var e;
|
|
94
93
|
return (e = w.value) == null ? void 0 : e.focus();
|
|
95
|
-
},
|
|
94
|
+
}, Y = () => {
|
|
96
95
|
o.open = !o.open, o.open || (o.search = "");
|
|
97
|
-
},
|
|
98
|
-
var
|
|
96
|
+
}, Z = () => o.open = !0, ee = (e) => {
|
|
97
|
+
var l, c, p;
|
|
99
98
|
const t = e.relatedTarget;
|
|
100
|
-
!((
|
|
101
|
-
},
|
|
102
|
-
var
|
|
99
|
+
!((l = i.value) != null && l.contains(t)) && !((p = (c = _.value) == null ? void 0 : c.listRef) != null && p.contains(t)) && (o.search = "", o.open = !1);
|
|
100
|
+
}, oe = (e) => {
|
|
101
|
+
var x, A;
|
|
103
102
|
if (["ArrowDown", "ArrowUp", "Enter", "Escape"].includes(e.code))
|
|
104
103
|
e.preventDefault();
|
|
105
104
|
else
|
|
106
105
|
return;
|
|
107
|
-
const { open: t, activeIndex:
|
|
106
|
+
const { open: t, activeIndex: l } = o;
|
|
108
107
|
if (!t) {
|
|
109
108
|
e.code === "Enter" && (o.open = !0);
|
|
110
109
|
return;
|
|
111
110
|
}
|
|
112
|
-
e.code === "Escape" && (o.open = !1, (
|
|
113
|
-
const c =
|
|
114
|
-
if (!
|
|
111
|
+
e.code === "Escape" && (o.open = !1, (x = i.value) == null || x.focus());
|
|
112
|
+
const c = R.value, { length: p } = c;
|
|
113
|
+
if (!p)
|
|
115
114
|
return;
|
|
116
|
-
e.code === "Enter" &&
|
|
117
|
-
const
|
|
118
|
-
o.activeIndex =
|
|
115
|
+
e.code === "Enter" && O((A = c.find((y) => y.index === l)) == null ? void 0 : A.value);
|
|
116
|
+
const te = c.findIndex((y) => y.index === l) ?? -1, re = e.code === "ArrowDown" ? 1 : e.code === "ArrowUp" ? -1 : 0, ne = Math.abs(te + re + p) % p;
|
|
117
|
+
o.activeIndex = c[ne].index ?? -1;
|
|
119
118
|
};
|
|
120
|
-
return
|
|
119
|
+
return he(i), S(() => r.modelValue, q, { immediate: !0 }), S(
|
|
121
120
|
() => o.open,
|
|
122
121
|
(e) => {
|
|
123
122
|
var t;
|
|
124
123
|
return e ? (t = w.value) == null ? void 0 : t.focus() : "";
|
|
125
124
|
}
|
|
126
|
-
),
|
|
125
|
+
), de(() => {
|
|
127
126
|
var e;
|
|
128
|
-
o.search, o.activeIndex >= 0 && o.open && ((e =
|
|
129
|
-
}), (e, t) => (
|
|
127
|
+
o.search, o.activeIndex >= 0 && o.open && ((e = _.value) == null || e.scrollIntoActive());
|
|
128
|
+
}), (e, t) => (n(), a("div", {
|
|
130
129
|
class: "pl-dropdown__envelope",
|
|
131
|
-
onClick:
|
|
130
|
+
onClick: X
|
|
132
131
|
}, [
|
|
133
|
-
|
|
132
|
+
u("div", {
|
|
134
133
|
ref_key: "rootRef",
|
|
135
|
-
ref:
|
|
136
|
-
tabindex:
|
|
134
|
+
ref: i,
|
|
135
|
+
tabindex: j.value,
|
|
137
136
|
class: g(["pl-dropdown", { open: o.open, error: e.error, disabled: k.value }]),
|
|
138
|
-
onKeydown:
|
|
139
|
-
onFocusout:
|
|
137
|
+
onKeydown: oe,
|
|
138
|
+
onFocusout: ee
|
|
140
139
|
}, [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
u("div", Ce, [
|
|
141
|
+
u("div", Ee, [
|
|
142
|
+
ce(u("input", {
|
|
144
143
|
ref_key: "input",
|
|
145
144
|
ref: w,
|
|
146
|
-
"onUpdate:modelValue": t[0] || (t[0] = (
|
|
145
|
+
"onUpdate:modelValue": t[0] || (t[0] = (l) => o.search = l),
|
|
147
146
|
type: "text",
|
|
148
147
|
tabindex: "-1",
|
|
149
148
|
disabled: k.value,
|
|
150
149
|
placeholder: H.value,
|
|
151
150
|
spellcheck: "false",
|
|
152
151
|
autocomplete: "chrome-off",
|
|
153
|
-
onFocus:
|
|
154
|
-
}, null, 40,
|
|
155
|
-
[
|
|
152
|
+
onFocus: Z
|
|
153
|
+
}, null, 40, Re), [
|
|
154
|
+
[ue, o.search]
|
|
156
155
|
]),
|
|
157
|
-
o.open ?
|
|
158
|
-
|
|
159
|
-
default:
|
|
160
|
-
|
|
156
|
+
o.open ? d("", !0) : (n(), a("div", Oe, [
|
|
157
|
+
B(we, null, {
|
|
158
|
+
default: $(() => [
|
|
159
|
+
pe(m(E.value), 1)
|
|
161
160
|
]),
|
|
162
161
|
_: 1
|
|
163
162
|
})
|
|
164
163
|
])),
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
u("div", xe, [
|
|
165
|
+
h.value ? (n(), v(f(ye), {
|
|
167
166
|
key: 0,
|
|
168
167
|
name: "loading"
|
|
169
|
-
})) :
|
|
170
|
-
e.clearable && U.value ? (
|
|
168
|
+
})) : d("", !0),
|
|
169
|
+
e.clearable && U.value ? (n(), v(f(ke), {
|
|
171
170
|
key: 1,
|
|
172
171
|
class: "clear",
|
|
173
172
|
name: "delete-clear",
|
|
174
|
-
onClick:
|
|
175
|
-
})) :
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
onClick: M(Q, ["stop"])
|
|
174
|
+
})) : d("", !0),
|
|
175
|
+
z(e.$slots, "append"),
|
|
176
|
+
u("div", {
|
|
178
177
|
class: "pl-dropdown__arrow-wrapper",
|
|
179
|
-
onClick:
|
|
178
|
+
onClick: M(Y, ["stop"])
|
|
180
179
|
}, [
|
|
181
|
-
e.arrowIconLarge ? (
|
|
180
|
+
e.arrowIconLarge ? (n(), a("div", {
|
|
182
181
|
key: 0,
|
|
183
182
|
class: g(["arrow-icon", [`icon-24 ${e.arrowIconLarge}`]])
|
|
184
|
-
}, null, 2)) : e.arrowIcon ? (
|
|
183
|
+
}, null, 2)) : e.arrowIcon ? (n(), a("div", {
|
|
185
184
|
key: 1,
|
|
186
185
|
class: g(["arrow-icon", [`icon-16 ${e.arrowIcon}`]])
|
|
187
|
-
}, null, 2)) : (
|
|
186
|
+
}, null, 2)) : (n(), a("div", Ae))
|
|
188
187
|
])
|
|
189
188
|
])
|
|
190
189
|
]),
|
|
191
|
-
e.label ? (
|
|
192
|
-
e.required ? (
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
e.label ? (n(), a("label", De, [
|
|
191
|
+
e.required ? (n(), v(ge, { key: 0 })) : d("", !0),
|
|
192
|
+
u("span", null, m(e.label), 1),
|
|
193
|
+
N.tooltip ? (n(), v(f(ve), {
|
|
195
194
|
key: 1,
|
|
196
195
|
class: "info",
|
|
197
196
|
position: "top"
|
|
198
197
|
}, {
|
|
199
|
-
tooltip:
|
|
200
|
-
|
|
198
|
+
tooltip: $(() => [
|
|
199
|
+
z(e.$slots, "tooltip")
|
|
201
200
|
]),
|
|
202
201
|
_: 3
|
|
203
|
-
})) :
|
|
204
|
-
])) :
|
|
205
|
-
o.open ? (
|
|
202
|
+
})) : d("", !0)
|
|
203
|
+
])) : d("", !0),
|
|
204
|
+
o.open ? (n(), v(be, {
|
|
206
205
|
key: 1,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
option: n,
|
|
217
|
-
"is-selected": n.isSelected,
|
|
218
|
-
"is-hovered": n.isActive,
|
|
219
|
-
size: e.optionSize,
|
|
220
|
-
onClick: b((u) => S(n.value), ["stop"])
|
|
221
|
-
}, null, 8, ["option", "is-selected", "is-hovered", "size", "onClick"]))), 128)),
|
|
222
|
-
m.value.length ? i("", !0) : (r(), a("div", Se, "Nothing found"))
|
|
223
|
-
]),
|
|
224
|
-
_: 1
|
|
225
|
-
}, 8, ["root"])) : i("", !0),
|
|
226
|
-
F(fe, { class: "pl-dropdown__contour" })
|
|
206
|
+
ref_key: "optionListRef",
|
|
207
|
+
ref: _,
|
|
208
|
+
"root-ref": i.value,
|
|
209
|
+
groups: f(G),
|
|
210
|
+
rest: f(W),
|
|
211
|
+
"option-size": e.optionSize,
|
|
212
|
+
"select-option": J
|
|
213
|
+
}, null, 8, ["root-ref", "groups", "rest", "option-size"])) : d("", !0),
|
|
214
|
+
B(me, { class: "pl-dropdown__contour" })
|
|
227
215
|
])
|
|
228
|
-
], 42,
|
|
229
|
-
|
|
216
|
+
], 42, Le),
|
|
217
|
+
L.value ? (n(), a("div", Se, m(L.value), 1)) : h.value && e.loadingOptionsHelper ? (n(), a("div", Be, m(e.loadingOptionsHelper), 1)) : e.helper ? (n(), a("div", $e, m(e.helper), 1)) : d("", !0)
|
|
230
218
|
]));
|
|
231
219
|
}
|
|
232
220
|
});
|
|
233
221
|
export {
|
|
234
|
-
|
|
222
|
+
Ze as default
|
|
235
223
|
};
|
|
236
224
|
//# sourceMappingURL=PlDropdown.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlDropdown.vue.js","sources":["../../../src/components/PlDropdown/PlDropdown.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting one value from a list of options\n */\nexport default {\n name: 'PlDropdown',\n};\n</script>\n\n<script lang=\"ts\" setup generic=\"M = unknown\">\nimport './pl-dropdown.scss';\nimport { computed, reactive, ref, unref, useSlots, useTemplateRef, watch, watchPostEffect } from 'vue';\nimport { tap } from '../../helpers/functions';\nimport { PlTooltip } from '../PlTooltip';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport type { ListOption, ListOptionNormalized } from '../../types';\nimport { deepEqual } from '../../helpers/objects';\nimport DropdownListItem from '../DropdownListItem.vue';\nimport LongText from '../LongText.vue';\nimport { normalizeListOptions } from '../../helpers/utils';\nimport { PlIcon16 } from '../PlIcon16';\nimport { PlMaskIcon24 } from '../PlMaskIcon24';\nimport { DropdownOverlay } from '../../utils/DropdownOverlay';\nimport SvgRequired from '../../generated/components/svg/images/SvgRequired.vue';\nimport { getErrorMessage } from '../../helpers/error.ts';\n\nconst emit = defineEmits<{\n /**\n * Emitted when the model value is updated.\n */\n (e: 'update:modelValue', value: M | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected value of the dropdown.\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 * A helper text displayed below the dropdown when there are no options yet or options is undefined (optional).\n */\n loadingOptionsHelper?: 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 * Enables a button to clear the selected value (default: false)\n */\n clearable?: boolean;\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 * Custom icon (16px) class for the dropdown arrow (optional)\n */\n arrowIcon?: string;\n /**\n * Custom icon (24px) class for the dropdown arrow (optional)\n */\n arrowIconLarge?: string;\n /**\n * Option list item size\n */\n optionSize?: 'small' | 'medium';\n }>(),\n {\n label: '',\n helper: undefined,\n loadingOptionsHelper: undefined,\n error: undefined,\n placeholder: '...',\n clearable: false,\n required: false,\n disabled: false,\n arrowIcon: undefined,\n arrowIconLarge: undefined,\n optionSize: 'small',\n options: undefined,\n },\n);\n\nconst slots = defineSlots<{\n [key: string]: unknown;\n}>();\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst input = ref<HTMLInputElement | undefined>();\n\nconst overlayRef = useTemplateRef('overlay');\n\nconst data = reactive({\n search: '',\n activeIndex: -1,\n open: false,\n optionsHeight: 0,\n});\n\nconst findActiveIndex = () =>\n tap(\n filteredRef.value.findIndex((o) => deepEqual(o.value, props.modelValue)),\n (v) => (v < 0 ? 0 : v),\n );\n\nconst updateActive = () => (data.activeIndex = findActiveIndex());\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 selectedIndex = computed(() => {\n return (props.options ?? []).findIndex((o) => deepEqual(o.value, props.modelValue));\n});\n\nconst computedError = computed(() => {\n if (isLoadingOptions.value) {\n return undefined;\n }\n\n if (props.error) {\n return getErrorMessage(props.error);\n }\n\n if (props.modelValue !== undefined && selectedIndex.value === -1) {\n return 'The selected value is not one of the options';\n }\n\n return undefined;\n});\n\nconst optionsRef = computed(() =>\n normalizeListOptions(props.options ?? []).map((opt, index) => ({\n ...opt,\n index,\n isSelected: index === selectedIndex.value,\n isActive: index === data.activeIndex,\n })),\n);\n\nconst textValue = computed(() => {\n const options = unref(optionsRef);\n\n const item: ListOption | undefined = options.find((o) => deepEqual(o.value, props.modelValue));\n\n return item?.label || props.modelValue; // @todo show inner value?\n});\n\nconst computedPlaceholder = computed(() => {\n if (!data.open && props.modelValue) {\n return '';\n }\n\n return props.modelValue ? String(textValue.value) : props.placeholder;\n});\n\nconst hasValue = computed(() => {\n return props.modelValue !== undefined && props.modelValue !== null;\n});\n\nconst filteredRef = computed(() => {\n const options = optionsRef.value;\n\n if (data.search) {\n return options.filter((o: ListOptionNormalized) => {\n const search = data.search.toLowerCase();\n\n if (o.label.toLowerCase().includes(search)) {\n return true;\n }\n\n if (o.description && o.description.toLowerCase().includes(search)) {\n return true;\n }\n\n if (typeof o.value === 'string') {\n return o.value.toLowerCase().includes(search);\n }\n\n return o.value === data.search;\n });\n }\n\n return options;\n});\n\nconst tabindex = computed(() => (isDisabled.value ? undefined : '0'));\n\nconst selectOption = (v: M | undefined) => {\n emit('update:modelValue', v);\n data.search = '';\n data.open = false;\n rootRef?.value?.focus();\n};\n\nconst clear = () => emit('update:modelValue', undefined);\n\nconst setFocusOnInput = () => input.value?.focus();\n\nconst toggleOpen = () => {\n data.open = !data.open;\n if (!data.open) {\n data.search = '';\n }\n};\n\nconst onInputFocus = () => (data.open = true);\n\nconst onFocusOut = (event: FocusEvent) => {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!rootRef.value?.contains(relatedTarget) && !overlayRef.value?.listRef?.contains(relatedTarget)) {\n data.search = '';\n data.open = false;\n }\n};\n\nconst handleKeydown = (e: { code: string; preventDefault(): void }) => {\n if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(e.code)) {\n return;\n } else {\n e.preventDefault();\n }\n\n const { open, activeIndex } = 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 filtered = unref(filteredRef);\n\n const { length } = filtered;\n\n if (!length) {\n return;\n }\n\n if (e.code === 'Enter') {\n selectOption(filtered.find((it) => it.index === activeIndex)?.value);\n }\n\n const localIndex = filtered.findIndex((it) => it.index === activeIndex) ?? -1;\n\n const delta = e.code === 'ArrowDown' ? 1 : e.code === 'ArrowUp' ? -1 : 0;\n\n const newIndex = Math.abs(localIndex + delta + length) % length;\n\n data.activeIndex = filteredRef.value[newIndex].index ?? -1;\n};\n\nuseLabelNotch(rootRef);\n\nwatch(() => props.modelValue, updateActive, { immediate: true });\n\nwatch(\n () => data.open,\n (open) => (open ? input.value?.focus() : ''),\n);\n\nwatchPostEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n data.search; // to watch\n\n if (data.activeIndex >= 0 && data.open) {\n overlayRef.value?.scrollIntoActive();\n }\n});\n</script>\n\n<template>\n <div class=\"pl-dropdown__envelope\" @click=\"setFocusOnInput\">\n <div\n ref=\"rootRef\"\n :tabindex=\"tabindex\"\n class=\"pl-dropdown\"\n :class=\"{ open: data.open, error, disabled: isDisabled }\"\n @keydown=\"handleKeydown\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown__container\">\n <div class=\"pl-dropdown__field\">\n <input\n ref=\"input\"\n v-model=\"data.search\"\n type=\"text\"\n tabindex=\"-1\"\n :disabled=\"isDisabled\"\n :placeholder=\"computedPlaceholder\"\n spellcheck=\"false\"\n autocomplete=\"chrome-off\"\n @focus=\"onInputFocus\"\n />\n\n <div v-if=\"!data.open\" class=\"input-value\">\n <LongText> {{ textValue }} </LongText>\n </div>\n\n <div class=\"pl-dropdown__controls\">\n <PlMaskIcon24 v-if=\"isLoadingOptions\" name=\"loading\" />\n <PlIcon16 v-if=\"clearable && hasValue\" class=\"clear\" name=\"delete-clear\" @click.stop=\"clear\" />\n <slot name=\"append\" />\n <div class=\"pl-dropdown__arrow-wrapper\" @click.stop=\"toggleOpen\">\n <div v-if=\"arrowIconLarge\" class=\"arrow-icon\" :class=\"[`icon-24 ${arrowIconLarge}`]\" />\n <div v-else-if=\"arrowIcon\" class=\"arrow-icon\" :class=\"[`icon-16 ${arrowIcon}`]\" />\n <div v-else 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 v-if=\"data.open\" ref=\"overlay\" :root=\"rootRef\" class=\"pl-dropdown__options\" tabindex=\"-1\" :gap=\"3\">\n <DropdownListItem\n v-for=\"(item, index) in filteredRef\"\n :key=\"index\"\n :option=\"item\"\n :is-selected=\"item.isSelected\"\n :is-hovered=\"item.isActive\"\n :size=\"optionSize\"\n @click.stop=\"selectOption(item.value)\"\n />\n <div v-if=\"!filteredRef.length\" class=\"nothing-found\">Nothing found</div>\n </DropdownOverlay>\n <DoubleContour class=\"pl-dropdown__contour\" />\n </div>\n </div>\n <div v-if=\"computedError\" class=\"pl-dropdown__error\">{{ computedError }}</div>\n <div v-else-if=\"isLoadingOptions && loadingOptionsHelper\" class=\"pl-dropdown__helper\">{{ loadingOptionsHelper }}</div>\n <div v-else-if=\"helper\" class=\"pl-dropdown__helper\">{{ helper }}</div>\n </div>\n</template>\n"],"names":["__default__","emit","__emit","props","__props","slots","_useSlots","rootRef","ref","input","overlayRef","useTemplateRef","data","reactive","findActiveIndex","tap","filteredRef","o","deepEqual","v","updateActive","isLoadingOptions","computed","isDisabled","selectedIndex","computedError","getErrorMessage","optionsRef","normalizeListOptions","opt","index","textValue","item","unref","computedPlaceholder","hasValue","options","search","tabindex","selectOption","_a","clear","setFocusOnInput","toggleOpen","onInputFocus","onFocusOut","event","relatedTarget","_c","_b","handleKeydown","open","activeIndex","filtered","length","it","localIndex","delta","newIndex","useLabelNotch","watch","watchPostEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIeA,KAAA;AAAA,EACb,MAAM;AACR;;;;;;;;;;;;;;;;;;;AAqBA,UAAMC,IAAOC,GAOPC,IAAQC,GAuERC,IAAQC,GAEV,GAEEC,IAAUC,EAA6B,GACvCC,IAAQD,EAAkC,GAE1CE,IAAaC,GAAe,SAAS,GAErCC,IAAOC,GAAS;AAAA,MACpB,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,MAAM;AAAA,MACN,eAAe;AAAA,IAAA,CAChB,GAEKC,IAAkB,MACtBC;AAAA,MACEC,EAAY,MAAM,UAAU,CAACC,MAAMC,EAAUD,EAAE,OAAOd,EAAM,UAAU,CAAC;AAAA,MACvE,CAACgB,MAAOA,IAAI,IAAI,IAAIA;AAAA,IACtB,GAEIC,IAAe,MAAOR,EAAK,cAAcE,EAAgB,GAEzDO,IAAmBC,EAAS,MACzBnB,EAAM,YAAY,MAC1B,GAEKoB,IAAaD,EAAS,MACtBD,EAAiB,QACZ,KAGFlB,EAAM,QACd,GAEKqB,IAAgBF,EAAS,OACrBnB,EAAM,WAAW,CAAA,GAAI,UAAU,CAACc,MAAMC,EAAUD,EAAE,OAAOd,EAAM,UAAU,CAAC,CACnF,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EAAS,KAAK,CAACE,MAAOA,EAAG,UAAUH,CAAW,MAA9C,gBAAAH,EAAiD,KAAK;AAG/D,YAAAO,IAAaH,EAAS,UAAU,CAACE,MAAOA,EAAG,UAAUH,CAAW,KAAK,IAErEK,IAAQ,EAAE,SAAS,cAAc,IAAI,EAAE,SAAS,YAAY,KAAK,GAEjEC,KAAW,KAAK,IAAIF,IAAaC,IAAQH,CAAM,IAAIA;AAEzD,MAAA1C,EAAK,cAAcI,EAAY,MAAM0C,EAAQ,EAAE,SAAS;AAAA,IAC1D;AAEA,WAAAC,GAAcpD,CAAO,GAErBqD,EAAM,MAAMzD,EAAM,YAAYiB,GAAc,EAAE,WAAW,IAAM,GAE/DwC;AAAA,MACE,MAAMhD,EAAK;AAAA,MACX,CAACuC,MAAU;;AAAA,eAAAA,KAAOX,IAAA/B,EAAM,UAAN,gBAAA+B,EAAa,UAAU;AAAA;AAAA,IAC3C,GAEAqB,GAAgB,MAAM;;AAEf,MAAAjD,EAAA,QAEDA,EAAK,eAAe,KAAKA,EAAK,UAChC4B,IAAA9B,EAAW,UAAX,QAAA8B,EAAkB;AAAA,IACpB,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"PlDropdown.vue.js","sources":["../../../src/components/PlDropdown/PlDropdown.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting one value from a list of options\n */\nexport default {\n name: 'PlDropdown',\n};\n</script>\n\n<script lang=\"ts\" setup generic=\"M = unknown\">\nimport './pl-dropdown.scss';\nimport { computed, reactive, ref, unref, useTemplateRef, watch, watchPostEffect } from 'vue';\nimport { tap } from '../../helpers/functions';\nimport { PlTooltip } from '../PlTooltip';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport type { ListOption, ListOptionNormalized } from '../../types';\nimport { deepEqual } from '../../helpers/objects';\nimport LongText from '../LongText.vue';\nimport { normalizeListOptions } from '../../helpers/utils';\nimport { PlIcon16 } from '../PlIcon16';\nimport { PlMaskIcon24 } from '../PlMaskIcon24';\nimport SvgRequired from '../../generated/components/svg/images/SvgRequired.vue';\nimport { getErrorMessage } from '../../helpers/error.ts';\nimport OptionList from './OptionList.vue';\nimport { useGroupBy } from './useGroupBy';\nimport type { LOption } from './types';\n\nconst emit = defineEmits<{\n /**\n * Emitted when the model value is updated.\n */\n (e: 'update:modelValue', value: M | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected value of the dropdown.\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 * A helper text displayed below the dropdown when there are no options yet or options is undefined (optional).\n */\n loadingOptionsHelper?: 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 * Enables a button to clear the selected value (default: false)\n */\n clearable?: boolean;\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 * Custom icon (16px) class for the dropdown arrow (optional)\n */\n arrowIcon?: string;\n /**\n * Custom icon (24px) class for the dropdown arrow (optional)\n */\n arrowIconLarge?: string;\n /**\n * Option list item size\n */\n optionSize?: 'small' | 'medium';\n }>(),\n {\n label: '',\n helper: undefined,\n loadingOptionsHelper: undefined,\n error: undefined,\n placeholder: '...',\n clearable: false,\n required: false,\n disabled: false,\n arrowIcon: undefined,\n arrowIconLarge: undefined,\n optionSize: 'small',\n options: undefined,\n },\n);\n\nconst slots = defineSlots<{\n [key: string]: unknown;\n}>();\n\nconst rootRef = ref<HTMLElement | undefined>();\nconst input = ref<HTMLInputElement | undefined>();\n\nconst optionListRef = useTemplateRef<InstanceType<typeof OptionList>>('optionListRef');\n\nconst data = reactive({\n search: '',\n activeIndex: -1,\n open: false,\n optionsHeight: 0,\n});\n\nconst findActiveIndex = () =>\n tap(\n orderedRef.value.findIndex((o) => deepEqual(o.value, props.modelValue)),\n (v) => (v < 0 ? 0 : v),\n );\n\nconst updateActive = () => (data.activeIndex = findActiveIndex());\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 selectedIndex = computed(() => {\n return (props.options ?? []).findIndex((o) => deepEqual(o.value, props.modelValue));\n});\n\nconst computedError = computed(() => {\n if (isLoadingOptions.value) {\n return undefined;\n }\n\n if (props.error) {\n return getErrorMessage(props.error);\n }\n\n if (props.modelValue !== undefined && selectedIndex.value === -1) {\n return 'The selected value is not one of the options';\n }\n\n return undefined;\n});\n\nconst optionsRef = computed<LOption<M>[]>(() =>\n normalizeListOptions(props.options ?? []).map((opt, index) => ({\n ...opt,\n index,\n isSelected: index === selectedIndex.value,\n isActive: index === data.activeIndex,\n })),\n);\n\nconst textValue = computed(() => {\n const options = unref(optionsRef);\n\n const item: ListOption | undefined = options.find((o) => deepEqual(o.value, props.modelValue));\n\n return item?.label || props.modelValue; // @todo show inner value?\n});\n\nconst computedPlaceholder = computed(() => {\n if (!data.open && props.modelValue) {\n return '';\n }\n\n return props.modelValue ? String(textValue.value) : props.placeholder;\n});\n\nconst hasValue = computed(() => {\n return props.modelValue !== undefined && props.modelValue !== null;\n});\n\nconst filteredRef = computed(() => {\n const options = optionsRef.value;\n\n if (data.search) {\n return options.filter((o: ListOptionNormalized) => {\n const search = data.search.toLowerCase();\n\n if (o.label.toLowerCase().includes(search)) {\n return true;\n }\n\n if (o.description && o.description.toLowerCase().includes(search)) {\n return true;\n }\n\n if (typeof o.value === 'string') {\n return o.value.toLowerCase().includes(search);\n }\n\n return o.value === data.search;\n });\n }\n\n return options;\n});\n\nconst { orderedRef, groupsRef, restRef } = useGroupBy(filteredRef, 'group');\n\nconst tabindex = computed(() => (isDisabled.value ? undefined : '0'));\n\nconst selectOption = (v: M | undefined) => {\n emit('update:modelValue', v);\n data.search = '';\n data.open = false;\n rootRef?.value?.focus();\n};\n\nconst selectOptionWrapper = (v: unknown) => {\n selectOption(v as M | undefined);\n};\n\nconst clear = () => emit('update:modelValue', undefined);\n\nconst setFocusOnInput = () => input.value?.focus();\n\nconst toggleOpen = () => {\n data.open = !data.open;\n if (!data.open) {\n data.search = '';\n }\n};\n\nconst onInputFocus = () => (data.open = true);\n\nconst onFocusOut = (event: FocusEvent) => {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!rootRef.value?.contains(relatedTarget) && !optionListRef.value?.listRef?.contains(relatedTarget)) {\n data.search = '';\n data.open = false;\n }\n};\n\nconst handleKeydown = (e: { code: string; preventDefault(): void }) => {\n if (!['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(e.code)) {\n return;\n } else {\n e.preventDefault();\n }\n\n const { open, activeIndex } = 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 ordered = orderedRef.value;\n\n const { length } = ordered;\n\n if (!length) {\n return;\n }\n\n if (e.code === 'Enter') {\n selectOption(ordered.find((it) => it.index === activeIndex)?.value);\n }\n\n const localIndex = ordered.findIndex((it) => it.index === activeIndex) ?? -1;\n\n const delta = e.code === 'ArrowDown' ? 1 : e.code === 'ArrowUp' ? -1 : 0;\n\n const newIndex = Math.abs(localIndex + delta + length) % length;\n\n data.activeIndex = ordered[newIndex].index ?? -1;\n};\n\nuseLabelNotch(rootRef);\n\nwatch(() => props.modelValue, updateActive, { immediate: true });\n\nwatch(\n () => data.open,\n (open) => (open ? input.value?.focus() : ''),\n);\n\nwatchPostEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n data.search; // to watch\n\n if (data.activeIndex >= 0 && data.open) {\n optionListRef.value?.scrollIntoActive();\n }\n});\n</script>\n\n<template>\n <div class=\"pl-dropdown__envelope\" @click=\"setFocusOnInput\">\n <div\n ref=\"rootRef\"\n :tabindex=\"tabindex\"\n class=\"pl-dropdown\"\n :class=\"{ open: data.open, error, disabled: isDisabled }\"\n @keydown=\"handleKeydown\"\n @focusout=\"onFocusOut\"\n >\n <div class=\"pl-dropdown__container\">\n <div class=\"pl-dropdown__field\">\n <input\n ref=\"input\"\n v-model=\"data.search\"\n type=\"text\"\n tabindex=\"-1\"\n :disabled=\"isDisabled\"\n :placeholder=\"computedPlaceholder\"\n spellcheck=\"false\"\n autocomplete=\"chrome-off\"\n @focus=\"onInputFocus\"\n />\n\n <div v-if=\"!data.open\" class=\"input-value\">\n <LongText> {{ textValue }} </LongText>\n </div>\n\n <div class=\"pl-dropdown__controls\">\n <PlMaskIcon24 v-if=\"isLoadingOptions\" name=\"loading\" />\n <PlIcon16 v-if=\"clearable && hasValue\" class=\"clear\" name=\"delete-clear\" @click.stop=\"clear\" />\n <slot name=\"append\" />\n <div class=\"pl-dropdown__arrow-wrapper\" @click.stop=\"toggleOpen\">\n <div v-if=\"arrowIconLarge\" class=\"arrow-icon\" :class=\"[`icon-24 ${arrowIconLarge}`]\" />\n <div v-else-if=\"arrowIcon\" class=\"arrow-icon\" :class=\"[`icon-16 ${arrowIcon}`]\" />\n <div v-else 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 <OptionList\n v-if=\"data.open\"\n ref=\"optionListRef\"\n :root-ref=\"rootRef!\"\n :groups=\"groupsRef\"\n :rest=\"restRef\"\n :option-size=\"optionSize\"\n :select-option=\"selectOptionWrapper\"\n />\n <DoubleContour class=\"pl-dropdown__contour\" />\n </div>\n </div>\n <div v-if=\"computedError\" class=\"pl-dropdown__error\">{{ computedError }}</div>\n <div v-else-if=\"isLoadingOptions && loadingOptionsHelper\" class=\"pl-dropdown__helper\">{{ loadingOptionsHelper }}</div>\n <div v-else-if=\"helper\" class=\"pl-dropdown__helper\">{{ helper }}</div>\n </div>\n</template>\n"],"names":["__default__","emit","__emit","props","__props","slots","_useSlots","rootRef","ref","input","optionListRef","useTemplateRef","data","reactive","findActiveIndex","tap","orderedRef","o","deepEqual","v","updateActive","isLoadingOptions","computed","isDisabled","selectedIndex","computedError","getErrorMessage","optionsRef","normalizeListOptions","opt","index","textValue","item","unref","computedPlaceholder","hasValue","filteredRef","options","search","groupsRef","restRef","useGroupBy","tabindex","selectOption","_a","selectOptionWrapper","clear","setFocusOnInput","toggleOpen","onInputFocus","onFocusOut","event","relatedTarget","_c","_b","handleKeydown","open","activeIndex","ordered","length","it","localIndex","delta","newIndex","useLabelNotch","watch","watchPostEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIeA,KAAA;AAAA,EACb,MAAM;AACR;;;;;;;;;;;;;;;;;;;AAsBA,UAAMC,IAAOC,GAOPC,IAAQC,GAuERC,IAAQC,GAEV,GAEEC,IAAUC,EAA6B,GACvCC,IAAQD,EAAkC,GAE1CE,IAAgBC,GAAgD,eAAe,GAE/EC,IAAOC,GAAS;AAAA,MACpB,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,MAAM;AAAA,MACN,eAAe;AAAA,IAAA,CAChB,GAEKC,IAAkB,MACtBC;AAAA,MACEC,EAAW,MAAM,UAAU,CAACC,MAAMC,EAAUD,EAAE,OAAOd,EAAM,UAAU,CAAC;AAAA,MACtE,CAACgB,MAAOA,IAAI,IAAI,IAAIA;AAAA,IACtB,GAEIC,IAAe,MAAOR,EAAK,cAAcE,EAAgB,GAEzDO,IAAm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.ts","sourceRoot":"","sources":["../../../src/components/PlDropdown/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,OAAO,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export declare function useGroupBy<T, K extends keyof T>(list: Ref<T[]>, byKey: K): {
|
|
3
|
+
orderedRef: import('vue').ComputedRef<T[]>;
|
|
4
|
+
groupsRef: import('vue').ComputedRef<Map<NonNullable<T[K]>, T[]>>;
|
|
5
|
+
restRef: import('vue').ComputedRef<T[]>;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useGroupBy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGroupBy.d.ts","sourceRoot":"","sources":["../../../src/components/PlDropdown/useGroupBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AA6C/B,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAC7C,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EACd,KAAK,EAAE,CAAC;;;;EAeT"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { computed as c } from "vue";
|
|
2
|
+
function d(o, t) {
|
|
3
|
+
var u;
|
|
4
|
+
const e = /* @__PURE__ */ new Map();
|
|
5
|
+
if (!o)
|
|
6
|
+
return {
|
|
7
|
+
grouped: e,
|
|
8
|
+
rest: [],
|
|
9
|
+
ordered: []
|
|
10
|
+
};
|
|
11
|
+
for (const s of o) {
|
|
12
|
+
const r = s[t];
|
|
13
|
+
r !== void 0 && r !== null && (e.has(r) || e.set(r, []), (u = e.get(r)) == null || u.push(s));
|
|
14
|
+
}
|
|
15
|
+
const n = o.filter((s) => {
|
|
16
|
+
const r = s[t];
|
|
17
|
+
return r == null;
|
|
18
|
+
}), f = [...Array.from(e.values()).flat(), ...n];
|
|
19
|
+
return {
|
|
20
|
+
grouped: e,
|
|
21
|
+
rest: n,
|
|
22
|
+
ordered: f
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function l(o, t) {
|
|
26
|
+
const e = c(() => d(o.value, t)), n = c(() => e.value.ordered), f = c(() => e.value.grouped), u = c(() => e.value.rest);
|
|
27
|
+
return {
|
|
28
|
+
orderedRef: n,
|
|
29
|
+
groupsRef: f,
|
|
30
|
+
restRef: u
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
l as useGroupBy
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useGroupBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGroupBy.js","sources":["../../../src/components/PlDropdown/useGroupBy.ts"],"sourcesContent":["import type { Ref } from 'vue';\nimport { computed } from 'vue';\n\nfunction groupBy<T, K extends keyof T>(\n list: T[],\n groupBy: K,\n): {\n grouped: Map<NonNullable<T[K]>, T[]>;\n rest: T[];\n ordered: T[];\n } {\n const grouped: Map<NonNullable<T[K]>, T[]> = new Map();\n\n if (!list) {\n return {\n grouped,\n rest: [],\n ordered: [],\n };\n }\n\n // Group items by the specified key\n for (const item of list) {\n const key = item[groupBy];\n if (key === undefined) continue;\n if (key === null) continue;\n if (!grouped.has(key)) grouped.set(key, []);\n grouped.get(key)?.push(item);\n }\n\n // Items without a group key\n const rest = list.filter((item: T) => {\n const key = item[groupBy];\n return key === undefined || key === null;\n });\n\n const ordered = [...Array.from(grouped.values()).flat(), ...rest];\n\n return {\n grouped,\n rest,\n ordered,\n };\n}\n\nexport function useGroupBy<T, K extends keyof T>(\n list: Ref<T[]>,\n byKey: K,\n) {\n const result = computed(() => groupBy(list.value, byKey));\n\n const orderedRef = computed(() => result.value.ordered);\n\n const groupsRef = computed(() => result.value.grouped);\n\n const restRef = computed(() => result.value.rest);\n\n return {\n orderedRef,\n groupsRef,\n restRef,\n };\n}\n"],"names":["groupBy","list","grouped","item","key","_a","rest","ordered","useGroupBy","byKey","result","computed","orderedRef","groupsRef","restRef"],"mappings":";AAGA,SAASA,EACPC,GACAD,GAKE;;AACI,QAAAE,wBAA2C,IAAI;AAErD,MAAI,CAACD;AACI,WAAA;AAAA,MACL,SAAAC;AAAA,MACA,MAAM,CAAC;AAAA,MACP,SAAS,CAAA;AAAA,IACX;AAIF,aAAWC,KAAQF,GAAM;AACjB,UAAAG,IAAMD,EAAKH,CAAO;AACxB,IAAII,MAAQ,UACRA,MAAQ,SACPF,EAAQ,IAAIE,CAAG,KAAWF,EAAA,IAAIE,GAAK,EAAE,IAC1CC,IAAAH,EAAQ,IAAIE,CAAG,MAAf,QAAAC,EAAkB,KAAKF;AAAA,EAAI;AAI7B,QAAMG,IAAOL,EAAK,OAAO,CAACE,MAAY;AAC9B,UAAAC,IAAMD,EAAKH,CAAO;AACjB,WAAqBI,KAAQ;AAAA,EAAA,CACrC,GAEKG,IAAU,CAAC,GAAG,MAAM,KAAKL,EAAQ,OAAO,CAAC,EAAE,QAAQ,GAAGI,CAAI;AAEzD,SAAA;AAAA,IACL,SAAAJ;AAAA,IACA,MAAAI;AAAA,IACA,SAAAC;AAAA,EACF;AACF;AAEgB,SAAAC,EACdP,GACAQ,GACA;AACA,QAAMC,IAASC,EAAS,MAAMX,EAAQC,EAAK,OAAOQ,CAAK,CAAC,GAElDG,IAAaD,EAAS,MAAMD,EAAO,MAAM,OAAO,GAEhDG,IAAYF,EAAS,MAAMD,EAAO,MAAM,OAAO,GAE/CI,IAAUH,EAAS,MAAMD,EAAO,MAAM,IAAI;AAEzC,SAAA;AAAA,IACL,YAAAE;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,EACF;AACF;"}
|
|
@@ -115,8 +115,8 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{
|
|
|
115
115
|
helper: string;
|
|
116
116
|
placeholder: string;
|
|
117
117
|
clearable: boolean;
|
|
118
|
-
loadingOptionsHelper: string;
|
|
119
118
|
optionSize: "small" | "medium";
|
|
119
|
+
loadingOptionsHelper: string;
|
|
120
120
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, {
|
|
121
121
|
tooltip?(_: {}): any;
|
|
122
122
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlDropdownRef.vue.d.ts","sourceRoot":"","sources":["../../../src/components/PlDropdownRef/PlDropdownRef.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlDropdownRef.vue.d.ts","sourceRoot":"","sources":["../../../src/components/PlDropdownRef/PlDropdownRef.vue"],"names":[],"mappings":"AAgHA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKvD;;GAEG;;IAcC;;OAEG;gBACS,QAAQ,GAAG,SAAS;IAChC;;OAEG;YACK,MAAM;IACd;;OAEG;cACO,QAAQ,CAAC,SAAS,EAAE,CAAC;IAC/B;;OAEG;aACM,MAAM;IACf;;OAEG;2BACoB,MAAM;IAC7B;;OAEG;YACK,OAAO;IACf;;OAEG;kBACW,MAAM;IACpB;;OAEG;gBACS,OAAO;IACnB;;OAEG;eACQ,OAAO;IAClB;;OAEG;eACQ,OAAO;IAClB;;OAEG;iBACU,OAAO,GAAG,QAAQ;;;;;;;;;IA3C/B;;OAEG;gBACS,QAAQ,GAAG,SAAS;IAChC;;OAEG;YACK,MAAM;IACd;;OAEG;cACO,QAAQ,CAAC,SAAS,EAAE,CAAC;IAC/B;;OAEG;aACM,MAAM;IACf;;OAEG;2BACoB,MAAM;IAC7B;;OAEG;YACK,OAAO;IACf;;OAEG;kBACW,MAAM;IACpB;;OAEG;gBACS,OAAO;IACnB;;OAEG;eACQ,OAAO;IAClB;;OAEG;eACQ,OAAO;IAClB;;OAEG;iBACU,OAAO,GAAG,QAAQ;;;;;;;;;aAhCrB,QAAQ,CAAC,SAAS,EAAE,CAAC;;WAJvB,MAAM;cA4BH,OAAO;cAIP,OAAO;YAxBT,MAAM;iBAYD,MAAM;eAIR,OAAO;gBAYN,OAAO,GAAG,QAAQ;0BAxBR,MAAM;;qBA+GJ,GAAG;;AA/IhC,wBA4LK;AAcL,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as s, useSlots as u, computed as t, createBlock as f, openBlock as m, unref as a, mergeProps as c, createSlots as
|
|
1
|
+
import { defineComponent as s, useSlots as u, computed as t, createBlock as f, openBlock as m, unref as a, mergeProps as c, createSlots as g, withCtx as v, renderSlot as b } from "vue";
|
|
2
2
|
import _ from "../PlDropdown/PlDropdown.vue.js";
|
|
3
3
|
const k = {
|
|
4
4
|
name: "PlDropdownRef"
|
|
@@ -19,25 +19,26 @@ const k = {
|
|
|
19
19
|
},
|
|
20
20
|
emits: ["update:modelValue"],
|
|
21
21
|
setup(n) {
|
|
22
|
-
const
|
|
22
|
+
const r = u(), l = n, i = t(
|
|
23
23
|
() => {
|
|
24
24
|
var e;
|
|
25
25
|
return (e = l.options) == null ? void 0 : e.map((o) => ({
|
|
26
26
|
label: o.label,
|
|
27
|
-
value: o.ref
|
|
27
|
+
value: o.ref,
|
|
28
|
+
group: o.group
|
|
28
29
|
}));
|
|
29
30
|
}
|
|
30
|
-
),
|
|
31
|
+
), d = t(() => l.disabled ? "icon-link-disabled" : "icon-link");
|
|
31
32
|
return (e, o) => (m(), f(a(_), c(l, {
|
|
32
|
-
options:
|
|
33
|
+
options: i.value,
|
|
33
34
|
"loading-options-helper": e.loadingOptionsHelper,
|
|
34
|
-
"arrow-icon-large":
|
|
35
|
+
"arrow-icon-large": d.value,
|
|
35
36
|
"onUpdate:modelValue": o[0] || (o[0] = (p) => e.$emit("update:modelValue", p))
|
|
36
|
-
}),
|
|
37
|
-
a(
|
|
37
|
+
}), g({ _: 2 }, [
|
|
38
|
+
a(r).tooltip ? {
|
|
38
39
|
name: "tooltip",
|
|
39
|
-
fn:
|
|
40
|
-
|
|
40
|
+
fn: v(() => [
|
|
41
|
+
b(e.$slots, "tooltip")
|
|
41
42
|
]),
|
|
42
43
|
key: "0"
|
|
43
44
|
} : void 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlDropdownRef.vue.js","sources":["../../../src/components/PlDropdownRef/PlDropdownRef.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting one value from a list of options\n */\nexport default {\n name: 'PlDropdownRef',\n};\n</script>\n\n<script lang=\"ts\" setup>\nimport type { ModelRef, RefOption } from '../../types';\nimport { PlDropdown } from '../PlDropdown';\nimport { computed, useSlots } from 'vue';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst slots: any = useSlots();\n\ndefineEmits<{\n /**\n * Emitted when the model value is updated.\n */\n (e: 'update:modelValue', value: ModelRef | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected ref of the dropdown.\n */\n modelValue: ModelRef | undefined;\n /**\n * The label text for the dropdown field (optional)\n */\n label?: string;\n /**\n * List of available ref options for the dropdown\n */\n options?: Readonly<RefOption[]>;\n /**\n * A helper text displayed below the dropdown when there are no errors (optional).\n */\n helper?: string;\n /**\n * A helper text displayed below the dropdown when there are no options yet or options is undefined (optional).\n */\n loadingOptionsHelper?: 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 * Enables a button to clear the selected value (default: false)\n */\n clearable?: boolean;\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 * Option list item size\n */\n optionSize?: 'small' | 'medium';\n }>(),\n {\n label: '',\n helper: undefined,\n loadingOptionsHelper: undefined,\n error: undefined,\n placeholder: '...',\n clearable: false,\n required: false,\n disabled: false,\n arrowIcon: undefined,\n optionSize: 'small',\n options: undefined,\n },\n);\n\nconst options = computed(() =>\n props.options?.map((opt) => ({\n label: opt.label,\n value: opt.ref,\n })),\n);\n\nconst arrowIcon = computed(() => (props.disabled ? 'icon-link-disabled' : 'icon-link'));\n</script>\n\n<template>\n <PlDropdown\n v-bind=\"props\"\n :options=\"options\"\n :loading-options-helper=\"loadingOptionsHelper\"\n :arrow-icon-large=\"arrowIcon\"\n @update:model-value=\"$emit('update:modelValue', $event)\"\n >\n <template v-if=\"slots.tooltip\" #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlDropdown>\n</template>\n"],"names":["__default__","slots","useSlots","props","__props","options","computed","_a","opt","arrowIcon"],"mappings":";;AAIA,MAAeA,IAAA;AAAA,EACb,MAAM;AACR;;;;;;;;;;;;;;;;;AASA,UAAMC,IAAaC,EAAS,GAStBC,IAAQC,GA8DRC,IAAUC;AAAA,MAAS,MAAA;;AACvB,gBAAAC,IAAAJ,EAAM,YAAN,gBAAAI,EAAe,IAAI,CAACC,OAAS;AAAA,UAC3B,OAAOA,EAAI;AAAA,UACX,OAAOA,EAAI;AAAA,QAAA;AAAA;AAAA,IAEf,GAEMC,IAAYH,EAAS,MAAOH,EAAM,WAAW,uBAAuB,WAAY;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"PlDropdownRef.vue.js","sources":["../../../src/components/PlDropdownRef/PlDropdownRef.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * A component for selecting one value from a list of options\n */\nexport default {\n name: 'PlDropdownRef',\n};\n</script>\n\n<script lang=\"ts\" setup>\nimport type { ModelRef, RefOption } from '../../types';\nimport { PlDropdown } from '../PlDropdown';\nimport { computed, useSlots } from 'vue';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst slots: any = useSlots();\n\ndefineEmits<{\n /**\n * Emitted when the model value is updated.\n */\n (e: 'update:modelValue', value: ModelRef | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current selected ref of the dropdown.\n */\n modelValue: ModelRef | undefined;\n /**\n * The label text for the dropdown field (optional)\n */\n label?: string;\n /**\n * List of available ref options for the dropdown\n */\n options?: Readonly<RefOption[]>;\n /**\n * A helper text displayed below the dropdown when there are no errors (optional).\n */\n helper?: string;\n /**\n * A helper text displayed below the dropdown when there are no options yet or options is undefined (optional).\n */\n loadingOptionsHelper?: 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 * Enables a button to clear the selected value (default: false)\n */\n clearable?: boolean;\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 * Option list item size\n */\n optionSize?: 'small' | 'medium';\n }>(),\n {\n label: '',\n helper: undefined,\n loadingOptionsHelper: undefined,\n error: undefined,\n placeholder: '...',\n clearable: false,\n required: false,\n disabled: false,\n arrowIcon: undefined,\n optionSize: 'small',\n options: undefined,\n },\n);\n\nconst options = computed(() =>\n props.options?.map((opt) => ({\n label: opt.label,\n value: opt.ref,\n group: opt.group,\n })),\n);\n\nconst arrowIcon = computed(() => (props.disabled ? 'icon-link-disabled' : 'icon-link'));\n</script>\n\n<template>\n <PlDropdown\n v-bind=\"props\"\n :options=\"options\"\n :loading-options-helper=\"loadingOptionsHelper\"\n :arrow-icon-large=\"arrowIcon\"\n @update:model-value=\"$emit('update:modelValue', $event)\"\n >\n <template v-if=\"slots.tooltip\" #tooltip>\n <slot name=\"tooltip\" />\n </template>\n </PlDropdown>\n</template>\n"],"names":["__default__","slots","useSlots","props","__props","options","computed","_a","opt","arrowIcon"],"mappings":";;AAIA,MAAeA,IAAA;AAAA,EACb,MAAM;AACR;;;;;;;;;;;;;;;;;AASA,UAAMC,IAAaC,EAAS,GAStBC,IAAQC,GA8DRC,IAAUC;AAAA,MAAS,MAAA;;AACvB,gBAAAC,IAAAJ,EAAM,YAAN,gBAAAI,EAAe,IAAI,CAACC,OAAS;AAAA,UAC3B,OAAOA,EAAI;AAAA,UACX,OAAOA,EAAI;AAAA,UACX,OAAOA,EAAI;AAAA,QAAA;AAAA;AAAA,IAEf,GAEMC,IAAYH,EAAS,MAAOH,EAAM,WAAW,uBAAuB,WAAY;;;;;;;;;;;;;;;;;"}
|