@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-group/edit.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-group/edit.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAiB,mBAAmB,EAAE,gBAAgB,EAAyC,MAAM,SAAS,CAAA;AAW1H,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,IACtC,0CAIlB;IACD,UAAU,EAAE,mBAAmB,CAAA;IAC/B,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;IACxD,QAAQ,EAAE,MAAM,CAAA;CACjB,iCAwLF"}
|
|
@@ -3,14 +3,20 @@ import { InspectorControls, RichText } from '@wordpress/block-editor';
|
|
|
3
3
|
import { FormTokenField, Notice, PanelBody, SelectControl, TextControl, ToggleControl } from '@wordpress/components';
|
|
4
4
|
import { useDispatch } from '@wordpress/data';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { cleanForSlug } from '@wordpress/url';
|
|
6
7
|
import clsx from 'clsx';
|
|
7
8
|
import { useEffect } from 'react';
|
|
8
9
|
import { useGroupBlock } from '../../../hooks/useGroupBlock';
|
|
9
10
|
import { EXTERNAL_METHODS, INTERNAL_SUBMIT_BEHAVIORS, PROCESSING_MODES } from './constants';
|
|
10
11
|
const ALLOWED_BLOCKS = ['brilo/form-field'];
|
|
12
|
+
function generateFormId(formName) {
|
|
13
|
+
const slug = cleanForSlug(formName) || 'form';
|
|
14
|
+
const hash = Math.random().toString(36).slice(2, 8);
|
|
15
|
+
return `form-${slug}-${hash}`;
|
|
16
|
+
}
|
|
11
17
|
export function createFormGroupEdit(options) {
|
|
12
18
|
return function Edit({ attributes, setAttributes, clientId, }) {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
14
20
|
const { lockPostSaving, unlockPostSaving } = useDispatch('core/editor');
|
|
15
21
|
const processingMode = (_a = attributes.processingMode) !== null && _a !== void 0 ? _a : 'internal';
|
|
16
22
|
const isInternal = processingMode === 'internal';
|
|
@@ -28,6 +34,14 @@ export function createFormGroupEdit(options) {
|
|
|
28
34
|
}
|
|
29
35
|
return () => unlockPostSaving(lockName);
|
|
30
36
|
}, [clientId, isRecipientsMissing, isExternalUrlMissing, lockPostSaving, unlockPostSaving]);
|
|
37
|
+
// Generated once and persisted into the block's attributes so it stays stable across edits.
|
|
38
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: must run once on mount only
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
var _a;
|
|
41
|
+
if (!attributes.formId) {
|
|
42
|
+
setAttributes({ formId: generateFormId((_a = attributes.formName) !== null && _a !== void 0 ? _a : '') });
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
31
45
|
const { blockProps, innerBlocksProps } = useGroupBlock({
|
|
32
46
|
blockClassName: clsx((_c = options.blockClassName) !== null && _c !== void 0 ? _c : 'g-form wp-block-section'),
|
|
33
47
|
containerClassName: [(_d = options.containerClassName) !== null && _d !== void 0 ? _d : 'g-form__fields'],
|
|
@@ -36,10 +50,10 @@ export function createFormGroupEdit(options) {
|
|
|
36
50
|
orientation: 'horizontal',
|
|
37
51
|
layout: { type: 'default' },
|
|
38
52
|
});
|
|
39
|
-
return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsxs(PanelBody, { title: __('Formulář', 'brilo-blocks'), children: [_jsx(TextControl, { label: __('Název formuláře (volitelné)', 'brilo-blocks'), value: (
|
|
53
|
+
return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsxs(PanelBody, { title: __('Formulář', 'brilo-blocks'), children: [_jsx(TextControl, { label: __('ID formuláře', 'brilo-blocks'), value: (_f = attributes.formId) !== null && _f !== void 0 ? _f : '', readOnly: true, onChange: () => { }, help: __('Generuje se automaticky, slouží k jednoznačné identifikaci formuláře.', 'brilo-blocks') }), _jsx(TextControl, { label: __('Název formuláře (volitelné)', 'brilo-blocks'), value: (_g = attributes.formName) !== null && _g !== void 0 ? _g : '', placeholder: __('Např. Kontaktní formulář', 'brilo-blocks'), onChange: (formName) => setAttributes({ formName }) }), _jsx(SelectControl, { label: __('Zpracování', 'brilo-blocks'), value: processingMode, options: PROCESSING_MODES.map((m) => ({ label: m.label, value: m.value })), onChange: (mode) => setAttributes({ processingMode: mode }) }), isExternal && (_jsxs(_Fragment, { children: [_jsx(SelectControl, { label: __('Metoda odeslání', 'brilo-blocks'), value: (_h = attributes.externalMethod) !== null && _h !== void 0 ? _h : 'POST', options: EXTERNAL_METHODS.map((m) => ({ label: m.label, value: m.value })), onChange: (externalMethod) => setAttributes({ externalMethod: externalMethod }) }), _jsx(TextControl, { label: __('Externí URL', 'brilo-blocks'), value: (_j = attributes.externalUrl) !== null && _j !== void 0 ? _j : '', onChange: (externalUrl) => setAttributes({ externalUrl }) }), isExternalUrlMissing && (_jsx(Notice, { status: "warning", isDismissible: false, children: __('Pole „Externí URL“ je povinné pro externí zpracování.', 'brilo-blocks') }))] })), isInternal && (_jsxs(_Fragment, { children: [_jsx(FormTokenField, { label: __('Komu (příjemci)', 'brilo-blocks'), value: recipients, __next40pxDefaultSize: true, onChange: (senders) => setAttributes({
|
|
40
54
|
senders: (senders !== null && senders !== void 0 ? senders : [])
|
|
41
55
|
.map((item) => (typeof item === 'string' ? item.trim() : ''))
|
|
42
56
|
.filter((item) => item.length > 0),
|
|
43
|
-
}) }), isRecipientsMissing && (_jsx(Notice, { status: "warning", isDismissible: false, children: __('Pole „Komu (příjemci)“ je povinné. Vyplňte alespoň jeden e-mail příjemce.', 'brilo-blocks') })), _jsx(TextControl, { label: __('Od koho (From email)', 'brilo-blocks'), value: (
|
|
57
|
+
}) }), isRecipientsMissing && (_jsx(Notice, { status: "warning", isDismissible: false, children: __('Pole „Komu (příjemci)“ je povinné. Vyplňte alespoň jeden e-mail příjemce.', 'brilo-blocks') })), _jsx(TextControl, { label: __('Od koho (From email)', 'brilo-blocks'), value: (_k = attributes.fromEmail) !== null && _k !== void 0 ? _k : '', onChange: (fromEmail) => setAttributes({ fromEmail }) }), _jsx(TextControl, { label: __('Předmět emailu', 'brilo-blocks'), value: (_l = attributes.subject) !== null && _l !== void 0 ? _l : '', placeholder: __('Potvrzení odeslaného formuláře', 'brilo-blocks'), onChange: (subject) => setAttributes({ subject }) }), _jsx(SelectControl, { label: __('Po odeslání', 'brilo-blocks'), value: (_m = attributes.internalSubmitBehavior) !== null && _m !== void 0 ? _m : 'stay', options: INTERNAL_SUBMIT_BEHAVIORS.map((b) => ({ label: b.label, value: b.value })), onChange: (internalSubmitBehavior) => setAttributes({ internalSubmitBehavior: internalSubmitBehavior }) }), ((_o = attributes.internalSubmitBehavior) !== null && _o !== void 0 ? _o : 'stay') === 'redirect' && (_jsx(TextControl, { label: __('URL děkovné stránky', 'brilo-blocks'), value: (_p = attributes.internalRedirectUrl) !== null && _p !== void 0 ? _p : '', onChange: (internalRedirectUrl) => setAttributes({ internalRedirectUrl }) })), _jsx(TextControl, { label: __('Úspěšná zpráva', 'brilo-blocks'), value: (_q = attributes.successMessage) !== null && _q !== void 0 ? _q : '', onChange: (successMessage) => setAttributes({ successMessage }) })] })), _jsx(TextControl, { label: __('Titulek tlačítka odeslání', 'brilo-blocks'), value: (_s = (_r = attributes.submit) === null || _r === void 0 ? void 0 : _r.label) !== null && _s !== void 0 ? _s : 'Odeslat', onChange: (label) => setAttributes({ submit: { label } }) })] }) }), _jsxs("div", { ...blockProps, children: [_jsx("div", { ...innerBlocksProps }), _jsxs("div", { className: "g-form__gdpr", children: [_jsxs("div", { className: "g-form__gdpr-header", children: [_jsx("strong", { children: __('GDPR obsah', 'brilo-blocks') }), _jsx(ToggleControl, { label: __('S checkboxem?', 'brilo-blocks'), checked: (_u = (_t = attributes.gdpr) === null || _t === void 0 ? void 0 : _t.checkbox) !== null && _u !== void 0 ? _u : true, onChange: (checkbox) => { var _a, _b; return setAttributes({ gdpr: { content: (_b = (_a = attributes.gdpr) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : '', checkbox } }); } })] }), _jsx(RichText, { className: "g-form__gdpr-content", tagName: "div", value: (_w = (_v = attributes.gdpr) === null || _v === void 0 ? void 0 : _v.content) !== null && _w !== void 0 ? _w : '', allowedFormats: ['core/bold', 'core/link'], onChange: (content) => { var _a, _b; return setAttributes({ gdpr: { content, checkbox: (_b = (_a = attributes.gdpr) === null || _a === void 0 ? void 0 : _a.checkbox) !== null && _b !== void 0 ? _b : true } }); }, placeholder: __('Text GDPR souhlasu…', 'brilo-blocks') })] })] })] }));
|
|
44
58
|
};
|
|
45
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-group/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAGzD,OAAO,KAAK,EAAC,mBAAmB,EAAE,gBAAgB,EAAC,MAAM,SAAS,CAAA;AAElE,YAAY,EAAC,mBAAmB,EAAE,gBAAgB,EAAC,CAAA;AAEnD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-group/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAGzD,OAAO,KAAK,EAAC,mBAAmB,EAAE,gBAAgB,EAAC,MAAM,SAAS,CAAA;AAElE,YAAY,EAAC,mBAAmB,EAAE,gBAAgB,EAAC,CAAA;AAEnD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CA2BvG"}
|
|
@@ -13,6 +13,7 @@ export function createFormGroupBlock(options) {
|
|
|
13
13
|
icon: (_c = options.icon) !== null && _c !== void 0 ? _c : 'feedback',
|
|
14
14
|
supports: { html: false, customClassName: false },
|
|
15
15
|
attributes: {
|
|
16
|
+
formId: { type: 'string', default: '' },
|
|
16
17
|
formName: { type: 'string', default: '' },
|
|
17
18
|
processingMode: { type: 'string', default: 'internal' },
|
|
18
19
|
externalMethod: { type: 'string', default: 'POST' },
|
|
@@ -3,6 +3,7 @@ export type ProcessingMode = 'internal' | 'external';
|
|
|
3
3
|
export type ExternalMethod = 'POST' | 'GET';
|
|
4
4
|
export type InternalSubmitBehavior = 'stay' | 'redirect';
|
|
5
5
|
export interface FormGroupAttributes extends Record<string, unknown> {
|
|
6
|
+
formId: string;
|
|
6
7
|
formName: string;
|
|
7
8
|
processingMode: ProcessingMode;
|
|
8
9
|
externalMethod: ExternalMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-group/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,CAAA;AACpD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,CAAA;AAC3C,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,UAAU,CAAA;AAExD,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,mBAAmB,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAA;IACvB,IAAI,EAAE;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAAA;IAC1C,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-group/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,UAAU,CAAA;AACpD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,CAAA;AAC3C,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,UAAU,CAAA;AAExD,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,mBAAmB,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAA;IACvB,IAAI,EAAE;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAAA;IAC1C,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brilo/base-blocks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"author": "Brilo",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"clsx": "^2.1.1"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
|
-
"build"
|
|
39
|
+
"build",
|
|
40
|
+
"src"
|
|
40
41
|
],
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {PanelBody, RangeControl} from '@wordpress/components'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
5
|
+
import type {ColumnGroupAttributes, ColumnGroupOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export function createColumnGroupEdit(options: ColumnGroupOptions) {
|
|
8
|
+
return function Edit({
|
|
9
|
+
attributes,
|
|
10
|
+
setAttributes,
|
|
11
|
+
}: {
|
|
12
|
+
attributes: ColumnGroupAttributes
|
|
13
|
+
setAttributes: (a: Partial<ColumnGroupAttributes>) => void
|
|
14
|
+
}) {
|
|
15
|
+
const {spacingX, spacingY} = attributes
|
|
16
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
17
|
+
blockClassName: options.blockClassName ?? 'g-column wp-block-section',
|
|
18
|
+
containerClassName: options.containerClassName ?? 'g-column__inner',
|
|
19
|
+
allowedBlocks: options.allowedBlocks,
|
|
20
|
+
template: options.template,
|
|
21
|
+
layout: {type: 'default'},
|
|
22
|
+
containerStyle: {
|
|
23
|
+
'--gap-x': `${spacingX}px`,
|
|
24
|
+
'--gap-y': `${spacingY}px`,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<InspectorControls>
|
|
31
|
+
<PanelBody title={__('Nastavení sloupců', 'brilo-blocks')}>
|
|
32
|
+
<RangeControl
|
|
33
|
+
label={__('Horizontální mezera (px)', 'brilo-blocks')}
|
|
34
|
+
value={spacingX}
|
|
35
|
+
onChange={(v) => setAttributes({spacingX: v ?? 0})}
|
|
36
|
+
min={0}
|
|
37
|
+
max={64}
|
|
38
|
+
step={8}
|
|
39
|
+
/>
|
|
40
|
+
<RangeControl
|
|
41
|
+
label={__('Vertikální mezera (px)', 'brilo-blocks')}
|
|
42
|
+
value={spacingY}
|
|
43
|
+
onChange={(v) => setAttributes({spacingY: v ?? 0})}
|
|
44
|
+
min={0}
|
|
45
|
+
max={64}
|
|
46
|
+
step={8}
|
|
47
|
+
/>
|
|
48
|
+
</PanelBody>
|
|
49
|
+
</InspectorControls>
|
|
50
|
+
<div {...blockProps}>
|
|
51
|
+
<div {...innerBlocksProps} />
|
|
52
|
+
</div>
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createColumnGroupEdit} from './edit'
|
|
5
|
+
import type {ColumnGroupAttributes, ColumnGroupOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export function createColumnGroupBlock(options: ColumnGroupOptions): BlockConfiguration<ColumnGroupAttributes> {
|
|
8
|
+
return {
|
|
9
|
+
name: options.name,
|
|
10
|
+
title: options.title ?? __('Obsahové sloupce', 'brilo-blocks'),
|
|
11
|
+
description: options.description,
|
|
12
|
+
category: options.category ?? 'layout',
|
|
13
|
+
...(options.parent && {parent: options.parent}),
|
|
14
|
+
icon: options.icon ?? 'columns',
|
|
15
|
+
supports: {html: false, customClassName: false},
|
|
16
|
+
attributes: {
|
|
17
|
+
spacingX: {
|
|
18
|
+
type: 'number',
|
|
19
|
+
default: 16,
|
|
20
|
+
},
|
|
21
|
+
spacingY: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
default: 16,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
edit: createColumnGroupEdit(options),
|
|
27
|
+
save: () => <InnerBlocks.Content />,
|
|
28
|
+
} as BlockConfiguration<ColumnGroupAttributes>
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type {ColumnGroupAttributes, ColumnGroupOptions} from './types'
|
|
2
|
+
export {createColumnGroupBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {ColumnGroupOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const columnGroupDefaults: ColumnGroupOptions = {
|
|
7
|
+
name: 'brilo/column-group',
|
|
8
|
+
allowedBlocks: ['brilo/column-item'],
|
|
9
|
+
parent: ['brilo/base-section'],
|
|
10
|
+
template: [
|
|
11
|
+
['brilo/column-item', {}],
|
|
12
|
+
['brilo/column-item', {}],
|
|
13
|
+
],
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SIZES = ['1/4', '1/3', '1/2', '2/3', '3/4', '1/1']
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {PanelBody, RangeControl} from '@wordpress/components'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import clsx from 'clsx'
|
|
5
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
6
|
+
import type {ColumnItemAttributes, ColumnItemOptions} from './types'
|
|
7
|
+
import {SIZES} from './constants'
|
|
8
|
+
|
|
9
|
+
export function createColumnItemEdit(options: ColumnItemOptions) {
|
|
10
|
+
return function Edit({
|
|
11
|
+
attributes,
|
|
12
|
+
setAttributes,
|
|
13
|
+
}: {
|
|
14
|
+
attributes: ColumnItemAttributes
|
|
15
|
+
setAttributes: (a: Partial<ColumnItemAttributes>) => void
|
|
16
|
+
}) {
|
|
17
|
+
const {size} = attributes
|
|
18
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
19
|
+
blockClassName: clsx(options.blockClassName ?? 'i-column', `--size-${size}`),
|
|
20
|
+
containerClassName: options.containerClassName ?? 'i-column__inner',
|
|
21
|
+
allowedBlocks: options.allowedBlocks,
|
|
22
|
+
template: options.template,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const sizeIndex = SIZES.indexOf(size)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<InspectorControls>
|
|
30
|
+
<PanelBody title={__('Nastavení položky sloupce', 'brilo-blocks')}>
|
|
31
|
+
<RangeControl
|
|
32
|
+
label={__('Šířka sloupce', 'brilo-blocks')}
|
|
33
|
+
value={sizeIndex}
|
|
34
|
+
onChange={(v) => setAttributes({size: SIZES[v as number]})}
|
|
35
|
+
min={0}
|
|
36
|
+
max={SIZES.length - 1}
|
|
37
|
+
withInputField={false}
|
|
38
|
+
marks={SIZES.map((s, i) => ({label: s, value: i}))}
|
|
39
|
+
/>
|
|
40
|
+
</PanelBody>
|
|
41
|
+
</InspectorControls>
|
|
42
|
+
<div {...blockProps}>
|
|
43
|
+
<div {...innerBlocksProps} />
|
|
44
|
+
</div>
|
|
45
|
+
</>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.i-column {
|
|
3
|
+
border: 1px dashed #0073aa;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
padding: 4px;
|
|
7
|
+
min-height: 64px;
|
|
8
|
+
margin: 0 !important;
|
|
9
|
+
|
|
10
|
+
&.--size-1\/4 {
|
|
11
|
+
grid-column: span 3;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.--size-1\/3 {
|
|
15
|
+
grid-column: span 4;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.--size-1\/2 {
|
|
19
|
+
grid-column: span 6;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.--size-2\/3 {
|
|
23
|
+
grid-column: span 8;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.--size-3\/4 {
|
|
27
|
+
grid-column: span 9;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.--size-1\/1 {
|
|
31
|
+
grid-column: span 12;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createColumnItemEdit} from './edit'
|
|
5
|
+
import type {ColumnItemAttributes, ColumnItemOptions} from './types'
|
|
6
|
+
|
|
7
|
+
export function createColumnItemBlock(options: ColumnItemOptions): BlockConfiguration<ColumnItemAttributes> {
|
|
8
|
+
return {
|
|
9
|
+
name: options.name,
|
|
10
|
+
title: options.title ?? __('Položka sloupce', 'brilo-blocks'),
|
|
11
|
+
description: options.description,
|
|
12
|
+
category: options.category ?? 'layout',
|
|
13
|
+
...(options.parent && {parent: options.parent}),
|
|
14
|
+
icon: options.icon ?? 'column',
|
|
15
|
+
supports: {html: false, customClassName: false},
|
|
16
|
+
attributes: {
|
|
17
|
+
size: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
default: '1/2',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
edit: createColumnItemEdit(options),
|
|
23
|
+
save: () => <InnerBlocks.Content />,
|
|
24
|
+
} as BlockConfiguration<ColumnItemAttributes>
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {ColumnItemAttributes, ColumnItemOptions} from './types'
|
|
2
|
+
export {createColumnItemBlock} from './factory'
|
|
3
|
+
|
|
4
|
+
import type {ColumnItemOptions} from './types'
|
|
5
|
+
|
|
6
|
+
export const columnItemDefaults: ColumnItemOptions = {
|
|
7
|
+
name: 'brilo/column-item',
|
|
8
|
+
parent: ['brilo/column-group'],
|
|
9
|
+
allowedBlocks: ['core/paragraph', 'core/list', 'core/image', 'core/heading', 'core/embed', 'core/quote', 'core/table', 'core/gallery'],
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const HEADING_LEVELS = [2, 3, 4] as const
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
5
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
6
|
+
} from '@wordpress/components'
|
|
7
|
+
import {__} from '@wordpress/i18n'
|
|
8
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
9
|
+
import {HEADING_LEVELS} from './constants'
|
|
10
|
+
import type {CompareGroupAttributes, CompareGroupOptions} from './types'
|
|
11
|
+
|
|
12
|
+
export function createCompareGroupEdit(options: CompareGroupOptions) {
|
|
13
|
+
return function Edit({
|
|
14
|
+
attributes,
|
|
15
|
+
setAttributes,
|
|
16
|
+
}: {
|
|
17
|
+
attributes: CompareGroupAttributes
|
|
18
|
+
setAttributes: (a: Partial<CompareGroupAttributes>) => void
|
|
19
|
+
}) {
|
|
20
|
+
const {headingLevel} = attributes
|
|
21
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
22
|
+
blockClassName: options.blockClassName ?? 'g-compare wp-block-section',
|
|
23
|
+
containerClassName: [options.containerClassName ?? 'u-grid-responsive'],
|
|
24
|
+
allowedBlocks: options.allowedBlocks,
|
|
25
|
+
orientation: 'horizontal',
|
|
26
|
+
template: options.template,
|
|
27
|
+
layout: {type: 'default'},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<InspectorControls>
|
|
33
|
+
<PanelBody title={__('Nastavení', 'brilo-blocks')}>
|
|
34
|
+
<ToggleGroupControl
|
|
35
|
+
isBlock
|
|
36
|
+
label={__('Úroveň nadpisu', 'brilo-blocks')}
|
|
37
|
+
value={String(headingLevel)}
|
|
38
|
+
onChange={(v) => setAttributes({headingLevel: Number(v) as CompareGroupAttributes['headingLevel']})}
|
|
39
|
+
>
|
|
40
|
+
{HEADING_LEVELS.map((l) => (
|
|
41
|
+
<ToggleGroupControlOption key={l} value={String(l)} label={`H${l}`} />
|
|
42
|
+
))}
|
|
43
|
+
</ToggleGroupControl>
|
|
44
|
+
</PanelBody>
|
|
45
|
+
</InspectorControls>
|
|
46
|
+
<div {...blockProps}>
|
|
47
|
+
<div {...innerBlocksProps} />
|
|
48
|
+
</div>
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createCompareGroupEdit} from './edit'
|
|
5
|
+
import {icon as defaultIcon} from './icon'
|
|
6
|
+
import {HEADING_LEVELS} from './constants'
|
|
7
|
+
import type {CompareGroupAttributes, CompareGroupOptions} from './types'
|
|
8
|
+
|
|
9
|
+
export type {CompareGroupAttributes, CompareGroupOptions}
|
|
10
|
+
|
|
11
|
+
export function createCompareGroupBlock(options: CompareGroupOptions): BlockConfiguration<CompareGroupAttributes> {
|
|
12
|
+
return {
|
|
13
|
+
name: options.name,
|
|
14
|
+
title: options.title ?? __('Srovnání', 'brilo-blocks'),
|
|
15
|
+
description: options.description,
|
|
16
|
+
category: options.category ?? 'layout',
|
|
17
|
+
...(options.parent && {parent: options.parent}),
|
|
18
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
19
|
+
supports: {html: false, customClassName: false},
|
|
20
|
+
attributes: {
|
|
21
|
+
headingLevel: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
default: HEADING_LEVELS[1],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
edit: createCompareGroupEdit(options),
|
|
27
|
+
save: () => <InnerBlocks.Content />,
|
|
28
|
+
} as unknown as BlockConfiguration<CompareGroupAttributes>
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<title>Compare Group</title>
|
|
4
|
+
<rect x="2" y="2" width="7" height="16" rx="1" stroke="currentColor" strokeWidth="1.5" fill="none" />
|
|
5
|
+
<rect x="11" y="2" width="7" height="16" rx="1" stroke="currentColor" strokeWidth="1.5" fill="none" />
|
|
6
|
+
</svg>
|
|
7
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {CompareGroupAttributes, CompareGroupOptions} from './types'
|
|
2
|
+
export {createCompareGroupBlock} from './factory'
|
|
3
|
+
import type {CompareGroupOptions} from './types'
|
|
4
|
+
|
|
5
|
+
export const compareGroupDefaults: CompareGroupOptions = {
|
|
6
|
+
name: 'brilo/compare-group',
|
|
7
|
+
parent: ['brilo/base-section'],
|
|
8
|
+
allowedBlocks: ['brilo/compare-item'],
|
|
9
|
+
template: [
|
|
10
|
+
['brilo/compare-item', {}],
|
|
11
|
+
['brilo/compare-item', {}],
|
|
12
|
+
],
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {HEADING_LEVELS} from './constants'
|
|
2
|
+
import type {BriloBlockType} from '~/types'
|
|
3
|
+
|
|
4
|
+
export type CompareHeadingLevel = (typeof HEADING_LEVELS)[number]
|
|
5
|
+
|
|
6
|
+
export interface CompareGroupAttributes extends Record<string, unknown> {
|
|
7
|
+
headingLevel: CompareHeadingLevel
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CompareGroupOptions extends BriloBlockType {
|
|
11
|
+
allowedBlocks: string[]
|
|
12
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {RichText, useBlockProps, useInnerBlocksProps} from '@wordpress/block-editor'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import type {CompareItemAttributes, CompareItemOptions} from './types'
|
|
4
|
+
|
|
5
|
+
export function createCompareItemEdit(options: CompareItemOptions) {
|
|
6
|
+
return function Edit({
|
|
7
|
+
attributes,
|
|
8
|
+
setAttributes,
|
|
9
|
+
}: {
|
|
10
|
+
attributes: CompareItemAttributes
|
|
11
|
+
setAttributes: (a: Partial<CompareItemAttributes>) => void
|
|
12
|
+
}) {
|
|
13
|
+
const {title} = attributes
|
|
14
|
+
const blockProps = useBlockProps({className: 'i-compare'})
|
|
15
|
+
const innerBlocksProps = useInnerBlocksProps(
|
|
16
|
+
{className: 'i-compare__options wp-block-inner-content'},
|
|
17
|
+
{
|
|
18
|
+
allowedBlocks: options.allowedBlocks,
|
|
19
|
+
template: options.template,
|
|
20
|
+
},
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div {...blockProps}>
|
|
25
|
+
<div className={'i-compare__inner'}>
|
|
26
|
+
<RichText
|
|
27
|
+
tagName={'div'}
|
|
28
|
+
className="i-compare__title u-text-editable"
|
|
29
|
+
value={title}
|
|
30
|
+
onChange={(v) => setAttributes({title: v})}
|
|
31
|
+
placeholder={__('Nadpis...', 'brilo-blocks')}
|
|
32
|
+
/>
|
|
33
|
+
<div {...innerBlocksProps} />
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {InnerBlocks} from '@wordpress/block-editor'
|
|
2
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
3
|
+
import {__} from '@wordpress/i18n'
|
|
4
|
+
import {createCompareItemEdit} from './edit'
|
|
5
|
+
import {icon as defaultIcon} from './icon'
|
|
6
|
+
import type {CompareItemAttributes, CompareItemOptions} from './types'
|
|
7
|
+
|
|
8
|
+
export type {CompareItemAttributes, CompareItemOptions}
|
|
9
|
+
|
|
10
|
+
export function createCompareItemBlock(options: CompareItemOptions): BlockConfiguration<CompareItemAttributes> {
|
|
11
|
+
return {
|
|
12
|
+
name: options.name,
|
|
13
|
+
title: options.title ?? __('Položka srovnání', 'brilo-blocks'),
|
|
14
|
+
description: options.description,
|
|
15
|
+
category: options.category ?? 'layout',
|
|
16
|
+
...(options.parent && {parent: options.parent}),
|
|
17
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
18
|
+
supports: {html: false, customClassName: false},
|
|
19
|
+
attributes: {
|
|
20
|
+
title: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: '',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
edit: createCompareItemEdit(options),
|
|
26
|
+
save: () => <InnerBlocks.Content />,
|
|
27
|
+
} as unknown as BlockConfiguration<CompareItemAttributes>
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<title>Compare Item</title>
|
|
4
|
+
<rect x="4" y="2" width="12" height="16" rx="1" stroke="currentColor" strokeWidth="1.5" fill="none" />
|
|
5
|
+
<path d="M7 6H13" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
6
|
+
<path d="M7 9H13" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
7
|
+
<path d="M7 12H10" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
8
|
+
</svg>
|
|
9
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {CompareItemAttributes, CompareItemOptions} from './types'
|
|
2
|
+
export {createCompareItemBlock} from './factory'
|
|
3
|
+
import type {CompareItemOptions} from './types'
|
|
4
|
+
|
|
5
|
+
export const compareItemDefaults: CompareItemOptions = {
|
|
6
|
+
name: 'brilo/compare-item',
|
|
7
|
+
parent: ['brilo/compare-group'],
|
|
8
|
+
allowedBlocks: ['brilo/compare-option'],
|
|
9
|
+
template: [
|
|
10
|
+
['brilo/compare-option', {variant: 'plus'}],
|
|
11
|
+
['brilo/compare-option', {variant: 'minus'}],
|
|
12
|
+
],
|
|
13
|
+
}
|