slice-machine-ui 1.26.1-beta.25 → 1.26.1-beta.27

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 (34) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/chunks/{188-9cdca9e923488afd.js → 188-2e42d5ebef697946.js} +1 -1
  3. package/out/_next/static/chunks/{91-717d764a224ac07f.js → 91-67c244a4a034c8de.js} +1 -1
  4. package/out/_next/static/chunks/pages/{_app-607ae4e0137c7991.js → _app-89061074e404a43c.js} +1 -1
  5. package/out/_next/static/chunks/pages/{changelog-042822d12df57669.js → changelog-3f04a3d8747ae383.js} +1 -1
  6. package/out/_next/static/chunks/pages/{changes-194f6cf187fa6ee7.js → changes-ec62e7eb50d6f2be.js} +1 -1
  7. package/out/_next/static/chunks/pages/{labs-7a4fe64cb86b59e8.js → labs-830dde0b85d6dd01.js} +1 -1
  8. package/out/_next/static/chunks/pages/{settings-419384d4d43070c2.js → settings-f61144a9387fd6f1.js} +1 -1
  9. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-ad66e6c755798ce7.js +1 -0
  10. package/out/_next/static/chunks/pages/{slices-98f88ac46b6ad58b.js → slices-d65be4ca817a766d.js} +1 -1
  11. package/out/_next/static/css/{172e1bc0b9586c22.css → e3ffbc7931a47375.css} +1 -1
  12. package/out/_next/static/{jUSFBdGosRRScGUchEixA → d2smUBa0QoLDrrmOf-btR}/_buildManifest.js +1 -1
  13. package/out/changelog.html +1 -1
  14. package/out/changes.html +1 -1
  15. package/out/custom-types/[customTypeId].html +1 -1
  16. package/out/custom-types.html +1 -1
  17. package/out/index.html +1 -1
  18. package/out/labs.html +1 -1
  19. package/out/page-types/[pageTypeId].html +1 -1
  20. package/out/settings.html +1 -1
  21. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  22. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  23. package/out/slices.html +1 -1
  24. package/package.json +3 -3
  25. package/src/hooks/useScreenshotChangesModal.ts +1 -1
  26. package/src/legacy/lib/builders/SliceBuilder/FieldZones/index.tsx +3 -12
  27. package/src/legacy/lib/builders/SliceBuilder/VariationsList/VariationsList.module.css +10 -0
  28. package/src/legacy/lib/builders/SliceBuilder/VariationsList/VariationsList.module.css.d.ts +5 -0
  29. package/src/legacy/lib/builders/SliceBuilder/{Sidebar → VariationsList}/index.tsx +164 -76
  30. package/src/legacy/lib/builders/SliceBuilder/index.tsx +10 -5
  31. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-d3e157cc3a540dd4.js +0 -1
  32. package/src/features/slices/sliceBuilder/useGroupsInSlicesExperiment.ts +0 -8
  33. /package/out/_next/static/{jUSFBdGosRRScGUchEixA → d2smUBa0QoLDrrmOf-btR}/_ssgManifest.js +0 -0
  34. /package/src/legacy/lib/builders/SliceBuilder/{Sidebar → VariationsList}/AddVariationModal.tsx +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[136],{31314:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/slices/[lib]/[sliceName]/[variation]",function(){return t(54350)}])},25998:function(e,n,t){"use strict";t.d(n,{Z:function(){return l}});var i=t(5632),r=t(56580),o=t(95200),a=function(e,n,t){var i,r=null===(i=(0,o.Sd)(e))||void 0===i?void 0:i.find(function(e){return e.name.replace(/\//g,"--")===n});return null==r?void 0:r.components.find(function(e){return e.model.name===t})},l=function(){var e=(0,i.useRouter)(),n=(0,r.v9)(function(n){return{slice:a(n,e.query.lib,e.query.sliceName)}}).slice;if(!n)return{};var t=n.model.variations.find(function(n){return n.id===e.query.variation});return t?{slice:n,variation:t}:{}}},54350:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return eR}});var i=t(52322),r=t(97729),o=t.n(r),a=t(5632),l=t(22710),s=t(62230),c=t(85244),u=t(99267),d=t(74217),f=t(2784),m=t(82770),v=t(50950),p=t(26921),h=t(90374),x=(0,f.createContext)(void 0);function y(e){var n=e.children,t=e.initialSlice,r=(0,a.useRouter)(),o=(0,f.useState)(t),y=o[0],g=o[1],b=(0,p.c)({errorMessage:"Failed to save slice. Check your browser's console for more information."}),j=b.actionQueueStatus,w=b.setNextAction,S=(0,h.Z)().saveSliceSuccess,C=(0,d.R9)(S),k=(0,v.g)().syncChanges,I=(0,f.useMemo)(function(){var e=r.query.variation,n=y.model.variations.find(function(n){return n.id===e});if(n)return n;throw Error("Variation not found")},[y,r]),T=(0,f.useCallback)(function(e){g(e),w((0,l.Z)(function(){var n,t,i,r,o;return(0,u.__generator)(this,function(n){switch(n.label){case 0:return[4,(0,m.Ve)(e)];case 1:if((t=n.sent().errors).length>0)throw t;return[4,(0,m.pL)({libraryID:e.from,sliceID:e.model.id})];case 2:if(r=(i=n.sent()).errors,o=i.mocks,r.length>0)throw r;return C((0,c.Z)((0,s.Z)({},e),{mocks:o})),k(),[2]}})}))},[w,C,k]),E=(0,f.useMemo)(function(){return{actionQueueStatus:j,slice:y,setSlice:T,variation:I}},[j,y,T,I]);return(0,i.jsx)(x.Provider,{value:E,children:"function"==typeof n?n(E):n})}function g(){var e=(0,f.useContext)(x);if(!e)throw Error("SliceBuilderProvider not found");return e}var b=t(25998),j=t(22715),w=t(41730),S=t(47976),C=t(8564),k=t(18566),I=t(81038);function T(e){return E.apply(this,arguments)}function E(){return(E=(0,l.Z)(function(e){var n,t,i;return(0,u.__generator)(this,function(r){switch(r.label){case 0:return[4,I.j.customTypes.readCustomType({id:e})];case 1:if(t=(n=r.sent()).errors,i=n.model,t.length>0)throw t;return[2,i]}})})).apply(this,arguments)}var R=t(67445),A=t(64722),Z=t(20812),N=function(e){return(0,i.jsxs)("svg",(0,c.Z)((0,s.Z)({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,i.jsx)("path",{d:"M9.5 12L6 9.5L9.5 7V9.5V12Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M6 9.5H11C14.3 9.5 17 12.2 17 15.5V17.5M6 9.5L9.5 12V9.5V7L6 9.5Z",stroke:"currentColor",strokeLinecap:"round"})]}))},L=function(){var e,n,t=(e=(0,A.l)().source,n=(0,R.Ag)(e.query),void 0!==n&&(0,R.ne)(e.asPath,n)?n:void 0);return void 0!==t?(0,i.jsx)(C.S,{children:(0,i.jsx)(f.Suspense,{children:(0,i.jsx)(j.xu,{bottom:32,justifyContent:"center",position:"fixed",right:0,width:"100vw",children:(0,i.jsx)(_,{sourceCustomTypeId:t})})})}):null},_=function(e){var n,t=(n=e.sourceCustomTypeId,(0,k.QT)(T,[n])),r=(0,f.useState)(!0),o=r[0],l=r[1],s=(0,a.useRouter)();if(void 0===t||!o)return null;var c=t.format,u=t.id,d=R.cd[c].getBuilderPagePathname(u);return(0,i.jsxs)(j.hE,{density:"compact",color:"dark",children:[(0,i.jsxs)(j.zx,{onClick:function(){s.push(d)},renderStartIcon:function(){return(0,i.jsx)(N,{})},children:["Return to ",t.label]}),(0,i.jsx)(j.zx,{onClick:function(){l(!1)},renderStartIcon:function(){return(0,i.jsx)(Z.T,{})}})]})},D=t(76478),V=t(56580),O=t(33710),F=t(51991),z=t(42189),P=t(63094),M=t(17036),K=function(e){var n=e.children,t=e.open,r=e.onClose;return(0,i.jsxs)(F.zs,{open:t,trigger:n,onClose:r,children:[(0,i.jsx)(F.Ev,{children:"Simulate your slices"}),(0,i.jsx)(F.LB,{component:"video",cloudName:"dmtf1daqp",loop:!1,autoPlay:!1,publicId:P.Sn,poster:"/simulator-video-thumbnail.png",controls:!0,onPlay:function(){m.Xe.track({event:"open-video-tutorials",video:P.Sn})}}),(0,i.jsx)(F.OJ,{children:"Minimize context-switching by previewing your Slice components in the simulator."}),(0,i.jsx)(F.Rp,{children:"Got it"})]})},q=function(e){var n=e.disabled,t=(0,a.useRouter)(),r=(0,f.useRef)(null),o=(0,h.Z)().setSeenSimulatorToolTip,l=(0,V.v9)(function(e){return{hasSeenSimulatorTooltip:(0,M.bv)(e)}}).hasSeenSimulatorTooltip;(0,f.useEffect)(function(){var e=r.current;e&&!l&&setTimeout(function(){return O.Z.show(e)},5e3)},[l]);var s=function(){if(o(),r.current){var e=r.current;O.Z.hide(e)}};return(0,i.jsx)("span",{"data-tip":!0,"data-tip-disable":!1,"data-for":"simulator-button-tooltip",ref:r,children:(0,i.jsx)(K,{open:!l,onClose:s,children:(0,i.jsx)(j.zx,{"data-tip":!0,"data-testid":"simulator-open-button",onClick:function(){s(),window.open("".concat(t.asPath,"/simulator"),P.pq)},disabled:n,renderStartIcon:function(){return(0,i.jsx)(z.z,{color:j.TV.color.greyLight1,height:j.TV.size[24],style:{transform:"scale(calc(4 / 3))"},width:j.TV.size[24]})},children:"Simulate"})})})},B=t(88866),H=t(28316),X=t(28173),W=t(5479),G=t(11563),U=t(73393),Q=t(79560),Y=t(24244),J=t(23373),$=t(36195),ee=t(52586),en=[ee.Group,ee.StructuredText,ee.Image,ee.Link,ee.LinkToMedia,ee.ContentRelationship,ee.Select,ee.Boolean,ee.Date,ee.Timestamp,ee.Embed,ee.Number,ee.GeoPoint,ee.Color,ee.Text,],et=t(13302),ei=t(17384),er=t(9461),eo=function(){var e,n=g(),t=n.slice,r=n.setSlice,o=n.variation,a=(0,f.useState)(!1),l=a[0],s=a[1],c={eligible:(null==(e=(0,G.L)("slicemachine-groups-in-slices"))?void 0:e.value)==="on"},u=Boolean(o.items&&Object.keys(o.items).length>0),d=function(e){return function(n){if(c.eligible&&e===J.Rt.Items&&o.items&&Object.keys(o.items).length<=1){s(!0);return}var i=(0,W.AK)({slice:t,variationId:o.id,widgetArea:e,fieldId:n});r(i)}},v=function(e){return function(n){var i=n.apiId,a=n.newKey,l=n.value,s=(0,W.L4)({slice:t,variationId:o.id,widgetArea:e,previousFieldId:i,newFieldId:a,newField:l});r(s)}},p=function(e){return function(n){var i=n.id,a=n.label,l=n.widgetTypeName,s=en.find(function(e){return e.CUSTOM_NAME===l||e.TYPE_NAME===l});if(!s)throw Error("Unsupported Field Type: ".concat(l));var c=s.create(a);try{s.schema.validateSync(c,{stripUnknown:!1})}catch(u){throw Error('Model is invalid for widget "'.concat(c.type,'".'))}var d=(0,W.xS)({slice:t,variationId:o.id,widgetArea:e,newFieldId:i,newField:c.type===B.GroupFieldType?Y.Fl.fromSM(c):c});r(d),m.Xe.track({event:"field:added",id:i,name:a,type:c.type,isInAGroup:!1,contentType:(0,er.T)(window.location.pathname)})}},h=function(e){return function(n){if(!(0,et.uS)(n)){var i=n.source,a=n.destination;if(a){var l=(0,W.gR)({slice:t,variationId:o.id,widgetArea:e,sourceIndex:i.index,destinationIndex:a.index});(0,H.flushSync)(function(){return r(l)})}}}},x=function(){var e=(0,W.Oh)({slice:t,variationId:o.id});r(e),s(!1)};return(0,i.jsxs)(X.aV,{children:[(0,i.jsx)(Q.Z,{zoneType:"slice",zoneTypeFormat:void 0,tabId:void 0,title:"Fields",dataTip:" The non-repeatable zone\n is for fields<br/> that should appear once, like a<br/>\n section title.\n",fields:o.primary,EditModal:U.Z,widgetsArray:c.eligible?en:$.Z,onDeleteItem:d(J.Rt.Primary),onSave:v(J.Rt.Primary),onSaveNewField:p(J.Rt.Primary),onDragEnd:h(J.Rt.Primary),poolOfFieldsToCheck:o.primary||[],renderHintBase:function(e){var n=e.item;return"slice.primary".concat((0,ei.Ti)(n.key))},renderFieldAccessor:function(e){return"slice.primary".concat((0,ei.Ti)(e))},testId:"static-zone-content",isRepeatableCustomType:void 0,emptyStateHeading:c.eligible?void 0:"No fields",emptyStateActionTestId:"add-Static-field"}),!c.eligible||u?(0,i.jsx)(Q.Z,{zoneType:"slice",zoneTypeFormat:void 0,tabId:void 0,isRepeatable:!0,title:"Repeatable Zone",dataTip:"The repeatable zone is for a group<br/>\n of fields that you want to be able to repeat an<br/>\n indeterminate number of times, like FAQs",widgetsArray:$.Z,fields:o.items,EditModal:U.Z,onDeleteItem:d(J.Rt.Items),onSave:v(J.Rt.Items),onSaveNewField:p(J.Rt.Items),onDragEnd:h(J.Rt.Items),poolOfFieldsToCheck:o.items||[],renderHintBase:function(e){var n=e.item;return"item".concat((0,ei.Ti)(n.key))},renderFieldAccessor:function(e){return"slice.items[i]".concat((0,ei.Ti)(e))},testId:"slice-repeatable-zone",isRepeatableCustomType:void 0,emptyStateHeading:"No fields",emptyStateActionTestId:"add-Repeatable-field"}):null,(0,i.jsxs)(j.Vq,{size:"small",open:l,onOpenChange:function(e){return s(e)},children:[(0,i.jsx)(j.fK,{icon:"delete",title:"Delete field"}),(0,i.jsxs)(j.cZ,{children:[(0,i.jsxs)(j.xu,{padding:24,gap:12,flexDirection:"column",children:[(0,i.jsxs)("strong",{children:["This action will permanently remove the repeatable zone from the"," ",t.model.name," slice."]}),(0,i.jsx)("div",{children:"To reimplement repeatable fields later, use a group field instead of the repeatable zone."})]}),(0,i.jsx)(j.kX,{ok:{text:"Delete",color:"tomato",onClick:function(){return x()}},cancel:{text:"Cancel"}})]})]})]})},ea=t(88932),el=t(56319),es=t(49451),ec=t(47731);function eu(){return(eu=(0,l.Z)(function(e){var n,t,i,r,o,a,l,d,f,v,p,h;return(0,u.__generator)(this,function(n){switch(n.label){case 0:return n.trys.push([0,6,,7]),[4,(0,m.Ve)(e.component)];case 1:if((t=n.sent().errors).length>0)throw t;return[4,(0,m.Xi)({libraryID:e.component.from,sliceID:e.component.model.id,variationID:e.variation.id})];case 2:if((r=n.sent().errors).length>0)throw r;return[4,(0,m.X$)(e.component.from,e.component.model.id)];case 3:if(a=(o=n.sent()).slice,(l=o.errors).length>0)throw l;if(!a)throw Error("Could not read variation `".concat(e.variation.name,"`"));return[4,(0,m.pL)({libraryID:e.component.from,sliceID:e.component.model.id})];case 4:return d=n.sent().mocks,f=es.Y.getBuilderPagePathname({libraryName:e.component.href,sliceName:a.name,variationId:a.variations[0].id}),[4,e.router.replace(f)];case 5:return n.sent(),v=(0,c.Z)((0,s.Z)({},e.component),{model:a,mocks:d}),e.saveSliceSuccess(v),[2,v];case 6:throw p=n.sent(),h="Could not delete variation `".concat(e.variation.name,"`"),console.error(h,p),ea.Am.error(h),p;case 7:return[2]}})})).apply(this,arguments)}var ed=function(e){var n=e.isOpen,t=e.onClose,r=e.slice,o=e.variation,s=(0,a.useRouter)(),c=(0,f.useState)(!1),d=c[0],m=c[1],v=(0,h.Z)().saveSliceSuccess,p=g().setSlice;return(0,i.jsxs)(j.Vq,{open:n,onOpenChange:function(e){return!e&&t()},size:{width:448,height:"auto"},children:[(0,i.jsx)(j.fK,{icon:"delete",title:"Delete variation"}),(0,i.jsx)(j.cZ,{children:(0,i.jsxs)(j.xu,{flexDirection:"column",children:[(0,i.jsxs)(j.xv,{color:"grey11",sx:{marginBlock:16,marginInline:16},children:["This action will remove the variation from the slice model and delete associated files. When you push your changes, the variation will disappear from your repository. This update will"," ",(0,i.jsx)(ef,{children:"not"})," affect your documents until you ",(0,i.jsx)(ef,{children:"edit"})," ","them manually."]}),(0,i.jsx)(j.kX,{ok:{text:"Delete",color:"tomato",onClick:function(){o&&(0,l.Z)(function(){var e;return(0,u.__generator)(this,function(e){switch(e.label){case 0:m(!0),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,function(e){return eu.apply(this,arguments)}({component:r,router:s,saveSliceSuccess:v,variation:o})];case 2:return p(e.sent()),[3,4];case 3:return e.sent(),[3,4];case 4:return m(!1),t(),[2]}})})()},loading:d},cancel:{text:"Cancel"},size:"medium"})]})})]})},ef=function(e){return(0,i.jsx)(j.xv,(0,c.Z)((0,s.Z)({},e),{color:"inherit",component:"span",variant:"bold"}))},em=t(63397);function ev(){return(ev=(0,l.Z)(function(e){var n,t,i,r,o,a,l,d,f,v,p;return(0,u.__generator)(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),[4,(0,m.Ve)(e.component)];case 1:if((t=n.sent().errors).length>0)throw t;return[4,(0,m.eH)(e.component,(0,c.Z)((0,s.Z)({},e.variation),{name:e.variationName}))];case 2:if((r=n.sent().errors).length>0)throw r;return[4,(0,m.X$)(e.component.from,e.component.model.id)];case 3:if(a=(o=n.sent()).slice,(l=o.errors).length>0)throw l;if(!a)throw Error("Could not read variation `".concat(e.variation.name,"`"));return[4,(0,m.pL)({libraryID:e.component.from,sliceID:e.component.model.id})];case 4:return d=n.sent().mocks,f=(0,c.Z)((0,s.Z)({},e.component),{model:a,mocks:d}),e.saveSliceSuccess(f),[2,f];case 5:throw v=n.sent(),p="Could not rename variation `".concat(e.variation.name,"`"),console.error(p,v),ea.Am.error(p),v;case 6:return[2]}})})).apply(this,arguments)}var ep=t(83576),eh=t.n(ep),ex=function(e){var n,t,r=e.isOpen,o=e.onClose,a=e.slice,s=e.variation,c=(0,f.useState)(!1),d=c[0],m=c[1],v=g().setSlice,p=(0,h.Z)().saveSliceSuccess;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(j.Vq,{open:r,onOpenChange:function(e){return!e&&o()},size:{width:448,height:"auto"},children:[(0,i.jsx)(j.fK,{icon:"edit",title:"Rename variation"}),(0,i.jsx)(j.cZ,{children:(0,i.jsx)(em.J9,{validateOnMount:!0,initialValues:{variationName:null!==(n=null==s?void 0:s.name)&&void 0!==n?n:""},validate:function(e){if(0===e.variationName.length)return{variationName:"Cannot be empty"}},onSubmit:(t=(0,l.Z)(function(e){var n;return(0,u.__generator)(this,function(n){switch(n.label){case 0:if(!s)return[2];m(!0),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,function(e){return ev.apply(this,arguments)}({component:a,saveSliceSuccess:p,variation:s,variationName:e.variationName.trim()})];case 2:return v(n.sent()),[3,4];case 3:return n.sent(),[3,4];case 4:return m(!1),o(),[2]}})}),function(e){return t.apply(this,arguments)}),children:function(e){return(0,i.jsxs)("form",{children:[(0,i.jsxs)(j.xu,{flexDirection:"column",gap:8,padding:16,children:[(0,i.jsx)(j.xv,{variant:"normal",color:"grey11",children:"This action will rename the variation in the slice model. When you push your changes, the variation will be renamed in your repository."}),(0,i.jsxs)(j.xu,{flexDirection:"column",gap:4,children:[(0,i.jsxs)("label",{className:eh().label,children:[(0,i.jsx)(j.xv,{variant:"bold",children:"Variation name*"}),"string"==typeof e.errors.variationName?(0,i.jsx)(j.xv,{variant:"small",color:"tomato10",children:e.errors.variationName}):null]}),(0,i.jsx)(j.yt,{placeholder:"Variation name",error:"string"==typeof e.errors.variationName,value:e.values.variationName,onValueChange:function(n){e.setFieldValue("variationName",n.slice(0,30))}})]})]}),(0,i.jsx)(j.kX,{ok:{text:"Rename",onClick:function(){e.submitForm()},loading:d,disabled:!e.isValid},cancel:{text:"Cancel"},size:"medium"})]})}})})]})})},ey=t(12773),eg=t(76635),eb=t(36131),ej=t(75289),ew=t(98898),eS=function(e){var n=e.children,t=e.FooterContent,r=e.HeaderContent,o=e.close,a=e.sx,l=e.headerSx,c=void 0===l?{}:l;return(0,i.jsx)(ew.Z,{borderFooter:!0,footerSx:{p:0},bodySx:{pt:2,pb:4,px:4},sx:(0,s.Z)({border:"none"},void 0===a?{}:a),Header:function(e){var n=e.radius;return(0,i.jsxs)(ej.kC,{sx:(0,s.Z)({p:3,pl:4,bg:"headSection",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:n,borderTopRightRadius:n,borderBottom:function(e){var n;return"1px solid ".concat(null===(n=e.colors)||void 0===n?void 0:n.borders)}},c),children:[r,o?(0,i.jsx)(ej.x8,{onClick:o,type:"button"}):null]})},Footer:t?(0,i.jsxs)(ej.kC,{sx:{alignItems:"space-between",bg:"headSection",p:3},children:[(0,i.jsx)(ej.xu,{sx:{ml:"auto"}}),t]}):null,children:n})},eC=t(83399),ek=function(e){var n=e.msg;return(0,i.jsx)(ej.xv,{as:"span",sx:{fontSize:12,color:"error",mt:"5px",ml:2},children:n||"Error!"})},eI=function(e){var n=e.isOpen,t=e.onClose,r=e.onSubmit,o=e.initialVariation,a=e.variations,d=function(e){var n=e.id,t=e.name,i=e.origin,r=n&&n.length?null:{id:"Required!"},o=a.find(function(e){return e.id===n})?{id:"This id already exists!"}:null,l=t&&t.length?null:{name:"Required!"},c=i.value.length&&a.find(function(e){return e.id===i.value})?null:{id:"You must select an existing variation!"},u=n&&n.length&&!/^[A-Za-z0-9]+([A-Za-z0-9]+)*$/.exec(n)&&{id:"No special characters allowed"};return(0,s.Z)({},r,o,l,c,u)},m=function(e){C((0,eg.camelCase)(e))},v=function(e){A(e),I&&m(e)},p=function(e){T(!1),m(e)},h=function(){x(),t()},x=function(){C(""),A(""),b({}),T(!0),L({value:o.id,label:o.name})},y=(0,f.useState)({}),g=y[0],b=y[1],w=(0,f.useState)(""),S=w[0],C=w[1],k=(0,f.useState)(!0),I=k[0],T=k[1],E=(0,f.useState)(""),R=E[0],A=E[1],Z=(0,f.useState)({value:o.id,label:o.name}),N=Z[0],L=Z[1],_=(0,f.useState)(!1),D=_[0],V=_[1];function O(){return F.apply(this,arguments)}function F(){return(F=(0,l.Z)(function(){var e,n;return(0,u.__generator)(this,function(t){switch(t.label){case 0:if(!Object.keys(e=d({id:S,name:R,origin:N})).length)return[3,1];return b(e),[3,3];case 1:if(!(n=a.find(function(e){return e.id===N.value})))return[3,3];return V(!0),[4,r(S,R,n)];case 2:t.sent(),V(!1),h(),t.label=3;case 3:return[2]}})})).apply(this,arguments)}return(0,f.useEffect)(function(){x()},[o,n]),(0,i.jsx)(eC.Z,{isOpen:n,shouldCloseOnOverlayClick:!0,onRequestClose:function(){return h()},contentLabel:"Widget Form Modal",style:{content:{maxWidth:"700px"}},children:(0,i.jsx)(em.J9,{initialValues:{id:S,name:R,origin:N},onSubmit:O,children:(0,i.jsx)(em.l0,{id:"variation-add",onKeyDown:function(e){"Enter"===e.key&&(e.preventDefault(),O())},children:(0,i.jsx)(j.xu,{children:(0,i.jsxs)(eS,{sx:{textAlign:"left"},HeaderContent:(0,i.jsx)(ej.xv,{as:"h2",children:"Add new Variation"}),FooterContent:(0,i.jsxs)(j.xu,{gap:16,alignItems:"center",children:[(0,i.jsx)(j.zx,{onClick:h,color:"grey",children:"Cancel"}),(0,i.jsx)(j.zx,{loading:D,children:"Submit"})]}),close:h,children:[(0,i.jsxs)(j.xu,{flexDirection:"column",padding:{block:16},children:[(0,i.jsxs)(ej.__,{htmlFor:"name",sx:{mb:1},children:["Variation name*",g.name?(0,i.jsx)(ek,{msg:g.name}):""]}),(0,i.jsx)(em.gN,{autoComplete:"off",id:"name",name:"name",placeholder:"e.g. Grid - With Icon",as:ej.II,maxLength:30,value:R,onChange:function(e){return v(e.currentTarget.value)}}),(0,i.jsx)(ej.xv,{children:"It will appear here in Slice Machine, and in the page editor in Prismic"})]}),(0,i.jsxs)(j.xu,{flexDirection:"column",padding:{bottom:16},children:[(0,i.jsxs)(ej.__,{htmlFor:"id",sx:{mb:1},children:["Variation ID*",g.id?(0,i.jsx)(ek,{msg:g.id}):""]}),(0,i.jsx)(em.gN,{autoComplete:"off",id:"id",name:"id",placeholder:"e.g. GridWithIcon",as:ej.II,maxLength:30,value:S,onChange:function(e){return p(e.currentTarget.value)}}),(0,i.jsx)(ej.xv,{children:"It's generated automatically based on the variation name and will appear in the API responses."})]}),(0,i.jsxs)(j.xu,{flexDirection:"column",padding:{bottom:8},children:[(0,i.jsx)(ej.__,{htmlFor:"origin",sx:{mb:1},children:"Duplicate from"}),(0,i.jsx)(eb.ZP,{name:"origin",options:a.map(function(e){return{value:e.id,label:e.name}}),onChange:function(e){e&&L(e)},defaultValue:N,maxMenuHeight:150,theme:function(e){return(0,c.Z)((0,s.Z)({},e),{colors:(0,c.Z)((0,s.Z)({},e.colors),{text:"text",primary:"background"})})}})]})]})})})})})},eT=function(){var e,n=g(),t=n.slice,r=n.variation,o=n.setSlice,s=(0,f.useState)(),c=s[0],d=s[1],v=(0,ec.H)(),p=v.modalPayload,x=p.sliceFilterFn,y=p.defaultVariationSelector,b=p.onUploadSuccess,w=(0,a.useRouter)(),S=(0,h.Z)().saveSliceSuccess;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(j.xu,{flexDirection:"column",gap:16,children:[t.model.variations.map(function(e){return(0,i.jsx)(el.b,{action:{type:"menu",onRename:function(){d({type:"RENAME_VARIATION",variation:e})},onRemove:function(){d({type:"DELETE_VARIATION",variation:e})},removeDisabled:t.model.variations.length<=1},mode:"navigation",onUpdateScreenshot:function(){v.onOpenModal({sliceFilterFn:function(e){return e},defaultVariationSelector:{sliceID:t.model.id,variationID:e.id},onUploadSuccess:function(e){o(e)}})},replace:!0,selected:e.id===r.id,slice:t,variant:"outlined",variationId:e.id},e.id)}),(0,i.jsx)("div",{style:{bottom:j.rS.space[0],marginBottom:"-".concat(j.rS.space[16]),position:"sticky"},children:(0,i.jsxs)(j.xu,{backgroundColor:"grey2",flexDirection:"column",padding:{bottom:40,inline:24},children:[(0,i.jsx)(j.ph,{sx:{left:0,position:"absolute",right:0}}),(0,i.jsx)(j.zx,{color:"grey",onClick:function(){d({type:"ADD_VARIATION"})},startIcon:"add",sx:{position:"relative"},children:"Add a new variation"})]})})]}),(0,i.jsx)(ey.Z,{slices:x([t]),defaultVariationSelector:y,onUploadSuccess:b}),(0,i.jsx)(ex,{isOpen:(null==c?void 0:c.type)==="RENAME_VARIATION",onClose:function(){d(void 0)},slice:t,variation:null==c?void 0:c.variation}),(0,i.jsx)(ed,{isOpen:(null==c?void 0:c.type)==="DELETE_VARIATION",onClose:function(){d(void 0)},slice:t,variation:null==c?void 0:c.variation}),(0,i.jsx)(eI,{initialVariation:r,isOpen:(null==c?void 0:c.type)==="ADD_VARIATION",onClose:function(){d(void 0)},onSubmit:(e=(0,l.Z)(function(e,n,i){var r,a,l,s,c,d;return(0,u.__generator)(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),a=(r=(0,W.Kp)({slice:t,id:e,name:n,copiedVariation:i})).slice,l=r.variation,[4,(0,m.Ve)(a)];case 1:return u.sent(),S(a),o(a),s=es.Y.getBuilderPagePathname({libraryName:a.href,sliceName:a.model.name,variationId:l.id}),w.replace(s),[3,3];case 2:return c=u.sent(),d="Could not add variation `".concat(n,"`"),console.error(d,c),ea.Am.error(d),[3,3];case 3:return[2]}})}),function(n,t,i){return e.apply(this,arguments)}),variations:t.model.variations})]})},eE=function(){var e=g(),n=e.slice,t=e.actionQueueStatus;return(0,i.jsxs)(D.LN,{children:[(0,i.jsxs)(D.wd,{children:[(0,i.jsx)(D.Xq,{url:"/slices"}),(0,i.jsxs)(D.Cx,{children:[(0,i.jsx)(w.g,{children:"Slices"}),(0,i.jsx)(w.g,{active:!0,children:n.model.name})]}),(0,i.jsxs)(D.K2,{children:[(0,i.jsx)(S.X,{status:t}),(0,i.jsx)(q,{disabled:"done"!==t})]})]}),(0,i.jsxs)(D.RN,{children:[(0,i.jsxs)(j.xu,{alignItems:"flex-start",display:"grid",gap:16,gridTemplateColumns:"320px 1fr",children:[(0,i.jsx)(eT,{}),(0,i.jsx)(eo,{})]}),(0,i.jsx)(L,{})]})]})};function eR(){var e=(0,a.useRouter)(),n=(0,b.Z)(),t=n.slice,r=n.variation;return void 0===t||void 0===r?(e.replace("/"),null):(0,i.jsx)(y,{initialSlice:t,children:function(e){var n=e.slice;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o(),{children:(0,i.jsxs)("title",{children:[n.model.name," - Slice Machine"]})}),(0,i.jsx)(eE,{})]})}})}},83576:function(e){e.exports={label:"RenameVariationModal_label__SLsVs"}},76473:function(e,n,t){"use strict";t.d(n,{y1:function(){return b}});var i=t(2784);function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}t(52322);var o=["shift","alt","meta","mod","ctrl"],a={esc:"escape",return:"enter",".":"period",",":"comma","-":"slash"," ":"space","`":"backquote","#":"backslash","+":"bracketright",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function l(e){return(a[e]||e).trim().toLowerCase().replace(/key|digit|numpad|arrow/,"")}function s(e,n){return void 0===n&&(n=","),e.split(n)}function c(e,n,t){void 0===n&&(n="+");var i,a=e.toLocaleLowerCase().split(n).map(function(e){return l(e)});return r({},{alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod")},{keys:a.filter(function(e){return!o.includes(e)}),description:t})}"undefined"!=typeof document&&(document.addEventListener("keydown",function(e){void 0!==e.key&&f([l(e.key),l(e.code)])}),document.addEventListener("keyup",function(e){void 0!==e.key&&m([l(e.key),l(e.code)])})),"undefined"!=typeof window&&window.addEventListener("blur",function(){u.clear()});var u=new Set;function d(e){return Array.isArray(e)}function f(e){var n=Array.isArray(e)?e:[e];u.has("meta")&&u.forEach(function(e){var n;return!o.includes(e)&&u.delete(e.toLowerCase())}),n.forEach(function(e){return u.add(e.toLowerCase())})}function m(e){var n=Array.isArray(e)?e:[e];"meta"===e?u.clear():n.forEach(function(e){return u.delete(e.toLowerCase())})}function v(e,n){var t=e.target;void 0===n&&(n=!1);var i=t&&t.tagName;return d(n)?Boolean(i&&n&&n.some(function(e){return e.toLowerCase()===i.toLowerCase()})):Boolean(i&&n&&!0===n)}var p=function(e,n,t){void 0===t&&(t=!1);var i,r,o=n.alt,a=n.meta,s=n.mod,c=n.shift,f=n.ctrl,m=n.keys,v=e.key,p=e.code,h=e.ctrlKey,x=e.metaKey,y=e.shiftKey,g=e.altKey,b=l(p),j=v.toLowerCase();if(!t){if(!g===o&&"alt"!==j||!y===c&&"shift"!==j)return!1;if(s){if(!x&&!h)return!1}else if(!x===a&&"meta"!==j&&"os"!==j||!h===f&&"ctrl"!==j&&"control"!==j)return!1}return!!(m&&1===m.length&&(m.includes(j)||m.includes(b)))||(m?(void 0===r&&(r=","),(d(i=m)?i:i.split(r)).every(function(e){return u.has(e.trim().toLowerCase())})):!m)},h=(0,i.createContext)(void 0),x=(0,i.createContext)({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),y=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},g="undefined"!=typeof window?i.useLayoutEffect:i.useEffect;function b(e,n,t,r){var o,a,u=(0,i.useRef)(null),b=(0,i.useRef)(!1),j=t instanceof Array?r instanceof Array?void 0:r:t,w=d(e)?e.join(null==j?void 0:j.splitKey):e,S=t instanceof Array?t:r instanceof Array?r:void 0,C=(0,i.useCallback)(n,null!=S?S:[]),k=(0,i.useRef)(C);S?k.current=C:k.current=n;var I=(!function e(n,t){return n&&t&&"object"==typeof n&&"object"==typeof t?Object.keys(n).length===Object.keys(t).length&&Object.keys(n).reduce(function(i,r){return i&&e(n[r],t[r])},!0):n===t}((a=(0,i.useRef)(void 0)).current,j)&&(a.current=j),a.current),T=(0,i.useContext)(x).enabledScopes,E=(0,i.useContext)(h);return g(function(){if((null==I?void 0:I.enabled)!==!1&&(e=T,n=null==I?void 0:I.scopes,0===e.length&&n?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):!!(!n||e.some(function(e){return n.includes(e)})||e.includes("*")))){var e,n,t=function(e,n){var t,i;if(void 0===n&&(n=!1),!(v(e,["input","textarea","select"])&&!v(e,null==I?void 0:I.enableOnFormTags)||null!=I&&null!=I.ignoreEventWhen&&I.ignoreEventWhen(e))){if(null!==u.current&&document.activeElement!==u.current&&!u.current.contains(document.activeElement)){y(e);return}(null==(t=e.target)||!t.isContentEditable||null!=I&&I.enableOnContentEditable)&&s(w,null==I?void 0:I.splitKey).forEach(function(t){var i,r,o,a,l,s,u,d=c(t,null==I?void 0:I.combinationKey);if(p(e,d,null==I?void 0:I.ignoreModifiers)||null!=(u=d.keys)&&u.includes("*")){if(n&&b.current)return;if(i=e,r=d,("function"==typeof(o=null==I?void 0:I.preventDefault)&&o(i,r)||!0===o)&&i.preventDefault(),a=e,l=d,"function"==typeof(s=null==I?void 0:I.enabled)?!s(a,l):!0!==s&&void 0!==s){y(e);return}k.current(e,d),n||(b.current=!0)}})}},i=function(e){void 0!==e.key&&(f(l(e.code)),((null==I?void 0:I.keydown)===void 0&&(null==I?void 0:I.keyup)!==!0||null!=I&&I.keydown)&&t(e))},r=function(e){void 0!==e.key&&(m(l(e.code)),b.current=!1,null!=I&&I.keyup&&t(e,!0))},o=u.current||(null==j?void 0:j.document)||document;return o.addEventListener("keyup",r),o.addEventListener("keydown",i),E&&s(w,null==I?void 0:I.splitKey).forEach(function(e){return E.addHotkey(c(e,null==I?void 0:I.combinationKey,null==I?void 0:I.description))}),function(){o.removeEventListener("keyup",r),o.removeEventListener("keydown",i),E&&s(w,null==I?void 0:I.splitKey).forEach(function(e){return E.removeHotkey(c(e,null==I?void 0:I.combinationKey,null==I?void 0:I.description))})}}},[w,I,T]),u}}},function(e){e.O(0,[898,789,917,525,461,139,183,50,543,696,614,661,90,774,888,179],function(){return e(e.s=31314)}),_N_E=e.O()}]);
@@ -1,8 +0,0 @@
1
- import { useExperimentVariant } from "@/hooks/useExperimentVariant";
2
-
3
- type UseGitIntegrationExperimentReturnType = { eligible: boolean };
4
-
5
- export function useGroupsInSlicesExperiment(): UseGitIntegrationExperimentReturnType {
6
- const variant = useExperimentVariant("slicemachine-groups-in-slices");
7
- return { eligible: variant?.value === "on" };
8
- }