@brilo/base-blocks 0.1.38 → 0.1.40

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.
@@ -1,4 +1,4 @@
1
- export declare const FIELD_TYPE_VALUES: readonly ['text', 'textarea', 'select', 'hidden'];
1
+ export declare const FIELD_TYPE_VALUES: readonly ['text', 'textarea', 'select', 'hidden', 'file'];
2
2
  export declare const FIELD_TYPES: readonly [{
3
3
  readonly value: "text";
4
4
  readonly label: import("@wordpress/i18n").TransformedText<"Text">;
@@ -11,6 +11,9 @@ export declare const FIELD_TYPES: readonly [{
11
11
  }, {
12
12
  readonly value: "hidden";
13
13
  readonly label: import("@wordpress/i18n").TransformedText<"Hidden">;
14
+ }, {
15
+ readonly value: "file";
16
+ readonly label: import("@wordpress/i18n").TransformedText<"Soubor">;
14
17
  }];
15
18
  export declare const FIELD_TEXT_TYPE_VALUES: readonly ['text', 'tel', 'email', 'number', 'date', 'time'];
16
19
  export declare const FIELD_TEXT_TYPES: ({
@@ -45,4 +48,33 @@ export declare const FIELD_SELECT_MODES: readonly [{
45
48
  readonly value: "email";
46
49
  readonly label: import("@wordpress/i18n").TransformedText<"Výběr s routováním e-mailu">;
47
50
  }];
51
+ export declare const FILE_EXTENSION_PRESETS: readonly [{
52
+ readonly value: 'jpg,jpeg,png,webp';
53
+ readonly label: import("@wordpress/i18n").TransformedText<"Obrázky">;
54
+ }, {
55
+ readonly value: 'pdf';
56
+ readonly label: import("@wordpress/i18n").TransformedText<"PDF">;
57
+ }, {
58
+ readonly value: 'doc,docx';
59
+ readonly label: import("@wordpress/i18n").TransformedText<"Word">;
60
+ }, {
61
+ readonly value: 'xls,xlsx';
62
+ readonly label: import("@wordpress/i18n").TransformedText<"Excel">;
63
+ }];
64
+ export declare const FILE_BUTTON_VARIANT_VALUES: readonly ['primary', 'secondary', 'neutral', 'ghost'];
65
+ export declare const FILE_BUTTON_VARIANTS: readonly [{
66
+ readonly value: "primary";
67
+ readonly label: import("@wordpress/i18n").TransformedText<"Primary">;
68
+ }, {
69
+ readonly value: "secondary";
70
+ readonly label: import("@wordpress/i18n").TransformedText<"Secondary">;
71
+ }, {
72
+ readonly value: "neutral";
73
+ readonly label: import("@wordpress/i18n").TransformedText<"Neutral">;
74
+ }, {
75
+ readonly value: "ghost";
76
+ readonly label: import("@wordpress/i18n").TransformedText<"Ghost">;
77
+ }];
78
+ export declare const FIELD_FILE_BUTTON_VARIANT_DEFAULT = "secondary";
79
+ export declare const FIELD_FILE_BUTTON_LABEL_DEFAULT: import("@wordpress/i18n").TransformedText<"Nahrát soubor">;
48
80
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,YAAI,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAElF,eAAO,MAAM,WAAW;aACrB,KAAK;aAAwB,KAAK;;aAClC,KAAK;aAAwB,KAAK;;aAClC,KAAK;aAAwB,KAAK;;aAClC,KAAK;aAAwB,KAAK;EAC3B,CAAA;AAEV,eAAO,MAAM,sBAAsB,YAAI,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA;AACjG,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;IAO5B,CAAA;AAED,eAAO,MAAM,mBAAmB;aAAI,GAAG,EAAE,CAAC;aAAE,GAAG,EAAE,EAAE;CAAU,CAAA;AAE7D,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAEtC,eAAO,MAAM,wBAAwB,YAAI,SAAS,EAAE,OAAO,CAAU,CAAA;AAErE,eAAO,MAAM,kBAAkB;aAC5B,KAAK;aAA+B,KAAK;;aACzC,KAAK;aAA+B,KAAK;EAClC,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,YAAI,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAA;AAE1F,eAAO,MAAM,WAAW;aACrB,KAAK;aAAwB,KAAK;;aAClC,KAAK;aAAwB,KAAK;;aAClC,KAAK;aAAwB,KAAK;;aAClC,KAAK;aAAwB,KAAK;;aAClC,KAAK;aAAwB,KAAK;EAC3B,CAAA;AAEV,eAAO,MAAM,sBAAsB,YAAI,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA;AACjG,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;IAO5B,CAAA;AAED,eAAO,MAAM,mBAAmB;aAAI,GAAG,EAAE,CAAC;aAAE,GAAG,EAAE,EAAE;CAAU,CAAA;AAE7D,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAEtC,eAAO,MAAM,wBAAwB,YAAI,SAAS,EAAE,OAAO,CAAU,CAAA;AAErE,eAAO,MAAM,kBAAkB;aAC5B,KAAK;aAA+B,KAAK;;aACzC,KAAK;aAA+B,KAAK;EAClC,CAAA;AAEV,eAAO,MAAM,sBAAsB;aAChC,KAAK,EAAE,mBAAmB;aAAE,KAAK;;aACjC,KAAK,EAAE,KAAK;aAAE,KAAK;;aACnB,KAAK,EAAE,UAAU;aAAE,KAAK;;aACxB,KAAK,EAAE,UAAU;aAAE,KAAK;EACjB,CAAA;AAEV,eAAO,MAAM,0BAA0B,YAAI,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAU,CAAA;AAE/F,eAAO,MAAM,oBAAoB;aAC9B,KAAK;aAAiC,KAAK;;aAC3C,KAAK;aAAiC,KAAK;;aAC3C,KAAK;aAAiC,KAAK;;aAC3C,KAAK;aAAiC,KAAK;EACpC,CAAA;AAEV,eAAO,MAAM,iCAAiC,cAAc,CAAA;AAE5D,eAAO,MAAM,+BAA+B,4DAAsC,CAAA"}
@@ -1,10 +1,11 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- export const FIELD_TYPE_VALUES = ['text', 'textarea', 'select', 'hidden'];
2
+ export const FIELD_TYPE_VALUES = ['text', 'textarea', 'select', 'hidden', 'file'];
3
3
  export const FIELD_TYPES = [
4
4
  { value: FIELD_TYPE_VALUES[0], label: __('Text', 'brilo-blocks') },
5
5
  { value: FIELD_TYPE_VALUES[1], label: __('Textarea', 'brilo-blocks') },
6
6
  { value: FIELD_TYPE_VALUES[2], label: __('Select', 'brilo-blocks') },
7
7
  { value: FIELD_TYPE_VALUES[3], label: __('Hidden', 'brilo-blocks') },
8
+ { value: FIELD_TYPE_VALUES[4], label: __('Soubor', 'brilo-blocks') },
8
9
  ];
9
10
  export const FIELD_TEXT_TYPE_VALUES = ['text', 'tel', 'email', 'number', 'date', 'time'];
10
11
  export const FIELD_TEXT_TYPES = [
@@ -22,3 +23,18 @@ export const FIELD_SELECT_MODES = [
22
23
  { value: FIELD_SELECT_MODE_VALUES[0], label: __('Klasický', 'brilo-blocks') },
23
24
  { value: FIELD_SELECT_MODE_VALUES[1], label: __('Výběr s routováním e-mailu', 'brilo-blocks') },
24
25
  ];
26
+ export const FILE_EXTENSION_PRESETS = [
27
+ { value: 'jpg,jpeg,png,webp', label: __('Obrázky', 'brilo-blocks') },
28
+ { value: 'pdf', label: __('PDF', 'brilo-blocks') },
29
+ { value: 'doc,docx', label: __('Word', 'brilo-blocks') },
30
+ { value: 'xls,xlsx', label: __('Excel', 'brilo-blocks') },
31
+ ];
32
+ export const FILE_BUTTON_VARIANT_VALUES = ['primary', 'secondary', 'neutral', 'ghost'];
33
+ export const FILE_BUTTON_VARIANTS = [
34
+ { value: FILE_BUTTON_VARIANT_VALUES[0], label: __('Primary', 'brilo-blocks') },
35
+ { value: FILE_BUTTON_VARIANT_VALUES[1], label: __('Secondary', 'brilo-blocks') },
36
+ { value: FILE_BUTTON_VARIANT_VALUES[2], label: __('Neutral', 'brilo-blocks') },
37
+ { value: FILE_BUTTON_VARIANT_VALUES[3], label: __('Ghost', 'brilo-blocks') },
38
+ ];
39
+ export const FIELD_FILE_BUTTON_VARIANT_DEFAULT = 'secondary';
40
+ export const FIELD_FILE_BUTTON_LABEL_DEFAULT = __('Nahrát soubor', 'brilo-blocks');
@@ -1 +1 @@
1
- {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/edit.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAC,mBAAmB,EAAE,gBAAgB,EAAwD,MAAM,SAAS,CAAA;AAepH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,oCAIzD;IACD,UAAU,EAAE,mBAAmB,CAAA;IAC/B,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;CACzD,iCAwLF"}
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/edit.tsx"],"names":[],"mappings":"AAgBA,OAAO,EACL,mBAAmB,EAEnB,gBAAgB,EAIjB,MAAM,SAAS,CAAA;AAehB,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,oCAIzD;IACD,UAAU,EAAE,mBAAmB,CAAA;IAC/B,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;CACzD,iCAqQF"}
@@ -1,10 +1,10 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
3
- import { Button, Modal, PanelBody, RangeControl, SelectControl, TextControl, ToggleControl } from '@wordpress/components';
3
+ import { CheckboxControl, Button, Modal, PanelBody, RangeControl, SelectControl, TextControl, ToggleControl } from '@wordpress/components';
4
4
  import { __, sprintf } from '@wordpress/i18n';
5
5
  import clsx from 'clsx';
6
6
  import { useState } from 'react';
7
- import { FIELD_COLUMNS_DEFAULT, FIELD_COLUMNS_RANGE, FIELD_SELECT_MODES, FIELD_TEXT_TYPES, FIELD_TYPES } from './constants';
7
+ import { FIELD_COLUMNS_DEFAULT, FIELD_COLUMNS_RANGE, FIELD_SELECT_MODES, FIELD_TEXT_TYPES, FIELD_TYPES, FILE_BUTTON_VARIANTS, FILE_EXTENSION_PRESETS, } from './constants';
8
8
  import { normalizeOptions, serializeOptions } from './normalizeOptions';
9
9
  import { SelectOptionsRepeater } from './SelectOptionsRepeater';
10
10
  const { min: MIN_COLUMNS, max: MAX_COLUMNS } = FIELD_COLUMNS_RANGE;
@@ -20,7 +20,7 @@ function sanitizeHtmlName(raw) {
20
20
  }
21
21
  export function createFormFieldEdit(_options) {
22
22
  return function Edit({ attributes, setAttributes, }) {
23
- var _a, _b, _c, _d, _e, _f;
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
24
24
  const currentColumns = Math.max(MIN_COLUMNS, Math.min(MAX_COLUMNS, attributes.columns || MIN_COLUMNS));
25
25
  const blockProps = useBlockProps({
26
26
  className: clsx('i-form-field', `--type-${attributes.type}`, `--cols-${currentColumns}`, attributes.required && '--required'),
@@ -37,6 +37,14 @@ export function createFormFieldEdit(_options) {
37
37
  { label: __('Žádná', 'brilo-blocks'), value: '' },
38
38
  ...optionRows.map((row) => ({ label: row.label, value: row.label })),
39
39
  ];
40
- return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsxs(PanelBody, { title: __('Pole formuláře', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Typ inputu', 'brilo-blocks'), value: attributes.type, options: FIELD_TYPES.map((t) => ({ label: t.label, value: t.value })), onChange: (type) => setAttributes({ type: type }) }), attributes.type === 'text' && (_jsx(_Fragment, { children: _jsx(SelectControl, { label: __('Typ textovho inputu', 'brilo-blocks'), value: attributes.textType, options: FIELD_TEXT_TYPES.map((t) => ({ label: t.label, value: t.value })), onChange: (fieldType) => setAttributes({ textType: fieldType }) }) })), attributes.type !== 'hidden' && (_jsxs(_Fragment, { children: [_jsx(TextControl, { label: __('Popisek', 'brilo-blocks'), value: attributes.label, onChange: (label) => setAttributes({ label }) }), _jsx(ToggleControl, { label: __('Povinné', 'brilo-blocks'), checked: attributes.required, onChange: (required) => setAttributes({ required }) }), _jsx(TextControl, { label: __('Název html atributu', 'brilo-blocks'), value: attributes.name, help: __('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í.', 'brilo-blocks'), onChange: (name) => setAttributes({ name: sanitizeHtmlName(name) }) }), _jsx(TextControl, { label: __('Placeholder', 'brilo-blocks'), value: attributes.placeholder, onChange: (placeholder) => setAttributes({ placeholder }) })] })), attributes.type === 'select' && (_jsxs(_Fragment, { children: [_jsx(SelectControl, { label: __('Režim selectu', 'brilo-blocks'), value: (_a = attributes.selectMode) !== null && _a !== void 0 ? _a : 'classic', options: FIELD_SELECT_MODES.map((m) => ({ label: m.label, value: m.value })), onChange: (selectMode) => setAttributes({ selectMode: selectMode }) }), _jsx("div", { className: "i-form-field__options-trigger", children: _jsx(Button, { variant: "secondary", onClick: () => setIsOptionsModalOpen(true), children: sprintf(__('Upravit možnosti (%d)', 'brilo-blocks'), optionRows.length) }) }), isOptionsModalOpen && (_jsx(Modal, { title: __('Možnosti pole', 'brilo-blocks'), onRequestClose: () => setIsOptionsModalOpen(false), size: "large", children: _jsx(SelectOptionsRepeater, { rows: optionRows, onChange: updateOptionRows, showEmail: ((_b = attributes.selectMode) !== null && _b !== void 0 ? _b : 'classic') === 'email', onClose: () => setIsOptionsModalOpen(false) }) })), _jsx(SelectControl, { label: __('Výchozí hodnota', 'brilo-blocks'), value: (_c = attributes.defaultValue) !== null && _c !== void 0 ? _c : '', options: selectOptions, onChange: (defaultValue) => setAttributes({ defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : '' }) })] })), attributes.type === 'hidden' && (_jsxs(_Fragment, { children: [_jsx(TextControl, { label: __('Hodnota', 'brilo-blocks'), value: (_d = attributes.value) !== null && _d !== void 0 ? _d : '', onChange: (value) => setAttributes({ value }), help: __('Hodnota, která bude odeslána s formulářem.', 'brilo-blocks') }), _jsx(TextControl, { label: __('Název html atributu', 'brilo-blocks'), value: attributes.name, help: __('Použijte pouze bezpečné znaky: a-z, 0-9, pomlčka a podtržítko. Mezery a diakritika se automaticky odstraní.', 'brilo-blocks'), onChange: (name) => setAttributes({ name: sanitizeHtmlName(name) }) })] })), attributes.type !== 'hidden' && (_jsx(RangeControl, { label: __('Počet sloupců', 'brilo-blocks'), value: currentColumns, min: MIN_COLUMNS, max: MAX_COLUMNS, onChange: (columns) => setAttributes({ columns: Math.max(MIN_COLUMNS, Math.min(MAX_COLUMNS, columns !== null && columns !== void 0 ? columns : FIELD_COLUMNS_DEFAULT)) }) }))] }) }), _jsx("div", { ...blockProps, children: _jsx("div", { className: "i-form-field__wrapper", children: attributes.type === 'hidden' ? (_jsxs(_Fragment, { children: [_jsx("strong", { children: __('Skryté pole', 'brilo-blocks') }), _jsxs("div", { children: [__('Hodnota', 'brilo-blocks'), ": ", (_e = attributes.value) !== null && _e !== void 0 ? _e : ''] }), _jsxs("div", { children: [__('Název', 'brilo-blocks'), ": ", (_f = attributes.name) !== null && _f !== void 0 ? _f : ''] })] })) : (_jsxs(_Fragment, { children: [_jsx("strong", { children: attributes.label || __('Pole', 'brilo-blocks') }), _jsx("div", { children: attributes.type }), _jsxs("div", { className: "i-form-field__columns-control", children: [_jsx(Button, { size: "small", variant: "secondary", onClick: () => setAttributes({ columns: Math.max(MIN_COLUMNS, currentColumns - 1) }), disabled: currentColumns <= MIN_COLUMNS, "aria-label": __('Snížit počet sloupců', 'brilo-blocks'), children: "-" }), _jsx("div", { className: "i-form-field__columns-value", children: `${currentColumns}/${MAX_COLUMNS}` }), _jsx(Button, { size: "small", variant: "secondary", onClick: () => setAttributes({ columns: Math.min(MAX_COLUMNS, currentColumns + 1) }), disabled: currentColumns >= MAX_COLUMNS, "aria-label": __('Zvýšit počet sloupců', 'brilo-blocks'), children: "+" })] })] })) }) })] }));
40
+ return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsxs(PanelBody, { title: __('Pole formuláře', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Typ inputu', 'brilo-blocks'), value: attributes.type, options: FIELD_TYPES.map((t) => ({ label: t.label, value: t.value })), onChange: (type) => setAttributes({ type: type }) }), attributes.type === 'text' && (_jsxs(_Fragment, { children: [_jsx(SelectControl, { label: __('Typ textovho inputu', 'brilo-blocks'), value: attributes.textType, options: FIELD_TEXT_TYPES.map((t) => ({ label: t.label, value: t.value })), onChange: (textType) => setAttributes(textType === 'email'
41
+ ? { textType: textType }
42
+ : { textType: textType, isReplyTo: false }) }), attributes.textType === 'email' && (_jsx(ToggleControl, { label: __('Použít jako Reply-To pole', 'brilo-blocks'), help: __('Hodnota tohoto pole se použije jako Reply-To adresa notifikačního e-mailu.', 'brilo-blocks'), checked: (_a = attributes.isReplyTo) !== null && _a !== void 0 ? _a : false, onChange: (isReplyTo) => setAttributes({ isReplyTo }) }))] })), attributes.type !== 'hidden' && (_jsxs(_Fragment, { children: [_jsx(TextControl, { label: __('Popisek', 'brilo-blocks'), value: attributes.label, onChange: (label) => setAttributes({ label }) }), _jsx(ToggleControl, { label: __('Povinné', 'brilo-blocks'), checked: attributes.required, onChange: (required) => setAttributes({ required }) }), _jsx(TextControl, { label: __('Název html atributu', 'brilo-blocks'), value: attributes.name, help: __('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í.', 'brilo-blocks'), onChange: (name) => setAttributes({ name: sanitizeHtmlName(name) }) }), attributes.type !== 'file' && (_jsx(TextControl, { label: __('Placeholder', 'brilo-blocks'), value: attributes.placeholder, onChange: (placeholder) => setAttributes({ placeholder }) })), attributes.type !== 'file' && (_jsx(ToggleControl, { label: __('Odesílat do GTM (dataLayer)', 'brilo-blocks'), help: __('Po úspěšném odeslání formuláře se do dataLayer pushne klíč podle názvu html atributu s vyplněnou/vybranou hodnotou tohoto pole.', 'brilo-blocks'), checked: (_b = attributes.gtmEnabled) !== null && _b !== void 0 ? _b : false, onChange: (gtmEnabled) => setAttributes({ gtmEnabled }) }))] })), attributes.type === 'file' && (_jsxs(_Fragment, { children: [_jsx(ToggleControl, { label: __('Povolit více souborů', 'brilo-blocks'), checked: (_c = attributes.multiple) !== null && _c !== void 0 ? _c : false, onChange: (multiple) => setAttributes({ multiple }) }), _jsx("p", { className: "i-form-field__file-extensions-label", children: __('Povolené přípony', 'brilo-blocks') }), FILE_EXTENSION_PRESETS.map((preset) => { var _a; return (_jsx(CheckboxControl, { label: preset.label, checked: ((_a = attributes.extensionsPreset) !== null && _a !== void 0 ? _a : []).includes(preset.value), onChange: (checked) => {
43
+ var _a;
44
+ const current = (_a = attributes.extensionsPreset) !== null && _a !== void 0 ? _a : [];
45
+ setAttributes({
46
+ extensionsPreset: checked ? [...current, preset.value] : current.filter((value) => value !== preset.value),
47
+ });
48
+ } }, preset.value)); }), _jsx(TextControl, { label: __('Vlastní přípony', 'brilo-blocks'), help: __('Oddělené čárkou, bez tečky. Např. heic,zip', 'brilo-blocks'), value: (_d = attributes.extensionsCustom) !== null && _d !== void 0 ? _d : '', onChange: (extensionsCustom) => setAttributes({ extensionsCustom }) }), _jsx(SelectControl, { label: __('Vzhled tlačítka', 'brilo-blocks'), value: (_e = attributes.buttonVariant) !== null && _e !== void 0 ? _e : 'secondary', options: FILE_BUTTON_VARIANTS.map((v) => ({ label: v.label, value: v.value })), onChange: (buttonVariant) => setAttributes({ buttonVariant: buttonVariant }) }), _jsx(ToggleControl, { label: __('Outline styl tlačítka', 'brilo-blocks'), checked: (_f = attributes.buttonOutline) !== null && _f !== void 0 ? _f : true, onChange: (buttonOutline) => setAttributes({ buttonOutline }) }), _jsx(TextControl, { label: __('Text tlačítka', 'brilo-blocks'), value: (_g = attributes.buttonLabel) !== null && _g !== void 0 ? _g : '', onChange: (buttonLabel) => setAttributes({ buttonLabel }) })] })), attributes.type === 'select' && (_jsxs(_Fragment, { children: [_jsx(SelectControl, { label: __('Režim selectu', 'brilo-blocks'), value: (_h = attributes.selectMode) !== null && _h !== void 0 ? _h : 'classic', options: FIELD_SELECT_MODES.map((m) => ({ label: m.label, value: m.value })), onChange: (selectMode) => setAttributes({ selectMode: selectMode }) }), _jsx("div", { className: "i-form-field__options-trigger", children: _jsx(Button, { variant: "secondary", onClick: () => setIsOptionsModalOpen(true), children: sprintf(__('Upravit možnosti (%d)', 'brilo-blocks'), optionRows.length) }) }), isOptionsModalOpen && (_jsx(Modal, { title: __('Možnosti pole', 'brilo-blocks'), onRequestClose: () => setIsOptionsModalOpen(false), size: "large", children: _jsx(SelectOptionsRepeater, { rows: optionRows, onChange: updateOptionRows, showEmail: ((_j = attributes.selectMode) !== null && _j !== void 0 ? _j : 'classic') === 'email', onClose: () => setIsOptionsModalOpen(false) }) })), _jsx(SelectControl, { label: __('Výchozí hodnota', 'brilo-blocks'), value: (_k = attributes.defaultValue) !== null && _k !== void 0 ? _k : '', options: selectOptions, onChange: (defaultValue) => setAttributes({ defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : '' }) })] })), attributes.type === 'hidden' && (_jsxs(_Fragment, { children: [_jsx(TextControl, { label: __('Hodnota', 'brilo-blocks'), value: (_l = attributes.value) !== null && _l !== void 0 ? _l : '', onChange: (value) => setAttributes({ value }), help: __('Hodnota, která bude odeslána s formulářem.', 'brilo-blocks') }), _jsx(TextControl, { label: __('Název html atributu', 'brilo-blocks'), value: attributes.name, help: __('Použijte pouze bezpečné znaky: a-z, 0-9, pomlčka a podtržítko. Mezery a diakritika se automaticky odstraní.', 'brilo-blocks'), onChange: (name) => setAttributes({ name: sanitizeHtmlName(name) }) })] })), attributes.type !== 'hidden' && (_jsx(RangeControl, { label: __('Počet sloupců', 'brilo-blocks'), value: currentColumns, min: MIN_COLUMNS, max: MAX_COLUMNS, onChange: (columns) => setAttributes({ columns: Math.max(MIN_COLUMNS, Math.min(MAX_COLUMNS, columns !== null && columns !== void 0 ? columns : FIELD_COLUMNS_DEFAULT)) }) }))] }) }), _jsx("div", { ...blockProps, children: _jsx("div", { className: "i-form-field__wrapper", children: attributes.type === 'hidden' ? (_jsxs(_Fragment, { children: [_jsx("strong", { children: __('Skryté pole', 'brilo-blocks') }), _jsxs("div", { children: [__('Hodnota', 'brilo-blocks'), ": ", (_m = attributes.value) !== null && _m !== void 0 ? _m : ''] }), _jsxs("div", { children: [__('Název', 'brilo-blocks'), ": ", (_o = attributes.name) !== null && _o !== void 0 ? _o : ''] })] })) : (_jsxs(_Fragment, { children: [_jsx("strong", { children: attributes.label || __('Pole', 'brilo-blocks') }), _jsx("div", { children: attributes.type }), _jsxs("div", { className: "i-form-field__columns-control", children: [_jsx(Button, { size: "small", variant: "secondary", onClick: () => setAttributes({ columns: Math.max(MIN_COLUMNS, currentColumns - 1) }), disabled: currentColumns <= MIN_COLUMNS, "aria-label": __('Snížit počet sloupců', 'brilo-blocks'), children: "-" }), _jsx("div", { className: "i-form-field__columns-value", children: `${currentColumns}/${MAX_COLUMNS}` }), _jsx(Button, { size: "small", variant: "secondary", onClick: () => setAttributes({ columns: Math.min(MAX_COLUMNS, currentColumns + 1) }), disabled: currentColumns >= MAX_COLUMNS, "aria-label": __('Zvýšit počet sloupců', 'brilo-blocks'), children: "+" })] })] })) }) })] }));
41
49
  };
42
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAIzD,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,CAyBvG"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAIzD,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,CAiCvG"}
@@ -1,5 +1,5 @@
1
1
  import { __ } from '@wordpress/i18n';
2
- import { FIELD_COLUMNS_DEFAULT } from './constants';
2
+ import { FIELD_COLUMNS_DEFAULT, FIELD_FILE_BUTTON_LABEL_DEFAULT, FIELD_FILE_BUTTON_VARIANT_DEFAULT } from './constants';
3
3
  import { createFormFieldEdit } from './edit';
4
4
  export function createFormFieldBlock(options) {
5
5
  var _a, _b, _c;
@@ -23,6 +23,14 @@ export function createFormFieldBlock(options) {
23
23
  selectMode: { type: 'string', default: 'classic' },
24
24
  defaultValue: { type: 'string', default: '' },
25
25
  value: { type: 'string', default: '' },
26
+ isReplyTo: { type: 'boolean', default: false },
27
+ gtmEnabled: { type: 'boolean', default: false },
28
+ multiple: { type: 'boolean', default: false },
29
+ extensionsPreset: { type: 'array', default: [] },
30
+ extensionsCustom: { type: 'string', default: '' },
31
+ buttonVariant: { type: 'string', default: FIELD_FILE_BUTTON_VARIANT_DEFAULT },
32
+ buttonOutline: { type: 'boolean', default: true },
33
+ buttonLabel: { type: 'string', default: FIELD_FILE_BUTTON_LABEL_DEFAULT },
26
34
  },
27
35
  edit: createFormFieldEdit(options),
28
36
  save: () => null,
@@ -1,8 +1,9 @@
1
- import { FIELD_SELECT_MODE_VALUES, FIELD_TEXT_TYPE_VALUES, FIELD_TYPE_VALUES } from './constants';
1
+ import { FIELD_SELECT_MODE_VALUES, FIELD_TEXT_TYPE_VALUES, FIELD_TYPE_VALUES, FILE_BUTTON_VARIANT_VALUES } from './constants';
2
2
  import type { BriloBlockType } from '../../../types';
3
3
  export type FormFieldType = (typeof FIELD_TYPE_VALUES)[number];
4
4
  export type FormFieldTextType = (typeof FIELD_TEXT_TYPE_VALUES)[number];
5
5
  export type FormFieldSelectMode = (typeof FIELD_SELECT_MODE_VALUES)[number];
6
+ export type FormFieldFileButtonVariant = (typeof FILE_BUTTON_VARIANT_VALUES)[number];
6
7
  export type FormFieldOption = string | {
7
8
  label?: string;
8
9
  value?: string;
@@ -20,6 +21,14 @@ export interface FormFieldAttributes extends Record<string, unknown> {
20
21
  selectMode: FormFieldSelectMode;
21
22
  defaultValue: string;
22
23
  value: string;
24
+ isReplyTo: boolean;
25
+ gtmEnabled: boolean;
26
+ multiple: boolean;
27
+ extensionsPreset: string[];
28
+ extensionsCustom: string;
29
+ buttonVariant: FormFieldFileButtonVariant;
30
+ buttonOutline: boolean;
31
+ buttonLabel: string;
23
32
  }
24
33
  export interface FormFieldOptions extends BriloBlockType {
25
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAoB,sBAAsB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AACjH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AACvE,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3E,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAA;AAEvF,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,IAAI,EAAE,aAAa,CAAA;IACnB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,UAAU,EAAE,mBAAmB,CAAA;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAExB,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AACvE,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAA;AAC3E,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAA;AAEvF,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAClE,IAAI,EAAE,aAAa,CAAA;IACnB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,UAAU,EAAE,mBAAmB,CAAA;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,0BAA0B,CAAA;IACzC,aAAa,EAAE,OAAO,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG"}
@@ -1 +1 @@
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,8CAKxD;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"}
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;AA8C1H,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,8CAKxD;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,iCAyRF"}
@@ -1,11 +1,11 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { InspectorControls, RichText } from '@wordpress/block-editor';
3
3
  import { FormTokenField, Notice, PanelBody, SelectControl, TextControl, ToggleControl } from '@wordpress/components';
4
- import { useDispatch } from '@wordpress/data';
4
+ import { useDispatch, useSelect } from '@wordpress/data';
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { cleanForSlug } from '@wordpress/url';
7
7
  import clsx from 'clsx';
8
- import { useEffect } from 'react';
8
+ import { useEffect, useMemo } from 'react';
9
9
  import { useGroupBlock } from '../../../hooks/useGroupBlock';
10
10
  import { EXTERNAL_METHODS, INTERNAL_SUBMIT_BEHAVIORS, PROCESSING_MODES } from './constants';
11
11
  const ALLOWED_BLOCKS = ['brilo/form-field'];
@@ -14,10 +14,38 @@ function generateFormId(formName) {
14
14
  const hash = Math.random().toString(36).slice(2, 8);
15
15
  return `form-${slug}-${hash}`;
16
16
  }
17
+ function slugifyFieldName(raw) {
18
+ return (raw !== null && raw !== void 0 ? raw : '')
19
+ .normalize('NFD')
20
+ .replace(/\p{Diacritic}/gu, '')
21
+ .replace(/[\s_]+/g, '-')
22
+ .replace(/[^a-zA-Z0-9_-]/g, '')
23
+ .replace(/[-_]{2,}/g, '-')
24
+ .replace(/^[-_]+/g, '')
25
+ .toLowerCase();
26
+ }
27
+ function gtmPlaceholderValue(type, textType) {
28
+ if (type === 'select') {
29
+ return '<vybraná možnost>';
30
+ }
31
+ if (type === 'textarea') {
32
+ return '<vyplněný text>';
33
+ }
34
+ if (textType === 'email') {
35
+ return '<vyplněný email>';
36
+ }
37
+ if (textType === 'tel') {
38
+ return '<vyplněné telefonní číslo>';
39
+ }
40
+ if (textType === 'number') {
41
+ return '<vyplněné číslo>';
42
+ }
43
+ return '<vyplněná hodnota>';
44
+ }
17
45
  export function createFormGroupEdit(options) {
18
46
  return function Edit({ attributes, setAttributes, clientId, }) {
19
47
  var _a, _b, _c;
20
- var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
48
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
21
49
  const { lockPostSaving, unlockPostSaving } = useDispatch('core/editor');
22
50
  const processingMode = (_d = attributes.processingMode) !== null && _d !== void 0 ? _d : 'internal';
23
51
  const isInternal = processingMode === 'internal';
@@ -25,16 +53,37 @@ export function createFormGroupEdit(options) {
25
53
  const recipients = Array.isArray(attributes.senders) ? attributes.senders : [];
26
54
  const isRecipientsMissing = isInternal && recipients.length === 0;
27
55
  const isExternalUrlMissing = isExternal && ((_e = attributes.externalUrl) !== null && _e !== void 0 ? _e : '').trim() === '';
56
+ const { replyToCount, gtmFields } = useSelect((select) => {
57
+ const editor = select('core/block-editor');
58
+ const blocks = editor.getBlocks(clientId) || [];
59
+ const replyToCount = blocks.filter((block) => block.attributes.type === 'text' && block.attributes.textType === 'email' && block.attributes.isReplyTo === true).length;
60
+ const gtmFields = blocks.filter((block) => block.attributes.gtmEnabled).map((block) => block.attributes);
61
+ return { replyToCount, gtmFields };
62
+ }, [clientId]);
63
+ const hasMultipleReplyTo = replyToCount > 1;
64
+ const gtmPreview = useMemo(() => {
65
+ var _a;
66
+ const preview = {
67
+ event: ((_a = attributes.gtmEventName) !== null && _a !== void 0 ? _a : '').trim() || '<název eventu>',
68
+ url: '<URL stránky, odkud bylo odesláno>',
69
+ };
70
+ gtmFields.forEach((field) => {
71
+ var _a;
72
+ const name = (field.name && field.name.trim() !== '' ? field.name : slugifyFieldName((_a = field.label) !== null && _a !== void 0 ? _a : '')) || '<pole-bez-nazvu>';
73
+ preview[name] = gtmPlaceholderValue(field.type, field.textType);
74
+ });
75
+ return preview;
76
+ }, [attributes.gtmEventName, gtmFields]);
28
77
  useEffect(() => {
29
78
  const lockName = `brilo-form-group-${clientId}`;
30
- if (isRecipientsMissing || isExternalUrlMissing) {
79
+ if (isRecipientsMissing || isExternalUrlMissing || hasMultipleReplyTo) {
31
80
  lockPostSaving(lockName);
32
81
  }
33
82
  else {
34
83
  unlockPostSaving(lockName);
35
84
  }
36
85
  return () => unlockPostSaving(lockName);
37
- }, [clientId, isRecipientsMissing, isExternalUrlMissing, lockPostSaving, unlockPostSaving]);
86
+ }, [clientId, isRecipientsMissing, isExternalUrlMissing, hasMultipleReplyTo, lockPostSaving, unlockPostSaving]);
38
87
  // Generated once and persisted into the block's attributes so it stays stable across edits.
39
88
  // biome-ignore lint/correctness/useExhaustiveDependencies: must run once on mount only
40
89
  useEffect(() => {
@@ -51,10 +100,10 @@ export function createFormGroupEdit(options) {
51
100
  orientation: 'horizontal',
52
101
  layout: { type: 'default' },
53
102
  });
54
- return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsxs(PanelBody, { title: __('Formulář', 'brilo-blocks'), children: [_jsx(TextControl, { label: __('ID formuláře', 'brilo-blocks'), value: (_j = attributes.formId) !== null && _j !== void 0 ? _j : '', 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: (_k = attributes.formName) !== null && _k !== void 0 ? _k : '', 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: (_l = attributes.externalMethod) !== null && _l !== void 0 ? _l : '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: (_m = attributes.externalUrl) !== null && _m !== void 0 ? _m : '', 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({
55
- senders: (senders !== null && senders !== void 0 ? senders : [])
56
- .map((item) => (typeof item === 'string' ? item.trim() : ''))
57
- .filter((item) => item.length > 0),
58
- }) }), 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: (_o = attributes.fromEmail) !== null && _o !== void 0 ? _o : '', onChange: (fromEmail) => setAttributes({ fromEmail }) }), _jsx(TextControl, { label: __('Předmět emailu', 'brilo-blocks'), value: (_p = attributes.subject) !== null && _p !== void 0 ? _p : '', placeholder: __('Potvrzení odeslaného formuláře', 'brilo-blocks'), onChange: (subject) => setAttributes({ subject }) }), _jsx(SelectControl, { label: __('Po odeslání', 'brilo-blocks'), value: (_q = attributes.internalSubmitBehavior) !== null && _q !== void 0 ? _q : 'stay', options: INTERNAL_SUBMIT_BEHAVIORS.map((b) => ({ label: b.label, value: b.value })), onChange: (internalSubmitBehavior) => setAttributes({ internalSubmitBehavior: internalSubmitBehavior }) }), ((_r = attributes.internalSubmitBehavior) !== null && _r !== void 0 ? _r : 'stay') === 'redirect' && (_jsx(TextControl, { label: __('URL děkovné stránky', 'brilo-blocks'), value: (_s = attributes.internalRedirectUrl) !== null && _s !== void 0 ? _s : '', onChange: (internalRedirectUrl) => setAttributes({ internalRedirectUrl }) })), _jsx(TextControl, { label: __('Úspěšná zpráva', 'brilo-blocks'), value: (_t = attributes.successMessage) !== null && _t !== void 0 ? _t : '', onChange: (successMessage) => setAttributes({ successMessage }) })] })), _jsx(TextControl, { label: __('Titulek tlačítka odeslání', 'brilo-blocks'), value: (_u = (_a = attributes.submit) === null || _a === void 0 ? void 0 : _a.label) !== null && _u !== void 0 ? _u : '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: (_v = (_b = attributes.gdpr) === null || _b === void 0 ? void 0 : _b.checkbox) !== null && _v !== void 0 ? _v : true, onChange: (checkbox) => { var _a; var _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 = (_c = attributes.gdpr) === null || _c === void 0 ? void 0 : _c.content) !== null && _w !== void 0 ? _w : '', allowedFormats: ['core/bold', 'core/link'], onChange: (content) => { var _a; var _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') })] })] })] }));
103
+ return (_jsxs(_Fragment, { children: [_jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Formulář', 'brilo-blocks'), children: [_jsx(TextControl, { label: __('ID formuláře', 'brilo-blocks'), value: (_j = attributes.formId) !== null && _j !== void 0 ? _j : '', 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: (_k = attributes.formName) !== null && _k !== void 0 ? _k : '', 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: (_l = attributes.externalMethod) !== null && _l !== void 0 ? _l : '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: (_m = attributes.externalUrl) !== null && _m !== void 0 ? _m : '', 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({
104
+ senders: (senders !== null && senders !== void 0 ? senders : [])
105
+ .map((item) => (typeof item === 'string' ? item.trim() : ''))
106
+ .filter((item) => item.length > 0),
107
+ }) }), 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: (_o = attributes.fromEmail) !== null && _o !== void 0 ? _o : '', onChange: (fromEmail) => setAttributes({ fromEmail }) }), _jsx(TextControl, { label: __('Předmět emailu', 'brilo-blocks'), value: (_p = attributes.subject) !== null && _p !== void 0 ? _p : '', placeholder: __('Potvrzení odeslaného formuláře', 'brilo-blocks'), onChange: (subject) => setAttributes({ subject }) }), _jsx(SelectControl, { label: __('Po odeslání', 'brilo-blocks'), value: (_q = attributes.internalSubmitBehavior) !== null && _q !== void 0 ? _q : 'stay', options: INTERNAL_SUBMIT_BEHAVIORS.map((b) => ({ label: b.label, value: b.value })), onChange: (internalSubmitBehavior) => setAttributes({ internalSubmitBehavior: internalSubmitBehavior }) }), ((_r = attributes.internalSubmitBehavior) !== null && _r !== void 0 ? _r : 'stay') === 'redirect' && (_jsx(TextControl, { label: __('URL děkovné stránky', 'brilo-blocks'), value: (_s = attributes.internalRedirectUrl) !== null && _s !== void 0 ? _s : '', onChange: (internalRedirectUrl) => setAttributes({ internalRedirectUrl }) })), _jsx(TextControl, { label: __('Úspěšná zpráva', 'brilo-blocks'), value: (_t = attributes.successMessage) !== null && _t !== void 0 ? _t : '', onChange: (successMessage) => setAttributes({ successMessage }) })] })), hasMultipleReplyTo && (_jsx(Notice, { status: "warning", isDismissible: false, children: __('Formulář obsahuje více polí označených jako Reply-To. Podporováno je pouze jedno takové pole.', 'brilo-blocks') })), _jsx(TextControl, { label: __('Titulek tlačítka odeslání', 'brilo-blocks'), value: (_u = (_a = attributes.submit) === null || _a === void 0 ? void 0 : _a.label) !== null && _u !== void 0 ? _u : 'Odeslat', onChange: (label) => setAttributes({ submit: { label } }) })] }), isInternal && (_jsxs(PanelBody, { title: __('Google Tag Manager', 'brilo-blocks'), initialOpen: false, children: [_jsx(ToggleControl, { label: __('Odesílat data do dataLayer', 'brilo-blocks'), help: __('Po úspěšném odeslání formuláře se pushne event do window.dataLayer. Zbytek (cíle, tagy) se nastavuje v GTM.', 'brilo-blocks'), checked: (_v = attributes.gtmEnabled) !== null && _v !== void 0 ? _v : false, onChange: (gtmEnabled) => setAttributes({ gtmEnabled }) }), ((_w = attributes.gtmEnabled) !== null && _w !== void 0 ? _w : false) && (_jsxs(_Fragment, { children: [_jsx(TextControl, { label: __('Název GTM eventu', 'brilo-blocks'), placeholder: __('napr. website_form', 'brilo-blocks'), value: (_x = attributes.gtmEventName) !== null && _x !== void 0 ? _x : '', onChange: (gtmEventName) => setAttributes({ gtmEventName }), help: __('Pushne se { event: <tento název>, url: <stránka, odkud bylo odesláno>, ...pole s GTM }. Jednotlivá pole si zapnete u nich ("Odesílat do GTM").', 'brilo-blocks') }), ((_y = attributes.gtmEventName) !== null && _y !== void 0 ? _y : '').trim() === '' && (_jsx(Notice, { status: "warning", isDismissible: false, children: __('Bez názvu eventu se dataLayer push neodešle.', 'brilo-blocks') })), _jsx("p", { children: _jsx("strong", { children: __('Náhled objektu při úspěšném odeslání:', 'brilo-blocks') }) }), _jsx("pre", { className: "g-form__gtm-preview", children: JSON.stringify(gtmPreview, null, 2) }), gtmFields.length === 0 && (_jsx(Notice, { status: "info", isDismissible: false, children: __('Žádné pole formuláře nemá zapnuté "Odesílat do GTM" - do dataLayer půjde jen event a url. Zapněte to u polí, jejichž hodnotu chcete v dataLayer mít.', 'brilo-blocks') }))] }))] }))] }), _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: (_z = (_b = attributes.gdpr) === null || _b === void 0 ? void 0 : _b.checkbox) !== null && _z !== void 0 ? _z : true, onChange: (checkbox) => { var _a; var _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: (_0 = (_c = attributes.gdpr) === null || _c === void 0 ? void 0 : _c.content) !== null && _0 !== void 0 ? _0 : '', allowedFormats: ['core/bold', 'core/link'], onChange: (content) => { var _a; var _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') })] })] })] }));
59
108
  };
60
109
  }
@@ -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,CA2BvG"}
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,CA6BvG"}
@@ -26,6 +26,8 @@ export function createFormGroupBlock(options) {
26
26
  submit: { type: 'object', default: { label: 'Odeslat' } },
27
27
  gdpr: { type: 'object', default: { content: '', checkbox: true } },
28
28
  successMessage: { type: 'string', default: 'Formulář byl úspěšně odeslán.' },
29
+ gtmEnabled: { type: 'boolean', default: false },
30
+ gtmEventName: { type: 'string', default: '' },
29
31
  },
30
32
  edit: createFormGroupEdit(options),
31
33
  save: () => _jsx(InnerBlocks.Content, {}),
@@ -21,6 +21,8 @@ export interface FormGroupAttributes extends Record<string, unknown> {
21
21
  checkbox: boolean;
22
22
  };
23
23
  successMessage: string;
24
+ gtmEnabled: boolean;
25
+ gtmEventName: string;
24
26
  }
25
27
  export interface FormGroupOptions extends BriloBlockType {
26
28
  }
@@ -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,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"}
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;IACtB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG"}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@brilo/base-blocks",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "author": "Brilo",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
7
+ "sideEffects": false,
7
8
  "scripts": {
8
9
  "build": "tsc && tsc-alias",
9
10
  "watch": "tsc --watch",
@@ -1,12 +1,13 @@
1
1
  import {__} from '@wordpress/i18n'
2
2
 
3
- export const FIELD_TYPE_VALUES = ['text', 'textarea', 'select', 'hidden'] as const
3
+ export const FIELD_TYPE_VALUES = ['text', 'textarea', 'select', 'hidden', 'file'] as const
4
4
 
5
5
  export const FIELD_TYPES = [
6
6
  {value: FIELD_TYPE_VALUES[0], label: __('Text', 'brilo-blocks')},
7
7
  {value: FIELD_TYPE_VALUES[1], label: __('Textarea', 'brilo-blocks')},
8
8
  {value: FIELD_TYPE_VALUES[2], label: __('Select', 'brilo-blocks')},
9
9
  {value: FIELD_TYPE_VALUES[3], label: __('Hidden', 'brilo-blocks')},
10
+ {value: FIELD_TYPE_VALUES[4], label: __('Soubor', 'brilo-blocks')},
10
11
  ] as const
11
12
 
12
13
  export const FIELD_TEXT_TYPE_VALUES = ['text', 'tel', 'email', 'number', 'date', 'time'] as const
@@ -29,3 +30,23 @@ export const FIELD_SELECT_MODES = [
29
30
  {value: FIELD_SELECT_MODE_VALUES[0], label: __('Klasický', 'brilo-blocks')},
30
31
  {value: FIELD_SELECT_MODE_VALUES[1], label: __('Výběr s routováním e-mailu', 'brilo-blocks')},
31
32
  ] as const
33
+
34
+ export const FILE_EXTENSION_PRESETS = [
35
+ {value: 'jpg,jpeg,png,webp', label: __('Obrázky', 'brilo-blocks')},
36
+ {value: 'pdf', label: __('PDF', 'brilo-blocks')},
37
+ {value: 'doc,docx', label: __('Word', 'brilo-blocks')},
38
+ {value: 'xls,xlsx', label: __('Excel', 'brilo-blocks')},
39
+ ] as const
40
+
41
+ export const FILE_BUTTON_VARIANT_VALUES = ['primary', 'secondary', 'neutral', 'ghost'] as const
42
+
43
+ export const FILE_BUTTON_VARIANTS = [
44
+ {value: FILE_BUTTON_VARIANT_VALUES[0], label: __('Primary', 'brilo-blocks')},
45
+ {value: FILE_BUTTON_VARIANT_VALUES[1], label: __('Secondary', 'brilo-blocks')},
46
+ {value: FILE_BUTTON_VARIANT_VALUES[2], label: __('Neutral', 'brilo-blocks')},
47
+ {value: FILE_BUTTON_VARIANT_VALUES[3], label: __('Ghost', 'brilo-blocks')},
48
+ ] as const
49
+
50
+ export const FIELD_FILE_BUTTON_VARIANT_DEFAULT = 'secondary'
51
+
52
+ export const FIELD_FILE_BUTTON_LABEL_DEFAULT = __('Nahrát soubor', 'brilo-blocks')
@@ -1,12 +1,27 @@
1
1
  import {InspectorControls, useBlockProps} from '@wordpress/block-editor'
2
- import {Button, Modal, PanelBody, RangeControl, SelectControl, TextControl, ToggleControl} from '@wordpress/components'
2
+ import {CheckboxControl, Button, Modal, PanelBody, RangeControl, SelectControl, TextControl, ToggleControl} from '@wordpress/components'
3
3
  import {__, sprintf} from '@wordpress/i18n'
4
4
  import clsx from 'clsx'
5
5
  import {useState} from 'react'
6
- import {FIELD_COLUMNS_DEFAULT, FIELD_COLUMNS_RANGE, FIELD_SELECT_MODES, FIELD_TEXT_TYPES, FIELD_TYPES} from './constants'
6
+ import {
7
+ FIELD_COLUMNS_DEFAULT,
8
+ FIELD_COLUMNS_RANGE,
9
+ FIELD_SELECT_MODES,
10
+ FIELD_TEXT_TYPES,
11
+ FIELD_TYPES,
12
+ FILE_BUTTON_VARIANTS,
13
+ FILE_EXTENSION_PRESETS,
14
+ } from './constants'
7
15
  import {normalizeOptions, serializeOptions, type OptionRow} from './normalizeOptions'
8
16
  import {SelectOptionsRepeater} from './SelectOptionsRepeater'
9
- import {FormFieldAttributes, FormFieldOptions, FormFieldSelectMode, FormFieldTextType, FormFieldType} from './types'
17
+ import {
18
+ FormFieldAttributes,
19
+ FormFieldFileButtonVariant,
20
+ FormFieldOptions,
21
+ FormFieldSelectMode,
22
+ FormFieldTextType,
23
+ FormFieldType,
24
+ } from './types'
10
25
 
11
26
  const {min: MIN_COLUMNS, max: MAX_COLUMNS} = FIELD_COLUMNS_RANGE
12
27
 
@@ -67,8 +82,23 @@ export function createFormFieldEdit(_options: FormFieldOptions) {
67
82
  label={__('Typ textovho inputu', 'brilo-blocks')}
68
83
  value={attributes.textType}
69
84
  options={FIELD_TEXT_TYPES.map((t) => ({label: t.label, value: t.value}))}
70
- onChange={(fieldType) => setAttributes({textType: fieldType as FormFieldTextType})}
85
+ onChange={(textType) =>
86
+ setAttributes(
87
+ textType === 'email'
88
+ ? {textType: textType as FormFieldTextType}
89
+ : {textType: textType as FormFieldTextType, isReplyTo: false},
90
+ )
91
+ }
71
92
  />
93
+
94
+ {attributes.textType === 'email' && (
95
+ <ToggleControl
96
+ label={__('Použít jako Reply-To pole', 'brilo-blocks')}
97
+ help={__('Hodnota tohoto pole se použije jako Reply-To adresa notifikačního e-mailu.', 'brilo-blocks')}
98
+ checked={attributes.isReplyTo ?? false}
99
+ onChange={(isReplyTo) => setAttributes({isReplyTo})}
100
+ />
101
+ )}
72
102
  </>
73
103
  )}
74
104
 
@@ -89,10 +119,72 @@ export function createFormFieldEdit(_options: FormFieldOptions) {
89
119
  )}
90
120
  onChange={(name) => setAttributes({name: sanitizeHtmlName(name)})}
91
121
  />
122
+ {attributes.type !== 'file' && (
123
+ <TextControl
124
+ label={__('Placeholder', 'brilo-blocks')}
125
+ value={attributes.placeholder}
126
+ onChange={(placeholder) => setAttributes({placeholder})}
127
+ />
128
+ )}
129
+
130
+ {attributes.type !== 'file' && (
131
+ <ToggleControl
132
+ label={__('Odesílat do GTM (dataLayer)', 'brilo-blocks')}
133
+ help={__(
134
+ 'Po úspěšném odeslání formuláře se do dataLayer pushne klíč podle názvu html atributu s vyplněnou/vybranou hodnotou tohoto pole.',
135
+ 'brilo-blocks',
136
+ )}
137
+ checked={attributes.gtmEnabled ?? false}
138
+ onChange={(gtmEnabled) => setAttributes({gtmEnabled})}
139
+ />
140
+ )}
141
+ </>
142
+ )}
143
+
144
+ {attributes.type === 'file' && (
145
+ <>
146
+ <ToggleControl
147
+ label={__('Povolit více souborů', 'brilo-blocks')}
148
+ checked={attributes.multiple ?? false}
149
+ onChange={(multiple) => setAttributes({multiple})}
150
+ />
151
+
152
+ <p className="i-form-field__file-extensions-label">{__('Povolené přípony', 'brilo-blocks')}</p>
153
+ {FILE_EXTENSION_PRESETS.map((preset) => (
154
+ <CheckboxControl
155
+ key={preset.value}
156
+ label={preset.label}
157
+ checked={(attributes.extensionsPreset ?? []).includes(preset.value)}
158
+ onChange={(checked) => {
159
+ const current = attributes.extensionsPreset ?? []
160
+ setAttributes({
161
+ extensionsPreset: checked ? [...current, preset.value] : current.filter((value) => value !== preset.value),
162
+ })
163
+ }}
164
+ />
165
+ ))}
166
+ <TextControl
167
+ label={__('Vlastní přípony', 'brilo-blocks')}
168
+ help={__('Oddělené čárkou, bez tečky. Např. heic,zip', 'brilo-blocks')}
169
+ value={attributes.extensionsCustom ?? ''}
170
+ onChange={(extensionsCustom) => setAttributes({extensionsCustom})}
171
+ />
172
+
173
+ <SelectControl
174
+ label={__('Vzhled tlačítka', 'brilo-blocks')}
175
+ value={attributes.buttonVariant ?? 'secondary'}
176
+ options={FILE_BUTTON_VARIANTS.map((v) => ({label: v.label, value: v.value}))}
177
+ onChange={(buttonVariant) => setAttributes({buttonVariant: buttonVariant as FormFieldFileButtonVariant})}
178
+ />
179
+ <ToggleControl
180
+ label={__('Outline styl tlačítka', 'brilo-blocks')}
181
+ checked={attributes.buttonOutline ?? true}
182
+ onChange={(buttonOutline) => setAttributes({buttonOutline})}
183
+ />
92
184
  <TextControl
93
- label={__('Placeholder', 'brilo-blocks')}
94
- value={attributes.placeholder}
95
- onChange={(placeholder) => setAttributes({placeholder})}
185
+ label={__('Text tlačítka', 'brilo-blocks')}
186
+ value={attributes.buttonLabel ?? ''}
187
+ onChange={(buttonLabel) => setAttributes({buttonLabel})}
96
188
  />
97
189
  </>
98
190
  )}
@@ -1,6 +1,6 @@
1
1
  import type {BlockConfiguration} from '@wordpress/blocks'
2
2
  import {__} from '@wordpress/i18n'
3
- import {FIELD_COLUMNS_DEFAULT} from './constants'
3
+ import {FIELD_COLUMNS_DEFAULT, FIELD_FILE_BUTTON_LABEL_DEFAULT, FIELD_FILE_BUTTON_VARIANT_DEFAULT} from './constants'
4
4
  import {createFormFieldEdit} from './edit'
5
5
  import type {FormFieldAttributes, FormFieldOptions} from './types'
6
6
 
@@ -27,6 +27,14 @@ export function createFormFieldBlock(options: FormFieldOptions): BlockConfigurat
27
27
  selectMode: {type: 'string', default: 'classic'},
28
28
  defaultValue: {type: 'string', default: ''},
29
29
  value: {type: 'string', default: ''},
30
+ isReplyTo: {type: 'boolean', default: false},
31
+ gtmEnabled: {type: 'boolean', default: false},
32
+ multiple: {type: 'boolean', default: false},
33
+ extensionsPreset: {type: 'array', default: []},
34
+ extensionsCustom: {type: 'string', default: ''},
35
+ buttonVariant: {type: 'string', default: FIELD_FILE_BUTTON_VARIANT_DEFAULT},
36
+ buttonOutline: {type: 'boolean', default: true},
37
+ buttonLabel: {type: 'string', default: FIELD_FILE_BUTTON_LABEL_DEFAULT},
30
38
  },
31
39
  edit: createFormFieldEdit(options),
32
40
  save: () => null,