pleroma/priv/static/static/js/vertical_tab_switcher.CgkOofcV.js
2026-10-22 11:23:51 +04:00

2 lines
No EOL
18 KiB
JavaScript

import{E as e,I as t,L as n,M as r,R as i,U as a,W as o,X as s,_ as c,d as l,f as u,g as d,i as f,p,q as m,t as h,u as g,z as _}from"./_plugin-vue_export-helper.By3-ojQa.js";import{a as v}from"./modal.BLgTTi-o.js";import{i as y}from"./vuex.esm-bundler.CWMfctgB.js";import{t as b}from"./lodash.daI9UflD.js";import{A as x,O as S,d as C,er as w}from"./oauth.C4JLKGAu.js";import{En as T,V as E,kn as D}from"./free-solid-svg-icons.vn_kySUQ.js";import{t as O}from"./popover.94nM-RDc.js";import{t as ee}from"./checkbox.BfKZDdOO.js";import{t as k}from"./select.BU31Em0g.js";import{G as A,h as j}from"./main.CPF6dYCY.js";var M=b();D.add(T);var te={components:{Popover:O},props:[`changed`]},ne={key:0,class:`DraftButtons`},re={class:`modified-tooltip`},N={class:`modified-tooltip`},P={class:`modified-tooltip`};function F(e,t,n,o,c,f){let m=i(`Popover`);return e.$parent.isDirty||e.$parent.canHardReset?(r(),p(`span`,ne,[e.$parent.isDirty?(r(),l(m,{key:0,trigger:`hover`,"normal-button":``,"trigger-attrs":{"aria-label":e.$t(`settings.commit_value_tooltip`)},onClick:e.$parent.commitDraft},{trigger:a(()=>[d(s(e.$t(`settings.commit_value`)),1)]),content:a(()=>[g(`div`,re,s(e.$t(`settings.commit_value_tooltip`)),1)]),_:1},8,[`trigger-attrs`,`onClick`])):u(``,!0),e.$parent.isDirty?(r(),l(m,{key:1,trigger:`hover`,"normal-button":``,"trigger-attrs":{"aria-label":e.$t(`settings.reset_value_tooltip`)},onClick:e.$parent.reset},{trigger:a(()=>[d(s(e.$t(`settings.reset_value`)),1)]),content:a(()=>[g(`div`,N,s(e.$t(`settings.reset_value_tooltip`)),1)]),_:1},8,[`trigger-attrs`,`onClick`])):u(``,!0),e.$parent.canHardReset?(r(),l(m,{key:2,trigger:`hover`,"normal-button":``,"trigger-attrs":{"aria-label":e.$t(`settings.hard_reset_value_tooltip`)},onClick:e.$parent.hardReset},{trigger:a(()=>[d(s(e.$t(`settings.hard_reset_value`)),1)]),content:a(()=>[g(`div`,P,s(e.$t(`settings.hard_reset_value_tooltip`)),1)]),_:1},8,[`trigger-attrs`,`onClick`])):u(``,!0)])):u(``,!0)}var I=h(te,[[`render`,F]]);D.add(E);var L={components:{Popover:O},props:[`isLocal`]},R={key:0,class:`LocalSettingIndicator`},z={class:`profilesetting-tooltip`};function B(e,t,n,o,l,d){let f=i(`FAIcon`),m=i(`Popover`);return n.isLocal?(r(),p(`span`,R,[c(m,{trigger:`hover`},{trigger:a(()=>[c(f,{icon:`desktop`,"aria-label":e.$t(`settings.setting_local_side`)},null,8,[`aria-label`])]),content:a(()=>[g(`div`,z,s(e.$t(`settings.setting_local_side`)),1)]),_:1})])):u(``,!0)}var V=h(L,[[`render`,B]]);D.add(T);var H={components:{Popover:O},props:{changed:Boolean,messageKey:{type:String,default:`settings.setting_changed`}}},U={key:0,class:`ModifiedIndicator`},W={class:`modified-tooltip`};function G(e,t,n,o,l,d){let f=i(`FAIcon`),m=i(`Popover`);return n.changed?(r(),p(`span`,U,[c(m,{trigger:`hover`,"trigger-attrs":{"aria-label":e.$t(`settings.setting_changed`)}},{trigger:a(()=>[c(f,{icon:`wrench`})]),content:a(()=>[g(`div`,W,s(e.$t(n.messageKey)),1)]),_:1},8,[`trigger-attrs`])])):u(``,!0)}var K=h(H,[[`render`,G]]),q={components:{ModifiedIndicator:K,DraftButtons:I,LocalSettingIndicator:V},props:{modelValue:{type:String,default:null},description:{type:String,default:null},path:{type:[String,Array],required:!1},showDescription:{type:Boolean,required:!1},descriptionPathOverride:{type:[String,Array],required:!1},suggestions:{type:[String,Array],required:!1},subgroup:{type:String,required:!1},disabled:{type:Boolean,default:!1},local:{type:Boolean,default:!1},parentPath:{type:[String,Array]},parentInvert:{type:Boolean,default:!1},expert:{type:[Number,String],default:0},source:{type:String,default:void 0},hideDraftButtons:{required:!1,type:Boolean},hideLabel:{type:Boolean},hideDescription:{type:Boolean},swapDescriptionAndLabel:{type:Boolean},backendDescriptionPath:{type:[String,Array]},overrideBackendDescription:{type:Boolean},overrideBackendDescriptionLabel:{type:[Boolean,String]},draftMode:{type:Boolean,default:void 0},timedApplyMode:{type:Boolean,default:!1}},inject:{defaultSource:{default:`default`},defaultDraftMode:{default:!1}},data(){return{localDraft:null}},emits:[`update:modelValue`],created(){this.realDraftMode&&(this.realSource!==`admin`||this.path==null)&&(this.draft=(0,M.cloneDeep)(this.state))},computed:{draft:{get(){return this.realSource===`admin`||this.path==null?(0,M.get)(A().draft,this.canonPath):this.localDraft},set(e){this.realSource===`admin`||this.path==null?A().updateAdminDraft({path:this.canonPath,value:e}):this.localDraft=e}},state(){if(this.path==null)return this.modelValue;let e=(0,M.get)(this.configSource,this.canonPath);return e===void 0?this.defaultState:e},visibleState(){return this.realDraftMode?this.draft:this.state},realSource(){return this.source||this.defaultSource},realDraftMode(){return this.draftMode===void 0?this.defaultDraftMode:this.draftMode},backendDescription(){return(0,M.get)(A().descriptions,this.descriptionPath)},backendDescriptionLabel(){return this.realSource===`admin`?this.overrideBackendDescriptionLabel!==``&&typeof this.overrideBackendDescriptionLabel==`string`?this.overrideBackendDescriptionLabel:!this.backendDescription||this.overrideBackendDescriptionLabel?this.$t([`admin_dash`,`temp_overrides`,...this.canonPath.map(e=>e.replace(/\./g,`_DOT_`)),`label`].join(`.`)):this.swapDescriptionAndLabel?this.backendDescription?.description:this.backendDescription?.label:``},backendDescriptionDescription(){return this.description?this.description:this.realSource===`admin`?this.hideDescription?null:!this.backendDescription||this.overrideBackendDescription?this.$t([`admin_dash`,`temp_overrides`,...this.canonPath.map(e=>e.replace(/\./g,`_DOT_`)),`description`].join(`.`)):this.swapDescriptionAndLabel?this.backendDescription?.label:this.backendDescription?.description:``},backendDescriptionSuggestions(){return this.backendDescription?.suggestions||this.suggestions},shouldBeDisabled(){if(this.path==null)return this.disabled;let e=null;return this.parentPath!==void 0&&this.realSource===`admin`&&(e=this.realDraftMode?(0,M.get)(A().draft,this.parentPath):(0,M.get)(this.configSource,this.parentPath)),this.disabled||(e===null?!1:this.parentInvert?e:!e)},configSource(){switch(this.realSource){case`profile`:return this.$store.state.profileConfig;case`admin`:return A().config;default:return S().mergedConfig}},configSink(){if(this.path==null)return()=>{};switch(this.realSource){case`profile`:return(e,t)=>this.$store.dispatch(`setProfileOption`,{name:e,value:t});case`admin`:return(e,t)=>A().pushAdminSetting({path:e,value:t});default:return(e,t)=>{let n=`${e}`;if(!this.timedApplyMode)this.local?w().set({path:n,value:t}):x().setSimplePrefAndSave({path:n,value:t});else{if(C().temporaryChangesTimeoutId!==null){console.error(`Can't track more than one temporary change`);return}let r=(0,M.get)(this.configSource,e);this.local?w().setTemporarily({path:n,value:t}):x().setPreference({path:n,value:t}),C().setTemporaryChanges({confirm:()=>{this.local?w().set({path:n,value:t}):x().pushSyncConfig(),C().clearTemporaryChanges()},revert:()=>{this.local?w().unsetTemporarily({path:n,value:t}):x().setPreference({path:n,value:r}),C().clearTemporaryChanges()}})}}}},defaultState(){switch(this.realSource){case`profile`:return{};default:return(0,M.get)(S().mergedConfigDefault,this.path)}},isProfileSetting(){return this.realSource===`profile`},isLocalSetting(){return this.local},isChanged(){if(this.path==null)return!1;switch(this.realSource){case`profile`:case`admin`:return!1;default:return this.state!==this.defaultState}},canonPath(){return this.path==null?null:Array.isArray(this.path)?this.path:this.path.split(`.`)},descriptionPath(){if(this.path==null)return null;if(this.descriptionPathOverride)return this.descriptionPathOverride;let e=Array.isArray(this.path)?this.path:this.path.split(`.`);return this.subgroup?[...e.slice(0,e.length-1),`:subgroup,`+this.subgroup,...e.slice(e.length-1)]:e},isDirty(){return this.path==null||this.realSource===`admin`&&this.canonPath.length>3?!1:this.realDraftMode&&!(0,M.isEqual)(this.draft,this.state)},canHardReset(){return this.realSource===`admin`&&A().modifiedPaths?.has(this.canonPath.join(` -> `))},matchesExpertLevel(){return(this.expert||0)<=(S().mergedConfig.expertLevel||0)}},methods:{getValue(e){return e.target.value},update(e){this.realDraftMode?this.draft=this.getValue(e):(this.$emit(`update:modelValue`,this.getValue(e)),this.configSink(this.path,this.getValue(e)))},commitDraft(){this.realDraftMode&&(this.$emit(`update:modelValue`,this.draft),this.configSink(this.path,this.draft))},reset(){this.realDraftMode?this.draft=(0,M.cloneDeep)(this.state):(0,M.set)(S().mergedConfig,this.path,(0,M.cloneDeep)(this.defaultState))},hardReset(){switch(this.realSource){case`admin`:return this.$store.dispatch(`resetAdminSetting`,{path:this.path}).then(()=>{this.draft=this.state});default:console.warn(`Hard reset not implemented yet!`)}}}},J={...q,props:{...q.props,indeterminateState:[String,Object]},components:{...q.components,Checkbox:ee},computed:{...q.computed,isIndeterminate(){return this.visibleState===this.indeterminateState}},methods:{...q.methods,getValue(e){return this.indeterminateState&&!e&&this.visibleState===!0?this.indeterminateState:e}}},Y={key:0,class:`BooleanSetting setting-item`};function X(e,t,o,l,h,_){let v=i(`ModifiedIndicator`),y=i(`LocalSettingIndicator`),b=i(`Checkbox`),x=i(`DraftButtons`);return e.matchesExpertLevel?(r(),p(`label`,Y,[c(b,{class:`setting-control setting-label`,"model-value":e.visibleState,disabled:e.shouldBeDisabled,indeterminate:e.isIndeterminate,"onUpdate:modelValue":e.update},{default:a(()=>[g(`span`,{class:m([`label`,{faint:e.shouldBeDisabled}])},[c(v,{changed:e.isChanged,onclick:e.reset},null,8,[`changed`,`onclick`]),c(y,{"is-local":e.isLocalSetting},null,8,[`is-local`]),t[0]||=d(` `+s(` `)+` `,-1),e.backendDescriptionLabel?(r(),p(f,{key:0},[d(s(e.backendDescriptionLabel),1)],64)):e.source===`admin`?(r(),p(f,{key:1},[d(` MISSING LABEL FOR `+s(e.path),1)],64)):n(e.$slots,`default`,{key:2})],2)]),_:3},8,[`model-value`,`disabled`,`indeterminate`,`onUpdate:modelValue`]),e.backendDescriptionDescription||e.showDescription?(r(),p(`p`,{key:0,class:m([`setting-description`,{faint:e.shouldBeDisabled}])},[n(e.$slots,`description`,{},()=>[d(s(e.backendDescriptionDescription+` `),1)])],2)):u(``,!0),c(x)])):u(``,!0)}var ie=h(J,[[`render`,X]]),ae={...q,components:{...q.components,Select:k},props:{...q.props,overrideOptions:{type:Boolean,required:!1},options:{type:Array,required:!1},optionLabelMap:{type:Object,required:!1,default:{}}},computed:{...q.computed,realOptions(){return this.overrideOptions?this.options:this.realSource===`admin`?!this.backendDescriptionSuggestions?.length||this.backendDescriptionSuggestions?.length===0?this.options:this.backendDescriptionSuggestions.map(e=>({key:e,value:e,label:this.optionLabelMap[e]||e})):this.options}},methods:{...q.methods,getValue(e){return e}}},oe={class:`setting-label`},se=[`value`],ce={key:0,class:`setting-description`};function le(e,o,l,h,_,v){let y=i(`ModifiedIndicator`),b=i(`LocalSettingIndicator`),x=i(`Select`),S=i(`DraftButtons`);return e.matchesExpertLevel?(r(),p(`label`,{key:0,class:m([`ChoiceSetting setting-item`,{faint:e.shouldBeDisabled}])},[g(`span`,oe,[c(y,{changed:e.isChanged,onclick:e.reset},null,8,[`changed`,`onclick`]),c(b,{"is-local":e.isLocalSetting},null,8,[`is-local`]),o[0]||=d(` `+s(` `)+` `,-1),e.backendDescriptionLabel?(r(),p(f,{key:0},[d(s(e.backendDescriptionLabel),1)],64)):n(e.$slots,`default`,{key:1})]),c(x,{class:`setting-control`,"model-value":e.realDraftMode?e.draft:e.state,disabled:e.shouldBeDisabled,"onUpdate:modelValue":e.update},{default:a(()=>[(r(!0),p(f,null,t(e.realOptions,t=>(r(),p(`option`,{key:t.key,value:t.value},s(t.label)+` `+s(t.value===e.defaultState?e.$t(`settings.instance_default_simple`):``),9,se))),128))]),_:1},8,[`model-value`,`disabled`,`onUpdate:modelValue`]),c(S),e.backendDescriptionDescription?(r(),p(`p`,ce,s(e.backendDescriptionDescription+` `),1)):u(``,!0)],2)):u(``,!0)}var ue=h(ae,[[`render`,le]]),de={...q,props:{...q.props,min:{type:Number,required:!1,default:1},max:{type:Number,required:!1,default:1},step:{type:Number,required:!1,default:1},truncate:{type:Number,required:!1,default:1}},methods:{...q.methods,getValue(e){return!this.truncate===1?parseInt(e.target.value):this.truncate>1?Math.trunc(e.target.value/this.truncate)*this.truncate:parseFloat(e.target.value)}}},fe={key:0,class:`NumberSetting setting-item`},pe=[`for`],me=[`id`,`step`,`disabled`,`placeholder`,`min`,`value`];function he(e,t,a,o,h,_){let v=i(`ModifiedIndicator`),y=i(`LocalSettingIndicator`),b=i(`DraftButtons`);return e.matchesExpertLevel?(r(),p(`span`,fe,[e.hideLabel?u(``,!0):(r(),p(`label`,{key:0,for:e.path,class:m([`setting-label`,{faint:e.shouldBeDisabled}])},[c(v,{changed:e.isChanged,onclick:e.reset},null,8,[`changed`,`onclick`]),c(y,{"is-local":e.isLocalSetting},null,8,[`is-local`]),t[1]||=d(` `+s(` `)+` `,-1),e.hideDraftButtons?u(``,!0):(r(),l(b,{key:0})),e.backendDescriptionLabel?(r(),p(f,{key:1},[d(s(e.backendDescriptionLabel+` `),1)],64)):e.source===`admin`?(r(),p(f,{key:2},[d(` MISSING LABEL FOR `+s(e.path),1)],64)):n(e.$slots,`default`,{key:3})],10,pe)),t[2]||=d(` `+s(` `)+` `,-1),g(`input`,{id:e.path,class:`input number-input setting-control`,type:`number`,step:e.step||1,disabled:e.shouldBeDisabled,placeholder:e.backendDescriptionSuggestions,min:e.min||0,value:e.realDraftMode?e.draft:e.state,onChange:t[0]||=(...t)=>e.update&&e.update(...t)},null,40,me),e.backendDescriptionDescription?(r(),p(`p`,{key:1,class:m([`setting-description`,{faint:e.shouldBeDisabled}])},s(e.backendDescriptionDescription+` `),3)):u(``,!0)])):u(``,!0)}var Z=h(de,[[`render`,he]]),ge={components:{NumberSetting:Z}};function _e(t,o,s,c,u,d){let f=i(`NumberSetting`);return r(),l(f,e(t.$attrs,{truncate:1}),{default:a(()=>[n(t.$slots,`default`)]),_:3},16)}var ve=h(ge,[[`render`,_e]]),ye=()=>({...v(S,[`mergedConfig`]),...v(S,{expertLevel:e=>e.mergedConfig.expertLevel}),...v(A,{adminConfig:e=>e.config,adminDraft:e=>e.draft}),...y({user:e=>e.users.currentUser})}),be={...q},xe={key:0,class:`StringSetting setting-item`},Q=[`for`],Se=[`id`,`disabled`,`placeholder`,`value`];function Ce(e,t,a,o,h,_){let v=i(`ModifiedIndicator`),y=i(`LocalSettingIndicator`),b=i(`DraftButtons`);return e.matchesExpertLevel?(r(),p(`span`,xe,[e.hideLabel?u(``,!0):(r(),p(`label`,{key:0,for:e.path,class:m([`setting-label`,{faint:e.shouldBeDisabled}])},[c(v,{changed:e.isChanged,onclick:e.reset},null,8,[`changed`,`onclick`]),c(y,{"is-local":e.isLocalSetting},null,8,[`is-local`]),t[1]||=d(` `+s(` `)+` `,-1),e.backendDescriptionLabel?(r(),p(f,{key:0},[d(s(e.backendDescriptionLabel+` `),1)],64)):e.source===`admin`?(r(),p(f,{key:1},[d(` MISSING LABEL FOR `+s(e.path),1)],64)):n(e.$slots,`default`,{key:2})],10,Q)),g(`input`,{id:e.path,class:m([`setting-control input string-input`,{disabled:e.shouldBeDisabled}]),disabled:e.shouldBeDisabled,placeholder:e.backendDescriptionSuggestions,value:e.realDraftMode?e.draft:e.state,onChange:t[0]||=(...t)=>e.update&&e.update(...t)},null,42,Se),t[2]||=d(` `+s(` `)+` `,-1),e.hideDraftButtons?u(``,!0):(r(),l(b,{key:1})),e.backendDescriptionDescription?(r(),p(`p`,{key:2,class:m([`setting-description`,{faint:e.shouldBeDisabled}])},s(e.backendDescriptionDescription+` `),3)):u(``,!0)])):u(``,!0)}var we=h(be,[[`render`,Ce]]),$=e=>e.findIndex(e=>e.props),Te={name:`VerticalTabSwitcher`,props:{renderOnlyFocused:{required:!1,type:Boolean,default:!1},onSwitch:{required:!1,type:Function,default:void 0},activeTab:{required:!1,type:String,default:void 0},bodyScrollLock:{required:!1,type:Boolean,default:!1}},data(){return{active:$(this.slots()),resizeHandler:null,navSide:`tabs`}},computed:{activeIndex(){return this.activeTab?this.slots().findIndex(e=>e&&e.props&&this.activeTab===e.props.key):this.active},isActive(){return e=>this.$slots.default().findIndex(t=>t.props&&t.props[`data-tab-name`]===e)===this.activeIndex},...v(C,{mobileLayout:e=>e.layoutType===`mobile`})},beforeUpdate(){this.slots()[this.active].props||(this.active=$(this.slots()))},methods:{clickTab(e){return t=>{t.preventDefault(),this.setTab(e)}},setTab(e){typeof this.onSwitch==`function`&&this.onSwitch.call(null,this.slots()[e].key),this.active=e,this.changeNavSide(`content`)},changeNavSide(e){this.navSide!==e&&(this.navSide=e)},slots(){return this.$slots.default()[0].type===f?this.$slots.default()[0].children:this.$slots.default()}},render(){let e=this.slots().map((e,t)=>{let n=e.props;if(!n)return;let r=[`vertical-tab`,`menu-item`];return this.activeIndex===t&&C().layoutType!==`mobile`&&r.push(`-active`),c(`button`,{disabled:n.disabled,onClick:this.clickTab(t),class:r.join(` `),type:`button`,role:`tab`,title:n.label},[n.icon?c(j,{class:`tab-icon`,size:`1x`,"fixed-width":!0,icon:n.icon},null):``,c(`span`,{class:`text`},[n.label])])}),t=this.slots().map((e,t)=>{let n=e.props;if(!n)return;let r=this.activeIndex===t,i=e.props[`delay-render`];i&&r&&(e.props[`delay-render`]=!1,i=!1);let a=!i&&(!this.renderOnlyFocused||r)?e:``,o=c(`h2`,{class:[`tab-content-label`]},[c(`button`,{type:`button`,onClick:()=>this.changeNavSide(`tabs`),title:this.$t(`nav.back`),class:`button-unstyled`},[c(j,{size:`lg`,class:`back-button-icon`,icon:`chevron-left`},null)]),n.label]),s=[`tab-content-wrapper`,r?`-active`:`-hidden`],l=[`tab-slot-wrapper`,r?`-active`:`-hidden`],u=[`tab-content`];return(n[`full-width`]||n[`full-width`]!=null)&&(u.push(`-full-width`),s.push(`-full-width`),l.push(`-full-width`)),(n[`full-height`]||n[`full-width`]!=null)&&(u.push(`-full-height`),s.push(`-full-height`),l.push(`-full-height`)),c(`div`,{class:s},[c(`div`,{class:`tab-mobile-header`},[o]),c(`div`,{class:l},[c(`div`,{class:u},[a])])])}),n=[`vertical-tab-switcher`];return C().layoutType===`mobile`&&n.push(`-mobile`),this.navSide===`tabs`?n.push(`-nav-tabs`):n.push(`-nav-contents`),c(`div`,{ref:`root`,class:n.join(` `)},[c(`div`,{class:`tabs`,role:`tablist`,ref:`nav`},[e]),o(c(`div`,{role:`tabpanel`,class:`contents`,ref:`contents`},[t]),[[_(`body-scroll-lock`),this.bodyScrollLock]])])}};export{Z as a,q as c,ve as i,K as l,we as n,ue as o,ye as r,ie as s,Te as t,V as u};
//# sourceMappingURL=vertical_tab_switcher.CgkOofcV.js.map