@brilo/base-blocks 0.1.57 → 0.1.60

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 (149) hide show
  1. package/build/.tsbuildinfo +1 -1
  2. package/build/blocks/column/column-item/factory.d.ts.map +1 -1
  3. package/build/blocks/column/column-item/factory.js +2 -1
  4. package/build/blocks/column/column-item/icon.d.ts +2 -0
  5. package/build/blocks/column/column-item/icon.d.ts.map +1 -0
  6. package/build/blocks/column/column-item/icon.js +2 -0
  7. package/build/blocks/column/column-item/index.d.ts.map +1 -1
  8. package/build/blocks/column/column-item/index.js +2 -0
  9. package/build/blocks/food-menu/food-menu-group/FoodMenuPreview.d.ts +6 -0
  10. package/build/blocks/food-menu/food-menu-group/FoodMenuPreview.d.ts.map +1 -0
  11. package/build/blocks/food-menu/food-menu-group/FoodMenuPreview.js +167 -0
  12. package/build/blocks/food-menu/food-menu-group/FoodMenuSelectModal.d.ts +7 -0
  13. package/build/blocks/food-menu/food-menu-group/FoodMenuSelectModal.d.ts.map +1 -0
  14. package/build/blocks/food-menu/food-menu-group/FoodMenuSelectModal.js +56 -0
  15. package/build/blocks/food-menu/food-menu-group/constants.d.ts +8 -0
  16. package/build/blocks/food-menu/food-menu-group/constants.d.ts.map +1 -0
  17. package/build/blocks/food-menu/food-menu-group/constants.js +7 -0
  18. package/build/blocks/food-menu/food-menu-group/edit.d.ts +7 -0
  19. package/build/blocks/food-menu/food-menu-group/edit.d.ts.map +1 -0
  20. package/build/blocks/food-menu/food-menu-group/edit.js +36 -0
  21. package/build/blocks/food-menu/food-menu-group/factory.d.ts +4 -0
  22. package/build/blocks/food-menu/food-menu-group/factory.d.ts.map +1 -0
  23. package/build/blocks/food-menu/food-menu-group/factory.js +57 -0
  24. package/build/blocks/food-menu/food-menu-group/icon.d.ts +2 -0
  25. package/build/blocks/food-menu/food-menu-group/icon.d.ts.map +1 -0
  26. package/build/blocks/food-menu/food-menu-group/icon.js +2 -0
  27. package/build/blocks/food-menu/food-menu-group/index.d.ts +6 -0
  28. package/build/blocks/food-menu/food-menu-group/index.d.ts.map +1 -0
  29. package/build/blocks/food-menu/food-menu-group/index.js +7 -0
  30. package/build/blocks/food-menu/food-menu-group/types.d.ts +19 -0
  31. package/build/blocks/food-menu/food-menu-group/types.d.ts.map +1 -0
  32. package/build/blocks/food-menu/food-menu-group/types.js +1 -0
  33. package/build/blocks/form/form-group/index.js +1 -1
  34. package/build/blocks/gallery/gallery-group/constants.d.ts +1 -19
  35. package/build/blocks/gallery/gallery-group/constants.d.ts.map +1 -1
  36. package/build/blocks/gallery/gallery-group/constants.js +1 -8
  37. package/build/blocks/gallery/gallery-group/edit.d.ts.map +1 -1
  38. package/build/blocks/gallery/gallery-group/edit.js +3 -19
  39. package/build/blocks/gallery/gallery-group/index.js +1 -1
  40. package/build/blocks/gallery/gallery-item/index.js +1 -1
  41. package/build/blocks/gallery/gallery-strip-group/constants.d.ts +34 -0
  42. package/build/blocks/gallery/gallery-strip-group/constants.d.ts.map +1 -0
  43. package/build/blocks/gallery/gallery-strip-group/constants.js +17 -0
  44. package/build/blocks/gallery/gallery-strip-group/edit.d.ts +7 -0
  45. package/build/blocks/gallery/gallery-strip-group/edit.d.ts.map +1 -0
  46. package/build/blocks/gallery/gallery-strip-group/edit.js +34 -0
  47. package/build/blocks/gallery/gallery-strip-group/factory.d.ts +5 -0
  48. package/build/blocks/gallery/gallery-strip-group/factory.d.ts.map +1 -0
  49. package/build/blocks/gallery/gallery-strip-group/factory.js +28 -0
  50. package/build/blocks/gallery/gallery-strip-group/index.d.ts +5 -0
  51. package/build/blocks/gallery/gallery-strip-group/index.d.ts.map +1 -0
  52. package/build/blocks/gallery/gallery-strip-group/index.js +7 -0
  53. package/build/blocks/gallery/gallery-strip-group/types.d.ts +18 -0
  54. package/build/blocks/gallery/gallery-strip-group/types.d.ts.map +1 -0
  55. package/build/blocks/gallery/gallery-strip-group/types.js +1 -0
  56. package/build/blocks/groups/text-and-media-group/index.d.ts.map +1 -1
  57. package/build/blocks/groups/text-and-media-group/index.js +2 -0
  58. package/build/blocks/hero/hero-item/index.js +1 -1
  59. package/build/blocks/review/review-summary-item/constants.d.ts +3 -0
  60. package/build/blocks/review/review-summary-item/constants.d.ts.map +1 -0
  61. package/build/blocks/review/review-summary-item/constants.js +2 -0
  62. package/build/blocks/review/review-summary-item/edit.d.ts +6 -0
  63. package/build/blocks/review/review-summary-item/edit.d.ts.map +1 -0
  64. package/build/blocks/review/review-summary-item/edit.js +17 -0
  65. package/build/blocks/review/review-summary-item/factory.d.ts +5 -0
  66. package/build/blocks/review/review-summary-item/factory.d.ts.map +1 -0
  67. package/build/blocks/review/review-summary-item/factory.js +23 -0
  68. package/build/blocks/review/review-summary-item/index.d.ts +5 -0
  69. package/build/blocks/review/review-summary-item/index.d.ts.map +1 -0
  70. package/build/blocks/review/review-summary-item/index.js +5 -0
  71. package/build/blocks/review/review-summary-item/types.d.ts +11 -0
  72. package/build/blocks/review/review-summary-item/types.d.ts.map +1 -0
  73. package/build/blocks/review/review-summary-item/types.js +1 -0
  74. package/build/blocks/urgency/urgency-item/constants.d.ts +56 -0
  75. package/build/blocks/urgency/urgency-item/constants.d.ts.map +1 -0
  76. package/build/blocks/urgency/urgency-item/constants.js +32 -0
  77. package/build/blocks/urgency/urgency-item/edit.d.ts +7 -0
  78. package/build/blocks/urgency/urgency-item/edit.d.ts.map +1 -0
  79. package/build/blocks/urgency/urgency-item/edit.js +83 -0
  80. package/build/blocks/urgency/urgency-item/factory.d.ts +5 -0
  81. package/build/blocks/urgency/urgency-item/factory.d.ts.map +1 -0
  82. package/build/blocks/urgency/urgency-item/factory.js +31 -0
  83. package/build/blocks/urgency/urgency-item/index.d.ts +5 -0
  84. package/build/blocks/urgency/urgency-item/index.d.ts.map +1 -0
  85. package/build/blocks/urgency/urgency-item/index.js +5 -0
  86. package/build/blocks/urgency/urgency-item/types.d.ts +22 -0
  87. package/build/blocks/urgency/urgency-item/types.d.ts.map +1 -0
  88. package/build/blocks/urgency/urgency-item/types.js +1 -0
  89. package/build/components/EntitySelectModal/EntitySelectModal.d.ts +6 -0
  90. package/build/components/EntitySelectModal/EntitySelectModal.d.ts.map +1 -1
  91. package/build/components/EntitySelectModal/EntitySelectModal.js +3 -2
  92. package/build/components/GalleryImagesAppender/index.d.ts +5 -0
  93. package/build/components/GalleryImagesAppender/index.d.ts.map +1 -0
  94. package/build/components/GalleryImagesAppender/index.js +12 -0
  95. package/build/constants.d.ts +19 -0
  96. package/build/constants.d.ts.map +1 -1
  97. package/build/constants.js +8 -0
  98. package/build/index.d.ts +8 -0
  99. package/build/index.d.ts.map +1 -1
  100. package/build/index.js +4 -0
  101. package/build/utils/plural.d.ts +3 -0
  102. package/build/utils/plural.d.ts.map +1 -0
  103. package/build/utils/plural.js +7 -0
  104. package/package.json +1 -1
  105. package/src/blocks/column/column-item/factory.tsx +2 -1
  106. package/src/blocks/column/column-item/icon.tsx +10 -0
  107. package/src/blocks/column/column-item/index.ts +2 -0
  108. package/src/blocks/food-menu/food-menu-group/FoodMenuPreview.tsx +380 -0
  109. package/src/blocks/food-menu/food-menu-group/FoodMenuSelectModal.tsx +69 -0
  110. package/src/blocks/food-menu/food-menu-group/constants.ts +9 -0
  111. package/src/blocks/food-menu/food-menu-group/edit.tsx +153 -0
  112. package/src/blocks/food-menu/food-menu-group/editor.scss +269 -0
  113. package/src/blocks/food-menu/food-menu-group/factory.tsx +66 -0
  114. package/src/blocks/food-menu/food-menu-group/icon.tsx +8 -0
  115. package/src/blocks/food-menu/food-menu-group/index.ts +17 -0
  116. package/src/blocks/food-menu/food-menu-group/types.ts +21 -0
  117. package/src/blocks/form/form-group/index.ts +1 -1
  118. package/src/blocks/gallery/gallery-group/constants.ts +1 -8
  119. package/src/blocks/gallery/gallery-group/edit.tsx +3 -39
  120. package/src/blocks/gallery/gallery-group/editor.scss +0 -12
  121. package/src/blocks/gallery/gallery-group/index.ts +1 -1
  122. package/src/blocks/gallery/gallery-item/index.ts +1 -1
  123. package/src/blocks/gallery/gallery-strip-group/constants.ts +22 -0
  124. package/src/blocks/gallery/gallery-strip-group/edit.tsx +112 -0
  125. package/src/blocks/gallery/gallery-strip-group/editor.scss +36 -0
  126. package/src/blocks/gallery/gallery-strip-group/factory.tsx +32 -0
  127. package/src/blocks/gallery/gallery-strip-group/index.ts +11 -0
  128. package/src/blocks/gallery/gallery-strip-group/types.ts +20 -0
  129. package/src/blocks/groups/text-and-media-group/index.ts +2 -0
  130. package/src/blocks/hero/hero-item/index.ts +1 -1
  131. package/src/blocks/review/review-summary-item/constants.ts +2 -0
  132. package/src/blocks/review/review-summary-item/edit.tsx +86 -0
  133. package/src/blocks/review/review-summary-item/editor.scss +44 -0
  134. package/src/blocks/review/review-summary-item/factory.tsx +27 -0
  135. package/src/blocks/review/review-summary-item/index.ts +9 -0
  136. package/src/blocks/review/review-summary-item/types.ts +11 -0
  137. package/src/blocks/urgency/urgency-item/constants.ts +39 -0
  138. package/src/blocks/urgency/urgency-item/edit.tsx +319 -0
  139. package/src/blocks/urgency/urgency-item/editor.scss +99 -0
  140. package/src/blocks/urgency/urgency-item/factory.tsx +36 -0
  141. package/src/blocks/urgency/urgency-item/index.ts +9 -0
  142. package/src/blocks/urgency/urgency-item/types.ts +23 -0
  143. package/src/components/EntitySelectModal/EntitySelectModal.tsx +19 -7
  144. package/src/components/GalleryImagesAppender/editor.scss +15 -0
  145. package/src/components/GalleryImagesAppender/index.tsx +29 -0
  146. package/src/constants.ts +9 -0
  147. package/src/editor.scss +5 -0
  148. package/src/index.ts +13 -0
  149. package/src/utils/plural.ts +13 -0
@@ -1,7 +1,7 @@
1
1
  export { createGalleryGroupBlock } from './factory';
2
2
  export const galleryGroupDefaults = {
3
3
  name: 'brilo/gallery-group',
4
- parent: ['brilo/base-section'],
4
+ parent: ['brilo/base-section', 'brilo/column-item'],
5
5
  allowedBlocks: ['brilo/gallery-item'],
6
6
  template: [],
7
7
  };
@@ -1,6 +1,6 @@
1
1
  export { createGalleryItemBlock } from './factory';
2
2
  export const galleryItemDefaults = {
3
3
  name: 'brilo/gallery-item',
4
- parent: ['brilo/gallery-group'],
4
+ parent: ['brilo/gallery-group', 'brilo/gallery-strip-group'],
5
5
  template: [],
6
6
  };
@@ -0,0 +1,34 @@
1
+ export declare const HEIGHTS: 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
+ export declare const SPEEDS: readonly [{
12
+ readonly value: 'slow';
13
+ readonly label: import("@wordpress/i18n").TransformedText<"Pomalu">;
14
+ }, {
15
+ readonly value: 'medium';
16
+ readonly label: import("@wordpress/i18n").TransformedText<"Středně">;
17
+ }, {
18
+ readonly value: 'fast';
19
+ readonly label: import("@wordpress/i18n").TransformedText<"Rychle">;
20
+ }];
21
+ export declare const DIRECTIONS: readonly [{
22
+ readonly value: 'left';
23
+ readonly label: import("@wordpress/i18n").TransformedText<"Doleva">;
24
+ }, {
25
+ readonly value: 'right';
26
+ readonly label: import("@wordpress/i18n").TransformedText<"Doprava">;
27
+ }];
28
+ export { GALLERY_RATIOS as DEFAULT_RATIOS } from '../../../constants';
29
+ export declare const HEIGHT_PIXELS: {
30
+ readonly sm: 160;
31
+ readonly md: 240;
32
+ readonly lg: 320;
33
+ };
34
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;aACjB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;;aAClB,KAAK,EAAE,IAAI;aAAE,KAAK;EACX,CAAA;AAEV,eAAO,MAAM,MAAM;aAChB,KAAK,EAAE,MAAM;aAAE,KAAK;;aACpB,KAAK,EAAE,QAAQ;aAAE,KAAK;;aACtB,KAAK,EAAE,MAAM;aAAE,KAAK;EACb,CAAA;AAEV,eAAO,MAAM,UAAU;aACpB,KAAK,EAAE,MAAM;aAAE,KAAK;;aACpB,KAAK,EAAE,OAAO;aAAE,KAAK;EACd,CAAA;AAEV,OAAO,EAAC,cAAc,IAAI,cAAc,EAAC,MAAM,aAAa,CAAA;AAE5D,eAAO,MAAM,aAAa;aAAI,EAAE,EAAE,GAAG;aAAE,EAAE,EAAE,GAAG;aAAE,EAAE,EAAE,GAAG;CAAU,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ export const HEIGHTS = [
3
+ { value: 'sm', label: __('Malá', 'brilo-blocks') },
4
+ { value: 'md', label: __('Střední', 'brilo-blocks') },
5
+ { value: 'lg', label: __('Velká', 'brilo-blocks') },
6
+ ];
7
+ export const SPEEDS = [
8
+ { value: 'slow', label: __('Pomalu', 'brilo-blocks') },
9
+ { value: 'medium', label: __('Středně', 'brilo-blocks') },
10
+ { value: 'fast', label: __('Rychle', 'brilo-blocks') },
11
+ ];
12
+ export const DIRECTIONS = [
13
+ { value: 'left', label: __('Doleva', 'brilo-blocks') },
14
+ { value: 'right', label: __('Doprava', 'brilo-blocks') },
15
+ ];
16
+ export { GALLERY_RATIOS as DEFAULT_RATIOS } from '../../../constants';
17
+ export const HEIGHT_PIXELS = { sm: 160, md: 240, lg: 320 };
@@ -0,0 +1,7 @@
1
+ import type { GalleryStripGroupAttributes, GalleryStripGroupOptions } from './types';
2
+ export declare function createGalleryStripGroupEdit(options: GalleryStripGroupOptions): ({ attributes, setAttributes, clientId, }: {
3
+ attributes: GalleryStripGroupAttributes;
4
+ setAttributes: (a: Partial<GalleryStripGroupAttributes>) => void;
5
+ clientId: string;
6
+ }) => import("react").JSX.Element;
7
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/edit.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAEV,2BAA2B,EAC3B,wBAAwB,EAIzB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,wBAAwB,8CAOxE;IACD,UAAU,EAAE,2BAA2B,CAAA;IACvC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,KAAK,IAAI,CAAA;IAChE,QAAQ,EAAE,MAAM,CAAA;CACjB,iCA+EF"}
@@ -0,0 +1,34 @@
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 clsx from 'clsx';
6
+ import { GalleryImagesAppender } from '../../../components/GalleryImagesAppender';
7
+ import { ItemSpacingPanel, itemSpacingStyle } from '../../../components/ItemSpacingControl';
8
+ import { useGroupBlock } from '../../../hooks/useGroupBlock';
9
+ import { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, HEIGHT_PIXELS, SPEEDS } from './constants';
10
+ export function createGalleryStripGroupEdit(options) {
11
+ var _a;
12
+ const RATIOS = (_a = options.ratios) !== null && _a !== void 0 ? _a : DEFAULT_RATIOS;
13
+ return function Edit({ attributes, setAttributes, clientId, }) {
14
+ var _a, _b, _c;
15
+ const { height, ratio, speed, direction, spacing } = attributes;
16
+ const heightPx = (_a = HEIGHT_PIXELS[height]) !== null && _a !== void 0 ? _a : HEIGHT_PIXELS.md;
17
+ const [ratioWidth, ratioHeight] = ratio.split(':').map(Number);
18
+ const { blockProps, innerBlocksProps } = useGroupBlock({
19
+ blockClassName: clsx((_b = options.blockClassName) !== null && _b !== void 0 ? _b : 'g-gallery g-gallery-strip wp-block-section', `--speed-${speed}`, `--direction-${direction}`),
20
+ containerClassName: (_c = options.containerClassName) !== null && _c !== void 0 ? _c : 'g-gallery-strip__track',
21
+ containerStyle: {
22
+ '--gallery-strip-height': `${heightPx}px`,
23
+ '--gallery-strip-item-width': `${Math.round((heightPx * ratioWidth) / ratioHeight)}px`,
24
+ ...itemSpacingStyle(spacing),
25
+ },
26
+ allowedBlocks: options.allowedBlocks,
27
+ orientation: 'horizontal',
28
+ renderAppender: () => _jsx(GalleryImagesAppender, { clientId: clientId, itemBlock: options.allowedBlocks[0] }),
29
+ template: options.template,
30
+ layout: { type: 'default' },
31
+ });
32
+ return (_jsxs(_Fragment, { children: [_jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Rozložení', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { isBlock: true, label: __('Výška', 'brilo-blocks'), value: height, onChange: (v) => setAttributes({ height: v }), children: HEIGHTS.map((h) => (_jsx(ToggleGroupControlOption, { value: h.value, label: h.label }, h.value))) }), _jsx(ToggleGroupControl, { isBlock: true, label: __('Poměr stran', 'brilo-blocks'), value: ratio, onChange: (v) => setAttributes({ ratio: v }), children: RATIOS.map((r) => (_jsx(ToggleGroupControlOption, { value: r.value, label: r.label }, r.value))) })] }), _jsxs(PanelBody, { title: __('Animace', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { isBlock: true, label: __('Rychlost', 'brilo-blocks'), value: speed, onChange: (v) => setAttributes({ speed: v }), children: SPEEDS.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) }), _jsx(ToggleGroupControl, { isBlock: true, label: __('Směr', 'brilo-blocks'), value: direction, onChange: (v) => setAttributes({ direction: v }), children: DIRECTIONS.map((d) => (_jsx(ToggleGroupControlOption, { value: d.value, label: d.label }, d.value))) })] }), _jsx(ItemSpacingPanel, { spacing: spacing, onChange: (v) => setAttributes({ spacing: v }) })] }), _jsx("div", { ...blockProps, children: _jsx("div", { ...innerBlocksProps }) })] }));
33
+ };
34
+ }
@@ -0,0 +1,5 @@
1
+ import type { BlockConfiguration } from '@wordpress/blocks';
2
+ import type { GalleryStripGroupAttributes, GalleryStripGroupOptions } from './types';
3
+ export type { GalleryStripGroupAttributes, GalleryStripGroupOptions };
4
+ export declare function createGalleryStripGroupBlock(options: GalleryStripGroupOptions): BlockConfiguration<GalleryStripGroupAttributes>;
5
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/factory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAKzD,OAAO,KAAK,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAElF,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,CAAA;AAEnE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,wBAAwB,GAAG,kBAAkB,CAAC,2BAA2B,CAAC,CAqB/H"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { InnerBlocks } from '@wordpress/block-editor';
3
+ import { __ } from '@wordpress/i18n';
4
+ import { ITEM_SPACING_ATTRIBUTE } from '../../../components/ItemSpacingControl';
5
+ import { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, SPEEDS } from './constants';
6
+ import { createGalleryStripGroupEdit } from './edit';
7
+ export function createGalleryStripGroupBlock(options) {
8
+ var _a, _b, _c, _d, _e;
9
+ const ratios = (_a = options.ratios) !== null && _a !== void 0 ? _a : DEFAULT_RATIOS;
10
+ return {
11
+ name: options.name,
12
+ title: (_b = options.title) !== null && _b !== void 0 ? _b : __('Pás obrázků', 'brilo-blocks'),
13
+ description: (_c = options.description) !== null && _c !== void 0 ? _c : __('Nekonečně se posouvající pás obrázků', 'brilo-blocks'),
14
+ category: (_d = options.category) !== null && _d !== void 0 ? _d : 'layout',
15
+ ...(options.parent && { parent: options.parent }),
16
+ icon: (_e = options.icon) !== null && _e !== void 0 ? _e : 'images-alt2',
17
+ supports: { html: false, customClassName: false },
18
+ attributes: {
19
+ height: { type: 'string', default: HEIGHTS[1].value, enum: HEIGHTS.map((h) => h.value) },
20
+ ratio: { type: 'string', default: ratios[0].value, enum: ratios.map((r) => r.value) },
21
+ speed: { type: 'string', default: SPEEDS[1].value, enum: SPEEDS.map((s) => s.value) },
22
+ direction: { type: 'string', default: DIRECTIONS[0].value, enum: DIRECTIONS.map((d) => d.value) },
23
+ ...ITEM_SPACING_ATTRIBUTE,
24
+ },
25
+ edit: createGalleryStripGroupEdit(options),
26
+ save: () => _jsx(InnerBlocks.Content, {}),
27
+ };
28
+ }
@@ -0,0 +1,5 @@
1
+ export type { GalleryStripGroupAttributes, GalleryStripGroupOptions } from './types';
2
+ export { createGalleryStripGroupBlock } from './factory';
3
+ import type { GalleryStripGroupOptions } from './types';
4
+ export declare const galleryStripGroupDefaults: GalleryStripGroupOptions;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAClF,OAAO,EAAC,4BAA4B,EAAC,MAAM,WAAW,CAAA;AAEtD,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAErD,eAAO,MAAM,yBAAyB,EAAE,wBAKvC,CAAA"}
@@ -0,0 +1,7 @@
1
+ export { createGalleryStripGroupBlock } from './factory';
2
+ export const galleryStripGroupDefaults = {
3
+ name: 'brilo/gallery-strip-group',
4
+ parent: ['brilo/base-section'],
5
+ allowedBlocks: ['brilo/gallery-item'],
6
+ template: [],
7
+ };
@@ -0,0 +1,18 @@
1
+ import type { BriloBlockType, OptionArray } from '../../../types';
2
+ import type { DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, SPEEDS } from './constants';
3
+ export type GalleryStripHeight = (typeof HEIGHTS)[number]['value'];
4
+ export type GalleryStripSpeed = (typeof SPEEDS)[number]['value'];
5
+ export type GalleryStripRatio = (typeof DEFAULT_RATIOS)[number]['value'];
6
+ export type GalleryStripDirection = (typeof DIRECTIONS)[number]['value'];
7
+ export interface GalleryStripGroupAttributes extends Record<string, unknown> {
8
+ height: GalleryStripHeight;
9
+ ratio: GalleryStripRatio;
10
+ speed: GalleryStripSpeed;
11
+ direction: GalleryStripDirection;
12
+ spacing?: number;
13
+ }
14
+ export interface GalleryStripGroupOptions extends BriloBlockType {
15
+ allowedBlocks: string[];
16
+ ratios?: OptionArray;
17
+ }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/gallery/gallery-strip-group/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AACxD,OAAO,KAAK,EAAC,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,aAAa,CAAA;AAE5E,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAClE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAChE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AACxE,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;AAExE,MAAM,WAAW,2BAA4B,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1E,MAAM,EAAE,kBAAkB,CAAA;IAC1B,KAAK,EAAE,iBAAiB,CAAA;IACxB,KAAK,EAAE,iBAAiB,CAAA;IACxB,SAAS,EAAE,qBAAqB,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/text-and-media-group/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAClF,OAAO,EAAC,4BAA4B,EAAC,MAAM,WAAW,CAAA;AAEtD,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAErD,eAAO,MAAM,yBAAyB,EAAE,wBAavC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/groups/text-and-media-group/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAClF,OAAO,EAAC,4BAA4B,EAAC,MAAM,WAAW,CAAA;AAEtD,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAErD,eAAO,MAAM,yBAAyB,EAAE,wBAevC,CAAA"}
@@ -11,5 +11,7 @@ export const textAndMediaGroupDefaults = {
11
11
  'core/heading',
12
12
  'core/list',
13
13
  'core/paragraph',
14
+ 'brilo/review-summary-item',
15
+ 'brilo/urgency-item',
14
16
  ],
15
17
  };
@@ -2,5 +2,5 @@ export { createHeroItemBlock } from './factory';
2
2
  export const heroItemDefaults = {
3
3
  name: 'brilo/hero-item',
4
4
  parent: ['brilo/hero-group'],
5
- allowedBlocks: ['core/list', 'core/paragraph', 'brilo/button-group'],
5
+ allowedBlocks: ['core/list', 'core/paragraph', 'brilo/button-group', 'brilo/review-summary-item'],
6
6
  };
@@ -0,0 +1,3 @@
1
+ export declare const RATING_MAX = 5;
2
+ export declare const RATING_STEP = 0.1;
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/review/review-summary-item/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,IAAI,CAAA;AAC3B,eAAO,MAAM,WAAW,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const RATING_MAX = 5;
2
+ export const RATING_STEP = 0.1;
@@ -0,0 +1,6 @@
1
+ import type { ReviewSummaryItemAttributes, ReviewSummaryItemOptions } from './types';
2
+ export declare function createReviewSummaryItemEdit(options: ReviewSummaryItemOptions): ({ attributes, setAttributes, }: {
3
+ attributes: ReviewSummaryItemAttributes;
4
+ setAttributes: (a: Partial<ReviewSummaryItemAttributes>) => 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/review/review-summary-item/edit.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAIlF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,wBAAwB,oCAIxE;IACD,UAAU,EAAE,2BAA2B,CAAA;IACvC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,KAAK,IAAI,CAAA;CACjE,iCAoEF"}
@@ -0,0 +1,17 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor';
3
+ import { PanelBody, RangeControl, TextControl, ToggleControl } from '@wordpress/components';
4
+ import { __ } from '@wordpress/i18n';
5
+ import clsx from 'clsx';
6
+ import { RATING_MAX, RATING_STEP } from './constants';
7
+ const roundToHalf = (value) => Math.round(value * 2) / 2;
8
+ export function createReviewSummaryItemEdit(options) {
9
+ return function Edit({ attributes, setAttributes, }) {
10
+ var _a;
11
+ const { rating, count, countLabel, showMax, description } = attributes;
12
+ const hasRating = typeof rating === 'number';
13
+ const hasCount = typeof count === 'number' && count > 0;
14
+ const blockProps = useBlockProps({ className: clsx((_a = options.blockClassName) !== null && _a !== void 0 ? _a : 'i-review-summary-item wp-block-section') });
15
+ return (_jsxs(_Fragment, { children: [_jsx(InspectorControls, { children: _jsxs(PanelBody, { title: __('Hodnocení', 'brilo-blocks'), children: [_jsx(RangeControl, { label: __('Průměrné hodnocení', 'brilo-blocks'), help: __('Bez hodnoty se hvězdičky ani číslo nezobrazí.', 'brilo-blocks'), value: rating, onChange: (v) => setAttributes({ rating: v }), min: 0, max: RATING_MAX, step: RATING_STEP, allowReset: true, withInputField: true }), _jsx(ToggleControl, { label: __('Zobrazit „/ 5"', 'brilo-blocks'), checked: showMax, onChange: (v) => setAttributes({ showMax: v }) }), _jsx(TextControl, { type: "number", min: 0, label: __('Počet recenzí', 'brilo-blocks'), help: __('Při nule nebo prázdné hodnotě se počet nezobrazí.', 'brilo-blocks'), value: typeof count === 'number' ? String(count) : '', onChange: (v) => setAttributes({ count: v === '' ? undefined : Math.max(0, Number.parseInt(v, 10) || 0) }) }), _jsx(TextControl, { label: __('Popisek počtu', 'brilo-blocks'), value: countLabel, onChange: (v) => setAttributes({ countLabel: v }) })] }) }), _jsxs("div", { ...blockProps, children: [_jsxs("div", { className: "i-review-summary-item__score", children: [hasRating && (_jsxs(_Fragment, { children: [_jsx("span", { className: "i-review-summary-item__stars", style: { '--rating-fill': `${(roundToHalf(rating) / RATING_MAX) * 100}%` }, children: "\u2605\u2605\u2605\u2605\u2605" }), _jsxs("strong", { className: "i-review-summary-item__value", children: [rating.toLocaleString(undefined, { minimumFractionDigits: 1, maximumFractionDigits: 1 }), showMax && ` / ${RATING_MAX}`] })] })), hasCount && _jsx("span", { className: "i-review-summary-item__count", children: `${count} ${countLabel}` }), !hasRating && !hasCount && (_jsx("span", { className: "i-review-summary-item__placeholder", children: __('Nastavte hodnocení v postranním panelu', 'brilo-blocks') }))] }), _jsx(RichText, { tagName: "p", className: "i-review-summary-item__description u-text-editable", value: description, onChange: (v) => setAttributes({ description: v }), placeholder: __('Popis hodnocení...', 'brilo-blocks'), allowedFormats: ['core/bold', 'core/italic', 'core/link', 'brilo-blocks/text-color'] })] })] }));
16
+ };
17
+ }
@@ -0,0 +1,5 @@
1
+ import type { BlockConfiguration } from '@wordpress/blocks';
2
+ import type { ReviewSummaryItemAttributes, ReviewSummaryItemOptions } from './types';
3
+ export type { ReviewSummaryItemAttributes, ReviewSummaryItemOptions };
4
+ export declare function createReviewSummaryItemBlock(options: ReviewSummaryItemOptions): BlockConfiguration<ReviewSummaryItemAttributes>;
5
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/review/review-summary-item/factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAGzD,OAAO,KAAK,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAElF,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,CAAA;AAEnE,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,wBAAwB,GAAG,kBAAkB,CAAC,2BAA2B,CAAC,CAmB/H"}
@@ -0,0 +1,23 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { createReviewSummaryItemEdit } from './edit';
3
+ export function createReviewSummaryItemBlock(options) {
4
+ var _a, _b, _c, _d;
5
+ return {
6
+ name: options.name,
7
+ title: (_a = options.title) !== null && _a !== void 0 ? _a : __('Souhrn hodnocení', 'brilo-blocks'),
8
+ description: (_b = options.description) !== null && _b !== void 0 ? _b : __('Průměrné hodnocení hvězdičkami s počtem recenzí a popisem', 'brilo-blocks'),
9
+ category: (_c = options.category) !== null && _c !== void 0 ? _c : 'layout',
10
+ ...(options.parent && { parent: options.parent }),
11
+ icon: (_d = options.icon) !== null && _d !== void 0 ? _d : 'star-half',
12
+ supports: { html: false, customClassName: false },
13
+ attributes: {
14
+ rating: { type: 'number' },
15
+ count: { type: 'number' },
16
+ countLabel: { type: 'string', default: __('hodnocení', 'brilo-blocks') },
17
+ showMax: { type: 'boolean', default: false },
18
+ description: { type: 'string', default: '' },
19
+ },
20
+ edit: createReviewSummaryItemEdit(options),
21
+ save: () => null,
22
+ };
23
+ }
@@ -0,0 +1,5 @@
1
+ export type { ReviewSummaryItemAttributes, ReviewSummaryItemOptions } from './types';
2
+ export { createReviewSummaryItemBlock } from './factory';
3
+ import type { ReviewSummaryItemOptions } from './types';
4
+ export declare const reviewSummaryItemDefaults: ReviewSummaryItemOptions;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/blocks/review/review-summary-item/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,2BAA2B,EAAE,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAClF,OAAO,EAAC,4BAA4B,EAAC,MAAM,WAAW,CAAA;AAEtD,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAA;AAErD,eAAO,MAAM,yBAAyB,EAAE,wBAGvC,CAAA"}
@@ -0,0 +1,5 @@
1
+ export { createReviewSummaryItemBlock } from './factory';
2
+ export const reviewSummaryItemDefaults = {
3
+ name: 'brilo/review-summary-item',
4
+ parent: ['brilo/base-section', 'brilo/text-and-media-group', 'brilo/hero-item'],
5
+ };
@@ -0,0 +1,11 @@
1
+ import type { BriloBlockType } from '../../../types';
2
+ export interface ReviewSummaryItemAttributes extends Record<string, unknown> {
3
+ rating?: number;
4
+ count?: number;
5
+ countLabel: string;
6
+ showMax: boolean;
7
+ description: string;
8
+ }
9
+ export interface ReviewSummaryItemOptions extends BriloBlockType {
10
+ }
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/blocks/review/review-summary-item/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAE3C,MAAM,WAAW,2BAA4B,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,wBAAyB,SAAQ,cAAc;CAAG"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ export { CONTENT_SIZES as TEXT_SIZES } from '../../../constants';
2
+ export declare const TYPES: readonly [{
3
+ readonly value: 'deadline';
4
+ readonly label: import("@wordpress/i18n").TransformedText<"Termín">;
5
+ }, {
6
+ readonly value: 'capacity';
7
+ readonly label: import("@wordpress/i18n").TransformedText<"Volná místa">;
8
+ }, {
9
+ readonly value: 'season';
10
+ readonly label: import("@wordpress/i18n").TransformedText<"Sezóna">;
11
+ }];
12
+ export declare const DEADLINE_DISPLAYS: readonly [{
13
+ readonly value: 'countdown';
14
+ readonly label: import("@wordpress/i18n").TransformedText<"Odpočet">;
15
+ }, {
16
+ readonly value: 'date';
17
+ readonly label: import("@wordpress/i18n").TransformedText<"Datum">;
18
+ }];
19
+ export declare const TEXTS: {
20
+ readonly countdown: import("@wordpress/i18n").TransformedText<"Nabídka končí za">;
21
+ readonly date: import("@wordpress/i18n").TransformedText<"Nabídka platí do">;
22
+ readonly capacity: import("@wordpress/i18n").TransformedText<"Zbývá volných míst">;
23
+ readonly season: import("@wordpress/i18n").TransformedText<"Nabídka platí pouze tuto sezónu">;
24
+ };
25
+ export declare const COUNTDOWN_UNITS: readonly [{
26
+ readonly key: 'days';
27
+ readonly label: import("@wordpress/i18n").TransformedText<"dní">;
28
+ }, {
29
+ readonly key: 'hours';
30
+ readonly label: import("@wordpress/i18n").TransformedText<"hod">;
31
+ }, {
32
+ readonly key: 'minutes';
33
+ readonly label: import("@wordpress/i18n").TransformedText<"min">;
34
+ }, {
35
+ readonly key: 'seconds';
36
+ readonly label: import("@wordpress/i18n").TransformedText<"sek">;
37
+ }];
38
+ export declare const NUMBER_SIZE_MIN = 16;
39
+ export declare const NUMBER_SIZE_MAX = 120;
40
+ export declare const NUMBER_SIZE_PRESETS: readonly [{
41
+ readonly value: 32;
42
+ readonly label: import("@wordpress/i18n").TransformedText<"XS">;
43
+ }, {
44
+ readonly value: 40;
45
+ readonly label: import("@wordpress/i18n").TransformedText<"SM">;
46
+ }, {
47
+ readonly value: 48;
48
+ readonly label: import("@wordpress/i18n").TransformedText<"MD">;
49
+ }, {
50
+ readonly value: 60;
51
+ readonly label: import("@wordpress/i18n").TransformedText<"LG">;
52
+ }, {
53
+ readonly value: 72;
54
+ readonly label: import("@wordpress/i18n").TransformedText<"XL">;
55
+ }];
56
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/blocks/urgency/urgency-item/constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,IAAI,UAAU,EAAC,MAAM,aAAa,CAAA;AAEvD,eAAO,MAAM,KAAK;aACf,KAAK,EAAE,UAAU;aAAE,KAAK;;aACxB,KAAK,EAAE,UAAU;aAAE,KAAK;;aACxB,KAAK,EAAE,QAAQ;aAAE,KAAK;EACf,CAAA;AAEV,eAAO,MAAM,iBAAiB;aAC3B,KAAK,EAAE,WAAW;aAAE,KAAK;;aACzB,KAAK,EAAE,MAAM;aAAE,KAAK;EACb,CAAA;AAEV,eAAO,MAAM,KAAK;aAChB,SAAS;aACT,IAAI;aACJ,QAAQ;aACR,MAAM;CACE,CAAA;AAEV,eAAO,MAAM,eAAe;aACzB,GAAG,EAAE,MAAM;aAAE,KAAK;;aAClB,GAAG,EAAE,OAAO;aAAE,KAAK;;aACnB,GAAG,EAAE,SAAS;aAAE,KAAK;;aACrB,GAAG,EAAE,SAAS;aAAE,KAAK;EACd,CAAA;AAEV,eAAO,MAAM,eAAe,KAAK,CAAA;AACjC,eAAO,MAAM,eAAe,MAAM,CAAA;AAElC,eAAO,MAAM,mBAAmB;aAC7B,KAAK,EAAE,EAAE;aAAE,KAAK;;aAChB,KAAK,EAAE,EAAE;aAAE,KAAK;;aAChB,KAAK,EAAE,EAAE;aAAE,KAAK;;aAChB,KAAK,EAAE,EAAE;aAAE,KAAK;;aAChB,KAAK,EAAE,EAAE;aAAE,KAAK;EACT,CAAA"}
@@ -0,0 +1,32 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ export { CONTENT_SIZES as TEXT_SIZES } from '../../../constants';
3
+ export const TYPES = [
4
+ { value: 'deadline', label: __('Termín', 'brilo-blocks') },
5
+ { value: 'capacity', label: __('Volná místa', 'brilo-blocks') },
6
+ { value: 'season', label: __('Sezóna', 'brilo-blocks') },
7
+ ];
8
+ export const DEADLINE_DISPLAYS = [
9
+ { value: 'countdown', label: __('Odpočet', 'brilo-blocks') },
10
+ { value: 'date', label: __('Datum', 'brilo-blocks') },
11
+ ];
12
+ export const TEXTS = {
13
+ countdown: __('Nabídka končí za', 'brilo-blocks'),
14
+ date: __('Nabídka platí do', 'brilo-blocks'),
15
+ capacity: __('Zbývá volných míst', 'brilo-blocks'),
16
+ season: __('Nabídka platí pouze tuto sezónu', 'brilo-blocks'),
17
+ };
18
+ export const COUNTDOWN_UNITS = [
19
+ { key: 'days', label: __('dní', 'brilo-blocks') },
20
+ { key: 'hours', label: __('hod', 'brilo-blocks') },
21
+ { key: 'minutes', label: __('min', 'brilo-blocks') },
22
+ { key: 'seconds', label: __('sek', 'brilo-blocks') },
23
+ ];
24
+ export const NUMBER_SIZE_MIN = 16;
25
+ export const NUMBER_SIZE_MAX = 120;
26
+ export const NUMBER_SIZE_PRESETS = [
27
+ { value: 32, label: __('XS', 'brilo-blocks') },
28
+ { value: 40, label: __('SM', 'brilo-blocks') },
29
+ { value: 48, label: __('MD', 'brilo-blocks') },
30
+ { value: 60, label: __('LG', 'brilo-blocks') },
31
+ { value: 72, label: __('XL', 'brilo-blocks') },
32
+ ];
@@ -0,0 +1,7 @@
1
+ import type { UrgencyItemAttributes, UrgencyItemOptions } from './types';
2
+ export declare function createUrgencyItemEdit(options: UrgencyItemOptions): ({ attributes, setAttributes, clientId, }: {
3
+ attributes: UrgencyItemAttributes;
4
+ setAttributes: (a: Partial<UrgencyItemAttributes>) => void;
5
+ clientId: string;
6
+ }) => import("react").JSX.Element;
7
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../../../src/blocks/urgency/urgency-item/edit.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAyB,qBAAqB,EAAE,kBAAkB,EAA+B,MAAM,SAAS,CAAA;AAiE5H,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,8CAK5D;IACD,UAAU,EAAE,qBAAqB,CAAA;IACjC,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAA;IAC1D,QAAQ,EAAE,MAAM,CAAA;CACjB,iCAuNF"}
@@ -0,0 +1,83 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
3
+ import { BaseControl, Button, ColorPalette, DateTimePicker, Notice, PanelBody, RangeControl, TextControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, } from '@wordpress/components';
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { dateI18n, getDate, getSettings } from '@wordpress/date';
6
+ import { __ } from '@wordpress/i18n';
7
+ import clsx from 'clsx';
8
+ import { useEffect } from 'react';
9
+ import { useTenantColorPalette } from '../../../hooks/useTenantColorPalette';
10
+ import { COUNTDOWN_UNITS, DEADLINE_DISPLAYS, TEXTS, NUMBER_SIZE_MAX, NUMBER_SIZE_MIN, NUMBER_SIZE_PRESETS, TEXT_SIZES, TYPES, } from './constants';
11
+ const TEXT_VALUES = Object.values(TEXTS);
12
+ function defaultTextFor(type, display) {
13
+ return type === 'deadline' ? TEXTS[display] : TEXTS[type];
14
+ }
15
+ function parseCount(value) {
16
+ return value === '' ? undefined : Math.max(0, Number.parseInt(value, 10) || 0);
17
+ }
18
+ function countdownParts(milliseconds) {
19
+ const totalSeconds = Math.max(0, Math.floor(milliseconds / 1000));
20
+ const pad = (n) => String(n).padStart(2, '0');
21
+ return {
22
+ days: pad(Math.floor(totalSeconds / 86400)),
23
+ hours: pad(Math.floor((totalSeconds % 86400) / 3600)),
24
+ minutes: pad(Math.floor((totalSeconds % 3600) / 60)),
25
+ seconds: pad(totalSeconds % 60),
26
+ };
27
+ }
28
+ function formatDeadline(deadline) {
29
+ const { formats } = getSettings();
30
+ const time = deadline.slice(11, 16);
31
+ const format = time === '00:00' || time === '23:59' ? formats.date : `${formats.date} ${formats.time}`;
32
+ return dateI18n(format, getDate(deadline));
33
+ }
34
+ function endOfDay(date) {
35
+ return getDate(`${date}T23:59:59`).getTime();
36
+ }
37
+ function ColorControl({ label, id, value, onChange }) {
38
+ const { paletteColors } = useTenantColorPalette();
39
+ return (_jsx(BaseControl, { label: label, id: id, children: _jsx(ColorPalette, { colors: paletteColors, value: value || undefined, onChange: (v) => onChange(v !== null && v !== void 0 ? v : '') }) }));
40
+ }
41
+ function NumberSizeControl({ value, onChange }) {
42
+ return (_jsxs(BaseControl, { label: __('Velikost čísel (px)', 'brilo-blocks'), help: __('Bez nastavení se použije velikost nadpisu ze šablony.', 'brilo-blocks'), id: "urgency-item-number-size", children: [_jsx("div", { className: "i-urgency__number-presets", children: NUMBER_SIZE_PRESETS.map((p) => (_jsx(Button, { variant: value === p.value ? 'primary' : 'secondary', size: "small", onClick: () => onChange(p.value), children: p.label }, p.label))) }), _jsx(RangeControl, { value: value, onChange: onChange, min: NUMBER_SIZE_MIN, max: NUMBER_SIZE_MAX, step: 1, withInputField: true, allowReset: true })] }));
43
+ }
44
+ export function createUrgencyItemEdit(options) {
45
+ return function Edit({ attributes, setAttributes, clientId, }) {
46
+ var _a;
47
+ const { type, text, deadline, display, remaining, total, endDate, textSize, numberSize, backgroundColor, numberBackgroundColor, textColor, } = attributes;
48
+ // core/editor is missing outside the post editor (widgets, site editor) – dispatch returns undefined there.
49
+ const editorDispatch = useDispatch('core/editor');
50
+ const lockPostSaving = editorDispatch === null || editorDispatch === void 0 ? void 0 : editorDispatch.lockPostSaving;
51
+ const unlockPostSaving = editorDispatch === null || editorDispatch === void 0 ? void 0 : editorDispatch.unlockPostSaving;
52
+ const isDeadlineMissing = type === 'deadline' && !deadline;
53
+ const isCapacityMissing = type === 'capacity' && (typeof remaining !== 'number' || typeof total !== 'number' || total <= 0);
54
+ const expiresAt = type === 'deadline' && deadline ? getDate(deadline).getTime() : type === 'season' && endDate ? endOfDay(endDate) : null;
55
+ const isExpired = expiresAt !== null && expiresAt <= Date.now();
56
+ useEffect(() => {
57
+ if (!lockPostSaving || !unlockPostSaving) {
58
+ return;
59
+ }
60
+ const lockName = `brilo-urgency-item-${clientId}`;
61
+ if (isDeadlineMissing || isCapacityMissing) {
62
+ lockPostSaving(lockName);
63
+ }
64
+ else {
65
+ unlockPostSaving(lockName);
66
+ }
67
+ return () => unlockPostSaving(lockName);
68
+ }, [clientId, isDeadlineMissing, isCapacityMissing, lockPostSaving, unlockPostSaving]);
69
+ const switchText = (nextType, nextDisplay) => !text || TEXT_VALUES.includes(text) ? { text: defaultTextFor(nextType, nextDisplay) } : {};
70
+ const countdown = countdownParts(deadline ? getDate(deadline).getTime() - Date.now() : 0);
71
+ const takenPercent = type === 'capacity' && total ? Math.min(100, Math.max(0, ((total - Math.min(remaining !== null && remaining !== void 0 ? remaining : total, total)) / total) * 100)) : 0;
72
+ const blockProps = useBlockProps({ className: clsx((_a = options.blockClassName) !== null && _a !== void 0 ? _a : 'i-urgency wp-block-section', `--${type}`) });
73
+ const isCountdown = type === 'deadline' && display === 'countdown';
74
+ const cardStyle = {
75
+ color: textColor || undefined,
76
+ '--urgency-background': backgroundColor || undefined,
77
+ '--urgency-number-background': numberBackgroundColor || undefined,
78
+ '--urgency-text-color': textColor || undefined,
79
+ '--urgency-number-size': numberSize ? `${numberSize}px` : undefined,
80
+ };
81
+ return (_jsxs(_Fragment, { children: [_jsxs(InspectorControls, { children: [_jsxs(PanelBody, { title: __('Nastavení', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { isBlock: true, label: __('Co zobrazit', 'brilo-blocks'), value: type, onChange: (v) => setAttributes({ type: v, ...switchText(v, display) }), children: TYPES.map((t) => (_jsx(ToggleGroupControlOption, { value: t.value, label: t.label }, t.value))) }), _jsx(TextControl, { label: __('Text', 'brilo-blocks'), value: text, placeholder: defaultTextFor(type, display), onChange: (v) => setAttributes({ text: v }) })] }), type === 'deadline' && (_jsxs(PanelBody, { title: __('Termín', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { isBlock: true, label: __('Zobrazit jako', 'brilo-blocks'), value: display, onChange: (v) => setAttributes({ display: v, ...switchText(type, v) }), children: DEADLINE_DISPLAYS.map((d) => (_jsx(ToggleGroupControlOption, { value: d.value, label: d.label }, d.value))) }), _jsx(DateTimePicker, { currentDate: deadline || null, onChange: (v) => setAttributes({ deadline: v !== null && v !== void 0 ? v : '' }), is12Hour: false })] })), type === 'capacity' && (_jsxs(PanelBody, { title: __('Volná místa', 'brilo-blocks'), children: [_jsx(TextControl, { type: "number", min: 0, label: __('Zbývá míst', 'brilo-blocks'), value: typeof remaining === 'number' ? String(remaining) : '', onChange: (v) => setAttributes({ remaining: parseCount(v) }) }), _jsx(TextControl, { type: "number", min: 1, label: __('Celkem míst', 'brilo-blocks'), value: typeof total === 'number' ? String(total) : '', onChange: (v) => setAttributes({ total: parseCount(v) }) })] })), type === 'season' && (_jsx(PanelBody, { title: __('Sezóna', 'brilo-blocks'), children: _jsx(TextControl, { type: "date", label: __('Konec sezóny (volitelné)', 'brilo-blocks'), help: __('Po tomto dni se blok na webu skryje.', 'brilo-blocks'), value: endDate, onChange: (v) => setAttributes({ endDate: v }) }) })), _jsxs(PanelBody, { title: __('Styl', 'brilo-blocks'), children: [_jsx(ToggleGroupControl, { isBlock: true, label: __('Velikost textu', 'brilo-blocks'), value: textSize, onChange: (v) => setAttributes({ textSize: v }), children: TEXT_SIZES.map((s) => (_jsx(ToggleGroupControlOption, { value: s.value, label: s.label }, s.value))) }), type !== 'season' && _jsx(NumberSizeControl, { value: numberSize, onChange: (v) => setAttributes({ numberSize: v }) }), _jsx(ColorControl, { label: __('Barva pozadí', 'brilo-blocks'), id: "urgency-item-background-color", value: backgroundColor, onChange: (v) => setAttributes({ backgroundColor: v }) }), isCountdown && (_jsx(ColorControl, { label: __('Pozadí čísel', 'brilo-blocks'), id: "urgency-item-number-background-color", value: numberBackgroundColor, onChange: (v) => setAttributes({ numberBackgroundColor: v }) })), _jsx(ColorControl, { label: __('Barva textu', 'brilo-blocks'), id: "urgency-item-text-color", value: textColor, onChange: (v) => setAttributes({ textColor: v }) })] })] }), _jsxs("div", { ...blockProps, children: [isDeadlineMissing && (_jsx(Notice, { status: "error", isDismissible: false, children: __('Vyberte termín v postranním panelu – bez něj nelze stránku uložit.', 'brilo-blocks') })), isCapacityMissing && (_jsx(Notice, { status: "error", isDismissible: false, children: __('Vyplňte volná a celková místa v postranním panelu – bez nich nelze stránku uložit.', 'brilo-blocks') })), isExpired && (_jsx(Notice, { status: "warning", isDismissible: false, children: __('Termín vypršel – na webu se nezobrazuje.', 'brilo-blocks') })), _jsxs("div", { className: clsx('i-urgency__card', `--text-${textSize}`), style: cardStyle, children: [text && _jsx("span", { className: "i-urgency__label", children: text }), isCountdown && (_jsx("span", { className: "i-urgency__countdown", children: COUNTDOWN_UNITS.map((unit) => (_jsxs("span", { className: "i-urgency__unit", children: [_jsx("span", { className: "i-urgency__number", children: countdown[unit.key] }), _jsx("span", { className: "i-urgency__unit-label", children: unit.label })] }, unit.key))) })), type === 'deadline' && display === 'date' && (_jsx("span", { className: "i-urgency__value", children: deadline ? formatDeadline(deadline) : '—' })), type === 'capacity' && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "i-urgency__value", children: [remaining !== null && remaining !== void 0 ? remaining : '—', " / ", total !== null && total !== void 0 ? total : '—'] }), _jsx("span", { className: "i-urgency__progress", children: _jsx("span", { className: "i-urgency__progress-fill", style: { width: `${takenPercent}%` } }) })] }))] })] })] }));
82
+ };
83
+ }
@@ -0,0 +1,5 @@
1
+ import type { BlockConfiguration } from '@wordpress/blocks';
2
+ import type { UrgencyItemAttributes, UrgencyItemOptions } from './types';
3
+ export type { UrgencyItemAttributes, UrgencyItemOptions };
4
+ export declare function createUrgencyItemBlock(options: UrgencyItemOptions): BlockConfiguration<UrgencyItemAttributes>;
5
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/blocks/urgency/urgency-item/factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAIzD,OAAO,KAAK,EAAC,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAEtE,YAAY,EAAC,qBAAqB,EAAE,kBAAkB,EAAC,CAAA;AAEvD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAAC,qBAAqB,CAAC,CA2B7G"}
@@ -0,0 +1,31 @@
1
+ import { __ } from '@wordpress/i18n';
2
+ import { DEADLINE_DISPLAYS, TEXTS, TEXT_SIZES, TYPES } from './constants';
3
+ import { createUrgencyItemEdit } from './edit';
4
+ export function createUrgencyItemBlock(options) {
5
+ var _a, _b, _c, _d;
6
+ return {
7
+ name: options.name,
8
+ title: (_a = options.title) !== null && _a !== void 0 ? _a : __('Naléhavost', 'brilo-blocks'),
9
+ description: (_b = options.description) !== null && _b !== void 0 ? _b : __('Skutečný termín, počet volných míst nebo sezóna. Po vypršení termínu se na webu skryje.', 'brilo-blocks'),
10
+ category: (_c = options.category) !== null && _c !== void 0 ? _c : 'layout',
11
+ ...(options.parent && { parent: options.parent }),
12
+ icon: (_d = options.icon) !== null && _d !== void 0 ? _d : 'clock',
13
+ supports: { html: false, customClassName: false },
14
+ attributes: {
15
+ type: { type: 'string', default: TYPES[0].value, enum: TYPES.map((t) => t.value) },
16
+ text: { type: 'string', default: TEXTS.countdown },
17
+ deadline: { type: 'string', default: '' },
18
+ display: { type: 'string', default: DEADLINE_DISPLAYS[0].value, enum: DEADLINE_DISPLAYS.map((d) => d.value) },
19
+ remaining: { type: 'number' },
20
+ total: { type: 'number' },
21
+ endDate: { type: 'string', default: '' },
22
+ textSize: { type: 'string', default: TEXT_SIZES[1].value, enum: TEXT_SIZES.map((s) => s.value) },
23
+ numberSize: { type: 'number' },
24
+ backgroundColor: { type: 'string', default: '' },
25
+ numberBackgroundColor: { type: 'string', default: '' },
26
+ textColor: { type: 'string', default: '' },
27
+ },
28
+ edit: createUrgencyItemEdit(options),
29
+ save: () => null,
30
+ };
31
+ }