efficient-easel 26.4.0 → 26.5.0

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/README.md CHANGED
@@ -1438,6 +1438,8 @@ A host with a window system of its own does not use the dialog: it calls
1438
1438
  `usePageCopyForm({ source, taken, duplicate, onDuplicated })` and draws
1439
1439
  `<DuplicatePageFields form={form} host={host} />` inside its own window, with
1440
1440
  `form.submit` on its own button (efficient-admin-portal's `PopupForm`).
1441
+ `form.slug` is the handle as typed (it may end on the word-break "-");
1442
+ `form.finalSlug` is the handle that is checked, shown in the URL hint and sent.
1441
1443
  Its words are `pageCopy` in `efficient-easel/strings`.
1442
1444
 
1443
1445
  ## The engine's words — `efficient-easel/strings`
@@ -60,6 +60,8 @@ type PageCopyFormInput<Copy> = {
60
60
  declare function usePageCopyForm<Copy>({ source, taken, duplicate, onDuplicated }: PageCopyFormInput<Copy>): {
61
61
  title: string;
62
62
  slug: string;
63
+ /** The handle that is checked and sent: `slug` without the typing hyphen. */
64
+ finalSlug: string;
63
65
  clash: boolean;
64
66
  canSubmit: boolean;
65
67
  busy: boolean;
@@ -1,5 +1,5 @@
1
- import{DEFAULT_PAGE_COPY_WORDS as t}from"../chunk-CEC5XLN4.js";export{DEFAULT_PAGE_COPY_WORDS}from"../chunk-CEC5XLN4.js";import{useWords as e}from"../chunk-MFIRYGHW.js";import{slugify as n}from"efficient-shell/format";import{useState as o,useId as i}from"react";import{FormField as l,Input as r,Dialog as a,Button as s}from"efficient-shell/ui";import{jsxs as u,jsx as c}from"react/jsx-runtime";var h=255,m=/* @__PURE__ */new Set(["normal","dynamic"]);function f(t,e){return(!t.kind||m.has(t.kind))&&!e?.(t.slug)}function g(t){const e=n(t);return e&&/[^a-z0-9]$/.test(t.toLowerCase())?`${e}-`:e}function d(t,e){const n=new Set(e);if(!n.has(t))return t;let o=2;for(;n.has(`${t}-${o}`);)o+=1;return`${t}-${o}`}function p(t,e){return d(n(t)||"page",e)}function C(t,e){return new Set(e).has(t)}function y(t,e){return{title:`${t.title||t.slug} copy`,slug:p(`${t.slug}-copy`,e)}}function b({source:t,taken:e,duplicate:i,onDuplicated:l}){const[r]=o(()=>y(t,e)),[a,s]=o(r.title),[u,c]=o(r.slug),[h,m]=o(!1),[f,d]=o(!1),[p,b]=o(!1),[v,k]=o(!1),x=C(u,e),S=Boolean(a.trim()&&u&&!x&&!p);return{title:a,slug:u,clash:x,canSubmit:S,busy:p,failed:v,touched:f,titleMax:255,onTitleChange:t=>{d(!0),s(t),h||c(n(t))},onSlugChange:t=>{d(!0),m(!0),c(g(t))},submit:async()=>{if(S){b(!0),k(!1);try{l(await i({title:a.trim(),slug:u}))}catch{k(!0)}finally{b(!1)}}}}}function v({form:n,host:o}){const a=e("pageCopy",t),s=i(),h=i(),m=t=>{t.nativeEvent.isComposing||229===t.keyCode||"Enter"===t.key&&n.submit()};/* @__PURE__ */
2
- return u("div",{className:"flex flex-col gap-4",children:[
3
- /* @__PURE__ */c(l,{label:a.titleLabel,htmlFor:s,error:n.failed?a.failed:void 0,hint:a.hint,children:/* @__PURE__ */c(r,{id:s,autoFocus:!0,value:n.title,maxLength:n.titleMax,onChange:t=>n.onTitleChange(t.target.value),onKeyDown:m})}),
4
- /* @__PURE__ */c(l,{label:a.slugLabel,htmlFor:h,error:n.clash?a.clash:void 0,hint:a.address({host:o,slug:n.slug}),children:/* @__PURE__ */c(r,{id:h,value:n.slug,invalid:n.clash,onChange:t=>n.onSlugChange(t.target.value),onKeyDown:m})})]})}function k({host:n,onClose:o,...i}){const l=e("pageCopy",t),r=b(i),u=i.source.title||i.source.slug;/* @__PURE__ */
5
- return c(a,{open:!0,dirty:r.touched,onClose:()=>{r.busy||o()},title:l.title({name:u}),size:"sm",footer:/* @__PURE__ */c(s,{disabled:!r.canSubmit,loading:r.busy,onClick:()=>{r.submit()},children:l.submit}),children:/* @__PURE__ */c(v,{form:r,host:n})})}export{h as DUPLICATE_TITLE_MAX,k as DuplicatePageDialog,v as DuplicatePageFields,f as canDuplicatePage,y as copySuggestion,d as firstFreeSlug,g as slugWhileTyping,p as uniqueSlug,C as urlHandleTaken,b as usePageCopyForm};
1
+ import{DEFAULT_PAGE_COPY_WORDS as t}from"../chunk-CEC5XLN4.js";export{DEFAULT_PAGE_COPY_WORDS}from"../chunk-CEC5XLN4.js";import{useWords as e}from"../chunk-MFIRYGHW.js";import{slugify as n}from"efficient-shell/format";import{useState as o,useId as i}from"react";import{FormField as l,Input as r,Dialog as a,Button as u}from"efficient-shell/ui";import{jsxs as s,jsx as c}from"react/jsx-runtime";var h=255,f=/* @__PURE__ */new Set(["normal","dynamic"]);function m(t,e){return(!t.kind||f.has(t.kind))&&!e?.(t.slug)}function g(t){const e=n(t);return e&&/[^a-z0-9]$/.test(t.toLowerCase())?`${e}-`:e}function d(t,e){const n=new Set(e);if(!n.has(t))return t;let o=2;for(;n.has(`${t}-${o}`);)o+=1;return`${t}-${o}`}function p(t,e){return d(n(t)||"page",e)}function C(t,e){return new Set(e).has(t)}function y(t,e){return{title:`${t.title||t.slug} copy`,slug:p(`${t.slug}-copy`,e)}}function b({source:t,taken:e,duplicate:i,onDuplicated:l}){const[r]=o(()=>y(t,e)),[a,u]=o(r.title),[s,c]=o(r.slug),[h,f]=o(!1),[m,d]=o(!1),[p,b]=o(!1),[v,S]=o(!1),k=n(s),x=C(k,e),$=Boolean(a.trim()&&k&&!x&&!p);return{title:a,slug:s,finalSlug:k,clash:x,canSubmit:$,busy:p,failed:v,touched:m,titleMax:255,onTitleChange:t=>{d(!0),u(t),h||c(n(t))},onSlugChange:t=>{d(!0),f(!0),c(g(t))},submit:async()=>{if($){b(!0),S(!1);try{l(await i({title:a.trim(),slug:k}))}catch{S(!0)}finally{b(!1)}}}}}function v({form:n,host:o}){const a=e("pageCopy",t),u=i(),h=i(),f=t=>{t.nativeEvent.isComposing||229===t.keyCode||"Enter"===t.key&&n.submit()};/* @__PURE__ */
2
+ return s("div",{className:"flex flex-col gap-4",children:[
3
+ /* @__PURE__ */c(l,{label:a.titleLabel,htmlFor:u,error:n.failed?a.failed:void 0,hint:a.hint,children:/* @__PURE__ */c(r,{id:u,autoFocus:!0,value:n.title,maxLength:n.titleMax,onChange:t=>n.onTitleChange(t.target.value),onKeyDown:f})}),
4
+ /* @__PURE__ */c(l,{label:a.slugLabel,htmlFor:h,error:n.clash?a.clash:void 0,hint:a.address({host:o,slug:n.finalSlug}),children:/* @__PURE__ */c(r,{id:h,value:n.slug,invalid:n.clash,onChange:t=>n.onSlugChange(t.target.value),onKeyDown:f})})]})}function S({host:n,onClose:o,...i}){const l=e("pageCopy",t),r=b(i),s=i.source.title||i.source.slug;/* @__PURE__ */
5
+ return c(a,{open:!0,dirty:r.touched,onClose:()=>{r.busy||o()},title:l.title({name:s}),size:"sm",footer:/* @__PURE__ */c(u,{disabled:!r.canSubmit,loading:r.busy,onClick:()=>{r.submit()},children:l.submit}),children:/* @__PURE__ */c(v,{form:r,host:n})})}export{h as DUPLICATE_TITLE_MAX,S as DuplicatePageDialog,v as DuplicatePageFields,m as canDuplicatePage,y as copySuggestion,d as firstFreeSlug,g as slugWhileTyping,p as uniqueSlug,C as urlHandleTaken,b as usePageCopyForm};
@@ -1,2 +1,2 @@
1
- import{DEFAULT_TEXT_STYLES_WORDS as o}from"../chunk-OGH6CC3E.js";import{DEFAULT_SCREEN_WORDS as r,DEFAULT_IMAGE_ROW_WORDS as n}from"../chunk-Q3VAJMXS.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"../chunk-6WY6ZXJG.js";import{DEFAULT_CANVAS_WORDS as c}from"../chunk-TBY3DFKS.js";import{DEFAULT_TREE_WORDS as e}from"../chunk-K56YDHYQ.js";import{DEFAULT_COLOUR_ROW_WORDS as m,DEFAULT_PANEL_WORDS as i}from"../chunk-56ID6FKZ.js";import{DEFAULT_PAGE_COPY_WORDS as s}from"../chunk-CEC5XLN4.js";import{DEFAULT_NODE_MENU_WORDS as u}from"../chunk-WK3AFPXY.js";import{DEFAULT_SAVE_WORDS as f}from"../chunk-H6DDIBQ4.js";import{DEFAULT_CHROME_WORDS as p,DEFAULT_NOTICE_WORDS as l}from"../chunk-AJSDWWJW.js";import{DEFAULT_RAIL_WORDS as h}from"../chunk-2OAZYSWJ.js";import{DEFAULT_LOCK_WORDS as j}from"../chunk-RE4LP46F.js";import{DEFAULT_COPY_WORDS as a}from"../chunk-PMRN5Z3T.js";import{DEFAULT_FIELDS_WORDS as k}from"../chunk-JACEEVVF.js";import{stringsContext as y}from"../chunk-MFIRYGHW.js";import{DEFAULT_DRAG_WORDS as Y}from"../chunk-TQ5Y6S2X.js";import{useContext as C,useMemo as W}from"react";import{jsx as d}from"react/jsx-runtime";var g={notice:l,lock:j,save:f,chrome:p,rail:h,tree:e,panel:i,fields:k,colourRow:m,imageRow:n,drag:Y,menu:u,styleClipboard:t,copy:a,canvas:c,textStyles:o,screen:r,pageCopy:s},v=o=>"object"==typeof o&&null!==o;function D(o,r){const n={};for(const t of Object.keys(o)){const c=o[t],e=r[t];null==e?n[t]=c:v(c)?n[t]=v(e)?D(c,e):c:n[t]=typeof e==typeof c?e:c}return n}function F(o,r){return r?D(o,r):o}function J({value:o,locale:r,children:n}){const t=y(),c=C(t),e=c?.strings??g,m=r??c?.locale??"en",i=W(()=>({strings:F(e,o),locale:m}),[e,o,m]);/* @__PURE__ */
1
+ import{DEFAULT_TEXT_STYLES_WORDS as o}from"../chunk-OGH6CC3E.js";import{DEFAULT_SCREEN_WORDS as r,DEFAULT_IMAGE_ROW_WORDS as n}from"../chunk-Q3VAJMXS.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"../chunk-6WY6ZXJG.js";import{DEFAULT_CANVAS_WORDS as c}from"../chunk-TBY3DFKS.js";import{DEFAULT_TREE_WORDS as e}from"../chunk-K56YDHYQ.js";import{DEFAULT_COLOUR_ROW_WORDS as m,DEFAULT_PANEL_WORDS as i}from"../chunk-56ID6FKZ.js";import{DEFAULT_NODE_MENU_WORDS as s}from"../chunk-WK3AFPXY.js";import{DEFAULT_PAGE_COPY_WORDS as u}from"../chunk-CEC5XLN4.js";import{DEFAULT_SAVE_WORDS as f}from"../chunk-H6DDIBQ4.js";import{DEFAULT_CHROME_WORDS as p,DEFAULT_NOTICE_WORDS as l}from"../chunk-AJSDWWJW.js";import{DEFAULT_RAIL_WORDS as h}from"../chunk-2OAZYSWJ.js";import{DEFAULT_LOCK_WORDS as j}from"../chunk-RE4LP46F.js";import{DEFAULT_COPY_WORDS as a}from"../chunk-PMRN5Z3T.js";import{DEFAULT_FIELDS_WORDS as k}from"../chunk-JACEEVVF.js";import{stringsContext as y}from"../chunk-MFIRYGHW.js";import{DEFAULT_DRAG_WORDS as Y}from"../chunk-TQ5Y6S2X.js";import{useContext as C,useMemo as W}from"react";import{jsx as d}from"react/jsx-runtime";var g={notice:l,lock:j,save:f,chrome:p,rail:h,tree:e,panel:i,fields:k,colourRow:m,imageRow:n,drag:Y,menu:s,styleClipboard:t,copy:a,canvas:c,textStyles:o,screen:r,pageCopy:u},v=o=>"object"==typeof o&&null!==o;function D(o,r){const n={};for(const t of Object.keys(o)){const c=o[t],e=r[t];null==e?n[t]=c:v(c)?n[t]=v(e)?D(c,e):c:n[t]=typeof e==typeof c?e:c}return n}function F(o,r){return r?D(o,r):o}function J({value:o,locale:r,children:n}){const t=y(),c=C(t),e=c?.strings??g,m=r??c?.locale??"en",i=W(()=>({strings:F(e,o),locale:m}),[e,o,m]);/* @__PURE__ */
2
2
  return d(t.Provider,{value:i,children:n})}function S(){return C(y())?.strings??g}function A(){return C(y())?.locale??"en"}export{g as DEFAULT_EASEL_STRINGS,J as EaselStringsProvider,F as mergeEaselStrings,A as useEaselLocale,S as useEaselStrings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-easel",
3
- "version": "26.4.0",
3
+ "version": "26.5.0",
4
4
  "description": "Efficient Easel: the EFFICIENT editors' shared engine and chrome: the saved document as pure functions, the published renderer, and the editor frame, panels, Layers tree, text grammar and type-in-place box. Published as editor-shell up to 0.66.0 and as efficient-editor up to 0.95.0.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Efficient Pty Ltd",