@fkui/vue 5.36.3 → 5.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +42 -26
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/esm/index.esm.js +43 -27
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/types/index.d.ts +174 -67
- package/htmlvalidate/elements/components.js +12 -1
- package/package.json +12 -12
package/dist/esm/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"core-js/modules/es.array.push.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:true,configurable:true,writable:true,value}):obj[key]=value;var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!=="symbol"?key+"":key,value);import{defineComponent,openBlock,createElementBlock,normalizeClass,renderSlot,mergeProps,createTextVNode,createElementVNode,isVNode,Comment,createApp,resolveComponent,withKeys,createCommentVNode,toDisplayString,createVNode,createBlock,withCtx,Fragment,renderList,withModifiers,resolveDynamicComponent,Teleport,normalizeProps,guardReactiveProps,ref,inject,toValue,Transition,createSlots,withDirectives,vModelSelect,normalizeStyle,vModelDynamic,toHandlers,shallowRef,vShow,onMounted,onUnmounted,watchEffect,toRefs,computed,getCurrentInstance}from"vue";import{TranslationService,isSet,configLogic,focus as focus$1,ElementIdService,pushFocus,findTabbableElements,popFocus,scrollTo,Reference,documentOrderComparator,ValidationService,isValidatableHTMLElement,alertScreenReader,debounce,handleTab,deepClone,formatNumber,parseNumber,parseBankAccountNumber,parseBankgiro,parseClearingNumber,formatPersonnummer,parsePersonnummer,parsePlusgiro,formatPostalCode,parsePercent,formatPercent,parseOrganisationsnummer,isInvalidDatesConfig,isInvalidWeekdaysConfig,parseDate,waitForScreenReader,saveFocus,addFocusListener,removeFocusListener,restoreFocus,DomUtils,focusFirst}from"@fkui/logic";import{getWeekdayNamings,groupByWeek,FDate,DateFormat}from"@fkui/date";import{isEqual as isEqual$2}from"lodash";const statuses=["default","warning","error","success","info"];const _sfc_main$1d=defineComponent({name:"FBadge",props:{/**
|
|
1
|
+
import"core-js/modules/es.array.push.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:true,configurable:true,writable:true,value}):obj[key]=value;var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!=="symbol"?key+"":key,value);import{defineComponent,openBlock,createElementBlock,normalizeClass,renderSlot,mergeProps,createTextVNode,createElementVNode,isVNode,Comment,createApp,resolveComponent,withKeys,createCommentVNode,toDisplayString,createVNode,createBlock,withCtx,Fragment,renderList,withModifiers,resolveDynamicComponent,Teleport,normalizeProps,guardReactiveProps,ref,inject,useSlots,provide,toValue,Transition,createSlots,withDirectives,vModelSelect,normalizeStyle,vModelDynamic,toHandlers,shallowRef,vShow,onMounted,onUnmounted,watchEffect,toRefs,computed,getCurrentInstance}from"vue";import{TranslationService,isSet,configLogic,focus as focus$1,ElementIdService,pushFocus,findTabbableElements,popFocus,scrollTo,Reference,documentOrderComparator,ValidationService,isValidatableHTMLElement,alertScreenReader,debounce,handleTab,deepClone,formatNumber,parseNumber,parseBankAccountNumber,parseBankgiro,parseClearingNumber,formatPersonnummer,parsePersonnummer,parsePlusgiro,formatPostalCode,parsePercent,formatPercent,parseOrganisationsnummer,isInvalidDatesConfig,isInvalidWeekdaysConfig,parseDate,waitForScreenReader,saveFocus,addFocusListener,removeFocusListener,restoreFocus,DomUtils,focusFirst}from"@fkui/logic";import{getWeekdayNamings,groupByWeek,FDate,DateFormat}from"@fkui/date";import{isEqual as isEqual$2}from"lodash";const statuses=["default","warning","error","success","info"];const _sfc_main$1d=defineComponent({name:"FBadge",props:{/**
|
|
2
2
|
* The status of the badge, can be either 'default', 'warning', 'error', 'success' or 'info'.
|
|
3
3
|
*
|
|
4
4
|
*/status:{type:String,default:"default",validator:function(value){return statuses.includes(value);}},/**
|
|
@@ -136,7 +136,11 @@ isIndex(key,length)))){result.push(key);}}return result;}var _arrayLikeKeys=arra
|
|
|
136
136
|
* If the prop is not set a random value will be generated.
|
|
137
137
|
*/id:{type:String,required:false,default:()=>ElementIdService.generateElementId()},/**
|
|
138
138
|
* Include the error list component.
|
|
139
|
-
*/useErrorList:{type:Boolean,required:false,default:true}
|
|
139
|
+
*/useErrorList:{type:Boolean,required:false,default:true},/**
|
|
140
|
+
* Display bullets in the error list component.
|
|
141
|
+
*/errorListBullets:{type:Boolean,required:false,default:true},/**
|
|
142
|
+
*Optional callback function to the error list component for performing actions before navigation.
|
|
143
|
+
*/errorListBeforeNavigate:{type:Function,required:false,default(){return()=>{};}}},emits:["submit"],data(){return{validity:{isValid:true,componentsWithError:[],componentCount:0},submitted:false};},computed:{groupKey(){return`${this.id}-group`;},errors(){return this.validity.componentsWithError.map(c=>({id:c.elementId,focusElementId:c.focusElementId,title:c.errorMessage}));},displayErrors(){return this.useErrorList&&this.submitted&&this.errors.length>0;}},methods:{async hasFormErrors(){ValidationService.setSubmitted(this.id);await ValidationService.validateAllElements(this.id);await this.$nextTick();await new Promise(resolve=>window.setTimeout(resolve,0));if(this.validity.isValid){return false;}if(this.useErrorList){focus$1(this.$refs.errors);}else{const firstError=this.validity.componentsWithError[0];const element=document.getElementById(firstError.focusElementId);focus$1(element);}return true;},async onSubmit(event){this.submitted=true;const beforeValidation=this.beforeValidation?await this.beforeValidation():void 0;if(beforeValidation===FValidationFormAction.CANCEL){return;}if(await this.hasFormErrors()){return;}const beforeAction=this.beforeSubmit?await this.beforeSubmit():void 0;if(beforeAction===FValidationFormAction.CANCEL){return;}if(await this.hasFormErrors()){return;}this.$emit("submit",event);}}});const _hoisted_1$Q=["id"];const _hoisted_2$C={key:0,ref:"errors",tabindex:"-1",role:"group"};function _sfc_render$X(_ctx,_cache,$props,$setup,$data,$options){const _component_f_error_list=resolveComponent("f-error-list");const _component_f_validation_group=resolveComponent("f-validation-group");return openBlock(),createBlock(_component_f_validation_group,{key:_ctx.groupKey,modelValue:_ctx.validity,"onUpdate:modelValue":_cache[1]||(_cache[1]=$event=>_ctx.validity=$event),"stop-propagation":true},{default:withCtx(()=>[createElementVNode("form",mergeProps({id:_ctx.id},_ctx.$attrs,{novalidate:"",autocomplete:"off",onSubmit:_cache[0]||(_cache[0]=withModifiers((...args)=>_ctx.onSubmit&&_ctx.onSubmit(...args),["prevent"]))}),[_ctx.displayErrors?(openBlock(),createElementBlock("nav",_hoisted_2$C,[createVNode(_component_f_error_list,{items:_ctx.errors,bullets:_ctx.errorListBullets,"before-navigate":_ctx.errorListBeforeNavigate},{title:withCtx(()=>[renderSlot(_ctx.$slots,"error-message")]),_:3/* FORWARDED */},8,["items","bullets","before-navigate"])],512/* NEED_PATCH */)):createCommentVNode("v-if",true),createTextVNode(),renderSlot(_ctx.$slots,"default")],16,_hoisted_1$Q)]),_:3/* FORWARDED */},8,["modelValue"]);}const FValidationForm=/* @__PURE__ */_export_sfc(_sfc_main$15,[["render",_sfc_render$X]]);const _sfc_main$14=defineComponent({name:"FFormModal",components:{FModal,FValidationForm},mixins:[TranslationMixin],inheritAttrs:true,props:{/**
|
|
140
144
|
* Enable fullscreen mode in mobile.
|
|
141
145
|
*/fullscreen:{type:Boolean,required:false,default:true},/**
|
|
142
146
|
* If the modal is open.
|
|
@@ -235,22 +239,7 @@ isIndex(key,length)))){result.push(key);}}return result;}var _arrayLikeKeys=arra
|
|
|
235
239
|
* The items to be diplayed in the menu
|
|
236
240
|
*/items:{type:Array,required:true},/**
|
|
237
241
|
* Unique accessible name for navigation landmark.
|
|
238
|
-
*/ariaLabel:{type:String,required:false,default:"Kontextuell meny"}},emits:["close","select"],setup(){return{contextmenu:ref(null)};},data(){return{selectedItem:"",currentFocusedItemIndex:-1};},computed:{popupItems(){return this.items.filter(isContextMenuTextItem);},separatorPositions(){const res=[];if(this.items.length>1){this.items.forEach((it,i)=>{if(isContextMenuSeparatorItem(it)){const pos=i-1-res.length;if(pos>=0&&pos<this.items.length-1){res.push(pos);}}});}return res;},hasIcons(){return this.items.some(it=>isContextMenuTextItem(it)&&it.icon);}},watch:{isOpen:{immediate:true,async handler(){if(this.isOpen){this.currentFocusedItemIndex=-1;this.selectedItem="";}}}},methods:{hasSeparatorAfterItemAt(index){return this.separatorPositions.includes(index);},closePopup(){this.$emit("close");},onClickItem(item){if(isContextMenuTextItem(item)&&item.key){this.selectedItem=item.key;this.$emit("select",this.selectedItem);this.closePopup();}},tabIndex(index){return index===this.currentFocusedItemIndex?0:-1;},onKeyUp(event){if(preventKeys$3.includes(event.key)){event.preventDefault();}},doHandlePopupMenuTabKey(action){if(action===MenuAction.MOVE_NEXT&&this.currentFocusedItemIndex+1===this.popupItems.length){this.closePopup();return true;}else if(action===MenuAction.MOVE_PREV&&(this.currentFocusedItemIndex===0||this.currentFocusedItemIndex===-1)){this.closePopup();return false;}return false;},async onKeyDown(event){if(!preventKeys$3.includes(event.key)){return;}if(event.key==="Escape"){this.$emit("close");return;}const action=actionFromKeyboardEvent(event);if(action===null){return;}if(event.key==="Tab"&&this.doHandlePopupMenuTabKey(action)){return;}if(keyUp$1.includes(event.key)&&this.currentFocusedItemIndex===-1){this.currentFocusedItemIndex=this.popupItems.length>0?this.popupItems.length:1;}event.preventDefault();await doMenuAction$3(action,this);},async setFocusOnItem(index){if(index<0||index>=this.popupItems.length){return;}this.currentFocusedItemIndex=index;await this.$nextTick();if(!this.isOpen){return;}const items=getHTMLElementsFromVueRef(this.$refs.items);if(items.length>0){const popupMenuItem=items[index];focus$1(popupMenuItem,{preventScroll:true});}},async activateItem(index){if(index<0||index>=this.popupItems.length){return;}if(index!==this.currentFocusedItemIndex){await this.setFocusOnItem(index);}this.onClickItem(this.popupItems[this.currentFocusedItemIndex]);}}});const _hoisted_1$I=["aria-label"];const _hoisted_2$w={ref:"contextmenu",role:"menu",tabindex:"-1",class:"contextmenu__list"};const _hoisted_3$s=["onClick"];const _hoisted_4$n=["tabindex"];const _hoisted_5$l={key:0,class:"contextmenu__separator"};function _sfc_render$N(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");const _component_i_popup=resolveComponent("i-popup");return openBlock(),createBlock(_component_i_popup,{"is-open":_ctx.isOpen,"keyboard-trap":false,anchor:_ctx.anchor,"set-focus":true,"focus-element":()=>_ctx.contextmenu,inline:"never",onClose:_cache[2]||(_cache[2]=$event=>_ctx.$emit("close"))},{default:withCtx(()=>[createElementVNode("nav",{class:"contextmenu","aria-label":_ctx.ariaLabel,onKeyup:_cache[0]||(_cache[0]=(...args)=>_ctx.onKeyUp&&_ctx.onKeyUp(...args)),onKeydown:_cache[1]||(_cache[1]=(...args)=>_ctx.onKeyDown&&_ctx.onKeyDown(...args))},[createElementVNode("ul",_hoisted_2$w,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.popupItems,(item,index)=>{return openBlock(),createElementBlock("li",{key:item.key,role:"menuitem",onClick:$event=>_ctx.onClickItem(item)},[createElementVNode("div",{ref_for:true,ref:"items",tabindex:_ctx.tabIndex(index),class:"contextmenu__list__item"},[_ctx.hasIcons?(openBlock(),createBlock(_component_f_icon,{key:0,class:"contextmenu__lefticon",name:item.icon?item.icon:"",library:item.iconLibrary?item.iconLibrary:"f"},null,8,["name","library"])):createCommentVNode("v-if",true),createTextVNode(),createElementVNode("a",{ref_for:true,ref:"anchors"},toDisplayString(item.label),513/* TEXT, NEED_PATCH */)],8,_hoisted_4$n),createTextVNode(),_ctx.hasSeparatorAfterItemAt(index)?(openBlock(),createElementBlock("hr",_hoisted_5$l)):createCommentVNode("v-if",true)],8,_hoisted_3$s);}),128/* KEYED_FRAGMENT */))],512/* NEED_PATCH */)],40,_hoisted_1$I)]),_:1/* STABLE */},8,["is-open","anchor","focus-element"]);}const FContextMenu=/* @__PURE__ */_export_sfc(_sfc_main$X,[["render",_sfc_render$N]]);const
|
|
239
|
-
* Set to `true`, empty string `""` or string `"disabled"` to disable this input field.
|
|
240
|
-
*/disabled:{type:Boolean,required:false,default:false},/**
|
|
241
|
-
* The id for the input id attribute.
|
|
242
|
-
* The id for the label for attribute.
|
|
243
|
-
* If the prop is not set a random value will be generated.
|
|
244
|
-
*/id:{type:String,required:false,default:()=>ElementIdService.generateElementId()},/**
|
|
245
|
-
* The value for the input checked attribute.
|
|
246
|
-
* @model
|
|
247
|
-
*/// ? The rule is disabled so that the `checked` prop can be undefined or null.
|
|
248
|
-
/* eslint-disable-next-line vue/require-default-prop -- technical debt,
|
|
249
|
-
/* it should contain a default value of undefined and proptype should
|
|
250
|
-
/* include undefined (see comment on line above) */modelValue:{type:anyType$1,required:false},/**
|
|
251
|
-
* The value for the input.
|
|
252
|
-
*/value:{type:anyType$1,required:true}},emits:["change","update:modelValue"],setup(){return{showDetails:inject("showDetails","never"),getFieldsetLabelText:inject("getFieldsetLabelText",()=>"")};},data(){return{expanded:false,height:0,initialStyle:{overflow:"hidden",transition:"height 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96)"},hiddenStyle:{height:"auto",position:"absolute",visibility:"hidden"},visibleStyle:{width:"",position:"",visibility:"",height:"0px"},openedStyle:{height:"auto"}};},computed:{attrs(){let checked;if(Array.isArray(this.modelValue)){checked=this.modelValue.findIndex(it=>isEqual$2(toValue(it),toValue(this.value)))>=0;}else{checked=this.value===this.modelValue;}return{...this.$attrs,value:this.value,checked,onChange:event=>{if(event.target instanceof HTMLInputElement){this.emitVModelEvent(event);}},onInput:event=>{event.target.focus();}};},disabledClass(){return this.disabled?"disabled":"";},// eslint-disable-next-line @typescript-eslint/no-explicit-any -- technical debt, nore sure whats going on here
|
|
253
|
-
injected(){return this;}},methods:{updateExpandedFlag(){const checkboxInput=getHTMLElementFromVueRef(this.$refs["checkboxInput"]);this.expanded=checkboxInput.checked;},emitVModelEvent(event){let newModel;if(Array.isArray(this.modelValue)){newModel=[...this.modelValue].filter(it=>!isEqual$2(toValue(it),toValue(this.value)));if(this.modelValue.length<=newModel.length){newModel.push(this.value);}}else{if(this.value===this.modelValue){newModel=typeof this.value==="boolean"?false:void 0;}else{const target=event.target;newModel=target.value==="true"?true:this.value;}}this.$emit("update:modelValue",newModel);this.$emit("change",newModel);},onKeydown(event){event.stopPropagation();},onValidity({detail}){if(detail.target!==this.$el.querySelector("input")){return;}let errorMessage="";if(hasSlot(this,"default")){const labelText=this.injected.getFieldsetLabelText();if(labelText){errorMessage=`${labelText} ${renderSlotText(this.$slots.default)}`;}else{errorMessage=`${renderSlotText(this.$slots.default)}`;}}const element=this.$el.querySelector(`#${detail.elementId}`);if(element){dispatchComponentValidityEvent(element,{...detail,errorMessage,focusElementId:detail.elementId});}},enter(element){const htmlElement=getHTMLElementFromVueRef(element);const computedStyle=getComputedStyle(element);Object.assign(htmlElement.style,this.initialStyle);Object.assign(htmlElement.style,this.hiddenStyle);htmlElement.style.width=computedStyle.width;const height=computedStyle.height;Object.assign(htmlElement.style,this.visibleStyle);getComputedStyle(element).height;setTimeout(()=>{this.height=parseInt(height,10);htmlElement.style.height=height;});},afterEnter(element){const htmlElement=getHTMLElementFromVueRef(element);Object.assign(htmlElement.style,this.openedStyle);},leave(element){const htmlElement=getHTMLElementFromVueRef(element);const height=getComputedStyle(element).height;htmlElement.style.height=height;getComputedStyle(element).height;setTimeout(()=>{Object.assign(htmlElement.style,this.visibleStyle);});}}});const _hoisted_1$H=["id","disabled"];const _hoisted_2$v=["for"];const _hoisted_3$r={key:0,class:"checkbox__details"};const _hoisted_4$m=/* @__PURE__ */createElementVNode("br",null,null,-1/* HOISTED */);const _hoisted_5$k={key:0,class:"checkbox__details"};const _hoisted_6$g=/* @__PURE__ */createElementVNode("br",null,null,-1/* HOISTED */);function _sfc_render$M(_ctx,_cache,$props,$setup,$data,$options){return openBlock(),createElementBlock("div",{class:normalizeClass(["checkbox",_ctx.disabledClass]),onValidity:_cache[2]||(_cache[2]=(...args)=>_ctx.onValidity&&_ctx.onValidity(...args))},[createElementVNode("input",mergeProps({id:_ctx.id},_ctx.attrs,{ref:"checkboxInput",type:"checkbox",class:"checkbox__input",disabled:_ctx.disabled,onKeydown:_cache[0]||(_cache[0]=withKeys((...args)=>_ctx.onKeydown&&_ctx.onKeydown(...args),["space"])),onChange:_cache[1]||(_cache[1]=$event=>_ctx.updateExpandedFlag())}),null,16,_hoisted_1$H),createTextVNode(),createElementVNode("label",{class:normalizeClass(_ctx.$slots.details?"checkbox__label checkbox__width":"checkbox__label"),for:_ctx.id},[renderSlot(_ctx.$slots,"default"),createTextVNode(),_ctx.$slots.details?(openBlock(),createElementBlock(Fragment,{key:0},[_ctx.showDetails==="always"?(openBlock(),createElementBlock("span",_hoisted_3$r,[_hoisted_4$m,createTextVNode(),renderSlot(_ctx.$slots,"details")])):createCommentVNode("v-if",true),createTextVNode(),_ctx.showDetails==="when-selected"?(openBlock(),createBlock(Transition,{key:1,onEnter:_ctx.enter,onAfterEnter:_ctx.afterEnter,onLeave:_ctx.leave},{default:withCtx(()=>[_ctx.expanded?(openBlock(),createElementBlock("span",_hoisted_5$k,[_hoisted_6$g,createTextVNode(),renderSlot(_ctx.$slots,"details",{height:_ctx.height})])):createCommentVNode("v-if",true)]),_:3/* FORWARDED */},8,["onEnter","onAfterEnter","onLeave"])):createCommentVNode("v-if",true)],64/* STABLE_FRAGMENT */)):createCommentVNode("v-if",true)],10,_hoisted_2$v)],34/* CLASS, NEED_HYDRATION */);}const FCheckboxField=/* @__PURE__ */_export_sfc(_sfc_main$W,[["render",_sfc_render$M]]);const getFieldsetLabelText=Symbol("getFieldsetLabelText");function*labelClasses(options){const{labelClass}=options;yield"fieldset__label";yield labelClass;}function*contentClasses(options){const{hasRadiobutton,hasCheckbox,contentClass}=options;yield"fieldset__content";if(hasRadiobutton){yield"radio-button-group__content";}if(hasCheckbox){yield"checkbox-group__content";}yield contentClass;}const _sfc_main$V=defineComponent({name:"FFieldset",components:{FIcon},mixins:[TranslationMixin],provide(){return{[getFieldsetLabelText]:()=>{return renderSlotText(this.$slots.label);},sharedName:this.name,showDetails:this.showDetails};},props:{/**
|
|
242
|
+
*/ariaLabel:{type:String,required:false,default:"Kontextuell meny"}},emits:["close","select"],setup(){return{contextmenu:ref(null)};},data(){return{selectedItem:"",currentFocusedItemIndex:-1};},computed:{popupItems(){return this.items.filter(isContextMenuTextItem);},separatorPositions(){const res=[];if(this.items.length>1){this.items.forEach((it,i)=>{if(isContextMenuSeparatorItem(it)){const pos=i-1-res.length;if(pos>=0&&pos<this.items.length-1){res.push(pos);}}});}return res;},hasIcons(){return this.items.some(it=>isContextMenuTextItem(it)&&it.icon);}},watch:{isOpen:{immediate:true,async handler(){if(this.isOpen){this.currentFocusedItemIndex=-1;this.selectedItem="";}}}},methods:{hasSeparatorAfterItemAt(index){return this.separatorPositions.includes(index);},closePopup(){this.$emit("close");},onClickItem(item){if(isContextMenuTextItem(item)&&item.key){this.selectedItem=item.key;this.$emit("select",this.selectedItem);this.closePopup();}},tabIndex(index){return index===this.currentFocusedItemIndex?0:-1;},onKeyUp(event){if(preventKeys$3.includes(event.key)){event.preventDefault();}},doHandlePopupMenuTabKey(action){if(action===MenuAction.MOVE_NEXT&&this.currentFocusedItemIndex+1===this.popupItems.length){this.closePopup();return true;}else if(action===MenuAction.MOVE_PREV&&(this.currentFocusedItemIndex===0||this.currentFocusedItemIndex===-1)){this.closePopup();return false;}return false;},async onKeyDown(event){if(!preventKeys$3.includes(event.key)){return;}if(event.key==="Escape"){this.$emit("close");return;}const action=actionFromKeyboardEvent(event);if(action===null){return;}if(event.key==="Tab"&&this.doHandlePopupMenuTabKey(action)){return;}if(keyUp$1.includes(event.key)&&this.currentFocusedItemIndex===-1){this.currentFocusedItemIndex=this.popupItems.length>0?this.popupItems.length:1;}event.preventDefault();await doMenuAction$3(action,this);},async setFocusOnItem(index){if(index<0||index>=this.popupItems.length){return;}this.currentFocusedItemIndex=index;await this.$nextTick();if(!this.isOpen){return;}const items=getHTMLElementsFromVueRef(this.$refs.items);if(items.length>0){const popupMenuItem=items[index];focus$1(popupMenuItem,{preventScroll:true});}},async activateItem(index){if(index<0||index>=this.popupItems.length){return;}if(index!==this.currentFocusedItemIndex){await this.setFocusOnItem(index);}this.onClickItem(this.popupItems[this.currentFocusedItemIndex]);}}});const _hoisted_1$I=["aria-label"];const _hoisted_2$w={ref:"contextmenu",role:"menu",tabindex:"-1",class:"contextmenu__list"};const _hoisted_3$s=["onClick"];const _hoisted_4$n=["tabindex"];const _hoisted_5$l={key:0,class:"contextmenu__separator"};function _sfc_render$N(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");const _component_i_popup=resolveComponent("i-popup");return openBlock(),createBlock(_component_i_popup,{"is-open":_ctx.isOpen,"keyboard-trap":false,anchor:_ctx.anchor,"set-focus":true,"focus-element":()=>_ctx.contextmenu,inline:"never",onClose:_cache[2]||(_cache[2]=$event=>_ctx.$emit("close"))},{default:withCtx(()=>[createElementVNode("nav",{class:"contextmenu","aria-label":_ctx.ariaLabel,onKeyup:_cache[0]||(_cache[0]=(...args)=>_ctx.onKeyUp&&_ctx.onKeyUp(...args)),onKeydown:_cache[1]||(_cache[1]=(...args)=>_ctx.onKeyDown&&_ctx.onKeyDown(...args))},[createElementVNode("ul",_hoisted_2$w,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.popupItems,(item,index)=>{return openBlock(),createElementBlock("li",{key:item.key,role:"menuitem",onClick:$event=>_ctx.onClickItem(item)},[createElementVNode("div",{ref_for:true,ref:"items",tabindex:_ctx.tabIndex(index),class:"contextmenu__list__item"},[_ctx.hasIcons?(openBlock(),createBlock(_component_f_icon,{key:0,class:"contextmenu__lefticon",name:item.icon?item.icon:"",library:item.iconLibrary?item.iconLibrary:"f"},null,8,["name","library"])):createCommentVNode("v-if",true),createTextVNode(),createElementVNode("a",{ref_for:true,ref:"anchors"},toDisplayString(item.label),513/* TEXT, NEED_PATCH */)],8,_hoisted_4$n),createTextVNode(),_ctx.hasSeparatorAfterItemAt(index)?(openBlock(),createElementBlock("hr",_hoisted_5$l)):createCommentVNode("v-if",true)],8,_hoisted_3$s);}),128/* KEYED_FRAGMENT */))],512/* NEED_PATCH */)],40,_hoisted_1$I)]),_:1/* STABLE */},8,["is-open","anchor","focus-element"]);}const FContextMenu=/* @__PURE__ */_export_sfc(_sfc_main$X,[["render",_sfc_render$N]]);function*labelClasses(options){const{labelClass}=options;yield"fieldset__label";yield labelClass;}function*contentClasses(options){const{hasRadiobutton,hasCheckbox,contentClass}=options;yield"fieldset__content";if(hasRadiobutton){yield"radio-button-group__content";}if(hasCheckbox){yield"checkbox-group__content";}yield contentClass;}const injectionKeys={sharedName:Symbol("sharedName"),showDetails:Symbol("showDetails"),getFieldsetLabelText:Symbol("getFieldsetLabelText")};function useFieldset(){return{sharedName:inject(injectionKeys.sharedName,void 0),showDetails:inject(injectionKeys.showDetails,"never"),getFieldsetLabelText:inject(injectionKeys.getFieldsetLabelText,()=>void 0)};}const _sfc_main$W=defineComponent({name:"FFieldset",components:{FIcon},mixins:[TranslationMixin],props:{/**
|
|
254
243
|
* The id for the fieldset id attribute.
|
|
255
244
|
* If the prop is not set a random value will be generated.
|
|
256
245
|
*/id:{type:String,required:false,default:()=>ElementIdService.generateElementId()},/**
|
|
@@ -274,10 +263,25 @@ injected(){return this;}},methods:{updateExpandedFlag(){const checkboxInput=getH
|
|
|
274
263
|
* * `never` (default) - Never show item details.
|
|
275
264
|
* - `when-selected` - Show item details when selected.
|
|
276
265
|
* - `always` - Always show item details.
|
|
277
|
-
*/showDetails:{type:String,default:"never",validator(value){return["never","when-selected","always"].includes(value);}}},data(){return{validity:{validityMode:"INITIAL"},descriptionClass:["label__description"],discreteDescriptionClass:["label__description","label__description--discrete"],validityElement:null,dispatchObject:{},detail:{},hasDocumentListener:false,legendKey:1,oldMessage:"",children:new Array(),hasCheckbox:false,hasRadiobutton:false};},computed:{hasError(){return this.validity.validityMode==="ERROR";},hasErrorMessageSlot(){return hasSlot(this,"error-message");},hasTooltipSlot(){return Boolean(this.$slots.tooltip);},hasDescriptionSlot(){return hasSlot(this,"description");},legendClass(){return this.hasTooltipSlot?["sr-only"]:this.groupLabelClass;},groupLabelClass(){return Array.from(labelClasses(this));},groupContentClass(){return Array.from(contentClasses(this));},classes(){const{hasRadiobutton,hasCheckbox,horizontal,chip,border}=this;return{"radio-button-group":hasRadiobutton,"radio-button-group--chip":chip&&hasRadiobutton,"radio-button-group--horizontal":horizontal&&hasRadiobutton,"radio-button-group--border":border&&hasRadiobutton,"checkbox-group":hasCheckbox,"checkbox-group--chip":chip&&hasCheckbox,"checkbox-group--horizontal":horizontal&&hasCheckbox,"checkbox-group--border":border&&hasCheckbox};},checkedChildren(){return this.children.filter(child=>child.checked);},debouncedUpdateChildren(){return debounce(this.updateCheckboxChildren.bind(this),150);},checkboxCheckedScreenReaderText(){return this.checkedChildren.length===1?this.$t("fkui.checkbox-group.checkbox.checked","Kryssruta kryssad"):this.$t("fkui.checkbox-group.checkbox.not.checked","Kryssruta ej kryssad");},numberOfCheckboxesScreenReaderText(){return this.$t("fkui.checkbox-group.count","Grupp med {{ count }} kryssrutor",{count:String(this.children.length)});},numberOfCheckedCheckboxesScreenText(){return this.$t("fkui.checkbox-group.checked","{{ checked }} kryssad av {{ count }}",{checked:String(this.checkedChildren.length),count:String(this.children.length)});}},async mounted(){await this.$nextTick();const types=Array.from(this.$el.querySelectorAll(`input[type="checkbox"], input[type="radio"]`),it=>it.getAttribute("type"));this.hasCheckbox=types.includes("checkbox");this.hasRadiobutton=types.includes("radio");if(this.hasCheckbox){this.updateCheckboxChildren();}},updated(){if(this.hasCheckbox){this.debouncedUpdateChildren();}},methods:{async onValidity({detail}){var _renderSlotText2;if(detail.target!==this.$el){return;}this.detail=detail;await this.$nextTick();const errorMessage=(_renderSlotText2=renderSlotText(this.$slots.label))!==null&&_renderSlotText2!==void 0?_renderSlotText2:"";const firstFocusableElement=this.$el.querySelector("input:not(disabled), select:not(disabled), textarea:not(disabled)");const focusElementId=firstFocusableElement?firstFocusableElement.id:this.id;this.validityElement=this.$el;this.dispatchObject={...detail,errorMessage,focusElementId};this.validity=this.detail;if(this.validityElement){dispatchComponentValidityEvent(this.validityElement,this.dispatchObject);}const message=detail.validityMode==="INITIAL"?"":detail.validationMessage;if(message!==this.oldMessage){this.forceLegendUpdate();this.oldMessage=message;}},/**
|
|
266
|
+
*/showDetails:{type:String,default:"never",validator(value){return["never","when-selected","always"].includes(value);}}},setup(props){const slots=useSlots();provide(injectionKeys.sharedName,props.name);provide(injectionKeys.showDetails,props.showDetails);provide(injectionKeys.getFieldsetLabelText,()=>{return renderSlotText(slots.label);});},data(){return{validity:{validityMode:"INITIAL"},descriptionClass:["label__description"],discreteDescriptionClass:["label__description","label__description--discrete"],validityElement:null,dispatchObject:{},detail:{},hasDocumentListener:false,legendKey:1,oldMessage:"",children:new Array(),hasCheckbox:false,hasRadiobutton:false};},computed:{hasError(){return this.validity.validityMode==="ERROR";},hasErrorMessageSlot(){return hasSlot(this,"error-message");},hasTooltipSlot(){return Boolean(this.$slots.tooltip);},hasDescriptionSlot(){return hasSlot(this,"description");},legendClass(){return this.hasTooltipSlot?["sr-only"]:this.groupLabelClass;},groupLabelClass(){return Array.from(labelClasses(this));},groupContentClass(){return Array.from(contentClasses(this));},classes(){const{hasRadiobutton,hasCheckbox,horizontal,chip,border}=this;return{"radio-button-group":hasRadiobutton,"radio-button-group--chip":chip&&hasRadiobutton,"radio-button-group--horizontal":horizontal&&hasRadiobutton,"radio-button-group--border":border&&hasRadiobutton,"checkbox-group":hasCheckbox,"checkbox-group--chip":chip&&hasCheckbox,"checkbox-group--horizontal":horizontal&&hasCheckbox,"checkbox-group--border":border&&hasCheckbox};},checkedChildren(){return this.children.filter(child=>child.checked);},debouncedUpdateChildren(){return debounce(this.updateCheckboxChildren.bind(this),150);},checkboxCheckedScreenReaderText(){return this.checkedChildren.length===1?this.$t("fkui.checkbox-group.checkbox.checked","Kryssruta kryssad"):this.$t("fkui.checkbox-group.checkbox.not.checked","Kryssruta ej kryssad");},numberOfCheckboxesScreenReaderText(){return this.$t("fkui.checkbox-group.count","Grupp med {{ count }} kryssrutor",{count:String(this.children.length)});},numberOfCheckedCheckboxesScreenText(){return this.$t("fkui.checkbox-group.checked","{{ checked }} kryssad av {{ count }}",{checked:String(this.checkedChildren.length),count:String(this.children.length)});}},async mounted(){await this.$nextTick();const types=Array.from(this.$el.querySelectorAll(`input[type="checkbox"], input[type="radio"]`),it=>it.getAttribute("type"));this.hasCheckbox=types.includes("checkbox");this.hasRadiobutton=types.includes("radio");if(this.hasCheckbox){this.updateCheckboxChildren();}},updated(){if(this.hasCheckbox){this.debouncedUpdateChildren();}},methods:{async onValidity({detail}){var _renderSlotText2;if(detail.target!==this.$el){return;}this.detail=detail;await this.$nextTick();const errorMessage=(_renderSlotText2=renderSlotText(this.$slots.label))!==null&&_renderSlotText2!==void 0?_renderSlotText2:"";const firstFocusableElement=this.$el.querySelector("input:not(disabled), select:not(disabled), textarea:not(disabled)");const focusElementId=firstFocusableElement?firstFocusableElement.id:this.id;this.validityElement=this.$el;this.dispatchObject={...detail,errorMessage,focusElementId};this.validity=this.detail;if(this.validityElement){dispatchComponentValidityEvent(this.validityElement,this.dispatchObject);}const message=detail.validityMode==="INITIAL"?"":detail.validationMessage;if(message!==this.oldMessage){this.forceLegendUpdate();this.oldMessage=message;}},/**
|
|
278
267
|
* Workaround for NVDA-bug. Force re rendering of legend element due to NVDA not recognizing innerHTML changes.
|
|
279
268
|
* NVDA has closed the bug as it is related to the browser (works in FF): https://github.com/nvaccess/nvda/issues/13162
|
|
280
|
-
*/forceLegendUpdate(){this.legendKey++;},async updateCheckboxChildren(){await this.$nextTick();this.children=Array.from(this.$el.querySelectorAll('input[type="checkbox"]'));}}});const _hoisted_1$
|
|
269
|
+
*/forceLegendUpdate(){this.legendKey++;},async updateCheckboxChildren(){await this.$nextTick();this.children=Array.from(this.$el.querySelectorAll('input[type="checkbox"]'));}}});const _hoisted_1$H=["id"];const _hoisted_2$v={key:0,class:"sr-only"};const _hoisted_3$r={key:0,class:"label__message label__message--error"};const _hoisted_4$m={key:0,"data-test":"checked-boxes",class:"sr-only","aria-live":"polite"};const _hoisted_5$k={key:0};const _hoisted_6$g={key:1};const _hoisted_7$d={class:"sr-separator"};const _hoisted_8$9={class:"tooltip-before","aria-hidden":"true"};const _hoisted_9$5={class:"label tooltip-before__label"};const _hoisted_10$5={key:0,class:"label__message label__message--error"};function _sfc_render$M(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");return openBlock(),createElementBlock("fieldset",{id:_ctx.id,class:normalizeClass(["fieldset",_ctx.classes]),onValidity:_cache[0]||(_cache[0]=(...args)=>_ctx.onValidity&&_ctx.onValidity(...args))},[(openBlock(),createElementBlock("legend",{key:_ctx.legendKey,class:normalizeClass(["label",_ctx.legendClass])},[renderSlot(_ctx.$slots,"label"),createTextVNode(),_ctx.hasCheckbox&&_ctx.children.length>1?(openBlock(),createElementBlock("span",_hoisted_2$v,[createElementVNode("span",null,toDisplayString(_ctx.numberOfCheckboxesScreenReaderText),1/* TEXT */)])):createCommentVNode("v-if",true),createTextVNode(),renderSlot(_ctx.$slots,"description",normalizeProps(guardReactiveProps({descriptionClass:_ctx.descriptionClass,discreteDescriptionClass:_ctx.discreteDescriptionClass}))),createTextVNode(),renderSlot(_ctx.$slots,"error-message",normalizeProps(guardReactiveProps({hasError:_ctx.hasError,validationMessage:_ctx.validity.validationMessage})),()=>[_ctx.hasError?(openBlock(),createElementBlock("span",_hoisted_3$r,[createVNode(_component_f_icon,{class:"label__icon--left",name:"error"}),createTextVNode(" "+toDisplayString(_ctx.validity.validationMessage),1/* TEXT */)])):createCommentVNode("v-if",true)])],2/* CLASS */)),createTextVNode(),_ctx.hasCheckbox?(openBlock(),createElementBlock("span",_hoisted_4$m,[_ctx.children.length===1?(openBlock(),createElementBlock("span",_hoisted_5$k,toDisplayString(_ctx.checkboxCheckedScreenReaderText),1/* TEXT */)):(openBlock(),createElementBlock("span",_hoisted_6$g,toDisplayString(_ctx.numberOfCheckedCheckboxesScreenText),1/* TEXT */))])):createCommentVNode("v-if",true),createTextVNode(),_ctx.hasTooltipSlot?(openBlock(),createElementBlock(Fragment,{key:1},[createElementVNode("div",_hoisted_7$d,[createElementVNode("div",_hoisted_8$9,[createElementVNode("div",_hoisted_9$5,[renderSlot(_ctx.$slots,"label")])]),createTextVNode(),renderSlot(_ctx.$slots,"tooltip")]),createTextVNode(),_ctx.hasDescriptionSlot||_ctx.hasErrorMessageSlot||_ctx.hasError?(openBlock(),createElementBlock("div",{key:0,class:normalizeClass(["label",_ctx.groupLabelClass]),"aria-hidden":"true"},[renderSlot(_ctx.$slots,"description",normalizeProps(guardReactiveProps({descriptionClass:_ctx.descriptionClass,discreteDescriptionClass:_ctx.discreteDescriptionClass}))),createTextVNode(),renderSlot(_ctx.$slots,"error-message",normalizeProps(guardReactiveProps({hasError:_ctx.hasError,validationMessage:_ctx.validity.validationMessage})),()=>[_ctx.hasError?(openBlock(),createElementBlock("span",_hoisted_10$5,[createVNode(_component_f_icon,{class:"label__icon--left",name:"error"}),createTextVNode(" "+toDisplayString(_ctx.validity.validationMessage),1/* TEXT */)])):createCommentVNode("v-if",true)])],2/* CLASS */)):createCommentVNode("v-if",true)],64/* STABLE_FRAGMENT */)):createCommentVNode("v-if",true),createTextVNode(),createElementVNode("div",{class:normalizeClass(_ctx.groupContentClass)},[renderSlot(_ctx.$slots,"default")],2/* CLASS */)],42,_hoisted_1$H);}const FFieldset=/* @__PURE__ */_export_sfc(_sfc_main$W,[["render",_sfc_render$M]]);const anyType$1=[String,Object,Array,Number,Date,Boolean];const _sfc_main$V=defineComponent({name:"FCheckboxField",inheritAttrs:false,props:{/**
|
|
270
|
+
* Set to `true`, empty string `""` or string `"disabled"` to disable this input field.
|
|
271
|
+
*/disabled:{type:Boolean,required:false,default:false},/**
|
|
272
|
+
* The id for the input id attribute.
|
|
273
|
+
* The id for the label for attribute.
|
|
274
|
+
* If the prop is not set a random value will be generated.
|
|
275
|
+
*/id:{type:String,required:false,default:()=>ElementIdService.generateElementId()},/**
|
|
276
|
+
* The value for the input checked attribute.
|
|
277
|
+
* @model
|
|
278
|
+
*/// ? The rule is disabled so that the `checked` prop can be undefined or null.
|
|
279
|
+
/* eslint-disable-next-line vue/require-default-prop -- technical debt,
|
|
280
|
+
/* it should contain a default value of undefined and proptype should
|
|
281
|
+
/* include undefined (see comment on line above) */modelValue:{type:anyType$1,required:false},/**
|
|
282
|
+
* The value for the input.
|
|
283
|
+
*/value:{type:anyType$1,required:true}},emits:["change","update:modelValue"],setup(){const{showDetails,getFieldsetLabelText}=useFieldset();return{showDetails,getFieldsetLabelText};},data(){return{expanded:false,height:0,initialStyle:{overflow:"hidden",transition:"height 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96)"},hiddenStyle:{height:"auto",position:"absolute",visibility:"hidden"},visibleStyle:{width:"",position:"",visibility:"",height:"0px"},openedStyle:{height:"auto"}};},computed:{attrs(){let checked;if(Array.isArray(this.modelValue)){checked=this.modelValue.findIndex(it=>isEqual$2(toValue(it),toValue(this.value)))>=0;}else{checked=this.value===this.modelValue;}return{...this.$attrs,value:this.value,checked,onChange:event=>{if(event.target instanceof HTMLInputElement){this.emitVModelEvent(event);}},onInput:event=>{event.target.focus();}};},disabledClass(){return this.disabled?"disabled":"";},// eslint-disable-next-line @typescript-eslint/no-explicit-any -- technical debt, nore sure whats going on here
|
|
284
|
+
injected(){return this;}},methods:{updateExpandedFlag(){const checkboxInput=getHTMLElementFromVueRef(this.$refs["checkboxInput"]);this.expanded=checkboxInput.checked;},emitVModelEvent(event){let newModel;if(Array.isArray(this.modelValue)){newModel=[...this.modelValue].filter(it=>!isEqual$2(toValue(it),toValue(this.value)));if(this.modelValue.length<=newModel.length){newModel.push(this.value);}}else{if(this.value===this.modelValue){newModel=typeof this.value==="boolean"?false:void 0;}else{const target=event.target;newModel=target.value==="true"?true:this.value;}}this.$emit("update:modelValue",newModel);this.$emit("change",newModel);},onKeydown(event){event.stopPropagation();},onValidity({detail}){if(detail.target!==this.$el.querySelector("input")){return;}let errorMessage="";if(hasSlot(this,"default")){const labelText=this.injected.getFieldsetLabelText();if(labelText){errorMessage=`${labelText} ${renderSlotText(this.$slots.default)}`;}else{errorMessage=`${renderSlotText(this.$slots.default)}`;}}const element=this.$el.querySelector(`#${detail.elementId}`);if(element){dispatchComponentValidityEvent(element,{...detail,errorMessage,focusElementId:detail.elementId});}},enter(element){const htmlElement=getHTMLElementFromVueRef(element);const computedStyle=getComputedStyle(element);Object.assign(htmlElement.style,this.initialStyle);Object.assign(htmlElement.style,this.hiddenStyle);htmlElement.style.width=computedStyle.width;const height=computedStyle.height;Object.assign(htmlElement.style,this.visibleStyle);getComputedStyle(element).height;setTimeout(()=>{this.height=parseInt(height,10);htmlElement.style.height=height;});},afterEnter(element){const htmlElement=getHTMLElementFromVueRef(element);Object.assign(htmlElement.style,this.openedStyle);},leave(element){const htmlElement=getHTMLElementFromVueRef(element);const height=getComputedStyle(element).height;htmlElement.style.height=height;getComputedStyle(element).height;setTimeout(()=>{Object.assign(htmlElement.style,this.visibleStyle);});}}});const _hoisted_1$G=["id","disabled"];const _hoisted_2$u=["for"];const _hoisted_3$q={key:0,class:"checkbox__details"};const _hoisted_4$l=/* @__PURE__ */createElementVNode("br",null,null,-1/* HOISTED */);const _hoisted_5$j={key:0,class:"checkbox__details"};const _hoisted_6$f=/* @__PURE__ */createElementVNode("br",null,null,-1/* HOISTED */);function _sfc_render$L(_ctx,_cache,$props,$setup,$data,$options){return openBlock(),createElementBlock("div",{class:normalizeClass(["checkbox",_ctx.disabledClass]),onValidity:_cache[2]||(_cache[2]=(...args)=>_ctx.onValidity&&_ctx.onValidity(...args))},[createElementVNode("input",mergeProps({id:_ctx.id},_ctx.attrs,{ref:"checkboxInput",type:"checkbox",class:"checkbox__input",disabled:_ctx.disabled,onKeydown:_cache[0]||(_cache[0]=withKeys((...args)=>_ctx.onKeydown&&_ctx.onKeydown(...args),["space"])),onChange:_cache[1]||(_cache[1]=$event=>_ctx.updateExpandedFlag())}),null,16,_hoisted_1$G),createTextVNode(),createElementVNode("label",{class:normalizeClass(_ctx.$slots.details?"checkbox__label checkbox__width":"checkbox__label"),for:_ctx.id},[renderSlot(_ctx.$slots,"default"),createTextVNode(),_ctx.$slots.details?(openBlock(),createElementBlock(Fragment,{key:0},[_ctx.showDetails==="always"?(openBlock(),createElementBlock("span",_hoisted_3$q,[_hoisted_4$l,createTextVNode(),renderSlot(_ctx.$slots,"details")])):createCommentVNode("v-if",true),createTextVNode(),_ctx.showDetails==="when-selected"?(openBlock(),createBlock(Transition,{key:1,onEnter:_ctx.enter,onAfterEnter:_ctx.afterEnter,onLeave:_ctx.leave},{default:withCtx(()=>[_ctx.expanded?(openBlock(),createElementBlock("span",_hoisted_5$j,[_hoisted_6$f,createTextVNode(),renderSlot(_ctx.$slots,"details",{height:_ctx.height})])):createCommentVNode("v-if",true)]),_:3/* FORWARDED */},8,["onEnter","onAfterEnter","onLeave"])):createCommentVNode("v-if",true)],64/* STABLE_FRAGMENT */)):createCommentVNode("v-if",true)],10,_hoisted_2$u)],34/* CLASS, NEED_HYDRATION */);}const FCheckboxField=/* @__PURE__ */_export_sfc(_sfc_main$V,[["render",_sfc_render$L]]);const _sfc_main$U=defineComponent({name:"FCheckboxGroup",components:{FFieldset},mixins:[TranslationMixin],inheritAttrs:false,props:{/**
|
|
281
285
|
* The id for the fieldset id attribute.
|
|
282
286
|
* If the prop is not set the id will be generated.
|
|
283
287
|
*/id:{type:String,required:false,default:()=>ElementIdService.generateElementId()},/**
|
|
@@ -305,7 +309,7 @@ injected(){return this;}},methods:{updateExpandedFlag(){const checkboxInput=getH
|
|
|
305
309
|
* Property for changing the "modify" modal heading
|
|
306
310
|
*/modifyModalHeader:{type:String,required:false,default:TranslationService.provider.translate("fkui.crud-dataset.modal.header.modify","Ändra rad")},/**
|
|
307
311
|
* Property for changing the "delete" modal heading
|
|
308
|
-
*/deleteModalHeader:{type:String,required:false,default:TranslationService.provider.translate("fkui.crud-dataset.modal.header.delete","Är du säker på att du vill ta bort raden?")}},emits:["change","created","deleted","updated","update:modelValue"],data(){return{result:[],Operation,operation:3,item:null,originalItemToUpdate:null,isFormModalOpen:false,isConfirmModalOpen:false,callbackAfterItemAdd(){},callbackBeforeItemDelete(){}};},computed:{confirmButtonText(){return this.operation===0?this.$t("fkui.crud-dataset.modal.confirm.add","Lägg till"):this.$t("fkui.crud-dataset.modal.confirm.modify","Spara");},cancelButtonText(){return this.operation===0?this.$t("fkui.crud-dataset.modal.cancel.add","Avbryt"):this.$t("fkui.crud-dataset.modal.cancel.modify","Avbryt");},confirmDeleteButtons(){return[{label:this.$t("fkui.crud-dataset.modal.confirm.delete","Ja, ta bort"),type:"primary",event:"confirm"},{label:this.$t("fkui.crud-dataset.modal.cancel.delete","Nej, avbryt"),type:"secondary"}];},hasAddSlot(){return Boolean(this.$slots.add);},hasDeleteSlot(){return Boolean(this.$slots.delete);},hasModifySlot(){return Boolean(this.$slots.modify);},formModalHeader(){return this.operation===0?this.addNewModalHeader:this.modifyModalHeader;}},watch:{modelValue:{immediate:true,deep:true,handler(data){this.result=[...data];}}},mounted(){if(!this.hasAddSlot&&!this.hasDeleteSlot&&!this.hasModifySlot){throw Error("Atleast one template of the following must be defined. #add, #delete or #modify");}},methods:{createItem(){if(!this.hasAddSlot){throw Error("No template is defined for #add");}this.operation=0;this.item=this.beforeCreate?this.beforeCreate():{};this.isFormModalOpen=true;},deleteItem(item){if(!this.hasDeleteSlot){throw Error("No template is defined for #delete");}this.operation=1;this.item=item;this.isConfirmModalOpen=true;},onDeleteConfirm(){if(!this.item){return;}this.callbackBeforeItemDelete(this.item);this.result=this.result.filter(item=>item!==this.item);this.$emit("deleted",this.item);this.$emit("update:modelValue",this.result);this.$emit("change",this.result);alertScreenReader(this.$t("fkui.crud-dataset.aria-live.delete","Raden har tagits bort"),{assertive:true});},onDeleteClose(e){this.onModalClose();if(e.reason==="close"&&this.onCancel){this.onCancel();}},onModalClose(){this.isFormModalOpen=false;this.isConfirmModalOpen=false;},onFormModalSubmit(){if(!this.item){return;}if(this.operation===0){this.result.push(this.item);this.$emit("created",this.item);this.$emit("update:modelValue",this.result);this.$emit("change",this.result);this.callbackAfterItemAdd(this.item);alertScreenReader(this.$t("fkui.crud-dataset.aria-live.add","En rad har lagts till"),{assertive:true});}else if(this.operation===2){if(this.originalItemToUpdate){Object.assign(this.originalItemToUpdate,this.item);}else{this.originalItemToUpdate=this.item;}this.$emit("updated",this.originalItemToUpdate);this.$emit("update:modelValue",this.result);this.$emit("change",this.result);alertScreenReader(this.$t("fkui.crud-dataset.aria-live.modify","Raden har ändrats"),{assertive:true});}this.isFormModalOpen=false;},updateItem(item){if(!this.hasModifySlot){throw Error("No template is defined for #modify");}this.operation=2;this.originalItemToUpdate=item;this.item=deepClone(item);this.isFormModalOpen=true;}}});const _hoisted_1$F={class:"crud-dataset"};const _hoisted_2$t={key:0};function _sfc_render$J(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");const _component_f_form_modal=resolveComponent("f-form-modal");const _component_f_confirm_modal=resolveComponent("f-confirm-modal");return openBlock(),createElementBlock("div",_hoisted_1$F,[renderSlot(_ctx.$slots,"default"),createTextVNode(),_ctx.hasAddSlot?(openBlock(),createElementBlock("div",_hoisted_2$t,[createElementVNode("button",{"data-test":"f-crud-dataset-add-button",type:"button",class:"button button--discrete crud-dataset__add-button",onClick:_cache[0]||(_cache[0]=$event=>_ctx.createItem())},[createVNode(_component_f_icon,{class:"button__icon",name:"plus"}),createTextVNode(),renderSlot(_ctx.$slots,"add-button",{},()=>[createTextVNode(toDisplayString(_ctx.$t("fkui.crud-dataset.button.add","Lägg till ny")),1/* TEXT */)])])])):createCommentVNode("v-if",true),createTextVNode(),createVNode(_component_f_form_modal,{"is-open":_ctx.isFormModalOpen,"aria-close-text":_ctx.$t("fkui.crud-dataset.modal.close","Stäng"),"use-error-list":false,"before-submit":_ctx.beforeSubmit,"before-validation":_ctx.beforeValidation,"on-cancel":_ctx.onCancel,onClose:_ctx.onModalClose,onCancel:_ctx.onCancel,onSubmit:_ctx.onFormModalSubmit},{header:withCtx(()=>[createTextVNode(toDisplayString(_ctx.formModalHeader),1/* TEXT */)]),"input-text-fields":withCtx(()=>[_ctx.operation===_ctx.Operation.ADD?renderSlot(_ctx.$slots,"add",normalizeProps(mergeProps({key:0},{item:_ctx.item}))):createCommentVNode("v-if",true),createTextVNode(),_ctx.operation===_ctx.Operation.MODIFY?renderSlot(_ctx.$slots,"modify",normalizeProps(mergeProps({key:1},{item:_ctx.item}))):createCommentVNode("v-if",true)]),"submit-button-text":withCtx(()=>[createTextVNode(toDisplayString(_ctx.confirmButtonText),1/* TEXT */)]),"cancel-button-text":withCtx(()=>[createTextVNode(toDisplayString(_ctx.cancelButtonText),1/* TEXT */)]),_:3/* FORWARDED */},8,["is-open","aria-close-text","before-submit","before-validation","on-cancel","onClose","onCancel","onSubmit"]),createTextVNode(),createVNode(_component_f_confirm_modal,{"is-open":_ctx.isConfirmModalOpen,buttons:_ctx.confirmDeleteButtons,onConfirm:_ctx.onDeleteConfirm,onClose:_ctx.onDeleteClose},{heading:withCtx(()=>[createTextVNode(toDisplayString(_ctx.deleteModalHeader),1/* TEXT */)]),content:withCtx(()=>[renderSlot(_ctx.$slots,"delete",normalizeProps(guardReactiveProps({item:_ctx.item})))]),_:3/* FORWARDED */},8,["is-open","buttons","onConfirm","onClose"])]);}const FCrudDataset=/* @__PURE__ */_export_sfc(_sfc_main$T,[["render",_sfc_render$J]]);function FCrudDatasetInjected(){return{delete:inject("delete"),modify:inject("modify")};}const _sfc_main$S=defineComponent({name:"FCrudButton",components:{FIcon},mixins:[TranslationMixin],props:{action:{type:String,required:true,validator(value){return["delete","modify"].includes(value);}},icon:{type:Boolean,default:false},item:{type:Object,required:true},label:{type:Boolean,default:false}},setup(){return FCrudDatasetInjected();},computed:{iconName(){if(this.action==="delete"){return"trashcan";}else{return"pen";}},buttonText(){if(this.action==="delete"){return this.$t("fkui.crud-button.delete","Ta bort");}else{return this.$t("fkui.crud-button.modify","Ändra");}}},methods:{executeAction(){if(this.action==="delete"){this.delete(this.item);}else{this.modify(this.item);}}}});const _hoisted_1$E={key:1,class:"sr-only"};function _sfc_render$I(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");return openBlock(),createElementBlock("button",{type:"button",class:"button button--discrete",onClick:_cache[0]||(_cache[0]=(...args)=>_ctx.executeAction&&_ctx.executeAction(...args))},[_ctx.icon?(openBlock(),createBlock(_component_f_icon,{key:0,class:"button__icon",name:_ctx.iconName},null,8,["name"])):createCommentVNode("v-if",true),createTextVNode(),!_ctx.label?(openBlock(),createElementBlock("span",_hoisted_1$E,[renderSlot(_ctx.$slots,"default",{},()=>[createTextVNode(toDisplayString(_ctx.buttonText),1/* TEXT */)])])):createCommentVNode("v-if",true),createTextVNode(),_ctx.label?renderSlot(_ctx.$slots,"default",{key:2},()=>[createTextVNode(toDisplayString(_ctx.buttonText),1/* TEXT */)]):createCommentVNode("v-if",true)]);}const FCrudButton=/* @__PURE__ */_export_sfc(_sfc_main$S,[["render",_sfc_render$I]]);function ActivateItemInjected(){return{registerCallbackAfterItemAdd:inject("registerCallbackAfterItemAdd",()=>void 0),registerCallbackBeforeItemDelete:inject("registerCallbackBeforeItemDelete",()=>void 0)};}var FTableColumnType=/* @__PURE__ */(FTableColumnType2=>{FTableColumnType2["TEXT"]="text";FTableColumnType2["DATE"]="date";FTableColumnType2["NUMERIC"]="numeric";FTableColumnType2["ACTION"]="action";return FTableColumnType2;})(FTableColumnType||{});var FTableColumnSize=/* @__PURE__ */(FTableColumnSize2=>{FTableColumnSize2["EXPAND"]="table__column--expand";FTableColumnSize2["SHRINK"]="table__column--shrink";return FTableColumnSize2;})(FTableColumnSize||{});var FTableColumnSort=/* @__PURE__ */(FTableColumnSort2=>{FTableColumnSort2["UNSORTED"]="unsorted";FTableColumnSort2["ASCENDING"]="ascending";FTableColumnSort2["DESCENDING"]="descending";return FTableColumnSort2;})(FTableColumnSort||{});function addColumn(src,column){if(!src.some(col=>col.name===column.name)){return[...src,column];}return src;}function setVisibilityColumn(src,id,visible){const column=src.find(col=>col.name===id);if(column){column.visible=visible;}}function updateSortOrder(src,columnName,ascending){src.forEach(column=>{if(column.name===columnName){column.sort=ascending?"ascending":"descending";}else{column.sort="unsorted";}});}function setSortableColumns(src,columnNames){for(const columnName of columnNames){const foundColumn=src.find(col=>col.name===columnName);if(foundColumn){foundColumn.sortable=true;}}}function getSortableIconName(column){switch(column.sort){case"unsorted":return"sort";case"ascending":return"caret-up";case"descending":return"caret-down";default:return"";}}function getSortableIconClasses(column){const classes=["table__column__header__icon"];if(column.sort==="unsorted"){classes.push("table__column__header__icon--discrete");}return classes;}function isTableColumnType(value){return["text","date","numeric","action"].includes(value);}function FTableInjected(){return{addColumn:inject("addColumn"),setVisibilityColumn:inject("setVisibilityColumn"),textFieldTableMode:true};}const _sfc_main$R=defineComponent({name:"FTableColumn",inheritAttrs:false,props:{/**
|
|
312
|
+
*/deleteModalHeader:{type:String,required:false,default:TranslationService.provider.translate("fkui.crud-dataset.modal.header.delete","Är du säker på att du vill ta bort raden?")}},emits:["change","created","deleted","updated","update:modelValue"],data(){return{result:[],Operation,operation:Operation.NONE,item:null,originalItemToUpdate:null,isFormModalOpen:false,isConfirmModalOpen:false,callbackAfterItemAdd(){},callbackBeforeItemDelete(){}};},computed:{confirmButtonText(){return this.operation===Operation.ADD?this.$t("fkui.crud-dataset.modal.confirm.add","Lägg till"):this.$t("fkui.crud-dataset.modal.confirm.modify","Spara");},cancelButtonText(){return this.operation===Operation.ADD?this.$t("fkui.crud-dataset.modal.cancel.add","Avbryt"):this.$t("fkui.crud-dataset.modal.cancel.modify","Avbryt");},confirmDeleteButtons(){return[{label:this.$t("fkui.crud-dataset.modal.confirm.delete","Ja, ta bort"),type:"primary",event:"confirm"},{label:this.$t("fkui.crud-dataset.modal.cancel.delete","Nej, avbryt"),type:"secondary"}];},hasAddSlot(){return Boolean(this.$slots.add);},hasDeleteSlot(){return Boolean(this.$slots.delete);},hasModifySlot(){return Boolean(this.$slots.modify);},formModalHeader(){return this.operation===Operation.ADD?this.addNewModalHeader:this.modifyModalHeader;}},watch:{modelValue:{immediate:true,deep:true,handler(data){this.result=[...data];}}},mounted(){if(!this.hasAddSlot&&!this.hasDeleteSlot&&!this.hasModifySlot){throw Error("Atleast one template of the following must be defined. #add, #delete or #modify");}},methods:{createItem(){if(!this.hasAddSlot){throw Error("No template is defined for #add");}this.operation=Operation.ADD;this.item=this.beforeCreate?this.beforeCreate():{};this.isFormModalOpen=true;},deleteItem(item){if(!this.hasDeleteSlot){throw Error("No template is defined for #delete");}this.operation=Operation.DELETE;this.item=item;this.isConfirmModalOpen=true;},onDeleteConfirm(){if(!this.item){return;}this.callbackBeforeItemDelete(this.item);this.result=this.result.filter(item=>item!==this.item);this.$emit("deleted",this.item);this.$emit("update:modelValue",this.result);this.$emit("change",this.result);alertScreenReader(this.$t("fkui.crud-dataset.aria-live.delete","Raden har tagits bort"),{assertive:true});},onDeleteClose(e){this.onModalClose();if(e.reason==="close"&&this.onCancel){this.onCancel();}},onModalClose(){this.isFormModalOpen=false;this.isConfirmModalOpen=false;},onFormModalSubmit(){if(!this.item){return;}if(this.operation===Operation.ADD){this.result.push(this.item);this.$emit("created",this.item);this.$emit("update:modelValue",this.result);this.$emit("change",this.result);this.callbackAfterItemAdd(this.item);alertScreenReader(this.$t("fkui.crud-dataset.aria-live.add","En rad har lagts till"),{assertive:true});}else if(this.operation===Operation.MODIFY){if(this.originalItemToUpdate){Object.assign(this.originalItemToUpdate,this.item);}else{this.originalItemToUpdate=this.item;}this.$emit("updated",this.originalItemToUpdate);this.$emit("update:modelValue",this.result);this.$emit("change",this.result);alertScreenReader(this.$t("fkui.crud-dataset.aria-live.modify","Raden har ändrats"),{assertive:true});}this.isFormModalOpen=false;},updateItem(item){if(!this.hasModifySlot){throw Error("No template is defined for #modify");}this.operation=Operation.MODIFY;this.originalItemToUpdate=item;this.item=deepClone(item);this.isFormModalOpen=true;}}});const _hoisted_1$F={class:"crud-dataset"};const _hoisted_2$t={key:0};function _sfc_render$J(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");const _component_f_form_modal=resolveComponent("f-form-modal");const _component_f_confirm_modal=resolveComponent("f-confirm-modal");return openBlock(),createElementBlock("div",_hoisted_1$F,[renderSlot(_ctx.$slots,"default"),createTextVNode(),_ctx.hasAddSlot?(openBlock(),createElementBlock("div",_hoisted_2$t,[createElementVNode("button",{"data-test":"f-crud-dataset-add-button",type:"button",class:"button button--discrete crud-dataset__add-button",onClick:_cache[0]||(_cache[0]=$event=>_ctx.createItem())},[createVNode(_component_f_icon,{class:"button__icon",name:"plus"}),createTextVNode(),renderSlot(_ctx.$slots,"add-button",{},()=>[createTextVNode(toDisplayString(_ctx.$t("fkui.crud-dataset.button.add","Lägg till ny")),1/* TEXT */)])])])):createCommentVNode("v-if",true),createTextVNode(),createVNode(_component_f_form_modal,{"is-open":_ctx.isFormModalOpen,"aria-close-text":_ctx.$t("fkui.crud-dataset.modal.close","Stäng"),"use-error-list":false,"before-submit":_ctx.beforeSubmit,"before-validation":_ctx.beforeValidation,"on-cancel":_ctx.onCancel,onClose:_ctx.onModalClose,onCancel:_ctx.onCancel,onSubmit:_ctx.onFormModalSubmit},{header:withCtx(()=>[createTextVNode(toDisplayString(_ctx.formModalHeader),1/* TEXT */)]),"input-text-fields":withCtx(()=>[_ctx.operation===_ctx.Operation.ADD?renderSlot(_ctx.$slots,"add",normalizeProps(mergeProps({key:0},{item:_ctx.item}))):createCommentVNode("v-if",true),createTextVNode(),_ctx.operation===_ctx.Operation.MODIFY?renderSlot(_ctx.$slots,"modify",normalizeProps(mergeProps({key:1},{item:_ctx.item}))):createCommentVNode("v-if",true)]),"submit-button-text":withCtx(()=>[createTextVNode(toDisplayString(_ctx.confirmButtonText),1/* TEXT */)]),"cancel-button-text":withCtx(()=>[createTextVNode(toDisplayString(_ctx.cancelButtonText),1/* TEXT */)]),_:3/* FORWARDED */},8,["is-open","aria-close-text","before-submit","before-validation","on-cancel","onClose","onCancel","onSubmit"]),createTextVNode(),createVNode(_component_f_confirm_modal,{"is-open":_ctx.isConfirmModalOpen,buttons:_ctx.confirmDeleteButtons,onConfirm:_ctx.onDeleteConfirm,onClose:_ctx.onDeleteClose},{heading:withCtx(()=>[createTextVNode(toDisplayString(_ctx.deleteModalHeader),1/* TEXT */)]),content:withCtx(()=>[renderSlot(_ctx.$slots,"delete",normalizeProps(guardReactiveProps({item:_ctx.item})))]),_:3/* FORWARDED */},8,["is-open","buttons","onConfirm","onClose"])]);}const FCrudDataset=/* @__PURE__ */_export_sfc(_sfc_main$T,[["render",_sfc_render$J]]);function FCrudDatasetInjected(){return{delete:inject("delete"),modify:inject("modify")};}const _sfc_main$S=defineComponent({name:"FCrudButton",components:{FIcon},mixins:[TranslationMixin],props:{action:{type:String,required:true,validator(value){return["delete","modify"].includes(value);}},icon:{type:Boolean,default:false},item:{type:Object,required:true},label:{type:Boolean,default:false}},setup(){return FCrudDatasetInjected();},computed:{iconName(){if(this.action==="delete"){return"trashcan";}else{return"pen";}},buttonText(){if(this.action==="delete"){return this.$t("fkui.crud-button.delete","Ta bort");}else{return this.$t("fkui.crud-button.modify","Ändra");}}},methods:{executeAction(){if(this.action==="delete"){this.delete(this.item);}else{this.modify(this.item);}}}});const _hoisted_1$E={key:1,class:"sr-only"};function _sfc_render$I(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");return openBlock(),createElementBlock("button",{type:"button",class:"button button--discrete",onClick:_cache[0]||(_cache[0]=(...args)=>_ctx.executeAction&&_ctx.executeAction(...args))},[_ctx.icon?(openBlock(),createBlock(_component_f_icon,{key:0,class:"button__icon",name:_ctx.iconName},null,8,["name"])):createCommentVNode("v-if",true),createTextVNode(),!_ctx.label?(openBlock(),createElementBlock("span",_hoisted_1$E,[renderSlot(_ctx.$slots,"default",{},()=>[createTextVNode(toDisplayString(_ctx.buttonText),1/* TEXT */)])])):createCommentVNode("v-if",true),createTextVNode(),_ctx.label?renderSlot(_ctx.$slots,"default",{key:2},()=>[createTextVNode(toDisplayString(_ctx.buttonText),1/* TEXT */)]):createCommentVNode("v-if",true)]);}const FCrudButton=/* @__PURE__ */_export_sfc(_sfc_main$S,[["render",_sfc_render$I]]);function ActivateItemInjected(){return{registerCallbackAfterItemAdd:inject("registerCallbackAfterItemAdd",()=>void 0),registerCallbackBeforeItemDelete:inject("registerCallbackBeforeItemDelete",()=>void 0)};}var FTableColumnType=/* @__PURE__ */(FTableColumnType2=>{FTableColumnType2["TEXT"]="text";FTableColumnType2["DATE"]="date";FTableColumnType2["NUMERIC"]="numeric";FTableColumnType2["ACTION"]="action";return FTableColumnType2;})(FTableColumnType||{});var FTableColumnSize=/* @__PURE__ */(FTableColumnSize2=>{FTableColumnSize2["EXPAND"]="table__column--expand";FTableColumnSize2["SHRINK"]="table__column--shrink";return FTableColumnSize2;})(FTableColumnSize||{});var FTableColumnSort=/* @__PURE__ */(FTableColumnSort2=>{FTableColumnSort2["UNSORTED"]="unsorted";FTableColumnSort2["ASCENDING"]="ascending";FTableColumnSort2["DESCENDING"]="descending";return FTableColumnSort2;})(FTableColumnSort||{});function addColumn(src,column){if(!src.some(col=>col.name===column.name)){return[...src,column];}return src;}function setVisibilityColumn(src,id,visible){const column=src.find(col=>col.name===id);if(column){column.visible=visible;}}function updateSortOrder(src,columnName,ascending){src.forEach(column=>{if(column.name===columnName){column.sort=ascending?"ascending":"descending";}else{column.sort="unsorted";}});}function setSortableColumns(src,columnNames){for(const columnName of columnNames){const foundColumn=src.find(col=>col.name===columnName);if(foundColumn){foundColumn.sortable=true;}}}function getSortableIconName(column){switch(column.sort){case"unsorted":return"sort";case"ascending":return"caret-up";case"descending":return"caret-down";default:return"";}}function getSortableIconClasses(column){const classes=["table__column__header__icon"];if(column.sort==="unsorted"){classes.push("table__column__header__icon--discrete");}return classes;}function isTableColumnType(value){return["text","date","numeric","action"].includes(value);}function FTableInjected(){return{addColumn:inject("addColumn"),setVisibilityColumn:inject("setVisibilityColumn"),textFieldTableMode:true};}const _sfc_main$R=defineComponent({name:"FTableColumn",inheritAttrs:false,props:{/**
|
|
309
313
|
* Unique (per-table) identifier.
|
|
310
314
|
*
|
|
311
315
|
* Typically set to the row property displayed but any unique string can
|
|
@@ -473,7 +477,7 @@ defaultText:"",descriptionText:"",descriptionScreenReaderText:"",discreteDescrip
|
|
|
473
477
|
* - `"vertical"`: Enables vertical scrolling
|
|
474
478
|
* - `"both"`: Enables scrolling in both directions
|
|
475
479
|
* - `"none"`: Disables scrolling (default)
|
|
476
|
-
*/scroll:{type:String,default:TableScroll.NONE,validator:function(value){const types=Object.values(TableScroll);return types.includes(value);}}},setup(){return FSortFilterDatasetInjected();},data(){return{columns:[],emptyRow:emptyTableRow()};},computed:{hasCaption(){return hasSlot(this,"caption");},tableClasses(){const classes=[];if(this.striped){classes.push("table--striped");}return classes;},isEmpty(){return this.rows.length===0;},visibleColumns(){return this.columns.filter(col=>col.visible);},hasInitiateColumns(){return this.columns.length>0;},wrapperClasses(){return tableScrollClasses(this.scroll);},tabindex(){return this.scroll!==TableScroll.NONE?0:void 0;}},mounted(){this.registerCallbackOnSort(this.callbackOnSort);this.registerCallbackOnMount(this.callbackSortableColumns);},methods:{rowKey(item){const key=item[this.keyAttribute];if(typeof key==="undefined"){throw new Error(`Key attribute [${this.keyAttribute}]' is missing in row`);}return String(key);},columnClasses(column){const classes=["table__column",`table__column--${column.type}`,column.size];if(column.sortable){classes.push("table__column--sortable");}return classes;},iconClasses(column){return getSortableIconClasses(column);},iconName(column){return getSortableIconName(column);},onClickColumnHeader(column){if(!column.sortable){return;}let columnName=column.name;if(column.sort===FTableColumnSort.DESCENDING){columnName="";column.sort=FTableColumnSort.UNSORTED;}this.sort(columnName,column.sort!==FTableColumnSort.ASCENDING);},callbackOnSort(columnName,ascending){updateSortOrder(this.columns,columnName,ascending);},callbackSortableColumns(columnNames){setSortableColumns(this.columns,columnNames);},escapeNewlines(value){return value.replace(/\n/g,"<br/>");}}});const _hoisted_1$v=["tabindex"];const _hoisted_2$p={key:0};const _hoisted_3$m={class:"table__row"};const _hoisted_4$h=["innerHTML"];const _hoisted_5$f={key:1,class:"table__column__description"};const _hoisted_6$b={key:0};const _hoisted_7$a={key:1};const _hoisted_8$8=["colspan"];function _sfc_render$y(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");return openBlock(),createElementBlock("div",{class:normalizeClass(_ctx.wrapperClasses)},[createElementVNode("table",mergeProps({class:["table",_ctx.tableClasses],tabindex:_ctx.tabindex},_ctx.$attrs),[_ctx.hasCaption?(openBlock(),createElementBlock("caption",_hoisted_2$p,[renderSlot(_ctx.$slots,"caption")])):createCommentVNode("v-if",true),createTextVNode(),createElementVNode("colgroup",null,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.columns,column=>{return openBlock(),createElementBlock("col",{key:column.id,class:normalizeClass(column.size)},null,2/* CLASS */);}),128/* KEYED_FRAGMENT */))]),createTextVNode(),createElementVNode("thead",null,[createElementVNode("tr",_hoisted_3$m,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.visibleColumns,column=>{return openBlock(),createElementBlock("th",mergeProps({key:column.id,scope:"col",class:_ctx.columnClasses(column)},toHandlers(column.sortable?{click:()=>_ctx.onClickColumnHeader(column)}:{},true)),[createElementVNode("span",{innerHTML:_ctx.escapeNewlines(column.title)},null,8,_hoisted_4$h),createTextVNode(),column.sortable?(openBlock(),createBlock(_component_f_icon,{key:0,class:normalizeClass(_ctx.iconClasses(column)),name:_ctx.iconName(column)},null,8,["class","name"])):createCommentVNode("v-if",true),createTextVNode(),column.description?(openBlock(),createElementBlock("span",_hoisted_5$f,toDisplayString(column.description),1/* TEXT */)):createCommentVNode("v-if",true)],16/* FULL_PROPS */);}),128/* KEYED_FRAGMENT */))])]),createTextVNode(),createElementVNode("tbody",null,[!_ctx.hasInitiateColumns?(openBlock(),createElementBlock("tr",_hoisted_6$b,[renderSlot(_ctx.$slots,"default",normalizeProps(guardReactiveProps({row:_ctx.emptyRow})))])):createCommentVNode("v-if",true),createTextVNode(),_ctx.isEmpty?(openBlock(),createElementBlock("tr",_hoisted_7$a,[createElementVNode("td",{class:"table__column table__column--action",colspan:_ctx.columns.length},[renderSlot(_ctx.$slots,"empty",{},()=>[createTextVNode(toDisplayString(_ctx.$t("fkui.data-table.empty","Tabellen är tom")),1/* TEXT */)])],8,_hoisted_8$8)])):createCommentVNode("v-if",true),createTextVNode(),(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.rows,row=>{return openBlock(),createElementBlock("tr",{key:_ctx.rowKey(row),class:"table__row"},[renderSlot(_ctx.$slots,"default",mergeProps({ref_for:true},{row}))]);}),128/* KEYED_FRAGMENT */))])],16,_hoisted_1$v)],2/* CLASS */);}const FDataTable=/* @__PURE__ */_export_sfc(_sfc_main$y,[["render",_sfc_render$y]]);function isDayEnabled(day,config2){return passesMinDate(day,config2.minDate)&&passesMaxDate(day,config2.maxDate)&&passesInvalidDates(day,config2.invalidDates)&&passesInvalidWeekdays(day,config2.invalidWeekdays);}function passesMinDate(day,config2){if(!config2){throw new Error("MinDate validator must be set");}if(!config2.limit){throw new Error("Invalid minDate config");}return config2.limit<=day.toString();}function passesMaxDate(day,config2){if(!config2){throw new Error("MaxDate validator must be set");}if(!config2.limit){throw new Error("Invalid maxDate config");}return day.toString()<=config2.limit;}function passesInvalidDates(day,config2){if(!config2){return true;}if(!isInvalidDatesConfig(config2)){throw new Error("Invalid invalidDates config");}return!config2.dates.includes(day.toString());}function passesInvalidWeekdays(day,config2){if(!config2){return true;}if(!isInvalidWeekdaysConfig(config2)){throw new Error("Invalid invalidWeekdays config");}return!config2.days.includes(day.weekDay);}function updateCalendarValue(newValue){const newCalendarValue=FDate.fromIso(newValue);if(!newCalendarValue.isValid()){
|
|
480
|
+
*/scroll:{type:String,default:TableScroll.NONE,validator:function(value){const types=Object.values(TableScroll);return types.includes(value);}}},setup(){return FSortFilterDatasetInjected();},data(){return{columns:[],emptyRow:emptyTableRow()};},computed:{hasCaption(){return hasSlot(this,"caption");},tableClasses(){const classes=[];if(this.striped){classes.push("table--striped");}return classes;},isEmpty(){return this.rows.length===0;},visibleColumns(){return this.columns.filter(col=>col.visible);},hasInitiateColumns(){return this.columns.length>0;},wrapperClasses(){return tableScrollClasses(this.scroll);},tabindex(){return this.scroll!==TableScroll.NONE?0:void 0;}},mounted(){this.registerCallbackOnSort(this.callbackOnSort);this.registerCallbackOnMount(this.callbackSortableColumns);},methods:{rowKey(item){const key=item[this.keyAttribute];if(typeof key==="undefined"){throw new Error(`Key attribute [${this.keyAttribute}]' is missing in row`);}return String(key);},columnClasses(column){const classes=["table__column",`table__column--${column.type}`,column.size];if(column.sortable){classes.push("table__column--sortable");}return classes;},iconClasses(column){return getSortableIconClasses(column);},iconName(column){return getSortableIconName(column);},onClickColumnHeader(column){if(!column.sortable){return;}let columnName=column.name;if(column.sort===FTableColumnSort.DESCENDING){columnName="";column.sort=FTableColumnSort.UNSORTED;}this.sort(columnName,column.sort!==FTableColumnSort.ASCENDING);},callbackOnSort(columnName,ascending){updateSortOrder(this.columns,columnName,ascending);},callbackSortableColumns(columnNames){setSortableColumns(this.columns,columnNames);},escapeNewlines(value){return value.replace(/\n/g,"<br/>");}}});const _hoisted_1$v=["tabindex"];const _hoisted_2$p={key:0};const _hoisted_3$m={class:"table__row"};const _hoisted_4$h=["innerHTML"];const _hoisted_5$f={key:1,class:"table__column__description"};const _hoisted_6$b={key:0};const _hoisted_7$a={key:1};const _hoisted_8$8=["colspan"];function _sfc_render$y(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");return openBlock(),createElementBlock("div",{class:normalizeClass(_ctx.wrapperClasses)},[createElementVNode("table",mergeProps({class:["table",_ctx.tableClasses],tabindex:_ctx.tabindex},_ctx.$attrs),[_ctx.hasCaption?(openBlock(),createElementBlock("caption",_hoisted_2$p,[renderSlot(_ctx.$slots,"caption")])):createCommentVNode("v-if",true),createTextVNode(),createElementVNode("colgroup",null,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.columns,column=>{return openBlock(),createElementBlock("col",{key:column.id,class:normalizeClass(column.size)},null,2/* CLASS */);}),128/* KEYED_FRAGMENT */))]),createTextVNode(),createElementVNode("thead",null,[createElementVNode("tr",_hoisted_3$m,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.visibleColumns,column=>{return openBlock(),createElementBlock("th",mergeProps({key:column.id,scope:"col",class:_ctx.columnClasses(column)},toHandlers(column.sortable?{click:()=>_ctx.onClickColumnHeader(column)}:{},true)),[createElementVNode("span",{innerHTML:_ctx.escapeNewlines(column.title)},null,8,_hoisted_4$h),createTextVNode(),column.sortable?(openBlock(),createBlock(_component_f_icon,{key:0,class:normalizeClass(_ctx.iconClasses(column)),name:_ctx.iconName(column)},null,8,["class","name"])):createCommentVNode("v-if",true),createTextVNode(),column.description?(openBlock(),createElementBlock("span",_hoisted_5$f,toDisplayString(column.description),1/* TEXT */)):createCommentVNode("v-if",true)],16/* FULL_PROPS */);}),128/* KEYED_FRAGMENT */))])]),createTextVNode(),createElementVNode("tbody",null,[!_ctx.hasInitiateColumns?(openBlock(),createElementBlock("tr",_hoisted_6$b,[renderSlot(_ctx.$slots,"default",normalizeProps(guardReactiveProps({row:_ctx.emptyRow})))])):createCommentVNode("v-if",true),createTextVNode(),_ctx.isEmpty?(openBlock(),createElementBlock("tr",_hoisted_7$a,[createElementVNode("td",{class:"table__column table__column--action",colspan:_ctx.columns.length},[renderSlot(_ctx.$slots,"empty",{},()=>[createTextVNode(toDisplayString(_ctx.$t("fkui.data-table.empty","Tabellen är tom")),1/* TEXT */)])],8,_hoisted_8$8)])):createCommentVNode("v-if",true),createTextVNode(),(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.rows,row=>{return openBlock(),createElementBlock("tr",{key:_ctx.rowKey(row),class:"table__row"},[renderSlot(_ctx.$slots,"default",mergeProps({ref_for:true},{row}))]);}),128/* KEYED_FRAGMENT */))])],16,_hoisted_1$v)],2/* CLASS */);}const FDataTable=/* @__PURE__ */_export_sfc(_sfc_main$y,[["render",_sfc_render$y]]);function isDayEnabled(day,config2){return passesMinDate(day,config2.minDate)&&passesMaxDate(day,config2.maxDate)&&passesInvalidDates(day,config2.invalidDates)&&passesInvalidWeekdays(day,config2.invalidWeekdays);}function passesMinDate(day,config2){if(!config2){throw new Error("MinDate validator must be set");}if(!config2.limit){throw new Error("Invalid minDate config");}return config2.limit<=day.toString();}function passesMaxDate(day,config2){if(!config2){throw new Error("MaxDate validator must be set");}if(!config2.limit){throw new Error("Invalid maxDate config");}return day.toString()<=config2.limit;}function passesInvalidDates(day,config2){if(!config2){return true;}if(!isInvalidDatesConfig(config2)){throw new Error("Invalid invalidDates config");}return!config2.dates.includes(day.toString());}function passesInvalidWeekdays(day,config2){if(!config2){return true;}if(!isInvalidWeekdaysConfig(config2)){throw new Error("Invalid invalidWeekdays config");}return!config2.days.includes(day.weekDay);}function updateCalendarValue(datepicker,newValue){const{isDateEnabled,minDate,maxDate}=datepicker;const newCalendarValue=FDate.fromIso(newValue);if(!newCalendarValue.isValid()){datepicker.calendarValue=void 0;}else if(isInvalidMonth(newCalendarValue,minDate,maxDate)){datepicker.calendarValue=void 0;}else if(!isDateEnabled(newCalendarValue)){datepicker.calendarValue=void 0;}else if(!datepicker.calendarValue||!datepicker.calendarValue.equals(newCalendarValue)){datepicker.calendarValue=newCalendarValue;}}function getDisplayMonth(minDate,maxDate,selectedDate,initialMonth){let effectiveDate;if(selectedDate&&selectedDate.isValid()){effectiveDate=selectedDate;}else if(initialMonth&&initialMonth.isValid()){effectiveDate=initialMonth;}else{effectiveDate=FDate.now();}let month;if(!isInvalidMonth(effectiveDate,minDate,maxDate)){month=effectiveDate.startOfMonth();}else if(isMonthBefore(effectiveDate,minDate)){month=minDate==null?void 0:minDate.startOfMonth();}else if(isMonthAfter(effectiveDate,maxDate)){month=maxDate==null?void 0:maxDate.startOfMonth();}return month||FDate.now().startOfMonth();}const _sfc_main$x=defineComponent({name:"FDatepickerField",components:{FCalendar,IPopup,FTextField,FIcon,FCalendarDay},mixins:[TranslationMixin],inheritAttrs:false,props:{/** Selected day.
|
|
477
481
|
* @model
|
|
478
482
|
*/modelValue:{type:String,required:false,default:""},/**
|
|
479
483
|
* Initial month. Applies when no day is selected.
|
|
@@ -496,7 +500,7 @@ defaultText:"",descriptionText:"",descriptionScreenReaderText:"",discreteDescrip
|
|
|
496
500
|
* ```
|
|
497
501
|
*/inputWidth:{type:String,required:false,default:"sm-12"},/**
|
|
498
502
|
* Set to `true`, empty string `""` or string `"disabled"` to disable this field.
|
|
499
|
-
*/disabled:{type:Boolean,required:false,default:false}},emits:["change","update:modelValue"],setup(){const defaultMinDate=FDate.now().addYears(-10);const defaultMaxDate=FDate.now().addYears(10);return{textFieldValue:ref(""),textFieldTouched:ref(false),textFieldValidityRevealed:ref(false),textFieldTableMode:inject("textFieldTableMode",false),componentTouched:ref(false),calendarMonth:shallowRef(getDisplayMonth(defaultMinDate,defaultMaxDate)),calendarValue:shallowRef(void 0),isCalendarOpen:ref(false),validationConfig:ref({}),minDate:shallowRef(defaultMinDate),maxDate:shallowRef(defaultMaxDate),calendarInputs:ref(null)};},computed:{calendarButtonText(){const{calendarValue}=this;if(calendarValue&&calendarValue.isValid()){const prettyDate=calendarValue.toString(DateFormat.FULL);const text=this.$t("fkui.datepicker-field.change","Ändra datum");return`${text} ${prettyDate}`;}else{return this.$t("fkui.datepicker-field.choose","Välj datum");}},popupClass(){return this.textFieldTableMode?"datepicker-field__popup datepicker-field__table":"datepicker-field__popup";}},watch:{modelValue:{async handler(value){if(value!==this.textFieldValue){await this.updateTextFieldValue(value);this.updateCalendarValue(value);}},immediate:true}},mounted(){ValidationService.addValidatorsToElement(getInputElement(this),{date:{},dateFormat:{},minDate:{limit:this.minDate.toString()},maxDate:{limit:this.maxDate.toString()}},true);},methods:{dateFormatter:parseDate,async onValidityTextField({detail}){if(this.textFieldValidityRevealed&&detail.validityMode==="INITIAL"){this.textFieldTouched=false;this.componentTouched=false;}if(!this.textFieldTouched&&["blur","change"].includes(detail.nativeEvent)){this.textFieldTouched=true;}if(this.isCalendarOpen){alertScreenReader(detail.validationMessage,{assertive:true});}this.textFieldValidityRevealed=detail.validityMode!=="INITIAL";if(detail.validityMode==="INITIAL"||!this.textFieldTouched||this.componentTouched){return;}const inputElement=getInputElement(this);const pendingValidityEvent=new CustomEvent("pending-validity",{bubbles:false});inputElement.dispatchEvent(pendingValidityEvent);},onChangeTextField(){this.updateCalendarValue(this.textFieldValue);this.$emit("update:modelValue",this.textFieldValue);this.$emit("change",this.textFieldValue);},onClickCalendarButton(){if(!this.isCalendarOpen){this.calendarMonth=getDisplayMonth(this.minDate,this.maxDate,this.calendarValue,this.initialMonth);}this.isCalendarOpen=!this.isCalendarOpen;},onFocusoutTextFieldButton(e){if(this.componentTouched||this.$refs.component===null){return;}const component=getHTMLElementFromVueRef(this.$refs.component);const relatedTarget=e.relatedTarget;if(!component.contains(relatedTarget)){this.componentTouched=true;const inputElement=getInputElement(this);ValidationService.setTouched(inputElement);ValidationService.validateElement(inputElement);}},async onSelectCalendarDay(date){this.componentTouched=true;this.isCalendarOpen=!this.isDateEnabled(date);if(!this.isCalendarOpen){getHTMLElementFromVueRef(this.$refs.calendarButton).focus();}this.$emit("update:modelValue",date.toString());this.$emit("change",date.toString());await this.updateTextFieldValue(date.toString());this.updateCalendarValue(date.toString());},async onKeyupEsc(){this.isCalendarOpen=false;waitForScreenReader(()=>{getHTMLElementFromVueRef(this.$refs.calendarButton).focus();});},async onClickCloseCalendarButton(){this.isCalendarOpen=false;waitForScreenReader(()=>{getHTMLElementFromVueRef(this.$refs.calendarButton).focus();});},onOpenPopup(){if(!this.isCalendarOpen){return;}const popup=getHTMLElementFromVueRef(this.$refs.popup);const navMonth=popup.querySelector(".calendar-navbar__month");if(navMonth){navMonth.focus({preventScroll:true});}},onClosePopup(){this.isCalendarOpen=false;},async onValidationConfigUpdate(event){this.validationConfig=event.detail.config;if(this.validationConfig.minDate){const minDateConfig=this.validationConfig.minDate;if(!minDateConfig.limit){throw new Error("MinDate validator must be set");}this.minDate=FDate.fromIso(minDateConfig.limit.toString());}if(this.validationConfig.maxDate){const maxDateConfig=this.validationConfig.maxDate;if(!maxDateConfig.limit){throw new Error("MaxDate validator must be set");}this.maxDate=FDate.fromIso(maxDateConfig.limit.toString());}const element=findHTMLElementFromVueRef(this.$refs.calendarInputs);if(element){await this.$nextTick();ValidationService.validateAllElements(element);}},isDateEnabled(day){return isDayEnabled(day,this.validationConfig);},isDaySelected(date){return this.calendarValue?date.equals(this.calendarValue):false;},highlightDay(date){return this.highlightToday&&date.equals(FDate.now());},async updateTextFieldValue(newValue){this.textFieldValue=newValue;await this.$nextTick();ValidationService.validateElement(getInputElement(this));},updateCalendarValue}});const _hoisted_1$u={ref:"component",class:"datepicker-field"};const _hoisted_2$o=["disabled","aria-expanded"];const _hoisted_3$l={class:"sr-only"};const _hoisted_4$g={class:"datepicker-field__close"};function _sfc_render$x(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");const _component_f_text_field=resolveComponent("f-text-field");const _component_f_calendar_day=resolveComponent("f-calendar-day");const _component_f_calendar=resolveComponent("f-calendar");const _component_i_popup=resolveComponent("i-popup");return openBlock(),createElementBlock("div",_hoisted_1$u,[createElementVNode("div",{ref:"calendarInputs",onFocusout:_cache[2]||(_cache[2]=(...args)=>_ctx.onFocusoutTextFieldButton&&_ctx.onFocusoutTextFieldButton(...args))},[createVNode(_component_f_text_field,mergeProps(_ctx.$attrs,{modelValue:_ctx.textFieldValue,"onUpdate:modelValue":_cache[1]||(_cache[1]=$event=>_ctx.textFieldValue=$event),maxlength:"20",disabled:_ctx.disabled,formatter:_ctx.dateFormatter,"label-width":_ctx.labelWidth,"input-width":_ctx.inputWidth,onComponentValidity:_ctx.onValidityTextField,onChange:_ctx.onChangeTextField,onValidationConfigUpdate:_ctx.onValidationConfigUpdate}),createSlots({description:withCtx(({descriptionClass,discreteDescriptionClass})=>[renderSlot(_ctx.$slots,"description",normalizeProps(guardReactiveProps({descriptionClass,discreteDescriptionClass})))]),"error-message":withCtx(({hasError,validationMessage})=>[renderSlot(_ctx.$slots,"error-message",normalizeProps(guardReactiveProps({hasError,validationMessage})))]),"input-right":withCtx(()=>[createElementVNode("button",{ref:"calendarButton",disabled:_ctx.disabled,class:"datepicker-field__button",type:"button","aria-expanded":_ctx.isCalendarOpen?"true":"false","data-test":"calendar-button",onClick:_cache[0]||(_cache[0]=$event=>_ctx.onClickCalendarButton())},[createVNode(_component_f_icon,{name:"calendar"}),createTextVNode(),createElementVNode("span",_hoisted_3$l,toDisplayString(_ctx.calendarButtonText),1/* TEXT */)],8,_hoisted_2$o)]),default:withCtx(()=>[renderSlot(_ctx.$slots,"default",{},()=>[createTextVNode(toDisplayString(_ctx.$t("fkui.datepicker-field.label","Datum")),1/* TEXT */)]),createTextVNode(),createTextVNode(),createTextVNode(),createTextVNode()]),_:2/* DYNAMIC */},[_ctx.$slots.tooltip?{name:"tooltip",fn:withCtx(()=>[renderSlot(_ctx.$slots,"tooltip")]),key:"0"}:void 0]),1040,["modelValue","disabled","formatter","label-width","input-width","onComponentValidity","onChange","onValidationConfigUpdate"])],544/* NEED_HYDRATION, NEED_PATCH */),createTextVNode(),createVNode(_component_i_popup,{"is-open":_ctx.isCalendarOpen,anchor:_ctx.calendarInputs,inline:_ctx.alwaysInline?"always":void 0,"set-focus":false,onOpen:_ctx.onOpenPopup,onClose:_ctx.onClosePopup},{default:withCtx(()=>[createElementVNode("div",{ref:"popup",class:normalizeClass(_ctx.popupClass)},[createVNode(_component_f_calendar,{modelValue:_ctx.calendarMonth,"onUpdate:modelValue":_cache[3]||(_cache[3]=$event=>_ctx.calendarMonth=$event),"tab-date":_ctx.calendarValue,"min-date":_ctx.minDate,"max-date":_ctx.maxDate,onClick:_ctx.onSelectCalendarDay,onKeyup:withKeys(withModifiers(_ctx.onKeyupEsc,["stop"]),["esc","native"])},{default:withCtx(({date,isFocused})=>[createVNode(_component_f_calendar_day,{day:date,enabled:_ctx.isDateEnabled(date),focused:isFocused,highlight:_ctx.highlightDay(date),selected:_ctx.isDaySelected(date)},null,8,["day","enabled","focused","highlight","selected"])]),_:1/* STABLE */},8,["modelValue","tab-date","min-date","max-date","onClick","onKeyup"]),createTextVNode(),createElementVNode("div",_hoisted_4$g,[createElementVNode("button",{class:"button button--discrete button--discrete--black datepicker-field__close__button",type:"button",onClick:_cache[4]||(_cache[4]=(...args)=>_ctx.onClickCloseCalendarButton&&_ctx.onClickCloseCalendarButton(...args)),onKeyup:_cache[5]||(_cache[5]=withKeys(withModifiers((...args)=>_ctx.onKeyupEsc&&_ctx.onKeyupEsc(...args),["stop"]),["esc"]))},[createElementVNode("span",null,toDisplayString(_ctx.$t("fkui.datepicker-field.close","Stäng")),1/* TEXT */),createTextVNode(),createVNode(_component_f_icon,{"aria-hidden":"true",class:"button__icon",name:"close"})],32/* NEED_HYDRATION */)])],2/* CLASS */)]),_:1/* STABLE */},8,["is-open","anchor","inline","onOpen","onClose"])],512/* NEED_PATCH */);}const FDatepickerField=/* @__PURE__ */_export_sfc(_sfc_main$x,[["render",_sfc_render$x]]);const _sfc_main$w=defineComponent({name:"FExpand",data(){return{height:0,initialStyle:{overflow:"hidden",transition:"height 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96)"},hiddenStyle:{height:"auto",position:"absolute",visibility:"hidden"},visibleStyle:{width:"",position:"",visibility:"",height:"0px"},openedStyle:{height:"auto"}};},methods:{enter(element){const htmlElement=getHTMLElementFromVueRef(element);Object.assign(htmlElement.style,this.initialStyle);Object.assign(htmlElement.style,this.hiddenStyle);htmlElement.style.width=getComputedStyle(element).width;const height=getComputedStyle(element).height;Object.assign(htmlElement.style,this.visibleStyle);getComputedStyle(element).height;setTimeout(()=>{this.height=parseInt(height,10);htmlElement.style.height=height;});},afterEnter(element){const htmlElement=getHTMLElementFromVueRef(element);Object.assign(htmlElement.style,this.openedStyle);},leave(element){const htmlElement=getHTMLElementFromVueRef(element);const height=getComputedStyle(element).height;htmlElement.style.height=height;getComputedStyle(element).height;setTimeout(()=>{Object.assign(htmlElement.style,this.visibleStyle);});}}});function _sfc_render$w(_ctx,_cache,$props,$setup,$data,$options){return openBlock(),createBlock(Transition,{onEnter:_ctx.enter,onAfterEnter:_ctx.afterEnter,onLeave:_ctx.leave},{default:withCtx(()=>[renderSlot(_ctx.$slots,"default",{height:_ctx.height})]),_:3/* FORWARDED */},8,["onEnter","onAfterEnter","onLeave"]);}const FExpand=/* @__PURE__ */_export_sfc(_sfc_main$w,[["render",_sfc_render$w]]);const _sfc_main$v=defineComponent({name:"FExpandablePanel",components:{FIcon,FExpand},mixins:[TranslationMixin],inheritAttrs:false,props:{/**
|
|
503
|
+
*/disabled:{type:Boolean,required:false,default:false}},emits:["change","update:modelValue"],setup(){const defaultMinDate=FDate.now().addYears(-10);const defaultMaxDate=FDate.now().addYears(10);return{textFieldValue:ref(""),textFieldTouched:ref(false),textFieldValidityRevealed:ref(false),textFieldTableMode:inject("textFieldTableMode",false),componentTouched:ref(false),calendarMonth:shallowRef(getDisplayMonth(defaultMinDate,defaultMaxDate)),calendarValue:shallowRef(void 0),isCalendarOpen:ref(false),validationConfig:ref({}),minDate:shallowRef(defaultMinDate),maxDate:shallowRef(defaultMaxDate),calendarInputs:ref(null)};},computed:{calendarButtonText(){const{calendarValue}=this;if(calendarValue&&calendarValue.isValid()){const prettyDate=calendarValue.toString(DateFormat.FULL);const text=this.$t("fkui.datepicker-field.change","Ändra datum");return`${text} ${prettyDate}`;}else{return this.$t("fkui.datepicker-field.choose","Välj datum");}},popupClass(){return this.textFieldTableMode?"datepicker-field__popup datepicker-field__table":"datepicker-field__popup";}},watch:{modelValue:{async handler(value){if(value!==this.textFieldValue){await this.updateTextFieldValue(value);updateCalendarValue(this,value);}},immediate:true}},mounted(){ValidationService.addValidatorsToElement(getInputElement(this),{date:{},dateFormat:{},minDate:{limit:this.minDate.toString()},maxDate:{limit:this.maxDate.toString()}},true);},methods:{dateFormatter:parseDate,async onValidityTextField({detail}){if(this.textFieldValidityRevealed&&detail.validityMode==="INITIAL"){this.textFieldTouched=false;this.componentTouched=false;}if(!this.textFieldTouched&&["blur","change"].includes(detail.nativeEvent)){this.textFieldTouched=true;}if(this.isCalendarOpen){alertScreenReader(detail.validationMessage,{assertive:true});}this.textFieldValidityRevealed=detail.validityMode!=="INITIAL";if(detail.validityMode==="INITIAL"||!this.textFieldTouched||this.componentTouched){return;}const inputElement=getInputElement(this);const pendingValidityEvent=new CustomEvent("pending-validity",{bubbles:false});inputElement.dispatchEvent(pendingValidityEvent);},onChangeTextField(){updateCalendarValue(this,this.textFieldValue);this.$emit("update:modelValue",this.textFieldValue);this.$emit("change",this.textFieldValue);},onClickCalendarButton(){if(!this.isCalendarOpen){this.calendarMonth=getDisplayMonth(this.minDate,this.maxDate,this.calendarValue,this.initialMonth);}this.isCalendarOpen=!this.isCalendarOpen;},onFocusoutTextFieldButton(e){if(this.componentTouched||this.$refs.component===null){return;}const component=getHTMLElementFromVueRef(this.$refs.component);const relatedTarget=e.relatedTarget;if(!component.contains(relatedTarget)){this.componentTouched=true;const inputElement=getInputElement(this);ValidationService.setTouched(inputElement);ValidationService.validateElement(inputElement);}},async onSelectCalendarDay(date){this.componentTouched=true;this.isCalendarOpen=!this.isDateEnabled(date);if(!this.isCalendarOpen){getHTMLElementFromVueRef(this.$refs.calendarButton).focus();}this.$emit("update:modelValue",date.toString());this.$emit("change",date.toString());await this.updateTextFieldValue(date.toString());updateCalendarValue(this,date.toString());},async onKeyupEsc(){this.isCalendarOpen=false;waitForScreenReader(()=>{getHTMLElementFromVueRef(this.$refs.calendarButton).focus();});},async onClickCloseCalendarButton(){this.isCalendarOpen=false;waitForScreenReader(()=>{getHTMLElementFromVueRef(this.$refs.calendarButton).focus();});},onOpenPopup(){if(!this.isCalendarOpen){return;}const popup=getHTMLElementFromVueRef(this.$refs.popup);const navMonth=popup.querySelector(".calendar-navbar__month");if(navMonth){navMonth.focus({preventScroll:true});}},onClosePopup(){this.isCalendarOpen=false;},async onValidationConfigUpdate(event){this.validationConfig=event.detail.config;if(this.validationConfig.minDate){const minDateConfig=this.validationConfig.minDate;if(!minDateConfig.limit){throw new Error("MinDate validator must be set");}this.minDate=FDate.fromIso(minDateConfig.limit.toString());}if(this.validationConfig.maxDate){const maxDateConfig=this.validationConfig.maxDate;if(!maxDateConfig.limit){throw new Error("MaxDate validator must be set");}this.maxDate=FDate.fromIso(maxDateConfig.limit.toString());}const element=findHTMLElementFromVueRef(this.$refs.calendarInputs);if(element){await this.$nextTick();ValidationService.validateAllElements(element);}},isDateEnabled(day){return isDayEnabled(day,this.validationConfig);},isDaySelected(date){return this.calendarValue?date.equals(this.calendarValue):false;},highlightDay(date){return this.highlightToday&&date.equals(FDate.now());},async updateTextFieldValue(newValue){this.textFieldValue=newValue;await this.$nextTick();ValidationService.validateElement(getInputElement(this));}}});const _hoisted_1$u={ref:"component",class:"datepicker-field"};const _hoisted_2$o=["disabled","aria-expanded"];const _hoisted_3$l={class:"sr-only"};const _hoisted_4$g={class:"datepicker-field__close"};function _sfc_render$x(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");const _component_f_text_field=resolveComponent("f-text-field");const _component_f_calendar_day=resolveComponent("f-calendar-day");const _component_f_calendar=resolveComponent("f-calendar");const _component_i_popup=resolveComponent("i-popup");return openBlock(),createElementBlock("div",_hoisted_1$u,[createElementVNode("div",{ref:"calendarInputs",onFocusout:_cache[2]||(_cache[2]=(...args)=>_ctx.onFocusoutTextFieldButton&&_ctx.onFocusoutTextFieldButton(...args))},[createVNode(_component_f_text_field,mergeProps(_ctx.$attrs,{modelValue:_ctx.textFieldValue,"onUpdate:modelValue":_cache[1]||(_cache[1]=$event=>_ctx.textFieldValue=$event),maxlength:"20",disabled:_ctx.disabled,formatter:_ctx.dateFormatter,"label-width":_ctx.labelWidth,"input-width":_ctx.inputWidth,onComponentValidity:_ctx.onValidityTextField,onChange:_ctx.onChangeTextField,onValidationConfigUpdate:_ctx.onValidationConfigUpdate}),createSlots({description:withCtx(({descriptionClass,discreteDescriptionClass})=>[renderSlot(_ctx.$slots,"description",normalizeProps(guardReactiveProps({descriptionClass,discreteDescriptionClass})))]),"error-message":withCtx(({hasError,validationMessage})=>[renderSlot(_ctx.$slots,"error-message",normalizeProps(guardReactiveProps({hasError,validationMessage})))]),"input-right":withCtx(()=>[createElementVNode("button",{ref:"calendarButton",disabled:_ctx.disabled,class:"datepicker-field__button",type:"button","aria-expanded":_ctx.isCalendarOpen?"true":"false","data-test":"calendar-button",onClick:_cache[0]||(_cache[0]=$event=>_ctx.onClickCalendarButton())},[createVNode(_component_f_icon,{name:"calendar"}),createTextVNode(),createElementVNode("span",_hoisted_3$l,toDisplayString(_ctx.calendarButtonText),1/* TEXT */)],8,_hoisted_2$o)]),default:withCtx(()=>[renderSlot(_ctx.$slots,"default",{},()=>[createTextVNode(toDisplayString(_ctx.$t("fkui.datepicker-field.label","Datum")),1/* TEXT */)]),createTextVNode(),createTextVNode(),createTextVNode(),createTextVNode()]),_:2/* DYNAMIC */},[_ctx.$slots.tooltip?{name:"tooltip",fn:withCtx(()=>[renderSlot(_ctx.$slots,"tooltip")]),key:"0"}:void 0]),1040,["modelValue","disabled","formatter","label-width","input-width","onComponentValidity","onChange","onValidationConfigUpdate"])],544/* NEED_HYDRATION, NEED_PATCH */),createTextVNode(),createVNode(_component_i_popup,{"is-open":_ctx.isCalendarOpen,anchor:_ctx.calendarInputs,inline:_ctx.alwaysInline?"always":void 0,"set-focus":false,onOpen:_ctx.onOpenPopup,onClose:_ctx.onClosePopup},{default:withCtx(()=>[createElementVNode("div",{ref:"popup",class:normalizeClass(_ctx.popupClass)},[createVNode(_component_f_calendar,{modelValue:_ctx.calendarMonth,"onUpdate:modelValue":_cache[3]||(_cache[3]=$event=>_ctx.calendarMonth=$event),"tab-date":_ctx.calendarValue,"min-date":_ctx.minDate,"max-date":_ctx.maxDate,onClick:_ctx.onSelectCalendarDay,onKeyup:withKeys(withModifiers(_ctx.onKeyupEsc,["stop"]),["esc","native"])},{default:withCtx(({date,isFocused})=>[createVNode(_component_f_calendar_day,{day:date,enabled:_ctx.isDateEnabled(date),focused:isFocused,highlight:_ctx.highlightDay(date),selected:_ctx.isDaySelected(date)},null,8,["day","enabled","focused","highlight","selected"])]),_:1/* STABLE */},8,["modelValue","tab-date","min-date","max-date","onClick","onKeyup"]),createTextVNode(),createElementVNode("div",_hoisted_4$g,[createElementVNode("button",{class:"button button--discrete button--discrete--black datepicker-field__close__button",type:"button",onClick:_cache[4]||(_cache[4]=(...args)=>_ctx.onClickCloseCalendarButton&&_ctx.onClickCloseCalendarButton(...args)),onKeyup:_cache[5]||(_cache[5]=withKeys(withModifiers((...args)=>_ctx.onKeyupEsc&&_ctx.onKeyupEsc(...args),["stop"]),["esc"]))},[createElementVNode("span",null,toDisplayString(_ctx.$t("fkui.datepicker-field.close","Stäng")),1/* TEXT */),createTextVNode(),createVNode(_component_f_icon,{"aria-hidden":"true",class:"button__icon",name:"close"})],32/* NEED_HYDRATION */)])],2/* CLASS */)]),_:1/* STABLE */},8,["is-open","anchor","inline","onOpen","onClose"])],512/* NEED_PATCH */);}const FDatepickerField=/* @__PURE__ */_export_sfc(_sfc_main$x,[["render",_sfc_render$x]]);const _sfc_main$w=defineComponent({name:"FExpand",data(){return{height:0,initialStyle:{overflow:"hidden",transition:"height 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96)"},hiddenStyle:{height:"auto",position:"absolute",visibility:"hidden"},visibleStyle:{width:"",position:"",visibility:"",height:"0px"},openedStyle:{height:"auto"}};},methods:{enter(element){const htmlElement=getHTMLElementFromVueRef(element);Object.assign(htmlElement.style,this.initialStyle);Object.assign(htmlElement.style,this.hiddenStyle);htmlElement.style.width=getComputedStyle(element).width;const height=getComputedStyle(element).height;Object.assign(htmlElement.style,this.visibleStyle);getComputedStyle(element).height;setTimeout(()=>{this.height=parseInt(height,10);htmlElement.style.height=height;});},afterEnter(element){const htmlElement=getHTMLElementFromVueRef(element);Object.assign(htmlElement.style,this.openedStyle);},leave(element){const htmlElement=getHTMLElementFromVueRef(element);const height=getComputedStyle(element).height;htmlElement.style.height=height;getComputedStyle(element).height;setTimeout(()=>{Object.assign(htmlElement.style,this.visibleStyle);});}}});function _sfc_render$w(_ctx,_cache,$props,$setup,$data,$options){return openBlock(),createBlock(Transition,{onEnter:_ctx.enter,onAfterEnter:_ctx.afterEnter,onLeave:_ctx.leave},{default:withCtx(()=>[renderSlot(_ctx.$slots,"default",{height:_ctx.height})]),_:3/* FORWARDED */},8,["onEnter","onAfterEnter","onLeave"]);}const FExpand=/* @__PURE__ */_export_sfc(_sfc_main$w,[["render",_sfc_render$w]]);const _sfc_main$v=defineComponent({name:"FExpandablePanel",components:{FIcon,FExpand},mixins:[TranslationMixin],inheritAttrs:false,props:{/**
|
|
500
504
|
* Toggle expanded/collapsed state
|
|
501
505
|
*/expanded:{type:Boolean,required:false,default:false},/**
|
|
502
506
|
* Element to render for the header element inside the expandable panel.
|
|
@@ -701,8 +705,20 @@ onItemFocus(event){if(event&&event.target){event.target.style.position="relative
|
|
|
701
705
|
* Target for skiplink.
|
|
702
706
|
*/href:{type:String,required:false,default:"main"}}});const _hoisted_1$b=["href"];function _sfc_render$c(_ctx,_cache,$props,$setup,$data,$options){return openBlock(),createElementBlock("a",{class:"iskiplink",href:_ctx.href},[renderSlot(_ctx.$slots,"default",{},()=>[createTextVNode(toDisplayString(_ctx.$t("fkui.skip-link.text","Gå direkt till innehåll")),1/* TEXT */)])],8,_hoisted_1$b);}const ISkipLink=/* @__PURE__ */_export_sfc(_sfc_main$c,[["render",_sfc_render$c]]);function getAltLogoText(hasRouterLink,routerLinkLabel,t){const srStdLogoAltText=t("fkui.page-header.logo.alt-text","Försäkringskassan");const srStdRouterLinkLabel=t("fkui.page-header.router.link.label","gå till startsidan");if(hasRouterLink&&routerLinkLabel!==""){return`${srStdLogoAltText} ${routerLinkLabel}`;}else if(hasRouterLink){return`${srStdLogoAltText}, ${srStdRouterLinkLabel}`;}else{return srStdLogoAltText;}}const _sfc_main$b=defineComponent({name:"FPageHeader",components:{ISkipLink},mixins:[TranslationMixin],inheritAttrs:true,props:{/** Setting the logo sizes small, large or responsive. */logoSize:{type:String,default:"responsive",required:false,validator(value){return["small","large","responsive"].includes(value);}},/**
|
|
703
707
|
* Render skiplink.
|
|
704
|
-
|
|
708
|
+
*
|
|
709
|
+
* When set to a non-empty string thethe skiplink feature is enabled.
|
|
710
|
+
* The string is the id of the element to move focus to.
|
|
711
|
+
*
|
|
712
|
+
* When set to `true` the deprecated `skipLinkHref` prop is used to
|
|
713
|
+
* set the element id to move focus to.
|
|
714
|
+
*
|
|
715
|
+
* When set to `false` or empty string the skiplink feature is disabled.
|
|
716
|
+
*
|
|
717
|
+
* Using a boolean is deprecated. Leave unset or a non-empty string.
|
|
718
|
+
*/skipLink:{type:[String,Boolean],required:false,default:""},/**
|
|
705
719
|
* Target for skiplink.
|
|
720
|
+
*
|
|
721
|
+
* @deprecated Use `skipLink` prop with a non-empty string instead.
|
|
706
722
|
*/skipLinkHref:{type:String,required:false,default:"#applicationlayout-main-content"},/**
|
|
707
723
|
* HTML element type for header.
|
|
708
724
|
*/headerTag:{default:"span",required:false,validator(value){return["span","h1"].includes(value);}},/**
|
|
@@ -713,7 +729,7 @@ onItemFocus(event){if(event&&event.target){event.target.style.position="relative
|
|
|
713
729
|
* (Behaviour from using both name and path in combination is undefined.)
|
|
714
730
|
*/routerLinkName:{type:String,required:false,default:""},/**
|
|
715
731
|
* Label to override the router-link label when router-link is present.
|
|
716
|
-
*/routerLinkLabel:{type:String,required:false,default:""}},computed:{logoClass(){return`page-header__logo--${this.logoSize}`;},hasRouterLink(){return Boolean(this.routerLinkName||this.routerLinkPath);},routerLinkTo(){const{routerLinkName,routerLinkPath}=this;if(routerLinkName){return{name:routerLinkName};}if(routerLinkPath){return{path:routerLinkPath};}return null;},altLogoText(){return getAltLogoText(this.hasRouterLink,this.routerLinkLabel,this.$t);}}});const _hoisted_1$a={class:"page-header__root"};const _hoisted_2$7={key:0};const _hoisted_3$6={ref:"header",class:"page-header"};const _hoisted_4$4={class:"page-header__logo"};const _hoisted_5$4=["aria-label"];const _hoisted_6$4=["aria-label"];const _hoisted_7$3={class:"page-header__right"};const _hoisted_8$3={class:"page-header__right-slot"};function _sfc_render$b(_ctx,_cache,$props,$setup,$data,$options){const _component_i_skip_link=resolveComponent("i-skip-link");const _component_router_link=resolveComponent("router-link");return openBlock(),createElementBlock("div",_hoisted_1$a,[_ctx.
|
|
732
|
+
*/routerLinkLabel:{type:String,required:false,default:""}},computed:{logoClass(){return`page-header__logo--${this.logoSize}`;},hasRouterLink(){return Boolean(this.routerLinkName||this.routerLinkPath);},routerLinkTo(){const{routerLinkName,routerLinkPath}=this;if(routerLinkName){return{name:routerLinkName};}if(routerLinkPath){return{path:routerLinkPath};}return null;},skipLinkAnchor(){const{skipLink,skipLinkHref}=this;if(skipLink===false||skipLink===""){return null;}else if(skipLink===true){return skipLinkHref;}else{return`#${skipLink}`;}},altLogoText(){return getAltLogoText(this.hasRouterLink,this.routerLinkLabel,this.$t);}}});const _hoisted_1$a={class:"page-header__root"};const _hoisted_2$7={key:0};const _hoisted_3$6={ref:"header",class:"page-header"};const _hoisted_4$4={class:"page-header__logo"};const _hoisted_5$4=["aria-label"];const _hoisted_6$4=["aria-label"];const _hoisted_7$3={class:"page-header__right"};const _hoisted_8$3={class:"page-header__right-slot"};function _sfc_render$b(_ctx,_cache,$props,$setup,$data,$options){const _component_i_skip_link=resolveComponent("i-skip-link");const _component_router_link=resolveComponent("router-link");return openBlock(),createElementBlock("div",_hoisted_1$a,[_ctx.skipLinkAnchor?(openBlock(),createElementBlock("nav",_hoisted_2$7,[createVNode(_component_i_skip_link,{href:_ctx.skipLinkAnchor},{default:withCtx(()=>[renderSlot(_ctx.$slots,"skip-link-text")]),_:3/* FORWARDED */},8,["href"])])):createCommentVNode("v-if",true),createTextVNode(),createElementVNode("div",_hoisted_3$6,[createElementVNode("div",_hoisted_4$4,[renderSlot(_ctx.$slots,"logo",{},()=>[_ctx.routerLinkTo?(openBlock(),createBlock(_component_router_link,{key:0,to:_ctx.routerLinkTo},{default:withCtx(()=>[createElementVNode("span",{class:normalizeClass(_ctx.logoClass),"aria-label":_ctx.altLogoText,role:"img"},null,10,_hoisted_5$4)]),_:1/* STABLE */},8,["to"])):(openBlock(),createElementBlock("span",{key:1,class:normalizeClass(_ctx.logoClass),"aria-label":_ctx.altLogoText,role:"img"},null,10,_hoisted_6$4))])]),createTextVNode(),(openBlock(),createBlock(resolveDynamicComponent(_ctx.headerTag),{class:"page-header__app-name"},{default:withCtx(()=>[renderSlot(_ctx.$slots,"default")]),_:3/* FORWARDED */})),createTextVNode(),createElementVNode("div",_hoisted_7$3,[createElementVNode("div",_hoisted_8$3,[renderSlot(_ctx.$slots,"right")])])],512/* NEED_PATCH */)]);}const FPageHeader=/* @__PURE__ */_export_sfc(_sfc_main$b,[["render",_sfc_render$b]]);const MIN_VALUE=0;const MAX_VALUE=100;function clamp(val){return Math.round(Math.min(Math.max(val||0,MIN_VALUE),MAX_VALUE));}const _sfc_main$a=defineComponent({name:"FProgressbar",props:{/**
|
|
717
733
|
* Sets the progress. Higher value indicates further progress. Value must be in range 0-100.
|
|
718
734
|
*/value:{type:Number,required:true,validator(value){return value>=MIN_VALUE&&value<=MAX_VALUE;}},/**
|
|
719
735
|
* Text that the screenreader will read, the actual value will be replaced with %VALUE% e.g You have uploaded %VALUE% percent
|
|
@@ -731,7 +747,7 @@ onItemFocus(event){if(event&&event.target){event.target.style.position="relative
|
|
|
731
747
|
/* it should contain a default value of undefined and proptype should
|
|
732
748
|
/* include undefined (see comment on line above) */modelValue:{type:anyType,required:false},/**
|
|
733
749
|
* The value for the input.
|
|
734
|
-
*/value:{type:anyType,required:true}},emits:["change","update:modelValue"],setup(){
|
|
750
|
+
*/value:{type:anyType,required:true}},emits:["change","update:modelValue"],setup(){const{sharedName,showDetails,getFieldsetLabelText}=useFieldset();return{sharedName,showDetails,getFieldsetLabelText};},data(){return{height:0,initialStyle:{overflow:"hidden",transition:"height 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96)"},hiddenStyle:{height:"auto",position:"absolute",visibility:"hidden"},visibleStyle:{width:"",position:"",visibility:"",height:"0px"},openedStyle:{height:"auto"}};},computed:{attrs(){var _this$sharedName;return{...this.$attrs,value:this.value,checked:this.value===this.modelValue,name:(_this$sharedName=this.sharedName)!==null&&_this$sharedName!==void 0?_this$sharedName:this.$attrs.name,onChange:event=>{if(event.target instanceof HTMLInputElement){this.$emit("update:modelValue",this.value);this.$emit("change",this.value);}},onInput:event=>{event.target.focus();}};},disabledClass(){return this.disabled?"disabled":"";}},methods:{async onValidity({detail}){if(detail.target!==this.$el.querySelector("input")){return;}await this.$nextTick();let errorMessage="";if(hasSlot(this,"default")){const labelText=this.getFieldsetLabelText();if(labelText){errorMessage=`${labelText} ${renderSlotText(this.$slots.default)}`;}else{errorMessage=`${renderSlotText(this.$slots.default)}`;}}const element=this.$el.querySelector(`#${detail.elementId}`);if(element){dispatchComponentValidityEvent(element,{...detail,errorMessage,focusElementId:detail.elementId});}},enter(element){const htmlElement=getHTMLElementFromVueRef(element);const computedStyle=getComputedStyle(element);Object.assign(htmlElement.style,this.initialStyle);Object.assign(htmlElement.style,this.hiddenStyle);htmlElement.style.width=computedStyle.width;const height=computedStyle.height;Object.assign(htmlElement.style,this.visibleStyle);getComputedStyle(element).height;setTimeout(()=>{this.height=parseInt(height,10);htmlElement.style.height=height;});},afterEnter(element){const htmlElement=getHTMLElementFromVueRef(element);Object.assign(htmlElement.style,this.openedStyle);},leave(element){const htmlElement=getHTMLElementFromVueRef(element);const height=getComputedStyle(element).height;htmlElement.style.height=height;getComputedStyle(element).height;setTimeout(()=>{Object.assign(htmlElement.style,this.visibleStyle);});}}});const _hoisted_1$8=["id","disabled"];const _hoisted_2$5=["for"];const _hoisted_3$4={key:0,class:"radio-button__details"};const _hoisted_4$3=/* @__PURE__ */createElementVNode("br",null,null,-1/* HOISTED */);const _hoisted_5$3={key:0,class:"radio-button__details"};const _hoisted_6$3=/* @__PURE__ */createElementVNode("br",null,null,-1/* HOISTED */);function _sfc_render$9(_ctx,_cache,$props,$setup,$data,$options){return openBlock(),createElementBlock("div",{class:normalizeClass(["radio-button",_ctx.disabledClass]),onValidity:_cache[0]||(_cache[0]=(...args)=>_ctx.onValidity&&_ctx.onValidity(...args))},[createElementVNode("input",mergeProps({id:_ctx.id,type:"radio",class:"radio-button__input",disabled:_ctx.disabled},_ctx.attrs),null,16,_hoisted_1$8),createTextVNode(),createElementVNode("label",{class:normalizeClass(_ctx.$slots.details?"radio-button__label radio-button__width":"radio-button__label"),for:_ctx.id},[renderSlot(_ctx.$slots,"default"),createTextVNode(),_ctx.$slots.details?(openBlock(),createElementBlock(Fragment,{key:0},[_ctx.showDetails==="always"?(openBlock(),createElementBlock("span",_hoisted_3$4,[_hoisted_4$3,createTextVNode(),renderSlot(_ctx.$slots,"details")])):createCommentVNode("v-if",true),createTextVNode(),_ctx.showDetails==="when-selected"?(openBlock(),createBlock(Transition,{key:1,onEnter:_ctx.enter,onAfterEnter:_ctx.afterEnter,onLeave:_ctx.leave},{default:withCtx(()=>[_ctx.value===_ctx.modelValue?(openBlock(),createElementBlock("span",_hoisted_5$3,[_hoisted_6$3,createTextVNode(),renderSlot(_ctx.$slots,"details",{height:_ctx.height})])):createCommentVNode("v-if",true)]),_:3/* FORWARDED */},8,["onEnter","onAfterEnter","onLeave"])):createCommentVNode("v-if",true)],64/* STABLE_FRAGMENT */)):createCommentVNode("v-if",true)],10,_hoisted_2$5)],34/* CLASS, NEED_HYDRATION */);}const FRadioField=/* @__PURE__ */_export_sfc(_sfc_main$9,[["render",_sfc_render$9]]);const _sfc_main$8=defineComponent({name:"FRadioGroup",components:{FFieldset},inheritAttrs:false,props:{/**
|
|
735
751
|
* The id for the fieldset id attribute.
|
|
736
752
|
* If the prop is not set the id will be generated.
|
|
737
753
|
*/id:{type:String,required:false,default:()=>ElementIdService.generateElementId()},/**
|
|
@@ -893,4 +909,4 @@ this.modelValue.length>=this.maxlength-this.softLimit;},charactersLeftWarningInt
|
|
|
893
909
|
* @model
|
|
894
910
|
*/modelValue:{type:Object,required:true},/**
|
|
895
911
|
* Dialogue tree
|
|
896
|
-
*/dialogueTree:{type:Object,required:true}},emits:["change","update:modelValue"],data(){return{currentStep:this.dialogueTree,steps:[]};},computed:{userData(){if(isDialogueTreeEndQuestion(this.currentStep)){return this.currentStep.userData;}return void 0;},options(){if(!isDialogueTreeEndQuestion(this.currentStep)){return this.currentStep.options;}return[];}},created(){this.currentStep=this.dialogueTree;if(isDialogueTreeEndQuestion(this.currentStep)){this.emitChange(true);}else{this.emitChange(false);}},methods:{async onClickedOption(option,index){this.steps.push(index);this.currentStep=option.question;if(isDialogueTreeEndQuestion(option.question)){this.emitChange(true);await this.$nextTick();focusFirst(this.$el);}else{this.emitChange(false);await this.$nextTick();const firstElement=getHTMLElementsFromVueRef(this.$refs["dialogueButton-0"])[0];if(firstElement){focus$1(firstElement);}}},emitChange(lastStep){const emit={label:this.currentStep.label,lastStep,steps:this.steps};this.$emit("update:modelValue",emit);this.$emit("change",emit);}}});const _hoisted_1={class:"dialogue-tree"};const _hoisted_2={key:0,class:"dialogue-tree__list"};const _hoisted_3=["onClick"];function _sfc_render(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");return openBlock(),createElementBlock("div",_hoisted_1,[_ctx.options.length>0?(openBlock(),createElementBlock("ul",_hoisted_2,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.options,(option,index)=>{return openBlock(),createElementBlock("li",{key:option.label,class:"dialogue-tree__list-item"},[createElementVNode("button",{ref_for:true,ref:`dialogueButton-${index}`,type:"button",onClick:$event=>_ctx.onClickedOption(option,index)},[createElementVNode("span",null,toDisplayString(option.label),1/* TEXT */),createTextVNode(),createVNode(_component_f_icon,{name:"arrow-right"})],8,_hoisted_3)]);}),128/* KEYED_FRAGMENT */))])):renderSlot(_ctx.$slots,"default",normalizeProps(mergeProps({key:1},{userData:_ctx.userData})))]);}const FDialogueTree=/* @__PURE__ */_export_sfc(_sfc_main,[["render",_sfc_render]]);export{ActivateItemInjected,ErrorData,ErrorPlugin,ErrorViewData,EventBus,FBadge,_sfc_main$I as FBankAccountNumberTextField,_sfc_main$H as FBankgiroTextField,FCalendar,FCalendarDay,FCard,FCheckboxField,FCheckboxGroup,FCheckboxField as FCheckboxGroupField,_sfc_main$G as FClearingnumberTextField,FConfirmModal,FContextMenu,FCrudButton,FCrudDataset,_sfc_main$K as FCurrencyTextField,FDataTable,FDatepickerField,FDialogueTree,FEmailTextField,FErrorHandlingApp,FErrorList,FExpand,FExpandablePanel,FExpandableParagraph,FFieldset,FFileItem,FFileSelector,FForm,FFormModal,FValidationFormAction as FFormModalAction,FFormStep,FFormStepButton,FIcon,FInteractiveTable,FKUIConfigButtonOrder,FLabel,FLayoutApplicationTemplate,FLayoutLeftPanel,FLayoutRightPanel,FLayoutRightPanelService,FList,FLoader,FMessageBox,FModal,FNavigationMenu,_sfc_main$F as FNumericTextField,FOffline,_sfc_main$A as FOrganisationsnummerTextField,FOutputField,FPageHeader,_sfc_main$B as FPercentTextField,_sfc_main$E as FPersonnummerTextField,FPhoneTextField,_sfc_main$D as FPlusgiroTextField,_sfc_main$C as FPostalCodeTextField,FProgressbar,FRadioField,FRadioGroup,FRadioField as FRadioGroupField,FSearchTextField,FSelectField,FSortFilterDataset,FSortFilterDatasetInjected,FStaticField,FTableColumn,FTextField,FTextareaField,FTooltip,FValidationForm,FValidationFormAction,FValidationGroup,FWizard,FWizardStep,FValidationFormAction as FWizardStepAction,FormErrorList,FormStep,IAnimateExpand,ICalendarMonth,ICalendarMonthGrid,ICalendarNavbar,IFlex,IFlexItem,IMenu,IPopup,IPopupError,IPopupMenu,ISkipLink,FValidationForm as IValidationForm,MenuAction,ModalReason,TableScroll,TestPlugin,TranslationMixin,TranslationPlugin,UNHANDLED_ERROR_EVENT,ValidationPlugin,actionFromKeyboardEvent,cleanUpElements,config,confirmModal,createFFormProvideOptions,dispatchComponentUnmountEvent,dispatchComponentValidityEvent,emptyTableRow,findElementFromVueRef,findHTMLElementFromVueRef,findParentByName,focus,formModal,getDayEndOffset,getDayStartOffset,getElementFromVueRef,getElementsFromVueRef,getHTMLElementFromVueRef,getHTMLElementsFromVueRef,getInputElement,getParentByName,getRef,getSortedHTMLElementsFromVueRef,getTextFromScopedSlot,handleKeyboardFocusNavigation,hasParentByName,hasSlot,includeItem,isContextMenuSeparatorItem,isContextMenuTextItem,isDialogueTreeEndQuestion,isFormStepReference,itemEquals,mountComponent,openModal,refIsElement,refIsElementArray,refIsHTMLElementArray,refIsVue,refIsVueArray,renderSlotText,setIsOpen,setRef,setRunningContext,sortComponentsWithErrorsOnDOMOrder,tableScrollClasses,
|
|
912
|
+
*/dialogueTree:{type:Object,required:true}},emits:["change","update:modelValue"],data(){return{currentStep:this.dialogueTree,steps:[]};},computed:{userData(){if(isDialogueTreeEndQuestion(this.currentStep)){return this.currentStep.userData;}return void 0;},options(){if(!isDialogueTreeEndQuestion(this.currentStep)){return this.currentStep.options;}return[];}},created(){this.currentStep=this.dialogueTree;if(isDialogueTreeEndQuestion(this.currentStep)){this.emitChange(true);}else{this.emitChange(false);}},methods:{async onClickedOption(option,index){this.steps.push(index);this.currentStep=option.question;if(isDialogueTreeEndQuestion(option.question)){this.emitChange(true);await this.$nextTick();focusFirst(this.$el);}else{this.emitChange(false);await this.$nextTick();const firstElement=getHTMLElementsFromVueRef(this.$refs["dialogueButton-0"])[0];if(firstElement){focus$1(firstElement);}}},emitChange(lastStep){const emit={label:this.currentStep.label,lastStep,steps:this.steps};this.$emit("update:modelValue",emit);this.$emit("change",emit);}}});const _hoisted_1={class:"dialogue-tree"};const _hoisted_2={key:0,class:"dialogue-tree__list"};const _hoisted_3=["onClick"];function _sfc_render(_ctx,_cache,$props,$setup,$data,$options){const _component_f_icon=resolveComponent("f-icon");return openBlock(),createElementBlock("div",_hoisted_1,[_ctx.options.length>0?(openBlock(),createElementBlock("ul",_hoisted_2,[(openBlock(true),createElementBlock(Fragment,null,renderList(_ctx.options,(option,index)=>{return openBlock(),createElementBlock("li",{key:option.label,class:"dialogue-tree__list-item"},[createElementVNode("button",{ref_for:true,ref:`dialogueButton-${index}`,type:"button",onClick:$event=>_ctx.onClickedOption(option,index)},[createElementVNode("span",null,toDisplayString(option.label),1/* TEXT */),createTextVNode(),createVNode(_component_f_icon,{name:"arrow-right"})],8,_hoisted_3)]);}),128/* KEYED_FRAGMENT */))])):renderSlot(_ctx.$slots,"default",normalizeProps(mergeProps({key:1},{userData:_ctx.userData})))]);}const FDialogueTree=/* @__PURE__ */_export_sfc(_sfc_main,[["render",_sfc_render]]);export{ActivateItemInjected,ErrorData,ErrorPlugin,ErrorViewData,EventBus,FBadge,_sfc_main$I as FBankAccountNumberTextField,_sfc_main$H as FBankgiroTextField,FCalendar,FCalendarDay,FCard,FCheckboxField,FCheckboxGroup,FCheckboxField as FCheckboxGroupField,_sfc_main$G as FClearingnumberTextField,FConfirmModal,FContextMenu,FCrudButton,FCrudDataset,_sfc_main$K as FCurrencyTextField,FDataTable,FDatepickerField,FDialogueTree,FEmailTextField,FErrorHandlingApp,FErrorList,FExpand,FExpandablePanel,FExpandableParagraph,FFieldset,FFileItem,FFileSelector,FForm,FFormModal,FValidationFormAction as FFormModalAction,FFormStep,FFormStepButton,FIcon,FInteractiveTable,FKUIConfigButtonOrder,FLabel,FLayoutApplicationTemplate,FLayoutLeftPanel,FLayoutRightPanel,FLayoutRightPanelService,FList,FLoader,FMessageBox,FModal,FNavigationMenu,_sfc_main$F as FNumericTextField,FOffline,_sfc_main$A as FOrganisationsnummerTextField,FOutputField,FPageHeader,_sfc_main$B as FPercentTextField,_sfc_main$E as FPersonnummerTextField,FPhoneTextField,_sfc_main$D as FPlusgiroTextField,_sfc_main$C as FPostalCodeTextField,FProgressbar,FRadioField,FRadioGroup,FRadioField as FRadioGroupField,FSearchTextField,FSelectField,FSortFilterDataset,FSortFilterDatasetInjected,FStaticField,FTableColumn,FTableColumnSize,FTableColumnSort,FTableColumnType,FTextField,FTextareaField,FTooltip,FValidationForm,FValidationFormAction,FValidationGroup,FWizard,FWizardStep,FValidationFormAction as FWizardStepAction,FormErrorList,FormStep,IAnimateExpand,ICalendarMonth,ICalendarMonthGrid,ICalendarNavbar,IFlex,IFlexItem,IMenu,IPopup,IPopupError,IPopupMenu,ISkipLink,FValidationForm as IValidationForm,MenuAction,ModalReason,Operation,Placement,TableScroll,TestPlugin,TranslationMixin,TranslationPlugin,UNHANDLED_ERROR_EVENT,ValidationPlugin,actionFromKeyboardEvent,cleanUpElements,config,confirmModal,createFFormProvideOptions,dispatchComponentUnmountEvent,dispatchComponentValidityEvent,emptyTableRow,findElementFromVueRef,findHTMLElementFromVueRef,findParentByName,focus,formModal,getDayEndOffset,getDayStartOffset,getElementFromVueRef,getElementsFromVueRef,getHTMLElementFromVueRef,getHTMLElementsFromVueRef,getInputElement,getParentByName,getRef,getSortedHTMLElementsFromVueRef,getTextFromScopedSlot,handleKeyboardFocusNavigation,hasParentByName,hasSlot,includeItem,isContextMenuSeparatorItem,isContextMenuTextItem,isDialogueTreeEndQuestion,isFormStepReference,itemEquals,mountComponent,openModal,refIsElement,refIsElementArray,refIsHTMLElementArray,refIsVue,refIsVueArray,renderSlotText,setIsOpen,setRef,setRunningContext,sortComponentsWithErrorsOnDOMOrder,tableScrollClasses,useTranslate};
|