@brilo/base-blocks 0.1.1 → 0.1.3
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/blocks/form/form-group/edit.d.ts.map +1 -1
- package/build/blocks/form/form-group/edit.js +17 -3
- package/build/blocks/form/form-group/factory.d.ts.map +1 -1
- package/build/blocks/form/form-group/factory.js +1 -0
- package/build/blocks/form/form-group/types.d.ts +1 -0
- package/build/blocks/form/form-group/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/blocks/column/column-group/edit.tsx +56 -0
- package/src/blocks/column/column-group/editor.scss +7 -0
- package/src/blocks/column/column-group/factory.tsx +29 -0
- package/src/blocks/column/column-group/index.ts +14 -0
- package/src/blocks/column/column-group/types.ts +8 -0
- package/src/blocks/column/column-item/constants.ts +1 -0
- package/src/blocks/column/column-item/edit.tsx +48 -0
- package/src/blocks/column/column-item/editor.scss +34 -0
- package/src/blocks/column/column-item/factory.tsx +25 -0
- package/src/blocks/column/column-item/index.ts +10 -0
- package/src/blocks/column/column-item/types.ts +7 -0
- package/src/blocks/compare/compare-group/constants.ts +1 -0
- package/src/blocks/compare/compare-group/edit.tsx +52 -0
- package/src/blocks/compare/compare-group/factory.tsx +29 -0
- package/src/blocks/compare/compare-group/icon.tsx +7 -0
- package/src/blocks/compare/compare-group/index.ts +13 -0
- package/src/blocks/compare/compare-group/types.ts +12 -0
- package/src/blocks/compare/compare-item/edit.tsx +38 -0
- package/src/blocks/compare/compare-item/editor.scss +15 -0
- package/src/blocks/compare/compare-item/factory.tsx +28 -0
- package/src/blocks/compare/compare-item/icon.tsx +9 -0
- package/src/blocks/compare/compare-item/index.ts +13 -0
- package/src/blocks/compare/compare-item/types.ts +9 -0
- package/src/blocks/compare/compare-option/constants.ts +7 -0
- package/src/blocks/compare/compare-option/edit.tsx +64 -0
- package/src/blocks/compare/compare-option/editor.scss +26 -0
- package/src/blocks/compare/compare-option/factory.tsx +35 -0
- package/src/blocks/compare/compare-option/icon.tsx +7 -0
- package/src/blocks/compare/compare-option/index.ts +8 -0
- package/src/blocks/compare/compare-option/types.ts +12 -0
- package/src/blocks/contact/contact-group/constants.ts +3 -0
- package/src/blocks/contact/contact-group/edit.tsx +57 -0
- package/src/blocks/contact/contact-group/editor.scss +20 -0
- package/src/blocks/contact/contact-group/factory.tsx +35 -0
- package/src/blocks/contact/contact-group/index.ts +12 -0
- package/src/blocks/contact/contact-group/types.ts +12 -0
- package/src/blocks/contact/contact-item/constants.ts +17 -0
- package/src/blocks/contact/contact-item/edit.tsx +93 -0
- package/src/blocks/contact/contact-item/editor.scss +38 -0
- package/src/blocks/contact/contact-item/factory.tsx +35 -0
- package/src/blocks/contact/contact-item/index.ts +23 -0
- package/src/blocks/contact/contact-item/types.ts +21 -0
- package/src/blocks/core/basic-button/constants.ts +17 -0
- package/src/blocks/core/basic-button/edit.tsx +107 -0
- package/src/blocks/core/basic-button/editor.scss +80 -0
- package/src/blocks/core/basic-button/factory.tsx +54 -0
- package/src/blocks/core/basic-button/index.ts +8 -0
- package/src/blocks/core/basic-button/types.ts +29 -0
- package/src/blocks/core/basic-heading/constants.ts +1 -0
- package/src/blocks/core/basic-heading/edit.tsx +76 -0
- package/src/blocks/core/basic-heading/editor.scss +8 -0
- package/src/blocks/core/basic-heading/factory.tsx +40 -0
- package/src/blocks/core/basic-heading/index.ts +8 -0
- package/src/blocks/core/basic-heading/types.ts +20 -0
- package/src/blocks/core/basic-overline/edit.tsx +28 -0
- package/src/blocks/core/basic-overline/editor.scss +14 -0
- package/src/blocks/core/basic-overline/factory.tsx +22 -0
- package/src/blocks/core/basic-overline/index.ts +8 -0
- package/src/blocks/core/basic-overline/types.ts +7 -0
- package/src/blocks/faq/faq-group/constants.ts +11 -0
- package/src/blocks/faq/faq-group/edit.tsx +55 -0
- package/src/blocks/faq/faq-group/editor.scss +11 -0
- package/src/blocks/faq/faq-group/factory.tsx +39 -0
- package/src/blocks/faq/faq-group/index.ts +11 -0
- package/src/blocks/faq/faq-group/types.ts +14 -0
- package/src/blocks/faq/faq-item/edit.tsx +50 -0
- package/src/blocks/faq/faq-item/editor.scss +57 -0
- package/src/blocks/faq/faq-item/factory.tsx +24 -0
- package/src/blocks/faq/faq-item/index.ts +9 -0
- package/src/blocks/faq/faq-item/types.ts +7 -0
- package/src/blocks/form/form-field/constants.ts +14 -0
- package/src/blocks/form/form-field/edit.tsx +178 -0
- package/src/blocks/form/form-field/editor.scss +71 -0
- package/src/blocks/form/form-field/factory.tsx +32 -0
- package/src/blocks/form/form-field/index.ts +10 -0
- package/src/blocks/form/form-field/types.ts +18 -0
- package/src/blocks/form/form-group/constants.ts +16 -0
- package/src/blocks/form/form-group/edit.tsx +214 -0
- package/src/blocks/form/form-group/editor.scss +41 -0
- package/src/blocks/form/form-group/factory.tsx +36 -0
- package/src/blocks/form/form-group/index.ts +18 -0
- package/src/blocks/form/form-group/types.ts +23 -0
- package/src/blocks/groups/banner-group/constants.ts +15 -0
- package/src/blocks/groups/banner-group/edit.tsx +122 -0
- package/src/blocks/groups/banner-group/editor.scss +18 -0
- package/src/blocks/groups/banner-group/factory.tsx +64 -0
- package/src/blocks/groups/banner-group/icon.tsx +13 -0
- package/src/blocks/groups/banner-group/index.ts +11 -0
- package/src/blocks/groups/banner-group/types.ts +30 -0
- package/src/blocks/groups/basic-header-group/constants.ts +9 -0
- package/src/blocks/groups/basic-header-group/edit.tsx +99 -0
- package/src/blocks/groups/basic-header-group/editor.scss +35 -0
- package/src/blocks/groups/basic-header-group/factory.tsx +46 -0
- package/src/blocks/groups/basic-header-group/icon.tsx +17 -0
- package/src/blocks/groups/basic-header-group/index.ts +9 -0
- package/src/blocks/groups/basic-header-group/types.ts +27 -0
- package/src/blocks/groups/button-group/constants.ts +7 -0
- package/src/blocks/groups/button-group/edit.tsx +52 -0
- package/src/blocks/groups/button-group/editor.scss +23 -0
- package/src/blocks/groups/button-group/factory.tsx +34 -0
- package/src/blocks/groups/button-group/index.ts +11 -0
- package/src/blocks/groups/button-group/types.ts +12 -0
- package/src/blocks/groups/text-and-media-group/constants.ts +43 -0
- package/src/blocks/groups/text-and-media-group/edit.tsx +241 -0
- package/src/blocks/groups/text-and-media-group/editor.scss +123 -0
- package/src/blocks/groups/text-and-media-group/factory.tsx +100 -0
- package/src/blocks/groups/text-and-media-group/icon.tsx +37 -0
- package/src/blocks/groups/text-and-media-group/index.ts +18 -0
- package/src/blocks/groups/text-and-media-group/types.ts +60 -0
- package/src/blocks/hero/hero-group/constants.ts +23 -0
- package/src/blocks/hero/hero-group/edit.tsx +85 -0
- package/src/blocks/hero/hero-group/editor.scss +0 -0
- package/src/blocks/hero/hero-group/factory.tsx +45 -0
- package/src/blocks/hero/hero-group/icon.tsx +28 -0
- package/src/blocks/hero/hero-group/index.ts +11 -0
- package/src/blocks/hero/hero-group/types.ts +22 -0
- package/src/blocks/hero/hero-item/constants.ts +15 -0
- package/src/blocks/hero/hero-item/edit.tsx +107 -0
- package/src/blocks/hero/hero-item/editor.scss +87 -0
- package/src/blocks/hero/hero-item/factory.tsx +49 -0
- package/src/blocks/hero/hero-item/index.ts +10 -0
- package/src/blocks/hero/hero-item/types.ts +38 -0
- package/src/blocks/map/map-group/constants.ts +20 -0
- package/src/blocks/map/map-group/edit.tsx +108 -0
- package/src/blocks/map/map-group/editor.scss +24 -0
- package/src/blocks/map/map-group/factory.tsx +51 -0
- package/src/blocks/map/map-group/index.ts +9 -0
- package/src/blocks/map/map-group/types.ts +16 -0
- package/src/blocks/newsletter/newsletter-form/constants.ts +5 -0
- package/src/blocks/newsletter/newsletter-form/edit.tsx +194 -0
- package/src/blocks/newsletter/newsletter-form/editor.scss +68 -0
- package/src/blocks/newsletter/newsletter-form/factory.tsx +59 -0
- package/src/blocks/newsletter/newsletter-form/index.ts +11 -0
- package/src/blocks/newsletter/newsletter-form/types.ts +45 -0
- package/src/blocks/post/post-slider-group/constants.ts +3 -0
- package/src/blocks/post/post-slider-group/edit.tsx +76 -0
- package/src/blocks/post/post-slider-group/factory.tsx +43 -0
- package/src/blocks/post/post-slider-group/icon.tsx +13 -0
- package/src/blocks/post/post-slider-group/index.ts +9 -0
- package/src/blocks/post/post-slider-group/types.ts +20 -0
- package/src/blocks/responsive-grid/responsive-grid-group/edit.tsx +95 -0
- package/src/blocks/responsive-grid/responsive-grid-group/factory.tsx +33 -0
- package/src/blocks/responsive-grid/responsive-grid-group/index.ts +13 -0
- package/src/blocks/responsive-grid/responsive-grid-group/types.ts +9 -0
- package/src/blocks/responsive-grid/responsive-grid-item/edit.tsx +19 -0
- package/src/blocks/responsive-grid/responsive-grid-item/factory.tsx +20 -0
- package/src/blocks/responsive-grid/responsive-grid-item/index.ts +9 -0
- package/src/blocks/responsive-grid/responsive-grid-item/types.ts +5 -0
- package/src/blocks/sections/base-section/attributes.ts +17 -0
- package/src/blocks/sections/base-section/constants.ts +18 -0
- package/src/blocks/sections/base-section/controls.tsx +70 -0
- package/src/blocks/sections/base-section/edit.tsx +34 -0
- package/src/blocks/sections/base-section/editor.scss +24 -0
- package/src/blocks/sections/base-section/factory.tsx +47 -0
- package/src/blocks/sections/base-section/icon.tsx +6 -0
- package/src/blocks/sections/base-section/index.ts +14 -0
- package/src/blocks/sections/base-section/types.ts +26 -0
- package/src/blocks/signpost/signpost-group/constants.ts +3 -0
- package/src/blocks/signpost/signpost-group/edit.tsx +75 -0
- package/src/blocks/signpost/signpost-group/editor.scss +0 -0
- package/src/blocks/signpost/signpost-group/factory.tsx +40 -0
- package/src/blocks/signpost/signpost-group/icon.tsx +19 -0
- package/src/blocks/signpost/signpost-group/index.ts +15 -0
- package/src/blocks/signpost/signpost-group/types.ts +9 -0
- package/src/blocks/signpost/signpost-item/constants.ts +4 -0
- package/src/blocks/signpost/signpost-item/edit.tsx +90 -0
- package/src/blocks/signpost/signpost-item/editor.scss +25 -0
- package/src/blocks/signpost/signpost-item/factory.tsx +29 -0
- package/src/blocks/signpost/signpost-item/icon.tsx +7 -0
- package/src/blocks/signpost/signpost-item/index.ts +10 -0
- package/src/blocks/signpost/signpost-item/types.ts +12 -0
- package/src/blocks/step/step-group/constants.ts +6 -0
- package/src/blocks/step/step-group/edit.tsx +64 -0
- package/src/blocks/step/step-group/editor.scss +19 -0
- package/src/blocks/step/step-group/factory.tsx +36 -0
- package/src/blocks/step/step-group/icon.tsx +27 -0
- package/src/blocks/step/step-group/index.ts +15 -0
- package/src/blocks/step/step-group/types.ts +13 -0
- package/src/blocks/step/step-item/constants.ts +6 -0
- package/src/blocks/step/step-item/edit.tsx +60 -0
- package/src/blocks/step/step-item/editor.scss +18 -0
- package/src/blocks/step/step-item/factory.tsx +27 -0
- package/src/blocks/step/step-item/index.ts +11 -0
- package/src/blocks/step/step-item/types.ts +12 -0
- package/src/blocks/testimonial/testimonial-group/constants.ts +27 -0
- package/src/blocks/testimonial/testimonial-group/edit.tsx +74 -0
- package/src/blocks/testimonial/testimonial-group/editor.scss +38 -0
- package/src/blocks/testimonial/testimonial-group/factory.tsx +44 -0
- package/src/blocks/testimonial/testimonial-group/icon.tsx +33 -0
- package/src/blocks/testimonial/testimonial-group/index.ts +15 -0
- package/src/blocks/testimonial/testimonial-group/types.ts +19 -0
- package/src/blocks/testimonial/testimonial-item/edit.tsx +48 -0
- package/src/blocks/testimonial/testimonial-item/editor.scss +20 -0
- package/src/blocks/testimonial/testimonial-item/factory.tsx +35 -0
- package/src/blocks/testimonial/testimonial-item/index.ts +9 -0
- package/src/blocks/testimonial/testimonial-item/types.ts +9 -0
- package/src/blocks/text-and-form/text-and-form-group/constants.ts +6 -0
- package/src/blocks/text-and-form/text-and-form-group/edit.tsx +59 -0
- package/src/blocks/text-and-form/text-and-form-group/editor.scss +21 -0
- package/src/blocks/text-and-form/text-and-form-group/factory.tsx +38 -0
- package/src/blocks/text-and-form/text-and-form-group/icon.tsx +23 -0
- package/src/blocks/text-and-form/text-and-form-group/index.ts +9 -0
- package/src/blocks/text-and-form/text-and-form-group/types.ts +23 -0
- package/src/blocks/text-and-form/text-and-form-text-column/constants.ts +10 -0
- package/src/blocks/text-and-form/text-and-form-text-column/edit.tsx +94 -0
- package/src/blocks/text-and-form/text-and-form-text-column/editor.scss +29 -0
- package/src/blocks/text-and-form/text-and-form-text-column/factory.tsx +41 -0
- package/src/blocks/text-and-form/text-and-form-text-column/index.ts +18 -0
- package/src/blocks/text-and-form/text-and-form-text-column/types.ts +23 -0
- package/src/blocks/usp/usp-group/constants.ts +54 -0
- package/src/blocks/usp/usp-group/edit.tsx +197 -0
- package/src/blocks/usp/usp-group/editor.scss +24 -0
- package/src/blocks/usp/usp-group/factory.tsx +113 -0
- package/src/blocks/usp/usp-group/icon.tsx +18 -0
- package/src/blocks/usp/usp-group/index.ts +15 -0
- package/src/blocks/usp/usp-group/types.ts +70 -0
- package/src/blocks/usp/usp-item/constants.ts +7 -0
- package/src/blocks/usp/usp-item/edit.tsx +65 -0
- package/src/blocks/usp/usp-item/editor.scss +17 -0
- package/src/blocks/usp/usp-item/factory.tsx +30 -0
- package/src/blocks/usp/usp-item/index.ts +11 -0
- package/src/blocks/usp/usp-item/types.ts +17 -0
- package/src/components/IconControl/IconControl.tsx +55 -0
- package/src/components/IconControl/editor.scss +53 -0
- package/src/components/IconControl/index.ts +2 -0
- package/src/components/IconControl/index.tsx +1 -0
- package/src/components/ImagePicker/ImagePicker.tsx +124 -0
- package/src/components/ImagePicker/editor.scss +79 -0
- package/src/components/ImagePicker/index.ts +2 -0
- package/src/components/ImagePicker/index.tsx +1 -0
- package/src/components/ItemIconControl/ItemIconControl.tsx +72 -0
- package/src/components/ItemIconControl/ItemIconModal.tsx +12 -0
- package/src/components/ItemIconControl/ItemIconPreview.tsx +93 -0
- package/src/components/ItemIconControl/editor.scss +52 -0
- package/src/components/ItemIconControl/index.ts +2 -0
- package/src/components/ItemIconControl/types.d.ts +30 -0
- package/src/constants.ts +20 -0
- package/src/editor.scss +34 -0
- package/src/globals.scss +237 -0
- package/src/hooks/useGroupBlock.ts +53 -0
- package/src/index.ts +122 -0
- package/src/types.ts +33 -0
- package/src/utils/createEditAdapter.ts +11 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
.wp-block-brilo-faq-item {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
border: 1px solid var(--border-color);
|
|
4
|
+
background: white;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.faq-item {
|
|
8
|
+
--dropdown-scale: -1;
|
|
9
|
+
--content-display: block;
|
|
10
|
+
|
|
11
|
+
&:has(input:checked) {
|
|
12
|
+
--dropdown-scale: 1;
|
|
13
|
+
--content-display: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.block-editor-block-list__layout {
|
|
17
|
+
p {
|
|
18
|
+
margin-block: 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.faq-item__content {
|
|
24
|
+
border: 1px solid var(--border-color);
|
|
25
|
+
padding: 12px;
|
|
26
|
+
display: var(--content-display);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.faq-item__dropdown {
|
|
30
|
+
height: 32px;
|
|
31
|
+
width: 32px;
|
|
32
|
+
margin-top: 21px;
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
position: relative;
|
|
35
|
+
background-color: #2271b1;
|
|
36
|
+
transition: background-color 0.3s ease;
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
background-color: #135e96;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
svg {
|
|
43
|
+
fill: white;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
input {
|
|
47
|
+
position: absolute;
|
|
48
|
+
bottom: 100%;
|
|
49
|
+
left: 0;
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.faq-item__dropdown-icon {
|
|
55
|
+
transition: transform 0.3s ease;
|
|
56
|
+
transform: scale(var(--dropdown-scale));
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createFaqItemEdit} from './edit'
|
|
5
|
+
import type {FaqItemAttributes, FaqItemOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export type {FaqItemAttributes, FaqItemOptions}
|
|
8
|
+
|
|
9
|
+
export function createFaqItemBlock(options: FaqItemOptions): BlockConfiguration<FaqItemAttributes> {
|
|
10
|
+
return {
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: options.title ?? __('FAQ položka', 'brilo-blocks'),
|
|
13
|
+
description: options.description,
|
|
14
|
+
category: options.category ?? 'layout',
|
|
15
|
+
...(options.parent && {parent: options.parent}),
|
|
16
|
+
icon: options.icon ?? 'editor-help',
|
|
17
|
+
supports: {html: false, customClassName: false},
|
|
18
|
+
attributes: {
|
|
19
|
+
title: {type: 'string', default: ''},
|
|
20
|
+
},
|
|
21
|
+
edit: createFaqItemEdit(options),
|
|
22
|
+
save: () => <InnerBlocks.Content />,
|
|
23
|
+
} as unknown as BlockConfiguration<FaqItemAttributes>
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type {FaqItemAttributes, FaqItemOptions} from './types'
|
|
2
|
+
export {createFaqItemBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {FaqItemOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const faqItemDefaults: FaqItemOptions = {
|
|
7
|
+
name: 'brilo/faq-item',
|
|
8
|
+
parent: ['brilo/faq-group'],
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const FIELD_TYPE_VALUES = ['text', 'textarea', 'select', 'hidden'] as const
|
|
4
|
+
|
|
5
|
+
export const FIELD_TYPES = [
|
|
6
|
+
{value: FIELD_TYPE_VALUES[0], label: __('Text', 'brilo-blocks')},
|
|
7
|
+
{value: FIELD_TYPE_VALUES[1], label: __('Textarea', 'brilo-blocks')},
|
|
8
|
+
{value: FIELD_TYPE_VALUES[2], label: __('Select', 'brilo-blocks')},
|
|
9
|
+
{value: FIELD_TYPE_VALUES[3], label: __('Hidden', 'brilo-blocks')},
|
|
10
|
+
] as const
|
|
11
|
+
|
|
12
|
+
export const FIELD_COLUMNS_RANGE = {min: 1, max: 12} as const
|
|
13
|
+
|
|
14
|
+
export const FIELD_COLUMNS_DEFAULT = 6
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
|
|
2
|
+
import {Button, FormTokenField, PanelBody, RangeControl, SelectControl, TextControl, ToggleControl} from '@wordpress/components'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import clsx from 'clsx'
|
|
5
|
+
import {FIELD_COLUMNS_DEFAULT, FIELD_COLUMNS_RANGE, FIELD_TYPES} from './constants'
|
|
6
|
+
import type {FormFieldAttributes, FormFieldOptions, FormFieldType} from './types'
|
|
7
|
+
|
|
8
|
+
const {min: MIN_COLUMNS, max: MAX_COLUMNS} = FIELD_COLUMNS_RANGE
|
|
9
|
+
|
|
10
|
+
function sanitizeHtmlName(raw: string): string {
|
|
11
|
+
return (raw ?? '')
|
|
12
|
+
.normalize('NFD')
|
|
13
|
+
.replace(/\p{Diacritic}/gu, '')
|
|
14
|
+
.replace(/[\s_]+/g, '-')
|
|
15
|
+
.replace(/[^a-zA-Z0-9_-]/g, '')
|
|
16
|
+
.replace(/[-_]{2,}/g, '-')
|
|
17
|
+
.replace(/^[-_]+/g, '')
|
|
18
|
+
.toLowerCase()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createFormFieldEdit(_options: FormFieldOptions) {
|
|
22
|
+
return function Edit({
|
|
23
|
+
attributes,
|
|
24
|
+
setAttributes,
|
|
25
|
+
}: {
|
|
26
|
+
attributes: FormFieldAttributes
|
|
27
|
+
setAttributes: (a: Partial<FormFieldAttributes>) => void
|
|
28
|
+
}) {
|
|
29
|
+
const currentColumns = Math.max(MIN_COLUMNS, Math.min(MAX_COLUMNS, attributes.columns || MIN_COLUMNS))
|
|
30
|
+
|
|
31
|
+
const blockProps = useBlockProps({
|
|
32
|
+
className: clsx('i-form-field', `--type-${attributes.type}`, `--cols-${currentColumns}`, attributes.required && '--required'),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const options = Array.isArray(attributes.options) ? attributes.options.filter((opt): opt is string => typeof opt === 'string') : []
|
|
36
|
+
|
|
37
|
+
const selectOptions = [{label: __('Žádná', 'brilo-blocks'), value: ''}, ...options.map((opt) => ({label: opt, value: opt}))]
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<InspectorControls>
|
|
42
|
+
<PanelBody title={__('Pole formuláře', 'brilo-blocks')}>
|
|
43
|
+
<SelectControl
|
|
44
|
+
label={__('Typ inputu', 'brilo-blocks')}
|
|
45
|
+
value={attributes.type}
|
|
46
|
+
options={FIELD_TYPES.map((t) => ({label: t.label, value: t.value}))}
|
|
47
|
+
onChange={(type) => setAttributes({type: type as FormFieldType})}
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
{attributes.type !== 'hidden' && (
|
|
51
|
+
<>
|
|
52
|
+
<TextControl label={__('Popisek', 'brilo-blocks')} value={attributes.label} onChange={(label) => setAttributes({label})} />
|
|
53
|
+
<ToggleControl
|
|
54
|
+
label={__('Povinné', 'brilo-blocks')}
|
|
55
|
+
checked={attributes.required}
|
|
56
|
+
onChange={(required) => setAttributes({required})}
|
|
57
|
+
/>
|
|
58
|
+
<TextControl
|
|
59
|
+
label={__('Název html atributu', 'brilo-blocks')}
|
|
60
|
+
value={attributes.name}
|
|
61
|
+
help={__(
|
|
62
|
+
'Použijte pouze bezpečné znaky: a-z, 0-9, pomlčka a podtržítko. Např. city-born-to. Mezery a diakritika se automaticky odstraní.',
|
|
63
|
+
'brilo-blocks',
|
|
64
|
+
)}
|
|
65
|
+
onChange={(name) => setAttributes({name: sanitizeHtmlName(name)})}
|
|
66
|
+
/>
|
|
67
|
+
<TextControl
|
|
68
|
+
label={__('Placeholder', 'brilo-blocks')}
|
|
69
|
+
value={attributes.placeholder}
|
|
70
|
+
onChange={(placeholder) => setAttributes({placeholder})}
|
|
71
|
+
/>
|
|
72
|
+
</>
|
|
73
|
+
)}
|
|
74
|
+
|
|
75
|
+
{attributes.type === 'select' && (
|
|
76
|
+
<>
|
|
77
|
+
<FormTokenField
|
|
78
|
+
label={__('Možnosti', 'brilo-blocks')}
|
|
79
|
+
value={options}
|
|
80
|
+
onChange={(nextOptions) =>
|
|
81
|
+
setAttributes({
|
|
82
|
+
options: (nextOptions ?? [])
|
|
83
|
+
.map((opt) => (typeof opt === 'string' ? opt : (opt as {value?: unknown}).value))
|
|
84
|
+
.filter((opt): opt is string => typeof opt === 'string' && opt.length > 0),
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
<SelectControl
|
|
90
|
+
label={__('Výchozí hodnota', 'brilo-blocks')}
|
|
91
|
+
value={attributes.defaultValue ?? ''}
|
|
92
|
+
options={selectOptions}
|
|
93
|
+
onChange={(defaultValue) => setAttributes({defaultValue: defaultValue ?? ''})}
|
|
94
|
+
/>
|
|
95
|
+
</>
|
|
96
|
+
)}
|
|
97
|
+
|
|
98
|
+
{attributes.type === 'hidden' && (
|
|
99
|
+
<>
|
|
100
|
+
<TextControl
|
|
101
|
+
label={__('Hodnota', 'brilo-blocks')}
|
|
102
|
+
value={attributes.value ?? ''}
|
|
103
|
+
onChange={(value) => setAttributes({value})}
|
|
104
|
+
help={__('Hodnota, která bude odeslána s formulářem.', 'brilo-blocks')}
|
|
105
|
+
/>
|
|
106
|
+
<TextControl
|
|
107
|
+
label={__('Název html atributu', 'brilo-blocks')}
|
|
108
|
+
value={attributes.name}
|
|
109
|
+
help={__(
|
|
110
|
+
'Použijte pouze bezpečné znaky: a-z, 0-9, pomlčka a podtržítko. Mezery a diakritika se automaticky odstraní.',
|
|
111
|
+
'brilo-blocks',
|
|
112
|
+
)}
|
|
113
|
+
onChange={(name) => setAttributes({name: sanitizeHtmlName(name)})}
|
|
114
|
+
/>
|
|
115
|
+
</>
|
|
116
|
+
)}
|
|
117
|
+
|
|
118
|
+
{attributes.type !== 'hidden' && (
|
|
119
|
+
<RangeControl
|
|
120
|
+
label={__('Počet sloupců', 'brilo-blocks')}
|
|
121
|
+
value={currentColumns}
|
|
122
|
+
min={MIN_COLUMNS}
|
|
123
|
+
max={MAX_COLUMNS}
|
|
124
|
+
onChange={(columns) =>
|
|
125
|
+
setAttributes({columns: Math.max(MIN_COLUMNS, Math.min(MAX_COLUMNS, columns ?? FIELD_COLUMNS_DEFAULT))})
|
|
126
|
+
}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
</PanelBody>
|
|
130
|
+
</InspectorControls>
|
|
131
|
+
|
|
132
|
+
<div {...blockProps}>
|
|
133
|
+
<div className="i-form-field__wrapper">
|
|
134
|
+
{attributes.type === 'hidden' ? (
|
|
135
|
+
<>
|
|
136
|
+
<strong>{__('Skryté pole', 'brilo-blocks')}</strong>
|
|
137
|
+
<div>
|
|
138
|
+
{__('Hodnota', 'brilo-blocks')}: {attributes.value ?? ''}
|
|
139
|
+
</div>
|
|
140
|
+
<div>
|
|
141
|
+
{__('Název', 'brilo-blocks')}: {attributes.name ?? ''}
|
|
142
|
+
</div>
|
|
143
|
+
</>
|
|
144
|
+
) : (
|
|
145
|
+
<>
|
|
146
|
+
<strong>{attributes.label || __('Pole', 'brilo-blocks')}</strong>
|
|
147
|
+
<div>{attributes.type}</div>
|
|
148
|
+
<div className="i-form-field__columns-control">
|
|
149
|
+
<Button
|
|
150
|
+
size="small"
|
|
151
|
+
variant="secondary"
|
|
152
|
+
onClick={() => setAttributes({columns: Math.max(MIN_COLUMNS, currentColumns - 1)})}
|
|
153
|
+
disabled={currentColumns <= MIN_COLUMNS}
|
|
154
|
+
aria-label={__('Snížit počet sloupců', 'brilo-blocks')}
|
|
155
|
+
>
|
|
156
|
+
-
|
|
157
|
+
</Button>
|
|
158
|
+
|
|
159
|
+
<div className="i-form-field__columns-value">{`${currentColumns}/${MAX_COLUMNS}`}</div>
|
|
160
|
+
|
|
161
|
+
<Button
|
|
162
|
+
size="small"
|
|
163
|
+
variant="secondary"
|
|
164
|
+
onClick={() => setAttributes({columns: Math.min(MAX_COLUMNS, currentColumns + 1)})}
|
|
165
|
+
disabled={currentColumns >= MAX_COLUMNS}
|
|
166
|
+
aria-label={__('Zvýšit počet sloupců', 'brilo-blocks')}
|
|
167
|
+
>
|
|
168
|
+
+
|
|
169
|
+
</Button>
|
|
170
|
+
</div>
|
|
171
|
+
</>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.i-form-field {
|
|
2
|
+
width: 100%;
|
|
3
|
+
margin-block: 0;
|
|
4
|
+
|
|
5
|
+
&.--cols-1 {
|
|
6
|
+
grid-column: span 1;
|
|
7
|
+
}
|
|
8
|
+
&.--cols-2 {
|
|
9
|
+
grid-column: span 2;
|
|
10
|
+
}
|
|
11
|
+
&.--cols-3 {
|
|
12
|
+
grid-column: span 3;
|
|
13
|
+
}
|
|
14
|
+
&.--cols-4 {
|
|
15
|
+
grid-column: span 4;
|
|
16
|
+
}
|
|
17
|
+
&.--cols-5 {
|
|
18
|
+
grid-column: span 5;
|
|
19
|
+
}
|
|
20
|
+
&.--cols-6 {
|
|
21
|
+
grid-column: span 6;
|
|
22
|
+
}
|
|
23
|
+
&.--cols-7 {
|
|
24
|
+
grid-column: span 7;
|
|
25
|
+
}
|
|
26
|
+
&.--cols-8 {
|
|
27
|
+
grid-column: span 8;
|
|
28
|
+
}
|
|
29
|
+
&.--cols-9 {
|
|
30
|
+
grid-column: span 9;
|
|
31
|
+
}
|
|
32
|
+
&.--cols-10 {
|
|
33
|
+
grid-column: span 10;
|
|
34
|
+
}
|
|
35
|
+
&.--cols-11 {
|
|
36
|
+
grid-column: span 11;
|
|
37
|
+
}
|
|
38
|
+
&.--cols-12 {
|
|
39
|
+
grid-column: span 12;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Hidden fields span the full row — no column control
|
|
43
|
+
&.--type-hidden {
|
|
44
|
+
grid-column: span 12;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.--type-hidden .i-form-field__wrapper {
|
|
48
|
+
background: #f6f7f7;
|
|
49
|
+
border-style: dotted;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.i-form-field__wrapper {
|
|
54
|
+
padding: 12px;
|
|
55
|
+
border: 1px dashed rgba(0, 0, 0, 0.25);
|
|
56
|
+
background: #fff;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.i-form-field__columns-control {
|
|
60
|
+
margin-top: 10px;
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: space-between;
|
|
64
|
+
gap: 8px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.i-form-field__columns-value {
|
|
68
|
+
flex: 1;
|
|
69
|
+
text-align: center;
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {FIELD_COLUMNS_DEFAULT} from './constants'
|
|
4
|
+
import {createFormFieldEdit} from './edit'
|
|
5
|
+
import type {FormFieldAttributes, FormFieldOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export type {FormFieldAttributes, FormFieldOptions}
|
|
8
|
+
|
|
9
|
+
export function createFormFieldBlock(options: FormFieldOptions): BlockConfiguration<FormFieldAttributes> {
|
|
10
|
+
return {
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: options.title ?? __('Pole formuláře', 'brilo-blocks'),
|
|
13
|
+
description: options.description,
|
|
14
|
+
category: options.category ?? 'layout',
|
|
15
|
+
...(options.parent && {parent: options.parent}),
|
|
16
|
+
icon: options.icon ?? 'forms',
|
|
17
|
+
supports: {html: false, customClassName: false, reusable: false},
|
|
18
|
+
attributes: {
|
|
19
|
+
type: {type: 'string', default: 'text'},
|
|
20
|
+
columns: {type: 'number', default: FIELD_COLUMNS_DEFAULT},
|
|
21
|
+
label: {type: 'string', default: ''},
|
|
22
|
+
name: {type: 'string', default: ''},
|
|
23
|
+
placeholder: {type: 'string', default: ''},
|
|
24
|
+
required: {type: 'boolean', default: false},
|
|
25
|
+
options: {type: 'array', default: []},
|
|
26
|
+
defaultValue: {type: 'string', default: ''},
|
|
27
|
+
value: {type: 'string', default: ''},
|
|
28
|
+
},
|
|
29
|
+
edit: createFormFieldEdit(options),
|
|
30
|
+
save: () => null,
|
|
31
|
+
} as unknown as BlockConfiguration<FormFieldAttributes>
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {FormFieldAttributes, FormFieldOptions, FormFieldType} from './types'
|
|
2
|
+
export {createFormFieldBlock} from './factory'
|
|
3
|
+
export {FIELD_TYPES, FIELD_COLUMNS_RANGE, FIELD_COLUMNS_DEFAULT} from './constants'
|
|
4
|
+
|
|
5
|
+
import type {FormFieldOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export const formFieldDefaults: FormFieldOptions = {
|
|
8
|
+
name: 'brilo/form-field',
|
|
9
|
+
parent: ['brilo/form-group'],
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {FIELD_TYPE_VALUES} from './constants'
|
|
2
|
+
import type {BriloBlockType} from '~/types'
|
|
3
|
+
|
|
4
|
+
export type FormFieldType = (typeof FIELD_TYPE_VALUES)[number]
|
|
5
|
+
|
|
6
|
+
export interface FormFieldAttributes extends Record<string, unknown> {
|
|
7
|
+
type: FormFieldType
|
|
8
|
+
columns: number
|
|
9
|
+
label: string
|
|
10
|
+
name: string
|
|
11
|
+
placeholder: string
|
|
12
|
+
required: boolean
|
|
13
|
+
options: string[]
|
|
14
|
+
defaultValue: string
|
|
15
|
+
value: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface FormFieldOptions extends BriloBlockType {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const PROCESSING_MODES = [
|
|
4
|
+
{value: 'internal', label: __('Interní', 'brilo-blocks')},
|
|
5
|
+
{value: 'external', label: __('Externí', 'brilo-blocks')},
|
|
6
|
+
] as const
|
|
7
|
+
|
|
8
|
+
export const EXTERNAL_METHODS = [
|
|
9
|
+
{value: 'POST', label: 'POST'},
|
|
10
|
+
{value: 'GET', label: 'GET'},
|
|
11
|
+
] as const
|
|
12
|
+
|
|
13
|
+
export const INTERNAL_SUBMIT_BEHAVIORS = [
|
|
14
|
+
{value: 'stay', label: __('Zůstat na stránce', 'brilo-blocks')},
|
|
15
|
+
{value: 'redirect', label: __('Přesměrovat na děkovnou stránku', 'brilo-blocks')},
|
|
16
|
+
] as const
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import {InspectorControls, RichText} from '@wordpress/block-editor'
|
|
2
|
+
import {FormTokenField, Notice, PanelBody, SelectControl, TextControl, ToggleControl} from '@wordpress/components'
|
|
3
|
+
import {useDispatch} from '@wordpress/data'
|
|
4
|
+
import {__} from '@wordpress/i18n'
|
|
5
|
+
import {cleanForSlug} from '@wordpress/url'
|
|
6
|
+
import clsx from 'clsx'
|
|
7
|
+
import {useEffect} from 'react'
|
|
8
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
9
|
+
import {EXTERNAL_METHODS, INTERNAL_SUBMIT_BEHAVIORS, PROCESSING_MODES} from './constants'
|
|
10
|
+
import type {ExternalMethod, FormGroupAttributes, FormGroupOptions, InternalSubmitBehavior, ProcessingMode} from './types'
|
|
11
|
+
|
|
12
|
+
const ALLOWED_BLOCKS = ['brilo/form-field']
|
|
13
|
+
|
|
14
|
+
function generateFormId(formName: string): string {
|
|
15
|
+
const slug = cleanForSlug(formName) || 'form'
|
|
16
|
+
const hash = Math.random().toString(36).slice(2, 8)
|
|
17
|
+
|
|
18
|
+
return `form-${slug}-${hash}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createFormGroupEdit(options: FormGroupOptions) {
|
|
22
|
+
return function Edit({
|
|
23
|
+
attributes,
|
|
24
|
+
setAttributes,
|
|
25
|
+
clientId,
|
|
26
|
+
}: {
|
|
27
|
+
attributes: FormGroupAttributes
|
|
28
|
+
setAttributes: (a: Partial<FormGroupAttributes>) => void
|
|
29
|
+
clientId: string
|
|
30
|
+
}) {
|
|
31
|
+
const {lockPostSaving, unlockPostSaving} = useDispatch('core/editor') as unknown as {
|
|
32
|
+
lockPostSaving: (lockName: string) => void
|
|
33
|
+
unlockPostSaving: (lockName: string) => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const processingMode = attributes.processingMode ?? 'internal'
|
|
37
|
+
const isInternal = processingMode === 'internal'
|
|
38
|
+
const isExternal = processingMode === 'external'
|
|
39
|
+
const recipients = Array.isArray(attributes.senders) ? attributes.senders : []
|
|
40
|
+
const isRecipientsMissing = isInternal && recipients.length === 0
|
|
41
|
+
const isExternalUrlMissing = isExternal && (attributes.externalUrl ?? '').trim() === ''
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const lockName = `brilo-form-group-${clientId}`
|
|
45
|
+
|
|
46
|
+
if (isRecipientsMissing || isExternalUrlMissing) {
|
|
47
|
+
lockPostSaving(lockName)
|
|
48
|
+
} else {
|
|
49
|
+
unlockPostSaving(lockName)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return () => unlockPostSaving(lockName)
|
|
53
|
+
}, [clientId, isRecipientsMissing, isExternalUrlMissing, lockPostSaving, unlockPostSaving])
|
|
54
|
+
|
|
55
|
+
// Generated once and persisted into the block's attributes so it stays stable across edits.
|
|
56
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: must run once on mount only
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!attributes.formId) {
|
|
59
|
+
setAttributes({formId: generateFormId(attributes.formName ?? '')})
|
|
60
|
+
}
|
|
61
|
+
}, [])
|
|
62
|
+
|
|
63
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
64
|
+
blockClassName: clsx(options.blockClassName ?? 'g-form wp-block-section'),
|
|
65
|
+
containerClassName: [options.containerClassName ?? 'g-form__fields'],
|
|
66
|
+
allowedBlocks: options.allowedBlocks ?? ALLOWED_BLOCKS,
|
|
67
|
+
template: options.template,
|
|
68
|
+
orientation: 'horizontal',
|
|
69
|
+
layout: {type: 'default'},
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<InspectorControls>
|
|
75
|
+
<PanelBody title={__('Formulář', 'brilo-blocks')}>
|
|
76
|
+
<TextControl
|
|
77
|
+
label={__('ID formuláře', 'brilo-blocks')}
|
|
78
|
+
value={attributes.formId ?? ''}
|
|
79
|
+
readOnly
|
|
80
|
+
onChange={() => {}}
|
|
81
|
+
help={__('Generuje se automaticky, slouží k jednoznačné identifikaci formuláře.', 'brilo-blocks')}
|
|
82
|
+
/>
|
|
83
|
+
|
|
84
|
+
<TextControl
|
|
85
|
+
label={__('Název formuláře (volitelné)', 'brilo-blocks')}
|
|
86
|
+
value={attributes.formName ?? ''}
|
|
87
|
+
placeholder={__('Např. Kontaktní formulář', 'brilo-blocks')}
|
|
88
|
+
onChange={(formName) => setAttributes({formName})}
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
<SelectControl
|
|
92
|
+
label={__('Zpracování', 'brilo-blocks')}
|
|
93
|
+
value={processingMode}
|
|
94
|
+
options={PROCESSING_MODES.map((m) => ({label: m.label, value: m.value}))}
|
|
95
|
+
onChange={(mode) => setAttributes({processingMode: mode as ProcessingMode})}
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
{isExternal && (
|
|
99
|
+
<>
|
|
100
|
+
<SelectControl
|
|
101
|
+
label={__('Metoda odeslání', 'brilo-blocks')}
|
|
102
|
+
value={attributes.externalMethod ?? 'POST'}
|
|
103
|
+
options={EXTERNAL_METHODS.map((m) => ({label: m.label, value: m.value}))}
|
|
104
|
+
onChange={(externalMethod) => setAttributes({externalMethod: externalMethod as ExternalMethod})}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<TextControl
|
|
108
|
+
label={__('Externí URL', 'brilo-blocks')}
|
|
109
|
+
value={attributes.externalUrl ?? ''}
|
|
110
|
+
onChange={(externalUrl) => setAttributes({externalUrl})}
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
{isExternalUrlMissing && (
|
|
114
|
+
<Notice status="warning" isDismissible={false}>
|
|
115
|
+
{__('Pole „Externí URL“ je povinné pro externí zpracování.', 'brilo-blocks')}
|
|
116
|
+
</Notice>
|
|
117
|
+
)}
|
|
118
|
+
</>
|
|
119
|
+
)}
|
|
120
|
+
|
|
121
|
+
{isInternal && (
|
|
122
|
+
<>
|
|
123
|
+
<FormTokenField
|
|
124
|
+
label={__('Komu (příjemci)', 'brilo-blocks')}
|
|
125
|
+
value={recipients}
|
|
126
|
+
__next40pxDefaultSize
|
|
127
|
+
onChange={(senders) =>
|
|
128
|
+
setAttributes({
|
|
129
|
+
senders: (senders ?? [])
|
|
130
|
+
.map((item) => (typeof item === 'string' ? item.trim() : ''))
|
|
131
|
+
.filter((item): item is string => item.length > 0),
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
{isRecipientsMissing && (
|
|
137
|
+
<Notice status="warning" isDismissible={false}>
|
|
138
|
+
{__('Pole „Komu (příjemci)“ je povinné. Vyplňte alespoň jeden e-mail příjemce.', 'brilo-blocks')}
|
|
139
|
+
</Notice>
|
|
140
|
+
)}
|
|
141
|
+
|
|
142
|
+
<TextControl
|
|
143
|
+
label={__('Od koho (From email)', 'brilo-blocks')}
|
|
144
|
+
value={attributes.fromEmail ?? ''}
|
|
145
|
+
onChange={(fromEmail) => setAttributes({fromEmail})}
|
|
146
|
+
/>
|
|
147
|
+
|
|
148
|
+
<TextControl
|
|
149
|
+
label={__('Předmět emailu', 'brilo-blocks')}
|
|
150
|
+
value={attributes.subject ?? ''}
|
|
151
|
+
placeholder={__('Potvrzení odeslaného formuláře', 'brilo-blocks')}
|
|
152
|
+
onChange={(subject) => setAttributes({subject})}
|
|
153
|
+
/>
|
|
154
|
+
|
|
155
|
+
<SelectControl
|
|
156
|
+
label={__('Po odeslání', 'brilo-blocks')}
|
|
157
|
+
value={attributes.internalSubmitBehavior ?? 'stay'}
|
|
158
|
+
options={INTERNAL_SUBMIT_BEHAVIORS.map((b) => ({label: b.label, value: b.value}))}
|
|
159
|
+
onChange={(internalSubmitBehavior) =>
|
|
160
|
+
setAttributes({internalSubmitBehavior: internalSubmitBehavior as InternalSubmitBehavior})
|
|
161
|
+
}
|
|
162
|
+
/>
|
|
163
|
+
|
|
164
|
+
{(attributes.internalSubmitBehavior ?? 'stay') === 'redirect' && (
|
|
165
|
+
<TextControl
|
|
166
|
+
label={__('URL děkovné stránky', 'brilo-blocks')}
|
|
167
|
+
value={attributes.internalRedirectUrl ?? ''}
|
|
168
|
+
onChange={(internalRedirectUrl) => setAttributes({internalRedirectUrl})}
|
|
169
|
+
/>
|
|
170
|
+
)}
|
|
171
|
+
|
|
172
|
+
<TextControl
|
|
173
|
+
label={__('Úspěšná zpráva', 'brilo-blocks')}
|
|
174
|
+
value={attributes.successMessage ?? ''}
|
|
175
|
+
onChange={(successMessage) => setAttributes({successMessage})}
|
|
176
|
+
/>
|
|
177
|
+
</>
|
|
178
|
+
)}
|
|
179
|
+
|
|
180
|
+
<TextControl
|
|
181
|
+
label={__('Titulek tlačítka odeslání', 'brilo-blocks')}
|
|
182
|
+
value={attributes.submit?.label ?? 'Odeslat'}
|
|
183
|
+
onChange={(label) => setAttributes({submit: {label}})}
|
|
184
|
+
/>
|
|
185
|
+
</PanelBody>
|
|
186
|
+
</InspectorControls>
|
|
187
|
+
|
|
188
|
+
<div {...blockProps}>
|
|
189
|
+
<div {...innerBlocksProps} />
|
|
190
|
+
|
|
191
|
+
<div className="g-form__gdpr">
|
|
192
|
+
<div className="g-form__gdpr-header">
|
|
193
|
+
<strong>{__('GDPR obsah', 'brilo-blocks')}</strong>
|
|
194
|
+
<ToggleControl
|
|
195
|
+
label={__('S checkboxem?', 'brilo-blocks')}
|
|
196
|
+
checked={attributes.gdpr?.checkbox ?? true}
|
|
197
|
+
onChange={(checkbox) => setAttributes({gdpr: {content: attributes.gdpr?.content ?? '', checkbox}})}
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<RichText
|
|
202
|
+
className="g-form__gdpr-content"
|
|
203
|
+
tagName="div"
|
|
204
|
+
value={attributes.gdpr?.content ?? ''}
|
|
205
|
+
allowedFormats={['core/bold', 'core/link']}
|
|
206
|
+
onChange={(content) => setAttributes({gdpr: {content, checkbox: attributes.gdpr?.checkbox ?? true}})}
|
|
207
|
+
placeholder={__('Text GDPR souhlasu…', 'brilo-blocks')}
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
</>
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
}
|