@object-ui/core 17.3.0 → 17.6.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/CHANGELOG.md +2018 -0
- package/README.md +38 -34
- package/dist/actions/ActionEngine.d.ts +43 -26
- package/dist/actions/ActionEngine.js +67 -54
- package/dist/actions/ActionRunner.d.ts +281 -31
- package/dist/actions/ActionRunner.js +458 -36
- package/dist/actions/actionKeys.d.ts +163 -27
- package/dist/actions/actionKeys.js +238 -27
- package/dist/actions/actionResponse.js +1 -1
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/actions/recordIdParam.d.ts +77 -0
- package/dist/actions/recordIdParam.js +37 -0
- package/dist/actions/serverActionHandler.d.ts +1 -1
- package/dist/actions/serverActionHandler.js +1 -1
- package/dist/data-scope/ViewDataProvider.d.ts +37 -12
- package/dist/data-scope/ViewDataProvider.js +83 -5
- package/dist/data-scope/element-data-source.d.ts +113 -0
- package/dist/data-scope/element-data-source.js +216 -0
- package/dist/data-scope/index.d.ts +2 -1
- package/dist/data-scope/index.js +1 -0
- package/dist/evaluator/ExpressionEvaluator.d.ts +42 -1
- package/dist/evaluator/ExpressionEvaluator.js +42 -1
- package/dist/evaluator/SafeExpressionParser.js +0 -4
- package/dist/evaluator/declaredPredicate.d.ts +119 -0
- package/dist/evaluator/declaredPredicate.js +152 -0
- package/dist/evaluator/fieldRules.d.ts +35 -0
- package/dist/evaluator/fieldRules.js +79 -20
- package/dist/evaluator/index.d.ts +2 -0
- package/dist/evaluator/index.js +2 -0
- package/dist/evaluator/listConditional.d.ts +54 -4
- package/dist/evaluator/listConditional.js +125 -19
- package/dist/evaluator/optionRules.d.ts +55 -0
- package/dist/evaluator/optionRules.js +60 -0
- package/dist/evaluator/predicateInput.d.ts +51 -3
- package/dist/evaluator/predicateInput.js +62 -5
- package/dist/evaluator/rowPredicateCanon.d.ts +67 -0
- package/dist/evaluator/rowPredicateCanon.js +208 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +31 -1
- package/dist/protocols/DndProtocol.d.ts +42 -1
- package/dist/protocols/KeyboardProtocol.d.ts +31 -1
- package/dist/protocols/SharingProtocol.d.ts +11 -1
- package/dist/registry/Registry.d.ts +62 -16
- package/dist/theme/ThemeEngine.d.ts +0 -8
- package/dist/theme/ThemeEngine.js +22 -103
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +7 -1
- package/dist/types/index.d.ts +125 -12
- package/dist/utils/chart-presentation.d.ts +205 -0
- package/dist/utils/chart-presentation.js +280 -0
- package/dist/utils/chart-series.d.ts +390 -23
- package/dist/utils/chart-series.js +776 -32
- package/dist/utils/column-identity.d.ts +43 -0
- package/dist/utils/column-identity.js +47 -1
- package/dist/utils/compare-to.d.ts +40 -13
- package/dist/utils/compare-to.js +4 -32
- package/dist/utils/dashboard-filters.d.ts +54 -8
- package/dist/utils/dashboard-filters.js +261 -12
- package/dist/utils/dataset-format.d.ts +73 -14
- package/dist/utils/dataset-format.js +142 -9
- package/dist/utils/dataset-pivot.d.ts +28 -7
- package/dist/utils/dataset-pivot.js +27 -6
- package/dist/utils/debug.js +7 -0
- package/dist/utils/dom-props.d.ts +137 -0
- package/dist/utils/dom-props.js +153 -0
- package/dist/utils/expand-fields.d.ts +97 -7
- package/dist/utils/expand-fields.js +97 -7
- package/dist/utils/filter-tokens.js +0 -1
- package/dist/utils/freeze-schema.d.ts +38 -1
- package/dist/utils/freeze-schema.js +10 -0
- package/dist/utils/humanize-label.d.ts +60 -0
- package/dist/utils/humanize-label.js +62 -0
- package/dist/utils/managedBy.d.ts +27 -2
- package/dist/utils/normalize-list-view.d.ts +36 -6
- package/dist/utils/normalize-list-view.js +93 -9
- package/dist/utils/number-display.d.ts +155 -0
- package/dist/utils/number-display.js +71 -0
- package/dist/utils/predicate-fields.d.ts +29 -4
- package/dist/utils/predicate-fields.js +44 -4
- package/dist/utils/resolve-view-id.d.ts +31 -0
- package/dist/utils/resolve-view-id.js +45 -0
- package/dist/utils/retired-field-types.d.ts +90 -0
- package/dist/utils/retired-field-types.js +124 -0
- package/dist/utils/sort-query.d.ts +57 -0
- package/dist/utils/sort-query.js +35 -0
- package/dist/utils/unmaterialized-fields.d.ts +52 -0
- package/dist/utils/unmaterialized-fields.js +57 -0
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/schema-validator.js +105 -0
- package/dist/validation/server-owned-value.d.ts +62 -0
- package/dist/validation/server-owned-value.js +99 -0
- package/dist/validation/validators/object-validation-engine.js +0 -2
- package/package.json +5 -5
- package/dist/__benchmarks__/core.bench.d.ts +0 -8
- package/dist/__benchmarks__/core.bench.js +0 -53
- package/dist/utils/merge-views-into-objects.d.ts +0 -19
- package/dist/utils/merge-views-into-objects.js +0 -39
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The ONE client-side answer to "is this field's value the PRODUCER's to
|
|
10
|
+
* supply?" — the other half of {@link isMissingForRequired}.
|
|
11
|
+
*
|
|
12
|
+
* A `required` verdict is a question about two facts: is the value absent
|
|
13
|
+
* (`required-presence.ts`), and was the client ever supposed to provide it.
|
|
14
|
+
* This module owns the second one. Both live here in `@object-ui/core` because
|
|
15
|
+
* every layer that decides required-ness reads them: the form renderer
|
|
16
|
+
* (`resolveFieldRuleState`), the wizard's cross-step gate, and the
|
|
17
|
+
* create-form field builders in `@object-ui/plugin-form`.
|
|
18
|
+
*
|
|
19
|
+
* ## What makes a value server-owned
|
|
20
|
+
*
|
|
21
|
+
* A `defaultValue` may be a literal, or an *instruction* the server resolves
|
|
22
|
+
* per insert:
|
|
23
|
+
*
|
|
24
|
+
* - a runtime token — `'NOW()'` / `'current_user'`, the whole
|
|
25
|
+
* `DEFAULT_VALUE_TOKENS` family from `@objectstack/spec/data`
|
|
26
|
+
* - a CEL Expression envelope — `{ dialect: 'cel', source: 'today()' }`
|
|
27
|
+
*
|
|
28
|
+
* A CREATE form deliberately leaves such a control EMPTY and omits the key
|
|
29
|
+
* from the payload, because `ObjectQL.applyFieldDefaults` resolves a declared
|
|
30
|
+
* default only for a field that arrives absent or null (#4047 / #4068). The
|
|
31
|
+
* field is therefore not "missing" on that submit — it is server-owned, and
|
|
32
|
+
* nothing the client evaluates may declare it required (#4069 / #4085).
|
|
33
|
+
*
|
|
34
|
+
* ## Create only
|
|
35
|
+
*
|
|
36
|
+
* On an EDIT form the token was already resolved at insert. The control shows
|
|
37
|
+
* a persisted value, so blanking it is a real removal and `required` (static
|
|
38
|
+
* or conditional) enforces normally.
|
|
39
|
+
*/
|
|
40
|
+
import { isRuntimeDefaultToken } from '@objectstack/spec/data';
|
|
41
|
+
/**
|
|
42
|
+
* Is `v` a CEL/template Expression envelope rather than a literal value?
|
|
43
|
+
*
|
|
44
|
+
* Same shape test the engine applies before handing a default to
|
|
45
|
+
* `ExpressionEngine` (`{ dialect, source }`), kept structural on purpose: the
|
|
46
|
+
* point is "the server evaluates this", which is true for every dialect.
|
|
47
|
+
*/
|
|
48
|
+
function isExpressionEnvelope(v) {
|
|
49
|
+
return (typeof v === 'object' &&
|
|
50
|
+
v !== null &&
|
|
51
|
+
typeof v.dialect === 'string' &&
|
|
52
|
+
typeof v.source === 'string');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Is this declared `defaultValue` a RUNTIME INSTRUCTION the server resolves per
|
|
56
|
+
* insert, rather than a literal value?
|
|
57
|
+
*
|
|
58
|
+
* True for the `DEFAULT_VALUE_TOKENS` family (`'NOW()'` / `'current_user'`) and
|
|
59
|
+
* for CEL/template Expression envelopes. This is THE classifier for "the
|
|
60
|
+
* producer owns this field's create value", and every consumer reads THIS one
|
|
61
|
+
* — a second copy would be free to disagree about, say, a CEL envelope, and
|
|
62
|
+
* then a form would seed a field it also refuses to submit. Today's consumers:
|
|
63
|
+
*
|
|
64
|
+
* 1. seeding (#4047 / #4068) — such a default is not seeded, because putting
|
|
65
|
+
* the literal text `NOW()` into a datetime input and submitting it
|
|
66
|
+
* suppresses the very resolution the declaration asked for;
|
|
67
|
+
* 2. the create-mode static `required` rule (#4069) —
|
|
68
|
+
* `isRequiredInForm` in `@object-ui/plugin-form`;
|
|
69
|
+
* 3. the create-mode `requiredWhen` rule (#4085) —
|
|
70
|
+
* {@link isServerOwnedValue}, read by `resolveFieldRuleState`.
|
|
71
|
+
*/
|
|
72
|
+
export function isRuntimeDefault(v) {
|
|
73
|
+
return isRuntimeDefaultToken(v) || isExpressionEnvelope(v);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Does the PRODUCER supply this field's value for the submit this form is
|
|
77
|
+
* about to make? (#4085)
|
|
78
|
+
*
|
|
79
|
+
* The single derivation of that fact, so the three call sites that feed
|
|
80
|
+
* `resolveFieldRuleState` cannot each answer "where does the declared default
|
|
81
|
+
* live" differently. It reads the runtime FormField's `field` slot — the
|
|
82
|
+
* resolved object-field metadata the object-bound builders stash there
|
|
83
|
+
* (`ObjectForm`, `sectionFields`, and the containers' no-sections paths), and
|
|
84
|
+
* the only spelling of a declared `defaultValue` that reaches the renderer.
|
|
85
|
+
* A hand-authored FormField carries no object metadata, so it is never
|
|
86
|
+
* server-owned and its rules are untouched.
|
|
87
|
+
*
|
|
88
|
+
* `isCreateForm` is the CALLER's fact, never inferred here: the form renderer
|
|
89
|
+
* reads it off `FormSchema.previousValues` (whose absence *is* the declared
|
|
90
|
+
* "this is an insert" signal, objectui#3484), while the wizard's step gate
|
|
91
|
+
* reads its own `mode`. An evaluator guessing from a `previous` argument would
|
|
92
|
+
* call an edit-mode caller that simply passes no `previous` a create form, and
|
|
93
|
+
* silently drop a `requiredWhen` the author meant to enforce.
|
|
94
|
+
*/
|
|
95
|
+
export function isServerOwnedValue(field, isCreateForm) {
|
|
96
|
+
if (!isCreateForm)
|
|
97
|
+
return false;
|
|
98
|
+
return isRuntimeDefault(field?.field?.defaultValue);
|
|
99
|
+
}
|
|
@@ -129,13 +129,11 @@ class SimpleExpressionEvaluator {
|
|
|
129
129
|
return leftVal === rightVal;
|
|
130
130
|
case '==':
|
|
131
131
|
// Use loose equality for backward compatibility with existing expressions
|
|
132
|
-
// eslint-disable-next-line eqeqeq
|
|
133
132
|
return leftVal == rightVal;
|
|
134
133
|
case '!==':
|
|
135
134
|
return leftVal !== rightVal;
|
|
136
135
|
case '!=':
|
|
137
136
|
// Use loose inequality for backward compatibility with existing expressions
|
|
138
|
-
// eslint-disable-next-line eqeqeq
|
|
139
137
|
return leftVal != rightVal;
|
|
140
138
|
case '>': return leftVal > rightVal;
|
|
141
139
|
case '<': return leftVal < rightVal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/core",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@objectstack/formula": "^17.0.0
|
|
29
|
-
"@objectstack/spec": "^17.0.0
|
|
28
|
+
"@objectstack/formula": "^17.0.0",
|
|
29
|
+
"@objectstack/spec": "^17.0.0",
|
|
30
30
|
"lodash": "^4.18.1",
|
|
31
31
|
"zod": "^4.4.3",
|
|
32
|
-
"@object-ui/types": "17.
|
|
32
|
+
"@object-ui/types": "17.6.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^6.0.3",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsc",
|
|
64
64
|
"test": "vitest run",
|
|
65
|
-
"type-check": "tsc --noEmit",
|
|
65
|
+
"type-check": "tsc --noEmit && tsc -p tsconfig.test.json",
|
|
66
66
|
"lint": "eslint ."
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Performance benchmark suite for @object-ui/core.
|
|
10
|
-
*
|
|
11
|
-
* Part of Q1 2026 roadmap §1.4 Test Coverage Improvement.
|
|
12
|
-
*
|
|
13
|
-
* Run with: npx vitest bench packages/core/src/__benchmarks__/
|
|
14
|
-
*/
|
|
15
|
-
import { bench, describe } from 'vitest';
|
|
16
|
-
import { ExpressionEvaluator } from '@object-ui/core';
|
|
17
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
18
|
-
import { contrastRatio, meetsContrastLevel, hexToHSL } from '@object-ui/core';
|
|
19
|
-
describe('ExpressionEvaluator performance', () => {
|
|
20
|
-
const evaluator = new ExpressionEvaluator({ data: { name: 'Alice', age: 30, active: true } });
|
|
21
|
-
bench('evaluate simple string', () => {
|
|
22
|
-
evaluator.evaluate('Hello ${data.name}');
|
|
23
|
-
});
|
|
24
|
-
bench('evaluate 100 expressions', () => {
|
|
25
|
-
for (let i = 0; i < 100; i++) {
|
|
26
|
-
evaluator.evaluate('Hello ${data.name}');
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe('ComponentRegistry performance', () => {
|
|
31
|
-
bench('get registered component', () => {
|
|
32
|
-
ComponentRegistry.get('button');
|
|
33
|
-
});
|
|
34
|
-
bench('has check', () => {
|
|
35
|
-
ComponentRegistry.has('button');
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe('Theme utilities performance', () => {
|
|
39
|
-
bench('hexToHSL conversion', () => {
|
|
40
|
-
hexToHSL('#336699');
|
|
41
|
-
});
|
|
42
|
-
bench('contrastRatio calculation', () => {
|
|
43
|
-
contrastRatio('#000000', '#ffffff');
|
|
44
|
-
});
|
|
45
|
-
bench('meetsContrastLevel check', () => {
|
|
46
|
-
meetsContrastLevel('#000000', '#ffffff', 'AA');
|
|
47
|
-
});
|
|
48
|
-
bench('100 contrast checks', () => {
|
|
49
|
-
for (let i = 0; i < 100; i++) {
|
|
50
|
-
meetsContrastLevel('#336699', '#ffffff', 'AA');
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Adapter: merge stack-level views into object definitions.
|
|
10
|
-
*
|
|
11
|
-
* Views are defined at the stack level (views[].listViews) but the runtime
|
|
12
|
-
* expects listViews on each object definition. This bridges the gap until
|
|
13
|
-
* the runtime/provider layer handles it natively.
|
|
14
|
-
*
|
|
15
|
-
* @param objects - Object definitions from composed stack
|
|
16
|
-
* @param views - View definitions containing listViews keyed by object name
|
|
17
|
-
* @returns Objects with listViews merged in from matching views
|
|
18
|
-
*/
|
|
19
|
-
export declare function mergeViewsIntoObjects(objects: any[], views: any[]): any[];
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Adapter: merge stack-level views into object definitions.
|
|
10
|
-
*
|
|
11
|
-
* Views are defined at the stack level (views[].listViews) but the runtime
|
|
12
|
-
* expects listViews on each object definition. This bridges the gap until
|
|
13
|
-
* the runtime/provider layer handles it natively.
|
|
14
|
-
*
|
|
15
|
-
* @param objects - Object definitions from composed stack
|
|
16
|
-
* @param views - View definitions containing listViews keyed by object name
|
|
17
|
-
* @returns Objects with listViews merged in from matching views
|
|
18
|
-
*/
|
|
19
|
-
export function mergeViewsIntoObjects(objects, views) {
|
|
20
|
-
const viewsByObject = {};
|
|
21
|
-
for (const view of views) {
|
|
22
|
-
if (!view.listViews)
|
|
23
|
-
continue;
|
|
24
|
-
for (const [viewName, listView] of Object.entries(view.listViews)) {
|
|
25
|
-
const objectName = listView?.data?.object;
|
|
26
|
-
if (!objectName)
|
|
27
|
-
continue;
|
|
28
|
-
if (!viewsByObject[objectName])
|
|
29
|
-
viewsByObject[objectName] = {};
|
|
30
|
-
viewsByObject[objectName][viewName] = listView;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return objects.map((obj) => {
|
|
34
|
-
const v = viewsByObject[obj.name];
|
|
35
|
-
if (!v)
|
|
36
|
-
return obj;
|
|
37
|
-
return { ...obj, listViews: { ...(obj.listViews || {}), ...v } };
|
|
38
|
-
});
|
|
39
|
-
}
|