UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 2.17 kB
import{l as e}from"./ErrorBlock-CuwX01Wv.js";import{D as t,H as n,U as r,c as i,j as a,w as o,x as s}from"./web-BWdORzMO.js";import{d as c}from"./Form-Cbz3dIAq.js";var l={changeLocale:`${/Mac|iPod|iPhone|iPad/.test(navigator.userAgent)?`⌘`:`Ctrl`}+Shift+.`,newEntry:`Shift+T`},u=()=>!!document.querySelector(`[role="dialog"][data-expanded]`),d=e=>{let t=t=>{e.changeLocale?.permission()&&(t.metaKey||t.ctrlKey)&&t.shiftKey&&t.code===`Period`&&(t.preventDefault(),t.stopPropagation(),e.changeLocale.callback()),e.newEntry?.permission()&&t.shiftKey&&t.key.toLowerCase()===`t`&&(t.preventDefault(),e.newEntry.callback())};r(()=>{window.addEventListener(`keydown`,t)}),n(()=>{window.removeEventListener(`keydown`,t)})},f=n=>{let r=a(()=>e.get.contentLocale),f=a(()=>e.get.locales),p=a(()=>f().length>1),m=a(()=>f().map(e=>({value:e.code,label:`${e.name?`${e.name} (${e.code})`:e.code}`}))||[]);return d({changeLocale:{permission:()=>{if(!p())return!1;let e=u(),t=n.value===void 0,r=n.value!==void 0;return!(t&&e||r&&!e)},callback:()=>{if(!p())return;let t=n.value===void 0?r():n.value,i=f(),a=i[(i.findIndex(e=>e.code===t)+1)%i.length].code;n.value!==void 0&&n.setValue?n.setValue(a):e.get.setContentLocale(a)}}}),t(o,{get children(){return[t(s,{get when(){return i(()=>n.value===void 0)()&&p()},get children(){return t(c,{id:`content-locale`,get value(){return r()},onChange:t=>{t?e.get.setContentLocale(t.toString()):e.get.setContentLocale(void 0)},name:`content-locale`,get options(){return m()},noMargin:!0,noClear:!0,get hasError(){return n.hasError},small:!0,get shortcut(){return i(()=>!!n.showShortcut)()?l.changeLocale:void 0},get shortcutDisplay(){return n.showShortcut?`compact`:void 0}})}}),t(s,{get when(){return i(()=>n.value!==void 0)()&&p()},get children(){return t(c,{id:`content-locale`,get value(){return n.value},onChange:e=>{e?n.setValue?.(e.toString()):n.setValue?.(void 0)},name:`content-locale`,get options(){return m()},noMargin:!0,noClear:!0,get hasError(){return n.hasError},small:!0,get shortcut(){return i(()=>!!n.showShortcut)()?l.changeLocale:void 0},get shortcutDisplay(){return n.showShortcut?`compact`:void 0}})}})]}})};export{d as n,f as t};