UNPKG

@wordpress/block-library

Version:
1 lines • 2.98 kB
{"version":3,"file":"variations.cjs","names":["__","ATTACHED_MEDIA","gallery","isGalleryFlexLayout","grid"],"sources":["../../src/gallery/variations.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { gallery, grid } from '@wordpress/icons';\nimport { ATTACHED_MEDIA } from './dynamic-source';\nimport { isGalleryFlexLayout } from './shared';\n\nconst variations = [\n\t{\n\t\tname: 'dynamic-gallery',\n\t\ttitle: __( 'Dynamic Gallery' ),\n\t\tdescription: __(\n\t\t\t'Display images from a source, such as those attached to the current post.'\n\t\t),\n\t\tattributes: {\n\t\t\tdynamicContent: { source: ATTACHED_MEDIA },\n\t\t},\n\t\t// Match any gallery that has a dynamic source configured, regardless of\n\t\t// the specific source or options, so the variation's title and\n\t\t// description describe the block whenever it runs in dynamic mode.\n\t\tisActive: ( blockAttributes ) => !! blockAttributes.dynamicContent,\n\t\t// No scopes for now. While dynamic mode only supports the \"attached to the\n\t\t// current post\" source, `'inserter'` is intentionally omitted: a dedicated\n\t\t// inserter entry would surface in post-less contexts (templates, template\n\t\t// parts, synced patterns) where there's no post to resolve images from. The\n\t\t// entry point is instead the inspector toggle on a regular Gallery.\n\t\t// `isActive` still relabels the block card to \"Dynamic Gallery\" regardless\n\t\t// of scope. Revisit adding `'inserter'` in a follow-up as the feature grows\n\t\t// beyond the post-attached source.\n\t\tscope: [],\n\t},\n\t{\n\t\tname: 'gallery-flex',\n\t\ttitle: __( 'Gallery' ),\n\t\tdescription: __( 'Arrange images in flexible rows.' ),\n\t\ticon: gallery,\n\t\tattributes: {\n\t\t\tlayout: {\n\t\t\t\ttype: 'flex',\n\t\t\t},\n\t\t},\n\t\tisActive: ( blockAttributes ) =>\n\t\t\tisGalleryFlexLayout( blockAttributes.layout ),\n\t\tscope: [ 'transform' ],\n\t},\n\t{\n\t\tname: 'gallery-grid',\n\t\ttitle: __( 'Gallery Grid' ),\n\t\tdescription: __( 'Arrange images in a grid.' ),\n\t\ticon: grid,\n\t\tattributes: {\n\t\t\tlayout: {\n\t\t\t\ttype: 'grid',\n\t\t\t},\n\t\t},\n\t\tisActive: ( blockAttributes ) =>\n\t\t\tblockAttributes.layout?.type === 'grid',\n\t\tscope: [ 'transform' ],\n\t},\n];\n\nexport default variations;\n"],"mappings":";;;;;;;;;;AAKA,MAAM,aAAa;CAClB;EACC,MAAM;EACN,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,iBAAkB;EAC7B,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,2EACD;EACA,YAAY,EACX,gBAAgB,EAAE,QAAQC,oBAAAA,eAAe,EAC1C;EAIA,WAAY,oBAAqB,CAAC,CAAE,gBAAgB;EASpD,OAAO,CAAC;CACT;CACA;EACC,MAAM;EACN,QAAA,GAAOD,gBAAAA,GAAAA,CAAI,SAAU;EACrB,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,kCAAmC;EACpD,MAAME,iBAAAA;EACN,YAAY,EACX,QAAQ,EACP,MAAM,OACP,EACD;EACA,WAAY,qBAAA,GACXC,YAAAA,oBAAAA,CAAqB,gBAAgB,MAAO;EAC7C,OAAO,CAAE,WAAY;CACtB;CACA;EACC,MAAM;EACN,QAAA,GAAOH,gBAAAA,GAAAA,CAAI,cAAe;EAC1B,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,2BAA4B;EAC7C,MAAMI,iBAAAA;EACN,YAAY,EACX,QAAQ,EACP,MAAM,OACP,EACD;EACA,WAAY,oBACX,gBAAgB,QAAQ,SAAS;EAClC,OAAO,CAAE,WAAY;CACtB;AACD"}