@mohsinonxrm/pptb-commandbar-studio 0.9.0-beta.2 → 0.10.0-beta.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +242 -2
  2. package/README.md +16 -14
  3. package/SECURITY.md +4 -4
  4. package/dist/assets/BulkPublishModal-9_XxYmS2.js +2 -0
  5. package/dist/assets/CommandEditorPanel-BtBG8540.js +1 -0
  6. package/dist/assets/CommandPalette-C2YXN_gD.js +1 -0
  7. package/dist/assets/CompareView-Beq5V68_.js +11 -0
  8. package/dist/assets/CrmParameterEditor-DfZv5BuF.js +1 -0
  9. package/dist/assets/EditorDrawer-D0K8zHVK.js +2 -0
  10. package/dist/assets/HideInsteadOfDeleteModal-C4AKxh50.js +1 -0
  11. package/dist/assets/IconPickerModal-B9UeIP7Z.js +1 -0
  12. package/dist/assets/ImportXmlModal-Cf75oVpN.js +1 -0
  13. package/dist/assets/{MonacoEditor-DweI16yt.js → MonacoEditor-B3J81C8F.js} +2 -2
  14. package/dist/assets/NewButtonModal-DhGNLWEW.js +1 -0
  15. package/dist/assets/NewGroupModal-CMLOZ15C.js +1 -0
  16. package/dist/assets/NewTabModal-N7FF7DT1.js +1 -0
  17. package/dist/assets/RuleEditorPanel-C9CcMM1s.js +1 -0
  18. package/dist/assets/ScriptView-B0ILfTWe.js +1 -0
  19. package/dist/assets/TabDisplayRulesPanel-DVMEaWWv.js +1 -0
  20. package/dist/assets/TitleTranslationsView-C68zJcNK.js +1 -0
  21. package/dist/assets/TranslationsView-BZXsG_LU.js +1 -0
  22. package/dist/assets/WebResourceBrowser-DEXq2SCy.js +1 -0
  23. package/dist/assets/XmlView-DEUwTHCt.js +2 -0
  24. package/dist/assets/crmParameters-Dxz06tk4.js +1 -0
  25. package/dist/assets/{dnd-iy5K5XAJ.js → dnd-C19d6Mn0.js} +1 -1
  26. package/dist/assets/fluent-ui-BThr2m8u.js +59 -0
  27. package/dist/assets/index-Df9NSpg6.js +136 -0
  28. package/dist/assets/index-browser-Bmt9T2GD.js +2 -0
  29. package/dist/assets/languages-CGjPBPNA.js +1 -0
  30. package/dist/assets/{monaco-cQE5XS3B.js → monaco-DzBcrxae.js} +1 -1
  31. package/dist/assets/monacoSetup-BRltj-y7.js +1 -0
  32. package/dist/assets/publishService-CKoTOngS.js +36 -0
  33. package/dist/assets/ribbonXsdCheck-CJBpxpVm.js +1923 -0
  34. package/dist/assets/{server.browser-DTeSoizu.js → server.browser-BokSAg1N.js} +1 -1
  35. package/dist/assets/useReplaceWebResourceConfirm-BUfgdCRQ.js +1 -0
  36. package/dist/assets/{useStableKeys-49o4VnxU.js → useStableKeys-EsghhjoV.js} +1 -1
  37. package/dist/assets/xmlValidator-Dki8Hf7Y.js +3 -0
  38. package/dist/assets/xmllint-CcuGSrO9.wasm +0 -0
  39. package/dist/assets/xmllint-browser-C85XrDSU.js +4 -0
  40. package/dist/index.html +3 -3
  41. package/package.json +2 -1
  42. package/dist/assets/BulkPublishModal-DjdSDcWe.js +0 -36
  43. package/dist/assets/CommandEditorPanel-DYsxUTOk.js +0 -1
  44. package/dist/assets/CommandPalette-DihgRpHI.js +0 -1
  45. package/dist/assets/CompareView-CdQo0D6e.js +0 -7
  46. package/dist/assets/CrmParameterEditor-DO6Rt764.js +0 -1
  47. package/dist/assets/EditorDrawer-Cid60F3b.js +0 -2
  48. package/dist/assets/HideInsteadOfDeleteModal-Bk_foggy.js +0 -1
  49. package/dist/assets/IconPickerModal-CW_pvpVS.js +0 -1
  50. package/dist/assets/ImportXmlModal-BcszuTi-.js +0 -1
  51. package/dist/assets/NewButtonModal-C2fAUuZI.js +0 -1
  52. package/dist/assets/NewGroupModal-BDr4DPBs.js +0 -1
  53. package/dist/assets/NewTabModal-CYc1fc2A.js +0 -1
  54. package/dist/assets/RuleEditorPanel-BxGrJYo4.js +0 -1
  55. package/dist/assets/ScriptView-tkdIK4sg.js +0 -1
  56. package/dist/assets/TabDisplayRulesPanel-S_AxUWfB.js +0 -1
  57. package/dist/assets/TranslationsView-DZIGE2pC.js +0 -1
  58. package/dist/assets/WebResourceBrowser-Dc3kBMvH.js +0 -1
  59. package/dist/assets/XmlView-B0weY9hR.js +0 -2
  60. package/dist/assets/crmParameters-rgfZhhzN.js +0 -1
  61. package/dist/assets/fluent-ui-CQyNN9H3.js +0 -59
  62. package/dist/assets/index-DRTwBo4g.js +0 -136
  63. package/dist/assets/monacoSetup-BIq1zGyP.js +0 -1
  64. package/dist/assets/ruleKinds-BKTUiZ1-.js +0 -1
  65. package/dist/assets/useReplaceWebResourceConfirm-BhU1AM5L.js +0 -1
  66. package/dist/assets/xmlValidator-CnbyWxHe.js +0 -3
@@ -1 +0,0 @@
1
- import{r as W,j as c,c as k,dX as de,a6 as ze,a7 as Fe,B as Ne,k as _,m as Pe,t as E}from"./fluent-ui-CQyNN9H3.js";import{a9 as ve,v as We,aa as Ue,ab as _e,ac as Je,ad as Ye,ae as Ke,b as ne,S as De,Z as Ve,a as Ze,a2 as Qe}from"./index-DRTwBo4g.js";import{a as et}from"./xmlValidator-CnbyWxHe.js";import{M as tt}from"./MonacoEditor-DweI16yt.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";import"./ruleKinds-BKTUiZ1-.js";import"./crmParameters-rgfZhhzN.js";const ge=["HomepageGrid","SubGrid","Form"],ue=[...ge,"Application"],pe=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]),me=new Set(["flyout","splitButton"]),he=/^Mscrm\.(HomepageGrid|SubGrid|Form)\.([^.]+)\./,Ie="._children",ot=/<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/,be=/\$LocLabels:([^"'\s<]+)/g,Le="cbs.import.Tab",nt="cbs.import.Group",je=(i,b)=>JSON.stringify(i)===JSON.stringify(b);function U(i){return i?Array.from(i.children):[]}function st(i){return Object.fromEntries(Array.from(i.attributes).map(b=>[b.name,b.value]))}function it(i,b,d){const m=i.documentElement;if(m.tagName==="RibbonDiffXml")return m;const h=Array.from(i.getElementsByTagName("RibbonDiffXml")),$=Array.from(i.querySelectorAll("Entities > Entity")).flatMap(l=>{const A=U(l),O=A.find(I=>I.tagName==="RibbonDiffXml"),T=A.find(I=>I.tagName==="Name")?.textContent?.trim()??"";return O?[{name:T,rdx:O}]:[]}),w=h.find(l=>l.parentElement===m);if($.length===0&&!w){if(h.length===1)return h[0];throw new Error(h.length===0?"No <RibbonDiffXml> element found.":`The XML has ${h.length} <RibbonDiffXml> elements and none belongs to a table or the application ribbon — paste just one.`)}const G=[...$.map(l=>l.name||"(unnamed table)"),...w?["the application ribbon"]:[]].join(", ");if(d){if(w)return w;throw new Error(`The XML has no application ribbon RibbonDiffXml (it has: ${G}). Open that table's ribbon to import its customizations.`)}const S=$.find(l=>l.name.toLowerCase()===b.toLowerCase());if(S)return S.rdx;throw new Error(`The XML has no RibbonDiffXml for ${b||"the loaded table"} (it has: ${G}). Load that table, or open the application ribbon for the application ribbon's customizations.`)}function rt(i){switch(i){case"HomePageGrid":return"HomepageGrid";case"Form":return"Form";case"SubGridStandard":case"SubGridAssociated":return"SubGrid";default:return}}function at(i){const b=i.languageCode??1033,d=i.entityLogicalName,m=new DOMParser().parseFromString(i.xml,"application/xml");if(m.querySelector("parsererror"))throw new Error("The XML is not well-formed.");const h=i.activeLocation==="Application",$=it(m,d,h),w=new XMLSerializer,G=w.serializeToString($),S=[],l=[],A=[],O=!!d&&new RegExp(`Mscrm\\.(HomepageGrid|SubGrid|Form)\\.${d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\.`,"i").test(G),T=h&&!($===m.documentElement&&O);$!==m.documentElement?A.push(`Imported the RibbonDiffXml of ${T?"the application ribbon":d} from the document.`):h&&!T&&A.push(`The XML's Locations name the ${d} table, so it was imported as that table's customizations, not the application ribbon's.`);const I=T?"Application":ge.includes(i.activeLocation)?i.activeLocation:"HomepageGrid",B=ve(G,i.activeLocation,d),H=(e,t,o)=>{const s=new Map,n=new Map;for(const y of t)s.set(y.id,y),n.set(y.id,(n.get(y.id)??0)+1);for(const[y,x]of n)x>1&&A.push(`${o} ${y} is defined ${x} times in the XML — the last one was used.`);const u=Array.from(s.values()),a=[...e],p=[];let f=0;for(const y of u){const x=a.findIndex(D=>D.id===y.id);if(x>=0&&je(a[x],y)){f++;continue}S.push(`${o} ${y.id} ${x>=0?"updated":"added"}`),x>=0?a[x]=y:a.push(y),p.push(y.id)}return{out:a,changedIds:p,unchanged:f}},L=H(i.commands,B.commands,"Command"),z=H(i.enableRules,B.enableRules,"Enable rule"),N=H(i.displayRules,B.displayRules,"Display rule"),C=H(i.locLabels,B.locLabels,"Label"),X=C.out,q=L.unchanged+z.unchanged+N.unchanged+C.unchanged,M=(e,t)=>e&&Ke(e,X,b)||t,j=JSON.parse(JSON.stringify(i.ribbons));let v=!1,F=0;const r=new Set,g=e=>{if(T)return ue.slice().reverse();const t=he.exec(e),o=t&&t[2]!=="{!EntityLogicalName}"?t[1]:I;return[o,...ge.filter(s=>s!==o),"Application"]},R=(e,t)=>{T&&e!=="Application"?A.push(`${t} is on the table's ribbon (${e}), not the application ribbon: the change is published with the table.`):!T&&e==="Application"&&A.push(`${t} was found only on the application ribbon: the change is published to the application ribbon and affects every table.`)},ie=[],P=(e,t)=>{e&&e!==t&&ie.push(e)},J=e=>{for(const t of g(e))for(const o of j[t].tabs){const s=o.groups.find(n=>n.id===e);if(s)return{location:t,tab:o,group:s}}},Y=e=>{for(const t of g(e)){const o=j[t].tabs.find(s=>s.id===e);if(o)return{location:t,tab:o}}},K=e=>{for(const t of g(e)){const o=[];for(const s of j[t].tabs)for(const n of s.groups)for(const u of n.buttons)u.id===e&&o.push({group:n,button:u});if(o.length>0)return{location:t,found:o}}},V=(e,t)=>{const o=he.exec(t);let s="it isn't in the loaded ribbon";o&&o[2]!=="{!EntityLogicalName}"&&d&&o[2]!==d?s=`it belongs to the ${o[2]} table, but ${d} is loaded`:(o?.[2]==="{!EntityLogicalName}"||t.startsWith("Mscrm.Global"))&&(s="it belongs to the application ribbon, which isn't loaded with it"),l.push(`${e}: Location "${t}" not found — ${s}.`)},Ee=U($.querySelector(":scope > RuleDefinitions > TabDisplayRules")).map(e=>w.serializeToString(e)).join(""),re=e=>ve(`<RibbonDiffXml><UI><Ribbon><Tabs>${e}</Tabs></Ribbon></UI><RuleDefinitions><TabDisplayRules>${Ee}</TabDisplayRules></RuleDefinitions></RibbonDiffXml>`,i.activeLocation,d,X).ribbon.tabs[0],Z=e=>w.serializeToString(e),ye=e=>re(`<Tab Id="${Le}"><Groups><Group Id="${nt}"><Controls>${Z(e)}</Controls></Group></Groups></Tab>`)?.groups[0]?.buttons.find(t=>t.id===e.getAttribute("Id")),xe=e=>{const t=e.source;t&&(e.label=M(t.labelToken,e.id),t.tooltipTitleToken&&(e.tooltipTitle=M(t.tooltipTitleToken,"")),t.tooltipBodyToken&&(e.tooltipBody=M(t.tooltipBodyToken,"")))},Q=e=>{for(const t of e.source?.xml?[e.source.xml]:Object.values(e.source?.attributes??{}))for(const[,o]of t.matchAll(be))X.some(s=>s.id===o)||l.push(`${e.id}: references label ${o}, which neither the XML nor the loaded ribbon defines — add its <LocLabel>, or its text won't show unless another solution defines it (the pre-publish check warns).`)},$e=e=>({titleToken:e.getAttribute("Title")??void 0,attributes:st(e)}),Ae=(e,t)=>(Ye(e,{origin:"unmanaged"}),e.hidden=!1,t!==void 0&&!e.source?.attributes.Sequence&&(e.sequence=t),xe(e),Q(e),e),ae=e=>l.push(`${e}: flyout / split buttons and their menus can't be imported yet (#27).`),Oe=(e,t)=>{const o=new Set(Array.from(e.querySelectorAll("Menu *")).map(n=>n.getAttribute("Id")).filter(n=>!!n)),s=[];for(const n of t?.buttons??[])o.has(n.id)||(me.has(n.kind)?ae(n.id):s.push(Ae(n)));return s},ee=(e,t)=>{const o=e.findIndex(s=>s.sequence>t.sequence);e.splice(o<0?e.length:o,0,t)},we=(e,t,o)=>{const s=K(e),n=ye(t);if(!s||!n)return!1;xe(n),Q(n),R(s.location,e);for(const{group:u,button:a}of s.found){if(n.kind!==a.kind)return l.push(`${e}: changing a <${t.tagName}> into another kind of control isn't supported.`),!0;if(me.has(a.kind))return ae(e),!0;const p=JSON.parse(JSON.stringify(a));Object.assign(a,{label:n.label,tooltipTitle:n.tooltipTitle,tooltipBody:n.tooltipBody,icon:n.icon,image16:n.image16,image32:n.image32,commandId:n.commandId,templateAlias:n.templateAlias||a.templateAlias,source:structuredClone(n.source)});const f=n.source?.attributes.Sequence?n.sequence:o;f!==void 0&&f!==a.sequence&&(a.origin==="unmanaged"?(u.buttons.splice(u.buttons.indexOf(a),1),a.sequence=f,ee(u.buttons,a)):l.push(`${e}: Sequence ${f} not applied — only your own buttons can be re-ordered.`)),Je(p,a)||p.sequence!==a.sequence?(v=!0,S.push(`Updated ${a.label} (${e}) on ${s.location}`),n.templateAlias||A.push(`${e}: the override has no TemplateAlias — ${a.templateAlias} from the loaded control is kept.`)):(Object.assign(a,p),je(p.source?.attributes,n.source?.attributes)?F++:l.push(`${e}: the override only changes attributes CBS doesn't publish yet (label, tooltip, icon, command and template alias are).`))}return!0},Ce=(e,t,o,s)=>{const n=t.getAttribute("Id");if(!n)return l.push(`CustomAction ${e.getAttribute("Id")}: the control has no Id.`);const u=K(n);if(u){u.found.some(f=>f.group.id===o)||l.push(`${n}: already in group ${u.found[0].group.id} — updated there, not moved to ${o}.`),we(n,t,s)&&P(e.getAttribute("Id"),`${n}.Override.CustomAction`);return}const a=J(o);if(!a)return V(`${n}`,e.getAttribute("Location")??"");const p=ye(t);if(!p)return l.push(`${n}: couldn't read the <${t.tagName}>.`);if(me.has(p.kind))return ae(n);ee(a.group.buttons,Ae(p,s)),R(a.location,n),P(e.getAttribute("Id"),`${n}.CustomAction`),v=!0,S.push(`Added ${p.label} (${n}) to ${a.group.id} on ${a.location}`)},Se=(e,t)=>{const o=re(`<Tab Id="${Le}"><Groups>${Z(e)}</Groups></Tab>`)?.groups[0];if(!o)return;const s=$e(e);return Q({id:o.id,source:s}),{...o,label:M(s.titleToken,o.id),source:s,sequence:e.getAttribute("Sequence")===null?t??o.sequence:o.sequence,buttons:Oe(e,o)}},Xe=(e,t,o,s)=>{const n=t.getAttribute("Id");if(!n)return l.push(`CustomAction ${e.getAttribute("Id")}: the group has no Id.`);if(J(n)){l.push(`Group ${n} already exists — it was left as is (re-titling groups isn't supported).`);for(const f of U(t.querySelector(":scope > Controls")))pe.has(f.tagName)?Ce(e,f,n,void 0):Ue(_e[f.tagName])&&l.push(`${f.getAttribute("Id")??"(no Id)"}: adding a <${f.tagName}> to an existing group isn't supported — Command Bar Studio shows it read-only.`);return}const a=Y(o);if(!a)return V(`Group ${n}`,e.getAttribute("Location")??"");const p=Se(t,s);if(!p)return l.push(`Group ${n}: couldn't read the <Group>.`);ee(a.tab.groups,p),R(a.location,n),P(e.getAttribute("Id"),`${n}.CustomAction`),v=!0,S.push(`Added group ${p.label} (${n}) with ${p.buttons.length} control(s) to ${o} on ${a.location}`)},ke=(e,t,o)=>{const s=t.getAttribute("Id");if(!s)return l.push(`CustomAction ${e.getAttribute("Id")}: the tab has no Id.`);if(Y(s))return l.push(`Tab ${s} already exists — it was left as is.`);const n=re(Z(t));if(!n)return l.push(`Tab ${s}: couldn't read the <Tab>.`);const u=n.tabDisplayRules.flatMap(D=>D.rules.map(Te=>Te.kind==="EntityRule"?rt(Te.context):void 0)),a=T?"Application":u.find(D=>!!D)??he.exec(s)?.[1]??I,f=Array.from(t.querySelectorAll(":scope > Groups > Group")).map(D=>Se(D,void 0)).filter(D=>!!D),y=$e(t);Q({id:s,source:y});const x={...n,label:M(y.titleToken,s),source:y,sequence:t.getAttribute("Sequence")===null?o??n.sequence:n.sequence,groups:f};ee(j[a].tabs,x),P(e.getAttribute("Id"),`${s}.CustomAction`),x.commandId&&(r.add(x.commandId),L.out.some(D=>D.id===x.commandId)||(L.out.push({id:x.commandId,enableRules:[],displayRules:[],actions:[]}),L.changedIds.push(x.commandId),A.push(`Tab ${s}: its Command ${x.commandId} has no CommandDefinition in the XML — an empty one was added.`))),v=!0,S.push(`Added tab ${x.label} (${s}) with ${f.length} group(s) to ${a}`),t.querySelector(":scope > Scaling > Scale")&&l.push(`Tab ${s}: its <Scale> steps weren't imported — CBS writes a default MaxSize for each group.`)},Ge=e=>{const t=e.getAttribute("Location")??"",o=K(t);if(o){const s=o.found.filter(n=>!n.button.hidden);for(const n of s)n.button.hidden=!0;s.length>0?(R(o.location,t),P(e.getAttribute("HideActionId"),`${t}.HideAction`),v=!0,S.push(`Hid ${s[0].button.label} (${t}) on ${o.location}`)):F++;return}if(J(t)||Y(t))return l.push(`Hiding ${t}: hiding whole groups or tabs isn't supported yet — hide their buttons.`);l.push(`Hiding ${t}: not found in the loaded ribbon (it may belong to another table, or already be hidden by your customizations).`)},Me=e=>{const t=e.getAttribute("Id")??"(no Id)",o=e.getAttribute("Location")??"",s=e.getAttribute("Sequence"),n=s===null?void 0:parseInt(s,10),u=U(e.querySelector(":scope > CommandUIDefinition"))[0];if(!u)return l.push(`CustomAction ${t}: no <CommandUIDefinition> content.`);const a=u.tagName;if(o.endsWith(Ie)){const p=o.slice(0,-Ie.length);return p.endsWith(".Controls")&&pe.has(a)?Ce(e,u,p.slice(0,-9),n):p.endsWith(".Groups")&&a==="Group"?Xe(e,u,p.slice(0,-7),n):p==="Mscrm.Tabs"&&a==="Tab"?ke(e,u,n):p.endsWith(".Scaling")&&(a==="MaxSize"||a==="Scale")?l.push(`CustomAction ${t}: <${a}> scaling isn't imported — CBS writes a default MaxSize for each new group.`):l.push(`CustomAction ${t}: a <${a}> at "${o}" isn't supported.`)}if(pe.has(a)&&u.getAttribute("Id")===o){if(we(o,u,n)){P(t,`${o}.Override.CustomAction`);return}return V(`Override ${t}`,o)}return K(o)||J(o)||Y(o)?l.push(`CustomAction ${t}: replacing ${o} with a <${a}> isn't supported — only overriding a control with the same Id is.`):V(`CustomAction ${t}`,o)},Be=U($.querySelector(":scope > CustomActions"));for(const e of Be)e.tagName==="CustomAction"?Me(e):e.tagName==="HideCustomAction"?Ge(e):l.push(`<${e.tagName}> in CustomActions isn't supported.`);const te=new Set;for(const e of ue)for(const t of j[e].tabs)for(const o of t.groups)for(const s of o.buttons)for(const n of We(s))te.add(n);for(const e of r)te.add(e);const le=new Set,ce=new Set;for(const e of L.out)if(te.has(e.id)){e.enableRules.forEach(t=>le.add(t)),e.displayRules.forEach(t=>ce.add(t));for(const t of e.rawRuleRefs??[]){const o=ot.exec(t.xml);o&&(o[1]==="EnableRule"?le:ce).add(o[2])}}const oe=(e,t,o,s)=>{for(const n of e)t.has(n)||l.push(`${o} ${n} was imported but ${s}, so it won't be published.`)};oe(L.changedIds,te,"Command","no button on the loaded ribbon uses it"),oe(z.changedIds,le,"Enable rule","no command a button uses references it"),oe(N.changedIds,ce,"Display rule","no command a button uses references it");const Re=new Set(Array.from(Z($).matchAll(be),e=>e[1]));for(const e of ue)for(const t of j[e].tabs)for(const o of t.groups)for(const s of o.buttons)for(const n of Object.values(s.source?.attributes??{}))for(const u of n.matchAll(be))Re.add(u[1]);oe(C.changedIds,Re,"Label","nothing references it");const qe=Array.from($.querySelectorAll(":scope > RuleDefinitions > TabDisplayRules > TabDisplayRule"));for(const e of qe){const t=e.getAttribute("TabCommand")??"";r.has(t)||l.push(`TabDisplayRule for ${t}: only the display rules of tabs this import adds are imported.`);const o=U(e).filter(s=>s.tagName!=="EntityRule"&&s.tagName!=="PageRule");o.length>0&&l.push(`TabDisplayRule for ${t}: ${o.map(s=>`<${s.tagName}>`).join(", ")} not imported — only EntityRule and PageRule are supported.`)}ie.length>0&&A.push(`Ids normalised: CBS publishes CustomAction / HideCustomAction ids as {control}.CustomAction, {control}.Override.CustomAction and {control}.HideAction, so ${ie.join(", ")} will be written under those ids.`),q+F>0&&S.push(`${q+F} control(s) / definition(s) were already up to date`);const He=v||L.changedIds.length+z.changedIds.length+N.changedIds.length+C.changedIds.length>0;return{ribbons:v?j:i.ribbons,commands:L.out,enableRules:z.out,displayRules:N.out,locLabels:X,applied:S,notApplied:l,notes:A,changed:He}}function lt(i,b){const d=Ze.getState(),m=at({xml:i,ribbons:d.ribbons,commands:d.commands,enableRules:d.enableRules,displayRules:d.displayRules,locLabels:d.locLabels,entityLogicalName:De.getState().activeEntity?.logicalName??d.ribbons.HomepageGrid.entityLogicalName,activeLocation:Qe.getState().location,languageCode:d.baseLanguageCode});return b&&m.changed&&d.applyImport(m,`${m.applied.length} change(s)`),m}const ct=Pe({content:{display:"grid",gridTemplateColumns:"1.4fr 1fr",gap:E.spacingHorizontalL,height:"min(560px, calc(100vh - 240px))",minHeight:"320px",overflowY:"hidden","@media (max-width: 760px)":{gridTemplateColumns:"1fr",gridTemplateRows:"minmax(240px, 1.4fr) 1fr",overflowY:"auto"}},editorColumn:{display:"flex",flexDirection:"column",gap:E.spacingVerticalXS,minHeight:0,minWidth:0},editor:{flex:1,minHeight:"200px",border:`1px solid ${E.colorNeutralStroke2}`,borderRadius:E.borderRadiusMedium,overflow:"hidden"},muted:{color:E.colorNeutralForeground3},results:{display:"flex",flexDirection:"column",gap:E.spacingVerticalM,minHeight:0,minWidth:0,overflowY:"auto",paddingRight:E.spacingHorizontalXS},section:{display:"flex",flexDirection:"column",gap:E.spacingVerticalXS},list:{listStyleType:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:E.spacingVerticalXS},row:{display:"flex",alignItems:"flex-start",gap:E.spacingHorizontalS,minWidth:0},rowBadge:{flexShrink:0,marginTop:"2px"},rowText:{minWidth:0,overflowWrap:"anywhere"},problemButton:{textAlign:"start",justifyContent:"flex-start",minWidth:0,height:"auto",padding:0,fontWeight:E.fontWeightRegular}});function fe(i){return/^Added\b|\badded$/.test(i)?"Add":/^Updated\b|\bupdated$/.test(i)?"Update":/^Hid\b/.test(i)?"Hide":null}const dt={Add:"success",Update:"brand",Hide:"informative"};function ut(i,b,d){const m=i.map(h=>{const $=h.lineHint?Number(/\d+/.exec(h.lineHint)?.[0]):void 0;return{severity:h.severity==="warning"?"warning":"error",text:h.message,line:Number.isFinite($)?$:void 0}});d&&m.push({severity:"error",text:d});for(const h of b?.notApplied??[])m.push({severity:"warning",text:h});return m}const se=(i,b)=>`${i} ${b}${i===1?"":"s"}`,$t=()=>{const i=ct(),b=ne(r=>r.importXmlOpen),d=ne(r=>r.importXmlSeed),m=ne(r=>r.importXmlNote),h=ne(r=>r.closeImportXml),$=De(r=>r.activeEntity?.displayName??r.activeEntity?.logicalName),[w,G]=W.useState(""),[S,l]=W.useState([]),[A,O]=W.useState(null),[T,I]=W.useState(""),B=W.useRef(null);W.useEffect(()=>{b&&(G(d),l([]),O(null),I(""))},[b,d]);const H=r=>{G(r),A?.imported||(O(null),l([]),I(""))},L=r=>{const g=et(w);if(l(g),I(""),g.some(R=>R.severity!=="warning")){O(null);return}try{O({result:lt(w,r),imported:r})}catch(R){O(null),I(R instanceof Error?R.message:String(R))}},z=r=>{const g=B.current;g&&(g.revealLineInCenter(r),g.setPosition({lineNumber:r,column:1}),g.focus())},N=A?.imported===!0,C=A?.result,X=C?.applied??[],q=ut(S,C,T),M=q.some(r=>r.severity==="error"),j=!!C||S.length>0||!!T,v=C&&!N?X.filter(r=>fe(r)).length:0,F=N?C.changed?`Imported ${se(X.filter(r=>fe(r)).length,"change")}`:"Nothing to import: the session already has all of it":j?`Preview · ${se(v,"change")}, ${se(q.length,"problem")}`:"Preview";return c.jsxs(Ve,{open:b,onOpenChange:r=>!r&&h(),title:"Import RibbonDiffXml",size:"large",contentClassName:i.content,actions:N?c.jsx(_,{appearance:"primary",onClick:h,children:"Close"}):c.jsxs(c.Fragment,{children:[c.jsx(_,{onClick:h,children:"Cancel"}),c.jsx(_,{onClick:()=>L(!1),disabled:!w.trim(),children:j?"Preview again":"Preview"}),c.jsx(_,{appearance:"primary",onClick:()=>L(!0),disabled:!w.trim()||M,children:v>0?`Import ${se(v,"change")}`:"Import"})]}),children:[c.jsxs("div",{className:i.editorColumn,children:[c.jsx(k,{weight:"semibold",id:"import-xml-label",children:"Paste RibbonDiffXml"}),c.jsxs(de,{className:i.muted,children:["From Ribbon Workbench or a solution's customizations.xml. Only"," ",$??"this table","'s part is used."]}),c.jsx("div",{className:i.editor,role:"group","aria-labelledby":"import-xml-label",children:c.jsx(tt,{language:"xml",value:w,onChange:H,readOnly:N,height:"100%",onMount:r=>{B.current=r},options:{wordWrap:"on",lineNumbers:"on",padding:{top:8}}})})]}),c.jsxs("section",{className:i.results,"aria-label":"Preview",children:[c.jsx(k,{weight:"semibold",role:"status",children:F}),!j&&c.jsxs(c.Fragment,{children:[m&&!w&&c.jsx(ze,{intent:"info",children:c.jsx(Fe,{children:m})}),c.jsx(k,{className:i.muted,children:"Preview shows what the import changes, and any problems, before anything changes. Commands, rules and labels are added or replaced by ID; buttons, groups and tabs are added to the ribbon; overrides and hides change the existing controls. The import is one change: Undo takes it all back."})]}),q.length>0&&c.jsxs("div",{className:i.section,children:[c.jsx(k,{weight:"semibold",children:"Problems"}),c.jsx("ul",{className:i.list,"aria-label":"Problems",children:q.map((r,g)=>c.jsxs("li",{className:i.row,children:[c.jsx(Ne,{className:i.rowBadge,size:"medium",appearance:"tint",color:r.severity==="error"?"danger":"warning",children:r.severity==="error"?"Error":"Warning"}),r.line?c.jsx(_,{appearance:"transparent",className:i.problemButton,onClick:()=>z(r.line),children:c.jsxs("span",{className:i.rowText,children:["Line ",r.line,": ",r.text]})}):c.jsx(k,{className:i.rowText,children:r.text})]},g))}),!M&&!N&&v>0&&C.notApplied.length>0&&c.jsx(de,{className:i.muted,children:"Warnings don't stop the import: they say what won't be imported or published."})]}),X.length>0&&c.jsxs("div",{className:i.section,children:[c.jsx(k,{weight:"semibold",children:N?"Imported":"Changes"}),c.jsx("ul",{className:i.list,"aria-label":"Changes",children:X.map((r,g)=>{const R=fe(r);return c.jsxs("li",{className:i.row,children:[R&&c.jsx(Ne,{className:i.rowBadge,size:"medium",appearance:"tint",color:dt[R],children:R}),c.jsx(k,{className:i.rowText,children:r})]},g)})})]}),C&&C.notes.length>0&&c.jsxs("div",{className:i.section,children:[c.jsx(k,{weight:"semibold",children:"Good to know"}),c.jsx("ul",{className:i.list,children:C.notes.map((r,g)=>c.jsx("li",{children:c.jsx(k,{className:i.rowText,children:r})},g))})]}),N&&C.changed&&c.jsx(de,{className:i.muted,children:"Review the changes on the canvas, then publish. Undo takes the whole import back."})]})]})};export{$t as ImportXmlModal,$t as default};
@@ -1 +0,0 @@
1
- import{r as B,j as e,F as j,ar as K,as as T,k as v}from"./fluent-ui-CQyNN9H3.js";import{b as C,a as i,a2 as b,S as p,Z as _,t as q,a3 as z,G as D}from"./index-DRTwBo4g.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";const H=()=>{const n=C(t=>t.newButtonGroupId),r=C(t=>t.closeNewButton),I=i(t=>t.createButton),w=i(t=>t.upsertCommand),y=i(t=>t.batch),N=b(t=>t.selectButtonInContext),E=p(t=>t.publisherPrefix),R=p(t=>t.activeSolution),s=b(t=>t.location),k=b(t=>t.tabId),F=p(t=>t.activeEntity),L=n!==null,[c,m]=B.useState("New Button"),[f,h]=B.useState("button"),P=()=>{if(!n||!s)return;const t=R?.publisherPrefix?.trim()||E?.trim()||"new",a=F?.logicalName??"global",l=i.getState().ribbons,A=i.getState().commands,x=new Set(A.map(o=>o.id));for(const o of Object.values(l))for(const d of o.tabs)for(const G of d.groups)for(const O of q(G))x.add(O.id);const{id:g,commandId:S}=z(t,a,s,c,x),u=l[s].tabs.find(o=>o.groups.some(d=>d.id===n))?.id??k;if(!l[s].tabs.some(o=>o.id===u)){D.getState().logError("canvas",`Could not add the button: group ${n} was not found.`),r();return}y(()=>{I({location:s,tabId:u,groupId:n,button:{id:g,label:c,kind:f,templateAlias:"o1",commandId:S,hidden:!1,oob:!1,custom:!0,managed:!1}}),w({id:S,enableRules:[],displayRules:[],actions:[]})}),N(s,u,n,g),m("New Button"),h("button"),r()};return e.jsxs(_,{open:L,onOpenChange:t=>!t&&r(),size:"small",title:"New button",actions:e.jsxs(e.Fragment,{children:[e.jsx(v,{appearance:"secondary",onClick:r,children:"Cancel"}),e.jsx(v,{appearance:"primary",onClick:P,disabled:!c.trim(),children:"Create button"})]}),children:[e.jsx(j,{label:"Label",required:!0,hint:"A command is created with it; edit it in the command editor.",children:e.jsx(K,{value:c,onChange:(t,a)=>m(a.value),"data-autofocus":!0})}),e.jsx(j,{label:"Kind",children:e.jsxs(T,{value:f,onChange:(t,a)=>h(a.value),children:[e.jsx("option",{value:"button",children:"Button"}),e.jsx("option",{value:"flyout",children:"Flyout"}),e.jsx("option",{value:"splitButton",children:"Split button"})]})})]})};export{H as NewButtonModal,H as default};
@@ -1 +0,0 @@
1
- import{r as u,j as a,F as m,ar as G,as as g,k as d}from"./fluent-ui-CQyNN9H3.js";import{b,a as T,a2 as h,Z as C,a4 as S}from"./index-DRTwBo4g.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";const s="Mscrm.Templates.Flexible2",F=()=>{const x=b(e=>e.newGroupOpen),t=b(e=>e.closeNewGroup),j=T(e=>e.createGroup),n=h(e=>e.location),l=h(e=>e.tabId),[o,c]=u.useState("New Group"),[p,i]=u.useState(s),w=()=>{!n||!l||(j({location:n,tabId:l,group:{label:o,template:p,buttons:[]}}),c("New Group"),i(s),t())};return a.jsxs(C,{open:x,onOpenChange:e=>!e&&t(),size:"small",title:"New group",actions:a.jsxs(a.Fragment,{children:[a.jsx(d,{appearance:"secondary",onClick:t,children:"Cancel"}),a.jsx(d,{appearance:"primary",onClick:w,disabled:!o.trim(),children:"Create group"})]}),children:[a.jsx(m,{label:"Label",required:!0,children:a.jsx(G,{value:o,onChange:(e,r)=>c(r.value),"data-autofocus":!0})}),a.jsx(m,{label:"Group template",hint:"How the group's buttons shrink when the classic ribbon is narrow. Unified Interface ignores it.",children:a.jsx(g,{value:p,onChange:(e,r)=>i(r.value),children:S.map(e=>a.jsxs("option",{value:e,children:[e.replace(/^Mscrm\.Templates\./,""),e===s?" (recommended)":""]},e))})})]})};export{F as NewGroupModal,F as default};
@@ -1 +0,0 @@
1
- import{r as T,W as D,j as a,F as x,ar as y,I as M,k as f,m as O,t as _}from"./fluent-ui-CQyNN9H3.js";import{a2 as F,a as l,S as w,b as S,a5 as L,a6 as R,a7 as z,Z as U,I as $,a8 as H}from"./index-DRTwBo4g.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";const j={HomepageGrid:"home grid",Form:"form",SubGrid:"sub-grid",Application:""},B=O({body:{display:"flex",flexDirection:"column",gap:_.spacingHorizontalM}}),P=()=>{const v=B(),[o,b]=T.useState("New Tab"),[d,u]=T.useState(""),s=F(e=>e.location),N=l(e=>e.createTab),i=l(e=>e.ribbons),p=l(e=>e.baseline),h=l(e=>e.layers),C=w(e=>e.activeEntity);w(e=>e.publisherPrefix);const A=S(e=>e.newTabOpen),r=S(e=>e.closeNewTab),m=D.useMemo(()=>L({baseline:p,layers:h},i),[p,h,i]),k=s==="Application"?"global":C?.logicalName??i[s].entityLogicalName,g=R(k,`${s}.${o}`,"Tab",m),t=d.trim(),n=t?z(t)??(/[^a-zA-Z0-9._]/.test(t)?"Use letters, digits, dots and underscores only":m.has(t)?"This ID is already used":null):null,I=t||g,E=()=>{n||(N(s,{id:I,label:o,tabDisplayRules:[],groups:[]}),b("New Tab"),u(""),r())};return a.jsx(U,{open:A,onOpenChange:e=>!e&&r(),size:"small",title:s==="Application"?"New tab":`New tab on the ${j[s]}`,actions:a.jsxs(a.Fragment,{children:[a.jsx(f,{appearance:"secondary",onClick:r,children:"Cancel"}),a.jsx(f,{appearance:"primary",disabled:!o.trim()||!!n,onClick:E,children:"Create tab"})]}),children:a.jsxs("div",{className:v.body,children:[a.jsx(x,{label:"Tab label",required:!0,hint:s==="Application"?"A tab shows only where a tab rule allows it: add one in Tab rules before publishing.":`It gets a tab rule for this table's ${j[s]}; change it in Tab rules.`,children:a.jsx(y,{value:o,onChange:(e,c)=>b(c.value),placeholder:"My Tab","data-autofocus":!0})}),a.jsx(x,{label:"Tab ID",hint:"Leave blank to generate one from the label.",validationState:n?"error":"none",validationMessage:n??void 0,children:a.jsx(y,{value:d,onChange:(e,c)=>u(c.value),placeholder:g})}),a.jsx($,{label:"ID it gets",value:I}),a.jsx(M,{size:"small",info:H,children:"How Unified Interface shows a new tab"})]})})};export{P as NewTabModal,P as default};
@@ -1 +0,0 @@
1
- import{r as V,dD as le,j as a,dP as te,I as W,dX as w,k as D,m as z,t as o,W as re,c as _,B as se,T as ie,l as oe,F as b,eQ as P,ar as j,C as ce,d as ue,as as de,P as K,q,at as Q,x as Y,e8 as pe,M as he,K as me,dC as ge,Q as xe,R as ye,X as H,cD as ve,cB as be,dB as Re}from"./fluent-ui-CQyNN9H3.js";import{b as F,a as M}from"./index-DRTwBo4g.js";import{R as fe,i as Ce,a as L}from"./ruleKinds-BKTUiZ1-.js";import{C as je}from"./CrmParameterEditor-DO6Rt764.js";import{u as Se}from"./useStableKeys-49o4VnxU.js";import{D as Te,c as Ne,S as $e,v as Oe,f as Ee,C as ke,g as we}from"./dnd-iy5K5XAJ.js";import"./preload-helper-PPVm8Dsz.js";import"./crmParameters-rgfZhhzN.js";const Ie=z({root:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS},searchRow:{display:"flex",alignItems:"center",gap:o.spacingHorizontalS,marginBottom:o.spacingVerticalXS},search:{flex:1,minWidth:0},group:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXXS},groupLabel:{color:o.colorNeutralForeground3,fontWeight:o.fontWeightSemibold,paddingTop:o.spacingVerticalXS},kindButton:{justifyContent:"flex-start",textAlign:"left"}});function Pe(e){switch(e){case"CommandClientTypeRule":return{kind:e,type:"Modern"};case"CrmClientTypeRule":return{kind:e,type:"Web"};case"FormStateRule":return{kind:e,state:"Existing"};case"FormTypeRule":return{kind:e,type:"Main"};case"SelectionCountRule":return{kind:e,minimum:1};case"EntityRule":return{kind:e};case"CustomRule":return{kind:e,library:"$webresource:",functionName:""};case"ValueRule":return{kind:e,field:"",value:""};case"SkuRule":return{kind:e,sku:"Online"};case"OrRule":return{kind:e,groups:[[{kind:"FormStateRule",state:"Existing"}],[{kind:"FormStateRule",state:"Create"}]]};case"FeatureControlRule":return{kind:e,featureControlBit:"",expectedValue:!0};case"OrganizationSettingRule":return{kind:e,setting:"IsSharepointEnabled"};case"EntityPrivilegeRule":return{kind:e,privilegeType:"Read",privilegeDepth:"Basic"};case"EntityPropertyRule":return{kind:e,propertyName:"IsCustomizable",propertyValue:!0};case"RecordPrivilegeRule":return{kind:e,privilegeType:"Read"};case"RelationshipTypeRule":return{kind:e,appliesTo:"SelectedEntity"};case"MiscellaneousPrivilegeRule":return{kind:e,privilegeName:"ExportToExcel"};case"FormEntityContextRule":return{kind:e,entityName:""};case"PageRule":return{kind:e,address:""};case"CrmOfflineAccessStateRule":return{kind:e,state:"Online"};case"CrmOutlookClientTypeRule":return{kind:e,type:"CrmForOutlook"};case"CrmOutlookClientVersionRule":return{kind:e,major:15,minor:0,build:0,revision:0};case"DeviceTypeRule":return{kind:e,type:"Web"};case"OptionSetRule":return{kind:e,optionSet:"",stateCode:"",objectTypeCode:""};case"OutlookItemTrackingRule":return{kind:e,trackedInCrm:!0};case"OutlookRenderTypeRule":return{kind:e,type:"Web"};case"OutlookVersionRule":return{kind:e,version:"2010"};case"HideForTabletExperienceRule":return{kind:e};case"ReferencingAttributeRequiredRule":return{kind:e};default:return{kind:e}}}const Z=({onSelect:e,container:t,insideOr:u=!1})=>{const c=Ie(),[g,f]=V.useState(""),i=le({axis:"vertical"}),x=fe.map(h=>({...h,kinds:h.kinds.filter(m=>{if(t&&!Ce(m,t,u)||u&&m==="OrRule")return!1;const O=L[m]??m;return!g||O.toLowerCase().includes(g.toLowerCase())||m.toLowerCase().includes(g.toLowerCase())})})).filter(h=>h.kinds.length>0);return a.jsxs("div",{className:c.root,children:[a.jsxs("div",{className:c.searchRow,children:[a.jsx(te,{className:c.search,placeholder:"Search steps","aria-label":"Search steps",value:g,onChange:(h,m)=>f(m.value)}),a.jsx(W,{info:"Show on grid or quick action comes from Microsoft's rules (Mscrm.ShowOnGrid, Mscrm.ShowOnQuickAction): add them to the command by ID instead.",children:a.jsx("span",{className:c.groupLabel,children:"Not here?"})})]}),a.jsxs("div",{role:"group","aria-label":"Kinds of step",...i,children:[x.map(h=>a.jsxs("div",{className:c.group,children:[a.jsx(w,{className:c.groupLabel,children:h.label}),h.kinds.map(m=>a.jsx(D,{appearance:"subtle",className:c.kindButton,onClick:()=>e(Pe(m)),children:L[m]??m},m))]},h.label)),x.length===0&&a.jsx(w,{children:"No kind of step matches."})]})]})},J=z({step:{display:"flex",flexDirection:"column",minWidth:0,gap:o.spacingVerticalXS,padding:o.spacingVerticalS,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium,backgroundColor:o.colorNeutralBackground2},header:{display:"flex",alignItems:"center",gap:o.spacingHorizontalXS},title:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:o.spacingHorizontalXS},kindBadge:{flexShrink:0},fields:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,minWidth:0},row:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:o.spacingHorizontalS,alignItems:"end",minWidth:0,"& > *":{minWidth:0,gridTemplateColumns:"minmax(0, 1fr)"},"& select":{minWidth:0}},number:{maxWidth:"140px"},muted:{color:o.colorNeutralForeground3},nested:{display:"flex",flexDirection:"column",gap:o.spacingVerticalXS,paddingLeft:o.spacingHorizontalM,borderLeft:`2px solid ${o.colorBrandStroke2}`},nestedToolbar:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:o.spacingHorizontalXS},pickerSurface:{minWidth:"300px",maxHeight:"50vh",overflowY:"auto",padding:o.spacingVerticalS}}),G=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/^Is /,"").toLowerCase().replace(/^./,t=>t.toUpperCase()),k=[["PrimaryEntity","Primary table (the form or grid)"],["SelectedEntity","Selected records"]],Ae=[["Form","Form"],["HomePageGrid","Home page grid"],["SubGridStandard","Sub-grid"],["SubGridAssociated","Associated grid"]],De=[["Create","New record"],["Existing","Existing record"],["ReadOnly","Read-only"],["Disabled","Disabled"],["BulkEdit","Bulk edit"]],Fe=[["Main","Main"],["Preview","Preview"],["AppointmentBook","Appointment book"],["Dashboard","Dashboard"],["Quick","Quick view"],["QuickCreate","Quick create"],["Card","Card"],["MainInteractionCentric","Main (interactive experience)"]],Me=[["None","None"],["Phone","Phone"],["Tablet","Tablet"],["Web","Web"],["Outlook","Outlook"],["InteractionCentric","Interactive experience"]],X=[["Create","Create"],["Read","Read"],["Write","Write"],["Delete","Delete"],["Assign","Assign"],["Share","Share"],["Append","Append"],["AppendTo","Append to"]],U=[["None","None"],["Basic","User (Basic)"],["Local","Business unit (Local)"],["Deep","Parent: child business units (Deep)"],["Global","Organization (Global)"]],_e=["DuplicateDetectionEnabled","GridFiltersEnabled","HasStateCode","IsConnectionsEnabled","MailMergeEnabled","WorksWithQueue","HasActivities","IsActivity","HasNotes","IsCustomizable","IsActivityParty","HasEmailAddresses","IsChildEntity","IsImportable","IsEnabledForCharts","IsBusinessProcessEnabled","HasFeedback","IsBPFEntity"],Ve=["IsSharepointEnabled","IsSOPIntegrationEnabled","IsFiscalCalendarDefined","IsReadFormModeDefined","IsBPFEntityCustomizationFeatureEnabled"],Le=["ExportToExcel","MailMerge","GoOffline","OfflineSynchronize","PublishReports"];function p({label:e,info:t,value:u,choices:c,anyLabel:g,disabled:f,onChange:i}){return a.jsx(b,{label:t?{children:(x,h)=>a.jsx(W,{...h,info:t,children:e})}:e,children:a.jsxs(de,{value:u??"",disabled:f,onChange:(x,h)=>i(h.value||void 0),children:[g!==void 0&&a.jsx("option",{value:"",children:g}),c.map(([x,h])=>a.jsx("option",{value:x,children:h},x))]})})}function A({label:e,value:t,required:u,min:c=0,onChange:g}){const f=J();return a.jsx(b,{label:e,children:a.jsx(pe,{className:f.number,min:c,value:t??null,onChange:(i,x)=>{const h=x.displayValue?.trim(),m=x.value!==void 0&&x.value!==null?x.value:h?parseInt(h,10):void 0;if(m===void 0)return u?void 0:g(void 0);Number.isInteger(m)&&m>=c&&g(m)}})})}const ee=({step:e,onChange:t,onRemove:u,container:c,number:g,menu:f})=>{const i=J(),[x,h]=re.useState(null),m=e.kind!=="OrRule"&&e.kind!=="RawRule",O=m?e.invertResult:void 0,E=m?e.default:void 0,y=L[e.kind]??e.kind,l=n=>{t({...e,...n})},T=(n,s)=>a.jsx(b,{label:"Table",hint:"Its logical name; empty for any.",children:a.jsx(j,{value:n??"",onChange:(C,v)=>s(v.value||void 0)})}),I=()=>{switch(e.kind){case"CommandClientTypeRule":return a.jsx(p,{label:"Client",value:e.type,choices:[["Modern","Modern (Unified Interface: web, tablets and phones)"],["Refresh","Refresh (legacy updated web client)"],["Legacy","Legacy (classic ribbon + Outlook list views)"]],onChange:n=>l({type:n})});case"CrmClientTypeRule":return a.jsx(p,{label:"Client",value:e.type,choices:[["Web","Web"],["Outlook","Outlook"]],onChange:n=>l({type:n})});case"FormStateRule":return a.jsx(p,{label:"State",value:e.state,choices:De,onChange:n=>l({state:n})});case"FormTypeRule":return a.jsx(p,{label:"Form type",value:e.type,choices:Fe,onChange:n=>l({type:n})});case"SelectionCountRule":return a.jsxs("div",{className:i.row,children:[a.jsx(A,{label:"At least",value:e.minimum,onChange:n=>l({minimum:n})}),a.jsx(A,{label:"At most",value:e.maximum,onChange:n=>l({maximum:n})}),a.jsx(p,{label:"Applies to",value:e.appliesTo,choices:k,anyLabel:"Any",onChange:n=>l({appliesTo:n})})]});case"EntityRule":return a.jsxs("div",{className:i.row,children:[T(e.entityName,n=>l({entityName:n})),a.jsx(p,{label:"Applies to",value:e.appliesTo,choices:k,anyLabel:"Any",onChange:n=>l({appliesTo:n})}),a.jsx(p,{label:"Where",value:e.context,choices:Ae,anyLabel:"Anywhere",onChange:n=>l({context:n})})]});case"FormEntityContextRule":return a.jsx(b,{label:"The form's table",hint:"Its logical name.",children:a.jsx(j,{value:e.entityName,onChange:(n,s)=>l({entityName:s.value})})});case"CustomRule":return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:i.row,children:[a.jsx(b,{label:"Library",hint:"A JavaScript web resource ($webresource:…).",children:a.jsx(j,{value:e.library,onChange:(n,s)=>l({library:s.value}),placeholder:"$webresource:publisher_/scripts/file.js"})}),a.jsx(b,{label:"Function",hint:"The function's full name, including its namespace.",children:a.jsx(j,{value:e.functionName,onChange:(n,s)=>l({functionName:s.value})})})]}),a.jsx(b,{label:"Parameters, in order",children:a.jsx(je,{params:e.params??[],onChange:n=>l({params:n.length?n:void 0})})}),a.jsx(w,{className:i.muted,children:"In Unified Interface the function can return a Promise of true or false; one that hasn't settled after 10 seconds counts as false."})]});case"CrmOfflineAccessStateRule":return a.jsx(p,{label:"State",value:e.state,choices:[["Online","Online"],["Offline","Offline"]],onChange:n=>l({state:n})});case"CrmOutlookClientTypeRule":return a.jsx(p,{label:"Outlook client",value:e.type,choices:[["CrmForOutlook","Outlook"],["CrmForOutlookOfflineAccess","Outlook with offline access"]],onChange:n=>l({type:n})});case"CrmOutlookClientVersionRule":return a.jsxs("div",{className:i.row,children:[a.jsx(A,{label:"Major",value:e.major,required:!0,onChange:n=>n!==void 0&&l({major:n})}),a.jsx(A,{label:"Minor",value:e.minor,onChange:n=>l({minor:n})}),a.jsx(A,{label:"Build",value:e.build,onChange:n=>l({build:n})}),a.jsx(A,{label:"Revision",value:e.revision,onChange:n=>l({revision:n})})]});case"DeviceTypeRule":return a.jsx(p,{label:"Device",value:e.type,choices:Me,onChange:n=>l({type:n})});case"EntityPrivilegeRule":return a.jsxs("div",{className:i.row,children:[T(e.entityName,n=>l({entityName:n})),a.jsx(p,{label:"Applies to",value:e.appliesTo,choices:k,anyLabel:"Any",onChange:n=>l({appliesTo:n})}),a.jsx(p,{label:"Privilege",value:e.privilegeType,choices:X,onChange:n=>l({privilegeType:n})}),a.jsx(p,{label:"Depth",value:e.privilegeDepth,choices:U,onChange:n=>l({privilegeDepth:n})})]});case"EntityPropertyRule":return a.jsxs("div",{className:i.row,children:[T(e.entityName,n=>l({entityName:n})),a.jsx(p,{label:"Applies to",value:e.appliesTo,choices:k,anyLabel:"Any",onChange:n=>l({appliesTo:n})}),a.jsx(p,{label:"Property",value:e.propertyName,choices:_e.map(n=>[n,G(n)]),onChange:n=>l({propertyName:n})}),a.jsx(P,{label:"The property is true",checked:e.propertyValue,onChange:(n,s)=>l({propertyValue:s.checked===!0})})]});case"ValueRule":return a.jsxs("div",{className:i.row,children:[a.jsx(b,{label:"Column",hint:"Its logical name.",children:a.jsx(j,{value:e.field,onChange:(n,s)=>l({field:s.value})})}),a.jsx(b,{label:"Equals",children:a.jsx(j,{value:e.value,onChange:(n,s)=>l({value:s.value})})})]});case"OrRule":{const n=C=>t({...e,groups:C.filter(v=>v.length>0)}),s=(C,v)=>a.jsxs(K,{open:x===C,onOpenChange:($,R)=>h(R.open?C:null),positioning:"below-start",children:[a.jsx(q,{children:a.jsx(D,{icon:a.jsx(Q,{}),appearance:"secondary",size:"small",children:v})}),a.jsx(Y,{className:i.pickerSurface,children:a.jsx(Z,{container:c,insideOr:!0,onSelect:$=>{n(C==="new"?[...e.groups,[$]]:e.groups.map((R,N)=>N===C?[...R,$]:R)),h(null)}})})]});return a.jsxs("div",{className:i.nested,children:[e.groups.map((C,v)=>a.jsxs("div",{className:i.nested,children:[a.jsxs(_,{size:200,weight:"semibold",children:[v===0?"Either":"Or",C.length>1?" (all of)":""]}),C.map(($,R)=>a.jsx(ee,{step:$,container:c,onChange:N=>n(e.groups.map((r,d)=>d===v?r.map((S,ne)=>ne===R?N:S):r)),onRemove:()=>n(e.groups.map((N,r)=>r===v?N.filter((d,S)=>S!==R):N))},`${v}-${R}-${$.kind}`)),a.jsx("div",{className:i.nestedToolbar,children:s(v,"And…")})]},v)),a.jsxs("div",{className:i.nestedToolbar,children:[s("new","Add an Or branch"),a.jsx(w,{className:i.muted,children:"An Or needs at least two branches."})]})]})}case"FeatureControlRule":return a.jsxs("div",{className:i.row,children:[a.jsx(b,{label:"Feature control bit",children:a.jsx(j,{value:e.featureControlBit,onChange:(n,s)=>l({featureControlBit:s.value})})}),a.jsx(P,{label:"The bit is set",checked:e.expectedValue,onChange:(n,s)=>l({expectedValue:s.checked===!0})})]});case"RawRule":return a.jsxs(a.Fragment,{children:[a.jsx(w,{className:i.muted,children:"Command Bar Studio doesn't edit this rule; it is kept exactly as loaded."}),a.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"11px"},children:e.xml})]});case"SkuRule":return a.jsx(p,{label:"Deployment",value:e.sku,choices:[["Online","Online"],["OnPremise","On-premises"],["Spla","Hosted (SPLA)"]],onChange:n=>l({sku:n})});case"OrganizationSettingRule":return a.jsx(p,{label:"Setting is on",value:e.setting,choices:Ve.map(n=>[n,G(n)]),onChange:n=>l({setting:n})});case"MiscellaneousPrivilegeRule":return a.jsxs("div",{className:i.row,children:[a.jsx(b,{label:"Privilege",children:a.jsx(ce,{freeform:!0,value:e.privilegeName,placeholder:"ExportToExcel",onChange:n=>l({privilegeName:n.target.value}),onOptionSelect:(n,s)=>s.optionValue&&l({privilegeName:s.optionValue}),children:Le.map(n=>a.jsx(ue,{value:n,children:n},n))})}),a.jsx(p,{label:"Depth",value:e.privilegeDepth,choices:U,anyLabel:"Any",onChange:n=>l({privilegeDepth:n})})]});case"OptionSetRule":return a.jsxs("div",{className:i.row,children:[a.jsx(b,{label:"Choice column",children:a.jsx(j,{value:e.optionSet,onChange:(n,s)=>l({optionSet:s.value})})}),a.jsx(b,{label:"State code",children:a.jsx(j,{value:e.stateCode,onChange:(n,s)=>l({stateCode:s.value})})}),a.jsx(b,{label:"Table type code",children:a.jsx(j,{value:e.objectTypeCode,onChange:(n,s)=>l({objectTypeCode:s.value})})})]});case"OutlookItemTrackingRule":return a.jsxs("div",{className:i.row,children:[a.jsx(P,{label:"The item is tracked",checked:e.trackedInCrm,onChange:(n,s)=>l({trackedInCrm:s.checked===!0})}),a.jsx(p,{label:"Applies to",value:e.appliesTo??"PrimaryEntity",choices:k.slice(0,1),onChange:n=>l({appliesTo:n})})]});case"OutlookRenderTypeRule":return a.jsx(p,{label:"Shown in",value:e.type,choices:[["Web","Web"],["Outlook","Outlook"]],onChange:n=>l({type:n})});case"OutlookVersionRule":return a.jsx(p,{label:"Outlook version",value:e.version,choices:[["2003","2003"],["2007","2007"],["2010","2010"]],onChange:n=>l({version:n})});case"PageRule":return a.jsx(b,{label:"Page address contains",children:a.jsx(j,{value:e.address,onChange:(n,s)=>l({address:s.value}),placeholder:"main.aspx"})});case"RecordPrivilegeRule":return a.jsxs("div",{className:i.row,children:[a.jsx(p,{label:"Privilege",value:e.privilegeType,choices:X,onChange:n=>l({privilegeType:n})}),a.jsx(p,{label:"Applies to",value:e.appliesTo,choices:k.slice(0,1),anyLabel:"The selected record",onChange:n=>l({appliesTo:n})})]});case"RelationshipTypeRule":return a.jsxs("div",{className:i.row,children:[a.jsx(p,{label:"Applies to",value:e.appliesTo,choices:k.slice(1),disabled:!0,onChange:()=>{}}),a.jsx(p,{label:"Relationship",value:e.relationshipType,choices:[["OneToMany","One-to-many"],["ManyToMany","Many-to-many"],["NoRelationship","No relationship"]],anyLabel:"Any",onChange:n=>l({relationshipType:n})}),a.jsx(P,{label:"Custom relationships too",checked:e.allowCustomRelationship===!0,onChange:(n,s)=>l({allowCustomRelationship:s.checked===!0})}),a.jsx(P,{label:"System relationships too",checked:e.allowSystemRelationship===!0,onChange:(n,s)=>l({allowSystemRelationship:s.checked===!0})})]});default:return a.jsx(w,{className:i.muted,children:"Nothing to set for this step."})}};return a.jsxs("div",{className:i.step,children:[a.jsxs("div",{className:i.header,children:[a.jsxs("div",{className:i.title,children:[g!==void 0&&a.jsxs(_,{weight:"semibold",children:[g,"."]}),a.jsx(se,{appearance:"outline",size:"medium",className:i.kindBadge,children:y})]}),f,a.jsx(ie,{content:`Remove ${y} step`,relationship:"label",children:a.jsx(D,{appearance:"subtle",icon:a.jsx(oe,{}),size:"small",onClick:u})})]}),a.jsxs("div",{className:i.fields,children:[I(),m&&a.jsxs("div",{className:i.row,children:[a.jsx(p,{label:"If it can't be evaluated",info:"What the step counts as when it can't be evaluated.",value:E===void 0?void 0:String(E),choices:[["true","Passes"],["false","Fails"]],anyLabel:"Not set",onChange:n=>l({default:n===void 0?void 0:n==="true"})}),a.jsx(b,{hint:"The step passes when its condition is false.",children:a.jsx(P,{label:"Invert result",checked:O===!0,onChange:(n,s)=>l({invertResult:s.checked===!0?!0:void 0})})})]})]})]})};function Be(e){return e.length===0?"No steps defined — a rule needs at least one before it can be published.":e.map(B).join(" AND ")}function B(e){const t="invertResult"in e&&e.invertResult?"NOT ":"";switch(e.kind){case"SelectionCountRule":{const u=e.minimum!==void 0?`at least ${e.minimum}`:null,c=e.maximum!==void 0?`at most ${e.maximum}`:null,g=[u,c].filter(Boolean).join(" and "),f=e.appliesTo?` (${e.appliesTo})`:"";return`${t}Selection count is ${g}${f}`}case"EntityRule":{const u=e.entityName??"any entity",c=e.context?` in ${e.context} context`:"",g=e.appliesTo?` (${e.appliesTo})`:"";return`${t}Entity is "${u}"${c}${g}`}case"FormStateRule":return`${t}Form state is "${e.state}"`;case"CommandClientTypeRule":return`${t}Client type is "${e.type}" (${We(e.type)})`;case"CrmClientTypeRule":return`${t}CRM client type is "${e.type}"`;case"CustomRule":return`${t}Custom rule: ${e.functionName}() from ${e.library}`;case"OrRule":return`(${e.groups.map(c=>c.length===1?B(c[0]):`(${c.map(B).join(" AND ")})`).join(" OR ")})`;case"FeatureControlRule":return`${t}Feature "${e.featureControlBit}" is ${e.expectedValue?"on":"off"}`;case"RawRule":return`${e.tagName} (kept as XML)`;case"MiscellaneousPrivilegeRule":{const u=e.privilegeDepth?` at ${e.privilegeDepth} depth`:"";return`${t}User has "${e.privilegeName}" privilege${u}`}case"EntityPrivilegeRule":{const u=e.entityName?` on "${e.entityName}"`:"",c=e.appliesTo?` (${e.appliesTo})`:"";return`${t}User has ${e.privilegeType} privilege${u} at ${e.privilegeDepth} depth${c}`}case"EntityPropertyRule":{const u=e.entityName?` for "${e.entityName}"`:"";return`${t}Entity property "${e.propertyName}" is ${e.propertyValue}${u}`}case"FormTypeRule":return`${t}Form type is "${e.type}"`;case"FormEntityContextRule":return`${t}Form entity context is "${e.entityName}"`;case"ValueRule":return`${t}Field "${e.field}" equals "${e.value}"`;case"SkuRule":return`${t}SKU is "${e.sku}"`;case"HideForTabletExperienceRule":return`${t}Hide for tablet experience`;case"OrganizationSettingRule":return`${t}Organization setting "${e.setting}" is enabled`;case"PageRule":return`${t}Page address matches "${e.address}"`;case"RecordPrivilegeRule":{const u=e.appliesTo?` (${e.appliesTo})`:"";return`${t}User has ${e.privilegeType} privilege on current record${u}`}case"RelationshipTypeRule":{const u=e.relationshipType??"any";return`${t}Relationship type is "${u}" (${e.appliesTo})`}case"ReferencingAttributeRequiredRule":return`${t}Referencing attribute is required`;case"OutlookItemTrackingRule":return`${t}Outlook item is ${e.trackedInCrm?"":"not "}tracked in CRM`;case"OutlookRenderTypeRule":return`${t}Outlook render type is "${e.type}"`;case"OutlookVersionRule":return`${t}Outlook version is "${e.version}"`;case"CrmOfflineAccessStateRule":return`${t}CRM offline state is "${e.state}"`;case"CrmOutlookClientTypeRule":return`${t}CRM Outlook client type is "${e.type}"`;case"CrmOutlookClientVersionRule":return`${t}CRM Outlook client version is ${e.major}.${e.minor??0}+`;case"DeviceTypeRule":return`${t}Device type is "${e.type}"`;case"OptionSetRule":return`${t}Option set "${e.optionSet}" state code is "${e.stateCode}"`;default:return"Unknown rule step"}}function We(e){switch(e){case"Modern":return"Unified Interface";case"Refresh":return"legacy updated web client";case"Legacy":return"Classic ribbon / Outlook list views";default:return e}}const ae=z({body:{display:"flex",flexDirection:"column",gap:o.spacingVerticalM,minWidth:0},stepsList:{display:"flex",flexDirection:"column",gap:o.spacingVerticalS,listStyle:"none",padding:0,margin:0},muted:{color:o.colorNeutralForeground3},summary:{padding:o.spacingVerticalS,backgroundColor:o.colorNeutralBackground3,borderRadius:o.borderRadiusMedium,color:o.colorNeutralForeground2,fontSize:o.fontSizeBase200},pickerPopover:{maxHeight:"60vh",overflowY:"auto",minWidth:"320px",padding:o.spacingVerticalM},sortableInner:{display:"flex",alignItems:"flex-start",gap:o.spacingHorizontalXS,minWidth:0},dragHandle:{marginTop:o.spacingVerticalXS,cursor:"grab",touchAction:"none"},stepBody:{flex:1,minWidth:0}}),ze=[],Je=()=>{const e=ae(),t=F(r=>r.ruleEditorOpen),u=F(r=>r.ruleEditorId),c=F(r=>r.ruleEditorKind),g=F(r=>r.closeRuleEditor),f=M(r=>r.enableRules),i=M(r=>r.displayRules),x=M(r=>r.upsertEnableRule),h=M(r=>r.upsertDisplayRule),[m,O]=V.useState(!1),E=c==="enable",y=E?f.find(r=>r.id===u):i.find(r=>r.id===u);V.useEffect(()=>{t&&u&&!y&&g()},[t,u,y,g]);const l=Se(`${c}:${y?.id??""}`,y?.steps??ze),T=l.keys;if(!y)return null;const I=r=>{E?x({...y,steps:r}):h({...y,steps:r})},n=(r,d)=>{const S=[...y.steps];S[r]=d,l.update(),I(S)},s=r=>{l.remove(r),I(y.steps.filter((d,S)=>S!==r))},C=r=>{l.add(),I([...y.steps,r]),O(!1)},v=(r,d)=>{r===d||r<0||d<0||d>=y.steps.length||(l.move(r,d),I(we(y.steps,r,d)))},$=r=>{r.over&&v(T.indexOf(String(r.active.id)),T.indexOf(String(r.over.id)))},R=y.steps.length,N=E?"enable":"display";return a.jsxs("div",{className:e.body,children:[E?a.jsx(W,{info:"Enable rules take fewer kinds of step than display rules; Add step only offers the ones they take.",children:"Passes when every step below is true."}):a.jsx(_,{children:"Passes when every step below is true."}),R>0?a.jsx(Te,{collisionDetection:Ne,onDragEnd:$,children:a.jsx($e,{items:T,strategy:Oe,children:a.jsx("ol",{className:e.stepsList,"aria-label":"Rule steps",children:y.steps.map((r,d)=>a.jsx(He,{id:T[d],draggable:R>1,children:a.jsx(ee,{step:r,number:d+1,menu:R>1&&a.jsxs(he,{children:[a.jsx(me,{disableButtonEnhancement:!0,children:a.jsx(D,{appearance:"subtle",size:"small",icon:a.jsx(ge,{}),"aria-label":`More for step ${d+1}`})}),a.jsx(xe,{children:a.jsxs(ye,{children:[a.jsx(H,{icon:a.jsx(ve,{}),disabled:d===0,onClick:()=>v(d,d-1),children:"Move up"}),a.jsx(H,{icon:a.jsx(be,{}),disabled:d===R-1,onClick:()=>v(d,d+1),children:"Move down"})]})})]}),onChange:S=>n(d,S),onRemove:()=>s(d),container:N})},T[d]))})})}):a.jsx(_,{className:e.muted,children:"No steps yet. A rule needs at least one step: add one before you publish, or remove the rule from its commands."}),a.jsx("div",{children:a.jsxs(K,{open:m,onOpenChange:(r,d)=>O(d.open),positioning:"below-start",children:[a.jsx(q,{children:a.jsx(D,{icon:a.jsx(Q,{}),onClick:()=>O(!0),children:"Add step"})}),a.jsx(Y,{className:e.pickerPopover,children:a.jsx(Z,{onSelect:C,container:N})})]})}),R>0&&a.jsxs(a.Fragment,{children:[a.jsx(w,{className:e.muted,children:"In words"}),a.jsx("div",{className:e.summary,role:"note","aria-label":"Rule summary",children:Be(y.steps)})]})]})};function He({id:e,draggable:t,children:u}){const c=ae(),{attributes:g,listeners:f,setNodeRef:i,setActivatorNodeRef:x,transform:h,transition:m}=Ee({id:e,disabled:!t});return a.jsx("li",{ref:i,style:{transform:ke.Transform.toString(h),transition:m},children:a.jsxs("div",{className:c.sortableInner,children:[t&&a.jsx(D,{ref:x,appearance:"subtle",size:"small",className:c.dragHandle,icon:a.jsx(Re,{}),...g,...f,"aria-label":"Drag to reorder step"}),a.jsx("div",{className:c.stepBody,children:u})]})})}export{Je as RuleEditorPanel,Je as default};
@@ -1 +0,0 @@
1
- import{r as n,j as e,a6 as d,a7 as u,dY as B,k as W,m as k,t as l}from"./fluent-ui-CQyNN9H3.js";import{aK as M,aL as N,at as R,ax as D,F as L}from"./index-DRTwBo4g.js";import{M as T}from"./MonacoEditor-DweI16yt.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";const H=k({root:{flex:1,display:"flex",flexDirection:"column",gap:l.spacingVerticalS,minHeight:"300px"},editor:{flex:1,minHeight:"240px",border:`1px solid ${l.colorNeutralStroke2}`,borderRadius:l.borderRadiusMedium,overflow:"hidden"},save:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:l.spacingHorizontalS}}),O=s=>s?new TextDecoder().decode(Uint8Array.from(atob(s),r=>r.charCodeAt(0))):"",U=s=>{const r=new TextEncoder().encode(s);let o="";for(let i=0;i<r.length;i+=1)o+=String.fromCharCode(r[i]);return btoa(o)},V={html:1,css:2,js:3,xml:4,png:5,jpg:6,gif:7,xsl:9,ico:10,svg:11,resx:12},z=s=>V[s.split(".").pop()?.toLowerCase()??""]??3;function K({name:s,editable:r}){const o=H(),[i,S]=n.useState(!0),[p,f]=n.useState(!1),[g,w]=n.useState(!1),[x,c]=n.useState(null),[h,m]=n.useState(null),[y,v]=n.useState(""),[b,j]=n.useState(!1);n.useEffect(()=>{let a=!0;return(async()=>{try{const t=await M(s);if(!a)return;if(!t){w(!0);return}const E=await N(t.id);a&&v(O(E))}catch(t){a&&c(t instanceof Error?t.message:"Couldn't load the script.")}finally{a&&S(!1)}})(),()=>{a=!1}},[s]);const C=async()=>{const a=L();f(!0),c(null),m(null);try{const t=await D(s,U(y),z(s),{displayName:s.split("/").pop(),guard:a});m([t.solutionWarning,t.publishWarning].filter(Boolean).join(" ")||null),j(!1)}catch(t){c(t instanceof Error?t.message:"Couldn't save the script.")}finally{f(!1)}};return e.jsxs("div",{className:o.root,children:[g&&e.jsx(d,{intent:"warning",children:e.jsxs(u,{children:["There's no web resource named ",s," in this environment. Check the action's library."]})}),x&&e.jsx(d,{intent:"error",children:e.jsx(u,{children:x})}),h&&e.jsx(d,{intent:"warning",children:e.jsx(u,{children:h})}),i?e.jsx(B,{size:"small",label:"Loading the script…"}):!g&&e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:o.save,children:[e.jsx(R,{prefix:"Saves to"}),e.jsx(W,{appearance:"primary",disabled:!b||p,onClick:()=>{C()},children:p?"Saving…":"Save script"})]}),e.jsx("div",{className:o.editor,children:e.jsx(T,{language:"javascript",value:y,readOnly:!r,onChange:a=>{v(a),j(!0)},options:{wordWrap:"on"}})})]})]})}export{K as ScriptView,K as default};
@@ -1 +0,0 @@
1
- import{W as C,j as e,c as j,a6 as F,a7 as O,T as V,k as v,aq as z,F as b,as as f,ar as w,M as W,K as $,at as A,Q as I,R as K,X as M,dX as X,m as q,t as o}from"./fluent-ui-CQyNN9H3.js";import{b as Q,a as p,ak as U,aM as J}from"./index-DRTwBo4g.js";import{u as Y}from"./useStableKeys-49o4VnxU.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";function Z(d){return(d??[]).flatMap(r=>r.rules)}const ee=[],P=()=>({kind:"EntityRule",appliesTo:"PrimaryEntity",context:"HomePageGrid"}),se=()=>({kind:"PageRule",address:""}),ae=q({body:{display:"flex",flexDirection:"column",gap:o.spacingVerticalM},muted:{color:o.colorNeutralForeground3},steps:{listStyleType:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:o.spacingVerticalS},step:{display:"flex",flexDirection:"column",gap:o.spacingVerticalS,padding:o.spacingVerticalM,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium},stepHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:o.spacingHorizontalS},fields:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:o.spacingHorizontalS,minWidth:0}}),de=({location:d,tabId:r})=>{const c=ae(),S=Q(s=>s.editorBack),T=p(s=>s.ribbons[d]),D=p(s=>s.setTabDisplayRules),E=p(s=>s.locLabels),B=p(s=>s.baseLanguageCode),G=U(),n=T.tabs.find(s=>s.id===r),m=d==="Application",k=p(s=>!s.baseline[d]?.tabs.some(a=>a.id===r)),N=p(s=>J(s,d)),l=!!n&&!k&&N!==void 0&&!N.includes(r),u=C.useMemo(()=>Z(n?.tabDisplayRules),[n?.tabDisplayRules]),x=Y(`tabRules:${d}:${r}`,n?u:ee),R=!n;if(C.useEffect(()=>{R&&S()},[R,S]),!n)return null;const g=s=>D(d,r,s.length>0?[{tabCommand:n.commandId??"",rules:s}]:[]),h=(s,a)=>{g(u.map((t,i)=>i===s?a:t)),x.update()},y=s=>{g([...u,s]),x.add()},H=s=>{g(u.filter((a,t)=>t!==s)),x.remove(s)},_=s=>[...new Set([T.entityLogicalName,s.entityName].filter(a=>!!a))],L=G(n.label,E,B,n.source?.titleToken)||n.id;return e.jsxs("div",{className:c.body,children:[e.jsxs(j,{children:["Tabs are hidden unless their display rule matches. ",e.jsx("strong",{children:L})," shows where ",e.jsx("strong",{children:"any"})," step below matches."]}),l&&e.jsx(F,{intent:"info",children:e.jsx(O,{children:"Another solution adds this tab, so its display rule can't be changed here."})}),u.length>0?e.jsx("ol",{className:c.steps,"aria-label":"Display rule steps",children:u.map((s,a)=>e.jsxs("li",{className:c.step,children:[e.jsxs("div",{className:c.stepHeader,children:[e.jsxs(j,{weight:"semibold",children:[a+1,". ",s.kind==="PageRule"?"Page":"Table"]}),!l&&e.jsx(V,{content:"Remove step",relationship:"label",children:e.jsx(v,{appearance:"subtle",size:"small",icon:e.jsx(z,{}),onClick:()=>H(a)})})]}),s.kind==="EntityRule"&&e.jsxs("div",{className:c.fields,children:[e.jsx(b,{label:"Applies to",children:e.jsxs(f,{value:s.appliesTo??"",disabled:l,onChange:(t,i)=>h(a,{...s,appliesTo:i.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"PrimaryEntity",children:"Primary entity"}),e.jsx("option",{value:"SelectedEntity",children:"Selected entity"})]})}),e.jsx(b,{label:"Context",children:e.jsxs(f,{value:s.context??"",disabled:l,onChange:(t,i)=>h(a,{...s,context:i.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),e.jsx("option",{value:"Form",children:"Form"}),e.jsx("option",{value:"HomePageGrid",children:"Home Page Grid"}),e.jsx("option",{value:"SubGridStandard",children:"SubGrid Standard"}),e.jsx("option",{value:"SubGridAssociated",children:"SubGrid Associated"})]})}),m?e.jsx(b,{label:"Table",hint:"Leave empty for any table.",children:e.jsx(w,{value:s.entityName??"",disabled:l,onChange:(t,i)=>h(a,{...s,entityName:i.value||void 0})})}):e.jsx(b,{label:"Table",children:e.jsxs(f,{value:s.entityName??"",disabled:l,onChange:(t,i)=>h(a,{...s,entityName:i.value||void 0}),children:[e.jsx("option",{value:"",children:"Any"}),_(s).map(t=>e.jsx("option",{value:t,children:t},t))]})})]}),s.kind==="PageRule"&&e.jsx(b,{label:"Address pattern",validationState:s.address.trim()?"none":"error",validationMessage:s.address.trim()?void 0:"Enter the page address.",children:e.jsx(w,{value:s.address,disabled:l,onChange:(t,i)=>h(a,{...s,address:i.value}),placeholder:"https://…"})})]},x.keys[a]))}):e.jsx(j,{className:c.muted,children:l?"This tab has no display rule of its own.":k&&!m?"No steps: when you publish, this new tab gets the default rule for its location (this table, where the tab is).":"No steps: this tab will be hidden."}),!l&&(m?e.jsx("div",{children:e.jsxs(W,{children:[e.jsx($,{disableButtonEnhancement:!0,children:e.jsx(v,{icon:e.jsx(A,{}),children:"Add step"})}),e.jsx(I,{children:e.jsxs(K,{children:[e.jsx(M,{onClick:()=>y(P()),children:"Table"}),e.jsx(M,{onClick:()=>y(se()),children:"Page"})]})})]})}):e.jsx("div",{children:e.jsx(v,{icon:e.jsx(A,{}),onClick:()=>y(P()),children:"Add step"})})),e.jsx(X,{className:c.muted,children:m?"Application ribbon tabs take table and page steps.":"A table's tabs take table steps only."})]})};export{de as TabDisplayRulesPanel,de as default};
@@ -1 +0,0 @@
1
- import{r as v,W as ne,j as n,a6 as U,a7 as W,c as _,dX as G,T as K,k as O,aq as se,F as q,ec as oe,ar as ie,eU as le,C as re,d as de,at as ce,m as ue,t as u}from"./fluent-ui-CQyNN9H3.js";import{b as ge,a as j,t as pe,aQ as R,aR as be,aS as he,aT as me}from"./index-DRTwBo4g.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";const z={1033:"English (United States)",1031:"German",1034:"Spanish (traditional)",1036:"French",1040:"Italian",1041:"Japanese",1042:"Korean",1043:"Dutch",1044:"Norwegian",1045:"Polish",1046:"Portuguese (Brazil)",1049:"Russian",1053:"Swedish",1054:"Thai",1055:"Turkish",1057:"Indonesian",1058:"Ukrainian",1066:"Vietnamese",2052:"Chinese (Simplified)",3082:"Spanish (Spain)"},p=m=>z[m]??`Language ${m}`,xe="​​",L=[{field:"label",name:"Label"},{field:"tooltipTitle",name:"Tooltip title"},{field:"tooltipBody",name:"Tooltip body",multiline:!0}],fe=ue({body:{display:"flex",flexDirection:"column",gap:u.spacingVerticalM},muted:{color:u.colorNeutralForeground3},add:{display:"flex",alignItems:"flex-end",gap:u.spacingHorizontalS},addField:{flex:"0 1 320px",minWidth:0},language:{display:"flex",flexDirection:"column",gap:u.spacingVerticalS,padding:u.spacingVerticalM,border:`1px solid ${u.colorNeutralStroke2}`,borderRadius:u.borderRadiusMedium},languageHeader:{display:"flex",alignItems:"center",gap:u.spacingHorizontalS},languageName:{flex:1,minWidth:0},fields:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:u.spacingHorizontalM,alignItems:"start"}}),Se=({buttonId:m})=>{const d=fe(),M=ge(e=>e.editorBack),D=j(e=>e.ribbons),y=j(e=>e.locLabels),s=j(e=>e.baseLanguageCode),J=j(e=>e.upsertLocLabel),Q=j(e=>e.setButtonProp),b=v.useMemo(()=>{for(const[e,t]of Object.entries(D))for(const a of t.tabs)for(const l of a.groups)for(const o of pe(l))if(o.id===m)return{button:o,location:e,tabId:a.id,groupId:l.id}},[D,m]),[X,F]=v.useState([]),[T,V]=v.useState(""),[Y,Z]=v.useState(!1),P=!b;if(ne.useEffect(()=>{P&&M()},[P,M]),!b)return null;const{button:i}=b,h=i.source,k={label:R(h?.labelToken,me(i.id),i.label,y,s),tooltipTitle:R(h?.tooltipTitleToken,he(i.id),i.tooltipTitle,y,s),tooltipBody:R(h?.tooltipBodyToken,be(i.id),i.tooltipBody,y,s)},H={label:h?.labelToken,tooltipTitle:h?.tooltipTitleToken,tooltipBody:h?.tooltipBodyToken},x=L.filter(({field:e})=>k[e]===null&&H[e]).map(({field:e})=>H[e].slice(11)).filter((e,t,a)=>a.indexOf(e)===t),S=i.origin!==void 0&&i.origin!=="unmanaged",f=e=>y.find(t=>t.id===k[e]),C=e=>i[e]??"",I=(e,t)=>t===s?C(e):f(e)?.titles.find(a=>a.languageCode===t)?.description??"",N=[s,...new Set([...L.flatMap(({field:e})=>(f(e)?.titles??[]).map(t=>t.languageCode)),...X].filter(e=>e!==s))].sort((e,t)=>e===s?-1:t===s?1:e-t),B=(e,t,a,l)=>{const o=k[e];if(!o)return;const g=f(e),c=new Map((g?.titles??[]).filter(r=>r.languageCode!==s).map(r=>[r.languageCode,r.description]));t!==null&&t!==s&&(a?c.set(t,a):c.delete(t)),!(!g&&c.size===0)&&J({id:o,titles:[...l?[{languageCode:s,description:l}]:[],...[...c].map(([r,E])=>({languageCode:r,description:E}))]})},w=(e,t,a)=>{if(t!==s)return B(e,t,a,C(e));e==="label"&&(Z(!a),!a)||(Q(b.location,b.tabId,b.groupId,i.id,{[e]:e==="label"?a:a||void 0}),f(e)&&B(e,null,"",a))},ee=e=>{for(const{field:t}of L)f(t)?.titles.some(a=>a.languageCode===e)&&B(t,e,"",C(t));F(t=>t.filter(a=>a!==e))},$=e=>{const t=Number(/\d+/.exec(e)?.[0])||Number(Object.entries(z).find(([,a])=>a===e)?.[0]);!t||N.includes(t)||(F(a=>[...a,t]),V(""))},te=(e,t,a)=>{const l=document.getElementById(a),o=I(e,t),g=l?.selectionStart??o.length,c=l?.selectionEnd??o.length;w(e,t,o.slice(0,g)+xe+o.slice(c))},ae=Object.keys(z).map(Number).filter(e=>!N.includes(e));return n.jsxs("div",{className:d.body,children:[S?n.jsx(U,{intent:"info",children:n.jsx(W,{children:"This button isn't yours, so its text is read-only. Customise it in Properties to give it text of its own, then translate it."})}):n.jsxs(_,{children:[p(s)," is the organization's base language: its text is the button's own. Other languages are published with it."]}),x.length>0&&n.jsx(U,{intent:"info",children:n.jsxs(W,{children:[x.join(", ")," ",x.length===1?"is a label":"are labels"," of another solution, shared with the controls that use"," ",x.length===1?"it":"them",", so"," ",x.length===1?"it isn't":"they aren't"," edited here. Change the text in Properties to give this button a label of its own."]})}),N.map(e=>n.jsxs("section",{className:d.language,"aria-label":`${p(e)} (${e})`,children:[n.jsxs("div",{className:d.languageHeader,children:[n.jsxs(_,{weight:"semibold",className:d.languageName,children:[p(e)," ",n.jsxs(G,{className:d.muted,children:[e,e===s?" · base language":""]})]}),e!==s&&!S&&n.jsx(K,{content:`Remove ${p(e)}`,relationship:"label",children:n.jsx(O,{appearance:"subtle",size:"small",icon:n.jsx(se,{}),onClick:()=>ee(e)})})]}),n.jsx("div",{className:d.fields,children:L.map(({field:t,name:a,multiline:l})=>{const o=`tr-${e}-${t}`,g=S||!k[t],c=`${a} (${p(e)})`,r=t==="label"&&e===s&&Y;return n.jsx(q,{label:a,validationState:r?"error":"none",validationMessage:r?"A button needs a label.":void 0,children:l?n.jsx(oe,{id:o,"aria-label":c,value:I(t,e),readOnly:g,resize:"vertical",onChange:(E,A)=>w(t,e,A.value)}):n.jsx(ie,{id:o,"aria-label":c,value:r?"":I(t,e),readOnly:g,onChange:(E,A)=>w(t,e,A.value),contentAfter:g?void 0:n.jsx(K,{content:"Insert a line break",relationship:"label",children:n.jsx(O,{appearance:"transparent",size:"small",icon:n.jsx(le,{}),onClick:()=>te(t,e,o)})})})},t)})})]},e)),!S&&n.jsxs("div",{className:d.add,children:[n.jsx(q,{label:"Add a language",className:d.addField,children:n.jsx(re,{freeform:!0,placeholder:"Language or LCID",value:T,onChange:e=>V(e.target.value),onOptionSelect:(e,t)=>t.optionValue&&$(t.optionValue),onKeyDown:e=>e.key==="Enter"&&$(T),children:ae.map(e=>n.jsx(de,{value:String(e),text:`${p(e)} (${e})`,children:`${p(e)} (${e})`},e))})}),n.jsx(O,{icon:n.jsx(ce,{}),disabled:!T.trim(),onClick:()=>$(T),children:"Add"})]}),n.jsx(G,{className:d.muted,children:"The line break button puts Dataverse's line break (two zero-width spaces) where a long label should wrap."})]})};export{Se as TranslationsView,Se as default};
@@ -1 +0,0 @@
1
- import{r as n,dM as ue,j as s,dP as me,as as he,eQ as xe,a6 as z,a7 as P,dY as ge,c as _,e as pe,dU as fe,k as I,bM as be,m as je,dN as A,dW as ve,dL as Y,bY as k,aj as j,N as v,t as h}from"./fluent-ui-CQyNN9H3.js";import{b as $,S as we,ao as K,Z as Se,az as ye,aA as Ce,aB as q,aC as Re,at as Ee,ax as We,ay as Ne,G as De,aD as V,F as Ie}from"./index-DRTwBo4g.js";import{u as ke}from"./useReplaceWebResourceConfirm-BhU1AM5L.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";const Q=je({content:{display:"flex",flexDirection:"column",gap:h.spacingVerticalS,height:"min(560px, calc(100vh - 220px))",minHeight:"240px",overflowY:"hidden"},toolbar:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:h.spacingHorizontalS,flexShrink:0},search:{flex:1,minWidth:"200px"},box:{flex:1,minHeight:0,overflowX:"auto",overflowY:"hidden"},row:{cursor:"pointer"},muted:{color:h.colorNeutralForeground3},state:{padding:h.spacingVerticalL,textAlign:"center"},reference:{flexShrink:0,overflowWrap:"anywhere",fontFamily:h.fontFamilyMonospace}}),Be={js:s.jsx(v,{}),ts:s.jsx(v,{}),css:s.jsx(v,{}),html:s.jsx(v,{}),svg:s.jsx(j,{}),png:s.jsx(j,{}),gif:s.jsx(j,{}),jpg:s.jsx(j,{}),xml:s.jsx(k,{}),resx:s.jsx(k,{})};function w(a){return a.split(".").pop()?.toLowerCase()??""}const He=[{label:"All types",value:"all"},{label:".js",value:"js"},{label:".html",value:"html"},{label:".svg",value:"svg"},{label:".png",value:"png"},{label:".css",value:"css"},{label:".xml",value:"xml"},{label:".resx",value:"resx"}],Le=[A({columnId:"name",renderHeaderCell:()=>"Name",renderCell:a=>s.jsx(Y,{truncate:!0,media:Be[w(a.name)]??s.jsx(k,{}),description:a.description||void 0,children:a.name})}),A({columnId:"modified",renderHeaderCell:()=>"Modified",renderCell:a=>s.jsx(Y,{truncate:!0,children:a.modifiedOn?new Date(a.modifiedOn).toLocaleDateString():"—"})})],Oe={name:{minWidth:240,idealWidth:720},modified:{minWidth:96,idealWidth:120}},Z=52,Fe=34,X=n.createContext({choose:()=>{}});function Ge({item:a,style:o}){const x=Q(),{choose:c}=n.useContext(X);return s.jsx(q,{style:o,className:x.row,"data-web-resource":a.name,onDoubleClick:()=>c(a),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),c(a))},children:({renderCell:i})=>s.jsx(ve,{children:i(a)})})}const Te=({item:a},o)=>s.jsx(Ge,{item:a,style:o}),Ae=({onSelect:a})=>{const o=Q(),x=ke(),c=$(e=>e.webResourceBrowserOpen),i=$(e=>e.closeWebResourceBrowser),J=we(e=>e.publisherPrefix),B=n.useRef(null),[S,H]=n.useState([]),[L,g]=n.useState(!1),[O,F]=n.useState(!1),[y,u]=n.useState(null),[C,R]=n.useState(null),[E,ee]=n.useState(""),[p,se]=n.useState("all"),[W,te]=n.useState(!0),[f,G]=n.useState(null),N=n.useRef(null),[ne,T]=n.useState(0),ae=f!==null;n.useLayoutEffect(()=>{T(N.current?.clientHeight??0)},[c,L,y,C,ae]),n.useEffect(()=>{const e=N.current;if(!e||typeof ResizeObserver>"u")return;const t=new ResizeObserver(([r])=>T(Math.floor(r.contentRect.height)));return t.observe(e),()=>t.disconnect()},[c]);const re=ue({tabBehavior:"unlimited",ignoreDefaultKeydown:{Enter:!0}}),D=n.useMemo(()=>{const e=E.toLowerCase();return S.filter(t=>{const r=w(t.name),l=e===""||t.name.toLowerCase().includes(e)||(t.description??"").toLowerCase().includes(e),d=p==="all"||r===p,b=!W||t.isCustom;return l&&d&&b})},[S,E,p,W]),m=D.find(e=>e.id===f)??null;n.useEffect(()=>{c&&(G(null),g(!0),u(null),R(null),K().then(e=>H(e)).catch(e=>u(e instanceof Error?e.message:String(e))).finally(()=>g(!1)))},[c]);const oe=async()=>{g(!0),u(null);try{H(await K())}catch(e){u(e instanceof Error?e.message:String(e))}finally{g(!1)}},le=e=>new Promise((t,r)=>{const l=new FileReader;l.onerror=()=>r(l.error??new Error("Unable to read file")),l.onload=()=>{const d=String(l.result??"");t(d.includes(",")?d.split(",")[1]??"":d)},l.readAsDataURL(e)}),ce=e=>{const t=w(e.name);return`${J||"new"}_/${t==="js"||t==="css"||t==="html"||t==="xml"?"scripts":t==="svg"||t==="png"?"icons":"webresources"}/${e.name}`},ie=async e=>{const t=Ie();F(!0),R(null);try{const r=await le(e),l=w(e.name),d={html:1,css:2,js:3,xml:4,png:5,jpg:6,gif:7,xsl:9,ico:10,svg:11,resx:12}[l]??4,b=await We(ce(e),r,d,{displayName:e.name,guard:t,onExisting:x.onExisting});await oe(),R([b.solutionWarning,b.publishWarning].filter(Boolean).join(" ")||null)}catch(r){if(r instanceof Ne)return;const l=r instanceof Error?r.message:String(r);u(l),De.getState().logError("webresource",`Upload of ${e.name} failed: ${l}`)}finally{F(!1)}},M=()=>{V.clear(),i()},U=e=>{V.invoke(e),a?.(e),i()},de=Math.max(Z,ne-Fe);return s.jsxs(s.Fragment,{children:[x.dialog,s.jsxs(Se,{open:c,onOpenChange:e=>!e&&M(),title:"Choose a web resource",size:"large",contentClassName:o.content,startActions:s.jsxs(s.Fragment,{children:[s.jsx(I,{icon:s.jsx(be,{}),disabled:O,onClick:()=>B.current?.click(),children:O?"Uploading…":"Upload…"}),s.jsx(Ee,{prefix:"Uploads to"})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(I,{appearance:"secondary",onClick:M,children:"Cancel"}),s.jsx(I,{appearance:"primary",disabled:!m,onClick:()=>m&&U(m),children:"Select"})]}),children:[s.jsx("input",{ref:B,type:"file",accept:".js,.html,.svg,.png,.css,.xml,.resx,.jpg,.gif,.ico,.xsl",style:{display:"none"},onChange:e=>{const t=e.target.files?.[0];e.currentTarget.value="",t&&ie(t)}}),s.jsxs("div",{className:o.toolbar,children:[s.jsx(me,{"aria-label":"Search the web resources by name",placeholder:"Search by name…",value:E,onChange:(e,t)=>ee(t.value),className:o.search}),s.jsx(he,{"aria-label":"Type",value:p,onChange:(e,t)=>se(t.value),children:He.map(e=>s.jsx("option",{value:e.value,children:e.label},e.value))}),s.jsx(xe,{label:"Custom only",checked:W,onChange:(e,t)=>te(t.checked===!0)})]}),y&&s.jsx(z,{intent:"error",children:s.jsx(P,{children:y})}),C&&s.jsx(z,{intent:"warning",children:s.jsx(P,{children:C})}),s.jsx("div",{ref:N,className:o.box,...re,children:L?s.jsx(ge,{className:o.state,size:"small",label:"Loading web resources…"}):D.length===0?s.jsx(_,{as:"p",className:pe(o.state,o.muted),children:S.length===0?"No web resources in this environment.":"No web resources match."}):s.jsx(X.Provider,{value:{choose:U},children:s.jsxs(ye,{items:D,columns:Le,columnSizingOptions:Oe,resizableColumns:!0,getRowId:e=>e.id,focusMode:"composite",selectionMode:"single",subtleSelection:!0,"aria-label":"Web resources",selectedItems:f?new Set([f]):new Set,onSelectionChange:(e,t)=>{const r=[...t.selectedItems][0];G(r??null)},children:[s.jsx(Ce,{children:s.jsx(q,{children:({renderHeaderCell:e})=>s.jsx(fe,{children:e()})})}),s.jsx(Re,{itemSize:Z,height:de,listProps:{width:"100%"},children:Te})]})})}),m&&s.jsxs(_,{size:200,className:o.reference,children:[s.jsx("span",{className:o.muted,children:"Reference: "}),"$webresource:",m.name]})]})]})};export{Ae as WebResourceBrowser,Ae as default};
@@ -1,2 +0,0 @@
1
- import{r as o,j as n,dX as P,dZ as O,d_ as B,z as V,E as R,ao as _,bO as U,eT as H,bM as z,a6 as G,a7 as K,m as W,t as y}from"./fluent-ui-CQyNN9H3.js";import{a as b,b as E,ao as Q,d as Y,an as Z,_ as q,aN as J}from"./index-DRTwBo4g.js";import{M as ee}from"./MonacoEditor-DweI16yt.js";import"./preload-helper-PPVm8Dsz.js";import"./dnd-iy5K5XAJ.js";const te=["Add","AddCircle","Alert","AppFolder","Archive","ArrowClockwise","ArrowCounterclockwise","ArrowDown","ArrowExport","ArrowImport","ArrowLeft","ArrowRight","ArrowSync","ArrowUp","Attach","Beaker","Bookmark","Bug","Building","Calculator","CalendarLtr","CalendarMonth","Call","Camera","Cart","Chart","Checkmark","CheckmarkCircle","Circle","ClipboardTask","Clock","Cloud","Code","CodeBlock","Comment","ContactCard","Copy","CreditCard","Crown","Cube","CursorClick","DataBarVertical","Delete","Diamond","Document","DocumentCopy","DocumentEdit","DocumentText","Download","Edit","Emoji","ErrorCircle","Eye","EyeOff","Filter","Flag","Flow","FolderOpen","Globe","Grid","Group","Heart","Home","Image","Info","Key","Library","Link","List","Location","Lock","Mail","Map","MegaphoneLoud","Money","MoreCircle","MoreHorizontal","Note","NoteEdit","NumberCircle1","Open","Organization","Pause","People","PeopleCommunity","Person","PersonAdd","PersonSearch","Phone","Play","Plug","Print","Question","Refresh","Rename","Save","Search","Send","Settings","Share","Shield","ShoppingBag","Sparkle","Star","StarEmphasis","Stop","Table","Tag","TaskList","TextBulletList","TextDescription","ThumbLike","Timer","ToggleLeft","ToggleRight","Tool","Translate","Umbrella","Unlock","Upload","Video","Warning","Wrench"];function A(a,C){const h=[];return h.push(a.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(m,e){const r=m.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!r.includes("$LocLabels:"))return{suggestions:[]};const d=r.lastIndexOf("$LocLabels:")+11,i=r.slice(d),u={startLineNumber:e.lineNumber,startColumn:e.column-i.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:b.getState().locLabels.map(c=>({label:c.id,kind:a.languages.CompletionItemKind.Reference,insertText:c.id,range:u,detail:"LocLabel reference"}))}}})),h.push(a.languages.registerCompletionItemProvider("xml",{triggerCharacters:[":","$"],provideCompletionItems(m,e){const r=m.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!r.includes("$webresource:"))return{suggestions:[]};const d=r.lastIndexOf("$webresource:")+13,i=r.slice(d),u={startLineNumber:e.lineNumber,startColumn:e.column-i.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:C().map(c=>({label:c,kind:a.languages.CompletionItemKind.File,insertText:c,range:u,detail:"Web resource"}))}}})),h.push(a.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(m,e){const r=m.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!/Command\s*=\s*"[^"]*$/.test(r))return{suggestions:[]};const i=r.match(/Command\s*=\s*"([^"]*)$/)?.[1]??"",u={startLineNumber:e.lineNumber,startColumn:e.column-i.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:b.getState().commands.map(c=>({label:c.id,kind:a.languages.CompletionItemKind.Function,insertText:c.id,range:u,detail:"CommandDefinition"}))}}})),h.push(a.languages.registerCompletionItemProvider("xml",{triggerCharacters:['"'],provideCompletionItems(m,e){const r=m.getValueInRange({startLineNumber:e.lineNumber,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column});if(!/ModernImage\s*=\s*"[^"]*$/.test(r))return{suggestions:[]};const i=r.match(/ModernImage\s*=\s*"([^"]*)$/)?.[1]??"",u={startLineNumber:e.lineNumber,startColumn:e.column-i.length,endLineNumber:e.lineNumber,endColumn:e.column};return{suggestions:te.map(l=>({label:l,kind:a.languages.CompletionItemKind.Color,insertText:l,range:u,detail:"Fluent icon (ModernImage)",documentation:`Renders the ${l}_20_Regular Fluent icon`}))}}})),h}function T(a){a.forEach(C=>C.dispose())}const ne=W({root:{flex:1,display:"flex",flexDirection:"column",gap:y.spacingVerticalS,minHeight:"320px"},muted:{color:y.colorNeutralForeground3},editor:{flex:1,minHeight:"240px",border:`1px solid ${y.colorNeutralStroke2}`,borderRadius:y.borderRadiusMedium,overflow:"hidden"}}),re=["HomepageGrid","SubGrid","Form","Application"],ce=({location:a})=>{const C=ne(),h=E(t=>t.closeEditor),m=E(t=>t.openImportXml),e=b(t=>t.ribbons),r=b(t=>t.baseline),d=b(t=>t.commands),i=b(t=>t.displayRules),u=b(t=>t.enableRules),p=b(t=>t.locLabels),[l,c]=o.useState(a),[S,g]=o.useState(null),[$,w]=o.useState(!1),f=o.useRef(0);o.useEffect(()=>{f.current++,g(null)},[l]);const[k,v]=o.useState([]),M=o.useRef(null),I=o.useRef(null),x=o.useRef([]);o.useEffect(()=>{Q().then(t=>v(t.map(s=>s.name))).catch(()=>v([]))},[]),o.useEffect(()=>()=>{T(x.current),x.current=[]},[]);const j=o.useCallback((t,s)=>{M.current=t,I.current=s,T(x.current),x.current=A(s,()=>k)},[k]);o.useEffect(()=>{I.current&&(T(x.current),x.current=A(I.current,()=>k))},[k]);const D=()=>{M.current?.getAction("editor.action.formatDocument")?.run()},N=o.useCallback(t=>{try{return`<?xml version="1.0" encoding="utf-8"?>
2
- ${Y({location:t,current:e[t],baseline:r[t],commands:d,displayRules:i,enableRules:u,locLabels:p,entityLogicalName:e[t].entityLogicalName})}`}catch(s){return`<!-- Error generating XML: ${String(s)} -->`}},[e,r,d,i,u,p])(l);o.useEffect(()=>{f.current++,g(null)},[N]);const F=async()=>{const t=f.current,s=await q(N);t===f.current&&g(s.ok?{intent:"success",text:"Copied the XML to the clipboard."}:{intent:"error",text:`Couldn't copy (${s.error}). Click in the XML, press Ctrl+A, then Ctrl+C.`})},X=async()=>{const t=f.current,s=`RibbonDiffXml_${l}.xml`;w(!0),g(null);try{const L=await J(s,N,[{name:"XML",extensions:["xml"]}]);if(t!==f.current)return;L.ok&&L.path?g({intent:"success",text:`Saved to ${L.path}.`}):L.ok?g({intent:"success",text:`Started downloading ${s}. If no file appears, use Copy.`}):L.canceled?g(null):g({intent:"error",text:`Couldn't save the file (${L.error}). Use Copy instead.`})}finally{w(!1)}};return n.jsxs("div",{className:C.root,children:[n.jsx(P,{className:C.muted,children:"Your changes to this location, as RibbonDiffXml. Publish merges them into your solution's layer; its View XML shows the merged result."}),n.jsx(O,{size:"small",selectedValue:l,onTabSelect:(t,s)=>c(s.value),children:re.map(t=>n.jsx(B,{value:t,children:Z[t].label},t))}),n.jsxs(V,{size:"small","aria-label":"XML actions",children:[n.jsx(R,{icon:n.jsx(_,{}),onClick:()=>{F()},children:"Copy"}),n.jsx(R,{icon:n.jsx(U,{}),disabled:$,onClick:()=>{X()},children:"Download"}),n.jsx(R,{icon:n.jsx(H,{}),onClick:D,children:"Format"}),n.jsx(R,{icon:n.jsx(z,{}),onClick:()=>{h(),m(N)},children:"Import this XML"})]}),S&&n.jsx(G,{intent:S.intent,role:"status",children:n.jsx(K,{children:S.text})}),n.jsx("div",{className:C.editor,children:n.jsx(ee,{language:"xml",value:N,readOnly:!0,height:"100%",onMount:j})})]})};export{ce as XmlView,ce as default};
@@ -1 +0,0 @@
1
- const t=[{value:"PrimaryControl",group:"Context",label:"Primary Control",description:"The primary Xrm.Page / FormContext / GridControl"},{value:"PrimaryControlId",group:"Context",label:"Primary Control ID",description:"ID of the primary control"},{value:"SelectedControl",group:"Context",label:"Selected Control",description:"The currently selected grid or form control"},{value:"CommandProperties",group:"Context",label:"Command Properties",description:"Properties of the command that triggered the action"},{value:"PrimaryEntityTypeCode",group:"Record",label:"Primary Entity Type Code",description:"Object type code of the primary entity"},{value:"PrimaryEntityTypeName",group:"Record",label:"Primary Entity Type Name",description:"Logical name of the primary entity"},{value:"FirstPrimaryItemId",group:"Record",label:"First Primary Item ID",description:"GUID of the first selected record (primary entity)"},{value:"PrimaryItemIds",group:"Record",label:"Primary Item IDs",description:"Array of GUIDs of all selected records (primary entity)"},{value:"SelectedEntityTypeCode",group:"Selection context",label:"Selected Entity Type Code",description:"Object type code of the selected entity in the grid"},{value:"SelectedEntityTypeName",group:"Selection context",label:"Selected Entity Type Name",description:"Logical name of the selected entity in the grid"},{value:"FirstSelectedItemId",group:"Selection context",label:"First Selected Item ID",description:"GUID of the first selected row in the grid"},{value:"SelectedControlSelectedItemCount",group:"Grid selection",label:"Selected Item Count",description:"Number of selected rows in the grid"},{value:"SelectedControlSelectedItemIds",group:"Grid selection",label:"Selected Item IDs",description:"Array of GUIDs of selected rows"},{value:"SelectedControlSelectedItemReferences",group:"Grid selection",label:"Selected Item References",description:"Entity references for selected rows"},{value:"SelectedControlAllItemCount",group:"Grid selection",label:"All Item Count",description:"Total number of rows in the grid"},{value:"SelectedControlAllItemIds",group:"Grid selection",label:"All Item IDs",description:"Array of GUIDs of all rows in the grid"},{value:"SelectedControlAllItemReferences",group:"Grid selection",label:"All Item References",description:"Entity references for all rows"},{value:"SelectedControlUnselectedItemCount",group:"Grid selection",label:"Unselected Item Count",description:"Number of unselected rows in the grid"},{value:"SelectedControlUnselectedItemIds",group:"Grid selection",label:"Unselected Item IDs",description:"Array of GUIDs of unselected rows"},{value:"SelectedControlUnselectedItemReferences",group:"Grid selection",label:"Unselected Item References",description:"Entity references for unselected rows"},{value:"OrgName",group:"Org/User",label:"Org Name",description:"Unique name of the Dataverse organization"},{value:"OrgLcid",group:"Org/User",label:"Org LCID",description:"Organization's base language LCID"},{value:"UserLcid",group:"Org/User",label:"User LCID",description:"Current user's language LCID"}],r=new Set(["SelectedControlSelectedItemReferences","SelectedControlAllItemReferences","SelectedControlUnselectedItemReferences"]),o=new Set(t.map(e=>e.value));function l(e){return o.has(e)&&!r.has(e)}export{o as C,r as U,l as i};