@brilo/base-blocks 0.1.7 → 0.1.8

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.
Files changed (84) hide show
  1. package/build/blocks/groups/content-group/factory.d.ts +2 -2
  2. package/build/blocks/groups/content-group/factory.d.ts.map +1 -1
  3. package/build/blocks/groups/content-group/factory.js +8 -8
  4. package/build/blocks/groups/content-group/icon.d.ts.map +1 -1
  5. package/build/blocks/link/link-item/constants.d.ts +11 -0
  6. package/build/blocks/link/link-item/constants.d.ts.map +1 -0
  7. package/build/blocks/link/link-item/constants.js +6 -0
  8. package/build/blocks/link/link-item/edit.d.ts +6 -0
  9. package/build/blocks/link/link-item/edit.d.ts.map +1 -0
  10. package/build/blocks/link/link-item/edit.js +25 -0
  11. package/build/blocks/link/link-item/factory.d.ts +4 -0
  12. package/build/blocks/link/link-item/factory.d.ts.map +1 -0
  13. package/build/blocks/link/link-item/factory.js +27 -0
  14. package/build/blocks/link/link-item/icon.d.ts +2 -0
  15. package/build/blocks/link/link-item/icon.d.ts.map +1 -0
  16. package/build/blocks/link/link-item/icon.js +2 -0
  17. package/build/blocks/link/link-item/index.d.ts +5 -0
  18. package/build/blocks/link/link-item/index.d.ts.map +1 -0
  19. package/build/blocks/link/link-item/index.js +6 -0
  20. package/build/blocks/link/link-item/types.d.ts +25 -0
  21. package/build/blocks/link/link-item/types.d.ts.map +1 -0
  22. package/build/blocks/link/link-item/types.js +1 -0
  23. package/build/blocks/map/map-group/constants.d.ts +1 -0
  24. package/build/blocks/map/map-group/constants.d.ts.map +1 -1
  25. package/build/blocks/map/map-group/constants.js +2 -0
  26. package/build/blocks/map/map-group/edit.d.ts.map +1 -1
  27. package/build/blocks/map/map-group/edit.js +19 -11
  28. package/build/blocks/map/map-group/factory.d.ts +3 -1
  29. package/build/blocks/map/map-group/factory.d.ts.map +1 -1
  30. package/build/blocks/map/map-group/factory.js +24 -5
  31. package/build/blocks/map/map-group/index.d.ts.map +1 -1
  32. package/build/blocks/map/map-group/index.js +1 -0
  33. package/build/blocks/map/map-group/types.d.ts +18 -4
  34. package/build/blocks/map/map-group/types.d.ts.map +1 -1
  35. package/build/blocks/sections/base-section/attributes.d.ts +5 -1
  36. package/build/blocks/sections/base-section/attributes.d.ts.map +1 -1
  37. package/build/blocks/sections/base-section/attributes.js +5 -1
  38. package/build/blocks/sections/base-section/constants.d.ts +0 -16
  39. package/build/blocks/sections/base-section/constants.d.ts.map +1 -1
  40. package/build/blocks/sections/base-section/constants.js +0 -7
  41. package/build/blocks/sections/base-section/controls.d.ts.map +1 -1
  42. package/build/blocks/sections/base-section/controls.js +6 -3
  43. package/build/blocks/sections/base-section/edit.d.ts.map +1 -1
  44. package/build/blocks/sections/base-section/edit.js +8 -1
  45. package/build/blocks/sections/base-section/factory.d.ts.map +1 -1
  46. package/build/blocks/sections/base-section/factory.js +3 -8
  47. package/build/blocks/sections/base-section/index.d.ts +1 -1
  48. package/build/blocks/sections/base-section/index.d.ts.map +1 -1
  49. package/build/blocks/sections/base-section/index.js +1 -1
  50. package/build/blocks/sections/base-section/types.d.ts +1 -0
  51. package/build/blocks/sections/base-section/types.d.ts.map +1 -1
  52. package/build/hooks/useTenantColorPalette.d.ts +9 -0
  53. package/build/hooks/useTenantColorPalette.d.ts.map +1 -0
  54. package/build/hooks/useTenantColorPalette.js +12 -0
  55. package/build/index.d.ts +3 -1
  56. package/build/index.d.ts.map +1 -1
  57. package/build/index.js +2 -1
  58. package/package.json +2 -1
  59. package/src/blocks/groups/content-group/factory.tsx +11 -11
  60. package/src/blocks/groups/content-group/icon.tsx +1 -1
  61. package/src/blocks/link/link-item/constants.ts +7 -0
  62. package/src/blocks/link/link-item/edit.tsx +116 -0
  63. package/src/blocks/link/link-item/editor.scss +11 -0
  64. package/src/blocks/link/link-item/factory.tsx +29 -0
  65. package/src/blocks/link/link-item/icon.tsx +6 -0
  66. package/src/blocks/link/link-item/index.ts +10 -0
  67. package/src/blocks/link/link-item/types.ts +24 -0
  68. package/src/blocks/map/map-group/constants.ts +3 -0
  69. package/src/blocks/map/map-group/edit.tsx +74 -8
  70. package/src/blocks/map/map-group/editor.scss +7 -0
  71. package/src/blocks/map/map-group/factory.tsx +26 -4
  72. package/src/blocks/map/map-group/index.ts +1 -0
  73. package/src/blocks/map/map-group/types.ts +18 -4
  74. package/src/blocks/responsive-grid/responsive-grid-item/editor.scss +9 -0
  75. package/src/blocks/sections/base-section/attributes.ts +5 -1
  76. package/src/blocks/sections/base-section/constants.ts +0 -8
  77. package/src/blocks/sections/base-section/controls.tsx +18 -8
  78. package/src/blocks/sections/base-section/edit.tsx +8 -1
  79. package/src/blocks/sections/base-section/factory.tsx +3 -7
  80. package/src/blocks/sections/base-section/index.ts +1 -1
  81. package/src/blocks/sections/base-section/types.ts +1 -0
  82. package/src/editor.scss +2 -0
  83. package/src/hooks/useTenantColorPalette.ts +21 -0
  84. package/src/index.ts +2 -1
@@ -1,4 +1,4 @@
1
- import type { BlockConfiguration } from "@wordpress/blocks";
2
- import type { ContentGroupAttributes, ContentGroupOptions } from "./types";
1
+ import type { BlockConfiguration } from '@wordpress/blocks';
2
+ import type { ContentGroupAttributes, ContentGroupOptions } from './types';
3
3
  export declare function createContentGroupBlock(options: ContentGroupOptions): BlockConfiguration<ContentGroupAttributes>;
4
4
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/content-group/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAG1D,OAAO,KAAK,EAAC,sBAAsB,EAAE,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAGzE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAkBhH"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/content-group/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAGzD,OAAO,KAAK,EAAC,sBAAsB,EAAE,mBAAmB,EAAC,MAAM,SAAS,CAAA;AAGxE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAkBhH"}
@@ -1,22 +1,22 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { InnerBlocks } from "@wordpress/block-editor";
3
- import { __ } from "@wordpress/i18n";
4
- import { createContentGroupEdit } from "./edit";
5
- import { icon as defaultIcon } from "./icon";
2
+ import { InnerBlocks } from '@wordpress/block-editor';
3
+ import { __ } from '@wordpress/i18n';
4
+ import { createContentGroupEdit } from './edit';
5
+ import { icon as defaultIcon } from './icon';
6
6
  export function createContentGroupBlock(options) {
7
7
  var _a, _b, _c;
8
8
  return {
9
9
  name: options.name,
10
- title: (_a = options.title) !== null && _a !== void 0 ? _a : __("Obsahová skupina", "brilo-blocks"),
10
+ title: (_a = options.title) !== null && _a !== void 0 ? _a : __('Obsahová skupina', 'brilo-blocks'),
11
11
  description: options.description,
12
- category: (_b = options.category) !== null && _b !== void 0 ? _b : "layout",
12
+ category: (_b = options.category) !== null && _b !== void 0 ? _b : 'layout',
13
13
  icon: (_c = options.icon) !== null && _c !== void 0 ? _c : { src: defaultIcon },
14
14
  ...(options.parent && { parent: options.parent }),
15
15
  supports: { html: false, customClassName: false },
16
16
  attributes: {
17
17
  size: {
18
- type: "string",
19
- default: "8",
18
+ type: 'string',
19
+ default: '8',
20
20
  },
21
21
  },
22
22
  edit: createContentGroupEdit(options),
@@ -1 +1 @@
1
- {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/content-group/icon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,6BAsBhB,CAAC"}
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/content-group/icon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,6BAsBhB,CAAA"}
@@ -0,0 +1,11 @@
1
+ export declare const ICON_TYPES: readonly [{
2
+ readonly value: "none";
3
+ readonly label: import("@wordpress/i18n").TransformedText<"Žádná">;
4
+ }, {
5
+ readonly value: "preselected";
6
+ readonly label: import("@wordpress/i18n").TransformedText<"Předdefinovaná">;
7
+ }, {
8
+ readonly value: "media";
9
+ readonly label: import("@wordpress/i18n").TransformedText<"Médium">;
10
+ }];
11
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/link/link-item/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;EAIb,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ export const ICON_TYPES = [
3
+ { value: 'none', label: __('Žádná', 'brilo-blocks') },
4
+ { value: 'preselected', label: __('Předdefinovaná', 'brilo-blocks') },
5
+ { value: 'media', label: __('Médium', 'brilo-blocks') },
6
+ ];
@@ -0,0 +1,6 @@
1
+ import type { LinkItemAttributes, LinkItemOptions } from './types';
2
+ export declare function createLinkItemEdit(options: LinkItemOptions): ({ attributes, setAttributes, }: {
3
+ attributes: LinkItemAttributes;
4
+ setAttributes: (a: Partial<LinkItemAttributes>) => void;
5
+ }) => import("react").JSX.Element;
6
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/link/link-item/edit.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAEhE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,IACpC,gCAGlB;IACD,UAAU,EAAE,kBAAkB,CAAA;IAC9B,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAA;CACxD,iCA4FF"}
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { ColorPalette, InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor';
3
+ import { PanelBody, RangeControl, TextControl, ToggleControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, } from '@wordpress/components';
4
+ import { __ } from '@wordpress/i18n';
5
+ import clsx from 'clsx';
6
+ import { ItemIconControl, ItemIconPreview } from '../../../components/ItemIconControl';
7
+ import { useTenantColorPalette } from '../../../hooks/useTenantColorPalette';
8
+ import { ICON_TYPES } from './constants';
9
+ export function createLinkItemEdit(options) {
10
+ return function Edit({ attributes, setAttributes, }) {
11
+ var _a;
12
+ const { title, url, icon, color, underline_initial } = attributes;
13
+ const { paletteColors } = useTenantColorPalette();
14
+ const hasIcon = icon.type !== 'none' && (icon.src || ((_a = icon.media) === null || _a === void 0 ? void 0 : _a.id));
15
+ const setIconBase = (attrs) => {
16
+ setAttributes({ icon: { ...icon, ...attrs.icon } });
17
+ };
18
+ const blockProps = useBlockProps({
19
+ className: clsx('link-item', underline_initial && '--underline-initial'),
20
+ style: color ? { color } : undefined,
21
+ });
22
+ const iconPreviewStyle = { maxWidth: icon.size, flex: `0 0 ${icon.size}px` };
23
+ return (_jsxs(_Fragment, { children: [_jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Odkaz', 'brilo-blocks'), children: [_jsx(TextControl, { label: __('URL', 'brilo-blocks'), value: url.src, onChange: (v) => setAttributes({ url: { ...url, src: v } }) }), _jsx(ToggleControl, { label: __('Otevřít v nové záložce', 'brilo-blocks'), checked: url.blank, onChange: (v) => setAttributes({ url: { ...url, blank: v } }) })] }), _jsxs(PanelBody, { title: __('Ikona', 'brilo-blocks'), initialOpen: false, children: [_jsx(ItemIconControl, { icon: icon, setAttributes: setIconBase, iconTypes: ICON_TYPES, options: options }), hasIcon && (_jsxs(_Fragment, { children: [_jsxs(ToggleGroupControl, { isBlock: true, label: __('Pozice', 'brilo-blocks'), value: icon.position, onChange: (v) => setAttributes({ icon: { ...icon, position: String(v) } }), children: [_jsx(ToggleGroupControlOption, { value: "before", label: __('Před', 'brilo-blocks') }), _jsx(ToggleGroupControlOption, { value: "after", label: __('Za', 'brilo-blocks') })] }), _jsx(RangeControl, { label: __('Velikost (px)', 'brilo-blocks'), value: icon.size, onChange: (v) => setAttributes({ icon: { ...icon, size: v !== null && v !== void 0 ? v : 24 } }), min: 8, max: 80, step: 1 })] }))] }), _jsxs(PanelBody, { title: __('Styl', 'brilo-blocks'), initialOpen: false, children: [_jsx("p", { children: __('Barva', 'brilo-blocks') }), _jsx(ColorPalette, { colors: paletteColors, value: color || undefined, onChange: (v) => setAttributes({ color: v !== null && v !== void 0 ? v : '' }) }), _jsx(ToggleControl, { label: __('Podtržení výchozí', 'brilo-blocks'), checked: underline_initial, onChange: (v) => setAttributes({ underline_initial: v }) })] })] }), _jsxs("div", { ...blockProps, children: [hasIcon && icon.position === 'before' && (_jsx("span", { className: "link-item__icon", style: iconPreviewStyle, children: _jsx(ItemIconPreview, { icon: icon, setAttributes: setIconBase, options: options }) })), _jsx(RichText, { tagName: "span", className: "link-item__title", value: title, onChange: (v) => setAttributes({ title: v }), placeholder: __('Text odkazu...', 'brilo-blocks'), allowedFormats: ['core/bold', 'core/italic'] }), hasIcon && icon.position === 'after' && (_jsx("span", { className: "link-item__icon", style: iconPreviewStyle, children: _jsx(ItemIconPreview, { icon: icon, setAttributes: setIconBase, options: options }) }))] })] }));
24
+ };
25
+ }
@@ -0,0 +1,4 @@
1
+ import { type BlockConfiguration } from '@wordpress/blocks';
2
+ import type { LinkItemAttributes, LinkItemOptions } from './types';
3
+ export declare function createLinkItemBlock(options: LinkItemOptions): BlockConfiguration<LinkItemAttributes>;
4
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/link/link-item/factory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAIzD,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAEhE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAsBpG"}
@@ -0,0 +1,27 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { createLinkItemEdit } from './edit';
3
+ import { icon as defaultIcon } from './icon';
4
+ export function createLinkItemBlock(options) {
5
+ var _a, _b, _c;
6
+ return {
7
+ name: options.name,
8
+ title: (_a = options.title) !== null && _a !== void 0 ? _a : __('Odkaz', 'brilo-blocks'),
9
+ description: options.description,
10
+ category: (_b = options.category) !== null && _b !== void 0 ? _b : 'text',
11
+ ...(options.parent && { parent: options.parent }),
12
+ icon: (_c = options.icon) !== null && _c !== void 0 ? _c : { src: defaultIcon },
13
+ supports: { html: false, customClassName: false },
14
+ attributes: {
15
+ title: { type: 'string', default: '' },
16
+ url: { type: 'object', default: { src: '', blank: false } },
17
+ icon: {
18
+ type: 'object',
19
+ default: { type: 'none', src: '', media: {}, position: 'after', size: 24 },
20
+ },
21
+ color: { type: 'string', default: '' },
22
+ underline_initial: { type: 'boolean', default: false },
23
+ },
24
+ edit: createLinkItemEdit(options),
25
+ save: () => null,
26
+ };
27
+ }
@@ -0,0 +1,2 @@
1
+ export declare const icon: import("react").JSX.Element;
2
+ //# sourceMappingURL=icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../src/blocks/link/link-item/icon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,6BAKhB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const icon = (_jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M8 4H4C2.895 4 2 4.895 2 6v10c0 1.105.895 2 2 2h10c1.105 0 2-.895 2-2v-4", stroke: "black", strokeWidth: "1.5", fill: "none" }), _jsx("path", { d: "M12 2h6v6M18 2L10 10", stroke: "black", strokeWidth: "1.5", strokeLinecap: "round" })] }));
@@ -0,0 +1,5 @@
1
+ export type { LinkItemAttributes, LinkItemIcon, LinkItemOptions } from './types';
2
+ export { createLinkItemBlock } from './factory';
3
+ import type { LinkItemOptions } from './types';
4
+ export declare const linkItemDefaults: LinkItemOptions;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/link/link-item/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAC9E,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAA;AAE7C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,gBAAgB,EAAE,eAI9B,CAAA"}
@@ -0,0 +1,6 @@
1
+ export { createLinkItemBlock } from './factory';
2
+ export const linkItemDefaults = {
3
+ name: 'brilo/link-item',
4
+ icons: [],
5
+ iconsSrc: '',
6
+ };
@@ -0,0 +1,25 @@
1
+ import type { Media } from '../../../types';
2
+ import type { BriloBlockType } from '../../../types';
3
+ import type { IconType } from '../../../components/IconControl';
4
+ export interface LinkItemIcon {
5
+ type: 'preselected' | 'media' | 'none';
6
+ src: string;
7
+ media: Media;
8
+ position: 'before' | 'after';
9
+ size: number;
10
+ }
11
+ export interface LinkItemAttributes extends Record<string, unknown> {
12
+ title: string;
13
+ url: {
14
+ src: string;
15
+ blank: boolean;
16
+ };
17
+ icon: LinkItemIcon;
18
+ color: string;
19
+ underline_initial: boolean;
20
+ }
21
+ export interface LinkItemOptions extends BriloBlockType {
22
+ icons: IconType[];
23
+ iconsSrc: string;
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/link/link-item/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAA;AAEtD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,aAAa,GAAG,OAAO,GAAG,MAAM,CAAA;IACtC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,kBAAmB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAC,CAAA;IAClC,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,OAAO,CAAA;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ export declare const DEFAULT_HEADING_STYLES: readonly ["h1", "h2", "h3", "h4"];
1
2
  export declare const MAP_TYPES: readonly [{
2
3
  readonly value: "gps";
3
4
  readonly label: import("@wordpress/i18n").TransformedText<"GPS">;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;EAiBZ,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,mCAAiB,CAAA;AAEpD,eAAO,MAAM,SAAS;;;;;;;;;;;;EAiBZ,CAAA"}
@@ -1,4 +1,6 @@
1
1
  import { __ } from '@wordpress/i18n';
2
+ import { HEADING_STYLES } from "../../../constants";
3
+ export const DEFAULT_HEADING_STYLES = HEADING_STYLES;
2
4
  export const MAP_TYPES = [
3
5
  {
4
6
  value: 'gps',
@@ -1 +1 @@
1
- {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/edit.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAGhE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,IACpC,gCAGlB;IACD,UAAU,EAAE,kBAAkB,CAAA;IAC9B,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAA;CACxD,iCA4FF"}
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/edit.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAOhE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,IACpC,gCAGG;IACtB,UAAU,EAAE,kBAAkB,CAAA;IAC9B,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAA;CACxD,iCAsJF"}
@@ -1,21 +1,29 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
3
- import { PanelBody, BaseControl, TextControl, SelectControl, TextareaControl } from '@wordpress/components';
2
+ import { InspectorControls, RichText } from '@wordpress/block-editor';
3
+ import { PanelBody, BaseControl, TextControl, SelectControl, TextareaControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption } from '@wordpress/components';
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { ImagePickerControl } from '../../../components/ImagePicker';
6
6
  import { MAP_TYPES } from './constants';
7
7
  import { Icon, mapMarker } from '@wordpress/icons';
8
+ import { useGroupBlock } from "../../../hooks/useGroupBlock";
9
+ import clsx from "clsx";
10
+ import { HEADING_LEVELS, HEADING_STYLES } from "../../../constants";
8
11
  export function createMapGroupEdit(options) {
9
12
  return function Edit({ attributes, setAttributes, }) {
10
- var _a;
11
- const { mapType, iframeSrc, iframeElement, img, url, lat, long } = attributes;
12
- const blockProps = useBlockProps({
13
- className: (_a = options.blockClassName) !== null && _a !== void 0 ? _a : 'g-map wp-block-section',
13
+ var _a, _b;
14
+ const { mapType, iframeSrc, iframeElement, img, url, address, lat, long, description, header } = attributes;
15
+ const { blockProps, innerBlocksProps } = useGroupBlock({
16
+ blockClassName: clsx((_a = options.blockClassName) !== null && _a !== void 0 ? _a : 'g-map wp-block-section'),
17
+ containerClassName: [(_b = options.containerClassName) !== null && _b !== void 0 ? _b : 'g-map__button-wraper wp-block-inner-content'],
18
+ allowedBlocks: options.allowedBlocks,
19
+ orientation: 'vertical',
20
+ template: options.template,
21
+ layout: { type: 'default' },
14
22
  });
15
- return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsxs(PanelBody, { title: __('Nastavení mapy', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Typ mapy', 'brilo-blocks'), value: mapType, options: [...MAP_TYPES], onChange: (v) => setAttributes({ mapType: v }) }), mapType === 'gps' && (_jsxs(BaseControl, { label: __('GPS', 'brilo-blocks'), children: [_jsx(TextControl, { label: __('Zeměpisná šířka:', 'brilo-blocks'), value: lat || '', onChange: (value) => setAttributes({ lat: value }) }), _jsx(TextControl, { label: __('Zeměpisná délka:', 'brilo-blocks'), value: long || '', onChange: (value) => setAttributes({ long: value }) })] })), mapType === 'url' && (_jsx(BaseControl, { label: __('Iframe', 'brilo-blocks'), children: _jsx(TextControl, { label: __('URL:', 'brilo-blocks'), value: iframeSrc || '', onChange: (value) => setAttributes({ iframeSrc: value }) }) })), mapType === 'element' && (_jsx(BaseControl, { label: __('Iframe', 'brilo-blocks'), children: _jsx(TextareaControl, { label: __('Zdrojový kód:', 'brilo-blocks'), value: iframeElement || '', onChange: (value) => setAttributes({ iframeElement: value }) }) })), mapType === 'image' && (_jsxs(_Fragment, { children: [_jsx(ImagePickerControl, { value: img, onChange: (v) => setAttributes({ img: v }) }), _jsx(TextControl, { label: __('URL:', 'brilo-blocks'), value: url || '', onChange: (value) => setAttributes({ url: value }) })] }))] }) }), _jsx("div", { ...blockProps, children: _jsxs("div", { className: "g-map__map", children: [mapType === 'gps' && (lat || long) && (_jsxs("div", { children: [_jsx(Icon, { icon: mapMarker }), _jsx("p", { children: [lat, long].filter(Boolean).join(', ') })] })), mapType === 'url' && iframeSrc && _jsx("iframe", { src: iframeSrc, width: 640, height: 320 }), mapType === 'element' && iframeElement && _jsx("div", { dangerouslySetInnerHTML: { __html: iframeElement } }), mapType === 'image' && img && _jsx(ImagePickerControl, { value: img, onChange: (v) => setAttributes({ img: v }), size: [640, 320] }), (!mapType ||
16
- (mapType === 'gps' && !lat && !long) ||
17
- (mapType === 'url' && !iframeSrc) ||
18
- (mapType === 'element' && !iframeElement) ||
19
- (mapType === 'image' && !img)) && (_jsxs(_Fragment, { children: [_jsx(Icon, { icon: mapMarker }), __('Zde je prostor pro vaši mapu.', 'brilo-blocks')] }))] }) })] }));
23
+ return (_jsxs(_Fragment, { children: [_jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Nadpis', 'brilo-blocks'), initialOpen: false, children: [_jsx(ToggleGroupControl, { label: __('Úroveň nadpisu', 'brilo-blocks'), value: String(header.heading.level), onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, level: Number(value) } } }), isBlock: true, children: HEADING_LEVELS.map((l) => (_jsx(ToggleGroupControlOption, { value: String(l), label: `H${l}` }, l))) }), _jsx(ToggleGroupControl, { label: __('Styl nadpisu', 'brilo-blocks'), value: header.heading.style, onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, style: value } } }), isBlock: true, children: HEADING_STYLES.map((s) => (_jsx(ToggleGroupControlOption, { value: s, label: s }, s))) })] }), _jsxs(PanelBody, { title: __('Nastavení mapy', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Typ mapy', 'brilo-blocks'), value: mapType, options: [...MAP_TYPES], onChange: (v) => setAttributes({ mapType: v }) }), mapType === 'gps' && (_jsxs(BaseControl, { label: __('GPS', 'brilo-blocks'), children: [_jsx(TextControl, { label: __('Zeměpisná šířka:', 'brilo-blocks'), value: lat || '', onChange: (value) => setAttributes({ lat: value }) }), _jsx(TextControl, { label: __('Zeměpisná délka:', 'brilo-blocks'), value: long || '', onChange: (value) => setAttributes({ long: value }) })] })), mapType === 'url' && (_jsx(BaseControl, { label: __('Iframe', 'brilo-blocks'), children: _jsx(TextControl, { label: __('URL:', 'brilo-blocks'), value: iframeSrc || '', onChange: (value) => setAttributes({ iframeSrc: value }) }) })), mapType === 'element' && (_jsx(BaseControl, { label: __('Iframe', 'brilo-blocks'), children: _jsx(TextareaControl, { label: __('Zdrojový kód:', 'brilo-blocks'), value: iframeElement || '', onChange: (value) => setAttributes({ iframeElement: value }) }) })), mapType === 'image' && (_jsxs(_Fragment, { children: [_jsx(ImagePickerControl, { value: img, onChange: (v) => setAttributes({ img: v }) }), _jsx(TextControl, { label: __('URL:', 'brilo-blocks'), value: url || '', onChange: (value) => setAttributes({ url: value }) }), _jsx(TextControl, { label: __('Adresa:', 'brilo-blocks'), value: address || '', onChange: (value) => setAttributes({ address: value }) })] }))] })] }), _jsxs("div", { ...blockProps, children: [_jsxs("div", { className: "g-map__banner", children: [_jsxs("div", { className: "g-map__content", children: [_jsx(RichText, { tagName: `h${header.heading.level}`, className: clsx('g-map__heading', `--heading-style-${header.heading.style}`, 'u-text-editable'), value: header.heading.title, onChange: (value) => setAttributes({ header: { ...header, heading: { ...header.heading, title: value } } }), placeholder: __('Nadpis...', 'brilo-blocks'), allowedFormats: ['core/bold', 'core/italic'] }), _jsx(RichText, { tagName: "div", className: "g-map__description u-text-editable", value: description, onChange: (value) => setAttributes({ description: value }), placeholder: __('Popis...', 'brilo-blocks') })] }), _jsx("div", { ...innerBlocksProps })] }), _jsxs("div", { className: "g-map__map", children: [mapType === 'gps' && (lat || long) && (_jsxs("div", { children: [_jsx(Icon, { icon: mapMarker }), _jsx("p", { children: [lat, long].filter(Boolean).join(', ') })] })), mapType === 'url' && iframeSrc && _jsx("iframe", { src: iframeSrc, width: 640, height: 320 }), mapType === 'element' && iframeElement && _jsx("div", { dangerouslySetInnerHTML: { __html: iframeElement } }), mapType === 'image' && img && _jsx(ImagePickerControl, { value: img, onChange: (v) => setAttributes({ img: v }), size: [640, 320] }), (!mapType ||
24
+ (mapType === 'gps' && !lat && !long) ||
25
+ (mapType === 'url' && !iframeSrc) ||
26
+ (mapType === 'element' && !iframeElement) ||
27
+ (mapType === 'image' && !img)) && (_jsxs(_Fragment, { children: [_jsx(Icon, { icon: mapMarker }), __('Zde je prostor pro vaši mapu.', 'brilo-blocks')] }))] })] })] }));
20
28
  };
21
29
  }
@@ -1,5 +1,7 @@
1
1
  import type { BlockConfiguration } from '@wordpress/blocks';
2
2
  import type { MapGroupAttributes, MapGroupOptions } from './types';
3
+ import type { StringArray } from "../../../types";
4
+ import { DEFAULT_HEADING_STYLES } from "../../../blocks/groups/banner-group/constants";
3
5
  export type { MapGroupAttributes, MapGroupOptions };
4
- export declare function createMapGroupBlock(options: MapGroupOptions): BlockConfiguration<MapGroupAttributes>;
6
+ export declare function createMapGroupBlock<THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES>(options: MapGroupOptions<THeadingStyles>): BlockConfiguration<MapGroupAttributes<THeadingStyles[number]>>;
5
7
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAGzD,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAGhE,YAAY,EAAC,kBAAkB,EAAE,eAAe,EAAC,CAAA;AAEjD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CA0CpG"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAGzD,OAAO,KAAK,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAEhE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,EAAC,sBAAsB,EAAmB,MAAM,wCAAwC,CAAC;AAIhG,YAAY,EAAC,kBAAkB,EAAE,eAAe,EAAC,CAAA;AAEjD,wBAAgB,mBAAmB,CAAC,cAAc,SAAS,WAAW,GAAG,OAAO,sBAAsB,EACpG,OAAO,EAAE,eAAe,CAAC,cAAc,CAAC,GACvC,kBAAkB,CAAC,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CA0DhE"}
@@ -1,17 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { __ } from '@wordpress/i18n';
2
3
  import { createMapGroupEdit } from './edit';
3
4
  import { MAP_TYPES } from './constants';
5
+ import { DEFAULT_HEADING_STYLES } from "../../../blocks/groups/banner-group/constants";
6
+ import { InnerBlocks } from "@wordpress/block-editor";
7
+ import { HEADING_LEVELS } from "../../../constants";
4
8
  export function createMapGroupBlock(options) {
5
- var _a, _b, _c;
9
+ var _a, _b, _c, _d, _e;
10
+ const headingStyles = (_a = options.headingStyles) !== null && _a !== void 0 ? _a : DEFAULT_HEADING_STYLES;
6
11
  return {
7
12
  name: options.name,
8
- title: (_a = options.title) !== null && _a !== void 0 ? _a : __('Mapa', 'brilo-blocks'),
13
+ title: (_b = options.title) !== null && _b !== void 0 ? _b : __('Mapa', 'brilo-blocks'),
9
14
  description: options.description,
10
- category: (_b = options.category) !== null && _b !== void 0 ? _b : 'layout',
15
+ category: (_c = options.category) !== null && _c !== void 0 ? _c : 'layout',
11
16
  ...(options.parent && { parent: options.parent }),
12
- icon: (_c = options.icon) !== null && _c !== void 0 ? _c : 'location-alt',
17
+ icon: (_d = options.icon) !== null && _d !== void 0 ? _d : 'location-alt',
13
18
  supports: { html: false, customClassName: false },
14
19
  attributes: {
20
+ header: {
21
+ type: 'object',
22
+ default: {
23
+ heading: { title: '', level: HEADING_LEVELS[1], style: (_e = headingStyles[1]) !== null && _e !== void 0 ? _e : headingStyles[0] },
24
+ },
25
+ },
26
+ description: {
27
+ type: 'string',
28
+ default: '',
29
+ },
15
30
  mapType: {
16
31
  type: 'string',
17
32
  default: MAP_TYPES[0].value,
@@ -28,6 +43,10 @@ export function createMapGroupBlock(options) {
28
43
  type: 'object',
29
44
  default: { id: 0, url: '', alt: '' },
30
45
  },
46
+ address: {
47
+ type: 'string',
48
+ default: '',
49
+ },
31
50
  url: {
32
51
  type: 'string',
33
52
  default: '',
@@ -42,6 +61,6 @@ export function createMapGroupBlock(options) {
42
61
  },
43
62
  },
44
63
  edit: createMapGroupEdit(options),
45
- save: () => null,
64
+ save: () => _jsx(InnerBlocks.Content, {}),
46
65
  };
47
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAChE,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAA;AAE7C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,gBAAgB,EAAE,eAG9B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,kBAAkB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAA;AAChE,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAA;AAE7C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,gBAAgB,EAAE,eAI9B,CAAA"}
@@ -2,4 +2,5 @@ export { createMapGroupBlock } from './factory';
2
2
  export const mapGroupDefaults = {
3
3
  name: 'brilo/map-group',
4
4
  parent: ['brilo/base-section'],
5
+ allowedBlocks: ['brilo/button-group', 'brilo/basic-button']
5
6
  };
@@ -1,15 +1,29 @@
1
- import { BriloBlockType, Media } from '../../../types';
2
- import { MAP_TYPES } from './constants';
1
+ import { BriloBlockType, Media, type StringArray } from '../../../types';
2
+ import { DEFAULT_HEADING_STYLES, MAP_TYPES } from './constants';
3
+ import { HEADING_LEVELS } from "../../../constants";
3
4
  export type MapType = (typeof MAP_TYPES)[number]['value'];
4
- export interface MapGroupAttributes extends Record<string, unknown> {
5
+ export type HeadingLevels = (typeof HEADING_LEVELS)[number];
6
+ export type HeadingStyles = (typeof DEFAULT_HEADING_STYLES)[number];
7
+ export interface MapGroupAttributes<THeadingStyle extends string = HeadingStyles> extends Record<string, unknown> {
8
+ header: {
9
+ heading: {
10
+ title: string;
11
+ level: HeadingLevels;
12
+ style: THeadingStyle;
13
+ };
14
+ };
15
+ description: string;
5
16
  mapType: MapType;
6
17
  iframeSrc: string;
7
18
  iframeElement: string;
8
19
  img: Media;
20
+ address: string;
9
21
  url: string;
10
22
  lat: string;
11
23
  long: string;
12
24
  }
13
- export interface MapGroupOptions extends BriloBlockType {
25
+ export interface MapGroupOptions<THeadingStyles extends StringArray = typeof DEFAULT_HEADING_STYLES> extends BriloBlockType {
26
+ headingStyles?: THeadingStyles;
27
+ headingLevels?: HeadingLevels;
14
28
  }
15
29
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,KAAK,EAAC,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AAErC,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAEzD,MAAM,WAAW,kBAAmB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,KAAK,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc;CAAG"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/map/map-group/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,KAAK,EAAoB,KAAK,WAAW,EAAC,MAAM,SAAS,CAAA;AACjF,OAAO,EAAC,sBAAsB,EAAE,SAAS,EAAC,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAEzD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnE,MAAM,WAAW,kBAAkB,CAAC,aAAa,SAAS,MAAM,GAAG,aAAa,CAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/G,MAAM,EAAE;QACN,OAAO,EAAE;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,aAAa,CAAC;YAAC,KAAK,EAAE,aAAa,CAAA;SAAC,CAAA;KACrE,CAAA;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,KAAK,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,eAAe,CAC9B,cAAc,SAAS,WAAW,GAAG,OAAO,sBAAsB,CAClE,SAAQ,cAAc;IACtB,aAAa,CAAC,EAAE,cAAc,CAAA;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B"}
@@ -12,7 +12,11 @@ export declare const baseAttributes: {
12
12
  };
13
13
  readonly background: {
14
14
  readonly type: "string";
15
- readonly default: "none";
15
+ readonly default: "";
16
+ };
17
+ readonly textColor: {
18
+ readonly type: "string";
19
+ readonly default: "";
16
20
  };
17
21
  };
18
22
  //# sourceMappingURL=attributes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/attributes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;CAgBjB,CAAA"}
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/attributes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;CAoBjB,CAAA"}
@@ -12,6 +12,10 @@ export const baseAttributes = {
12
12
  },
13
13
  background: {
14
14
  type: 'string',
15
- default: 'none',
15
+ default: '',
16
+ },
17
+ textColor: {
18
+ type: 'string',
19
+ default: '',
16
20
  },
17
21
  };
@@ -12,20 +12,4 @@ export declare const SPACING_POSITIONS: readonly [{
12
12
  readonly label: import("@wordpress/i18n").TransformedText<"Pouze dole">;
13
13
  }];
14
14
  export declare const SPACING_SIZES: readonly ["default", "sm", "xs"];
15
- export declare const BACKGROUNDS: readonly [{
16
- readonly value: "none";
17
- readonly label: import("@wordpress/i18n").TransformedText<"Žádné">;
18
- }, {
19
- readonly value: "primary";
20
- readonly label: import("@wordpress/i18n").TransformedText<"Primární">;
21
- }, {
22
- readonly value: "secondary";
23
- readonly label: import("@wordpress/i18n").TransformedText<"Sekundární">;
24
- }, {
25
- readonly value: "conversion";
26
- readonly label: import("@wordpress/i18n").TransformedText<"Konverzní">;
27
- }, {
28
- readonly value: "neutral";
29
- readonly label: import("@wordpress/i18n").TransformedText<"Neutrální">;
30
- }];
31
15
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAKpB,CAAA;AAEV,eAAO,MAAM,aAAa,kCAAmC,CAAA;AAE7D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;EAMd,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAKpB,CAAA;AAEV,eAAO,MAAM,aAAa,kCAAmC,CAAA"}
@@ -6,10 +6,3 @@ export const SPACING_POSITIONS = [
6
6
  { value: 'top-0', label: __('Pouze dole', 'brilo-blocks') },
7
7
  ];
8
8
  export const SPACING_SIZES = ['default', 'sm', 'xs'];
9
- export const BACKGROUNDS = [
10
- { value: 'none', label: __('Žádné', 'brilo-blocks') },
11
- { value: 'primary', label: __('Primární', 'brilo-blocks') },
12
- { value: 'secondary', label: __('Sekundární', 'brilo-blocks') },
13
- { value: 'conversion', label: __('Konverzní', 'brilo-blocks') },
14
- { value: 'neutral', label: __('Neutrální', 'brilo-blocks') },
15
- ];
@@ -1 +1 @@
1
- {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/controls.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAMpE,UAAU,iBAAiB;IACzB,UAAU,EAAE,mBAAmB,CAAA;IAC/B,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;IAC5D,OAAO,EAAE,kBAAkB,EAAE,CAAA;CAC9B;AAED,wBAAgB,YAAY,CAAC,EAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAC,EAAE,iBAAiB,+BAiDnF"}
1
+ {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/controls.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAMpE,UAAU,iBAAiB;IACzB,UAAU,EAAE,mBAAmB,CAAA;IAC/B,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;IAC5D,OAAO,EAAE,kBAAkB,EAAE,CAAA;CAC9B;AAED,wBAAgB,YAAY,CAAC,EAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAC,EAAE,iBAAiB,+BAyDnF"}
@@ -1,8 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { ColorPalette, ContrastChecker } from '@wordpress/block-editor';
2
3
  import { PanelBody, SelectControl, TextControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, } from '@wordpress/components';
3
4
  import { __ } from '@wordpress/i18n';
4
- import { BACKGROUNDS, SPACING_POSITIONS, SPACING_SIZES } from './constants';
5
+ import { useTenantColorPalette } from '../../../hooks/useTenantColorPalette';
6
+ import { SPACING_POSITIONS, SPACING_SIZES } from './constants';
5
7
  export function BaseControls({ attributes, setAttributes, exclude }) {
6
- const { id, spacing, background } = attributes;
7
- return (_jsxs(_Fragment, { children: [!exclude.includes('spacing') && (_jsxs(PanelBody, { title: __('Rozestupy', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Pozice', 'brilo-blocks'), value: spacing.position, options: [...SPACING_POSITIONS], onChange: (value) => setAttributes({ spacing: { ...spacing, position: value } }) }), _jsx(ToggleGroupControl, { label: __('Velikost', 'brilo-blocks'), value: spacing.size, onChange: (value) => setAttributes({ spacing: { ...spacing, size: value } }), isBlock: true, children: SPACING_SIZES.map((s) => (_jsx(ToggleGroupControlOption, { value: s, label: s === 'default' ? __('Výchozí', 'brilo-blocks') : s.toUpperCase() }, s))) })] })), !exclude.includes('background') && (_jsx(PanelBody, { title: __('Pozadí', 'brilo-blocks'), children: _jsx(SelectControl, { label: __('Pozadí', 'brilo-blocks'), value: background, options: [...BACKGROUNDS], onChange: (value) => setAttributes({ background: value }) }) })), !exclude.includes('id') && (_jsx(PanelBody, { title: __('Kotva', 'brilo-blocks'), initialOpen: false, children: _jsx(TextControl, { label: __('ID sekce', 'brilo-blocks'), value: id !== null && id !== void 0 ? id : '', onChange: (value) => setAttributes({ id: value }), help: __('Použije se jako HTML atribut id pro kotevní odkaz.', 'brilo-blocks') }) }))] }));
8
+ const { id, spacing, background, textColor } = attributes;
9
+ const { paletteColors, resolveHex } = useTenantColorPalette();
10
+ return (_jsxs(_Fragment, { children: [!exclude.includes('spacing') && (_jsxs(PanelBody, { title: __('Rozestupy', 'brilo-blocks'), children: [_jsx(SelectControl, { label: __('Pozice', 'brilo-blocks'), value: spacing.position, options: [...SPACING_POSITIONS], onChange: (value) => setAttributes({ spacing: { ...spacing, position: value } }) }), _jsx(ToggleGroupControl, { label: __('Velikost', 'brilo-blocks'), value: spacing.size, onChange: (value) => setAttributes({ spacing: { ...spacing, size: value } }), isBlock: true, children: SPACING_SIZES.map((s) => (_jsx(ToggleGroupControlOption, { value: s, label: s === 'default' ? __('Výchozí', 'brilo-blocks') : s.toUpperCase() }, s))) })] })), !exclude.includes('background') && (_jsxs(PanelBody, { title: __('Barvy', 'brilo-blocks'), children: [_jsx("p", { children: __('Pozadí', 'brilo-blocks') }), _jsx(ColorPalette, { colors: paletteColors, value: background || undefined, onChange: (value) => setAttributes({ background: value !== null && value !== void 0 ? value : '' }) }), _jsx("p", { children: __('Barva textu', 'brilo-blocks') }), _jsx(ColorPalette, { colors: paletteColors, value: textColor || undefined, onChange: (value) => setAttributes({ textColor: value !== null && value !== void 0 ? value : '' }) }), !!background && !!textColor && _jsx(ContrastChecker, { backgroundColor: resolveHex(background), textColor: resolveHex(textColor) })] })), !exclude.includes('id') && (_jsx(PanelBody, { title: __('Kotva', 'brilo-blocks'), initialOpen: false, children: _jsx(TextControl, { label: __('ID sekce', 'brilo-blocks'), value: id !== null && id !== void 0 ? id : '', onChange: (value) => setAttributes({ id: value }), help: __('Použije se jako HTML atribut id pro kotevní odkaz.', 'brilo-blocks') }) }))] }));
8
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/edit.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAGpE,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,IAGlH,OAAO,cAAc,CAAC,mBAAmB,GAAG,MAAM,CAAC,iCAyBzE"}
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/edit.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAGpE,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,IAGlH,OAAO,cAAc,CAAC,mBAAmB,GAAG,MAAM,CAAC,iCAgCzE"}
@@ -7,7 +7,14 @@ export function createBaseSectionEdit(options) {
7
7
  return function Edit(props) {
8
8
  var _a;
9
9
  const { attributes, setAttributes } = props;
10
- const blockProps = useBlockProps({ className: options.blockClassName });
10
+ const { background, textColor } = attributes;
11
+ const blockProps = useBlockProps({
12
+ className: options.blockClassName,
13
+ style: {
14
+ ...(background ? { backgroundColor: background, padding: '16px' } : {}),
15
+ ...(textColor ? { color: textColor } : {}),
16
+ },
17
+ });
11
18
  const innerBlocksProps = useInnerBlocksProps({ className: options.containerClassName }, {
12
19
  allowedBlocks: options.allowedBlocks,
13
20
  orientation: 'vertical',
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAMzD,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAExF,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,CAAA;AAEzE,wBAAgB,sBAAsB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACnG,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAClC,kBAAkB,CAAC,mBAAmB,GAAG,MAAM,CAAC,CAiClD"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/sections/base-section/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAKzD,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAExF,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,CAAA;AAEzE,wBAAgB,sBAAsB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACnG,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAClC,kBAAkB,CAAC,mBAAmB,GAAG,MAAM,CAAC,CA8BlD"}
@@ -2,7 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { InnerBlocks } from '@wordpress/block-editor';
3
3
  import { __ } from '@wordpress/i18n';
4
4
  import { baseAttributes } from './attributes';
5
- import { BACKGROUNDS } from './constants';
6
5
  import { createBaseSectionEdit } from './edit';
7
6
  import { icon as defaultIcon } from './icon';
8
7
  export function createBaseSectionBlock(options) {
@@ -10,13 +9,9 @@ export function createBaseSectionBlock(options) {
10
9
  const exclude = (_a = options.exclude) !== null && _a !== void 0 ? _a : [];
11
10
  const attributes = {};
12
11
  for (const [key, value] of Object.entries(baseAttributes)) {
13
- if (!exclude.includes(key)) {
14
- if (key === 'background') {
15
- attributes[key] = { ...value, enum: BACKGROUNDS.map((b) => b.value) };
16
- }
17
- else {
18
- attributes[key] = value;
19
- }
12
+ const excludeKey = key === 'textColor' ? 'background' : key;
13
+ if (!exclude.includes(excludeKey)) {
14
+ attributes[key] = value;
20
15
  }
21
16
  }
22
17
  if (options.extraAttributes) {
@@ -1,6 +1,6 @@
1
1
  export type { BaseBlockAttributes, BaseSectionOptions, ExcludableBaseAttr } from './types';
2
2
  export { baseAttributes } from './attributes';
3
- export { BACKGROUNDS, SPACING_POSITIONS, SPACING_SIZES } from './constants';
3
+ export { SPACING_POSITIONS, SPACING_SIZES } from './constants';
4
4
  export { createBaseSectionEdit } from './edit';
5
5
  export { createBaseSectionBlock } from './factory';
6
6
  import type { BaseSectionOptions } from './types';