@brilo/base-blocks 0.1.37 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.tsbuildinfo +1 -1
- package/build/blocks/anchor/anchor-group/factory.d.ts.map +1 -1
- package/build/blocks/anchor/anchor-group/factory.js +2 -1
- package/build/blocks/anchor/anchor-group/icon.d.ts +2 -0
- package/build/blocks/anchor/anchor-group/icon.d.ts.map +1 -0
- package/build/blocks/anchor/anchor-group/icon.js +2 -0
- package/build/blocks/anchor/anchor-group/index.d.ts.map +1 -1
- package/build/blocks/anchor/anchor-group/index.js +1 -0
- package/build/blocks/career/career-header/constants.d.ts +2 -0
- package/build/blocks/career/career-header/constants.d.ts.map +1 -0
- package/build/blocks/career/career-header/constants.js +1 -0
- package/build/blocks/career/career-header/edit.d.ts +1 -1
- package/build/blocks/career/career-header/edit.d.ts.map +1 -1
- package/build/blocks/career/career-header/edit.js +6 -3
- package/build/blocks/career/career-header/factory.d.ts.map +1 -1
- package/build/blocks/career/career-header/factory.js +3 -1
- package/build/blocks/career/career-header/index.d.ts +1 -0
- package/build/blocks/career/career-header/index.d.ts.map +1 -1
- package/build/blocks/career/career-header/index.js +4 -0
- package/build/blocks/career/job-position-group/index.d.ts.map +1 -1
- package/build/blocks/career/job-position-group/index.js +1 -0
- package/build/blocks/document/documents-grid/index.d.ts +1 -0
- package/build/blocks/document/documents-grid/index.d.ts.map +1 -1
- package/build/blocks/document/documents-grid/index.js +2 -0
- package/build/blocks/post/post-content/index.d.ts.map +1 -1
- package/build/blocks/post/post-content/index.js +1 -0
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
- package/build/blocks/sections/base-section/edit.js +3 -1
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/build/components/Document/DocumentTermSelectModal.d.ts +8 -0
- package/build/components/Document/DocumentTermSelectModal.d.ts.map +1 -0
- package/build/components/Document/DocumentTermSelectModal.js +49 -0
- package/build/components/Post/PostSelectModal.d.ts +7 -0
- package/build/components/Post/PostSelectModal.d.ts.map +1 -0
- package/build/components/Post/PostSelectModal.js +42 -0
- package/build/components/Post/PostTermSelectModal.d.ts +8 -0
- package/build/components/Post/PostTermSelectModal.d.ts.map +1 -0
- package/build/components/Post/PostTermSelectModal.js +49 -0
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/package.json +1 -1
- package/src/blocks/anchor/anchor-group/editor.scss +1 -1
- package/src/blocks/anchor/anchor-group/factory.tsx +2 -1
- package/src/blocks/anchor/anchor-group/icon.tsx +23 -0
- package/src/blocks/anchor/anchor-group/index.ts +1 -0
- package/src/blocks/anchor/anchor-item/editor.scss +1 -1
- package/src/blocks/career/career-header/constants.ts +1 -0
- package/src/blocks/career/career-header/edit.tsx +5 -2
- package/src/blocks/career/career-header/factory.tsx +2 -1
- package/src/blocks/career/career-header/index.ts +4 -0
- package/src/blocks/career/job-position-group/index.ts +1 -0
- package/src/blocks/document/documents-grid/index.ts +2 -0
- package/src/blocks/post/post-content/index.ts +1 -0
- package/src/blocks/sections/base-section/controls.tsx +5 -1
- package/src/blocks/sections/base-section/edit.tsx +3 -1
- package/src/blocks/sections/base-section/types.ts +9 -3
- package/src/components/Document/DocumentTermSelectModal.tsx +60 -0
- package/src/components/Post/PostSelectModal.tsx +51 -0
- package/src/components/Post/PostTermSelectModal.tsx +60 -0
- package/src/index.ts +8 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
1
2
|
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
3
|
import {__} from '@wordpress/i18n'
|
|
3
4
|
import {createCareerHeaderEdit} from './edit'
|
|
@@ -23,6 +24,6 @@ export function createCareerHeaderBlock(options: CareerHeaderOptions): BlockConf
|
|
|
23
24
|
showEmploymentType: {type: 'boolean', default: true},
|
|
24
25
|
},
|
|
25
26
|
edit: createCareerHeaderEdit(options),
|
|
26
|
-
save: () =>
|
|
27
|
+
save: () => <InnerBlocks.Content />,
|
|
27
28
|
} as unknown as BlockConfiguration<CareerHeaderAttributes>
|
|
28
29
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export type {CareerHeaderAttributes, CareerHeaderOptions} from './types'
|
|
2
2
|
export {createCareerHeaderBlock} from './factory'
|
|
3
|
+
export {DEFAULT_ALLOWED_BLOCKS} from './constants'
|
|
3
4
|
|
|
5
|
+
import {DEFAULT_ALLOWED_BLOCKS} from './constants'
|
|
4
6
|
import type {CareerHeaderOptions} from './types'
|
|
5
7
|
|
|
6
8
|
export const careerHeaderDefaults: CareerHeaderOptions = {
|
|
7
9
|
name: 'brilo/career-header',
|
|
10
|
+
parent: ['brilo/base-section'],
|
|
11
|
+
allowedBlocks: DEFAULT_ALLOWED_BLOCKS,
|
|
8
12
|
}
|
|
@@ -7,9 +7,11 @@ export type {
|
|
|
7
7
|
} from './types'
|
|
8
8
|
export {createDocumentsGridBlock} from './factory'
|
|
9
9
|
export {DocumentsSelectModal} from './DocumentsSelectModal'
|
|
10
|
+
export {DocumentTermSelectModal} from '~/components/Document/DocumentTermSelectModal'
|
|
10
11
|
|
|
11
12
|
import type {DocumentsGridOptions} from './types'
|
|
12
13
|
|
|
13
14
|
export const documentsGridDefaults: DocumentsGridOptions = {
|
|
14
15
|
name: 'brilo/documents-grid',
|
|
16
|
+
parent: ['brilo/base-section'],
|
|
15
17
|
}
|
|
@@ -289,7 +289,11 @@ function BackgroundImageControl({value, onChange}: BackgroundImageControlProps)
|
|
|
289
289
|
onChange={(next) => update({position: next as BackgroundImagePosition})}
|
|
290
290
|
/>
|
|
291
291
|
|
|
292
|
-
<BaseControl
|
|
292
|
+
<BaseControl
|
|
293
|
+
label={__('Překryv barvou', 'brilo-blocks')}
|
|
294
|
+
__nextHasNoMarginBottom
|
|
295
|
+
help={__('Ztmavení/zabarvení obrázku pro lepší čitelnost textu.', 'brilo-blocks')}
|
|
296
|
+
>
|
|
293
297
|
<ColorPalette
|
|
294
298
|
colors={paletteColors}
|
|
295
299
|
value={overlayColor || undefined}
|
|
@@ -26,7 +26,9 @@ export function createBaseSectionEdit<TExtra extends Record<string, unknown> = R
|
|
|
26
26
|
? {
|
|
27
27
|
backgroundImage: [tintLayer, `url(${bgImageSrc})`].filter(Boolean).join(', '),
|
|
28
28
|
backgroundSize: [tintLayer ? '100% 100%' : null, backgroundImage?.fit ?? 'cover'].filter(Boolean).join(', '),
|
|
29
|
-
backgroundPosition: [tintLayer ? 'center center' : null, backgroundImage?.position ?? 'center center']
|
|
29
|
+
backgroundPosition: [tintLayer ? 'center center' : null, backgroundImage?.position ?? 'center center']
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.join(', '),
|
|
30
32
|
backgroundRepeat: 'no-repeat',
|
|
31
33
|
padding: '16px',
|
|
32
34
|
}
|
|
@@ -34,9 +34,15 @@ export interface Decoration {
|
|
|
34
34
|
export type BackgroundImageFit = 'cover' | 'contain'
|
|
35
35
|
|
|
36
36
|
export type BackgroundImagePosition =
|
|
37
|
-
| 'left top'
|
|
38
|
-
| '
|
|
39
|
-
| '
|
|
37
|
+
| 'left top'
|
|
38
|
+
| 'center top'
|
|
39
|
+
| 'right top'
|
|
40
|
+
| 'left center'
|
|
41
|
+
| 'center center'
|
|
42
|
+
| 'right center'
|
|
43
|
+
| 'left bottom'
|
|
44
|
+
| 'center bottom'
|
|
45
|
+
| 'right bottom'
|
|
40
46
|
|
|
41
47
|
export interface BackgroundImageOverlay {
|
|
42
48
|
color?: string
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {View} from '@wordpress/dataviews/wp'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createEntitySelectModal} from '~/components/Event/EntitySelectModal'
|
|
4
|
+
|
|
5
|
+
type DocumentCategoryRecord = {
|
|
6
|
+
id: number
|
|
7
|
+
name: string
|
|
8
|
+
slug: string
|
|
9
|
+
count?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DEFAULT_VIEW: View = {
|
|
13
|
+
type: 'table',
|
|
14
|
+
search: '',
|
|
15
|
+
filters: [],
|
|
16
|
+
page: 1,
|
|
17
|
+
perPage: 20,
|
|
18
|
+
sort: {field: 'name', direction: 'asc'},
|
|
19
|
+
fields: ['slug', 'count'],
|
|
20
|
+
titleField: 'name',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Manual document_category picker (table view, search, sort, checkbox
|
|
25
|
+
* selection, reorderable selection list) with name/slug/count columns. See
|
|
26
|
+
* `EntitySelectModal` for the shared DataViews wiring.
|
|
27
|
+
*/
|
|
28
|
+
export const DocumentTermSelectModal = createEntitySelectModal<DocumentCategoryRecord>({
|
|
29
|
+
endpoint: '/wp/v2/document_category?per_page=100&orderby=name&order=asc&_fields=id,name,slug,count',
|
|
30
|
+
defaultView: DEFAULT_VIEW,
|
|
31
|
+
buttonLabel: __('Vybrat kategorie', 'brilo-blocks'),
|
|
32
|
+
modalTitle: __('Vybrat kategorie', 'brilo-blocks'),
|
|
33
|
+
emptyLabel: __('Nevybrány žádné kategorie.', 'brilo-blocks'),
|
|
34
|
+
getItemLabel: (item) => item.name,
|
|
35
|
+
matchesSearch: (item, needle) => item.name.toLowerCase().includes(needle) || item.slug.toLowerCase().includes(needle),
|
|
36
|
+
sortValue: (item, field) => (item as Record<string, unknown>)[field] as string | number,
|
|
37
|
+
fields: [
|
|
38
|
+
{
|
|
39
|
+
id: 'name',
|
|
40
|
+
label: __('Název', 'brilo-blocks'),
|
|
41
|
+
enableHiding: false,
|
|
42
|
+
enableSorting: true,
|
|
43
|
+
render: ({item}: {item: DocumentCategoryRecord}) => item.name || __('(bez názvu)', 'brilo-blocks'),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'slug',
|
|
47
|
+
label: __('Slug', 'brilo-blocks'),
|
|
48
|
+
enableSorting: true,
|
|
49
|
+
render: ({item}: {item: DocumentCategoryRecord}) => item.slug || '—',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'count',
|
|
53
|
+
label: __('Počet', 'brilo-blocks'),
|
|
54
|
+
enableSorting: true,
|
|
55
|
+
render: ({item}: {item: DocumentCategoryRecord}) => (undefined !== item.count ? String(item.count) : '—'),
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const DocumentTermSelect = DocumentTermSelectModal
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type {View} from '@wordpress/dataviews/wp'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createEntitySelectModal} from '~/components/Event/EntitySelectModal'
|
|
4
|
+
|
|
5
|
+
type PostRecord = {
|
|
6
|
+
id: number
|
|
7
|
+
title: {rendered: string}
|
|
8
|
+
date: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const DEFAULT_VIEW: View = {
|
|
12
|
+
type: 'table',
|
|
13
|
+
search: '',
|
|
14
|
+
filters: [],
|
|
15
|
+
page: 1,
|
|
16
|
+
perPage: 20,
|
|
17
|
+
sort: {field: 'title', direction: 'asc'},
|
|
18
|
+
fields: ['date'],
|
|
19
|
+
titleField: 'title',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Manual post picker (table view, search, sort, checkbox selection,
|
|
24
|
+
* reorderable selection list) with title/date columns. See `EntitySelectModal`
|
|
25
|
+
* for the shared DataViews wiring.
|
|
26
|
+
*/
|
|
27
|
+
export const PostSelectModal = createEntitySelectModal<PostRecord>({
|
|
28
|
+
endpoint: '/wp/v2/posts?per_page=100&orderby=title&order=asc&_fields=id,title,date',
|
|
29
|
+
defaultView: DEFAULT_VIEW,
|
|
30
|
+
buttonLabel: __('Vybrat příspěvky', 'brilo-blocks'),
|
|
31
|
+
modalTitle: __('Vybrat příspěvky', 'brilo-blocks'),
|
|
32
|
+
emptyLabel: __('Nevybrány žádné příspěvky.', 'brilo-blocks'),
|
|
33
|
+
getItemLabel: (item) => item.title.rendered,
|
|
34
|
+
matchesSearch: (item, needle) => item.title.rendered.toLowerCase().includes(needle),
|
|
35
|
+
sortValue: (item, field) => ('title' === field ? item.title.rendered : ((item as never)[field] ?? '')),
|
|
36
|
+
fields: [
|
|
37
|
+
{
|
|
38
|
+
id: 'title',
|
|
39
|
+
label: __('Název', 'brilo-blocks'),
|
|
40
|
+
enableHiding: false,
|
|
41
|
+
enableSorting: true,
|
|
42
|
+
render: ({item}: {item: PostRecord}) => item.title.rendered || __('(bez názvu)', 'brilo-blocks'),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'date',
|
|
46
|
+
label: __('Datum', 'brilo-blocks'),
|
|
47
|
+
enableSorting: true,
|
|
48
|
+
render: ({item}: {item: PostRecord}) => (item.date ? new Date(item.date).toLocaleDateString() : '—'),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {View} from '@wordpress/dataviews/wp'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {createEntitySelectModal} from '~/components/Event/EntitySelectModal'
|
|
4
|
+
|
|
5
|
+
type PostCategoryRecord = {
|
|
6
|
+
id: number
|
|
7
|
+
name: string
|
|
8
|
+
slug: string
|
|
9
|
+
count?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DEFAULT_VIEW: View = {
|
|
13
|
+
type: 'table',
|
|
14
|
+
search: '',
|
|
15
|
+
filters: [],
|
|
16
|
+
page: 1,
|
|
17
|
+
perPage: 20,
|
|
18
|
+
sort: {field: 'name', direction: 'asc'},
|
|
19
|
+
fields: ['slug', 'count'],
|
|
20
|
+
titleField: 'name',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Manual post category picker (table view, search, sort, checkbox
|
|
25
|
+
* selection, reorderable selection list) with name/slug/count columns. See
|
|
26
|
+
* `EntitySelectModal` for the shared DataViews wiring.
|
|
27
|
+
*/
|
|
28
|
+
export const PostTermSelectModal = createEntitySelectModal<PostCategoryRecord>({
|
|
29
|
+
endpoint: '/wp/v2/categories?per_page=100&orderby=name&order=asc&_fields=id,name,slug,count',
|
|
30
|
+
defaultView: DEFAULT_VIEW,
|
|
31
|
+
buttonLabel: __('Vybrat kategorie', 'brilo-blocks'),
|
|
32
|
+
modalTitle: __('Vybrat kategorie', 'brilo-blocks'),
|
|
33
|
+
emptyLabel: __('Nevybrány žádné kategorie.', 'brilo-blocks'),
|
|
34
|
+
getItemLabel: (item) => item.name,
|
|
35
|
+
matchesSearch: (item, needle) => item.name.toLowerCase().includes(needle) || item.slug.toLowerCase().includes(needle),
|
|
36
|
+
sortValue: (item, field) => (item as Record<string, unknown>)[field] as string | number,
|
|
37
|
+
fields: [
|
|
38
|
+
{
|
|
39
|
+
id: 'name',
|
|
40
|
+
label: __('Název', 'brilo-blocks'),
|
|
41
|
+
enableHiding: false,
|
|
42
|
+
enableSorting: true,
|
|
43
|
+
render: ({item}: {item: PostCategoryRecord}) => item.name || __('(bez názvu)', 'brilo-blocks'),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'slug',
|
|
47
|
+
label: __('Slug', 'brilo-blocks'),
|
|
48
|
+
enableSorting: true,
|
|
49
|
+
render: ({item}: {item: PostCategoryRecord}) => item.slug || '—',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'count',
|
|
53
|
+
label: __('Počet', 'brilo-blocks'),
|
|
54
|
+
enableSorting: true,
|
|
55
|
+
render: ({item}: {item: PostCategoryRecord}) => (undefined !== item.count ? String(item.count) : '—'),
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const PostTermSelect = PostTermSelectModal
|
package/src/index.ts
CHANGED
|
@@ -150,6 +150,8 @@ export type {PostSliderGroupAttributes, PostSliderGroupOptions} from './blocks/p
|
|
|
150
150
|
export {createPostSliderGroupBlock, postSliderGroupDefaults} from './blocks/post/post-slider-group'
|
|
151
151
|
export type {PostsGridAttributes, PostsGridOptions} from './blocks/post/posts-grid'
|
|
152
152
|
export {createPostsGridBlock, postsGridDefaults} from './blocks/post/posts-grid'
|
|
153
|
+
export {PostSelectModal} from './components/Post/PostSelectModal'
|
|
154
|
+
export {PostTermSelectModal} from './components/Post/PostTermSelectModal'
|
|
153
155
|
export type {
|
|
154
156
|
DocumentsGridAttributes,
|
|
155
157
|
DocumentsGridOptions,
|
|
@@ -157,7 +159,12 @@ export type {
|
|
|
157
159
|
DocumentsGridMode,
|
|
158
160
|
DocumentsGridSortBy,
|
|
159
161
|
} from './blocks/document/documents-grid'
|
|
160
|
-
export {
|
|
162
|
+
export {
|
|
163
|
+
createDocumentsGridBlock,
|
|
164
|
+
documentsGridDefaults,
|
|
165
|
+
DocumentsSelectModal,
|
|
166
|
+
DocumentTermSelectModal,
|
|
167
|
+
} from './blocks/document/documents-grid'
|
|
161
168
|
export type {LinkItemAttributes, LinkItemIcon, LinkItemOptions} from './blocks/link/link-item'
|
|
162
169
|
export {createLinkItemBlock, linkItemDefaults} from './blocks/link/link-item'
|
|
163
170
|
export type {ContentWithAsideAttributes, ContentWithAsideOptions} from './blocks/layout/layout-content-w-aside'
|