@aotearoan/neon 9.0.0-beta-1 → 9.0.2-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/presentation/dropdown/NeonDropdown.cjs.js +1 -1
- package/dist/components/presentation/dropdown/NeonDropdown.d.ts +12 -0
- package/dist/components/presentation/dropdown/NeonDropdown.es.js +4 -2
- package/dist/components/presentation/dropdown/NeonDropdown.es.js.map +1 -1
- package/dist/components/presentation/dropdown/NeonDropdown.ts_vue_type_script_src_4222fb80_lang.cjs.js +1 -1
- package/dist/components/presentation/dropdown/NeonDropdown.ts_vue_type_script_src_4222fb80_lang.cjs.js.map +1 -1
- package/dist/components/presentation/dropdown/NeonDropdown.ts_vue_type_script_src_4222fb80_lang.es.js +1 -0
- package/dist/components/presentation/dropdown/NeonDropdown.ts_vue_type_script_src_4222fb80_lang.es.js.map +1 -1
- package/dist/components/user-input/field/NeonField.cjs.js +1 -1
- package/dist/components/user-input/field/NeonField.es.js +3 -1
- package/dist/components/user-input/field/NeonField.es.js.map +1 -1
- package/dist/components/user-input/select/NeonSelect.cjs.js +1 -1
- package/dist/components/user-input/select/NeonSelect.d.ts +12 -0
- package/dist/components/user-input/select/NeonSelect.es.js +33 -32
- package/dist/components/user-input/select/NeonSelect.es.js.map +1 -1
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js +1 -1
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js.map +1 -1
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_37fb08e4_lang.es.js +1 -0
- package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_37fb08e4_lang.es.js.map +1 -1
- package/package.json +1 -1
- package/src/sass/components/_card.scss +1 -1
- package/src/sass/components/_field.scss +6 -1
- package/src/sass/global/_base-html.scss +1 -4
- package/src/sass/global/_typography.scss +4 -9
- package/src/sass/includes/_typography.scss +9 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=require("./NeonDropdown.ts_vue_type_script_src_4222fb80_lang.cjs.js"),o=require("vue"),a=require("../../../_virtual/plugin-vue_export-helper.cjs.js");const s={ref:"dropdownButton"},p={key:0,class:"neon-dropdown__button-wrapper"},u=["id","tabindex"],b=o.createElementVNode("div",{class:"neon-dropdown__click-blocker"},null,-1);function w(e,n,m,g,c,k){const r=o.resolveComponent("neon-button"),l=o.resolveComponent("neon-badge"),i=o.resolveComponent("neon-expansion-indicator");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass([[{"neon-dropdown--with-indicator":e.indicator,"neon-dropdown--open":e.modelValue,"neon-dropdown--open-on-hover":e.openOnHover,"neon-dropdown--icon-only":e.icon&&!e.label,"neon-dropdown--disabled":e.disabled},`neon-dropdown--${e.size}`,`neon-dropdown--${e.color}`],"neon-dropdown"])},[o.createElementVNode("div",s,[o.renderSlot(e.$slots,"dropdown-button",{},()=>[e.dropdownStyle==="text-button"||e.dropdownStyle==="solid-button"?(o.openBlock(),o.createElementBlock("div",p,[o.createVNode(r,{id:e.id,"alternate-color":e.alternateColor,"aria-expanded":e.modelValue,"button-style":e.dropdownStyle==="text-button"?"text":"solid",color:e.color,disabled:e.disabled,icon:e.icon,indicator:e.indicator,"indicator-expanded":e.modelValue,label:e.label,size:e.size,"aria-haspopup":"true",class:"neon-dropdown__button",onBlur:n[0]||(n[0]=d=>e.onBlur()),onClick:n[1]||(n[1]=d=>e.toggleOpen()),onFocus:n[2]||(n[2]=d=>e.onFocus())},null,8,["id","alternate-color","aria-expanded","button-style","color","disabled","icon","indicator","indicator-expanded","label","size"])])):(o.openBlock(),o.createElementBlock("div",{key:1,id:e.id,ref:"dropdownButton",tabindex:e.disabled?void 0:0,class:"neon-dropdown__badge",role:"button",onClick:n[3]||(n[3]=(...d)=>e.toggleOpen&&e.toggleOpen(...d)),onKeydown:[n[4]||(n[4]=o.withKeys((...d)=>e.toggleOpen&&e.toggleOpen(...d),["enter"])),n[5]||(n[5]=o.withKeys(o.withModifiers((...d)=>e.toggleOpen&&e.toggleOpen(...d),["stop","prevent"]),["space"]))]},[o.createVNode(l,{"alternate-color":e.alternateColor,circular:e.dropdownStyle==="circular-badge",color:e.color,disabled:e.disabled,icon:e.icon,image:e.image,imageAlt:e.imageAlt,label:e.label,size:e.size},null,8,["alternate-color","circular","color","disabled","icon","image","imageAlt","label","size"]),e.indicator?(o.openBlock(),o.createBlock(i,{key:0,color:e.color,disabled:e.disabled,expanded:e.modelValue,class:"neon-button__indicator"},null,8,["color","disabled","expanded"])):o.createCommentVNode("",!0)],40,u))])],512),b,o.withDirectives(o.createElementVNode("div",{ref:"dropdownContent",class:o.normalizeClass([`neon-dropdown__content--${e.dropdownPlacement}`,"neon-dropdown__content"])},[o.renderSlot(e.$slots,"default")],2),[[o.vShow,e.openOnHover||e.modelValue]])],2)}var v=a(t,[["render",w],["__file","/Users/andrew/dev/projects/neon/src/components/presentation/dropdown/NeonDropdown.vue"]]);module.exports=v;
|
|
2
2
|
//# sourceMappingURL=NeonDropdown.cjs.js.map
|
|
@@ -12,6 +12,12 @@ import { NeonDropdownStyle } from '@/common/enums/NeonDropdownStyle';
|
|
|
12
12
|
* <strong>NeonSelect</strong> form component.</p>
|
|
13
13
|
*/
|
|
14
14
|
declare const _default: import("vue").DefineComponent<{
|
|
15
|
+
/**
|
|
16
|
+
* Id for the dropdown button.
|
|
17
|
+
*/
|
|
18
|
+
id: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
};
|
|
15
21
|
/**
|
|
16
22
|
* Whether the dropdown is currently open.
|
|
17
23
|
*/
|
|
@@ -126,6 +132,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
126
132
|
onBlur: () => void;
|
|
127
133
|
onFocus: () => void;
|
|
128
134
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "focus" | "blur" | "dropdown-placement" | "button-ref")[], "update:modelValue" | "focus" | "blur" | "dropdown-placement" | "button-ref", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
135
|
+
/**
|
|
136
|
+
* Id for the dropdown button.
|
|
137
|
+
*/
|
|
138
|
+
id: {
|
|
139
|
+
type: StringConstructor;
|
|
140
|
+
};
|
|
129
141
|
/**
|
|
130
142
|
* Whether the dropdown is currently open.
|
|
131
143
|
*/
|
|
@@ -6,7 +6,7 @@ const _hoisted_2 = {
|
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "neon-dropdown__button-wrapper"
|
|
8
8
|
};
|
|
9
|
-
const _hoisted_3 = ["tabindex"];
|
|
9
|
+
const _hoisted_3 = ["id", "tabindex"];
|
|
10
10
|
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "neon-dropdown__click-blocker" }, null, -1);
|
|
11
11
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
12
12
|
const _component_neon_button = resolveComponent("neon-button");
|
|
@@ -29,6 +29,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
29
29
|
renderSlot(_ctx.$slots, "dropdown-button", {}, () => [
|
|
30
30
|
_ctx.dropdownStyle === "text-button" || _ctx.dropdownStyle === "solid-button" ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
31
31
|
createVNode(_component_neon_button, {
|
|
32
|
+
id: _ctx.id,
|
|
32
33
|
"alternate-color": _ctx.alternateColor,
|
|
33
34
|
"aria-expanded": _ctx.modelValue,
|
|
34
35
|
"button-style": _ctx.dropdownStyle === "text-button" ? "text" : "solid",
|
|
@@ -44,9 +45,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
44
45
|
onBlur: _cache[0] || (_cache[0] = ($event) => _ctx.onBlur()),
|
|
45
46
|
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.toggleOpen()),
|
|
46
47
|
onFocus: _cache[2] || (_cache[2] = ($event) => _ctx.onFocus())
|
|
47
|
-
}, null, 8, ["alternate-color", "aria-expanded", "button-style", "color", "disabled", "icon", "indicator", "indicator-expanded", "label", "size"])
|
|
48
|
+
}, null, 8, ["id", "alternate-color", "aria-expanded", "button-style", "color", "disabled", "icon", "indicator", "indicator-expanded", "label", "size"])
|
|
48
49
|
])) : (openBlock(), createElementBlock("div", {
|
|
49
50
|
key: 1,
|
|
51
|
+
id: _ctx.id,
|
|
50
52
|
ref: "dropdownButton",
|
|
51
53
|
tabindex: !_ctx.disabled ? 0 : void 0,
|
|
52
54
|
class: "neon-dropdown__badge",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonDropdown.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NeonDropdown.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("vue"),p=require("../../../common/enums/NeonDropdownPlacement.cjs.js"),f=require("../../../common/utils/NeonDropdownPlacementUtils.cjs.js"),w=require("../../../common/utils/NeonClosableUtils.cjs.js"),N=require("../../../common/enums/NeonSize.cjs.js"),
|
|
1
|
+
"use strict";var n=require("vue"),p=require("../../../common/enums/NeonDropdownPlacement.cjs.js"),f=require("../../../common/utils/NeonDropdownPlacementUtils.cjs.js"),w=require("../../../common/utils/NeonClosableUtils.cjs.js"),N=require("../../../common/enums/NeonSize.cjs.js"),y=require("../../../common/enums/NeonFunctionalColor.cjs.js"),j=require("../../../common/enums/NeonDropdownStyle.cjs.js"),S=require("../badge/NeonBadge.cjs.js"),g=require("../../user-input/button/NeonButton.cjs.js"),C=require("../expansion-indicator/NeonExpansionIndicator.cjs.js"),b=n.defineComponent({name:"NeonDropdown",components:{NeonBadge:S,NeonButton:g,NeonExpansionIndicator:C},props:{id:{type:String},modelValue:{type:Boolean,required:!0},label:{type:String,default:null},image:{type:String,default:null},imageAlt:{type:String,default:null},icon:{type:String,default:null},indicator:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},size:{type:String,default:N.NeonSize.Medium},color:{type:String,default:y.NeonFunctionalColor.LowContrast},alternateColor:{type:String,default:null},dropdownStyle:{type:String,default:j.NeonDropdownStyle.SolidButton},placement:{type:String,default:p.NeonDropdownPlacement.BottomLeft},placementContainer:{type:Object,default:null},openOnHover:{type:Boolean,default:!1}},emits:["update:modelValue","dropdown-placement","blur","focus","button-ref"],setup(e,{emit:t}){const r=n.ref(null),l=n.ref(null),a=n.ref(e.placement),u=n.ref(null),s=()=>{t("update:modelValue",!1)},d=()=>{e.modelValue&&s()},o=()=>{if(e.modelValue&&r.value&&l.value){const i=a.value;a.value=f.NeonDropdownPlacementUtils.calculatePlacement(r.value,l.value,e.placement,e.placementContainer),i!==a.value&&t("dropdown-placement",a.value)}},c=()=>{!e.disabled&&!e.openOnHover&&(t("update:modelValue",!e.modelValue),setTimeout(o))},m=()=>{t("blur")},v=()=>{t("focus")};return n.onMounted(()=>{!e.openOnHover&&l.value&&(u.value=new w.NeonClosableUtils(l.value,d)),window.addEventListener("resize",o,{passive:!0}),window.addEventListener("scroll",o,{passive:!0}),e.placementContainer&&e.placementContainer.addEventListener("scroll",o,{passive:!0})}),n.onUnmounted(()=>{e.openOnHover||u.value&&u.value.destroy(),window.removeEventListener("resize",o),window.removeEventListener("scroll",o),e.placementContainer&&e.placementContainer.removeEventListener("scroll",o)}),n.watch(()=>r.value,i=>t("button-ref",i),{immediate:!0}),{dropdownButton:r,dropdownContent:l,dropdownPlacement:a,closableUtils:u,onClose:s,close:d,toggleOpen:c,onBlur:m,onFocus:v}}});module.exports=b;
|
|
2
2
|
//# sourceMappingURL=NeonDropdown.ts_vue_type_script_src_4222fb80_lang.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonDropdown.ts_vue_type_script_src_4222fb80_lang.cjs.js","sources":["../../../../src/components/presentation/dropdown/NeonDropdown.ts?vue&type=script&src=4222fb80&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonDropdownPlacementUtils } from '@/common/utils/NeonDropdownPlacementUtils';\nimport { NeonClosableUtils } from '@/common/utils/NeonClosableUtils';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport { NeonDropdownStyle } from '@/common/enums/NeonDropdownStyle';\nimport NeonBadge from '@/components/presentation/badge/NeonBadge.vue';\nimport NeonButton from '@/components/user-input/button/NeonButton.vue';\nimport NeonExpansionIndicator from '@/components/presentation/expansion-indicator/NeonExpansionIndicator.vue';\n\n/**\n * <p>A general purpose dropdown component. This component consists of a button, to trigger the dropdown to open, and\n * the dropdown content which is displayed above the page when the user clicks the button.</p>\n * <p>This can be useful for secondary (perhaps more complex) actions for which there is not enough space on the page or\n * the action is asynchronous allowing the user to perform the action and continue what they were doing. Examples are\n * providing links to copy and letting the user send feedback.</p>\n * <p><strong>NeonDropdown</strong> is the basis for the <strong>NeonDropdownMenu</strong> component and the\n * <strong>NeonSelect</strong> form component.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdown',\n components: {\n NeonBadge,\n NeonButton,\n NeonExpansionIndicator,\n },\n props: {\n /**\n * Whether the dropdown is currently open.\n */\n modelValue: { type: Boolean, required: true },\n /**\n * The label for the dropdown button.\n */\n label: { type: String, default: null },\n /**\n * URL of image to display if the button style is a square or circular badge.\n */\n image: { type: String, default: null },\n /**\n * Badge image ALT text.\n */\n imageAlt: { type: String, default: null },\n /**\n * An icon to display on the dropdown button. This will be to the left of any label, but can also be used on its own.\n */\n icon: { type: String, default: null },\n /**\n * Show the dropdown button's indicator (chevron).\n */\n indicator: { type: Boolean, default: true },\n /**\n * Disable the dropdown button\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown button - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the dropdown button\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * The alternate color of the dropdown button (for gradient buttons).\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * The style of the dropdown button\n */\n dropdownStyle: { type: String as () => NeonDropdownStyle, default: NeonDropdownStyle.SolidButton },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n /**\n * Restrict placement to within this container.\n */\n placementContainer: { type: Object as () => HTMLElement, default: null },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the dropdown button is toggled.\n * @type {boolean} the open state of the dropdown.\n */\n 'update:modelValue',\n /**\n * Emitted on initialisation.\n * @type {NeonDropdownPlacement} the placement of the dropdown.\n */\n 'dropdown-placement',\n /**\n * Emitted when the dropdown button is blurred.\n * @type {void}\n */\n 'blur',\n /**\n * Emitted when the dropdown button is focussed.\n * @type {void}\n */\n 'focus',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const dropdownButton = ref<HTMLElement | null>(null);\n const dropdownContent = ref<HTMLDivElement | null>(null);\n\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n const closableUtils = ref<NeonClosableUtils | null>(null);\n\n const onClose = () => {\n emit('update:modelValue', false);\n };\n\n const close = () => {\n if (props.modelValue) {\n onClose();\n }\n };\n\n const recalculatePlacement = () => {\n if (props.modelValue && dropdownButton.value && dropdownContent.value) {\n const previousValue = dropdownPlacement.value;\n dropdownPlacement.value = NeonDropdownPlacementUtils.calculatePlacement(\n dropdownButton.value,\n dropdownContent.value,\n props.placement,\n props.placementContainer,\n );\n\n if (previousValue !== dropdownPlacement.value) {\n emit('dropdown-placement', dropdownPlacement.value);\n }\n }\n };\n\n const toggleOpen = () => {\n if (!props.disabled && !props.openOnHover) {\n emit('update:modelValue', !props.modelValue);\n setTimeout(recalculatePlacement);\n }\n };\n\n const onBlur = () => {\n emit('blur');\n };\n\n const onFocus = () => {\n emit('focus');\n };\n\n onMounted(() => {\n if (!props.openOnHover && dropdownContent.value) {\n closableUtils.value = new NeonClosableUtils(dropdownContent.value, close);\n }\n window.addEventListener('resize', recalculatePlacement, { passive: true });\n window.addEventListener('scroll', recalculatePlacement, { passive: true });\n if (props.placementContainer) {\n props.placementContainer.addEventListener('scroll', recalculatePlacement, { passive: true });\n }\n });\n\n onUnmounted(() => {\n if (!props.openOnHover) {\n closableUtils.value && closableUtils.value.destroy();\n }\n window.removeEventListener('resize', recalculatePlacement);\n window.removeEventListener('scroll', recalculatePlacement);\n if (props.placementContainer) {\n props.placementContainer.removeEventListener('scroll', recalculatePlacement);\n }\n });\n\n watch(\n () => dropdownButton.value,\n (value) => emit('button-ref', value),\n { immediate: true },\n );\n\n return {\n dropdownButton,\n dropdownContent,\n dropdownPlacement,\n closableUtils,\n onClose,\n close,\n toggleOpen,\n onBlur,\n onFocus,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonBadge","NeonButton","NeonExpansionIndicator","NeonSize","NeonFunctionalColor","NeonDropdownStyle","NeonDropdownPlacement","props","emit","dropdownButton","ref","dropdownContent","dropdownPlacement","closableUtils","onClose","close","recalculatePlacement","previousValue","NeonDropdownPlacementUtils","toggleOpen","onBlur","onFocus","onMounted","NeonClosableUtils","onUnmounted","watch","value"],"mappings":"gjBAoBAA,EAAeC,kBAAgB,CAC7B,KAAM,eACN,WAAY,CACV,UAAAC,EACA,WAAAC,EACA,uBAAAC,CACF,EACA,MAAO,CAIL,WAAY,CAAE,KAAM,QAAS,SAAU,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K,CAEtD,CAAA,EAGIO,EAAa,IAAM,CACnB,CAACZ,EAAM,UAAY,CAACA,EAAM,cACvBC,EAAA,oBAAqB,CAACD,EAAM,UAAU,EAC3C,WAAWS,CAAoB,EACjC,EAGII,EAAS,IAAM,CACnBZ,EAAK,MAAM,CAAA,EAGPa,EAAU,IAAM,CACpBb,EAAK,OAAO,CAAA,EAGdc,OAAAA,EAAAA,UAAU,IAAM,CACV,CAACf,EAAM,aAAeI,EAAgB,QACxCE,EAAc,MAAQ,IAAIU,EAAAA,kBAAkBZ,EAAgB,MAAOI,CAAK,GAE1E,OAAO,iBAAiB,SAAUC,EAAsB,CAAE,QAAS,GAAM,EACzE,OAAO,iBAAiB,SAAUA,EAAsB,CAAE,QAAS,GAAM,EACrET,EAAM,oBACRA,EAAM,mBAAmB,iBAAiB,SAAUS,EAAsB,CAAE,QAAS,GAAM,CAC7F,CACD,EAEDQ,EAAAA,YAAY,IAAM,CACXjB,EAAM,aACKM,EAAA,OAASA,EAAc,MAAM,QAAQ,EAE9C,OAAA,oBAAoB,SAAUG,CAAoB,EAClD,OAAA,oBAAoB,SAAUA,CAAoB,EACrDT,EAAM,oBACFA,EAAA,mBAAmB,oBAAoB,SAAUS,CAAoB,CAC7E,CACD,EAEDS,EAAA,MACE,IAAMhB,EAAe,MACpBiB,GAAUlB,EAAK,aAAckB,CAAK,EACnC,CAAE,UAAW,EAAK,CAAA,EAGb,CACL,eAAAjB,EACA,gBAAAE,EACA,kBAAAC,EACA,cAAAC,EACA,QAAAC,EACA,MAAAC,EACA,WAAAI,EACA,OAAAC,EACA,QAAAC,CAAA,CAEJ,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"NeonDropdown.ts_vue_type_script_src_4222fb80_lang.cjs.js","sources":["../../../../src/components/presentation/dropdown/NeonDropdown.ts?vue&type=script&src=4222fb80&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonDropdownPlacementUtils } from '@/common/utils/NeonDropdownPlacementUtils';\nimport { NeonClosableUtils } from '@/common/utils/NeonClosableUtils';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport { NeonDropdownStyle } from '@/common/enums/NeonDropdownStyle';\nimport NeonBadge from '@/components/presentation/badge/NeonBadge.vue';\nimport NeonButton from '@/components/user-input/button/NeonButton.vue';\nimport NeonExpansionIndicator from '@/components/presentation/expansion-indicator/NeonExpansionIndicator.vue';\n\n/**\n * <p>A general purpose dropdown component. This component consists of a button, to trigger the dropdown to open, and\n * the dropdown content which is displayed above the page when the user clicks the button.</p>\n * <p>This can be useful for secondary (perhaps more complex) actions for which there is not enough space on the page or\n * the action is asynchronous allowing the user to perform the action and continue what they were doing. Examples are\n * providing links to copy and letting the user send feedback.</p>\n * <p><strong>NeonDropdown</strong> is the basis for the <strong>NeonDropdownMenu</strong> component and the\n * <strong>NeonSelect</strong> form component.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdown',\n components: {\n NeonBadge,\n NeonButton,\n NeonExpansionIndicator,\n },\n props: {\n /**\n * Id for the dropdown button.\n */\n id: { type: String },\n /**\n * Whether the dropdown is currently open.\n */\n modelValue: { type: Boolean, required: true },\n /**\n * The label for the dropdown button.\n */\n label: { type: String, default: null },\n /**\n * URL of image to display if the button style is a square or circular badge.\n */\n image: { type: String, default: null },\n /**\n * Badge image ALT text.\n */\n imageAlt: { type: String, default: null },\n /**\n * An icon to display on the dropdown button. This will be to the left of any label, but can also be used on its own.\n */\n icon: { type: String, default: null },\n /**\n * Show the dropdown button's indicator (chevron).\n */\n indicator: { type: Boolean, default: true },\n /**\n * Disable the dropdown button\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown button - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the dropdown button\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * The alternate color of the dropdown button (for gradient buttons).\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * The style of the dropdown button\n */\n dropdownStyle: { type: String as () => NeonDropdownStyle, default: NeonDropdownStyle.SolidButton },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n /**\n * Restrict placement to within this container.\n */\n placementContainer: { type: Object as () => HTMLElement, default: null },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the dropdown button is toggled.\n * @type {boolean} the open state of the dropdown.\n */\n 'update:modelValue',\n /**\n * Emitted on initialisation.\n * @type {NeonDropdownPlacement} the placement of the dropdown.\n */\n 'dropdown-placement',\n /**\n * Emitted when the dropdown button is blurred.\n * @type {void}\n */\n 'blur',\n /**\n * Emitted when the dropdown button is focussed.\n * @type {void}\n */\n 'focus',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const dropdownButton = ref<HTMLElement | null>(null);\n const dropdownContent = ref<HTMLDivElement | null>(null);\n\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n const closableUtils = ref<NeonClosableUtils | null>(null);\n\n const onClose = () => {\n emit('update:modelValue', false);\n };\n\n const close = () => {\n if (props.modelValue) {\n onClose();\n }\n };\n\n const recalculatePlacement = () => {\n if (props.modelValue && dropdownButton.value && dropdownContent.value) {\n const previousValue = dropdownPlacement.value;\n dropdownPlacement.value = NeonDropdownPlacementUtils.calculatePlacement(\n dropdownButton.value,\n dropdownContent.value,\n props.placement,\n props.placementContainer,\n );\n\n if (previousValue !== dropdownPlacement.value) {\n emit('dropdown-placement', dropdownPlacement.value);\n }\n }\n };\n\n const toggleOpen = () => {\n if (!props.disabled && !props.openOnHover) {\n emit('update:modelValue', !props.modelValue);\n setTimeout(recalculatePlacement);\n }\n };\n\n const onBlur = () => {\n emit('blur');\n };\n\n const onFocus = () => {\n emit('focus');\n };\n\n onMounted(() => {\n if (!props.openOnHover && dropdownContent.value) {\n closableUtils.value = new NeonClosableUtils(dropdownContent.value, close);\n }\n window.addEventListener('resize', recalculatePlacement, { passive: true });\n window.addEventListener('scroll', recalculatePlacement, { passive: true });\n if (props.placementContainer) {\n props.placementContainer.addEventListener('scroll', recalculatePlacement, { passive: true });\n }\n });\n\n onUnmounted(() => {\n if (!props.openOnHover) {\n closableUtils.value && closableUtils.value.destroy();\n }\n window.removeEventListener('resize', recalculatePlacement);\n window.removeEventListener('scroll', recalculatePlacement);\n if (props.placementContainer) {\n props.placementContainer.removeEventListener('scroll', recalculatePlacement);\n }\n });\n\n watch(\n () => dropdownButton.value,\n (value) => emit('button-ref', value),\n { immediate: true },\n );\n\n return {\n dropdownButton,\n dropdownContent,\n dropdownPlacement,\n closableUtils,\n onClose,\n close,\n toggleOpen,\n onBlur,\n onFocus,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonBadge","NeonButton","NeonExpansionIndicator","NeonSize","NeonFunctionalColor","NeonDropdownStyle","NeonDropdownPlacement","props","emit","dropdownButton","ref","dropdownContent","dropdownPlacement","closableUtils","onClose","close","recalculatePlacement","previousValue","NeonDropdownPlacementUtils","toggleOpen","onBlur","onFocus","onMounted","NeonClosableUtils","onUnmounted","watch","value"],"mappings":"gjBAoBAA,EAAeC,kBAAgB,CAC7B,KAAM,eACN,WAAY,CACV,UAAAC,EACA,WAAAC,EACA,uBAAAC,CACF,EACA,MAAO,CAIL,GAAI,CAAE,KAAM,MAAO,EAInB,WAAY,CAAE,KAAM,QAAS,SAAU,EAAK,EAI5C,MAAO,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIrC,MAAO,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIrC,SAAU,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIxC,KAAM,CAAE,KAAM,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,EAAK,MAAM,CAAA,EAGPa,EAAU,IAAM,CACpBb,EAAK,OAAO,CAAA,EAGdc,OAAAA,EAAAA,UAAU,IAAM,CACV,CAACf,EAAM,aAAeI,EAAgB,QACxCE,EAAc,MAAQ,IAAIU,EAAAA,kBAAkBZ,EAAgB,MAAOI,CAAK,GAE1E,OAAO,iBAAiB,SAAUC,EAAsB,CAAE,QAAS,GAAM,EACzE,OAAO,iBAAiB,SAAUA,EAAsB,CAAE,QAAS,GAAM,EACrET,EAAM,oBACRA,EAAM,mBAAmB,iBAAiB,SAAUS,EAAsB,CAAE,QAAS,GAAM,CAC7F,CACD,EAEDQ,EAAAA,YAAY,IAAM,CACXjB,EAAM,aACKM,EAAA,OAASA,EAAc,MAAM,QAAQ,EAE9C,OAAA,oBAAoB,SAAUG,CAAoB,EAClD,OAAA,oBAAoB,SAAUA,CAAoB,EACrDT,EAAM,oBACFA,EAAA,mBAAmB,oBAAoB,SAAUS,CAAoB,CAC7E,CACD,EAEDS,EAAA,MACE,IAAMhB,EAAe,MACpBiB,GAAUlB,EAAK,aAAckB,CAAK,EACnC,CAAE,UAAW,EAAK,CAAA,EAGb,CACL,eAAAjB,EACA,gBAAAE,EACA,kBAAAC,EACA,cAAAC,EACA,QAAAC,EACA,MAAAC,EACA,WAAAI,EACA,OAAAC,EACA,QAAAC,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonDropdown.ts_vue_type_script_src_4222fb80_lang.es.js","sources":["../../../../src/components/presentation/dropdown/NeonDropdown.ts?vue&type=script&src=4222fb80&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonDropdownPlacementUtils } from '@/common/utils/NeonDropdownPlacementUtils';\nimport { NeonClosableUtils } from '@/common/utils/NeonClosableUtils';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport { NeonDropdownStyle } from '@/common/enums/NeonDropdownStyle';\nimport NeonBadge from '@/components/presentation/badge/NeonBadge.vue';\nimport NeonButton from '@/components/user-input/button/NeonButton.vue';\nimport NeonExpansionIndicator from '@/components/presentation/expansion-indicator/NeonExpansionIndicator.vue';\n\n/**\n * <p>A general purpose dropdown component. This component consists of a button, to trigger the dropdown to open, and\n * the dropdown content which is displayed above the page when the user clicks the button.</p>\n * <p>This can be useful for secondary (perhaps more complex) actions for which there is not enough space on the page or\n * the action is asynchronous allowing the user to perform the action and continue what they were doing. Examples are\n * providing links to copy and letting the user send feedback.</p>\n * <p><strong>NeonDropdown</strong> is the basis for the <strong>NeonDropdownMenu</strong> component and the\n * <strong>NeonSelect</strong> form component.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdown',\n components: {\n NeonBadge,\n NeonButton,\n NeonExpansionIndicator,\n },\n props: {\n /**\n * Whether the dropdown is currently open.\n */\n modelValue: { type: Boolean, required: true },\n /**\n * The label for the dropdown button.\n */\n label: { type: String, default: null },\n /**\n * URL of image to display if the button style is a square or circular badge.\n */\n image: { type: String, default: null },\n /**\n * Badge image ALT text.\n */\n imageAlt: { type: String, default: null },\n /**\n * An icon to display on the dropdown button. This will be to the left of any label, but can also be used on its own.\n */\n icon: { type: String, default: null },\n /**\n * Show the dropdown button's indicator (chevron).\n */\n indicator: { type: Boolean, default: true },\n /**\n * Disable the dropdown button\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown button - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the dropdown button\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * The alternate color of the dropdown button (for gradient buttons).\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * The style of the dropdown button\n */\n dropdownStyle: { type: String as () => NeonDropdownStyle, default: NeonDropdownStyle.SolidButton },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n /**\n * Restrict placement to within this container.\n */\n placementContainer: { type: Object as () => HTMLElement, default: null },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the dropdown button is toggled.\n * @type {boolean} the open state of the dropdown.\n */\n 'update:modelValue',\n /**\n * Emitted on initialisation.\n * @type {NeonDropdownPlacement} the placement of the dropdown.\n */\n 'dropdown-placement',\n /**\n * Emitted when the dropdown button is blurred.\n * @type {void}\n */\n 'blur',\n /**\n * Emitted when the dropdown button is focussed.\n * @type {void}\n */\n 'focus',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const dropdownButton = ref<HTMLElement | null>(null);\n const dropdownContent = ref<HTMLDivElement | null>(null);\n\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n const closableUtils = ref<NeonClosableUtils | null>(null);\n\n const onClose = () => {\n emit('update:modelValue', false);\n };\n\n const close = () => {\n if (props.modelValue) {\n onClose();\n }\n };\n\n const recalculatePlacement = () => {\n if (props.modelValue && dropdownButton.value && dropdownContent.value) {\n const previousValue = dropdownPlacement.value;\n dropdownPlacement.value = NeonDropdownPlacementUtils.calculatePlacement(\n dropdownButton.value,\n dropdownContent.value,\n props.placement,\n props.placementContainer,\n );\n\n if (previousValue !== dropdownPlacement.value) {\n emit('dropdown-placement', dropdownPlacement.value);\n }\n }\n };\n\n const toggleOpen = () => {\n if (!props.disabled && !props.openOnHover) {\n emit('update:modelValue', !props.modelValue);\n setTimeout(recalculatePlacement);\n }\n };\n\n const onBlur = () => {\n emit('blur');\n };\n\n const onFocus = () => {\n emit('focus');\n };\n\n onMounted(() => {\n if (!props.openOnHover && dropdownContent.value) {\n closableUtils.value = new NeonClosableUtils(dropdownContent.value, close);\n }\n window.addEventListener('resize', recalculatePlacement, { passive: true });\n window.addEventListener('scroll', recalculatePlacement, { passive: true });\n if (props.placementContainer) {\n props.placementContainer.addEventListener('scroll', recalculatePlacement, { passive: true });\n }\n });\n\n onUnmounted(() => {\n if (!props.openOnHover) {\n closableUtils.value && closableUtils.value.destroy();\n }\n window.removeEventListener('resize', recalculatePlacement);\n window.removeEventListener('scroll', recalculatePlacement);\n if (props.placementContainer) {\n props.placementContainer.removeEventListener('scroll', recalculatePlacement);\n }\n });\n\n watch(\n () => dropdownButton.value,\n (value) => emit('button-ref', value),\n { immediate: true },\n );\n\n return {\n dropdownButton,\n dropdownContent,\n dropdownPlacement,\n closableUtils,\n onClose,\n close,\n toggleOpen,\n onBlur,\n onFocus,\n };\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;AAoBA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,YAAY,EAAE,MAAM,SAAS,UAAU,KAAK;AAAA,IAI5C,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,UAAU,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIxC,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIpC,WAAW,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,IAI1C,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,MAAM,EAAE,MAAM,QAA0B,SAAS,SAAS,OAAO;AAAA,IAIjE,OAAO,EAAE,MAAM,QAAqC,SAAS,oBAAoB,YAAY;AAAA,IAI7F,gBAAgB,EAAE,MAAM,QAAqC,SAAS,KAAK;AAAA,IAI3E,eAAe,EAAE,MAAM,QAAmC,SAAS,kBAAkB,YAAY;AAAA,IAIjG,WAAW,EAAE,MAAM,QAAuC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AAgB,OAAO,KAAK;AAAA,MAC1E;AACA,aAAO,iBAAiB,UAAU,sBAAsB,EAAE,SAAS,MAAM;AACzE,aAAO,iBAAiB,UAAU,sBAAsB,EAAE,SAAS,MAAM;AACzE,UAAI,MAAM,oBAAoB;AAC5B,cAAM,mBAAmB,iBAAiB,UAAU,sBAAsB,EAAE,SAAS,MAAM;AAAA,MAC7F;AAAA,IAAA,CACD;AAED,gBAAY,MAAM;AACZ,UAAA,CAAC,MAAM,aAAa;AACR,sBAAA,SAAS,cAAc,MAAM,QAAQ;AAAA,MACrD;AACO,aAAA,oBAAoB,UAAU,oBAAoB;AAClD,aAAA,oBAAoB,UAAU,oBAAoB;AACzD,UAAI,MAAM,oBAAoB;AACtB,cAAA,mBAAmB,oBAAoB,UAAU,oBAAoB;AAAA,MAC7E;AAAA,IAAA,CACD;AAED;AAAA,MACE,MAAM,eAAe;AAAA,MACrB,CAAC,UAAU,KAAK,cAAc,KAAK;AAAA,MACnC,EAAE,WAAW,KAAK;AAAA,IAAA;AAGb,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"NeonDropdown.ts_vue_type_script_src_4222fb80_lang.es.js","sources":["../../../../src/components/presentation/dropdown/NeonDropdown.ts?vue&type=script&src=4222fb80&lang.ts"],"sourcesContent":["import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonDropdownPlacementUtils } from '@/common/utils/NeonDropdownPlacementUtils';\nimport { NeonClosableUtils } from '@/common/utils/NeonClosableUtils';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport { NeonDropdownStyle } from '@/common/enums/NeonDropdownStyle';\nimport NeonBadge from '@/components/presentation/badge/NeonBadge.vue';\nimport NeonButton from '@/components/user-input/button/NeonButton.vue';\nimport NeonExpansionIndicator from '@/components/presentation/expansion-indicator/NeonExpansionIndicator.vue';\n\n/**\n * <p>A general purpose dropdown component. This component consists of a button, to trigger the dropdown to open, and\n * the dropdown content which is displayed above the page when the user clicks the button.</p>\n * <p>This can be useful for secondary (perhaps more complex) actions for which there is not enough space on the page or\n * the action is asynchronous allowing the user to perform the action and continue what they were doing. Examples are\n * providing links to copy and letting the user send feedback.</p>\n * <p><strong>NeonDropdown</strong> is the basis for the <strong>NeonDropdownMenu</strong> component and the\n * <strong>NeonSelect</strong> form component.</p>\n */\nexport default defineComponent({\n name: 'NeonDropdown',\n components: {\n NeonBadge,\n NeonButton,\n NeonExpansionIndicator,\n },\n props: {\n /**\n * Id for the dropdown button.\n */\n id: { type: String },\n /**\n * Whether the dropdown is currently open.\n */\n modelValue: { type: Boolean, required: true },\n /**\n * The label for the dropdown button.\n */\n label: { type: String, default: null },\n /**\n * URL of image to display if the button style is a square or circular badge.\n */\n image: { type: String, default: null },\n /**\n * Badge image ALT text.\n */\n imageAlt: { type: String, default: null },\n /**\n * An icon to display on the dropdown button. This will be to the left of any label, but can also be used on its own.\n */\n icon: { type: String, default: null },\n /**\n * Show the dropdown button's indicator (chevron).\n */\n indicator: { type: Boolean, default: true },\n /**\n * Disable the dropdown button\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown button - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the dropdown button\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * The alternate color of the dropdown button (for gradient buttons).\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * The style of the dropdown button\n */\n dropdownStyle: { type: String as () => NeonDropdownStyle, default: NeonDropdownStyle.SolidButton },\n /**\n * Placement of the dropdown contents.\n */\n placement: { type: String as () => NeonDropdownPlacement, default: NeonDropdownPlacement.BottomLeft },\n /**\n * Restrict placement to within this container.\n */\n placementContainer: { type: Object as () => HTMLElement, default: null },\n /**\n * Instead of opening on click (default), open on hover.\n */\n openOnHover: { type: Boolean, default: false },\n },\n emits: [\n /**\n * Emitted when the dropdown button is toggled.\n * @type {boolean} the open state of the dropdown.\n */\n 'update:modelValue',\n /**\n * Emitted on initialisation.\n * @type {NeonDropdownPlacement} the placement of the dropdown.\n */\n 'dropdown-placement',\n /**\n * Emitted when the dropdown button is blurred.\n * @type {void}\n */\n 'blur',\n /**\n * Emitted when the dropdown button is focussed.\n * @type {void}\n */\n 'focus',\n /**\n * emitted on initialisation\n * @type {HTMLElement} the reference to the HTMLElement for the dropdown menu button.\n */\n 'button-ref',\n ],\n setup(props, { emit }) {\n const dropdownButton = ref<HTMLElement | null>(null);\n const dropdownContent = ref<HTMLDivElement | null>(null);\n\n const dropdownPlacement = ref<NeonDropdownPlacement>(props.placement);\n const closableUtils = ref<NeonClosableUtils | null>(null);\n\n const onClose = () => {\n emit('update:modelValue', false);\n };\n\n const close = () => {\n if (props.modelValue) {\n onClose();\n }\n };\n\n const recalculatePlacement = () => {\n if (props.modelValue && dropdownButton.value && dropdownContent.value) {\n const previousValue = dropdownPlacement.value;\n dropdownPlacement.value = NeonDropdownPlacementUtils.calculatePlacement(\n dropdownButton.value,\n dropdownContent.value,\n props.placement,\n props.placementContainer,\n );\n\n if (previousValue !== dropdownPlacement.value) {\n emit('dropdown-placement', dropdownPlacement.value);\n }\n }\n };\n\n const toggleOpen = () => {\n if (!props.disabled && !props.openOnHover) {\n emit('update:modelValue', !props.modelValue);\n setTimeout(recalculatePlacement);\n }\n };\n\n const onBlur = () => {\n emit('blur');\n };\n\n const onFocus = () => {\n emit('focus');\n };\n\n onMounted(() => {\n if (!props.openOnHover && dropdownContent.value) {\n closableUtils.value = new NeonClosableUtils(dropdownContent.value, close);\n }\n window.addEventListener('resize', recalculatePlacement, { passive: true });\n window.addEventListener('scroll', recalculatePlacement, { passive: true });\n if (props.placementContainer) {\n props.placementContainer.addEventListener('scroll', recalculatePlacement, { passive: true });\n }\n });\n\n onUnmounted(() => {\n if (!props.openOnHover) {\n closableUtils.value && closableUtils.value.destroy();\n }\n window.removeEventListener('resize', recalculatePlacement);\n window.removeEventListener('scroll', recalculatePlacement);\n if (props.placementContainer) {\n props.placementContainer.removeEventListener('scroll', recalculatePlacement);\n }\n });\n\n watch(\n () => dropdownButton.value,\n (value) => emit('button-ref', value),\n { immediate: true },\n );\n\n return {\n dropdownButton,\n dropdownContent,\n dropdownPlacement,\n closableUtils,\n onClose,\n close,\n toggleOpen,\n onBlur,\n onFocus,\n };\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;AAoBA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,IAAI,EAAE,MAAM,OAAO;AAAA,IAInB,YAAY,EAAE,MAAM,SAAS,UAAU,KAAK;AAAA,IAI5C,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,UAAU,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIxC,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIpC,WAAW,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,IAI1C,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,MAAM,EAAE,MAAM,QAA0B,SAAS,SAAS,OAAO;AAAA,IAIjE,OAAO,EAAE,MAAM,QAAqC,SAAS,oBAAoB,YAAY;AAAA,IAI7F,gBAAgB,EAAE,MAAM,QAAqC,SAAS,KAAK;AAAA,IAI3E,eAAe,EAAE,MAAM,QAAmC,SAAS,kBAAkB,YAAY;AAAA,IAIjG,WAAW,EAAE,MAAM,QAAuC,SAAS,sBAAsB,WA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AAAA,MAC1E;AACA,aAAO,iBAAiB,UAAU,sBAAsB,EAAE,SAAS,MAAM;AACzE,aAAO,iBAAiB,UAAU,sBAAsB,EAAE,SAAS,MAAM;AACzE,UAAI,MAAM,oBAAoB;AAC5B,cAAM,mBAAmB,iBAAiB,UAAU,sBAAsB,EAAE,SAAS,MAAM;AAAA,MAC7F;AAAA,IAAA,CACD;AAED,gBAAY,MAAM;AACZ,UAAA,CAAC,MAAM,aAAa;AACR,sBAAA,SAAS,cAAc,MAAM,QAAQ;AAAA,MACrD;AACO,aAAA,oBAAoB,UAAU,oBAAoB;AAClD,aAAA,oBAAoB,UAAU,oBAAoB;AACzD,UAAI,MAAM,oBAAoB;AACtB,cAAA,mBAAmB,oBAAoB,UAAU,oBAAoB;AAAA,MAC7E;AAAA,IAAA,CACD;AAED;AAAA,MACE,MAAM,eAAe;AAAA,MACrB,CAAC,UAAU,KAAK,cAAc,KAAK;AAAA,MACnC,EAAE,WAAW,KAAK;AAAA,IAAA;AAGb,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var s=require("./NeonField.ts_vue_type_script_src_d5c469d0_lang.cjs.js"),e=require("vue"),r=require("../../../_virtual/plugin-vue_export-helper.cjs.js");const
|
|
1
|
+
"use strict";var s=require("./NeonField.ts_vue_type_script_src_d5c469d0_lang.cjs.js"),e=require("vue"),r=require("../../../_virtual/plugin-vue_export-helper.cjs.js");const t=["for"],a={class:"neon-field__label-wrapper"},i={class:"neon-field__label"},d=e.createElementVNode("div",{class:"neon-field__contents"},null,-1);function p(l,n,_,u,m,f){const o=e.resolveComponent("neon-label");return e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass([{"neon-field--optional":l.optional,"neon-field--disabled":l.disabled,"neon-field--with-message":l.message!==null},"neon-field"]),for:l.labelFor},[e.createElementVNode("span",a,[e.createElementVNode("span",i,e.toDisplayString(l.label),1),l.optional?(e.openBlock(),e.createBlock(o,{key:0,label:l.optionalLabel,class:"neon-field__optional",size:"xxs"},null,8,["label"])):e.createCommentVNode("",!0)]),d,e.renderSlot(l.$slots,"default"),l.message!==null?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass([`neon-color-text-${l.messageColor}`,"neon-field__message"]),onClick:n[0]||(n[0]=e.withModifiers(()=>{},["prevent","stop"]))},e.toDisplayString(l.message),3)):e.createCommentVNode("",!0)],10,t)}var c=r(s,[["render",p],["__file","/Users/andrew/dev/projects/neon/src/components/user-input/field/NeonField.vue"]]);module.exports=c;
|
|
2
2
|
//# sourceMappingURL=NeonField.cjs.js.map
|
|
@@ -2,8 +2,9 @@ import _sfc_main from "./NeonField.ts_vue_type_script_src_d5c469d0_lang.es.js";
|
|
|
2
2
|
import { resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createBlock, createCommentVNode, renderSlot, withModifiers } from "vue";
|
|
3
3
|
import _export_sfc from "../../../_virtual/plugin-vue_export-helper.es.js";
|
|
4
4
|
const _hoisted_1 = ["for"];
|
|
5
|
-
const _hoisted_2 = { class: "neon-
|
|
5
|
+
const _hoisted_2 = { class: "neon-field__label-wrapper" };
|
|
6
6
|
const _hoisted_3 = { class: "neon-field__label" };
|
|
7
|
+
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "neon-field__contents" }, null, -1);
|
|
7
8
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
8
9
|
const _component_neon_label = resolveComponent("neon-label");
|
|
9
10
|
return openBlock(), createElementBlock("label", {
|
|
@@ -23,6 +24,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
23
24
|
size: "xxs"
|
|
24
25
|
}, null, 8, ["label"])) : createCommentVNode("", true)
|
|
25
26
|
]),
|
|
27
|
+
_hoisted_4,
|
|
26
28
|
renderSlot(_ctx.$slots, "default"),
|
|
27
29
|
_ctx.message !== null ? (openBlock(), createElementBlock("span", {
|
|
28
30
|
key: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonField.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NeonField.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=require("./NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js"),e=require("vue"),c=require("../../../_virtual/plugin-vue_export-helper.cjs.js");const p={class:"neon-select__wrapper"},u={class:"no-style neon-select__options"},m={class:"neon-select__option-container"},k={class:"neon-select__option-label"},b=["id","aria-selected","onClick","onMouseover"],y={class:"neon-select__option-container"},
|
|
1
|
+
"use strict";var d=require("./NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js"),e=require("vue"),c=require("../../../_virtual/plugin-vue_export-helper.cjs.js");const p={class:"neon-select__wrapper"},u={class:"no-style neon-select__options"},m={class:"neon-select__option-container"},k={class:"neon-select__option-label"},b=["id","aria-selected","onClick","onMouseover"],y={class:"neon-select__option-container"},v={class:"neon-select__option-label"},_=["disabled","multiple"],g=["selected"],h=["label"],B=["data-index","disabled","multiple","selected","value"],V=["data-index","disabled","multiple","selected","value"];function E(l,t,f,C,S,z){const a=e.resolveComponent("neon-switch"),i=e.resolveComponent("neon-icon"),r=e.resolveComponent("neon-dropdown");return e.openBlock(),e.createElementBlock("div",p,[e.createVNode(r,e.mergeProps({id:l.id,ref:"dropdown",modelValue:l.open,"onUpdate:modelValue":t[0]||(t[0]=n=>l.open=n),"aria-activedescendant":l.multiple?l.modelValue[0]:l.modelValue,"aria-multiselectable":l.multiple,class:[[`neon-select--${l.color}`,{"neon-select--grouped":l.groupedOptions,"neon-select--multiple":l.multiple}],"neon-select"],color:l.color,disabled:l.disabled,icon:l.computedIcon,label:l.computedLabel,size:l.size,role:"listbox"},l.sanitizedAttributes,{onDropdownPlacement:l.onPlacement}),{default:e.withCtx(()=>[e.createElementVNode("ul",u,[l.placeholderAsOption?(e.openBlock(),e.createElementBlock("li",{key:0,class:e.normalizeClass([`neon-select__option--${l.size}`,"neon-select__option neon-select__option--disabled neon-select__option-placeholder"])},[e.createElementVNode("div",m,[e.createElementVNode("span",k,e.toDisplayString(l.placeholder),1)])],2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.computedOptions,n=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[n.group!==""?(e.openBlock(),e.createElementBlock("li",{key:n.group,class:"neon-select__option-title"},e.toDisplayString(n.group),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.options,o=>(e.openBlock(),e.createElementBlock("li",{id:o.key,key:o.key,"aria-selected":l.multiple?l.modelValue.indexOf(o.key)>=0:o.key===l.modelValue,class:e.normalizeClass([[{"neon-select__option--disabled":o.disabled,"neon-select__option--separator-before":o.separatorBefore,"neon-select__option--selected":l.multiple?l.modelValue.indexOf(o.key)>=0:o.key===l.modelValue,"neon-select__option--highlighted":o.key===l.highlightedKey},`neon-select__option--${l.size}`],"neon-select__option"]),role:"option",onClick:s=>!o.disabled&&l.clickOption(o),onMouseover:s=>l.changeHighlighted(o.key)},[e.createElementVNode("div",y,[e.renderSlot(l.$slots,"option",{option:o},()=>[l.multiple?(e.openBlock(),e.createBlock(a,{key:0,color:l.color,modelValue:l.modelValue.indexOf(o.key)>=0,size:l.size==="l"?"m":"s","switch-style":"checkbox"},null,8,["color","modelValue","size"])):e.createCommentVNode("",!0),o.icon?(e.openBlock(),e.createBlock(i,{key:1,disabled:o.disabled,name:o.icon,class:"neon-select__option-icon"},null,8,["disabled","name"])):e.createCommentVNode("",!0),e.createElementVNode("span",v,e.toDisplayString(o.label),1)])])],42,b))),128))],64))),256))])]),_:3},16,["id","modelValue","aria-activedescendant","aria-multiselectable","class","color","disabled","icon","label","size","onDropdownPlacement"]),e.createElementVNode("select",e.mergeProps({disabled:l.disabled,multiple:l.multiple,class:"neon-select__native"},l.sanitizedAttributes,{onInput:t[1]||(t[1]=(...n)=>l.nativeSelectChange&&l.nativeSelectChange(...n))}),[e.createElementVNode("option",{selected:l.multiple?l.modelValue.length===0:l.modelValue==="",disabled:"",hidden:"",value:""},e.toDisplayString(l.placeholder),9,g),l.groupedOptions?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.groupedOptions,n=>(e.openBlock(),e.createElementBlock("optgroup",{key:n.group,label:n.group},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.options,(o,s)=>(e.openBlock(),e.createElementBlock("option",{key:`${o.key}-native`,"data-index":s,disabled:o.disabled,multiple:l.multiple,selected:l.multiple?l.modelValue.indexOf(o.key)>=0:o.key===l.modelValue,value:o.key},e.toDisplayString(o.label),9,B))),128))],8,h))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(l.options,(n,o)=>(e.openBlock(),e.createElementBlock("option",{key:`${n.key}-native`,"data-index":o,disabled:n.disabled,multiple:l.multiple,selected:l.multiple?l.modelValue.indexOf(n.key)>=0:n.key===l.modelValue,value:n.key},e.toDisplayString(n.label),9,V))),128))],16,_)])}var N=c(d,[["render",E],["__file","/Users/andrew/dev/projects/neon/src/components/user-input/select/NeonSelect.vue"]]);module.exports=N;
|
|
2
2
|
//# sourceMappingURL=NeonSelect.cjs.js.map
|
|
@@ -10,6 +10,12 @@ import { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';
|
|
|
10
10
|
* <a href="/presentation/dropdown">NeonDropdown</a> to change the style of the dropdown button.</p>
|
|
11
11
|
*/
|
|
12
12
|
declare const _default: import("vue").DefineComponent<{
|
|
13
|
+
/**
|
|
14
|
+
* Id for the dropdown button
|
|
15
|
+
*/
|
|
16
|
+
id: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
};
|
|
13
19
|
/**
|
|
14
20
|
* Placeholder to display as button label when there is no option selected.
|
|
15
21
|
*/
|
|
@@ -105,6 +111,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
105
111
|
changeHighlighted: (key: string) => void;
|
|
106
112
|
onPlacement: (placement: NeonDropdownPlacement) => void;
|
|
107
113
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
114
|
+
/**
|
|
115
|
+
* Id for the dropdown button
|
|
116
|
+
*/
|
|
117
|
+
id: {
|
|
118
|
+
type: StringConstructor;
|
|
119
|
+
};
|
|
108
120
|
/**
|
|
109
121
|
* Placeholder to display as button label when there is no option selected.
|
|
110
122
|
*/
|
|
@@ -8,35 +8,36 @@ const _hoisted_4 = { class: "neon-select__option-label" };
|
|
|
8
8
|
const _hoisted_5 = ["id", "aria-selected", "onClick", "onMouseover"];
|
|
9
9
|
const _hoisted_6 = { class: "neon-select__option-container" };
|
|
10
10
|
const _hoisted_7 = { class: "neon-select__option-label" };
|
|
11
|
-
const _hoisted_8 = ["
|
|
11
|
+
const _hoisted_8 = ["disabled", "multiple"];
|
|
12
12
|
const _hoisted_9 = ["selected"];
|
|
13
13
|
const _hoisted_10 = ["label"];
|
|
14
|
-
const _hoisted_11 = ["
|
|
15
|
-
const _hoisted_12 = ["
|
|
14
|
+
const _hoisted_11 = ["data-index", "disabled", "multiple", "selected", "value"];
|
|
15
|
+
const _hoisted_12 = ["data-index", "disabled", "multiple", "selected", "value"];
|
|
16
16
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
17
17
|
const _component_neon_switch = resolveComponent("neon-switch");
|
|
18
18
|
const _component_neon_icon = resolveComponent("neon-icon");
|
|
19
19
|
const _component_neon_dropdown = resolveComponent("neon-dropdown");
|
|
20
20
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
21
|
-
createVNode(_component_neon_dropdown, mergeProps({
|
|
21
|
+
createVNode(_component_neon_dropdown, mergeProps({
|
|
22
|
+
id: _ctx.id,
|
|
23
|
+
ref: "dropdown",
|
|
22
24
|
modelValue: _ctx.open,
|
|
23
25
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.open = $event),
|
|
24
|
-
class: ["neon-select", [`neon-select--${_ctx.color}`, { "neon-select--grouped": _ctx.groupedOptions, "neon-select--multiple": _ctx.multiple }]],
|
|
25
|
-
size: _ctx.size,
|
|
26
|
-
color: _ctx.color,
|
|
27
|
-
label: _ctx.computedLabel,
|
|
28
|
-
icon: _ctx.computedIcon,
|
|
29
|
-
disabled: _ctx.disabled,
|
|
30
|
-
role: "listbox",
|
|
31
26
|
"aria-activedescendant": _ctx.multiple ? _ctx.modelValue[0] : _ctx.modelValue,
|
|
32
27
|
"aria-multiselectable": _ctx.multiple,
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
class: [[`neon-select--${_ctx.color}`, { "neon-select--grouped": _ctx.groupedOptions, "neon-select--multiple": _ctx.multiple }], "neon-select"],
|
|
29
|
+
color: _ctx.color,
|
|
30
|
+
disabled: _ctx.disabled,
|
|
31
|
+
icon: _ctx.computedIcon,
|
|
32
|
+
label: _ctx.computedLabel,
|
|
33
|
+
size: _ctx.size,
|
|
34
|
+
role: "listbox"
|
|
35
|
+
}, _ctx.sanitizedAttributes, { onDropdownPlacement: _ctx.onPlacement }), {
|
|
35
36
|
default: withCtx(() => [
|
|
36
37
|
createElementVNode("ul", _hoisted_2, [
|
|
37
38
|
_ctx.placeholderAsOption ? (openBlock(), createElementBlock("li", {
|
|
38
39
|
key: 0,
|
|
39
|
-
class: normalizeClass(["neon-select__option neon-select__option--disabled neon-select__option-placeholder"
|
|
40
|
+
class: normalizeClass([`neon-select__option--${_ctx.size}`, "neon-select__option neon-select__option--disabled neon-select__option-placeholder"])
|
|
40
41
|
}, [
|
|
41
42
|
createElementVNode("div", _hoisted_3, [
|
|
42
43
|
createElementVNode("span", _hoisted_4, toDisplayString(_ctx.placeholder), 1)
|
|
@@ -52,7 +53,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
52
53
|
return openBlock(), createElementBlock("li", {
|
|
53
54
|
id: option.key,
|
|
54
55
|
key: option.key,
|
|
55
|
-
|
|
56
|
+
"aria-selected": _ctx.multiple ? _ctx.modelValue.indexOf(option.key) >= 0 : option.key === _ctx.modelValue,
|
|
57
|
+
class: normalizeClass([[
|
|
56
58
|
{
|
|
57
59
|
"neon-select__option--disabled": option.disabled,
|
|
58
60
|
"neon-select__option--separator-before": option.separatorBefore,
|
|
@@ -60,9 +62,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
60
62
|
"neon-select__option--highlighted": option.key === _ctx.highlightedKey
|
|
61
63
|
},
|
|
62
64
|
`neon-select__option--${_ctx.size}`
|
|
63
|
-
]]),
|
|
65
|
+
], "neon-select__option"]),
|
|
64
66
|
role: "option",
|
|
65
|
-
"aria-selected": _ctx.multiple ? _ctx.modelValue.indexOf(option.key) >= 0 : option.key === _ctx.modelValue,
|
|
66
67
|
onClick: ($event) => !option.disabled && _ctx.clickOption(option),
|
|
67
68
|
onMouseover: ($event) => _ctx.changeHighlighted(option.key)
|
|
68
69
|
}, [
|
|
@@ -70,17 +71,17 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
70
71
|
renderSlot(_ctx.$slots, "option", { option }, () => [
|
|
71
72
|
_ctx.multiple ? (openBlock(), createBlock(_component_neon_switch, {
|
|
72
73
|
key: 0,
|
|
73
|
-
size: _ctx.size === "l" ? "m" : "s",
|
|
74
74
|
color: _ctx.color,
|
|
75
75
|
modelValue: _ctx.modelValue.indexOf(option.key) >= 0,
|
|
76
|
+
size: _ctx.size === "l" ? "m" : "s",
|
|
76
77
|
"switch-style": "checkbox"
|
|
77
|
-
}, null, 8, ["
|
|
78
|
+
}, null, 8, ["color", "modelValue", "size"])) : createCommentVNode("", true),
|
|
78
79
|
option.icon ? (openBlock(), createBlock(_component_neon_icon, {
|
|
79
80
|
key: 1,
|
|
80
|
-
|
|
81
|
+
disabled: option.disabled,
|
|
81
82
|
name: option.icon,
|
|
82
|
-
|
|
83
|
-
}, null, 8, ["
|
|
83
|
+
class: "neon-select__option-icon"
|
|
84
|
+
}, null, 8, ["disabled", "name"])) : createCommentVNode("", true),
|
|
84
85
|
createElementVNode("span", _hoisted_7, toDisplayString(option.label), 1)
|
|
85
86
|
])
|
|
86
87
|
])
|
|
@@ -91,19 +92,19 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
91
92
|
])
|
|
92
93
|
]),
|
|
93
94
|
_: 3
|
|
94
|
-
}, 16, ["
|
|
95
|
+
}, 16, ["id", "modelValue", "aria-activedescendant", "aria-multiselectable", "class", "color", "disabled", "icon", "label", "size", "onDropdownPlacement"]),
|
|
95
96
|
createElementVNode("select", mergeProps({
|
|
96
|
-
|
|
97
|
+
disabled: _ctx.disabled,
|
|
97
98
|
multiple: _ctx.multiple,
|
|
98
|
-
|
|
99
|
+
class: "neon-select__native"
|
|
99
100
|
}, _ctx.sanitizedAttributes, {
|
|
100
101
|
onInput: _cache[1] || (_cache[1] = (...args) => _ctx.nativeSelectChange && _ctx.nativeSelectChange(...args))
|
|
101
102
|
}), [
|
|
102
103
|
createElementVNode("option", {
|
|
103
|
-
value: "",
|
|
104
|
-
disabled: "",
|
|
105
104
|
selected: _ctx.multiple ? _ctx.modelValue.length === 0 : _ctx.modelValue === "",
|
|
106
|
-
|
|
105
|
+
disabled: "",
|
|
106
|
+
hidden: "",
|
|
107
|
+
value: ""
|
|
107
108
|
}, toDisplayString(_ctx.placeholder), 9, _hoisted_9),
|
|
108
109
|
_ctx.groupedOptions ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.groupedOptions, (group) => {
|
|
109
110
|
return openBlock(), createElementBlock("optgroup", {
|
|
@@ -113,22 +114,22 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
113
114
|
(openBlock(true), createElementBlock(Fragment, null, renderList(group.options, (option, index) => {
|
|
114
115
|
return openBlock(), createElementBlock("option", {
|
|
115
116
|
key: `${option.key}-native`,
|
|
116
|
-
value: option.key,
|
|
117
117
|
"data-index": index,
|
|
118
|
+
disabled: option.disabled,
|
|
118
119
|
multiple: _ctx.multiple,
|
|
119
120
|
selected: _ctx.multiple ? _ctx.modelValue.indexOf(option.key) >= 0 : option.key === _ctx.modelValue,
|
|
120
|
-
|
|
121
|
+
value: option.key
|
|
121
122
|
}, toDisplayString(option.label), 9, _hoisted_11);
|
|
122
123
|
}), 128))
|
|
123
124
|
], 8, _hoisted_10);
|
|
124
125
|
}), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.options, (option, index) => {
|
|
125
126
|
return openBlock(), createElementBlock("option", {
|
|
126
127
|
key: `${option.key}-native`,
|
|
127
|
-
value: option.key,
|
|
128
128
|
"data-index": index,
|
|
129
|
+
disabled: option.disabled,
|
|
129
130
|
multiple: _ctx.multiple,
|
|
130
131
|
selected: _ctx.multiple ? _ctx.modelValue.indexOf(option.key) >= 0 : option.key === _ctx.modelValue,
|
|
131
|
-
|
|
132
|
+
value: option.key
|
|
132
133
|
}, toDisplayString(option.label), 9, _hoisted_12);
|
|
133
134
|
}), 128))
|
|
134
135
|
], 16, _hoisted_8)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSelect.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NeonSelect.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=require("vue"),I=require("../../../common/enums/NeonSize.cjs.js"),P=require("../../../common/enums/NeonFunctionalColor.cjs.js"),A=require("../../presentation/dropdown/NeonDropdown.cjs.js"),x=require("../../presentation/icon/NeonIcon.cjs.js"),z=require("../switch/NeonSwitch.cjs.js"),s=require("../../../common/enums/NeonDropdownPlacement.cjs.js"),B=require("../../../common/utils/NeonScrollUtils.cjs.js"),C=l.defineComponent({name:"NeonSelect",components:{NeonDropdown:A,NeonIcon:x,NeonSwitch:z},props:{placeholder:{type:String,required:!0},placeholderAsOption:{type:Boolean,default:!1},placeholderIcon:{type:String,required:!1},options:{type:Array,required:!1},groupedOptions:{type:Array,required:!1},modelValue:{type:[String,Array],required:!0},multiple:{type:Boolean,default:!1},multiselectPlaceholder:{type:String,required:!1},disabled:{type:Boolean,default:!1},size:{type:String,default:I.NeonSize.Medium},color:{type:String,default:P.NeonFunctionalColor.LowContrast}},emits:["update:modelValue"],setup(n,{emit:g}){const w=l.useAttrs(),f=l.ref(null),c=l.ref(!1),v=l.ref(null),i=l.ref(null),r=l.ref(-1),o=l.computed(()=>{var e;return n.options||((e=n.groupedOptions)==null?void 0:e.flatMap(t=>t.options))||[]}),N=()=>{if(!n.groupedOptions)switch(v.value){case s.NeonDropdownPlacement.TopLeft:case s.NeonDropdownPlacement.TopRight:case s.NeonDropdownPlacement.LeftBottom:case s.NeonDropdownPlacement.RightBottom:return!0}return!1},k=()=>{var t;const e=(t=f.value)==null?void 0:t.querySelector(".neon-select__option--highlighted");e&&B.NeonScrollUtils.scrollIntoView(e)},p=(e,t)=>{const a=r.value+e;a>=0&&a<=o.value.length-1&&(r.value=a,i.value=o.value[r.value].key,t.preventDefault(),setTimeout(k))},d=e=>{g("update:modelValue",e)},y=e=>{if(n.multiple){const t=[...n.modelValue],a=t.findIndex(m=>m===e.key);a>=0?t.splice(a,1):t.push(e.key),d(t)}else n.modelValue!==e.key&&(c.value=!1,d(e.key))},h=e=>{if(c.value)switch(e.code){case"ArrowUp":case"ArrowDown":{const t=N()?-1:1;e.code==="ArrowUp"?p(-1*t,e):p(1*t,e)}break;case"Enter":case"Space":o.value[r.value].disabled||(y(o.value[r.value]),e.preventDefault());break;case"Tab":!e.ctrlKey&&!e.metaKey&&!e.altKey&&(c.value=!1);break}},S=l.computed(()=>n.groupedOptions||[{group:"",options:n.options||[]}]),q=l.computed(()=>{const{...e}=w;return e}),j=l.computed(()=>{if(n.multiple&&n.modelValue.length>0){if(n.multiselectPlaceholder)return n.multiselectPlaceholder;if(n.modelValue.length>1)return`${n.modelValue.length} items selected`;{const e=o.value.find(t=>t.key===n.modelValue[0]);return(e==null?void 0:e.label)||""}}else if(n.modelValue){const e=o.value.find(t=>t.key===n.modelValue);if(e)return e.label}return n.placeholder}),V=l.computed(()=>{if(n.modelValue){const e=o.value.find(t=>t.key===n.modelValue);if(e)return e.icon}return n.placeholderIcon}),O=e=>{const t=Array.from(e.target.options).filter(u=>u.selected).map(u=>u.value),a=o.value.filter(u=>t.indexOf(u.key)>=0),m=n.multiple?a.map(u=>u.key):a[0].key;d(m)},b=e=>{i.value=e,r.value=o.value.findIndex(t=>t.key===e)},D=e=>{v.value=e};return l.onMounted(()=>{document.addEventListener("keydown",h)}),l.onUnmounted(()=>{document.removeEventListener("keydown",h)}),l.watch(()=>c.value,e=>{e&&(i.value=o.value[0].key,r.value=0)}),{dropdown:f,open:c,highlightedKey:i,highlightedIndex:r,flattenedOptions:o,computedLabel:j,sanitizedAttributes:q,computedOptions:S,computedIcon:V,clickOption:y,nativeSelectChange:O,changeHighlighted:b,onPlacement:D}}});module.exports=C;
|
|
1
|
+
"use strict";var l=require("vue"),I=require("../../../common/enums/NeonSize.cjs.js"),P=require("../../../common/enums/NeonFunctionalColor.cjs.js"),A=require("../../presentation/dropdown/NeonDropdown.cjs.js"),x=require("../../presentation/icon/NeonIcon.cjs.js"),z=require("../switch/NeonSwitch.cjs.js"),s=require("../../../common/enums/NeonDropdownPlacement.cjs.js"),B=require("../../../common/utils/NeonScrollUtils.cjs.js"),C=l.defineComponent({name:"NeonSelect",components:{NeonDropdown:A,NeonIcon:x,NeonSwitch:z},props:{id:{type:String},placeholder:{type:String,required:!0},placeholderAsOption:{type:Boolean,default:!1},placeholderIcon:{type:String,required:!1},options:{type:Array,required:!1},groupedOptions:{type:Array,required:!1},modelValue:{type:[String,Array],required:!0},multiple:{type:Boolean,default:!1},multiselectPlaceholder:{type:String,required:!1},disabled:{type:Boolean,default:!1},size:{type:String,default:I.NeonSize.Medium},color:{type:String,default:P.NeonFunctionalColor.LowContrast}},emits:["update:modelValue"],setup(n,{emit:g}){const w=l.useAttrs(),f=l.ref(null),c=l.ref(!1),v=l.ref(null),i=l.ref(null),r=l.ref(-1),o=l.computed(()=>{var e;return n.options||((e=n.groupedOptions)==null?void 0:e.flatMap(t=>t.options))||[]}),N=()=>{if(!n.groupedOptions)switch(v.value){case s.NeonDropdownPlacement.TopLeft:case s.NeonDropdownPlacement.TopRight:case s.NeonDropdownPlacement.LeftBottom:case s.NeonDropdownPlacement.RightBottom:return!0}return!1},k=()=>{var t;const e=(t=f.value)==null?void 0:t.querySelector(".neon-select__option--highlighted");e&&B.NeonScrollUtils.scrollIntoView(e)},p=(e,t)=>{const a=r.value+e;a>=0&&a<=o.value.length-1&&(r.value=a,i.value=o.value[r.value].key,t.preventDefault(),setTimeout(k))},d=e=>{g("update:modelValue",e)},y=e=>{if(n.multiple){const t=[...n.modelValue],a=t.findIndex(m=>m===e.key);a>=0?t.splice(a,1):t.push(e.key),d(t)}else n.modelValue!==e.key&&(c.value=!1,d(e.key))},h=e=>{if(c.value)switch(e.code){case"ArrowUp":case"ArrowDown":{const t=N()?-1:1;e.code==="ArrowUp"?p(-1*t,e):p(1*t,e)}break;case"Enter":case"Space":o.value[r.value].disabled||(y(o.value[r.value]),e.preventDefault());break;case"Tab":!e.ctrlKey&&!e.metaKey&&!e.altKey&&(c.value=!1);break}},S=l.computed(()=>n.groupedOptions||[{group:"",options:n.options||[]}]),q=l.computed(()=>{const{...e}=w;return e}),j=l.computed(()=>{if(n.multiple&&n.modelValue.length>0){if(n.multiselectPlaceholder)return n.multiselectPlaceholder;if(n.modelValue.length>1)return`${n.modelValue.length} items selected`;{const e=o.value.find(t=>t.key===n.modelValue[0]);return(e==null?void 0:e.label)||""}}else if(n.modelValue){const e=o.value.find(t=>t.key===n.modelValue);if(e)return e.label}return n.placeholder}),V=l.computed(()=>{if(n.modelValue){const e=o.value.find(t=>t.key===n.modelValue);if(e)return e.icon}return n.placeholderIcon}),O=e=>{const t=Array.from(e.target.options).filter(u=>u.selected).map(u=>u.value),a=o.value.filter(u=>t.indexOf(u.key)>=0),m=n.multiple?a.map(u=>u.key):a[0].key;d(m)},b=e=>{i.value=e,r.value=o.value.findIndex(t=>t.key===e)},D=e=>{v.value=e};return l.onMounted(()=>{document.addEventListener("keydown",h)}),l.onUnmounted(()=>{document.removeEventListener("keydown",h)}),l.watch(()=>c.value,e=>{e&&(i.value=o.value[0].key,r.value=0)}),{dropdown:f,open:c,highlightedKey:i,highlightedIndex:r,flattenedOptions:o,computedLabel:j,sanitizedAttributes:q,computedOptions:S,computedIcon:V,clickOption:y,nativeSelectChange:O,changeHighlighted:b,onPlacement:D}}});module.exports=C;
|
|
2
2
|
//# sourceMappingURL=NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js.map
|
package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=37fb08e4&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n return props.options || props.groupedOptions?.flatMap((group) => group.options) || [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonDropdown","NeonIcon","NeonSwitch","NeonSize","NeonFunctionalColor","props","emit","attrs","useAttrs","dropdown","ref","open","dropdownPlacement","highlightedKey","highlightedIndex","flattenedOptions","computed","_a","group","isReverse","NeonDropdownPlacement","scrollOnNavigate","element","NeonScrollUtils","navigateBy","offset","$event","newIndex","emitInputEvent","value","clickOption","option","values","index","v","keyboardHandler","reverseOffset","computedOptions","sanitizedAttributes","sanitized","computedLabel","selected","computedIcon","nativeSelectChange","event","selectedKeys","opt","selectedOptions","changeHighlighted","key","onPlacement","placement","onMounted","onUnmounted","watch"],"mappings":"waAiBAA,EAAeC,kBAAgB,CAC7B,KAAM,aACN,WAAY,CACV,aAAAC,EACA,SAAAC,EACA,WAAAC,CACF,EACA,MAAO,CAIL,YAAa,CAAE,KAAM,OAAQ,SAAU,EAAK,EAI5C,oBAAqB,CAAE,KAAM,QAAS,QAAS,EAAM,EAIrD,gBAAiB,CAAE,KAAM,OAAQ,SAAU,EAAM,EAIjD,QAAS,CAAE,KAAM,MAAwC,SAAU,EAAM,EAIzE,eAAgB,CAAE,KAAM,MAAuC,SAAU,EAAM,EAK/E,WAA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AAkB,CACbA,IACaE,EAAA,MAAQE,EAAiB,MAAM,GAAG,IACjDD,EAAiB,MAAQ,EAE7B,CAAA,EAGK,CACL,SAAAL,EACA,KAAAE,EACA,eAAAE,EACA,iBAAAC,EACA,iBAAAC,EACA,cAAAyB,EACA,oBAAAF,EACA,gBAAAD,EACA,aAAAK,EACA,YAAAZ,EACA,mBAAAa,EACA,kBAAAK,EACA,YAAAE,CAAA,CAEJ,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_37fb08e4_lang.cjs.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=37fb08e4&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Id for the dropdown button\n */\n id: { type: String },\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n return props.options || props.groupedOptions?.flatMap((group) => group.options) || [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonDropdown","NeonIcon","NeonSwitch","NeonSize","NeonFunctionalColor","props","emit","attrs","useAttrs","dropdown","ref","open","dropdownPlacement","highlightedKey","highlightedIndex","flattenedOptions","computed","_a","group","isReverse","NeonDropdownPlacement","scrollOnNavigate","element","NeonScrollUtils","navigateBy","offset","$event","newIndex","emitInputEvent","value","clickOption","option","values","index","v","keyboardHandler","reverseOffset","computedOptions","sanitizedAttributes","sanitized","computedLabel","selected","computedIcon","nativeSelectChange","event","selectedKeys","opt","selectedOptions","changeHighlighted","key","onPlacement","placement","onMounted","onUnmounted","watch"],"mappings":"waAiBAA,EAAeC,kBAAgB,CAC7B,KAAM,aACN,WAAY,CACV,aAAAC,EACA,SAAAC,EACA,WAAAC,CACF,EACA,MAAO,CAIL,GAAI,CAAE,KAAM,MAAO,EAInB,YAAa,CAAE,KAAM,OAAQ,SAAU,EAAK,EAI5C,oBAAqB,CAAE,KAAM,QAAS,QAAS,EAAM,EAIrD,gBAAiB,CAAE,KAAM,OAAQ,SAAU,EAAM,EAIjD,QAAS,CAAE,KAAM,MAAwC,SAAU,EAAM,EAIzE,eAAgB,CAAE,KAAM,MAAuC,SAAU,EAAM,EAK/E,WAAY,CAAE,KAAM,CAAC,OAAQ,KAA4B,EAAG,SAAU,EAAK,EAI3E,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,uBAAwB,CAAE,KAAM,OAAQ,SAAU,EAAM,EAIxD,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,KAAM,CAAE,KAAM,OAA0B,QAASC,EAAAA,SAAS,MAAO,EAIjE,MAAO,CAAE,KAAM,OAAqC,QAASC,EAAAA,oBAAoB,WAAY,CAC/F,EACA,MAAO,CAML,mBACF,EACA,MAAMC,EAAO,CAAE,KAAAC,GAAQ,CACrB,MAAMC,EAAQC,EAAAA,WAERC,EAAWC,MAAwB,IAAI,EAEvCC,EAAOD,MAAI,EAAK,EAChBE,EAAoBF,MAAkC,IAAI,EAC1DG,EAAiBH,MAAmB,IAAI,EACxCI,EAAmBJ,EAAAA,IAAI,EAAE,EAEzBK,EAAmBC,EAAAA,SAAS,IAA0B,OACnD,OAAAX,EAAM,WAAWY,EAAAZ,EAAM,iBAAN,YAAAY,EAAsB,QAASC,GAAUA,EAAM,WAAY,EAAC,CACrF,EAEKC,EAAY,IAAM,CAClB,GAAA,CAACd,EAAM,eACT,OAAQO,EAAkB,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vFL,EAAQxB,EAAM,SAAW0C,EAAgB,IAAKlB,GAAUA,EAAM,GAAG,EAAIkB,EAAgB,GAAG,IAC9FnB,EAAeC,CAAK,CAAA,EAGhBmB,EAAqBC,GAAgB,CACzCpC,EAAe,MAAQoC,EACNnC,EAAA,MAAQC,EAAiB,MAAM,UAAW+B,GAAQA,EAAI,MAAQG,CAAG,CAAA,EAG9EC,EAAeC,GAAqC,CACxDvC,EAAkB,MAAQuC,CAAA,EAG5BC,OAAAA,EAAAA,UAAU,IAAM,CACL,SAAA,iBAAiB,UAAWjB,CAAe,CAAA,CACrD,EAEDkB,EAAAA,YAAY,IAAM,CACP,SAAA,oBAAoB,UAAWlB,CAAe,CAAA,CACxD,EAEDmB,EAAA,MACE,IAAM3C,EAAK,MACVA,GAAkB,CACbA,IACaE,EAAA,MAAQE,EAAiB,MAAM,GAAG,IACjDD,EAAiB,MAAQ,EAE7B,CAAA,EAGK,CACL,SAAAL,EACA,KAAAE,EACA,eAAAE,EACA,iBAAAC,EACA,iBAAAC,EACA,cAAAyB,EACA,oBAAAF,EACA,gBAAAD,EACA,aAAAK,EACA,YAAAZ,EACA,mBAAAa,EACA,kBAAAK,EACA,YAAAE,CAAA,CAEJ,CACF,CAAC"}
|
package/dist/components/user-input/select/NeonSelect.ts_vue_type_script_src_37fb08e4_lang.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_37fb08e4_lang.es.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=37fb08e4&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n return props.options || props.groupedOptions?.flatMap((group) => group.options) || [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["value","open"],"mappings":";;;;;;;;AAiBA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,aAAa,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAI5C,qBAAqB,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAIrD,iBAAiB,EAAE,MAAM,QAAQ,UAAU,MAAM;AAAA,IAIjD,SAAS,EAAE,MAAM,OAAwC,UAAU,MAAM;AAAA,IAIzE,gBAAgB,EAAE,MAAM,OAAuC,UAAU,MAAM;AAAA,IAK/E,YAAY,EAAE,MAAM,CAAC,QAAQ,KAA4B,GAAG,UAAU,KAAK;AAAA,IAI3E,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,wBAAwB,EAAE,MAAM,QAAQ,UAAU,MAAM;AAAA,IAIxD,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,MAAM,EAAE,MAAM,QAA0B,SAAS,SAAS,OAAO;AAAA,IAIjE,OAAO,EAAE,MAAM,QAAqC,SAAS,oBAAoB,YAAY;AAAA,EAC/F;AAAA,EACA,OAAO;AAAA,IAML;AAAA,EACF;AAAA,EACA,MAAM,OAAO,EAAE,QAAQ;AACrB,UAAM,QAAQ;AAER,UAAA,WAAW,IAAwB,IAAI;AAEvC,UAAA,OAAO,IAAI,KAAK;AAChB,UAAA,oBAAoB,IAAkC,IAAI;AAC1D,UAAA,iBAA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AM,GAAG;AACjD,2BAAiB,QAAQ;AAAA,QAC3B;AAAA,MACF;AAAA,IAAA;AAGK,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"NeonSelect.ts_vue_type_script_src_37fb08e4_lang.es.js","sources":["../../../../src/components/user-input/select/NeonSelect.ts?vue&type=script&src=37fb08e4&lang.ts"],"sourcesContent":["import { computed, defineComponent, onMounted, onUnmounted, ref, useAttrs, watch } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport type { NeonSelectGroup } from '@/common/models/NeonSelectGroup';\nimport type { NeonSelectOption } from '@/common/models/NeonSelectOption';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonDropdown from '@/components/presentation/dropdown/NeonDropdown.vue';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport NeonSwitch from '@/components/user-input/switch/NeonSwitch.vue';\nimport { NeonDropdownPlacement } from '@/common/enums/NeonDropdownPlacement';\nimport { NeonScrollUtils } from '@/common/utils/NeonScrollUtils';\n\n/**\n * <p>The <strong>NeonSelect</strong> is the equivalent of an HTML <select> form control. On touch devices\n * NeonSelect will use the native select for input. <strong>NeonSelect</strong> supports grouping and multiselect.</p>\n * <p><strong>Note:</strong> As well as the options described below, pass through attributes supported by\n * <a href=\"/presentation/dropdown\">NeonDropdown</a> to change the style of the dropdown button.</p>\n */\nexport default defineComponent({\n name: 'NeonSelect',\n components: {\n NeonDropdown,\n NeonIcon,\n NeonSwitch,\n },\n props: {\n /**\n * Id for the dropdown button\n */\n id: { type: String },\n /**\n * Placeholder to display as button label when there is no option selected.\n */\n placeholder: { type: String, required: true },\n /**\n * Display the placeholder as the first option in the select, this is useful as an alternative to a label.\n */\n placeholderAsOption: { type: Boolean, default: false },\n /**\n * Optional placeholder icon.\n */\n placeholderIcon: { type: String, required: false },\n /**\n * A list of options to render in the select.\n */\n options: { type: Array as () => Array<NeonSelectOption>, required: false },\n /**\n * A list of grouped options to render in the select.\n */\n groupedOptions: { type: Array as () => Array<NeonSelectGroup>, required: false },\n /**\n * Either a single string, indicating the key of the selected option or an array of selected keys in the case\n * multiple = true.\n */\n modelValue: { type: [String, Array as () => Array<string>], required: true },\n /**\n * Allow multi-select.\n */\n multiple: { type: Boolean, default: false },\n /**\n * Placeholder when multiple values are selected.\n */\n multiselectPlaceholder: { type: String, required: false },\n /**\n * Disable the select\n */\n disabled: { type: Boolean, default: false },\n /**\n * The size of the dropdown - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the select.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n },\n emits: [\n /**\n * emitted when the user changes the selection.\n * @type {string | string[]} either the selected option's key (single select) or an array of the selected keys\n * (multi-select).\n */\n 'update:modelValue',\n ],\n setup(props, { emit }) {\n const attrs = useAttrs();\n\n const dropdown = ref<HTMLElement | null>(null);\n\n const open = ref(false);\n const dropdownPlacement = ref<NeonDropdownPlacement | null>(null);\n const highlightedKey = ref<string | null>(null);\n const highlightedIndex = ref(-1);\n\n const flattenedOptions = computed((): NeonSelectOption[] => {\n return props.options || props.groupedOptions?.flatMap((group) => group.options) || [];\n });\n\n const isReverse = () => {\n if (!props.groupedOptions) {\n switch (dropdownPlacement.value) {\n case NeonDropdownPlacement.TopLeft:\n case NeonDropdownPlacement.TopRight:\n case NeonDropdownPlacement.LeftBottom:\n case NeonDropdownPlacement.RightBottom:\n return true;\n }\n }\n\n return false;\n };\n\n const scrollOnNavigate = () => {\n const element = dropdown.value?.querySelector('.neon-select__option--highlighted') as HTMLElement;\n\n if (element) {\n NeonScrollUtils.scrollIntoView(element);\n }\n };\n\n const navigateBy = (offset: number, $event: KeyboardEvent) => {\n const newIndex = highlightedIndex.value + offset;\n if (newIndex >= 0 && newIndex <= flattenedOptions.value.length - 1) {\n highlightedIndex.value = newIndex;\n highlightedKey.value = flattenedOptions.value[highlightedIndex.value].key;\n $event.preventDefault();\n setTimeout(scrollOnNavigate);\n }\n };\n\n const emitInputEvent = (value: string | string[]) => {\n emit('update:modelValue', value);\n };\n\n const clickOption = (option: NeonSelectOption) => {\n if (props.multiple) {\n const values = [...props.modelValue];\n const index = values.findIndex((v) => v === option.key);\n if (index >= 0) {\n values.splice(index, 1);\n } else {\n values.push(option.key);\n }\n emitInputEvent(values);\n } else if (props.modelValue !== option.key) {\n open.value = false;\n emitInputEvent(option.key);\n }\n };\n\n const keyboardHandler = ($event: KeyboardEvent) => {\n if (open.value) {\n switch ($event.code) {\n case 'ArrowUp':\n case 'ArrowDown': {\n const reverseOffset = isReverse() ? -1 : 1;\n if ($event.code === 'ArrowUp') {\n navigateBy(-1 * reverseOffset, $event);\n } else {\n navigateBy(1 * reverseOffset, $event);\n }\n }\n break;\n case 'Enter':\n case 'Space':\n if (!flattenedOptions.value[highlightedIndex.value].disabled) {\n clickOption(flattenedOptions.value[highlightedIndex.value]);\n $event.preventDefault();\n }\n break;\n case 'Tab':\n if (!$event.ctrlKey && !$event.metaKey && !$event.altKey) {\n open.value = false;\n }\n break;\n }\n }\n };\n\n const computedOptions = computed((): Array<NeonSelectGroup> => {\n return (\n props.groupedOptions || [\n {\n group: '',\n options: props.options || [],\n },\n ]\n );\n });\n\n const sanitizedAttributes = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { ...sanitized } = attrs;\n return sanitized;\n });\n\n const computedLabel = computed(() => {\n if (props.multiple && props.modelValue.length > 0) {\n if (props.multiselectPlaceholder) {\n return props.multiselectPlaceholder;\n } else if (props.modelValue.length > 1) {\n return `${props.modelValue.length} items selected`;\n } else {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue[0]);\n return selected?.label || '';\n }\n } else if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.label;\n }\n }\n\n return props.placeholder;\n });\n\n const computedIcon = computed(() => {\n if (props.modelValue) {\n const selected = flattenedOptions.value.find((option) => option.key === props.modelValue);\n\n if (selected) {\n return selected.icon;\n }\n }\n\n return props.placeholderIcon;\n });\n\n const nativeSelectChange = (event: Event) => {\n const selectedKeys = Array.from((event.target as HTMLSelectElement).options)\n .filter((opt) => opt.selected)\n .map((opt) => opt.value);\n const selectedOptions = flattenedOptions.value.filter((v) => selectedKeys.indexOf(v.key) >= 0);\n const value = props.multiple ? selectedOptions.map((value) => value.key) : selectedOptions[0].key;\n emitInputEvent(value);\n };\n\n const changeHighlighted = (key: string) => {\n highlightedKey.value = key;\n highlightedIndex.value = flattenedOptions.value.findIndex((opt) => opt.key === key);\n };\n\n const onPlacement = (placement: NeonDropdownPlacement) => {\n dropdownPlacement.value = placement;\n };\n\n onMounted(() => {\n document.addEventListener('keydown', keyboardHandler);\n });\n\n onUnmounted(() => {\n document.removeEventListener('keydown', keyboardHandler);\n });\n\n watch(\n () => open.value,\n (open: boolean) => {\n if (open) {\n highlightedKey.value = flattenedOptions.value[0].key;\n highlightedIndex.value = 0;\n }\n },\n );\n\n return {\n dropdown,\n open,\n highlightedKey,\n highlightedIndex,\n flattenedOptions,\n computedLabel,\n sanitizedAttributes,\n computedOptions,\n computedIcon,\n clickOption,\n nativeSelectChange,\n changeHighlighted,\n onPlacement,\n };\n },\n});\n"],"names":["value","open"],"mappings":";;;;;;;;AAiBA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,IAAI,EAAE,MAAM,OAAO;AAAA,IAInB,aAAa,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAI5C,qBAAqB,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,I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AI,QAAQ,EAC5B,IAAI,CAAC,QAAQ,IAAI,KAAK;AACnB,YAAA,kBAAkB,iBAAiB,MAAM,OAAO,CAAC,MAAM,aAAa,QAAQ,EAAE,GAAG,KAAK,CAAC;AACvF,YAAA,QAAQ,MAAM,WAAW,gBAAgB,IAAI,CAACA,WAAUA,OAAM,GAAG,IAAI,gBAAgB,GAAG;AAC9F,qBAAe,KAAK;AAAA,IAAA;AAGhB,UAAA,oBAAoB,CAAC,QAAgB;AACzC,qBAAe,QAAQ;AACN,uBAAA,QAAQ,iBAAiB,MAAM,UAAU,CAAC,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAAA;AAG9E,UAAA,cAAc,CAAC,cAAqC;AACxD,wBAAkB,QAAQ;AAAA,IAAA;AAG5B,cAAU,MAAM;AACL,eAAA,iBAAiB,WAAW,eAAe;AAAA,IAAA,CACrD;AAED,gBAAY,MAAM;AACP,eAAA,oBAAoB,WAAW,eAAe;AAAA,IAAA,CACxD;AAED;AAAA,MACE,MAAM,KAAK;AAAA,MACX,CAACC,UAAkB;AACjB,YAAIA,OAAM;AACO,yBAAA,QAAQ,iBAAiB,MAAM,GAAG;AACjD,2BAAiB,QAAQ;AAAA,QAC3B;AAAA,MACF;AAAA,IAAA;AAGK,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aotearoan/neon",
|
|
3
3
|
"description": "Neon is a lightweight design library of Vue 3 components with minimal dependencies.",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.2-beta-1",
|
|
5
5
|
"main": "./dist/neoon.cjs.js",
|
|
6
6
|
"module": "dist/neon.es.js",
|
|
7
7
|
"types": "dist/neon.d.ts",
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
@use '../includes/responsive';
|
|
2
|
+
@use '../includes/typography';
|
|
2
3
|
|
|
3
4
|
$message-height: calc(var(--neon-font-size-s) * var(--neon-line-height-ratio));
|
|
4
5
|
|
|
5
6
|
@mixin field {
|
|
6
7
|
.neon-field {
|
|
8
|
+
width: fit-content;
|
|
9
|
+
margin-bottom: calc(2 * var(--neon-base-space));
|
|
10
|
+
|
|
7
11
|
& + .neon-field {
|
|
8
12
|
margin-top: calc(4 * var(--neon-base-space));
|
|
9
13
|
|
|
@@ -16,11 +20,12 @@ $message-height: calc(var(--neon-font-size-s) * var(--neon-line-height-ratio));
|
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
&
|
|
23
|
+
&__label-wrapper {
|
|
20
24
|
display: inline-flex;
|
|
21
25
|
align-items: center;
|
|
22
26
|
margin-bottom: var(--neon-base-space);
|
|
23
27
|
gap: calc(1.5 * var(--neon-base-space));
|
|
28
|
+
@include typography.label;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
&.neon-field--disabled {
|
|
@@ -159,6 +159,7 @@
|
|
|
159
159
|
blockquote,
|
|
160
160
|
.neon-note,
|
|
161
161
|
table,
|
|
162
|
+
label,
|
|
162
163
|
p {
|
|
163
164
|
& + h1,
|
|
164
165
|
& + .neon-h1,
|
|
@@ -214,10 +215,6 @@
|
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
label:not(.no-style) {
|
|
218
|
-
color: var(--neon-label-color);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
218
|
.neon-color-text {
|
|
222
219
|
color: var(--neon-color-text);
|
|
223
220
|
}
|
|
@@ -93,15 +93,10 @@
|
|
|
93
93
|
@include typography.neon-h6;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
label {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
letter-spacing: var(--neon-letter-spacing-m);
|
|
101
|
-
text-transform: uppercase;
|
|
102
|
-
user-select: none;
|
|
103
|
-
margin-bottom: calc(2 * var(--neon-base-space));
|
|
104
|
-
}
|
|
96
|
+
label:not(.no-style):not(.neon-field) {
|
|
97
|
+
width: fit-content;
|
|
98
|
+
margin-bottom: calc(2 * var(--neon-base-space));
|
|
99
|
+
@include typography.label;
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
@include responsive.responsive(mobile-large) {
|
|
@@ -46,3 +46,12 @@
|
|
|
46
46
|
margin-top: 0;
|
|
47
47
|
font-size: var(--neon-h6-size);
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
@mixin label {
|
|
51
|
+
color: var(--neon-label-color);
|
|
52
|
+
font-size: var(--neon-font-size-xs);
|
|
53
|
+
font-weight: var(--neon-font-weight-semi-bold);
|
|
54
|
+
letter-spacing: var(--neon-letter-spacing-m);
|
|
55
|
+
text-transform: uppercase;
|
|
56
|
+
user-select: none;
|
|
57
|
+
}
|