@brilo/base-blocks 0.1.21 → 0.1.23
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/SelectOptionsRepeater.d.ts +10 -0
- package/build/blocks/form/form-field/SelectOptionsRepeater.d.ts.map +1 -0
- package/build/blocks/form/form-field/SelectOptionsRepeater.js +20 -0
- package/build/blocks/form/form-field/constants.d.ts +8 -0
- package/build/blocks/form/form-field/constants.d.ts.map +1 -1
- package/build/blocks/form/form-field/constants.js +5 -0
- package/build/blocks/form/form-field/edit.d.ts.map +1 -1
- package/build/blocks/form/form-field/edit.js +20 -11
- package/build/blocks/form/form-field/factory.d.ts.map +1 -1
- package/build/blocks/form/form-field/factory.js +1 -0
- package/build/blocks/form/form-field/normalizeOptions.d.ts +18 -0
- package/build/blocks/form/form-field/normalizeOptions.d.ts.map +1 -0
- package/build/blocks/form/form-field/normalizeOptions.js +39 -0
- package/build/blocks/form/form-field/types.d.ts +9 -2
- package/build/blocks/form/form-field/types.d.ts.map +1 -1
- package/build/blocks/layout/layout-aside/constants.d.ts +2 -0
- package/build/blocks/layout/layout-aside/constants.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/constants.js +1 -0
- package/build/blocks/layout/layout-aside/edit.d.ts +4 -0
- package/build/blocks/layout/layout-aside/edit.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/edit.js +13 -0
- package/build/blocks/layout/layout-aside/factory.d.ts +4 -0
- package/build/blocks/layout/layout-aside/factory.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/factory.js +20 -0
- package/build/blocks/layout/layout-aside/icon.d.ts +3 -0
- package/build/blocks/layout/layout-aside/icon.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/icon.js +2 -0
- package/build/blocks/layout/layout-aside/index.d.ts +5 -0
- package/build/blocks/layout/layout-aside/index.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/index.js +5 -0
- package/build/blocks/layout/layout-aside/types.d.ts +6 -0
- package/build/blocks/layout/layout-aside/types.d.ts.map +1 -0
- package/build/blocks/layout/layout-aside/types.js +1 -0
- package/build/blocks/layout/layout-content/constants.d.ts +2 -0
- package/build/blocks/layout/layout-content/constants.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/constants.js +1 -0
- package/build/blocks/layout/layout-content/edit.d.ts +4 -0
- package/build/blocks/layout/layout-content/edit.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/edit.js +13 -0
- package/build/blocks/layout/layout-content/factory.d.ts +4 -0
- package/build/blocks/layout/layout-content/factory.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/factory.js +20 -0
- package/build/blocks/layout/layout-content/icon.d.ts +3 -0
- package/build/blocks/layout/layout-content/icon.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/icon.js +2 -0
- package/build/blocks/layout/layout-content/index.d.ts +5 -0
- package/build/blocks/layout/layout-content/index.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/index.js +5 -0
- package/build/blocks/layout/layout-content/types.d.ts +6 -0
- package/build/blocks/layout/layout-content/types.d.ts.map +1 -0
- package/build/blocks/layout/layout-content/types.js +1 -0
- package/build/blocks/layout/layout-content-w-aside/constants.d.ts +11 -0
- package/build/blocks/layout/layout-content-w-aside/constants.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/constants.js +6 -0
- package/build/blocks/layout/layout-content-w-aside/edit.d.ts +7 -0
- package/build/blocks/layout/layout-content-w-aside/edit.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/edit.js +22 -0
- package/build/blocks/layout/layout-content-w-aside/factory.d.ts +6 -0
- package/build/blocks/layout/layout-content-w-aside/factory.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/factory.js +26 -0
- package/build/blocks/layout/layout-content-w-aside/icon.d.ts +3 -0
- package/build/blocks/layout/layout-content-w-aside/icon.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/icon.js +2 -0
- package/build/blocks/layout/layout-content-w-aside/index.d.ts +5 -0
- package/build/blocks/layout/layout-content-w-aside/index.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/index.js +9 -0
- package/build/blocks/layout/layout-content-w-aside/types.d.ts +10 -0
- package/build/blocks/layout/layout-content-w-aside/types.d.ts.map +1 -0
- package/build/blocks/layout/layout-content-w-aside/types.js +1 -0
- package/build/blocks/post/posts-grid/constants.d.ts +4 -0
- package/build/blocks/post/posts-grid/constants.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/constants.js +3 -0
- package/build/blocks/post/posts-grid/edit.d.ts +6 -0
- package/build/blocks/post/posts-grid/edit.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/edit.js +21 -0
- package/build/blocks/post/posts-grid/factory.d.ts +5 -0
- package/build/blocks/post/posts-grid/factory.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/factory.js +59 -0
- package/build/blocks/post/posts-grid/icon.d.ts +2 -0
- package/build/blocks/post/posts-grid/icon.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/icon.js +2 -0
- package/build/blocks/post/posts-grid/index.d.ts +5 -0
- package/build/blocks/post/posts-grid/index.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/index.js +5 -0
- package/build/blocks/post/posts-grid/types.d.ts +22 -0
- package/build/blocks/post/posts-grid/types.d.ts.map +1 -0
- package/build/blocks/post/posts-grid/types.js +1 -0
- package/build/blocks/sections/base-section/attributes.d.ts +4 -0
- package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
- package/build/blocks/sections/base-section/attributes.js +4 -0
- package/build/blocks/sections/base-section/constants.d.ts +7 -0
- package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
- package/build/blocks/sections/base-section/constants.js +7 -0
- package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
- package/build/blocks/sections/base-section/controls.js +23 -5
- package/build/blocks/sections/base-section/types.d.ts +18 -1
- package/build/blocks/sections/base-section/types.d.ts.map +1 -1
- package/build/blocks/signpost/signpost-group/constants.d.ts +1 -1
- package/build/blocks/signpost/signpost-group/constants.d.ts.map +1 -1
- package/build/blocks/signpost/signpost-group/constants.js +1 -1
- package/build/index.d.ts +8 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/package.json +5 -2
- package/src/blocks/form/form-field/SelectOptionsRepeater.tsx +111 -0
- package/src/blocks/form/form-field/constants.ts +7 -0
- package/src/blocks/form/form-field/edit.tsx +42 -16
- package/src/blocks/form/form-field/editor.scss +28 -0
- package/src/blocks/form/form-field/factory.tsx +1 -0
- package/src/blocks/form/form-field/normalizeOptions.ts +58 -0
- package/src/blocks/form/form-field/types.ts +6 -2
- package/src/blocks/layout/layout-aside/constants.ts +1 -0
- package/src/blocks/layout/layout-aside/edit.tsx +20 -0
- package/src/blocks/layout/layout-aside/editor.scss +9 -0
- package/src/blocks/layout/layout-aside/factory.tsx +24 -0
- package/src/blocks/layout/layout-aside/icon.tsx +12 -0
- package/src/blocks/layout/layout-aside/index.ts +9 -0
- package/src/blocks/layout/layout-aside/types.ts +5 -0
- package/src/blocks/layout/layout-content/constants.ts +1 -0
- package/src/blocks/layout/layout-content/edit.tsx +20 -0
- package/src/blocks/layout/layout-content/editor.scss +9 -0
- package/src/blocks/layout/layout-content/factory.tsx +24 -0
- package/src/blocks/layout/layout-content/icon.tsx +12 -0
- package/src/blocks/layout/layout-content/index.ts +9 -0
- package/src/blocks/layout/layout-content/types.ts +5 -0
- package/src/blocks/layout/layout-content-w-aside/constants.ts +7 -0
- package/src/blocks/layout/layout-content-w-aside/edit.tsx +52 -0
- package/src/blocks/layout/layout-content-w-aside/editor.scss +35 -0
- package/src/blocks/layout/layout-content-w-aside/factory.tsx +34 -0
- package/src/blocks/layout/layout-content-w-aside/icon.tsx +12 -0
- package/src/blocks/layout/layout-content-w-aside/index.ts +13 -0
- package/src/blocks/layout/layout-content-w-aside/types.ts +12 -0
- package/src/blocks/post/posts-grid/constants.ts +3 -0
- package/src/blocks/post/posts-grid/edit.tsx +105 -0
- package/src/blocks/post/posts-grid/factory.tsx +63 -0
- package/src/blocks/post/posts-grid/icon.tsx +8 -0
- package/src/blocks/post/posts-grid/index.ts +9 -0
- package/src/blocks/post/posts-grid/types.ts +25 -0
- package/src/blocks/sections/base-section/attributes.ts +4 -0
- package/src/blocks/sections/base-section/constants.ts +10 -0
- package/src/blocks/sections/base-section/controls.tsx +83 -4
- package/src/blocks/sections/base-section/types.ts +20 -1
- package/src/blocks/signpost/signpost-group/constants.ts +1 -1
- package/src/editor.scss +3 -0
- package/src/index.ts +8 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OptionRow } from './normalizeOptions';
|
|
2
|
+
type Props = {
|
|
3
|
+
rows: OptionRow[];
|
|
4
|
+
onChange: (rows: OptionRow[]) => void;
|
|
5
|
+
showEmail: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function SelectOptionsRepeater({ rows, onChange, showEmail, onClose }: Props): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=SelectOptionsRepeater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectOptionsRepeater.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/SelectOptionsRepeater.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAA;AAIjD,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,SAAS,EAAE,CAAA;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,IAAI,CAAA;IACrC,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED,wBAAgB,qBAAqB,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAC,EAAE,KAAK,+BAgGhF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Card, CardBody, Flex, FlexBlock, FlexItem, TextControl } from '@wordpress/components';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { ReactSortable } from 'react-sortablejs';
|
|
5
|
+
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
6
|
+
export function SelectOptionsRepeater({ rows, onChange, showEmail, onClose }) {
|
|
7
|
+
const updateRow = (id, patch) => {
|
|
8
|
+
onChange(rows.map((row) => (row.id === id ? { ...row, ...patch } : row)));
|
|
9
|
+
};
|
|
10
|
+
const removeRow = (id) => {
|
|
11
|
+
onChange(rows.filter((row) => row.id !== id));
|
|
12
|
+
};
|
|
13
|
+
const addRow = () => {
|
|
14
|
+
onChange([...rows, { id: `${Date.now()}-${Math.random()}`, label: '', value: '', email: '' }]);
|
|
15
|
+
};
|
|
16
|
+
return (_jsxs("div", { className: "i-form-field__options-repeater", children: [_jsx(ReactSortable, { list: rows, setList: onChange, handle: ".i-form-field__option-drag-handle", animation: 150, children: rows.map((row) => {
|
|
17
|
+
const isEmailInvalid = row.email.trim() !== '' && !EMAIL_PATTERN.test(row.email.trim());
|
|
18
|
+
return (_jsx(Card, { size: "small", className: "i-form-field__option-row", children: _jsx(CardBody, { children: _jsxs(Flex, { align: "flex-start", gap: 3, children: [_jsx(FlexItem, { children: _jsx("span", { className: "i-form-field__option-drag-handle", "aria-hidden": "true", children: "\u283F" }) }), _jsx(FlexBlock, { children: _jsxs(Flex, { direction: "column", gap: 3, children: [_jsx(FlexItem, { children: _jsx(TextControl, { label: __('Popisek', 'brilo-blocks'), placeholder: __('Popisek možnosti', 'brilo-blocks'), value: row.label, onChange: (label) => updateRow(row.id, { label }) }) }), _jsx(FlexItem, { children: _jsx(TextControl, { label: __('Hodnota', 'brilo-blocks'), placeholder: __('auto (dle popisku)', 'brilo-blocks'), value: row.value, onChange: (value) => updateRow(row.id, { value }), help: __('Volitelné, jinak se odvodí z popisku.', 'brilo-blocks') }) }), showEmail && (_jsx(FlexItem, { children: _jsx(TextControl, { label: __('E-mail', 'brilo-blocks'), type: "email", placeholder: __('Email příjemce (volitelné)', 'brilo-blocks'), value: row.email, onChange: (email) => updateRow(row.id, { email }), help: isEmailInvalid ? __('Neplatný formát emailu.', 'brilo-blocks') : undefined }) }))] }) }), _jsx(FlexItem, { children: _jsx(Button, { icon: "no-alt", size: "small", variant: "tertiary", isDestructive: true, label: __('Odebrat možnost', 'brilo-blocks'), onClick: () => removeRow(row.id) }) })] }) }) }, row.id));
|
|
19
|
+
}) }), _jsxs(Flex, { className: "i-form-field__options-footer", justify: "flex-start", gap: 2, children: [_jsx(FlexItem, { children: _jsx(Button, { variant: "secondary", onClick: addRow, children: __('Přidat možnost', 'brilo-blocks') }) }), _jsx(FlexItem, { children: _jsx(Button, { variant: "tertiary", onClick: onClose, children: __('Zavřít', 'brilo-blocks') }) })] })] }));
|
|
20
|
+
}
|
|
@@ -37,4 +37,12 @@ export declare const FIELD_COLUMNS_RANGE: {
|
|
|
37
37
|
readonly max: 12;
|
|
38
38
|
};
|
|
39
39
|
export declare const FIELD_COLUMNS_DEFAULT = 6;
|
|
40
|
+
export declare const FIELD_SELECT_MODE_VALUES: readonly ['classic', 'email'];
|
|
41
|
+
export declare const FIELD_SELECT_MODES: readonly [{
|
|
42
|
+
readonly value: "classic";
|
|
43
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Klasický">;
|
|
44
|
+
}, {
|
|
45
|
+
readonly value: "email";
|
|
46
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Výběr s routováním e-mailu">;
|
|
47
|
+
}];
|
|
40
48
|
//# 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"}
|
|
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"}
|
|
@@ -17,3 +17,8 @@ export const FIELD_TEXT_TYPES = [
|
|
|
17
17
|
];
|
|
18
18
|
export const FIELD_COLUMNS_RANGE = { min: 1, max: 12 };
|
|
19
19
|
export const FIELD_COLUMNS_DEFAULT = 6;
|
|
20
|
+
export const FIELD_SELECT_MODE_VALUES = ['classic', 'email'];
|
|
21
|
+
export const FIELD_SELECT_MODES = [
|
|
22
|
+
{ value: FIELD_SELECT_MODE_VALUES[0], label: __('Klasický', 'brilo-blocks') },
|
|
23
|
+
{ value: FIELD_SELECT_MODE_VALUES[1], label: __('Výběr s routováním e-mailu', 'brilo-blocks') },
|
|
24
|
+
];
|
|
@@ -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":"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,9 +1,12 @@
|
|
|
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,
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Button, Modal, PanelBody, RangeControl, SelectControl, TextControl, ToggleControl } from '@wordpress/components';
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import {
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { FIELD_COLUMNS_DEFAULT, FIELD_COLUMNS_RANGE, FIELD_SELECT_MODES, FIELD_TEXT_TYPES, FIELD_TYPES } from './constants';
|
|
8
|
+
import { normalizeOptions, serializeOptions } from './normalizeOptions';
|
|
9
|
+
import { SelectOptionsRepeater } from './SelectOptionsRepeater';
|
|
7
10
|
const { min: MIN_COLUMNS, max: MAX_COLUMNS } = FIELD_COLUMNS_RANGE;
|
|
8
11
|
function sanitizeHtmlName(raw) {
|
|
9
12
|
return (raw !== null && raw !== void 0 ? raw : '')
|
|
@@ -17,17 +20,23 @@ function sanitizeHtmlName(raw) {
|
|
|
17
20
|
}
|
|
18
21
|
export function createFormFieldEdit(_options) {
|
|
19
22
|
return function Edit({ attributes, setAttributes, }) {
|
|
20
|
-
var _a, _b, _c, _d;
|
|
23
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
24
|
const currentColumns = Math.max(MIN_COLUMNS, Math.min(MAX_COLUMNS, attributes.columns || MIN_COLUMNS));
|
|
22
25
|
const blockProps = useBlockProps({
|
|
23
26
|
className: clsx('i-form-field', `--type-${attributes.type}`, `--cols-${currentColumns}`, attributes.required && '--required'),
|
|
24
27
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
// Rows carry a locally-generated id (for React/Sortable identity) that is never persisted;
|
|
29
|
+
// deriving it fresh from attributes on every render would remount inputs and drop focus mid-keystroke.
|
|
30
|
+
const [optionRows, setOptionRows] = useState(() => normalizeOptions(attributes.options));
|
|
31
|
+
const [isOptionsModalOpen, setIsOptionsModalOpen] = useState(false);
|
|
32
|
+
const updateOptionRows = (rows) => {
|
|
33
|
+
setOptionRows(rows);
|
|
34
|
+
setAttributes({ options: serializeOptions(rows) });
|
|
35
|
+
};
|
|
36
|
+
const selectOptions = [
|
|
37
|
+
{ label: __('Žádná', 'brilo-blocks'), value: '' },
|
|
38
|
+
...optionRows.map((row) => ({ label: row.label, value: row.label })),
|
|
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: "+" })] })] })) }) })] }));
|
|
32
41
|
};
|
|
33
42
|
}
|
|
@@ -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,CAyBvG"}
|
|
@@ -20,6 +20,7 @@ export function createFormFieldBlock(options) {
|
|
|
20
20
|
placeholder: { type: 'string', default: '' },
|
|
21
21
|
required: { type: 'boolean', default: false },
|
|
22
22
|
options: { type: 'array', default: [] },
|
|
23
|
+
selectMode: { type: 'string', default: 'classic' },
|
|
23
24
|
defaultValue: { type: 'string', default: '' },
|
|
24
25
|
value: { type: 'string', default: '' },
|
|
25
26
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type PersistedOption = string | {
|
|
2
|
+
label?: unknown;
|
|
3
|
+
value?: unknown;
|
|
4
|
+
email?: unknown;
|
|
5
|
+
};
|
|
6
|
+
export type OptionRow = {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
email: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function normalizeOptions(options: unknown): OptionRow[];
|
|
13
|
+
export declare function serializeOptions(rows: OptionRow[]): Array<{
|
|
14
|
+
label: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
email?: string;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=normalizeOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeOptions.d.ts","sourceRoot":"","sources":["../../../../src/blocks/form/form-field/normalizeOptions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC,CAAA;AAE1F,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAMD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,CA0B9D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAgB1G"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function makeId() {
|
|
2
|
+
return typeof crypto !== 'undefined' && 'randomUUID' in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random()}`;
|
|
3
|
+
}
|
|
4
|
+
export function normalizeOptions(options) {
|
|
5
|
+
if (!Array.isArray(options)) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return options
|
|
9
|
+
.map((option) => {
|
|
10
|
+
if (typeof option === 'string') {
|
|
11
|
+
return option === '' ? null : { id: makeId(), label: option, value: '', email: '' };
|
|
12
|
+
}
|
|
13
|
+
if (option && typeof option === 'object') {
|
|
14
|
+
const label = typeof option.label === 'string' ? option.label : '';
|
|
15
|
+
const value = typeof option.value === 'string' ? option.value : '';
|
|
16
|
+
const email = typeof option.email === 'string' ? option.email : '';
|
|
17
|
+
if (label === '') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return { id: makeId(), label, value, email };
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
})
|
|
24
|
+
.filter((row) => row !== null);
|
|
25
|
+
}
|
|
26
|
+
export function serializeOptions(rows) {
|
|
27
|
+
return rows
|
|
28
|
+
.filter((row) => row.label.trim() !== '')
|
|
29
|
+
.map((row) => {
|
|
30
|
+
const option = { label: row.label };
|
|
31
|
+
if (row.value.trim() !== '') {
|
|
32
|
+
option.value = row.value.trim();
|
|
33
|
+
}
|
|
34
|
+
if (row.email.trim() !== '') {
|
|
35
|
+
option.email = row.email.trim();
|
|
36
|
+
}
|
|
37
|
+
return option;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { FIELD_TEXT_TYPE_VALUES, FIELD_TYPE_VALUES } from './constants';
|
|
1
|
+
import { FIELD_SELECT_MODE_VALUES, FIELD_TEXT_TYPE_VALUES, FIELD_TYPE_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
|
+
export type FormFieldSelectMode = (typeof FIELD_SELECT_MODE_VALUES)[number];
|
|
6
|
+
export type FormFieldOption = string | {
|
|
7
|
+
label?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
};
|
|
5
11
|
export interface FormFieldAttributes extends Record<string, unknown> {
|
|
6
12
|
type: FormFieldType;
|
|
7
13
|
textType: FormFieldTextType;
|
|
@@ -10,7 +16,8 @@ export interface FormFieldAttributes extends Record<string, unknown> {
|
|
|
10
16
|
name: string;
|
|
11
17
|
placeholder: string;
|
|
12
18
|
required: boolean;
|
|
13
|
-
options:
|
|
19
|
+
options: FormFieldOption[];
|
|
20
|
+
selectMode: FormFieldSelectMode;
|
|
14
21
|
defaultValue: string;
|
|
15
22
|
value: string;
|
|
16
23
|
}
|
|
@@ -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,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-aside/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,IAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ASIDE_DEFAULTS = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-aside/edit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAkB,YAAY,EAAC,MAAM,SAAS,CAAA;AAE1D,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,2BAepD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useGroupBlock } from '../../../hooks/useGroupBlock';
|
|
3
|
+
export function createAsideEdit(options) {
|
|
4
|
+
return function Edit() {
|
|
5
|
+
const { blockProps, innerBlocksProps } = useGroupBlock({
|
|
6
|
+
blockClassName: 'l-content-w-aside__aside',
|
|
7
|
+
containerClassName: 'l-content-w-aside__aside-container',
|
|
8
|
+
layout: { type: 'default' },
|
|
9
|
+
orientation: 'vertical',
|
|
10
|
+
});
|
|
11
|
+
return (_jsx("aside", { ...blockProps, children: _jsx("div", { ...innerBlocksProps }) }));
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-aside/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAKzD,OAAO,KAAK,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAE1D,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,GACpB,kBAAkB,CAAC,eAAe,CAAC,CAarC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { InnerBlocks } from '@wordpress/block-editor';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { createAsideEdit } from './edit';
|
|
5
|
+
import { icon as defaultIcon } from './icon';
|
|
6
|
+
export function createAsideBlock(options) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
return {
|
|
9
|
+
name: options.name,
|
|
10
|
+
title: (_a = options.title) !== null && _a !== void 0 ? _a : __('Postranní panel', 'brilo-blocks'),
|
|
11
|
+
description: options.description,
|
|
12
|
+
category: (_b = options.category) !== null && _b !== void 0 ? _b : 'layout',
|
|
13
|
+
parent: options.parent,
|
|
14
|
+
icon: (_c = options.icon) !== null && _c !== void 0 ? _c : { src: defaultIcon },
|
|
15
|
+
supports: { html: false, customClassName: false },
|
|
16
|
+
attributes: {},
|
|
17
|
+
edit: createAsideEdit(options),
|
|
18
|
+
save: () => _jsx(InnerBlocks.Content, {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-aside/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,IAAI,mBAShB,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const icon = (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M8 4H20V20H8V4ZM10 6H18V18H10V6Z", fill: "currentColor" }) }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-aside/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAA;AAE1C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,aAAa,EAAE,YAG3B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-aside/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,WAAW,eAAgB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AAEnE,MAAM,WAAW,YAAa,SAAQ,cAAc;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,IAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CONTENT_DEFAULTS = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content/edit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAoB,cAAc,EAAC,MAAM,SAAS,CAAA;AAE9D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,2BAexD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useGroupBlock } from '../../../hooks/useGroupBlock';
|
|
3
|
+
export function createContentEdit(options) {
|
|
4
|
+
return function Edit() {
|
|
5
|
+
const { blockProps, innerBlocksProps } = useGroupBlock({
|
|
6
|
+
blockClassName: 'l-content-w-aside__content',
|
|
7
|
+
containerClassName: 'l-content-w-aside__content-container',
|
|
8
|
+
layout: { type: 'default' },
|
|
9
|
+
orientation: 'vertical',
|
|
10
|
+
});
|
|
11
|
+
return (_jsx("div", { ...blockProps, children: _jsx("div", { ...innerBlocksProps }) }));
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BlockConfiguration } from '@wordpress/blocks';
|
|
2
|
+
import type { ContentAttributes, ContentOptions } from './types';
|
|
3
|
+
export declare function createContentBlock(options: ContentOptions): BlockConfiguration<ContentAttributes>;
|
|
4
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAKzD,OAAO,KAAK,EAAC,iBAAiB,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAE9D,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,cAAc,GACtB,kBAAkB,CAAC,iBAAiB,CAAC,CAavC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { InnerBlocks } from '@wordpress/block-editor';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { createContentEdit } from './edit';
|
|
5
|
+
import { icon as defaultIcon } from './icon';
|
|
6
|
+
export function createContentBlock(options) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
return {
|
|
9
|
+
name: options.name,
|
|
10
|
+
title: (_a = options.title) !== null && _a !== void 0 ? _a : __('Obsah', 'brilo-blocks'),
|
|
11
|
+
description: options.description,
|
|
12
|
+
category: (_b = options.category) !== null && _b !== void 0 ? _b : 'layout',
|
|
13
|
+
parent: options.parent,
|
|
14
|
+
icon: (_c = options.icon) !== null && _c !== void 0 ? _c : { src: defaultIcon },
|
|
15
|
+
supports: { html: false, customClassName: false },
|
|
16
|
+
attributes: {},
|
|
17
|
+
edit: createContentEdit(options),
|
|
18
|
+
save: () => _jsx(InnerBlocks.Content, {}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,IAAI,mBAShB,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const icon = (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4 4H16V20H4V4ZM6 6H14V18H6V6Z", fill: "currentColor" }) }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,iBAAiB,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAC,kBAAkB,EAAC,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,eAAO,MAAM,eAAe,EAAE,cAG7B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,WAAW,iBAAkB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AAErE,MAAM,WAAW,cAAe,SAAQ,cAAc;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ASIDE_SIZES: readonly [{
|
|
2
|
+
readonly value: 'sm';
|
|
3
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Malá">;
|
|
4
|
+
}, {
|
|
5
|
+
readonly value: 'md';
|
|
6
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Střední">;
|
|
7
|
+
}, {
|
|
8
|
+
readonly value: 'lg';
|
|
9
|
+
readonly label: import("@wordpress/i18n").TransformedText<"Velká">;
|
|
10
|
+
}];
|
|
11
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content-w-aside/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;aACrB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;EACX,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ContentWithAsideAttributes, ContentWithAsideOptions } from './types';
|
|
3
|
+
export declare function createContentWithAsideEdit(options: ContentWithAsideOptions): ({ attributes, setAttributes, }: {
|
|
4
|
+
attributes: ContentWithAsideAttributes;
|
|
5
|
+
setAttributes: (a: Partial<ContentWithAsideAttributes>) => void;
|
|
6
|
+
}) => React.JSX.Element;
|
|
7
|
+
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content-w-aside/edit.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAY,0BAA0B,EAAE,uBAAuB,EAAC,MAAM,SAAS,CAAA;AAE3F,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,uBAAuB,oCAMtE;IACD,UAAU,EAAE,0BAA0B,CAAA;IACtC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,KAAK,IAAI,CAAA;CAChE,uBAkCF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { InspectorControls } from '@wordpress/block-editor';
|
|
3
|
+
import { PanelBody, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption } from '@wordpress/components';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useGroupBlock } from '../../../hooks/useGroupBlock';
|
|
6
|
+
import { ASIDE_SIZES } from './constants';
|
|
7
|
+
export function createContentWithAsideEdit(options) {
|
|
8
|
+
var _a;
|
|
9
|
+
const ASIDE_SIZES_OPTIONS = (_a = options.asideSizes) !== null && _a !== void 0 ? _a : ASIDE_SIZES;
|
|
10
|
+
return function Edit({ attributes, setAttributes, }) {
|
|
11
|
+
const { asideSize } = attributes;
|
|
12
|
+
const { blockProps, innerBlocksProps } = useGroupBlock({
|
|
13
|
+
blockClassName: 'l-content-w-aside',
|
|
14
|
+
containerClassName: `l-content-w-aside__container --aside-${asideSize}`,
|
|
15
|
+
template: options.template,
|
|
16
|
+
allowedBlocks: options.allowedBlocks,
|
|
17
|
+
orientation: 'horizontal',
|
|
18
|
+
layout: { type: 'default' },
|
|
19
|
+
});
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsx(PanelBody, { title: __('Nastavení', 'brilo-blocks'), children: _jsx(ToggleGroupControl, { isBlock: true, label: __('Velikost postranního panelu', 'brilo-blocks'), value: asideSize, onChange: (v) => setAttributes({ asideSize: v }), children: ASIDE_SIZES_OPTIONS.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) }) }) }), _jsx("div", { ...blockProps, children: _jsx("div", { ...innerBlocksProps }) })] }));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlockConfiguration } from '@wordpress/blocks';
|
|
2
|
+
import type { OptionArray } from '../../../types';
|
|
3
|
+
import { ASIDE_SIZES } from './constants';
|
|
4
|
+
import type { ContentWithAsideAttributes, ContentWithAsideOptions } from './types';
|
|
5
|
+
export declare function createContentWithAsideBlock<TAsideSizes extends OptionArray = typeof ASIDE_SIZES>(options: ContentWithAsideOptions<TAsideSizes>): BlockConfiguration<ContentWithAsideAttributes<TAsideSizes[number]['value']>>;
|
|
6
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/layout/layout-content-w-aside/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAGzD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AAGvC,OAAO,KAAK,EAAC,0BAA0B,EAAE,uBAAuB,EAAC,MAAM,SAAS,CAAA;AAEhF,wBAAgB,2BAA2B,CACzC,WAAW,SAAS,WAAW,GAAG,OAAO,WAAW,EAEpD,OAAO,EAAE,uBAAuB,CAAC,WAAW,CAAC,GAC5C,kBAAkB,CAAC,0BAA0B,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAmB9E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { InnerBlocks } from '@wordpress/block-editor';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { ASIDE_SIZES } from './constants';
|
|
5
|
+
import { createContentWithAsideEdit } from './edit';
|
|
6
|
+
import { icon as defaultIcon } from './icon';
|
|
7
|
+
export function createContentWithAsideBlock(options) {
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
const asideSizes = (_a = options.asideSizes) !== null && _a !== void 0 ? _a : ASIDE_SIZES;
|
|
10
|
+
return {
|
|
11
|
+
name: options.name,
|
|
12
|
+
title: (_b = options.title) !== null && _b !== void 0 ? _b : __('Obsah s postranním panelem', 'brilo-blocks'),
|
|
13
|
+
description: options.description,
|
|
14
|
+
category: (_c = options.category) !== null && _c !== void 0 ? _c : 'layout',
|
|
15
|
+
icon: (_d = options.icon) !== null && _d !== void 0 ? _d : { src: defaultIcon },
|
|
16
|
+
supports: { html: false, customClassName: false },
|
|
17
|
+
attributes: {
|
|
18
|
+
asideSize: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
default: asideSizes[1].value, // medium
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
edit: createContentWithAsideEdit(options),
|
|
24
|
+
save: () => _jsx(InnerBlocks.Content, {}),
|
|
25
|
+
};
|
|
26
|
+
}
|