@lowdefy/operators-js 4.7.3 → 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.
@@ -13,12 +13,18 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { getFromObject } from '@lowdefy/operators';
16
+ function getDarkModePreference(window) {
17
+ return window.localStorage?.getItem('lowdefy_darkMode') ?? 'system';
18
+ }
19
+ function getDarkMode(window) {
20
+ return window.__lowdefy_isDark ?? false;
21
+ }
16
22
  const breakpoints = {
17
- xs: 576,
23
+ xs: 640,
18
24
  sm: 768,
19
- md: 992,
20
- lg: 1200,
21
- xl: 1600
25
+ md: 1024,
26
+ lg: 1280,
27
+ xl: 1536
22
28
  };
23
29
  function _media({ arrayIndices, location, params, globals }) {
24
30
  const { window } = globals;
@@ -43,13 +49,15 @@ function _media({ arrayIndices, location, params, globals }) {
43
49
  size = 'xl';
44
50
  break;
45
51
  default:
46
- size = 'xxl';
52
+ size = '2xl';
47
53
  break;
48
54
  }
49
55
  const media = {
50
56
  size,
51
57
  width: window.innerWidth,
52
- height: window.innerHeight
58
+ height: window.innerHeight,
59
+ darkMode: getDarkMode(window),
60
+ darkModePreference: getDarkModePreference(window)
53
61
  };
54
62
  return getFromObject({
55
63
  arrayIndices,
@@ -21,7 +21,9 @@
21
21
  enum: [
22
22
  'size',
23
23
  'width',
24
- 'height'
24
+ 'height',
25
+ 'darkMode',
26
+ 'darkModePreference'
25
27
  ],
26
28
  description: 'Media property to return.'
27
29
  },
@@ -40,7 +42,9 @@
40
42
  enum: [
41
43
  'size',
42
44
  'width',
43
- 'height'
45
+ 'height',
46
+ 'darkMode',
47
+ 'darkModePreference'
44
48
  ],
45
49
  description: 'Media property to return.'
46
50
  },
@@ -12,15 +12,38 @@
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 { getFromArray } from '@lowdefy/operators';
16
- function _menu({ params, menus, location }) {
17
- return getFromArray({
15
+ */ import { getFromArray, getFromObject } from '@lowdefy/operators';
16
+ import { type } from '@lowdefy/helpers';
17
+ function _menu({ params, arrayIndices, menus, location }) {
18
+ // Support dot-path access: _menu: menuId.path.into.links
19
+ if (type.isString(params) && params.includes('.')) {
20
+ const dotIndex = params.indexOf('.');
21
+ const menuId = params.slice(0, dotIndex);
22
+ const path = params.slice(dotIndex + 1);
23
+ const menu = menus.find((item)=>item.menuId === menuId);
24
+ if (!menu) return undefined;
25
+ const links = menu.links ?? [];
26
+ return getFromObject({
27
+ params: path,
28
+ object: links,
29
+ arrayIndices,
30
+ operator: '_menu',
31
+ location
32
+ });
33
+ }
34
+ const result = getFromArray({
18
35
  params,
19
36
  array: menus,
20
37
  key: 'menuId',
21
38
  operator: '_menu',
22
39
  location
23
40
  });
41
+ // When selecting a single menu, return its links array directly.
42
+ // _menu: true and { all: true } return the full menus array (result is an array).
43
+ if (result && !Array.isArray(result)) {
44
+ return result.links ?? [];
45
+ }
46
+ return result;
24
47
  }
25
48
  _menu.dynamic = true;
26
49
  export default _menu;
@@ -0,0 +1,26 @@
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 { getFromObject } from '@lowdefy/operators';
16
+ function _theme({ arrayIndices, location, theme, params }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: theme?._resolvedAntdToken ?? theme?.antd?.token ?? {},
21
+ operator: '_theme',
22
+ params
23
+ });
24
+ }
25
+ _theme.dynamic = true;
26
+ export default _theme;
@@ -411,13 +411,15 @@ const meta = {
411
411
  validTypes: [
412
412
  'date',
413
413
  'null'
414
- ]
414
+ ],
415
+ dynamic: true
415
416
  },
416
417
  __default: {
417
418
  singleArg: true,
418
419
  validTypes: [
419
420
  'number',
420
- 'string'
421
+ 'string',
422
+ 'date'
421
423
  ]
422
424
  }
423
425
  };
@@ -172,6 +172,16 @@ const meta = {
172
172
  'array'
173
173
  ]
174
174
  },
175
+ mod: {
176
+ namedArgs: [
177
+ 'dividend',
178
+ 'divisor'
179
+ ],
180
+ validTypes: [
181
+ 'object',
182
+ 'array'
183
+ ]
184
+ },
175
185
  pow: {
176
186
  namedArgs: [
177
187
  'base',
@@ -259,9 +269,11 @@ const meta = {
259
269
  property: true
260
270
  }
261
271
  };
272
+ const functions = Object.create(Math);
273
+ functions.mod = (a, b)=>a % b;
262
274
  function _math({ params, location, methodName }) {
263
275
  return runClass({
264
- functions: Math,
276
+ functions,
265
277
  location,
266
278
  meta,
267
279
  methodName,
@@ -61,4 +61,5 @@ export { default as _media } from './operators/client/media.js';
61
61
  export { default as _menu } from './operators/client/menu.js';
62
62
  export { default as _request_details } from './operators/client/request_details.js';
63
63
  export { default as _request } from './operators/client/request.js';
64
+ export { default as _theme } from './operators/client/theme.js';
64
65
  export { default as _url_query } from './operators/client/url_query.js';
package/dist/types.js CHANGED
@@ -12,11 +12,104 @@
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 * as client from './operatorsClient.js';
16
- import * as server from './operatorsServer.js';
17
- export default {
15
+ */ export default {
18
16
  operators: {
19
- client: Object.keys(client),
20
- server: Object.keys(server)
17
+ client: [
18
+ '_actions',
19
+ '_and',
20
+ '_api',
21
+ '_args',
22
+ '_array',
23
+ '_base64',
24
+ '_date',
25
+ '_divide',
26
+ '_eq',
27
+ '_event',
28
+ '_event_log',
29
+ '_function',
30
+ '_get',
31
+ '_global',
32
+ '_gt',
33
+ '_gte',
34
+ '_if',
35
+ '_if_none',
36
+ '_index',
37
+ '_input',
38
+ '_intl',
39
+ '_js',
40
+ '_json',
41
+ '_location',
42
+ '_log',
43
+ '_lt',
44
+ '_lte',
45
+ '_math',
46
+ '_media',
47
+ '_menu',
48
+ '_ne',
49
+ '_not',
50
+ '_number',
51
+ '_object',
52
+ '_operator',
53
+ '_or',
54
+ '_product',
55
+ '_random',
56
+ '_regex',
57
+ '_request',
58
+ '_request_details',
59
+ '_state',
60
+ '_string',
61
+ '_subtract',
62
+ '_sum',
63
+ '_switch',
64
+ '_theme',
65
+ '_type',
66
+ '_uri',
67
+ '_url_query',
68
+ '_user'
69
+ ],
70
+ server: [
71
+ '_and',
72
+ '_args',
73
+ '_array',
74
+ '_base64',
75
+ '_date',
76
+ '_divide',
77
+ '_eq',
78
+ '_function',
79
+ '_get',
80
+ '_gt',
81
+ '_gte',
82
+ '_hash',
83
+ '_if',
84
+ '_if_none',
85
+ '_intl',
86
+ '_item',
87
+ '_js',
88
+ '_json',
89
+ '_log',
90
+ '_lt',
91
+ '_lte',
92
+ '_math',
93
+ '_ne',
94
+ '_not',
95
+ '_number',
96
+ '_object',
97
+ '_operator',
98
+ '_or',
99
+ '_payload',
100
+ '_product',
101
+ '_random',
102
+ '_regex',
103
+ '_secret',
104
+ '_state',
105
+ '_step',
106
+ '_string',
107
+ '_subtract',
108
+ '_sum',
109
+ '_switch',
110
+ '_type',
111
+ '_uri',
112
+ '_user'
113
+ ]
21
114
  }
22
115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/operators-js",
3
- "version": "4.7.3",
3
+ "version": "5.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,14 +43,15 @@
43
43
  "dist/*"
44
44
  ],
45
45
  "dependencies": {
46
- "@lowdefy/helpers": "4.7.3",
47
- "@lowdefy/operators": "4.7.3"
46
+ "@lowdefy/helpers": "5.0.0",
47
+ "@lowdefy/operators": "5.0.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@jest/globals": "28.1.3",
51
- "@swc/cli": "0.1.63",
52
- "@swc/core": "1.3.99",
53
- "@swc/jest": "0.2.29",
51
+ "@lowdefy/node-utils": "5.0.0",
52
+ "@swc/cli": "0.8.0",
53
+ "@swc/core": "1.15.18",
54
+ "@swc/jest": "0.2.39",
54
55
  "jest": "28.1.3",
55
56
  "jest-environment-jsdom": "28.1.3"
56
57
  },
@@ -58,7 +59,7 @@
58
59
  "access": "public"
59
60
  },
60
61
  "scripts": {
61
- "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
62
+ "build": "swc src --out-dir dist --config-file ../../../../.swcrc --cli-config-file ../../../../.swc-cli.json --copy-files",
62
63
  "clean": "rm -rf dist",
63
64
  "test": "TZ=UTC node --experimental-vm-modules node_modules/jest/bin/jest.js"
64
65
  }