@brilo/base-blocks 0.1.39 → 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.
- package/build/.tsbuildinfo +1 -1
- package/build/blocks/form/form-field/constants.d.ts +33 -1
- package/build/blocks/form/form-field/constants.d.ts.map +1 -1
- package/build/blocks/form/form-field/constants.js +17 -1
- package/build/blocks/form/form-field/edit.d.ts.map +1 -1
- package/build/blocks/form/form-field/edit.js +10 -4
- package/build/blocks/form/form-field/factory.d.ts.map +1 -1
- package/build/blocks/form/form-field/factory.js +7 -1
- package/build/blocks/form/form-field/types.d.ts +8 -1
- package/build/blocks/form/form-field/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blocks/form/form-field/constants.ts +22 -1
- package/src/blocks/form/form-field/edit.tsx +80 -13
- package/src/blocks/form/form-field/factory.tsx +7 -1
- package/src/blocks/form/form-field/types.ts +14 -1
|
@@ -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;
|
|
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":"
|
|
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, _g, _h;
|
|
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'),
|
|
@@ -39,6 +39,12 @@ export function createFormFieldEdit(_options) {
|
|
|
39
39
|
];
|
|
40
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
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) }) }), _jsx(TextControl, { label: __('Placeholder', 'brilo-blocks'), value: attributes.placeholder, onChange: (placeholder) => setAttributes({ placeholder }) }), _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 === '
|
|
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: "+" })] })] })) }) })] }));
|
|
43
49
|
};
|
|
44
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,
|
|
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;
|
|
@@ -25,6 +25,12 @@ export function createFormFieldBlock(options) {
|
|
|
25
25
|
value: { type: 'string', default: '' },
|
|
26
26
|
isReplyTo: { type: 'boolean', default: false },
|
|
27
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 },
|
|
28
34
|
},
|
|
29
35
|
edit: createFormFieldEdit(options),
|
|
30
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;
|
|
@@ -22,6 +23,12 @@ export interface FormFieldAttributes extends Record<string, unknown> {
|
|
|
22
23
|
value: string;
|
|
23
24
|
isReplyTo: boolean;
|
|
24
25
|
gtmEnabled: boolean;
|
|
26
|
+
multiple: boolean;
|
|
27
|
+
extensionsPreset: string[];
|
|
28
|
+
extensionsCustom: string;
|
|
29
|
+
buttonVariant: FormFieldFileButtonVariant;
|
|
30
|
+
buttonOutline: boolean;
|
|
31
|
+
buttonLabel: string;
|
|
25
32
|
}
|
|
26
33
|
export interface FormFieldOptions extends BriloBlockType {
|
|
27
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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
|
|
|
@@ -104,20 +119,72 @@ export function createFormFieldEdit(_options: FormFieldOptions) {
|
|
|
104
119
|
)}
|
|
105
120
|
onChange={(name) => setAttributes({name: sanitizeHtmlName(name)})}
|
|
106
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
|
+
))}
|
|
107
166
|
<TextControl
|
|
108
|
-
label={__('
|
|
109
|
-
|
|
110
|
-
|
|
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})}
|
|
111
171
|
/>
|
|
112
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
|
+
/>
|
|
113
179
|
<ToggleControl
|
|
114
|
-
label={__('
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
180
|
+
label={__('Outline styl tlačítka', 'brilo-blocks')}
|
|
181
|
+
checked={attributes.buttonOutline ?? true}
|
|
182
|
+
onChange={(buttonOutline) => setAttributes({buttonOutline})}
|
|
183
|
+
/>
|
|
184
|
+
<TextControl
|
|
185
|
+
label={__('Text tlačítka', 'brilo-blocks')}
|
|
186
|
+
value={attributes.buttonLabel ?? ''}
|
|
187
|
+
onChange={(buttonLabel) => setAttributes({buttonLabel})}
|
|
121
188
|
/>
|
|
122
189
|
</>
|
|
123
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
|
|
|
@@ -29,6 +29,12 @@ export function createFormFieldBlock(options: FormFieldOptions): BlockConfigurat
|
|
|
29
29
|
value: {type: 'string', default: ''},
|
|
30
30
|
isReplyTo: {type: 'boolean', default: false},
|
|
31
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},
|
|
32
38
|
},
|
|
33
39
|
edit: createFormFieldEdit(options),
|
|
34
40
|
save: () => null,
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FIELD_SELECT_MODE_VALUES,
|
|
3
|
+
FIELD_TEXT_TYPES,
|
|
4
|
+
FIELD_TEXT_TYPE_VALUES,
|
|
5
|
+
FIELD_TYPE_VALUES,
|
|
6
|
+
FILE_BUTTON_VARIANT_VALUES,
|
|
7
|
+
} from './constants'
|
|
2
8
|
import type {BriloBlockType} from '~/types'
|
|
3
9
|
|
|
4
10
|
export type FormFieldType = (typeof FIELD_TYPE_VALUES)[number]
|
|
5
11
|
export type FormFieldTextType = (typeof FIELD_TEXT_TYPE_VALUES)[number]
|
|
6
12
|
export type FormFieldSelectMode = (typeof FIELD_SELECT_MODE_VALUES)[number]
|
|
13
|
+
export type FormFieldFileButtonVariant = (typeof FILE_BUTTON_VARIANT_VALUES)[number]
|
|
7
14
|
|
|
8
15
|
export type FormFieldOption = string | {label?: string; value?: string; email?: string}
|
|
9
16
|
|
|
@@ -21,6 +28,12 @@ export interface FormFieldAttributes extends Record<string, unknown> {
|
|
|
21
28
|
value: string
|
|
22
29
|
isReplyTo: boolean
|
|
23
30
|
gtmEnabled: boolean
|
|
31
|
+
multiple: boolean
|
|
32
|
+
extensionsPreset: string[]
|
|
33
|
+
extensionsCustom: string
|
|
34
|
+
buttonVariant: FormFieldFileButtonVariant
|
|
35
|
+
buttonOutline: boolean
|
|
36
|
+
buttonLabel: string
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
export interface FormFieldOptions extends BriloBlockType {}
|