@lowdefy/client 4.7.2 → 5.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.
package/dist/Client.js CHANGED
@@ -44,6 +44,7 @@ const Client = ({ auth, Components, config: rawConfig, jsMap, lowdefy, resetCont
44
44
  id: "lowdefy-display-message",
45
45
  key: `${config.pageConfig.id}-display-message`,
46
46
  Component: lowdefy._internal.blockComponents.Message,
47
+ components: lowdefy._internal.components,
47
48
  methods: {
48
49
  registerMethod: (_, method)=>{
49
50
  lowdefy._internal.displayMessage = method;
@@ -59,10 +60,10 @@ const Client = ({ auth, Components, config: rawConfig, jsMap, lowdefy, resetCont
59
60
  if (!context._internal.onInitDone) return '';
60
61
  return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Head, {
61
62
  Component: Components.Head,
62
- properties: context._internal.RootAreas.map[config.pageConfig.blockId].eval.properties
63
+ properties: context._internal.RootSlots.map[config.pageConfig.blockId].eval.properties
63
64
  }), /*#__PURE__*/ React.createElement(Block, {
64
- block: context._internal.RootAreas.map[config.pageConfig.blockId],
65
- Blocks: context._internal.RootAreas,
65
+ block: context._internal.RootSlots.map[config.pageConfig.blockId],
66
+ Blocks: context._internal.RootSlots,
66
67
  context: context,
67
68
  lowdefy: lowdefy,
68
69
  parentLoading: false
package/dist/Context.js CHANGED
@@ -12,9 +12,20 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import React from 'react';
15
+ */ import React, { useEffect } from 'react';
16
16
  import getContext from '@lowdefy/engine';
17
+ import createShortcutManager from './createShortcutManager.js';
17
18
  import MountEvents from './MountEvents.js';
19
+ const ShortcutEffect = ({ context })=>{
20
+ useEffect(()=>{
21
+ const manager = createShortcutManager();
22
+ manager.init(context);
23
+ return ()=>manager.destroy();
24
+ }, [
25
+ context
26
+ ]);
27
+ return null;
28
+ };
18
29
  const Context = ({ children, config, jsMap, lowdefy, resetContext })=>{
19
30
  const context = getContext({
20
31
  config,
@@ -40,7 +51,9 @@ const Context = ({ children, config, jsMap, lowdefy, resetContext })=>{
40
51
  }
41
52
  }, (loadingOnInit)=>{
42
53
  if (loadingOnInit) return '';
43
- return children(context);
54
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(ShortcutEffect, {
55
+ context: context
56
+ }), children(context));
44
57
  });
45
58
  };
46
59
  export default Context;
@@ -13,13 +13,12 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
- import { makeCssClass } from '@lowdefy/block-utils';
17
- const DisplayMessage = ({ Component, id, methods })=>{
16
+ const DisplayMessage = ({ Component, components, id, methods })=>{
18
17
  return /*#__PURE__*/ React.createElement(Component, {
19
18
  blockId: id,
19
+ components: components,
20
20
  key: id,
21
21
  methods: {
22
- makeCssClass,
23
22
  registerMethod: methods.registerMethod,
24
23
  triggerEvent: ()=>undefined
25
24
  },
@@ -13,7 +13,6 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import React, { useReducer, useEffect } from 'react';
16
- import { makeCssClass } from '@lowdefy/block-utils';
17
16
  const initialState = {
18
17
  progress: 0,
19
18
  onMounts: 0
@@ -72,9 +71,7 @@ const ProgressBarController = ({ id, lowdefy, resetContext })=>{
72
71
  blockId: id,
73
72
  components: lowdefy._internal.components,
74
73
  menus: lowdefy.menus,
75
- methods: {
76
- makeCssClass
77
- },
74
+ methods: {},
78
75
  pageId: lowdefy.pageId,
79
76
  properties: state
80
77
  });
@@ -14,12 +14,12 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  import { BlockLayout } from '@lowdefy/layout';
17
- import { makeCssClass } from '@lowdefy/block-utils';
18
17
  import { type } from '@lowdefy/helpers';
19
18
  import InputContainer from './InputContainer.js';
20
19
  import Container from './Container.js';
21
20
  import List from './List.js';
22
21
  import LoadingBlock from './LoadingBlock.js';
22
+ import resolveClassNames from './resolveClassNames.js';
23
23
  const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
24
24
  if (!block.eval) return null; // TODO: check Renderer updates before eval is executed for the first time on lists. See #520
25
25
  if (block.eval.visible === false) return /*#__PURE__*/ React.createElement("div", {
@@ -29,17 +29,20 @@ const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
29
29
  }
30
30
  });
31
31
  const Component = lowdefy._internal.blockComponents[block.type];
32
+ const classNames = resolveClassNames(block.eval.class);
32
33
  if (loading && type.isObject(block.eval.skeleton)) {
33
34
  return /*#__PURE__*/ React.createElement(LoadingBlock, {
34
35
  blockLayout: block.eval.layout,
35
36
  blockProperties: block.eval.properties,
36
- blockStyle: block.eval.style,
37
+ blockStyle: block.eval.style?.block,
38
+ blockClass: classNames,
37
39
  context: context,
38
40
  lowdefy: lowdefy,
39
41
  skeleton: block.eval.skeleton
40
42
  });
41
43
  }
42
- switch(Component.meta.category){
44
+ const category = lowdefy._internal.blockMetas[block.type]?.category;
45
+ switch(category){
43
46
  case 'list':
44
47
  return /*#__PURE__*/ React.createElement(List, {
45
48
  block: block,
@@ -61,12 +64,11 @@ const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
61
64
  case 'input':
62
65
  return /*#__PURE__*/ React.createElement(BlockLayout, {
63
66
  id: `bl-${block.blockId}`,
64
- blockStyle: block.eval.style,
65
- layout: block.eval.layout,
66
- makeCssClass: makeCssClass
67
+ style: block.eval.style?.block,
68
+ className: classNames.block,
69
+ layout: block.eval.layout
67
70
  }, /*#__PURE__*/ React.createElement(Component, {
68
71
  methods: Object.assign(block.methods, {
69
- makeCssClass,
70
72
  registerEvent: block.registerEvent,
71
73
  registerMethod: block.registerMethod,
72
74
  setValue: block.setValue,
@@ -74,14 +76,16 @@ const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
74
76
  }),
75
77
  basePath: lowdefy.basePath,
76
78
  blockId: block.blockId,
79
+ classNames: classNames,
77
80
  components: lowdefy._internal.components,
78
- events: block.eval.events,
81
+ events: block.eval.events ?? {},
79
82
  key: block.blockId,
80
83
  loading: loading,
81
84
  menus: lowdefy.menus,
82
85
  pageId: lowdefy.pageId,
83
86
  properties: block.eval.properties,
84
87
  required: block.eval.required,
88
+ styles: block.eval.style ?? {},
85
89
  validation: block.eval.validation,
86
90
  value: block.value
87
91
  }));
@@ -97,26 +101,27 @@ const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
97
101
  default:
98
102
  return /*#__PURE__*/ React.createElement(BlockLayout, {
99
103
  id: `bl-${block.blockId}`,
100
- blockStyle: block.eval.style,
101
- layout: block.eval.layout,
102
- makeCssClass: makeCssClass
104
+ style: block.eval.style?.block,
105
+ className: classNames.block,
106
+ layout: block.eval.layout
103
107
  }, /*#__PURE__*/ React.createElement(Component, {
104
108
  methods: Object.assign(block.methods, {
105
- makeCssClass,
106
109
  registerEvent: block.registerEvent,
107
110
  registerMethod: block.registerMethod,
108
111
  triggerEvent: block.triggerEvent
109
112
  }),
110
113
  basePath: lowdefy.basePath,
111
114
  blockId: block.blockId,
115
+ classNames: classNames,
112
116
  components: lowdefy._internal.components,
113
- events: block.eval.events,
117
+ events: block.eval.events ?? {},
114
118
  key: block.blockId,
115
119
  loading: loading,
116
120
  menus: lowdefy.menus,
117
121
  pageId: lowdefy.pageId,
118
122
  properties: block.eval.properties,
119
123
  required: block.eval.required,
124
+ styles: block.eval.style ?? {},
120
125
  validation: block.eval.validation
121
126
  }));
122
127
  }
@@ -14,27 +14,29 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  import { Area, BlockLayout } from '@lowdefy/layout';
17
- import { makeCssClass } from '@lowdefy/block-utils';
17
+ import { cn } from '@lowdefy/block-utils';
18
18
  import Block from './Block.js';
19
+ import resolveClassNames from './resolveClassNames.js';
19
20
  const Container = ({ block, Blocks, Component, context, loading, lowdefy })=>{
21
+ const classNames = resolveClassNames(block.eval.class);
20
22
  const content = {};
21
23
  // eslint-disable-next-line prefer-destructuring
22
- const areas = Blocks.subAreas[block.id][0].areas;
23
- Object.keys(areas).forEach((areaKey, i)=>{
24
- content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
- area: block.eval.areas[areaKey],
26
- areaKey: areaKey,
27
- areaStyle: [
28
- areaStyle,
29
- block.eval.areas[areaKey]?.style
30
- ],
31
- id: `ar-${block.blockId}-${areaKey}`,
32
- key: `ar-${block.blockId}-${areaKey}-${i}`,
33
- layout: block.eval.layout,
34
- makeCssClass: makeCssClass
35
- }, areas[areaKey].blocks.map((bl, k)=>/*#__PURE__*/ React.createElement(Block, {
24
+ const slots = Blocks.subSlots[block.id][0].slots;
25
+ Object.keys(slots).forEach((slotKey, i)=>{
26
+ content[slotKey] = (contentStyle)=>/*#__PURE__*/ React.createElement(Area, {
27
+ area: block.eval.slots[slotKey],
28
+ areaKey: slotKey,
29
+ style: {
30
+ ...block.eval.slots[slotKey]?.style,
31
+ ...contentStyle
32
+ },
33
+ className: cn(block.eval.class?.[slotKey]),
34
+ id: `ar-${block.blockId}-${slotKey}`,
35
+ key: `ar-${block.blockId}-${slotKey}-${i}`,
36
+ layout: block.eval.layout
37
+ }, slots[slotKey].blocks.map((bl, k)=>/*#__PURE__*/ React.createElement(Block, {
36
38
  block: bl,
37
- Blocks: Blocks.subAreas[block.id][0],
39
+ Blocks: Blocks.subSlots[block.id][0],
38
40
  context: context,
39
41
  key: `co-${bl.blockId}-${k}`,
40
42
  lowdefy: lowdefy,
@@ -42,28 +44,29 @@ const Container = ({ block, Blocks, Component, context, loading, lowdefy })=>{
42
44
  })));
43
45
  });
44
46
  return /*#__PURE__*/ React.createElement(BlockLayout, {
45
- blockStyle: block.eval.style,
47
+ style: block.eval.style?.block,
48
+ className: classNames.block,
46
49
  id: `bl-${block.blockId}`,
47
- layout: block.eval.layout,
48
- makeCssClass: makeCssClass
50
+ layout: block.eval.layout
49
51
  }, /*#__PURE__*/ React.createElement(Component, {
50
52
  methods: Object.assign(block.methods, {
51
- makeCssClass,
52
53
  registerEvent: block.registerEvent,
53
54
  registerMethod: block.registerMethod,
54
55
  triggerEvent: block.triggerEvent
55
56
  }),
56
57
  basePath: lowdefy.basePath,
57
58
  blockId: block.blockId,
59
+ classNames: classNames,
58
60
  components: lowdefy._internal.components,
59
61
  content: content,
60
- events: block.eval.events,
62
+ events: block.eval.events ?? {},
61
63
  key: block.blockId,
62
64
  loading: loading,
63
65
  menus: lowdefy.menus,
64
66
  pageId: lowdefy.pageId,
65
67
  properties: block.eval.properties,
66
68
  required: block.eval.required,
69
+ styles: block.eval.style ?? {},
67
70
  validation: block.eval.validation
68
71
  }));
69
72
  };
@@ -14,27 +14,29 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  import { Area, BlockLayout } from '@lowdefy/layout';
17
- import { makeCssClass } from '@lowdefy/block-utils';
17
+ import { cn } from '@lowdefy/block-utils';
18
18
  import Block from './Block.js';
19
+ import resolveClassNames from './resolveClassNames.js';
19
20
  const InputContainer = ({ block, Blocks, Component, context, loading, lowdefy })=>{
21
+ const classNames = resolveClassNames(block.eval.class);
20
22
  const content = {};
21
23
  // eslint-disable-next-line prefer-destructuring
22
- const areas = Blocks.subAreas[block.id][0].areas;
23
- Object.keys(areas).forEach((areaKey, i)=>{
24
- content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
- area: block.eval.areas[areaKey],
26
- areaKey: areaKey,
27
- areaStyle: [
28
- areaStyle,
29
- block.eval.areas[areaKey]?.style
30
- ],
31
- id: `ar-${block.blockId}-${areaKey}`,
32
- key: `ar-${block.blockId}-${areaKey}-${i}`,
33
- layout: block.eval.layout,
34
- makeCssClass: makeCssClass
35
- }, areas[areaKey].blocks.map((bl, k)=>/*#__PURE__*/ React.createElement(Block, {
24
+ const slots = Blocks.subSlots[block.id][0].slots;
25
+ Object.keys(slots).forEach((slotKey, i)=>{
26
+ content[slotKey] = (contentStyle)=>/*#__PURE__*/ React.createElement(Area, {
27
+ area: block.eval.slots[slotKey],
28
+ areaKey: slotKey,
29
+ style: {
30
+ ...block.eval.slots[slotKey]?.style,
31
+ ...contentStyle
32
+ },
33
+ className: cn(block.eval.class?.[slotKey]),
34
+ id: `ar-${block.blockId}-${slotKey}`,
35
+ key: `ar-${block.blockId}-${slotKey}-${i}`,
36
+ layout: block.eval.layout
37
+ }, slots[slotKey].blocks.map((bl, k)=>/*#__PURE__*/ React.createElement(Block, {
36
38
  block: bl,
37
- Blocks: Blocks.subAreas[block.id][0],
39
+ Blocks: Blocks.subSlots[block.id][0],
38
40
  context: context,
39
41
  key: `co-${bl.blockId}-${k}`,
40
42
  lowdefy: lowdefy,
@@ -42,13 +44,12 @@ const InputContainer = ({ block, Blocks, Component, context, loading, lowdefy })
42
44
  })));
43
45
  });
44
46
  return /*#__PURE__*/ React.createElement(BlockLayout, {
45
- blockStyle: block.eval.style,
47
+ style: block.eval.style?.block,
48
+ className: classNames.block,
46
49
  id: `bl-${block.blockId}`,
47
- layout: block.eval.layout,
48
- makeCssClass: makeCssClass
50
+ layout: block.eval.layout
49
51
  }, /*#__PURE__*/ React.createElement(Component, {
50
52
  methods: Object.assign(block.methods, {
51
- makeCssClass,
52
53
  registerEvent: block.registerEvent,
53
54
  registerMethod: block.registerMethod,
54
55
  triggerEvent: block.triggerEvent,
@@ -61,15 +62,17 @@ const InputContainer = ({ block, Blocks, Component, context, loading, lowdefy })
61
62
  }),
62
63
  basePath: lowdefy.basePath,
63
64
  blockId: block.blockId,
65
+ classNames: classNames,
64
66
  components: lowdefy._internal.components,
65
67
  content: content,
66
- events: block.eval.events,
68
+ events: block.eval.events ?? {},
67
69
  key: block.blockId,
68
70
  loading: loading,
69
71
  menus: lowdefy.menus,
70
72
  pageId: lowdefy.pageId,
71
73
  properties: block.eval.properties,
72
74
  required: block.eval.required,
75
+ styles: block.eval.style ?? {},
73
76
  validation: block.eval.validation,
74
77
  value: block.value
75
78
  }));
@@ -14,25 +14,27 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  import { Area, BlockLayout } from '@lowdefy/layout';
17
- import { makeCssClass } from '@lowdefy/block-utils';
17
+ import { cn } from '@lowdefy/block-utils';
18
18
  import Block from './Block.js';
19
+ import resolveClassNames from './resolveClassNames.js';
19
20
  const List = ({ block, Blocks, Component, context, loading, lowdefy })=>{
21
+ const classNames = resolveClassNames(block.eval.class);
20
22
  const content = {};
21
23
  const contentList = [];
22
- Blocks.subAreas[block.id].forEach((SBlock)=>{
23
- Object.keys(SBlock.areas).forEach((areaKey)=>{
24
- content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
- area: block.eval.areas[areaKey],
26
- areaKey: areaKey,
27
- areaStyle: [
28
- areaStyle,
29
- block.eval.areas[areaKey]?.style
30
- ],
31
- id: `ar-${block.blockId}-${SBlock.id}-${areaKey}`,
32
- key: `ar-${block.blockId}-${SBlock.id}-${areaKey}`,
33
- layout: block.eval.layout,
34
- makeCssClass: makeCssClass
35
- }, SBlock.areas[areaKey].blocks.map((bl)=>/*#__PURE__*/ React.createElement(Block, {
24
+ Blocks.subSlots[block.id].forEach((SBlock)=>{
25
+ Object.keys(SBlock.slots).forEach((slotKey)=>{
26
+ content[slotKey] = (contentStyle)=>/*#__PURE__*/ React.createElement(Area, {
27
+ area: block.eval.slots[slotKey],
28
+ areaKey: slotKey,
29
+ style: {
30
+ ...block.eval.slots[slotKey]?.style,
31
+ ...contentStyle
32
+ },
33
+ className: cn(block.eval.class?.[slotKey]),
34
+ id: `ar-${block.blockId}-${SBlock.id}-${slotKey}`,
35
+ key: `ar-${block.blockId}-${SBlock.id}-${slotKey}`,
36
+ layout: block.eval.layout
37
+ }, SBlock.slots[slotKey].blocks.map((bl)=>/*#__PURE__*/ React.createElement(Block, {
36
38
  block: bl,
37
39
  Blocks: SBlock,
38
40
  context: context,
@@ -46,13 +48,12 @@ const List = ({ block, Blocks, Component, context, loading, lowdefy })=>{
46
48
  });
47
49
  });
48
50
  return /*#__PURE__*/ React.createElement(BlockLayout, {
49
- blockStyle: block.eval.style,
51
+ style: block.eval.style?.block,
52
+ className: classNames.block,
50
53
  id: `bl-${block.blockId}`,
51
- layout: block.eval.layout,
52
- makeCssClass: makeCssClass
54
+ layout: block.eval.layout
53
55
  }, /*#__PURE__*/ React.createElement(Component, {
54
56
  methods: Object.assign(block.methods, {
55
- makeCssClass,
56
57
  moveItemDown: block.moveItemDown,
57
58
  moveItemUp: block.moveItemUp,
58
59
  pushItem: block.pushItem,
@@ -64,8 +65,9 @@ const List = ({ block, Blocks, Component, context, loading, lowdefy })=>{
64
65
  }),
65
66
  basePath: lowdefy.basePath,
66
67
  blockId: block.blockId,
68
+ classNames: classNames,
67
69
  components: lowdefy._internal.components,
68
- events: block.eval.events,
70
+ events: block.eval.events ?? {},
69
71
  key: block.blockId,
70
72
  list: contentList,
71
73
  loading: loading,
@@ -73,6 +75,7 @@ const List = ({ block, Blocks, Component, context, loading, lowdefy })=>{
73
75
  pageId: lowdefy.pageId,
74
76
  properties: block.eval.properties,
75
77
  required: block.eval.required,
78
+ styles: block.eval.style ?? {},
76
79
  validation: block.eval.validation
77
80
  }));
78
81
  };
@@ -14,11 +14,9 @@
14
14
  limitations under the License.
15
15
  */ import React, { useEffect } from 'react';
16
16
  import { BlockLayout } from '@lowdefy/layout';
17
- import { makeCssClass } from '@lowdefy/block-utils';
18
17
  import LoadingContainer from './LoadingContainer.js';
19
18
  import LoadingList from './LoadingList.js';
20
19
  const blockMethods = {
21
- makeCssClass,
22
20
  moveItemDown: ()=>{},
23
21
  moveItemUp: ()=>{},
24
22
  pushItem: ()=>{},
@@ -29,7 +27,7 @@ const blockMethods = {
29
27
  triggerEvent: ()=>{},
30
28
  unshiftItem: ()=>{}
31
29
  };
32
- const LoadingBlock = ({ blockId, blockLayout, blockProperties, blockStyle, context, lowdefy, skeleton })=>{
30
+ const LoadingBlock = ({ blockClass, blockId, blockLayout, blockProperties, blockStyle, context, lowdefy, skeleton })=>{
33
31
  let Component = lowdefy._internal.blockComponents[skeleton.type];
34
32
  useEffect(()=>{
35
33
  if (!lowdefy._internal.blockComponents[skeleton.type]) {
@@ -41,7 +39,9 @@ const LoadingBlock = ({ blockId, blockLayout, blockProperties, blockStyle, conte
41
39
  // default to box when a skeleton block is not found - should be a basic or loader block.
42
40
  Component = lowdefy._internal.blockComponents.Box;
43
41
  }
44
- switch(Component.meta.category){
42
+ const resolvedType = Component === lowdefy._internal.blockComponents.Box ? 'Box' : skeleton.type;
43
+ const category = lowdefy._internal.blockMetas[resolvedType]?.category;
44
+ switch(category){
45
45
  case 'list':
46
46
  return /*#__PURE__*/ React.createElement(LoadingList, {
47
47
  blockId: blockId,
@@ -52,6 +52,7 @@ const LoadingBlock = ({ blockId, blockLayout, blockProperties, blockStyle, conte
52
52
  });
53
53
  case 'container':
54
54
  return /*#__PURE__*/ React.createElement(LoadingContainer, {
55
+ blockClass: blockClass,
55
56
  blockId: blockId,
56
57
  blockLayout: blockLayout,
57
58
  blockProperties: blockProperties,
@@ -63,10 +64,10 @@ const LoadingBlock = ({ blockId, blockLayout, blockProperties, blockStyle, conte
63
64
  });
64
65
  default:
65
66
  return /*#__PURE__*/ React.createElement(BlockLayout, {
66
- blockStyle: skeleton.style ?? blockStyle,
67
+ style: skeleton.style ?? blockStyle,
67
68
  id: `s-bl-${blockId}-${skeleton.id}`,
68
69
  layout: skeleton.layout ?? blockLayout,
69
- makeCssClass: makeCssClass
70
+ className: skeleton.class ?? blockClass
70
71
  }, /*#__PURE__*/ React.createElement(Component, {
71
72
  basePath: lowdefy.basePath,
72
73
  blockId: blockId,
@@ -14,24 +14,19 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  import { Area, BlockLayout } from '@lowdefy/layout';
17
- import { makeCssClass } from '@lowdefy/block-utils';
18
17
  import LoadingBlock from './LoadingBlock.js';
19
- const LoadingContainer = ({ blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
18
+ const LoadingContainer = ({ blockClass, blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
20
19
  const content = {};
21
20
  // eslint-disable-next-line prefer-destructuring
22
- Object.keys(skeleton.areas).forEach((areaKey, i)=>{
23
- content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
24
- area: skeleton.areas[areaKey],
25
- areaKey: areaKey,
26
- areaStyle: [
27
- areaStyle,
28
- skeleton.areas[areaKey]?.style
29
- ],
30
- id: `s-ar-${blockId}-${skeleton.id}-${areaKey}`,
31
- key: `s-ar-${blockId}-${skeleton.id}-${areaKey}-${i}`,
32
- layout: skeleton.layout ?? blockLayout,
33
- makeCssClass: makeCssClass
34
- }, skeleton.areas[areaKey].blocks.map((skl, k)=>/*#__PURE__*/ React.createElement(LoadingBlock, {
21
+ Object.keys(skeleton.slots).forEach((slotKey, i)=>{
22
+ content[slotKey] = ()=>/*#__PURE__*/ React.createElement(Area, {
23
+ area: skeleton.slots[slotKey],
24
+ areaKey: slotKey,
25
+ style: skeleton.slots[slotKey]?.style,
26
+ id: `s-ar-${blockId}-${skeleton.id}-${slotKey}`,
27
+ key: `s-ar-${blockId}-${skeleton.id}-${slotKey}-${i}`,
28
+ layout: skeleton.layout ?? blockLayout
29
+ }, skeleton.slots[slotKey].blocks.map((skl, k)=>/*#__PURE__*/ React.createElement(LoadingBlock, {
35
30
  blockId: blockId,
36
31
  context: context,
37
32
  key: `s-co-${skl.id}-${k}`,
@@ -40,10 +35,10 @@ const LoadingContainer = ({ blockId, blockLayout, blockProperties, blockStyle, C
40
35
  })));
41
36
  });
42
37
  return /*#__PURE__*/ React.createElement(BlockLayout, {
43
- blockStyle: skeleton.style ?? blockStyle,
38
+ style: skeleton.style ?? blockStyle,
44
39
  id: `s-bl-${blockId}-${skeleton.id}`,
45
40
  layout: skeleton.layout ?? blockLayout,
46
- makeCssClass: makeCssClass
41
+ className: skeleton.class ?? blockClass
47
42
  }, /*#__PURE__*/ React.createElement(Component, {
48
43
  basePath: lowdefy.basePath,
49
44
  blockId: blockId,
@@ -51,9 +46,7 @@ const LoadingContainer = ({ blockId, blockLayout, blockProperties, blockStyle, C
51
46
  content: content,
52
47
  key: skeleton.id,
53
48
  menus: lowdefy.menus,
54
- methods: {
55
- makeCssClass
56
- },
49
+ methods: {},
57
50
  pageId: lowdefy.pageId,
58
51
  properties: skeleton.properties ?? blockProperties
59
52
  }));
@@ -14,25 +14,20 @@
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
16
  import { Area, BlockLayout } from '@lowdefy/layout';
17
- import { makeCssClass } from '@lowdefy/block-utils';
18
17
  import LoadingBlock from './LoadingBlock.js';
19
- const LoadingList = ({ blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
18
+ const LoadingList = ({ blockClass, blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
20
19
  const content = {};
21
20
  const contentList = [];
22
21
  new Array(3).forEach(()=>{
23
- Object.keys(skeleton.areas).forEach((areaKey, i)=>{
24
- content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
- area: skeleton.areas[areaKey],
26
- areaKey: areaKey,
27
- areaStyle: [
28
- areaStyle,
29
- skeleton.areas[areaKey]?.style
30
- ],
31
- id: `s-ar-${blockId}-${skeleton.id}-${areaKey}`,
32
- key: `s-ar-${blockId}-${skeleton.id}-${areaKey}-${i}`,
33
- layout: skeleton.layout ?? blockLayout,
34
- makeCssClass: makeCssClass
35
- }, skeleton.areas[areaKey].blocks.map((skl, k)=>/*#__PURE__*/ React.createElement(LoadingBlock, {
22
+ Object.keys(skeleton.slots).forEach((slotKey, i)=>{
23
+ content[slotKey] = ()=>/*#__PURE__*/ React.createElement(Area, {
24
+ area: skeleton.slots[slotKey],
25
+ areaKey: slotKey,
26
+ style: skeleton.slots[slotKey]?.style,
27
+ id: `s-ar-${blockId}-${skeleton.id}-${slotKey}`,
28
+ key: `s-ar-${blockId}-${skeleton.id}-${slotKey}-${i}`,
29
+ layout: skeleton.layout ?? blockLayout
30
+ }, skeleton.slots[slotKey].blocks.map((skl, k)=>/*#__PURE__*/ React.createElement(LoadingBlock, {
36
31
  blockId: blockId,
37
32
  context: context,
38
33
  key: `s-co-${skl.id}-${k}`,
@@ -45,19 +40,17 @@ const LoadingList = ({ blockId, blockLayout, blockProperties, blockStyle, Compon
45
40
  });
46
41
  });
47
42
  return /*#__PURE__*/ React.createElement(BlockLayout, {
48
- blockStyle: skeleton.style ?? blockStyle,
43
+ style: skeleton.style ?? blockStyle,
49
44
  id: `s-bl-${blockId}-${skeleton.id}`,
50
45
  layout: skeleton.layout ?? blockLayout,
51
- makeCssClass: makeCssClass
46
+ className: skeleton.class ?? blockClass
52
47
  }, /*#__PURE__*/ React.createElement(Component, {
53
48
  basePath: lowdefy.basePath,
54
49
  blockId: blockId,
55
50
  components: lowdefy._internal.components,
56
51
  list: contentList,
57
52
  menus: lowdefy.menus,
58
- methods: {
59
- makeCssClass
60
- },
53
+ methods: {},
61
54
  pageId: lowdefy.pageId,
62
55
  properties: skeleton.properties ?? blockProperties
63
56
  }));
@@ -12,18 +12,13 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */
16
-
17
- .icon-spin {
18
- animation: spin 1s infinite linear;
19
- }
20
-
21
- @keyframes spin {
22
- 0% {
23
- transform: rotate(0deg);
24
- }
25
-
26
- 100% {
27
- transform: rotate(360deg);
28
- }
15
+ */ import { cn } from '@lowdefy/block-utils';
16
+ function resolveClassNames(evalClass) {
17
+ if (!evalClass) return {};
18
+ const resolved = {};
19
+ for (const [key, value] of Object.entries(evalClass)){
20
+ resolved[key] = cn(value);
21
+ }
22
+ return resolved;
29
23
  }
24
+ export default resolveClassNames;
@@ -17,6 +17,12 @@ import { serializer } from '@lowdefy/helpers';
17
17
  function createHandleError(lowdefy) {
18
18
  const loggedErrors = new Set();
19
19
  const logger = lowdefy._internal.logger;
20
+ function logError(error) {
21
+ if (!(error instanceof UserError)) {
22
+ lowdefy._runtimeErrorCallback?.(error);
23
+ }
24
+ logger.error(error);
25
+ }
20
26
  return async function handleError(error) {
21
27
  const errorKey = `${error.message}:${error.configKey || ''}`;
22
28
  if (loggedErrors.has(errorKey)) {
@@ -25,14 +31,14 @@ function createHandleError(lowdefy) {
25
31
  loggedErrors.add(errorKey);
26
32
  // UserError is client-only — log to browser console, never send to server
27
33
  if (error instanceof UserError) {
28
- logger.error(error);
34
+ logError(error);
29
35
  return;
30
36
  }
31
37
  // Send known error types to server for logging with location resolution
32
38
  if (error.isLowdefyError) {
33
39
  // Server-originated errors already have source resolved — just display locally
34
40
  if (error.source) {
35
- logger.error(error);
41
+ logError(error);
36
42
  return;
37
43
  }
38
44
  // Client-originated errors — send to server for logging + location resolution
@@ -54,18 +60,18 @@ function createHandleError(lowdefy) {
54
60
  // If server produced a consolidated ConfigError, log it and return early
55
61
  // (cause chain includes original error)
56
62
  if (serializedConfigError) {
57
- logger.error(serializer.deserialize(serializedConfigError));
63
+ logError(serializer.deserialize(serializedConfigError));
58
64
  return;
59
65
  }
60
66
  }
61
67
  } catch {
62
68
  // Server logging failed - continue with local console
63
69
  }
64
- logger.error(error);
70
+ logError(error);
65
71
  return;
66
72
  }
67
73
  // Other errors - just log locally
68
- logger.error(error);
74
+ logError(error);
69
75
  };
70
76
  }
71
77
  export default createHandleError;
@@ -13,10 +13,10 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
- import classNames from 'classnames';
17
16
  import { omit, type } from '@lowdefy/helpers';
18
17
  import Icon from '@ant-design/icons';
19
- import { blockDefaultProps, ErrorBoundary, makeCssClass } from '@lowdefy/block-utils';
18
+ import { cn, withBlockDefaults, ErrorBoundary } from '@lowdefy/block-utils';
19
+ import iconStyles from './style.module.css';
20
20
  const lowdefyProps = [
21
21
  'actionLog',
22
22
  'basePath',
@@ -30,6 +30,7 @@ const lowdefyProps = [
30
30
  'registerEvent',
31
31
  'registerMethod',
32
32
  'schemaErrors',
33
+ 'styles',
33
34
  'validation'
34
35
  ];
35
36
  const createIcon = (Icons)=>{
@@ -42,22 +43,20 @@ const createIcon = (Icons)=>{
42
43
  let spacedTitle = title.replace(/([A-Z])/g, ' $1').trim();
43
44
  return spacedTitle.substring(spacedTitle.indexOf(' ') + 1);
44
45
  };
45
- const IconBlock = ({ blockId, events, methods, onClick, properties, ...props })=>{
46
+ const IconBlock = ({ blockId, classNames = {}, events, methods, onClick, properties, styles = {}, ...props })=>{
46
47
  const propertiesObj = type.isString(properties) ? {
47
48
  name: properties
48
49
  } : properties;
49
50
  const spin = (propertiesObj.spin || events.onClick?.loading) && !propertiesObj.disableLoadingIcon;
50
51
  const iconProps = {
51
52
  id: blockId,
52
- className: classNames({
53
- [makeCssClass([
54
- {
55
- cursor: (onClick || events.onClick) && 'pointer'
56
- },
57
- propertiesObj.style
58
- ])]: true,
59
- 'icon-spin': spin
53
+ className: cn(classNames.element, {
54
+ [iconStyles['icon-spin']]: spin
60
55
  }),
56
+ style: {
57
+ cursor: onClick || events.onClick ? 'pointer' : undefined,
58
+ ...styles.element
59
+ },
61
60
  rotate: propertiesObj.rotate,
62
61
  color: propertiesObj.color,
63
62
  title: propertiesObj.title ?? formatTitle(propertiesObj.name),
@@ -87,7 +86,6 @@ const createIcon = (Icons)=>{
87
86
  const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
88
87
  component: ()=>/*#__PURE__*/ React.createElement(IconBlock, all)
89
88
  });
90
- AntIcon.defaultProps = blockDefaultProps;
91
- return AntIcon;
89
+ return withBlockDefaults(AntIcon);
92
90
  };
93
91
  export default createIcon;
@@ -0,0 +1,113 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import React from 'react';
16
+ import styles from './style.module.css';
17
+ const SPECIAL_KEY_DISPLAY = {
18
+ Escape: 'Esc',
19
+ Enter: '↵',
20
+ Backspace: '⌫',
21
+ Delete: '⌦',
22
+ ArrowUp: '↑',
23
+ ArrowDown: '↓',
24
+ ArrowLeft: '←',
25
+ ArrowRight: '→',
26
+ Tab: '⇥',
27
+ Space: '␣'
28
+ };
29
+ const MAC_MODIFIERS = {
30
+ mod: '⌘',
31
+ shift: '⇧',
32
+ alt: '⌥',
33
+ ctrl: '⌃'
34
+ };
35
+ const WIN_MODIFIERS = {
36
+ mod: 'Ctrl',
37
+ shift: 'Shift',
38
+ alt: 'Alt',
39
+ ctrl: 'Ctrl'
40
+ };
41
+ let isMacCached = null;
42
+ function isMac() {
43
+ if (isMacCached !== null) return isMacCached;
44
+ if (typeof navigator !== 'undefined') {
45
+ isMacCached = navigator.userAgentData?.platform === 'macOS' || /Mac|iPhone|iPad|iPod/.test(navigator.platform ?? '');
46
+ } else {
47
+ isMacCached = false;
48
+ }
49
+ return isMacCached;
50
+ }
51
+ function parseShortcut(shortcut) {
52
+ // Sequence: "g i" → ["G", "then", "I"]
53
+ if (shortcut.includes(' ') && !shortcut.includes('+')) {
54
+ const parts = shortcut.split(' ');
55
+ const result = [];
56
+ parts.forEach((part, i)=>{
57
+ if (i > 0) result.push('then');
58
+ result.push(displayKey(part));
59
+ });
60
+ return result;
61
+ }
62
+ if (shortcut.includes(' ')) {
63
+ // Sequence with modifiers: "mod+G mod+I"
64
+ const parts = shortcut.split(' ');
65
+ const result = [];
66
+ parts.forEach((part, i)=>{
67
+ if (i > 0) result.push('then');
68
+ result.push(...parsePart(part));
69
+ });
70
+ return result;
71
+ }
72
+ return parsePart(shortcut);
73
+ }
74
+ function parsePart(part) {
75
+ const segments = part.split('+');
76
+ if (segments.length === 1) {
77
+ return [
78
+ displayKey(segments[0])
79
+ ];
80
+ }
81
+ const key = segments[segments.length - 1];
82
+ const modifiers = segments.slice(0, -1);
83
+ const modMap = isMac() ? MAC_MODIFIERS : WIN_MODIFIERS;
84
+ const result = modifiers.map((mod)=>modMap[mod.toLowerCase()] || mod);
85
+ result.push(displayKey(key));
86
+ return [
87
+ result.join('\u2009')
88
+ ];
89
+ }
90
+ function displayKey(key) {
91
+ if (SPECIAL_KEY_DISPLAY[key]) return SPECIAL_KEY_DISPLAY[key];
92
+ if (key.length === 1) return key.toUpperCase();
93
+ return key;
94
+ }
95
+ function createShortcutBadge() {
96
+ function ShortcutBadge({ shortcut }) {
97
+ if (!shortcut) return null;
98
+ const primary = Array.isArray(shortcut) ? shortcut[0] : shortcut;
99
+ if (!primary) return null;
100
+ const segments = parseShortcut(primary);
101
+ return /*#__PURE__*/ React.createElement("span", {
102
+ className: styles['shortcut-badge']
103
+ }, segments.map((segment, i)=>segment === 'then' ? /*#__PURE__*/ React.createElement("span", {
104
+ key: i,
105
+ className: styles['shortcut-then']
106
+ }, "then") : /*#__PURE__*/ React.createElement("kbd", {
107
+ key: i,
108
+ className: styles['shortcut-kbd']
109
+ }, segment)));
110
+ }
111
+ return ShortcutBadge;
112
+ }
113
+ export default createShortcutBadge;
@@ -0,0 +1,135 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { tinykeys } from 'tinykeys';
16
+ const SPECIAL_KEYS = new Set([
17
+ 'Escape',
18
+ 'Enter',
19
+ 'Backspace',
20
+ 'Delete',
21
+ 'ArrowUp',
22
+ 'ArrowDown',
23
+ 'ArrowLeft',
24
+ 'ArrowRight',
25
+ 'Tab',
26
+ 'Space'
27
+ ]);
28
+ const MODIFIER_MAP = {
29
+ mod: '$mod',
30
+ alt: 'Alt',
31
+ shift: 'Shift',
32
+ ctrl: 'Control'
33
+ };
34
+ const MODIFIER_VALUES = new Set([
35
+ '$mod',
36
+ 'Alt',
37
+ 'Shift',
38
+ 'Control'
39
+ ]);
40
+ function normalizeShortcut(shortcut) {
41
+ // Sequences are space-separated parts like "g i"
42
+ if (shortcut.includes(' ') && !shortcut.includes('+')) {
43
+ return shortcut.split(' ').map((part)=>normalizePart(part)).join(' ');
44
+ }
45
+ // Check for sequences that have modifiers: "mod+G mod+I" is invalid in tinykeys,
46
+ // but "g i" (no modifiers) is a sequence. Handle mixed case: split on space.
47
+ if (shortcut.includes(' ')) {
48
+ return shortcut.split(' ').map((part)=>normalizePart(part)).join(' ');
49
+ }
50
+ return normalizePart(shortcut);
51
+ }
52
+ function normalizePart(part) {
53
+ const segments = part.split('+');
54
+ if (segments.length === 1) {
55
+ // Single key, no modifiers
56
+ return normalizeKey(segments[0]);
57
+ }
58
+ const key = segments[segments.length - 1];
59
+ const modifiers = segments.slice(0, -1);
60
+ const normalizedModifiers = modifiers.map((mod)=>MODIFIER_MAP[mod.toLowerCase()] || mod);
61
+ return [
62
+ ...normalizedModifiers,
63
+ normalizeKey(key)
64
+ ].join('+');
65
+ }
66
+ function normalizeKey(key) {
67
+ if (SPECIAL_KEYS.has(key)) return key;
68
+ if (key.length === 1) return key.toLowerCase();
69
+ return key;
70
+ }
71
+ function hasModifier(normalizedShortcut) {
72
+ // Check the first part (for sequences, only first part matters for suppression)
73
+ const firstPart = normalizedShortcut.split(' ')[0];
74
+ return firstPart.split('+').some((segment)=>MODIFIER_VALUES.has(segment));
75
+ }
76
+ function collectShortcuts(context) {
77
+ const entries = [];
78
+ const blockMap = context._internal.RootSlots.map;
79
+ Object.values(blockMap).forEach((block)=>{
80
+ if (!block.Events || !block.Events.events) return;
81
+ Object.entries(block.Events.events).forEach(([eventName, event])=>{
82
+ if (!event.shortcut) return;
83
+ const shortcuts = Array.isArray(event.shortcut) ? event.shortcut : [
84
+ event.shortcut
85
+ ];
86
+ shortcuts.forEach((s)=>entries.push({
87
+ block,
88
+ eventName,
89
+ shortcut: s
90
+ }));
91
+ });
92
+ });
93
+ return entries;
94
+ }
95
+ function createShortcutManager() {
96
+ let unsubscribe = null;
97
+ function init(context) {
98
+ const entries = collectShortcuts(context);
99
+ if (entries.length === 0) return;
100
+ const shortcutMap = {};
101
+ // Last entry wins for duplicates
102
+ entries.forEach(({ block, eventName, shortcut })=>{
103
+ const normalized = normalizeShortcut(shortcut);
104
+ const modded = hasModifier(normalized);
105
+ shortcutMap[normalized] = (event)=>{
106
+ // Visibility gating
107
+ if (block.visibleEval && block.visibleEval.output === false) return;
108
+ // Input field suppression for non-modifier shortcuts
109
+ if (!modded) {
110
+ const tag = event.target?.tagName;
111
+ if (tag === 'INPUT' || tag === 'TEXTAREA' || event.target?.isContentEditable) {
112
+ return;
113
+ }
114
+ }
115
+ event.preventDefault();
116
+ block.triggerEvent({
117
+ name: eventName
118
+ });
119
+ };
120
+ });
121
+ const win = context._internal.lowdefy._internal.globals.window;
122
+ unsubscribe = tinykeys(win, shortcutMap);
123
+ }
124
+ function destroy() {
125
+ if (unsubscribe) {
126
+ unsubscribe();
127
+ unsubscribe = null;
128
+ }
129
+ }
130
+ return {
131
+ init,
132
+ destroy
133
+ };
134
+ }
135
+ export default createShortcutManager;
package/dist/index.js CHANGED
@@ -14,3 +14,4 @@
14
14
  limitations under the License.
15
15
  */ import Client from './Client.js';
16
16
  export default Client;
17
+ export { default as useDarkMode } from './useDarkMode.js';
@@ -16,6 +16,7 @@
16
16
  import createAuthMethods from './auth/createAuthMethods.js';
17
17
  import createCallRequest from './createCallRequest.js';
18
18
  import createIcon from './createIcon.js';
19
+ import createShortcutBadge from './createShortcutBadge.js';
19
20
  import createLinkComponent from './createLinkComponent.js';
20
21
  import createHandleError from './createHandleError.js';
21
22
  import { createBrowserLogger } from '@lowdefy/logger/browser';
@@ -25,8 +26,10 @@ function initLowdefyContext({ auth, Components, config, lowdefy, router, stage,
25
26
  lowdefy._internal = {
26
27
  actions: types.actions,
27
28
  blockComponents: types.blocks,
29
+ blockMetas: types.blockMetas ?? {},
28
30
  components: {
29
- Icon: createIcon(types.icons)
31
+ Icon: createIcon(types.icons),
32
+ ShortcutBadge: createShortcutBadge()
30
33
  },
31
34
  displayMessage: ({ content })=>{
32
35
  console.log(content);
@@ -54,6 +57,7 @@ function initLowdefyContext({ auth, Components, config, lowdefy, router, stage,
54
57
  lowdefy.contexts = {};
55
58
  lowdefy.inputs = {};
56
59
  lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
60
+ lowdefy.theme = config.rootConfig.theme ?? {};
57
61
  lowdefy._internal.callAPI = createCallAPI(lowdefy);
58
62
  lowdefy._internal.auth = createAuthMethods(lowdefy, auth);
59
63
  lowdefy._internal.callRequest = createCallRequest(lowdefy);
@@ -62,6 +66,7 @@ function initLowdefyContext({ auth, Components, config, lowdefy, router, stage,
62
66
  lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
63
67
  lowdefy._internal.logger = createBrowserLogger();
64
68
  lowdefy._internal.handleError = createHandleError(lowdefy);
69
+ lowdefy._internal.components.handleError = lowdefy._internal.handleError;
65
70
  if (stage === 'dev' || stage === 'e2e') {
66
71
  window.lowdefy = lowdefy;
67
72
  }
@@ -0,0 +1,70 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ @layer components {
18
+ .icon-spin {
19
+ animation: spin 1s infinite linear;
20
+ }
21
+
22
+ @keyframes spin {
23
+ 0% {
24
+ transform: rotate(0deg);
25
+ }
26
+
27
+ 100% {
28
+ transform: rotate(360deg);
29
+ }
30
+ }
31
+
32
+ .shortcut-badge {
33
+ display: inline-flex;
34
+ align-items: center;
35
+ gap: 2px;
36
+ margin-left: var(--ant-margin-xs);
37
+ font-size: calc(var(--ant-font-size-sm) - 1px);
38
+ line-height: 1;
39
+ vertical-align: middle;
40
+ }
41
+
42
+ .shortcut-kbd {
43
+ display: inline-block;
44
+ padding: 2px 5px;
45
+ font-size: calc(var(--ant-font-size-sm) - 1px);
46
+ font-family:
47
+ system-ui,
48
+ -apple-system,
49
+ sans-serif;
50
+ background-color: var(--ant-color-fill-quaternary);
51
+ border-radius: var(--ant-border-radius-sm);
52
+ border: 1px solid var(--ant-color-border);
53
+ }
54
+
55
+ .shortcut-kbd + .shortcut-kbd {
56
+ border-left: none;
57
+ border-top-left-radius: 0;
58
+ border-bottom-left-radius: 0;
59
+ }
60
+
61
+ .shortcut-kbd:has(+ .shortcut-kbd) {
62
+ border-top-right-radius: 0;
63
+ border-bottom-right-radius: 0;
64
+ }
65
+
66
+ .shortcut-then {
67
+ margin: 0 2px;
68
+ font-size: calc(var(--ant-font-size-sm) - 2px);
69
+ }
70
+ }
@@ -0,0 +1,84 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { useCallback, useEffect, useState } from 'react';
16
+ import { theme as antdTheme } from 'antd';
17
+ const algorithmMap = {
18
+ default: antdTheme.defaultAlgorithm,
19
+ dark: antdTheme.darkAlgorithm,
20
+ compact: antdTheme.compactAlgorithm
21
+ };
22
+ function resolveAlgorithm(algorithm) {
23
+ if (Array.isArray(algorithm)) {
24
+ return algorithm.map((a)=>algorithmMap[a] || antdTheme.defaultAlgorithm);
25
+ }
26
+ return algorithmMap[algorithm] || antdTheme.defaultAlgorithm;
27
+ }
28
+ function stripDarkFromAlgorithm(algorithm) {
29
+ if (Array.isArray(algorithm)) {
30
+ const filtered = algorithm.filter((a)=>a !== 'dark');
31
+ return filtered.length > 0 ? filtered : 'default';
32
+ }
33
+ if (algorithm === 'dark') return 'default';
34
+ return algorithm;
35
+ }
36
+ function mergeAlgorithm(baseAlgorithm, isDark) {
37
+ if (!isDark) return baseAlgorithm;
38
+ const base = Array.isArray(baseAlgorithm) ? baseAlgorithm : baseAlgorithm ? [
39
+ baseAlgorithm
40
+ ] : [];
41
+ return [
42
+ ...base,
43
+ 'dark'
44
+ ];
45
+ }
46
+ function resolveIsDark({ configDarkMode, userPreference, systemIsDark }) {
47
+ if (configDarkMode === 'dark') return true;
48
+ if (configDarkMode === 'light') return false;
49
+ // configDarkMode is 'system' or undefined — user preference decides
50
+ if (userPreference === 'dark') return true;
51
+ if (userPreference === 'light') return false;
52
+ // userPreference is 'system' — follow OS
53
+ return systemIsDark;
54
+ }
55
+ function useDarkMode({ baseAlgorithm, configDarkMode }) {
56
+ const cleanAlgorithm = stripDarkFromAlgorithm(baseAlgorithm);
57
+ const [userPreference, setUserPreference] = useState(()=>{
58
+ return window.localStorage?.getItem('lowdefy_darkMode') ?? 'system';
59
+ });
60
+ const [systemIsDark, setSystemIsDark] = useState(()=>{
61
+ return window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false;
62
+ });
63
+ // Listen for OS theme changes
64
+ useEffect(()=>{
65
+ const mql = window.matchMedia?.('(prefers-color-scheme: dark)');
66
+ if (!mql?.addEventListener) return;
67
+ const handler = (e)=>setSystemIsDark(e.matches);
68
+ mql.addEventListener('change', handler);
69
+ return ()=>mql.removeEventListener('change', handler);
70
+ }, []);
71
+ const setPreference = useCallback((newPref)=>{
72
+ window.localStorage?.setItem('lowdefy_darkMode', newPref);
73
+ setUserPreference(newPref);
74
+ }, []);
75
+ window.__lowdefy_setDarkMode = setPreference;
76
+ const isDark = resolveIsDark({
77
+ configDarkMode,
78
+ userPreference,
79
+ systemIsDark
80
+ });
81
+ window.__lowdefy_isDark = isDark;
82
+ return resolveAlgorithm(mergeAlgorithm(cleanAlgorithm, isDark));
83
+ }
84
+ export default useDarkMode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/client",
3
- "version": "4.7.2",
3
+ "version": "5.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Client",
6
6
  "homepage": "https://lowdefy.com",
@@ -33,24 +33,24 @@
33
33
  "dist/*"
34
34
  ],
35
35
  "dependencies": {
36
- "@ant-design/icons": "4.8.0",
37
- "@lowdefy/block-utils": "4.7.2",
38
- "@lowdefy/engine": "4.7.2",
39
- "@lowdefy/errors": "4.7.2",
40
- "@lowdefy/helpers": "4.7.2",
41
- "@lowdefy/layout": "4.7.2",
42
- "@lowdefy/logger": "4.7.2",
43
- "classnames": "2.3.2",
36
+ "@ant-design/icons": "6.1.0",
37
+ "antd": "6.3.1",
38
+ "@lowdefy/block-utils": "5.0.0",
39
+ "@lowdefy/engine": "5.0.0",
40
+ "@lowdefy/errors": "5.0.0",
41
+ "@lowdefy/helpers": "5.0.0",
42
+ "@lowdefy/layout": "5.0.0",
43
+ "@lowdefy/logger": "5.0.0",
44
44
  "react": "18.2.0",
45
- "react-dom": "18.2.0"
45
+ "react-dom": "18.2.0",
46
+ "tinykeys": "^3.0.0"
46
47
  },
47
48
  "devDependencies": {
48
- "@emotion/jest": "11.10.5",
49
49
  "@jest/globals": "28.1.3",
50
- "@lowdefy/jest-yaml-transform": "4.7.2",
51
- "@swc/cli": "0.1.63",
52
- "@swc/core": "1.3.99",
53
- "@swc/jest": "0.2.29",
50
+ "@lowdefy/jest-yaml-transform": "5.0.0",
51
+ "@swc/cli": "0.8.0",
52
+ "@swc/core": "1.15.18",
53
+ "@swc/jest": "0.2.39",
54
54
  "@testing-library/dom": "8.19.1",
55
55
  "@testing-library/react": "13.4.0",
56
56
  "@testing-library/user-event": "14.4.3",
@@ -63,7 +63,7 @@
63
63
  "access": "public"
64
64
  },
65
65
  "scripts": {
66
- "build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start && pnpm copyfiles",
66
+ "build": "swc src --out-dir dist --config-file ../../.swcrc --cli-config-file ../../.swc-cli.json && pnpm copyfiles",
67
67
  "clean": "rm -rf dist",
68
68
  "copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
69
69
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"