@object-ui/react 4.0.6 → 4.0.7
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/CHANGELOG.md +34 -0
- package/dist/hooks/useExpression.d.ts +17 -0
- package/dist/hooks/useExpression.js +29 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @object-ui/react
|
|
2
2
|
|
|
3
|
+
## 4.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7c9b85c: Fix compatibility with the framework's normalized Expression envelope format.
|
|
8
|
+
|
|
9
|
+
`@objectstack/spec` now emits predicate (`visible` / `enabled`) and template
|
|
10
|
+
(`titleFormat`) fields as `{ dialect, source }` envelopes instead of bare
|
|
11
|
+
strings. The previous implementation assumed strings and crashed the record
|
|
12
|
+
detail view (`TypeError: titleFormat.replace is not a function`) and printed
|
|
13
|
+
`Failed to evaluate expression: ${[object Object]}` for every action visibility
|
|
14
|
+
predicate.
|
|
15
|
+
- `@object-ui/core`: `ExpressionEvaluator.evaluate` / `evaluateCondition` now
|
|
16
|
+
unwrap Expression envelopes transparently.
|
|
17
|
+
- `@object-ui/react`: new `toPredicateInput()` helper to safely normalize
|
|
18
|
+
`boolean | string | Expression` predicate inputs into the `${expr}` form
|
|
19
|
+
expected by `useCondition`.
|
|
20
|
+
- `@object-ui/components`: `action-bar`, `action-button`, `action-group`,
|
|
21
|
+
`action-icon`, `action-menu` renderers use `toPredicateInput()` instead of
|
|
22
|
+
template-literal interpolation that produced `${[object Object]}`.
|
|
23
|
+
- `@object-ui/plugin-detail`, `@object-ui/plugin-kanban`,
|
|
24
|
+
`@object-ui/plugin-calendar`, `@object-ui/app-shell`,
|
|
25
|
+
`@object-ui/console`: title-format helpers accept both legacy strings and
|
|
26
|
+
the new `{ source }` envelope.
|
|
27
|
+
|
|
28
|
+
All changes are backward-compatible — legacy bare strings continue to work.
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [7c9b85c]
|
|
31
|
+
- Updated dependencies [fd15918]
|
|
32
|
+
- @object-ui/core@4.0.7
|
|
33
|
+
- @object-ui/i18n@4.0.7
|
|
34
|
+
- @object-ui/data-objectstack@4.0.7
|
|
35
|
+
- @object-ui/types@4.0.7
|
|
36
|
+
|
|
3
37
|
## 4.0.6
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -5,6 +5,23 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Normalize a schema-supplied predicate (`visible` / `enabled` / `disabled` /
|
|
10
|
+
* `hidden`) into the `${expr}` template form expected by `useCondition`.
|
|
11
|
+
*
|
|
12
|
+
* Accepts:
|
|
13
|
+
* - `boolean` → returned as-is (predicate hooks short-circuit on booleans).
|
|
14
|
+
* - `string` → wrapped as `${string}` (legacy DX shorthand).
|
|
15
|
+
* - `Expression` envelope `{ dialect, source }` (new format from
|
|
16
|
+
* `@objectstack/spec`'s normalized predicate inputs) → unwrapped, then
|
|
17
|
+
* wrapped as `${source}`. Both `cel` and `template` dialects already use
|
|
18
|
+
* compatible variable syntax (`record.x`, etc.).
|
|
19
|
+
* - `null` / `undefined` / empty → `undefined` (default visible/enabled).
|
|
20
|
+
*
|
|
21
|
+
* This is the canonical helper to use in renderers so we never end up with
|
|
22
|
+
* `${[object Object]}` after JS template-literal interpolation.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toPredicateInput(value: unknown): string | boolean | undefined;
|
|
8
25
|
/**
|
|
9
26
|
* Hook for evaluating expressions with dynamic context
|
|
10
27
|
*
|
|
@@ -7,6 +7,35 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { useMemo } from 'react';
|
|
9
9
|
import { ExpressionEvaluator } from '@object-ui/core';
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a schema-supplied predicate (`visible` / `enabled` / `disabled` /
|
|
12
|
+
* `hidden`) into the `${expr}` template form expected by `useCondition`.
|
|
13
|
+
*
|
|
14
|
+
* Accepts:
|
|
15
|
+
* - `boolean` → returned as-is (predicate hooks short-circuit on booleans).
|
|
16
|
+
* - `string` → wrapped as `${string}` (legacy DX shorthand).
|
|
17
|
+
* - `Expression` envelope `{ dialect, source }` (new format from
|
|
18
|
+
* `@objectstack/spec`'s normalized predicate inputs) → unwrapped, then
|
|
19
|
+
* wrapped as `${source}`. Both `cel` and `template` dialects already use
|
|
20
|
+
* compatible variable syntax (`record.x`, etc.).
|
|
21
|
+
* - `null` / `undefined` / empty → `undefined` (default visible/enabled).
|
|
22
|
+
*
|
|
23
|
+
* This is the canonical helper to use in renderers so we never end up with
|
|
24
|
+
* `${[object Object]}` after JS template-literal interpolation.
|
|
25
|
+
*/
|
|
26
|
+
export function toPredicateInput(value) {
|
|
27
|
+
if (value === null || value === undefined || value === '')
|
|
28
|
+
return undefined;
|
|
29
|
+
if (typeof value === 'boolean')
|
|
30
|
+
return value;
|
|
31
|
+
if (typeof value === 'string')
|
|
32
|
+
return `\${${value}}`;
|
|
33
|
+
if (typeof value === 'object' && typeof value.source === 'string') {
|
|
34
|
+
const src = value.source;
|
|
35
|
+
return src ? `\${${src}}` : undefined;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
10
39
|
/**
|
|
11
40
|
* Hook for evaluating expressions with dynamic context
|
|
12
41
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "React bindings and SchemaRenderer component for Object UI",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@objectstack/spec": "^4.0.4",
|
|
28
28
|
"react-hook-form": "^7.75.0",
|
|
29
|
-
"@object-ui/
|
|
30
|
-
"@object-ui/
|
|
31
|
-
"@object-ui/
|
|
32
|
-
"@object-ui/types": "4.0.
|
|
29
|
+
"@object-ui/i18n": "4.0.7",
|
|
30
|
+
"@object-ui/core": "4.0.7",
|
|
31
|
+
"@object-ui/data-objectstack": "4.0.7",
|
|
32
|
+
"@object-ui/types": "4.0.7"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0 || ^19.0.0",
|