carbon-react 158.45.0 → 158.46.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.
@@ -1 +1 @@
1
- import{jsxs as e,Fragment as t,jsx as o}from"react/jsx-runtime";import{useLexicalComposerContext as n}from"@lexical/react/LexicalComposerContext";import{mergeRegister as i}from"@lexical/utils";import{$getSelection as r,$isRangeSelection as l,$getRoot as a,$createTextNode as s,$createParagraphNode as d,$isParagraphNode as c}from"lexical";import{useRef as u,useState as m,useCallback as p,useEffect as b}from"react";import{StyledToolbarWrapper as f,StyledToolbar as h,CommandButtons as g}from"./toolbar.style.js";import v from"../../../../button/button.component.js";import x from"../../../../../hooks/__internal__/useLocale/useLocale.js";import y from"./buttons/bold.component.js";import k from"./buttons/hyperlink.component.js";import E from"./buttons/italic.component.js";import j from"./buttons/list.component.js";import B from"./buttons/save.component.js";import F from"./buttons/typography.component.js";import w from"./buttons/underline.component.js";import z from"./button-group/button-group.component.js";import{TEXT_EDITOR_ACTION_TYPES as C}from"../../__utils__/constants.js";import{Textbox as D}from"../../../../textbox/textbox.component.js";import{$createLinkNode as L}from"@lexical/link";import{Dialog as $}from"../../../../dialog/dialog.component.js";import{Form as A}from"../../../../form/form.component.js";import"../../../../form/required-fields-indicator/required-fields-indicator.component.js";const I=({contentEditorRef:I,namespace:_,hasHeader:S,onCancel:q,onSave:O,size:T="medium",toolbarControls:H=["typography","bold","italic","underline","unordered-list","ordered-list","link"]})=>{const[R]=n(),U=R.isEditable(),N=u(null),[K,G]=m(!1),[J,M]=m(!1),[P,Q]=m(!1),[V,W]=m(!1),[X,Y]=m(!1),[Z,ee]=m(-1),[te,oe]=m(""),[ne,ie]=m(""),re=x(),le=H.includes("typography"),ae=H.includes("bold")||H.includes("italic")||H.includes("underline"),se=H.includes("unordered-list")||H.includes("ordered-list"),de=H.includes("link"),ce=p((()=>{const e=r();l(e)&&(G(e.hasFormat(C.Bold)),M(e.hasFormat(C.Italic)),Q(e.hasFormat(C.Underline)))}),[]);b((()=>i(R.registerUpdateListener((({editorState:e})=>{e.read((()=>{R.isEditable()&&ce()}))})))),[ce,R]);const ue=()=>{oe(""),ie(""),W(!1)};if(!U)return null;const me=te.length&&ne.length;return e(f,{"data-role":`${_}-toolbar-wrapper`,hasHeader:S,id:`${_}-toolbar-wrapper`,size:T,children:[e(h,{role:"toolbar","aria-label":re.textEditor.toolbarAriaLabel(),"data-role":`${_}-toolbar`,id:`${_}-toolbar`,ref:N,onKeyDown:e=>{var t,o;if(0===H.length||!N.current)return;const n=Array.from(null===(t=N.current)||void 0===t?void 0:t.querySelectorAll("button.toolbar-button"));if(!n.length)return;const i=n.findIndex((e=>{var t;return e.id===(null===(t=document.activeElement)||void 0===t?void 0:t.id)}));let r=-1;switch(e.key){case"ArrowRight":e.preventDefault(),X||(r=i<n.length-1?i+1:0);break;case"ArrowLeft":e.preventDefault(),X||(r=i>0?i-1:n.length-1);break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=n.length-1;break;default:return}n.forEach(((e,t)=>{e.tabIndex=t===r?0:-1})),r>-1&&(null===(o=n[r])||void 0===o||o.focus())},tabIndex:-1,children:[e(t,{children:[le&&o(z,{name:"typography-formatting-buttons",namespace:_,showDivider:ae||se||de,children:o(F,{contentEditorRef:I,namespace:_,isFirstButton:!0,isOpen:X,setIsOpen:Y,focusedIndex:Z,setFocusedIndex:ee,size:T})}),ae&&e(z,{name:"text-formatting-buttons",namespace:_,showDivider:se||de,children:[H.includes("bold")&&o(y,{isActive:K,namespace:_,isFirstButton:!le,size:T}),H.includes("italic")&&o(E,{isActive:J,namespace:_,isFirstButton:!le&&!H.includes("bold"),size:T}),H.includes("underline")&&o(w,{isActive:P,namespace:_,isFirstButton:!le&&!H.includes("bold")&&!H.includes("italic"),size:T})]}),se&&o(z,{name:"list-formatting-buttons",namespace:_,showDivider:de,children:o(j,{namespace:_,olIsFirstButton:!le&&!ae&&!H.includes("unordered-list"),showOL:H.includes("ordered-list"),showUL:H.includes("unordered-list"),ulIsFirstButton:!le&&!ae,size:T})}),de&&o(z,{name:"hyperlink-formatting-buttons",namespace:_,showDivider:!1,children:o(k,{namespace:_,isFirstButton:!le&&!ae&&!se,setDialogOpen:W,size:T})})]}),o($,{open:V,onCancel:()=>{ue()},title:re.textEditor.hyperlink.dialogTitle(),"data-role":`${_}-hyperlink-dialog`,"aria-label":re.textEditor.hyperlink.dialogTitle(),size:"small",children:e(A,{leftSideButtons:o(v,{"data-role":`${_}-hyperlink-cancel-button`,onClick:()=>{ue()},children:re.textEditor.cancelButton()}),saveButton:o(v,{buttonType:"primary",type:"submit",disabled:!me,"data-role":`${_}-hyperlink-save-button`,children:re.textEditor.saveButton()}),onSubmit:e=>{e.preventDefault(),R.isEditable()&&(R.update((()=>{const e=a(),t=e.getChildrenSize(),o=r(),n=L(ne);if(n.append(s(te)),0===t){const t=d();t.append(n),e.append(t),t.selectEnd()}else if(l(o))o.insertNodes([n]);else{const t=e.getLastChild();c(t)&&t.append(n)}})),ue())},children:[o(D,{label:re.textEditor.hyperlink.textFieldLabel(),name:"text",required:!0,"data-role":`${_}-hyperlink-text-field`,value:te,onChange:e=>oe(e.target.value)}),o(D,{label:re.textEditor.hyperlink.linkFieldLabel(),name:"link",required:!0,"data-role":`${_}-hyperlink-link-field`,value:ne,onChange:e=>ie(e.target.value)})]})})]}),e(g,{"data-role":`${_}-command-buttons`,children:[q&&o(v,{buttonType:"tertiary","data-role":`${_}-cancel-button`,"aria-label":re.textEditor.cancelButtonAria(),onClick:()=>null==q?void 0:q(R),size:T,className:"command-button",children:re.textEditor.cancelButton()}),O&&o(B,{namespace:_,onSave:O,size:T})]})]})};export{I as default};
1
+ import{jsxs as e,Fragment as t,jsx as o}from"react/jsx-runtime";import{useLexicalComposerContext as r}from"@lexical/react/LexicalComposerContext";import{mergeRegister as n}from"@lexical/utils";import{$getSelection as i,$isRangeSelection as l,$getRoot as a,$createTextNode as s,$createParagraphNode as c,$isParagraphNode as d}from"lexical";import{useRef as p,useState as u,useCallback as m,useEffect as f}from"react";import{StyledToolbarWrapper as b,StyledToolbar as h,CommandButtons as y}from"./toolbar.style.js";import x from"../../../../button/button.component.js";import g from"../../../../../hooks/__internal__/useLocale/useLocale.js";import v from"./buttons/bold.component.js";import j from"./buttons/hyperlink.component.js";import k from"./buttons/italic.component.js";import O from"./buttons/list.component.js";import E from"./buttons/save.component.js";import w from"./buttons/typography.component.js";import F from"./buttons/underline.component.js";import D from"./button-group/button-group.component.js";import{TEXT_EDITOR_ACTION_TYPES as B}from"../../__utils__/constants.js";import{Textbox as z}from"../../../../textbox/textbox.component.js";import{$createLinkNode as P}from"@lexical/link";import{Dialog as C}from"../../../../dialog/dialog.component.js";import{Form as S}from"../../../../form/form.component.js";import"../../../../form/required-fields-indicator/required-fields-indicator.component.js";import{Box as L}from"../../../../box/box.component.js";import{Typography as $}from"../../../../typography/typography.component.js";function A(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function I(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),r.forEach((function(t){A(e,t,o[t])}))}return e}function _(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))})),e}const T=({contentEditorRef:A,namespace:T,hasHeader:W,onCancel:q,onSave:H,size:M="medium",toolbarControls:R=["typography","bold","italic","underline","unordered-list","ordered-list","link"]})=>{var U,K,N,G,J,Q;const[V]=r(),X=V.isEditable(),Y=p(null),[Z,ee]=u(!1),[te,oe]=u(!1),[re,ne]=u(!1),[ie,le]=u(!1),[ae,se]=u(!1),[ce,de]=u(-1),[pe,ue]=u(""),[me,fe]=u(""),[be,he]=u(!1),[ye,xe]=u(!1),ge=p(null),ve=p(null),je=g(),ke=R.includes("typography"),Oe=R.includes("bold")||R.includes("italic")||R.includes("underline"),Ee=R.includes("unordered-list")||R.includes("ordered-list"),we=R.includes("link"),Fe=m((()=>{const e=i();l(e)&&(ee(e.hasFormat(B.Bold)),oe(e.hasFormat(B.Italic)),ne(e.hasFormat(B.Underline)))}),[]);f((()=>n(V.registerUpdateListener((({editorState:e})=>{e.read((()=>{V.isEditable()&&Fe()}))})))),[Fe,V]),f((()=>{ie&&V.read((()=>{const e=i();if(l(e)){const t=e.getTextContent();ue(t)}}))}),[ie,V]);const De=()=>{ue(""),fe(""),he(!1),xe(!1),le(!1)};return X?e(b,{"data-role":`${T}-toolbar-wrapper`,hasHeader:W,id:`${T}-toolbar-wrapper`,size:M,children:[e(h,{role:"toolbar","aria-label":je.textEditor.toolbarAriaLabel(),"data-role":`${T}-toolbar`,id:`${T}-toolbar`,ref:Y,onKeyDown:e=>{var t,o;if(0===R.length||!Y.current)return;const r=Array.from(null===(t=Y.current)||void 0===t?void 0:t.querySelectorAll("button.toolbar-button"));if(!r.length)return;const n=r.findIndex((e=>{var t;return e.id===(null===(t=document.activeElement)||void 0===t?void 0:t.id)}));let i=-1;switch(e.key){case"ArrowRight":e.preventDefault(),ae||(i=n<r.length-1?n+1:0);break;case"ArrowLeft":e.preventDefault(),ae||(i=n>0?n-1:r.length-1);break;case"Home":e.preventDefault(),i=0;break;case"End":e.preventDefault(),i=r.length-1;break;default:return}r.forEach(((e,t)=>{e.tabIndex=t===i?0:-1})),i>-1&&(null===(o=r[i])||void 0===o||o.focus())},tabIndex:-1,children:[e(t,{children:[ke&&o(D,{name:"typography-formatting-buttons",namespace:T,showDivider:Oe||Ee||we,children:o(w,{contentEditorRef:A,namespace:T,isFirstButton:!0,isOpen:ae,setIsOpen:se,focusedIndex:ce,setFocusedIndex:de,size:M})}),Oe&&e(D,{name:"text-formatting-buttons",namespace:T,showDivider:Ee||we,children:[R.includes("bold")&&o(v,{isActive:Z,namespace:T,isFirstButton:!ke,size:M}),R.includes("italic")&&o(k,{isActive:te,namespace:T,isFirstButton:!ke&&!R.includes("bold"),size:M}),R.includes("underline")&&o(F,{isActive:re,namespace:T,isFirstButton:!ke&&!R.includes("bold")&&!R.includes("italic"),size:M})]}),Ee&&o(D,{name:"list-formatting-buttons",namespace:T,showDivider:we,children:o(O,{namespace:T,olIsFirstButton:!ke&&!Oe&&!R.includes("unordered-list"),showOL:R.includes("ordered-list"),showUL:R.includes("unordered-list"),ulIsFirstButton:!ke&&!Oe,size:M})}),we&&o(D,{name:"hyperlink-formatting-buttons",namespace:T,showDivider:!1,children:o(j,{namespace:T,isFirstButton:!ke&&!Oe&&!Ee,setDialogOpen:le,size:M})})]}),o(C,{open:ie,onCancel:()=>{De()},title:je.textEditor.hyperlink.dialogTitle(),"data-role":`${T}-hyperlink-dialog`,"aria-label":je.textEditor.hyperlink.dialogTitle(),size:"medium-small",children:o(S,{leftSideButtons:o(x,{"data-role":`${T}-hyperlink-cancel-button`,onClick:()=>{De()},children:je.textEditor.cancelButton()}),saveButton:o(x,{buttonType:"primary",type:"submit","data-role":`${T}-hyperlink-save-button`,children:je.textEditor.saveButton()}),onSubmit:e=>{e.preventDefault();const t=!pe.trim(),o=!me.trim();var r,n;(he(t),xe(o),t||o)?t?null===(r=ge.current)||void 0===r||r.focus():null===(n=ve.current)||void 0===n||n.focus():V.isEditable()&&(V.update((()=>{const e=a(),t=e.getChildrenSize(),o=i(),r=P(me);if(r.append(s(pe)),0===t){const t=c();t.append(r),e.append(t),t.selectEnd()}else if(l(o))o.insertNodes([r]);else{const t=e.getLastChild();d(t)&&t.append(r)}})),De())},children:e(L,{display:"flex",flexDirection:"column",gap:"16px",children:[e($,{fontSize:"14px",fontWeight:"500",lineHeight:"21px",children:[o($,{as:"span",color:"#FF0000",children:"*"})," ",null===(U=(K=je.textEditor.hyperlink).formKey)||void 0===U?void 0:U.call(K)]}),e(L,{display:"flex",gap:"24px",flexWrap:"wrap",children:[o(L,{flex:"1 1 200px",minWidth:"200px",maxWidth:"560px",children:o(z,_(I({label:je.textEditor.hyperlink.textFieldLabel(),name:"text",required:!0,validationMessagePositionTop:!1},be&&{error:null===(N=(G=je.textEditor.hyperlink).textFieldErrorMessage)||void 0===N?void 0:N.call(G)}),{"data-role":`${T}-hyperlink-text-field`,value:pe,ref:ge,onChange:e=>{ue(e.target.value),he(!1)}}))}),o(L,{flex:"1 1 200px",minWidth:"200px",maxWidth:"560px",children:o(z,_(I({label:je.textEditor.hyperlink.linkFieldLabel(),name:"link",required:!0,validationMessagePositionTop:!1},ye&&{error:null===(J=(Q=je.textEditor.hyperlink).linkFieldErrorMessage)||void 0===J?void 0:J.call(Q)}),{"data-role":`${T}-hyperlink-link-field`,value:me,ref:ve,onChange:e=>{fe(e.target.value),xe(!1)}}))})]})]})})})]}),e(y,{"data-role":`${T}-command-buttons`,children:[q&&o(x,{buttonType:"tertiary","data-role":`${T}-cancel-button`,"aria-label":je.textEditor.cancelButtonAria(),onClick:()=>null==q?void 0:q(V),size:M,className:"command-button",children:je.textEditor.cancelButton()}),H&&o(E,{namespace:T,onSave:H,size:M})]})]}):null};export{T as default};
@@ -1 +1 @@
1
- import o,{css as t}from"styled-components";import{margin as r}from"styled-system";const e=o.div.withConfig({displayName:"text-editor.style__StyledTextEditor",componentId:"sc-f35af111-0"})(["position:relative;box-sizing:border-box;",""],(({error:o})=>o&&t(["margin:-1px;"]))),i=o.div.withConfig({displayName:"text-editor.style__StyledTextEditorWrapper",componentId:"sc-f35af111-1"})(["margin-bottom:var(--fieldSpacing);"," min-width:288px;"],r),a=o.div.withConfig({displayName:"text-editor.style__StyledWrapper",componentId:"sc-f35af111-2"})(['position:relative;.textBold{font-weight:bold;}.textItalic{font-style:italic;}.textUnderline{text-decoration:underline;}a:not([data-component="link-preview"]){color:var(--colorsActionMajor500);cursor:pointer;&:hover{color:var(--colorsActionMajor600);}&:focus{outline:none;text-decoration:none;color:var(--colorsActionMajorYin090);background-color:var(--colorsSemanticFocus250);border-radius:var(--borderRadius025);box-shadow:0 var(--spacing050) 0 0 var(--colorsUtilityYin090);}}']),d=o.div.withConfig({displayName:"text-editor.style__StyledEditorToolbarWrapper",componentId:"sc-f35af111-3"})(["border-radius:var(--borderRadius100);",""],(({error:o})=>t(o?["border:1px solid var(--colorsUtilityMajor200);"]:["outline:1px solid var(--colorsUtilityMajor200);"]))),n=o.div.withConfig({displayName:"text-editor.style__StyledHeaderWrapper",componentId:"sc-f35af111-4"})(["padding:var(--spacing200);"]),l=o.div.withConfig({displayName:"text-editor.style__StyledFooterWrapper",componentId:"sc-f35af111-5"})(["border-top:1px solid var(--colorsUtilityMajor200);padding:",";"],(({size:o})=>{switch(o){case"large":return"var(--spacing200)";case"small":return"var(--spacing100)";default:return"var(--spacing150)"}}));export{d as StyledEditorToolbarWrapper,l as StyledFooterWrapper,n as StyledHeaderWrapper,e as StyledTextEditor,i as StyledTextEditorWrapper,a as StyledWrapper,e as default};
1
+ import o,{css as t}from"styled-components";import{margin as r}from"styled-system";const e=o.div.withConfig({displayName:"text-editor.style__StyledTextEditor",componentId:"sc-afa0eb4b-0"})(["position:relative;box-sizing:border-box;",""],(({error:o})=>o&&t(["margin:-1px;"]))),i=o.div.withConfig({displayName:"text-editor.style__StyledTextEditorWrapper",componentId:"sc-afa0eb4b-1"})(["margin-bottom:var(--fieldSpacing);"," min-width:288px;"],r),a=o.div.withConfig({displayName:"text-editor.style__StyledWrapper",componentId:"sc-afa0eb4b-2"})(['position:relative;.textBold{font-weight:bold !important;}.textItalic{font-style:italic;}.textUnderline{text-decoration:underline;}a:not([data-component="link-preview"]){color:var(--colorsActionMajor500);cursor:pointer;&:hover{color:var(--colorsActionMajor600);}&:focus{outline:none;text-decoration:none;color:var(--colorsActionMajorYin090);background-color:var(--colorsSemanticFocus250);border-radius:var(--borderRadius025);box-shadow:0 var(--spacing050) 0 0 var(--colorsUtilityYin090);}}']),d=o.div.withConfig({displayName:"text-editor.style__StyledEditorToolbarWrapper",componentId:"sc-afa0eb4b-3"})(["border-radius:var(--borderRadius100);",""],(({error:o})=>t(o?["border:1px solid var(--colorsUtilityMajor200);"]:["outline:1px solid var(--colorsUtilityMajor200);"]))),n=o.div.withConfig({displayName:"text-editor.style__StyledHeaderWrapper",componentId:"sc-afa0eb4b-4"})(["padding:var(--spacing200);"]),l=o.div.withConfig({displayName:"text-editor.style__StyledFooterWrapper",componentId:"sc-afa0eb4b-5"})(["border-top:1px solid var(--colorsUtilityMajor200);padding:",";"],(({size:o})=>{switch(o){case"large":return"var(--spacing200)";case"small":return"var(--spacing100)";default:return"var(--spacing150)"}}));export{d as StyledEditorToolbarWrapper,l as StyledFooterWrapper,n as StyledHeaderWrapper,e as StyledTextEditor,i as StyledTextEditorWrapper,a as StyledWrapper,e as default};
@@ -1 +1 @@
1
- import{enGB as e}from"date-fns/locale/en-GB";const a=e=>1===("string"==typeof e?parseInt(e):e),r={locale:()=>"en-GB",actions:{edit:()=>"Edit",delete:()=>"Delete"},actionPopover:{ariaLabel:()=>"actions"},advancedColorPicker:{ariaLabel:()=>"Change colour",currentColorDescriptionTerm:()=>"Current colour assigned: ",currentColorAssigned:e=>e},batchSelection:{selected:e=>`${e} selected`},breadcrumbs:{ariaLabel:()=>"breadcrumbs"},confirm:{no:()=>"No",yes:()=>"Yes"},characterCount:{tooManyCharacters:(e,a)=>1===e?`${a} character too many`:`${a} characters too many`,charactersLeft:(e,a)=>1===e?`${a} character left`:`${a} characters left`,visuallyHiddenHint:e=>`You can enter up to ${e} characters`},date:{dateFnsLocale:()=>e,ariaLabels:{previousMonthButton:()=>"Previous month",nextMonthButton:()=>"Next month"},dateFormatOverride:void 0},dialog:{ariaLabels:{close:()=>"Close"}},dismissibleBox:{ariaLabels:{close:()=>"Close"}},errors:{messages:{formSummary:(e,r,t)=>{const o=a(e)?"error":"errors",n=a(r)?"warning":"warnings",i=a(e)?"is":"are",s=a(r)?"is":"are";return e&&r&&"warning"===t?["and",`${r} ${n}`]:e?[`There ${i}`,`${e} ${o}`]:r?[`There ${s}`,`${r} ${n}`]:null}}},fileInput:{dragAndDrop:()=>"or drag and drop your file",selectFile:()=>"Select file",fileUploadStatus:()=>"File upload status",actions:{cancel:()=>"Cancel upload",clear:()=>"Clear",delete:()=>"Delete file"}},heading:{backLinkAriaLabel:()=>"Back"},link:{skipLinkLabel:()=>"Skip to main content"},loader:{loading:()=>"Loading..."},loaderSpinner:{loading:()=>"Loading..."},loaderStar:{loading:()=>"Loading..."},menuFullscreen:{ariaLabels:{closeButton:()=>"Close"}},message:{closeButtonAriaLabel:()=>"Close",error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",ai:()=>"AI Information",callout:()=>"Callout"},numeralDate:{validation:{day:(e,a)=>e&&a?`Day in ${e} should be a number within 1-${a}.`:"Day should be a number within a 1-31 range.",month:()=>"Month should be a number within a 1-12 range.",year:()=>"Year should be a number within a 1800-2200 range."},labels:{day:()=>"Day",month:()=>"Month",year:()=>"Year"}},pager:{show:()=>"Show",records:(e,r=!0)=>{const t=a(e)?"item":"items";return r?`${e} ${t}`:t},first:()=>"First",last:()=>"Last",next:()=>"Next",previous:()=>"Previous",pageX:()=>"Page",ofY:e=>`of ${e}`},password:{buttonLabelHide:()=>"Hide",buttonLabelShow:()=>"Show",ariaLabelHide:()=>"Hide password",ariaLabelShow:()=>"Show password",ariaLiveShownMessage:()=>"Your password has been shown. Focus on the password input to have it read to you, if it is safe to do so.",ariaLiveHiddenMessage:()=>"Your password is currently hidden."},pill:{remove:e=>`Remove ${e} pill`},progressTracker:{of:()=>"of"},pod:{undo:()=>"Undo"},tabs:{error:e=>`The ${e} tab contains errors`,info:e=>`The ${e} tab contains information`,warning:e=>`The ${e} tab contains warnings`,scrollLeftText:()=>"Scroll Tabs Left",scrollRightText:()=>"Scroll Tabs Right"},textEditor:{boldAria:()=>"Bold",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",characterCounter:e=>`${"number"==typeof e?e.toString():e} characters remaining`,characterLimit:e=>`You are ${e} character(s) over the character limit`,contentEditorAria:()=>"Rich text content editor",hyperlink:{buttonAria:()=>"Hyperlink",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",dialogTitle:()=>"Add link",linkFieldLabel:()=>"Link",saveButton:()=>"Save",saveButtonAria:()=>"Save",textFieldLabel:()=>"Text"},typography:{selectAria:()=>"Heading type",paragraph:()=>"Paragraph",title:()=>"Title",subtitle:()=>"Subtitle",sectionHeader:()=>"Section header",sectionSubheader:()=>"Section subheader"},italicAria:()=>"Italic",orderedListAria:()=>"Ordered list",saveButton:()=>"Save",saveButtonAria:()=>"Save",toolbarAriaLabel:()=>"Formatting",underlineAria:()=>"Underline",unorderedListAria:()=>"Unordered list",mentions:{listAriaLabel:()=>"List of mentionable people"}},search:{searchButtonText:()=>"Search"},select:{actionButtonText:()=>"Add New Item",placeholder:()=>"Please Select...",noResultsForTerm:e=>`No results for "${e}"`},sidebar:{ariaLabels:{close:()=>"Close"}},sort:{accessibleName:(e,a)=>`Sort all ${e||"contents"}${a?` in an ${a} order.`:" in an ascending or descending order."}`,ariaRoleDescription:()=>"Sortable column header"},splitButton:{ariaLabel:()=>"Show more"},stepFlow:{stepLabel:(e,a)=>`Step ${e} of ${a}`,screenReaderOnlyTitle:(e,a,r,t)=>`${t?`${t}.`:""} ${e}. Step ${a} of ${r}.`,closeIconAriaLabel:()=>"Close"},switch:{on:()=>"ON",off:()=>"OFF"},tileSelect:{deselect:()=>"Deselect"},time:{amText:()=>"AM",pmText:()=>"PM",hoursLabelText:()=>"Hrs.",minutesLabelText:()=>"Mins.",hoursAriaLabelText:()=>"Hours",minutesAriaLabelText:()=>"Minutes"},toast:{ariaLabels:{close:()=>"Close"},error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",notification:()=>"Notification"},verticalMenu:{ariaLabels:{responsiveMenuLauncher:()=>"Product menu launcher",responsiveMenuCloseButton:()=>"Close product menu",responsiveMenuAria:()=>"Product menu"}},verticalMenuFullScreen:{ariaLabels:{close:()=>"Close"}}};export{r as default};
1
+ import{enGB as e}from"date-fns/locale/en-GB";const a=e=>1===("string"==typeof e?parseInt(e):e),r={locale:()=>"en-GB",actions:{edit:()=>"Edit",delete:()=>"Delete"},actionPopover:{ariaLabel:()=>"actions"},advancedColorPicker:{ariaLabel:()=>"Change colour",currentColorDescriptionTerm:()=>"Current colour assigned: ",currentColorAssigned:e=>e},batchSelection:{selected:e=>`${e} selected`},breadcrumbs:{ariaLabel:()=>"breadcrumbs"},confirm:{no:()=>"No",yes:()=>"Yes"},characterCount:{tooManyCharacters:(e,a)=>1===e?`${a} character too many`:`${a} characters too many`,charactersLeft:(e,a)=>1===e?`${a} character left`:`${a} characters left`,visuallyHiddenHint:e=>`You can enter up to ${e} characters`},date:{dateFnsLocale:()=>e,ariaLabels:{previousMonthButton:()=>"Previous month",nextMonthButton:()=>"Next month"},dateFormatOverride:void 0},dialog:{ariaLabels:{close:()=>"Close"}},dismissibleBox:{ariaLabels:{close:()=>"Close"}},errors:{messages:{formSummary:(e,r,t)=>{const o=a(e)?"error":"errors",n=a(r)?"warning":"warnings",i=a(e)?"is":"are",s=a(r)?"is":"are";return e&&r&&"warning"===t?["and",`${r} ${n}`]:e?[`There ${i}`,`${e} ${o}`]:r?[`There ${s}`,`${r} ${n}`]:null}}},fileInput:{dragAndDrop:()=>"or drag and drop your file",selectFile:()=>"Select file",fileUploadStatus:()=>"File upload status",actions:{cancel:()=>"Cancel upload",clear:()=>"Clear",delete:()=>"Delete file"}},heading:{backLinkAriaLabel:()=>"Back"},link:{skipLinkLabel:()=>"Skip to main content"},loader:{loading:()=>"Loading..."},loaderSpinner:{loading:()=>"Loading..."},loaderStar:{loading:()=>"Loading..."},menuFullscreen:{ariaLabels:{closeButton:()=>"Close"}},message:{closeButtonAriaLabel:()=>"Close",error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",ai:()=>"AI Information",callout:()=>"Callout"},numeralDate:{validation:{day:(e,a)=>e&&a?`Day in ${e} should be a number within 1-${a}.`:"Day should be a number within a 1-31 range.",month:()=>"Month should be a number within a 1-12 range.",year:()=>"Year should be a number within a 1800-2200 range."},labels:{day:()=>"Day",month:()=>"Month",year:()=>"Year"}},pager:{show:()=>"Show",records:(e,r=!0)=>{const t=a(e)?"item":"items";return r?`${e} ${t}`:t},first:()=>"First",last:()=>"Last",next:()=>"Next",previous:()=>"Previous",pageX:()=>"Page",ofY:e=>`of ${e}`},password:{buttonLabelHide:()=>"Hide",buttonLabelShow:()=>"Show",ariaLabelHide:()=>"Hide password",ariaLabelShow:()=>"Show password",ariaLiveShownMessage:()=>"Your password has been shown. Focus on the password input to have it read to you, if it is safe to do so.",ariaLiveHiddenMessage:()=>"Your password is currently hidden."},pill:{remove:e=>`Remove ${e} pill`},progressTracker:{of:()=>"of"},pod:{undo:()=>"Undo"},tabs:{error:e=>`The ${e} tab contains errors`,info:e=>`The ${e} tab contains information`,warning:e=>`The ${e} tab contains warnings`,scrollLeftText:()=>"Scroll Tabs Left",scrollRightText:()=>"Scroll Tabs Right"},textEditor:{boldAria:()=>"Bold",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",characterCounter:e=>`${"number"==typeof e?e.toString():e} characters remaining`,characterLimit:e=>`You are ${e} character(s) over the character limit`,contentEditorAria:()=>"Rich text content editor",hyperlink:{buttonAria:()=>"Hyperlink",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",dialogTitle:()=>"Insert link",formKey:()=>"Indicates required information",linkFieldLabel:()=>"Link address",linkFieldErrorMessage:()=>"Enter link address",saveButton:()=>"Save",saveButtonAria:()=>"Save",textFieldLabel:()=>"Link text",textFieldErrorMessage:()=>"Enter link text"},typography:{selectAria:()=>"Heading type",paragraph:()=>"Paragraph",title:()=>"Title",subtitle:()=>"Subtitle",sectionHeader:()=>"Section header",sectionSubheader:()=>"Section subheader"},italicAria:()=>"Italic",orderedListAria:()=>"Ordered list",saveButton:()=>"Save",saveButtonAria:()=>"Save",toolbarAriaLabel:()=>"Formatting",underlineAria:()=>"Underline",unorderedListAria:()=>"Unordered list",mentions:{listAriaLabel:()=>"List of mentionable people"}},search:{searchButtonText:()=>"Search"},select:{actionButtonText:()=>"Add New Item",placeholder:()=>"Please Select...",noResultsForTerm:e=>`No results for "${e}"`},sidebar:{ariaLabels:{close:()=>"Close"}},sort:{accessibleName:(e,a)=>`Sort all ${e||"contents"}${a?` in an ${a} order.`:" in an ascending or descending order."}`,ariaRoleDescription:()=>"Sortable column header"},splitButton:{ariaLabel:()=>"Show more"},stepFlow:{stepLabel:(e,a)=>`Step ${e} of ${a}`,screenReaderOnlyTitle:(e,a,r,t)=>`${t?`${t}.`:""} ${e}. Step ${a} of ${r}.`,closeIconAriaLabel:()=>"Close"},switch:{on:()=>"ON",off:()=>"OFF"},tileSelect:{deselect:()=>"Deselect"},time:{amText:()=>"AM",pmText:()=>"PM",hoursLabelText:()=>"Hrs.",minutesLabelText:()=>"Mins.",hoursAriaLabelText:()=>"Hours",minutesAriaLabelText:()=>"Minutes"},toast:{ariaLabels:{close:()=>"Close"},error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",notification:()=>"Notification"},verticalMenu:{ariaLabels:{responsiveMenuLauncher:()=>"Product menu launcher",responsiveMenuCloseButton:()=>"Close product menu",responsiveMenuAria:()=>"Product menu"}},verticalMenuFullScreen:{ariaLabels:{close:()=>"Close"}}};export{r as default};
@@ -149,10 +149,13 @@ interface Locale {
149
149
  cancelButton: () => string;
150
150
  cancelButtonAria: () => string;
151
151
  dialogTitle: () => string;
152
+ formKey?: () => string;
152
153
  linkFieldLabel: () => string;
154
+ linkFieldErrorMessage?: () => string;
153
155
  saveButton: () => string;
154
156
  saveButtonAria: () => string;
155
157
  textFieldLabel: () => string;
158
+ textFieldErrorMessage?: () => string;
156
159
  };
157
160
  typography: {
158
161
  selectAria: () => string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),r=require("lexical"),i=require("react"),o=require("./toolbar.style.js"),a=require("../../../../button/button.component.js"),l=require("../../../../../hooks/__internal__/useLocale/useLocale.js"),s=require("./buttons/bold.component.js"),d=require("./buttons/hyperlink.component.js"),u=require("./buttons/italic.component.js"),c=require("./buttons/list.component.js"),p=require("./buttons/save.component.js"),b=require("./buttons/typography.component.js"),m=require("./buttons/underline.component.js"),x=require("./button-group/button-group.component.js"),h=require("../../__utils__/constants.js"),f=require("../../../../textbox/textbox.component.js"),g=require("@lexical/link"),j=require("../../../../dialog/dialog.component.js"),v=require("../../../../form/form.component.js");require("../../../../form/required-fields-indicator/required-fields-indicator.component.js"),exports.default=({contentEditorRef:y,namespace:E,hasHeader:k,onCancel:q,onSave:S,size:T="medium",toolbarControls:$=["typography","bold","italic","underline","unordered-list","ordered-list","link"]})=>{const[_]=t.useLexicalComposerContext(),C=_.isEditable(),B=i.useRef(null),[D,F]=i.useState(!1),[I,L]=i.useState(!1),[w,z]=i.useState(!1),[A,O]=i.useState(!1),[R,N]=i.useState(!1),[P,H]=i.useState(-1),[U,X]=i.useState(""),[Y,K]=i.useState(""),M=l.default(),W=$.includes("typography"),G=$.includes("bold")||$.includes("italic")||$.includes("underline"),J=$.includes("unordered-list")||$.includes("ordered-list"),Q=$.includes("link"),V=i.useCallback((()=>{const e=r.$getSelection();r.$isRangeSelection(e)&&(F(e.hasFormat(h.TEXT_EDITOR_ACTION_TYPES.Bold)),L(e.hasFormat(h.TEXT_EDITOR_ACTION_TYPES.Italic)),z(e.hasFormat(h.TEXT_EDITOR_ACTION_TYPES.Underline)))}),[]);i.useEffect((()=>n.mergeRegister(_.registerUpdateListener((({editorState:e})=>{e.read((()=>{_.isEditable()&&V()}))})))),[V,_]);const Z=()=>{X(""),K(""),O(!1)};if(!C)return null;const ee=U.length&&Y.length;return e.jsxs(o.StyledToolbarWrapper,{"data-role":`${E}-toolbar-wrapper`,hasHeader:k,id:`${E}-toolbar-wrapper`,size:T,children:[e.jsxs(o.StyledToolbar,{role:"toolbar","aria-label":M.textEditor.toolbarAriaLabel(),"data-role":`${E}-toolbar`,id:`${E}-toolbar`,ref:B,onKeyDown:e=>{var t,n;if(0===$.length||!B.current)return;const r=Array.from(null===(t=B.current)||void 0===t?void 0:t.querySelectorAll("button.toolbar-button"));if(!r.length)return;const i=r.findIndex((e=>{var t;return e.id===(null===(t=document.activeElement)||void 0===t?void 0:t.id)}));let o=-1;switch(e.key){case"ArrowRight":e.preventDefault(),R||(o=i<r.length-1?i+1:0);break;case"ArrowLeft":e.preventDefault(),R||(o=i>0?i-1:r.length-1);break;case"Home":e.preventDefault(),o=0;break;case"End":e.preventDefault(),o=r.length-1;break;default:return}r.forEach(((e,t)=>{e.tabIndex=t===o?0:-1})),o>-1&&(null===(n=r[o])||void 0===n||n.focus())},tabIndex:-1,children:[e.jsxs(e.Fragment,{children:[W&&e.jsx(x.default,{name:"typography-formatting-buttons",namespace:E,showDivider:G||J||Q,children:e.jsx(b.default,{contentEditorRef:y,namespace:E,isFirstButton:!0,isOpen:R,setIsOpen:N,focusedIndex:P,setFocusedIndex:H,size:T})}),G&&e.jsxs(x.default,{name:"text-formatting-buttons",namespace:E,showDivider:J||Q,children:[$.includes("bold")&&e.jsx(s.default,{isActive:D,namespace:E,isFirstButton:!W,size:T}),$.includes("italic")&&e.jsx(u.default,{isActive:I,namespace:E,isFirstButton:!W&&!$.includes("bold"),size:T}),$.includes("underline")&&e.jsx(m.default,{isActive:w,namespace:E,isFirstButton:!W&&!$.includes("bold")&&!$.includes("italic"),size:T})]}),J&&e.jsx(x.default,{name:"list-formatting-buttons",namespace:E,showDivider:Q,children:e.jsx(c.default,{namespace:E,olIsFirstButton:!W&&!G&&!$.includes("unordered-list"),showOL:$.includes("ordered-list"),showUL:$.includes("unordered-list"),ulIsFirstButton:!W&&!G,size:T})}),Q&&e.jsx(x.default,{name:"hyperlink-formatting-buttons",namespace:E,showDivider:!1,children:e.jsx(d.default,{namespace:E,isFirstButton:!W&&!G&&!J,setDialogOpen:O,size:T})})]}),e.jsx(j.Dialog,{open:A,onCancel:()=>{Z()},title:M.textEditor.hyperlink.dialogTitle(),"data-role":`${E}-hyperlink-dialog`,"aria-label":M.textEditor.hyperlink.dialogTitle(),size:"small",children:e.jsxs(v.Form,{leftSideButtons:e.jsx(a.default,{"data-role":`${E}-hyperlink-cancel-button`,onClick:()=>{Z()},children:M.textEditor.cancelButton()}),saveButton:e.jsx(a.default,{buttonType:"primary",type:"submit",disabled:!ee,"data-role":`${E}-hyperlink-save-button`,children:M.textEditor.saveButton()}),onSubmit:e=>{e.preventDefault(),_.isEditable()&&(_.update((()=>{const e=r.$getRoot(),t=e.getChildrenSize(),n=r.$getSelection(),i=g.$createLinkNode(Y);if(i.append(r.$createTextNode(U)),0===t){const t=r.$createParagraphNode();t.append(i),e.append(t),t.selectEnd()}else if(r.$isRangeSelection(n))n.insertNodes([i]);else{const t=e.getLastChild();r.$isParagraphNode(t)&&t.append(i)}})),Z())},children:[e.jsx(f.Textbox,{label:M.textEditor.hyperlink.textFieldLabel(),name:"text",required:!0,"data-role":`${E}-hyperlink-text-field`,value:U,onChange:e=>X(e.target.value)}),e.jsx(f.Textbox,{label:M.textEditor.hyperlink.linkFieldLabel(),name:"link",required:!0,"data-role":`${E}-hyperlink-link-field`,value:Y,onChange:e=>K(e.target.value)})]})})]}),e.jsxs(o.CommandButtons,{"data-role":`${E}-command-buttons`,children:[q&&e.jsx(a.default,{buttonType:"tertiary","data-role":`${E}-cancel-button`,"aria-label":M.textEditor.cancelButtonAria(),onClick:()=>null==q?void 0:q(_),size:T,className:"command-button",children:M.textEditor.cancelButton()}),S&&e.jsx(p.default,{namespace:E,onSave:S,size:T})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@lexical/react/LexicalComposerContext"),r=require("@lexical/utils"),n=require("lexical"),o=require("react"),i=require("./toolbar.style.js"),l=require("../../../../button/button.component.js"),a=require("../../../../../hooks/__internal__/useLocale/useLocale.js"),s=require("./buttons/bold.component.js"),u=require("./buttons/hyperlink.component.js"),d=require("./buttons/italic.component.js"),c=require("./buttons/list.component.js"),p=require("./buttons/save.component.js"),x=require("./buttons/typography.component.js"),b=require("./buttons/underline.component.js"),f=require("./button-group/button-group.component.js"),m=require("../../__utils__/constants.js"),h=require("../../../../textbox/textbox.component.js"),g=require("@lexical/link"),y=require("../../../../dialog/dialog.component.js"),j=require("../../../../form/form.component.js");require("../../../../form/required-fields-indicator/required-fields-indicator.component.js");var v=require("../../../../box/box.component.js"),E=require("../../../../typography/typography.component.js");function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){k(e,t,r[t])}))}return e}function S(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}exports.default=({contentEditorRef:k,namespace:q,hasHeader:T,onCancel:w,onSave:$,size:D="medium",toolbarControls:B=["typography","bold","italic","underline","unordered-list","ordered-list","link"]})=>{var C,F,P,_,I,R;const[z]=t.useLexicalComposerContext(),L=z.isEditable(),A=o.useRef(null),[N,W]=o.useState(!1),[M,H]=o.useState(!1),[U,X]=o.useState(!1),[Y,K]=o.useState(!1),[G,J]=o.useState(!1),[Q,V]=o.useState(-1),[Z,ee]=o.useState(""),[te,re]=o.useState(""),[ne,oe]=o.useState(!1),[ie,le]=o.useState(!1),ae=o.useRef(null),se=o.useRef(null),ue=a.default(),de=B.includes("typography"),ce=B.includes("bold")||B.includes("italic")||B.includes("underline"),pe=B.includes("unordered-list")||B.includes("ordered-list"),xe=B.includes("link"),be=o.useCallback((()=>{const e=n.$getSelection();n.$isRangeSelection(e)&&(W(e.hasFormat(m.TEXT_EDITOR_ACTION_TYPES.Bold)),H(e.hasFormat(m.TEXT_EDITOR_ACTION_TYPES.Italic)),X(e.hasFormat(m.TEXT_EDITOR_ACTION_TYPES.Underline)))}),[]);o.useEffect((()=>r.mergeRegister(z.registerUpdateListener((({editorState:e})=>{e.read((()=>{z.isEditable()&&be()}))})))),[be,z]),o.useEffect((()=>{Y&&z.read((()=>{const e=n.$getSelection();if(n.$isRangeSelection(e)){const t=e.getTextContent();ee(t)}}))}),[Y,z]);const fe=()=>{ee(""),re(""),oe(!1),le(!1),K(!1)};return L?e.jsxs(i.StyledToolbarWrapper,{"data-role":`${q}-toolbar-wrapper`,hasHeader:T,id:`${q}-toolbar-wrapper`,size:D,children:[e.jsxs(i.StyledToolbar,{role:"toolbar","aria-label":ue.textEditor.toolbarAriaLabel(),"data-role":`${q}-toolbar`,id:`${q}-toolbar`,ref:A,onKeyDown:e=>{var t,r;if(0===B.length||!A.current)return;const n=Array.from(null===(t=A.current)||void 0===t?void 0:t.querySelectorAll("button.toolbar-button"));if(!n.length)return;const o=n.findIndex((e=>{var t;return e.id===(null===(t=document.activeElement)||void 0===t?void 0:t.id)}));let i=-1;switch(e.key){case"ArrowRight":e.preventDefault(),G||(i=o<n.length-1?o+1:0);break;case"ArrowLeft":e.preventDefault(),G||(i=o>0?o-1:n.length-1);break;case"Home":e.preventDefault(),i=0;break;case"End":e.preventDefault(),i=n.length-1;break;default:return}n.forEach(((e,t)=>{e.tabIndex=t===i?0:-1})),i>-1&&(null===(r=n[i])||void 0===r||r.focus())},tabIndex:-1,children:[e.jsxs(e.Fragment,{children:[de&&e.jsx(f.default,{name:"typography-formatting-buttons",namespace:q,showDivider:ce||pe||xe,children:e.jsx(x.default,{contentEditorRef:k,namespace:q,isFirstButton:!0,isOpen:G,setIsOpen:J,focusedIndex:Q,setFocusedIndex:V,size:D})}),ce&&e.jsxs(f.default,{name:"text-formatting-buttons",namespace:q,showDivider:pe||xe,children:[B.includes("bold")&&e.jsx(s.default,{isActive:N,namespace:q,isFirstButton:!de,size:D}),B.includes("italic")&&e.jsx(d.default,{isActive:M,namespace:q,isFirstButton:!de&&!B.includes("bold"),size:D}),B.includes("underline")&&e.jsx(b.default,{isActive:U,namespace:q,isFirstButton:!de&&!B.includes("bold")&&!B.includes("italic"),size:D})]}),pe&&e.jsx(f.default,{name:"list-formatting-buttons",namespace:q,showDivider:xe,children:e.jsx(c.default,{namespace:q,olIsFirstButton:!de&&!ce&&!B.includes("unordered-list"),showOL:B.includes("ordered-list"),showUL:B.includes("unordered-list"),ulIsFirstButton:!de&&!ce,size:D})}),xe&&e.jsx(f.default,{name:"hyperlink-formatting-buttons",namespace:q,showDivider:!1,children:e.jsx(u.default,{namespace:q,isFirstButton:!de&&!ce&&!pe,setDialogOpen:K,size:D})})]}),e.jsx(y.Dialog,{open:Y,onCancel:()=>{fe()},title:ue.textEditor.hyperlink.dialogTitle(),"data-role":`${q}-hyperlink-dialog`,"aria-label":ue.textEditor.hyperlink.dialogTitle(),size:"medium-small",children:e.jsx(j.Form,{leftSideButtons:e.jsx(l.default,{"data-role":`${q}-hyperlink-cancel-button`,onClick:()=>{fe()},children:ue.textEditor.cancelButton()}),saveButton:e.jsx(l.default,{buttonType:"primary",type:"submit","data-role":`${q}-hyperlink-save-button`,children:ue.textEditor.saveButton()}),onSubmit:e=>{e.preventDefault();const t=!Z.trim(),r=!te.trim();var o,i;(oe(t),le(r),t||r)?t?null===(o=ae.current)||void 0===o||o.focus():null===(i=se.current)||void 0===i||i.focus():z.isEditable()&&(z.update((()=>{const e=n.$getRoot(),t=e.getChildrenSize(),r=n.$getSelection(),o=g.$createLinkNode(te);if(o.append(n.$createTextNode(Z)),0===t){const t=n.$createParagraphNode();t.append(o),e.append(t),t.selectEnd()}else if(n.$isRangeSelection(r))r.insertNodes([o]);else{const t=e.getLastChild();n.$isParagraphNode(t)&&t.append(o)}})),fe())},children:e.jsxs(v.Box,{display:"flex",flexDirection:"column",gap:"16px",children:[e.jsxs(E.Typography,{fontSize:"14px",fontWeight:"500",lineHeight:"21px",children:[e.jsx(E.Typography,{as:"span",color:"#FF0000",children:"*"})," ",null===(C=(F=ue.textEditor.hyperlink).formKey)||void 0===C?void 0:C.call(F)]}),e.jsxs(v.Box,{display:"flex",gap:"24px",flexWrap:"wrap",children:[e.jsx(v.Box,{flex:"1 1 200px",minWidth:"200px",maxWidth:"560px",children:e.jsx(h.Textbox,S(O({label:ue.textEditor.hyperlink.textFieldLabel(),name:"text",required:!0,validationMessagePositionTop:!1},ne&&{error:null===(P=(_=ue.textEditor.hyperlink).textFieldErrorMessage)||void 0===P?void 0:P.call(_)}),{"data-role":`${q}-hyperlink-text-field`,value:Z,ref:ae,onChange:e=>{ee(e.target.value),oe(!1)}}))}),e.jsx(v.Box,{flex:"1 1 200px",minWidth:"200px",maxWidth:"560px",children:e.jsx(h.Textbox,S(O({label:ue.textEditor.hyperlink.linkFieldLabel(),name:"link",required:!0,validationMessagePositionTop:!1},ie&&{error:null===(I=(R=ue.textEditor.hyperlink).linkFieldErrorMessage)||void 0===I?void 0:I.call(R)}),{"data-role":`${q}-hyperlink-link-field`,value:te,ref:se,onChange:e=>{re(e.target.value),le(!1)}}))})]})]})})})]}),e.jsxs(i.CommandButtons,{"data-role":`${q}-command-buttons`,children:[w&&e.jsx(l.default,{buttonType:"tertiary","data-role":`${q}-cancel-button`,"aria-label":ue.textEditor.cancelButtonAria(),onClick:()=>null==w?void 0:w(z),size:D,className:"command-button",children:ue.textEditor.cancelButton()}),$&&e.jsx(p.default,{namespace:q,onSave:$,size:D})]})]}):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("styled-system");function r(e){return e&&e.__esModule?e:{default:e}}var o=r(e);const i=o.default.div.withConfig({displayName:"text-editor.style__StyledTextEditor",componentId:"sc-f35af111-0"})(["position:relative;box-sizing:border-box;",""],(({error:t})=>t&&e.css(["margin:-1px;"]))),a=o.default.div.withConfig({displayName:"text-editor.style__StyledTextEditorWrapper",componentId:"sc-f35af111-1"})(["margin-bottom:var(--fieldSpacing);"," min-width:288px;"],t.margin),d=o.default.div.withConfig({displayName:"text-editor.style__StyledWrapper",componentId:"sc-f35af111-2"})(['position:relative;.textBold{font-weight:bold;}.textItalic{font-style:italic;}.textUnderline{text-decoration:underline;}a:not([data-component="link-preview"]){color:var(--colorsActionMajor500);cursor:pointer;&:hover{color:var(--colorsActionMajor600);}&:focus{outline:none;text-decoration:none;color:var(--colorsActionMajorYin090);background-color:var(--colorsSemanticFocus250);border-radius:var(--borderRadius025);box-shadow:0 var(--spacing050) 0 0 var(--colorsUtilityYin090);}}']),l=o.default.div.withConfig({displayName:"text-editor.style__StyledEditorToolbarWrapper",componentId:"sc-f35af111-3"})(["border-radius:var(--borderRadius100);",""],(({error:t})=>t?e.css(["border:1px solid var(--colorsUtilityMajor200);"]):e.css(["outline:1px solid var(--colorsUtilityMajor200);"]))),s=o.default.div.withConfig({displayName:"text-editor.style__StyledHeaderWrapper",componentId:"sc-f35af111-4"})(["padding:var(--spacing200);"]),n=o.default.div.withConfig({displayName:"text-editor.style__StyledFooterWrapper",componentId:"sc-f35af111-5"})(["border-top:1px solid var(--colorsUtilityMajor200);padding:",";"],(({size:e})=>{switch(e){case"large":return"var(--spacing200)";case"small":return"var(--spacing100)";default:return"var(--spacing150)"}}));exports.StyledEditorToolbarWrapper=l,exports.StyledFooterWrapper=n,exports.StyledHeaderWrapper=s,exports.StyledTextEditor=i,exports.StyledTextEditorWrapper=a,exports.StyledWrapper=d,exports.default=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("styled-system");function r(e){return e&&e.__esModule?e:{default:e}}var o=r(e);const a=o.default.div.withConfig({displayName:"text-editor.style__StyledTextEditor",componentId:"sc-afa0eb4b-0"})(["position:relative;box-sizing:border-box;",""],(({error:t})=>t&&e.css(["margin:-1px;"]))),i=o.default.div.withConfig({displayName:"text-editor.style__StyledTextEditorWrapper",componentId:"sc-afa0eb4b-1"})(["margin-bottom:var(--fieldSpacing);"," min-width:288px;"],t.margin),d=o.default.div.withConfig({displayName:"text-editor.style__StyledWrapper",componentId:"sc-afa0eb4b-2"})(['position:relative;.textBold{font-weight:bold !important;}.textItalic{font-style:italic;}.textUnderline{text-decoration:underline;}a:not([data-component="link-preview"]){color:var(--colorsActionMajor500);cursor:pointer;&:hover{color:var(--colorsActionMajor600);}&:focus{outline:none;text-decoration:none;color:var(--colorsActionMajorYin090);background-color:var(--colorsSemanticFocus250);border-radius:var(--borderRadius025);box-shadow:0 var(--spacing050) 0 0 var(--colorsUtilityYin090);}}']),l=o.default.div.withConfig({displayName:"text-editor.style__StyledEditorToolbarWrapper",componentId:"sc-afa0eb4b-3"})(["border-radius:var(--borderRadius100);",""],(({error:t})=>t?e.css(["border:1px solid var(--colorsUtilityMajor200);"]):e.css(["outline:1px solid var(--colorsUtilityMajor200);"]))),s=o.default.div.withConfig({displayName:"text-editor.style__StyledHeaderWrapper",componentId:"sc-afa0eb4b-4"})(["padding:var(--spacing200);"]),n=o.default.div.withConfig({displayName:"text-editor.style__StyledFooterWrapper",componentId:"sc-afa0eb4b-5"})(["border-top:1px solid var(--colorsUtilityMajor200);padding:",";"],(({size:e})=>{switch(e){case"large":return"var(--spacing200)";case"small":return"var(--spacing100)";default:return"var(--spacing150)"}}));exports.StyledEditorToolbarWrapper=l,exports.StyledFooterWrapper=n,exports.StyledHeaderWrapper=s,exports.StyledTextEditor=a,exports.StyledTextEditorWrapper=i,exports.StyledWrapper=d,exports.default=a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("date-fns/locale/en-GB");const a=e=>1===("string"==typeof e?parseInt(e):e),r={locale:()=>"en-GB",actions:{edit:()=>"Edit",delete:()=>"Delete"},actionPopover:{ariaLabel:()=>"actions"},advancedColorPicker:{ariaLabel:()=>"Change colour",currentColorDescriptionTerm:()=>"Current colour assigned: ",currentColorAssigned:e=>e},batchSelection:{selected:e=>`${e} selected`},breadcrumbs:{ariaLabel:()=>"breadcrumbs"},confirm:{no:()=>"No",yes:()=>"Yes"},characterCount:{tooManyCharacters:(e,a)=>1===e?`${a} character too many`:`${a} characters too many`,charactersLeft:(e,a)=>1===e?`${a} character left`:`${a} characters left`,visuallyHiddenHint:e=>`You can enter up to ${e} characters`},date:{dateFnsLocale:()=>e.enGB,ariaLabels:{previousMonthButton:()=>"Previous month",nextMonthButton:()=>"Next month"},dateFormatOverride:void 0},dialog:{ariaLabels:{close:()=>"Close"}},dismissibleBox:{ariaLabels:{close:()=>"Close"}},errors:{messages:{formSummary:(e,r,t)=>{const o=a(e)?"error":"errors",n=a(r)?"warning":"warnings",i=a(e)?"is":"are",s=a(r)?"is":"are";return e&&r&&"warning"===t?["and",`${r} ${n}`]:e?[`There ${i}`,`${e} ${o}`]:r?[`There ${s}`,`${r} ${n}`]:null}}},fileInput:{dragAndDrop:()=>"or drag and drop your file",selectFile:()=>"Select file",fileUploadStatus:()=>"File upload status",actions:{cancel:()=>"Cancel upload",clear:()=>"Clear",delete:()=>"Delete file"}},heading:{backLinkAriaLabel:()=>"Back"},link:{skipLinkLabel:()=>"Skip to main content"},loader:{loading:()=>"Loading..."},loaderSpinner:{loading:()=>"Loading..."},loaderStar:{loading:()=>"Loading..."},menuFullscreen:{ariaLabels:{closeButton:()=>"Close"}},message:{closeButtonAriaLabel:()=>"Close",error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",ai:()=>"AI Information",callout:()=>"Callout"},numeralDate:{validation:{day:(e,a)=>e&&a?`Day in ${e} should be a number within 1-${a}.`:"Day should be a number within a 1-31 range.",month:()=>"Month should be a number within a 1-12 range.",year:()=>"Year should be a number within a 1800-2200 range."},labels:{day:()=>"Day",month:()=>"Month",year:()=>"Year"}},pager:{show:()=>"Show",records:(e,r=!0)=>{const t=a(e)?"item":"items";return r?`${e} ${t}`:t},first:()=>"First",last:()=>"Last",next:()=>"Next",previous:()=>"Previous",pageX:()=>"Page",ofY:e=>`of ${e}`},password:{buttonLabelHide:()=>"Hide",buttonLabelShow:()=>"Show",ariaLabelHide:()=>"Hide password",ariaLabelShow:()=>"Show password",ariaLiveShownMessage:()=>"Your password has been shown. Focus on the password input to have it read to you, if it is safe to do so.",ariaLiveHiddenMessage:()=>"Your password is currently hidden."},pill:{remove:e=>`Remove ${e} pill`},progressTracker:{of:()=>"of"},pod:{undo:()=>"Undo"},tabs:{error:e=>`The ${e} tab contains errors`,info:e=>`The ${e} tab contains information`,warning:e=>`The ${e} tab contains warnings`,scrollLeftText:()=>"Scroll Tabs Left",scrollRightText:()=>"Scroll Tabs Right"},textEditor:{boldAria:()=>"Bold",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",characterCounter:e=>`${"number"==typeof e?e.toString():e} characters remaining`,characterLimit:e=>`You are ${e} character(s) over the character limit`,contentEditorAria:()=>"Rich text content editor",hyperlink:{buttonAria:()=>"Hyperlink",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",dialogTitle:()=>"Add link",linkFieldLabel:()=>"Link",saveButton:()=>"Save",saveButtonAria:()=>"Save",textFieldLabel:()=>"Text"},typography:{selectAria:()=>"Heading type",paragraph:()=>"Paragraph",title:()=>"Title",subtitle:()=>"Subtitle",sectionHeader:()=>"Section header",sectionSubheader:()=>"Section subheader"},italicAria:()=>"Italic",orderedListAria:()=>"Ordered list",saveButton:()=>"Save",saveButtonAria:()=>"Save",toolbarAriaLabel:()=>"Formatting",underlineAria:()=>"Underline",unorderedListAria:()=>"Unordered list",mentions:{listAriaLabel:()=>"List of mentionable people"}},search:{searchButtonText:()=>"Search"},select:{actionButtonText:()=>"Add New Item",placeholder:()=>"Please Select...",noResultsForTerm:e=>`No results for "${e}"`},sidebar:{ariaLabels:{close:()=>"Close"}},sort:{accessibleName:(e,a)=>`Sort all ${e||"contents"}${a?` in an ${a} order.`:" in an ascending or descending order."}`,ariaRoleDescription:()=>"Sortable column header"},splitButton:{ariaLabel:()=>"Show more"},stepFlow:{stepLabel:(e,a)=>`Step ${e} of ${a}`,screenReaderOnlyTitle:(e,a,r,t)=>`${t?`${t}.`:""} ${e}. Step ${a} of ${r}.`,closeIconAriaLabel:()=>"Close"},switch:{on:()=>"ON",off:()=>"OFF"},tileSelect:{deselect:()=>"Deselect"},time:{amText:()=>"AM",pmText:()=>"PM",hoursLabelText:()=>"Hrs.",minutesLabelText:()=>"Mins.",hoursAriaLabelText:()=>"Hours",minutesAriaLabelText:()=>"Minutes"},toast:{ariaLabels:{close:()=>"Close"},error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",notification:()=>"Notification"},verticalMenu:{ariaLabels:{responsiveMenuLauncher:()=>"Product menu launcher",responsiveMenuCloseButton:()=>"Close product menu",responsiveMenuAria:()=>"Product menu"}},verticalMenuFullScreen:{ariaLabels:{close:()=>"Close"}}};exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("date-fns/locale/en-GB");const a=e=>1===("string"==typeof e?parseInt(e):e),r={locale:()=>"en-GB",actions:{edit:()=>"Edit",delete:()=>"Delete"},actionPopover:{ariaLabel:()=>"actions"},advancedColorPicker:{ariaLabel:()=>"Change colour",currentColorDescriptionTerm:()=>"Current colour assigned: ",currentColorAssigned:e=>e},batchSelection:{selected:e=>`${e} selected`},breadcrumbs:{ariaLabel:()=>"breadcrumbs"},confirm:{no:()=>"No",yes:()=>"Yes"},characterCount:{tooManyCharacters:(e,a)=>1===e?`${a} character too many`:`${a} characters too many`,charactersLeft:(e,a)=>1===e?`${a} character left`:`${a} characters left`,visuallyHiddenHint:e=>`You can enter up to ${e} characters`},date:{dateFnsLocale:()=>e.enGB,ariaLabels:{previousMonthButton:()=>"Previous month",nextMonthButton:()=>"Next month"},dateFormatOverride:void 0},dialog:{ariaLabels:{close:()=>"Close"}},dismissibleBox:{ariaLabels:{close:()=>"Close"}},errors:{messages:{formSummary:(e,r,t)=>{const o=a(e)?"error":"errors",n=a(r)?"warning":"warnings",i=a(e)?"is":"are",s=a(r)?"is":"are";return e&&r&&"warning"===t?["and",`${r} ${n}`]:e?[`There ${i}`,`${e} ${o}`]:r?[`There ${s}`,`${r} ${n}`]:null}}},fileInput:{dragAndDrop:()=>"or drag and drop your file",selectFile:()=>"Select file",fileUploadStatus:()=>"File upload status",actions:{cancel:()=>"Cancel upload",clear:()=>"Clear",delete:()=>"Delete file"}},heading:{backLinkAriaLabel:()=>"Back"},link:{skipLinkLabel:()=>"Skip to main content"},loader:{loading:()=>"Loading..."},loaderSpinner:{loading:()=>"Loading..."},loaderStar:{loading:()=>"Loading..."},menuFullscreen:{ariaLabels:{closeButton:()=>"Close"}},message:{closeButtonAriaLabel:()=>"Close",error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",ai:()=>"AI Information",callout:()=>"Callout"},numeralDate:{validation:{day:(e,a)=>e&&a?`Day in ${e} should be a number within 1-${a}.`:"Day should be a number within a 1-31 range.",month:()=>"Month should be a number within a 1-12 range.",year:()=>"Year should be a number within a 1800-2200 range."},labels:{day:()=>"Day",month:()=>"Month",year:()=>"Year"}},pager:{show:()=>"Show",records:(e,r=!0)=>{const t=a(e)?"item":"items";return r?`${e} ${t}`:t},first:()=>"First",last:()=>"Last",next:()=>"Next",previous:()=>"Previous",pageX:()=>"Page",ofY:e=>`of ${e}`},password:{buttonLabelHide:()=>"Hide",buttonLabelShow:()=>"Show",ariaLabelHide:()=>"Hide password",ariaLabelShow:()=>"Show password",ariaLiveShownMessage:()=>"Your password has been shown. Focus on the password input to have it read to you, if it is safe to do so.",ariaLiveHiddenMessage:()=>"Your password is currently hidden."},pill:{remove:e=>`Remove ${e} pill`},progressTracker:{of:()=>"of"},pod:{undo:()=>"Undo"},tabs:{error:e=>`The ${e} tab contains errors`,info:e=>`The ${e} tab contains information`,warning:e=>`The ${e} tab contains warnings`,scrollLeftText:()=>"Scroll Tabs Left",scrollRightText:()=>"Scroll Tabs Right"},textEditor:{boldAria:()=>"Bold",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",characterCounter:e=>`${"number"==typeof e?e.toString():e} characters remaining`,characterLimit:e=>`You are ${e} character(s) over the character limit`,contentEditorAria:()=>"Rich text content editor",hyperlink:{buttonAria:()=>"Hyperlink",cancelButton:()=>"Cancel",cancelButtonAria:()=>"Cancel",dialogTitle:()=>"Insert link",formKey:()=>"Indicates required information",linkFieldLabel:()=>"Link address",linkFieldErrorMessage:()=>"Enter link address",saveButton:()=>"Save",saveButtonAria:()=>"Save",textFieldLabel:()=>"Link text",textFieldErrorMessage:()=>"Enter link text"},typography:{selectAria:()=>"Heading type",paragraph:()=>"Paragraph",title:()=>"Title",subtitle:()=>"Subtitle",sectionHeader:()=>"Section header",sectionSubheader:()=>"Section subheader"},italicAria:()=>"Italic",orderedListAria:()=>"Ordered list",saveButton:()=>"Save",saveButtonAria:()=>"Save",toolbarAriaLabel:()=>"Formatting",underlineAria:()=>"Underline",unorderedListAria:()=>"Unordered list",mentions:{listAriaLabel:()=>"List of mentionable people"}},search:{searchButtonText:()=>"Search"},select:{actionButtonText:()=>"Add New Item",placeholder:()=>"Please Select...",noResultsForTerm:e=>`No results for "${e}"`},sidebar:{ariaLabels:{close:()=>"Close"}},sort:{accessibleName:(e,a)=>`Sort all ${e||"contents"}${a?` in an ${a} order.`:" in an ascending or descending order."}`,ariaRoleDescription:()=>"Sortable column header"},splitButton:{ariaLabel:()=>"Show more"},stepFlow:{stepLabel:(e,a)=>`Step ${e} of ${a}`,screenReaderOnlyTitle:(e,a,r,t)=>`${t?`${t}.`:""} ${e}. Step ${a} of ${r}.`,closeIconAriaLabel:()=>"Close"},switch:{on:()=>"ON",off:()=>"OFF"},tileSelect:{deselect:()=>"Deselect"},time:{amText:()=>"AM",pmText:()=>"PM",hoursLabelText:()=>"Hrs.",minutesLabelText:()=>"Mins.",hoursAriaLabelText:()=>"Hours",minutesAriaLabelText:()=>"Minutes"},toast:{ariaLabels:{close:()=>"Close"},error:()=>"Error",info:()=>"Information",success:()=>"Success",warning:()=>"Warning",neutral:()=>"Information",notification:()=>"Notification"},verticalMenu:{ariaLabels:{responsiveMenuLauncher:()=>"Product menu launcher",responsiveMenuCloseButton:()=>"Close product menu",responsiveMenuAria:()=>"Product menu"}},verticalMenuFullScreen:{ariaLabels:{close:()=>"Close"}}};exports.default=r;
@@ -149,10 +149,13 @@ interface Locale {
149
149
  cancelButton: () => string;
150
150
  cancelButtonAria: () => string;
151
151
  dialogTitle: () => string;
152
+ formKey?: () => string;
152
153
  linkFieldLabel: () => string;
154
+ linkFieldErrorMessage?: () => string;
153
155
  saveButton: () => string;
154
156
  saveButtonAria: () => string;
155
157
  textFieldLabel: () => string;
158
+ textFieldErrorMessage?: () => string;
156
159
  };
157
160
  typography: {
158
161
  selectAria: () => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "158.45.0",
3
+ "version": "158.46.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",