@lowdefy/blocks-basic 6.0.0 → 7.0.0

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 (41) hide show
  1. package/dist/blocks/Anchor/Anchor.js +1 -1
  2. package/dist/blocks/Anchor/gallery.yaml +14 -14
  3. package/dist/blocks/Anchor/meta.js +11 -2
  4. package/dist/blocks/Anchor/tests/Anchor.e2e.yaml +10 -1
  5. package/dist/blocks/Anchor/tests/AnchorPathTarget.e2e.yaml +23 -0
  6. package/dist/blocks/Anchor/tests.yaml +6 -6
  7. package/dist/blocks/Box/Box.js +9 -5
  8. package/dist/blocks/Box/gallery.yaml +9 -9
  9. package/dist/blocks/Box/tests/Box.e2e.yaml +62 -0
  10. package/dist/blocks/Box/tests/BoxPageTitle.e2e.yaml +57 -0
  11. package/dist/blocks/ClickableHtml/ClickableHtml.js +34 -0
  12. package/dist/blocks/ClickableHtml/e2e.js +23 -0
  13. package/dist/blocks/ClickableHtml/gallery.yaml +199 -0
  14. package/dist/blocks/ClickableHtml/meta.js +96 -0
  15. package/dist/blocks/ClickableHtml/tests/ClickableHtml.e2e.yaml +188 -0
  16. package/dist/blocks/ClickableHtml/tests.yaml +48 -0
  17. package/dist/blocks/DangerousHtml/DangerousHtml.js +19 -19
  18. package/dist/blocks/DangerousHtml/meta.js +13 -1
  19. package/dist/blocks/Dynamic/Dynamic.js +5 -3
  20. package/dist/blocks/Dynamic/meta.js +4 -0
  21. package/dist/blocks/Html/gallery.yaml +28 -0
  22. package/dist/blocks/Html/meta.js +23 -1
  23. package/dist/blocks/Html/tests/Html.e2e.yaml +13 -0
  24. package/dist/blocks/Icon/Icon.js +21 -1
  25. package/dist/blocks/Icon/gallery.yaml +158 -64
  26. package/dist/blocks/Icon/meta.js +11 -4
  27. package/dist/blocks/Icon/tests/Icon.e2e.yaml +3 -3
  28. package/dist/blocks/Icon/tests.yaml +7 -7
  29. package/dist/blocks/Img/meta.js +12 -4
  30. package/dist/blocks/List/gallery.yaml +11 -11
  31. package/dist/blocks/PollingTimer/PollingTimer.js +120 -0
  32. package/dist/blocks/PollingTimer/e2e.js +21 -0
  33. package/dist/blocks/PollingTimer/gallery.yaml +190 -0
  34. package/dist/blocks/PollingTimer/meta.js +61 -0
  35. package/dist/blocks/PollingTimer/validateInterval.js +21 -0
  36. package/dist/blocks/Span/Span.js +5 -3
  37. package/dist/blocks/Span/gallery.yaml +7 -7
  38. package/dist/blocks.js +2 -0
  39. package/dist/e2e.js +2 -0
  40. package/dist/metas.js +2 -0
  41. package/package.json +9 -6
@@ -237,3 +237,31 @@
237
237
  border: 1px solid var(--ant-color-border)
238
238
  properties:
239
239
  html: '<h4 style="margin: 0 0 8px 0;">Elevated Block</h4><p style="margin: 0;">Uses bg-elevated token for a surface that adapts to light and dark mode.</p>'
240
+
241
+ - title: Icons, tooltips and popovers
242
+ blocks:
243
+ - id: html_icons
244
+ type: Html
245
+ properties:
246
+ html: '<p><i data-icon="success" style="color: var(--ant-color-success)"></i> Saved <span data-tooltip="Saved to the cloud 2 minutes ago" style="text-decoration: underline dotted">just now</span></p><p><i data-icon="warning" style="color: var(--ant-color-warning)"></i> 3 fields need attention. <span data-popover="fields" style="color: var(--ant-color-primary); cursor: pointer">Which? <i data-icon="chevron-down"></i></span></p><div data-popover-content="fields" hidden><ul style="margin: 0; padding-left: 16px"><li>Email</li><li>Phone</li><li>Address</li></ul></div>'
247
+
248
+ - title: Links and status tags
249
+ blocks:
250
+ - id: html_links_tags
251
+ type: Html
252
+ properties:
253
+ html: '<p><a data-page-id="Button">Button</a> moved to <span data-tag="success">Released</span> · <a data-page-id="theming" data-url-query="section=icons">Theming</a> is <span data-tag="warning">In review</span> · <a href="https://ant.design" data-new-tab>Ant Design</a> <i data-icon="external-link"></i></p><p><span data-status="success">Online</span> &nbsp; <span data-status="processing">Syncing</span> &nbsp; <span data-status="error">Offline</span></p><p><span data-tag>Design</span> <span data-tag>Engineering</span> <span data-tag>Support</span> <span data-tag="purple">Beta</span> <span data-tag="#0f766e">Custom colour</span></p>'
254
+
255
+ - title: Dates, numbers, avatars and copy
256
+ blocks:
257
+ - id: html_time_format
258
+ type: Html
259
+ properties:
260
+ html: '<p><span data-avatar="Jane Doe"></span> Jane Doe updated the invoice <time datetime="2026-01-05T09:30:00Z" data-time="relative"></time> (<time datetime="2026-01-05T09:30:00Z" data-time="D MMM YYYY"></time>) · <span data-format="currency" data-currency="USD">1234.5</span> · <span data-format="percent" data-decimals="1">0.123</span> of target · <span data-format="bytes">1536000</span> attached</p><p>Invoice number <code data-copy>INV-2026-0042</code> · owner <img data-avatar="Sam Smith" src="" style="--lf-avatar-size: 32px"></p>'
261
+
262
+ - title: Truncation and text tone
263
+ blocks:
264
+ - id: html_truncate_tone
265
+ type: Html
266
+ properties:
267
+ html: '<div style="max-width: 320px"><div data-truncate><b>Quarterly report for the northern region, including every branch and its targets</b></div><div data-truncate="2" data-tone="secondary">The report covers revenue, costs and headcount for each branch, compares them with the same quarter last year, and lists the actions each branch manager agreed for the next quarter.</div><div><span data-tone="tertiary">Updated 3 days ago</span> · <span data-tone="success">On track</span> · <span data-tone="quaternary">—</span></div></div>'
@@ -19,6 +19,28 @@
19
19
  cssKeys: {
20
20
  element: 'The Html element.'
21
21
  },
22
+ hazards: [
23
+ {
24
+ id: 'html-style-stripped',
25
+ message: 'Content is sanitised with DOMPurify, so <style>, <script> and inline event handlers are removed before render. Use DangerousHtml for a trusted <style> block, or style the block through its style and class properties.',
26
+ see: 'display-blocks/html'
27
+ },
28
+ {
29
+ id: 'html-no-click-events',
30
+ message: 'Html fires no events from its markup: data-event attributes do nothing here. Use ClickableHtml for clickable elements, including icons.',
31
+ see: 'display-blocks/clickablehtml'
32
+ },
33
+ {
34
+ id: 'html-hardcoded-links',
35
+ message: 'Link to app pages with <a data-page-id="page-id" data-url-query="key=value"> (and data-path-params=\'{"name":"value"}\' for a page whose path has placeholders), not <a href="/page-id?key=value">. A hard-coded href reloads the whole app on click, ignores basePath and is not checked by the build. Use data-new-tab, not target="_blank", which sanitising removes.',
36
+ see: 'concepts/html-attributes'
37
+ },
38
+ {
39
+ id: 'html-inline-status-pills',
40
+ message: 'Show statuses with <span data-tag="success">Approved</span> or <span data-status="warning">Syncing</span>, not inline-styled pills or hex status colours. data-tag and data-status follow the theme and dark mode and match the ag-grid tag cells.',
41
+ see: 'concepts/html-attributes'
42
+ }
43
+ ],
22
44
  events: {
23
45
  onTextSelection: 'Trigger action when text is selected and pass selected text to the event object.'
24
46
  },
@@ -28,7 +50,7 @@
28
50
  properties: {
29
51
  html: {
30
52
  type: 'string',
31
- description: 'Content to be rendered as Html.',
53
+ description: 'Content to be rendered as Html. It understands these attributes: data-icon="edit" renders an icon (a semantic name like edit, delete or warning, or a Lucide icon name like Pencil); data-tooltip="Text" shows a tooltip on hover and focus; data-popover="id" toggles a popover showing the element with data-popover-content="id" (mark it hidden); <a data-page-id="page-id" data-url-query="key=value"> links to an app page without reloading (never hard-code href="/page"), with data-path-params=\'{"name":"value"}\' (a JSON object) for a page whose path has placeholders; data-link opts an existing app-relative <a href="/path"> into the same navigation; data-new-tab opens a link in a new tab (target is stripped by sanitising); data-tag="success" renders a tinted status tag and data-status="success" a status dot (tones success, processing, info, warning, error, default, an antd preset colour, a CSS colour, or any other value to seed a stable colour); <time datetime="ISO" data-time="relative"> renders a date as relative, date, datetime, time or a dayjs format; data-format="currency" data-currency="USD" formats the element\'s number as number, currency, percent, compact or bytes; data-avatar="Jane Doe" renders initials (on an <img>, a fallback for a broken image; never use an avatar image service); data-copy adds a copy button for the element\'s text or the attribute\'s value; data-truncate="2" clamps block text to 1–6 lines with the full text in a tooltip when cut off; data-tone="secondary" colours text with a theme tone (secondary, tertiary, quaternary, success, warning, error, info). See the HTML attributes docs page.',
32
54
  docs: {
33
55
  displayType: 'text-area'
34
56
  }
@@ -54,3 +54,16 @@ blocks:
54
54
  params:
55
55
  selected_text:
56
56
  _event: selectedText
57
+
58
+ - id: html_enhanced
59
+ type: Html
60
+ properties:
61
+ html: >-
62
+ <i id="enh_icon" data-icon="edit"></i>
63
+ <span id="enh_tooltip" data-tooltip="&lt;img src=x onerror=&quot;window.tooltipXss=1&quot;&gt;">Hover</span>
64
+ <span id="enh_popover" data-popover="more">More</span>
65
+ <div data-popover-content="more" hidden><b class="enh-popover-body">Popover body</b></div>
66
+ <a id="enh_page_link" data-page-id="clickablehtml" data-url-query="tab=a">Clickable</a>
67
+ <a id="enh_path_link" data-page-id="anchor-path-target" data-path-params='{"space":"s","ticket_id":"1"}'>Ticket</a>
68
+ <a id="enh_dot_link" href="/.//evil.example/x" data-link>Dot link</a>
69
+ <span id="enh_copy_long" data-copy="npm install lowdefy-package-with-a-long-name --save-dev">Install</span>
@@ -14,5 +14,25 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  import { withBlockDefaults } from '@lowdefy/block-utils';
17
- const IconBlock = ({ components: { Icon }, ...props })=>/*#__PURE__*/ React.createElement(Icon, props);
17
+ // An Icon block with an onClick event is a control, so it takes keyboard focus
18
+ // and Enter/Space fire the event like a click. The icon component other blocks
19
+ // render (inside a Button, an Alert) stays untouched: their block is the control.
20
+ const IconBlock = ({ components: { Icon }, events, methods, ...props })=>{
21
+ const keyboardProps = events.onClick ? {
22
+ tabIndex: 0,
23
+ onKeyDown: (event)=>{
24
+ if (event.key !== 'Enter' && event.key !== ' ') return;
25
+ event.preventDefault();
26
+ methods.triggerEvent({
27
+ name: 'onClick'
28
+ });
29
+ }
30
+ } : {};
31
+ return /*#__PURE__*/ React.createElement(Icon, {
32
+ events: events,
33
+ methods: methods,
34
+ ...keyboardProps,
35
+ ...props
36
+ });
37
+ };
18
38
  export default withBlockDefaults(IconBlock);