@rangka/client 0.1.1 → 0.1.3
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/App.d.ts.map +1 -1
- package/dist/App.js +7 -1
- package/dist/App.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -0
- package/dist/main.js.map +1 -1
- package/dist/shell/assets/index-63v1sBS3.css +1 -0
- package/dist/shell/assets/index-Dh7K40cQ.js +8634 -0
- package/dist/shell/assets/vendor-query-B2cydN5j.js +1 -0
- package/dist/shell/assets/vendor-radix-BJxYPxPb.js +69 -0
- package/dist/shell/assets/vendor-router-ET_myMt5.js +17 -0
- package/dist/shell/index.html +5 -2
- package/dist/theme.css +82 -0
- package/dist/widgets/components/lazy-manifest.d.ts +11 -0
- package/dist/widgets/components/lazy-manifest.d.ts.map +1 -0
- package/dist/widgets/components/lazy-manifest.js +32 -0
- package/dist/widgets/components/lazy-manifest.js.map +1 -0
- package/dist/widgets/components/register.js +12 -12
- package/dist/widgets/components/register.js.map +1 -1
- package/dist/widgets/loader.d.ts +3 -0
- package/dist/widgets/loader.d.ts.map +1 -0
- package/dist/widgets/loader.js +73 -0
- package/dist/widgets/loader.js.map +1 -0
- package/dist/widgets/renderer/LazyWidget.d.ts +8 -0
- package/dist/widgets/renderer/LazyWidget.d.ts.map +1 -0
- package/dist/widgets/renderer/LazyWidget.js +31 -0
- package/dist/widgets/renderer/LazyWidget.js.map +1 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.d.ts +17 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.d.ts.map +1 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.js +18 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.js.map +1 -0
- package/dist/widgets/renderer/WidgetRenderer.d.ts.map +1 -1
- package/dist/widgets/renderer/WidgetRenderer.js +8 -6
- package/dist/widgets/renderer/WidgetRenderer.js.map +1 -1
- package/package.json +7 -4
- package/.claude/skills/add-widget/SKILL.md +0 -101
- package/.turbo/turbo-build.log +0 -29
- package/CHANGELOG.md +0 -25
- package/CLAUDE.md +0 -236
- package/components.json +0 -25
- package/dist/components/ui/chart.d.ts +0 -45
- package/dist/components/ui/chart.d.ts.map +0 -1
- package/dist/components/ui/chart.js +0 -119
- package/dist/components/ui/chart.js.map +0 -1
- package/dist/shell/assets/index--35CAvcP.js +0 -8715
- package/dist/shell/assets/index-COLmoPYo.css +0 -1
- package/index.html +0 -12
- package/src/App.tsx +0 -44
- package/src/__tests__/setup.ts +0 -1
- package/src/api/auth.ts +0 -41
- package/src/api/boot.ts +0 -10
- package/src/api/client.ts +0 -26
- package/src/api/paths.ts +0 -3
- package/src/api/token.ts +0 -13
- package/src/auth/LoginForm.tsx +0 -67
- package/src/auth/SessionExpired.tsx +0 -24
- package/src/auth/SetupForm.tsx +0 -76
- package/src/boot/BootGate.tsx +0 -35
- package/src/boot/BootProvider.tsx +0 -28
- package/src/boot/types.ts +0 -9
- package/src/boot/useBoot.ts +0 -111
- package/src/components/Icon.tsx +0 -17
- package/src/components/ui/accordion.tsx +0 -82
- package/src/components/ui/alert-dialog.tsx +0 -180
- package/src/components/ui/alert.tsx +0 -76
- package/src/components/ui/aspect-ratio.tsx +0 -9
- package/src/components/ui/avatar.tsx +0 -94
- package/src/components/ui/badge.tsx +0 -45
- package/src/components/ui/breadcrumb.tsx +0 -104
- package/src/components/ui/button-group.tsx +0 -78
- package/src/components/ui/button.tsx +0 -65
- package/src/components/ui/calendar.tsx +0 -187
- package/src/components/ui/card.tsx +0 -85
- package/src/components/ui/carousel.tsx +0 -229
- package/src/components/ui/chart.tsx +0 -339
- package/src/components/ui/checkbox.tsx +0 -27
- package/src/components/ui/collapsible.tsx +0 -21
- package/src/components/ui/combobox.tsx +0 -275
- package/src/components/ui/command.tsx +0 -178
- package/src/components/ui/context-menu.tsx +0 -242
- package/src/components/ui/dialog.tsx +0 -146
- package/src/components/ui/direction.tsx +0 -20
- package/src/components/ui/drawer.tsx +0 -118
- package/src/components/ui/dropdown-menu.tsx +0 -247
- package/src/components/ui/empty.tsx +0 -94
- package/src/components/ui/field.tsx +0 -224
- package/src/components/ui/hover-card.tsx +0 -36
- package/src/components/ui/input-group.tsx +0 -142
- package/src/components/ui/input-otp.tsx +0 -86
- package/src/components/ui/input.tsx +0 -19
- package/src/components/ui/item.tsx +0 -182
- package/src/components/ui/kbd.tsx +0 -26
- package/src/components/ui/label.tsx +0 -19
- package/src/components/ui/menubar.tsx +0 -260
- package/src/components/ui/native-select.tsx +0 -55
- package/src/components/ui/navigation-menu.tsx +0 -160
- package/src/components/ui/pagination.tsx +0 -112
- package/src/components/ui/popover.tsx +0 -74
- package/src/components/ui/progress.tsx +0 -31
- package/src/components/ui/radio-group.tsx +0 -42
- package/src/components/ui/resizable.tsx +0 -42
- package/src/components/ui/scroll-area.tsx +0 -53
- package/src/components/ui/select.tsx +0 -185
- package/src/components/ui/separator.tsx +0 -26
- package/src/components/ui/sheet.tsx +0 -128
- package/src/components/ui/sidebar.tsx +0 -669
- package/src/components/ui/skeleton.tsx +0 -13
- package/src/components/ui/slider.tsx +0 -54
- package/src/components/ui/sonner.tsx +0 -43
- package/src/components/ui/spinner.tsx +0 -16
- package/src/components/ui/switch.tsx +0 -33
- package/src/components/ui/table.tsx +0 -87
- package/src/components/ui/tabs.tsx +0 -80
- package/src/components/ui/textarea.tsx +0 -18
- package/src/components/ui/toggle-group.tsx +0 -86
- package/src/components/ui/toggle.tsx +0 -44
- package/src/components/ui/tooltip.tsx +0 -53
- package/src/context/MetaContext.tsx +0 -22
- package/src/context/ModuleContext.tsx +0 -62
- package/src/context/PermissionsContext.tsx +0 -39
- package/src/context/ShellProviders.tsx +0 -33
- package/src/context/UserContext.tsx +0 -16
- package/src/data/QueryProvider.tsx +0 -7
- package/src/data/queryClient.ts +0 -18
- package/src/data/useModelMeta.ts +0 -17
- package/src/data/useMutation.ts +0 -60
- package/src/data/useRecord.ts +0 -29
- package/src/data/useSource.ts +0 -112
- package/src/hooks/use-mobile.ts +0 -19
- package/src/index.css +0 -260
- package/src/index.ts +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/main.tsx +0 -17
- package/src/router/NotFound.tsx +0 -8
- package/src/router/RouterProvider.tsx +0 -7
- package/src/router/buildRouteTree.tsx +0 -63
- package/src/router/createShellRouter.ts +0 -9
- package/src/router/hooks.ts +0 -43
- package/src/shell/CommandPalette.tsx +0 -76
- package/src/shell/ConfirmDialog.tsx +0 -34
- package/src/shell/ConfirmProvider.tsx +0 -56
- package/src/shell/DrawerContext.tsx +0 -44
- package/src/shell/HeaderActions.tsx +0 -31
- package/src/shell/ModuleSelectorPage.tsx +0 -149
- package/src/shell/PageOutlet.tsx +0 -21
- package/src/shell/ShellContext.tsx +0 -45
- package/src/shell/ShellDevTools.tsx +0 -153
- package/src/shell/ShellLayout.tsx +0 -231
- package/src/shell/Toast.tsx +0 -58
- package/src/shell/ToastProvider.tsx +0 -60
- package/src/shell/app-sidebar/AppSidebar.tsx +0 -44
- package/src/shell/app-sidebar/ModuleSwitcher.tsx +0 -87
- package/src/shell/app-sidebar/NavMain.tsx +0 -64
- package/src/shell/app-sidebar/NavUser.tsx +0 -97
- package/src/shell/app-sidebar/SearchMenu.tsx +0 -22
- package/src/shell/app-sidebar/index.ts +0 -8
- package/src/shell/app-sidebar/types.ts +0 -38
- package/src/shell/types.ts +0 -6
- package/src/shell/useBreadcrumbs.ts +0 -42
- package/src/studio/bridge.ts +0 -125
- package/src/studio/index.ts +0 -3
- package/src/studio/overlay.ts +0 -47
- package/src/studio/types.ts +0 -32
- package/src/studio/walker.ts +0 -48
- package/src/vite-env.d.ts +0 -1
- package/src/widgets/__tests__/action-edge-cases.test.ts +0 -281
- package/src/widgets/__tests__/action.test.ts +0 -236
- package/src/widgets/__tests__/attachment-widget.test.tsx +0 -85
- package/src/widgets/__tests__/attachments-widget.test.tsx +0 -109
- package/src/widgets/__tests__/binding.test.ts +0 -76
- package/src/widgets/__tests__/button-widget.test.tsx +0 -145
- package/src/widgets/__tests__/checkbox-widget.test.tsx +0 -158
- package/src/widgets/__tests__/code-widget.test.tsx +0 -64
- package/src/widgets/__tests__/computed-widget.test.tsx +0 -62
- package/src/widgets/__tests__/condition-edge-cases.test.ts +0 -120
- package/src/widgets/__tests__/condition.test.ts +0 -221
- package/src/widgets/__tests__/context.test.ts +0 -99
- package/src/widgets/__tests__/data-widget.test.tsx +0 -204
- package/src/widgets/__tests__/datepicker-widget.test.tsx +0 -66
- package/src/widgets/__tests__/datetime-widget.test.tsx +0 -67
- package/src/widgets/__tests__/drawer-widget.test.tsx +0 -149
- package/src/widgets/__tests__/dynamic-link-widget.test.tsx +0 -52
- package/src/widgets/__tests__/edge-cases.test.ts +0 -232
- package/src/widgets/__tests__/evaluator.test.ts +0 -107
- package/src/widgets/__tests__/functions.test.ts +0 -147
- package/src/widgets/__tests__/grid-widget.test.tsx +0 -137
- package/src/widgets/__tests__/hooks.test.tsx +0 -249
- package/src/widgets/__tests__/icon-widget.test.tsx +0 -129
- package/src/widgets/__tests__/input-widget.test.tsx +0 -264
- package/src/widgets/__tests__/integration.test.ts +0 -116
- package/src/widgets/__tests__/json-widget.test.tsx +0 -70
- package/src/widgets/__tests__/link-widget.test.tsx +0 -92
- package/src/widgets/__tests__/many-to-many-widget.test.tsx +0 -93
- package/src/widgets/__tests__/modal-widget.test.tsx +0 -148
- package/src/widgets/__tests__/money-widget.test.tsx +0 -97
- package/src/widgets/__tests__/parser.test.ts +0 -171
- package/src/widgets/__tests__/reactive-variables.test.ts +0 -383
- package/src/widgets/__tests__/renderer.test.tsx +0 -300
- package/src/widgets/__tests__/repeat-widget.test.tsx +0 -229
- package/src/widgets/__tests__/select-widget.test.tsx +0 -231
- package/src/widgets/__tests__/sequence-widget.test.tsx +0 -58
- package/src/widgets/__tests__/shell-integration.test.tsx +0 -1343
- package/src/widgets/__tests__/split-widget.test.tsx +0 -133
- package/src/widgets/__tests__/state-edge-cases.test.ts +0 -118
- package/src/widgets/__tests__/state.test.ts +0 -106
- package/src/widgets/__tests__/table-data-binding.test.tsx +0 -482
- package/src/widgets/__tests__/table-filter-popover.test.tsx +0 -486
- package/src/widgets/__tests__/table-search.test.tsx +0 -305
- package/src/widgets/__tests__/table-widget.test.tsx +0 -509
- package/src/widgets/__tests__/textarea-widget.test.tsx +0 -105
- package/src/widgets/__tests__/tracker-validator-edge-cases.test.ts +0 -242
- package/src/widgets/__tests__/tracker.test.ts +0 -133
- package/src/widgets/__tests__/tree-widget.test.tsx +0 -97
- package/src/widgets/__tests__/use-model-source.test.ts +0 -67
- package/src/widgets/__tests__/validator.test.ts +0 -208
- package/src/widgets/action/dispatcher.ts +0 -334
- package/src/widgets/action/index.ts +0 -2
- package/src/widgets/binding/index.ts +0 -2
- package/src/widgets/binding/resolver.ts +0 -61
- package/src/widgets/components/AttachmentWidget.tsx +0 -111
- package/src/widgets/components/AttachmentsWidget.tsx +0 -121
- package/src/widgets/components/BadgeWidget.tsx +0 -35
- package/src/widgets/components/ButtonWidget.tsx +0 -43
- package/src/widgets/components/CardWidget.tsx +0 -68
- package/src/widgets/components/CheckboxWidget.tsx +0 -39
- package/src/widgets/components/CodeWidget.tsx +0 -44
- package/src/widgets/components/ColumnWidget.tsx +0 -22
- package/src/widgets/components/ComputedWidget.tsx +0 -49
- package/src/widgets/components/DataWidget.tsx +0 -189
- package/src/widgets/components/DatePickerWidget.tsx +0 -73
- package/src/widgets/components/DatetimeWidget.tsx +0 -160
- package/src/widgets/components/DividerWidget.tsx +0 -37
- package/src/widgets/components/DrawerWidget.tsx +0 -52
- package/src/widgets/components/DynamicLinkWidget.tsx +0 -130
- package/src/widgets/components/GridWidget.tsx +0 -134
- package/src/widgets/components/GroupWidget.tsx +0 -111
- package/src/widgets/components/IconWidget.tsx +0 -29
- package/src/widgets/components/ImageWidget.tsx +0 -28
- package/src/widgets/components/InputWidget.tsx +0 -70
- package/src/widgets/components/JsonWidget.tsx +0 -78
- package/src/widgets/components/LinkWidget.tsx +0 -99
- package/src/widgets/components/ManyToManyWidget.tsx +0 -125
- package/src/widgets/components/ModalWidget.tsx +0 -52
- package/src/widgets/components/MoneyWidget.tsx +0 -80
- package/src/widgets/components/RepeatWidget.tsx +0 -66
- package/src/widgets/components/ScrollAreaWidget.tsx +0 -40
- package/src/widgets/components/SectionWidget.tsx +0 -78
- package/src/widgets/components/SelectWidget.tsx +0 -63
- package/src/widgets/components/SequenceWidget.tsx +0 -32
- package/src/widgets/components/SpacerWidget.tsx +0 -29
- package/src/widgets/components/SplitWidget.tsx +0 -60
- package/src/widgets/components/StackWidget.tsx +0 -44
- package/src/widgets/components/TableWidget.tsx +0 -366
- package/src/widgets/components/TextWidget.tsx +0 -44
- package/src/widgets/components/TextareaWidget.tsx +0 -49
- package/src/widgets/components/TreeWidget.tsx +0 -109
- package/src/widgets/components/index.ts +0 -30
- package/src/widgets/components/register.ts +0 -93
- package/src/widgets/components/table/CellRenderers.tsx +0 -83
- package/src/widgets/components/table/TablePagination.tsx +0 -45
- package/src/widgets/components/table/TableToolbar.tsx +0 -285
- package/src/widgets/components/table/filter-operators.ts +0 -134
- package/src/widgets/components/table/index.ts +0 -11
- package/src/widgets/condition/evaluator.ts +0 -57
- package/src/widgets/condition/index.ts +0 -1
- package/src/widgets/context/builder.ts +0 -99
- package/src/widgets/context/index.ts +0 -8
- package/src/widgets/context/types.ts +0 -37
- package/src/widgets/data/index.ts +0 -5
- package/src/widgets/data/useModelQuery.ts +0 -116
- package/src/widgets/data/useModelRecord.ts +0 -37
- package/src/widgets/expression/evaluator.ts +0 -100
- package/src/widgets/expression/functions.ts +0 -131
- package/src/widgets/expression/index.ts +0 -13
- package/src/widgets/expression/parser.ts +0 -229
- package/src/widgets/expression/types.ts +0 -45
- package/src/widgets/form/FormContext.ts +0 -29
- package/src/widgets/form/FormProvider.tsx +0 -84
- package/src/widgets/form/FormWidget.tsx +0 -42
- package/src/widgets/form/index.ts +0 -4
- package/src/widgets/form/useFormState.ts +0 -127
- package/src/widgets/form/useFormSubmit.ts +0 -90
- package/src/widgets/form/useFormValidation.ts +0 -62
- package/src/widgets/hooks/index.ts +0 -8
- package/src/widgets/hooks/useAction.ts +0 -83
- package/src/widgets/hooks/useBind.ts +0 -34
- package/src/widgets/hooks/useCondition.ts +0 -21
- package/src/widgets/hooks/useDataQuery.ts +0 -48
- package/src/widgets/hooks/useExpression.ts +0 -14
- package/src/widgets/hooks/usePageState.ts +0 -21
- package/src/widgets/hooks/useSurfaceContext.ts +0 -11
- package/src/widgets/hooks/useWidgetContext.ts +0 -14
- package/src/widgets/index.ts +0 -80
- package/src/widgets/lib/layout-props.ts +0 -135
- package/src/widgets/reactivity/index.ts +0 -11
- package/src/widgets/reactivity/tracker.ts +0 -139
- package/src/widgets/reactivity/variables.ts +0 -213
- package/src/widgets/registry.ts +0 -41
- package/src/widgets/renderer/SlotRenderer.tsx +0 -47
- package/src/widgets/renderer/WidgetRenderer.tsx +0 -191
- package/src/widgets/renderer/index.ts +0 -4
- package/src/widgets/shell/WidgetSlotRenderer.tsx +0 -73
- package/src/widgets/shell/index.ts +0 -4
- package/src/widgets/shell/useActionHandlers.ts +0 -170
- package/src/widgets/state/index.ts +0 -2
- package/src/widgets/state/store.ts +0 -96
- package/src/widgets/types.ts +0 -28
- package/src/widgets/validation/index.ts +0 -2
- package/src/widgets/validation/validator.ts +0 -140
- package/tsconfig.json +0 -27
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config.ts +0 -21
- package/vitest.config.ts +0 -16
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from 'vitest';
|
|
2
|
-
import { buildDependencyMap } from '../reactivity/tracker.js';
|
|
3
|
-
import { validateWidgetTree } from '../validation/validator.js';
|
|
4
|
-
import type { WidgetNode, WidgetDefinitionMeta } from '@rangka/shared';
|
|
5
|
-
|
|
6
|
-
describe('Dependency Tracker Edge Cases', () => {
|
|
7
|
-
test('empty widget array produces empty maps', () => {
|
|
8
|
-
const map = buildDependencyMap([]);
|
|
9
|
-
expect(map.fields.size).toBe(0);
|
|
10
|
-
expect(map.state.size).toBe(0);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('widget with no bind, no visible, no props has no deps', () => {
|
|
14
|
-
const nodes: WidgetNode[] = [{ id: 'w1', type: 'divider' }];
|
|
15
|
-
const map = buildDependencyMap(nodes);
|
|
16
|
-
expect(map.fields.size).toBe(0);
|
|
17
|
-
expect(map.state.size).toBe(0);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('non-expression string props are not tracked', () => {
|
|
21
|
-
const nodes: WidgetNode[] = [
|
|
22
|
-
{ id: 'w1', type: 'button', props: { label: 'Click me', variant: 'primary' } },
|
|
23
|
-
];
|
|
24
|
-
const map = buildDependencyMap(nodes);
|
|
25
|
-
expect(map.fields.size).toBe(0);
|
|
26
|
-
expect(map.state.size).toBe(0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('deeply nested children are tracked', () => {
|
|
30
|
-
const nodes: WidgetNode[] = [
|
|
31
|
-
{
|
|
32
|
-
id: 'l1',
|
|
33
|
-
type: 'group',
|
|
34
|
-
children: [
|
|
35
|
-
{
|
|
36
|
-
id: 'l2',
|
|
37
|
-
type: 'group',
|
|
38
|
-
children: [
|
|
39
|
-
{
|
|
40
|
-
id: 'deep',
|
|
41
|
-
type: 'input',
|
|
42
|
-
bind: { field: 'deep_field' },
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
const map = buildDependencyMap(nodes);
|
|
50
|
-
expect(map.fields.get('deep_field')).toEqual(new Set(['deep']));
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('same widget multiple deps from different sources', () => {
|
|
54
|
-
const nodes: WidgetNode[] = [
|
|
55
|
-
{
|
|
56
|
-
id: 'w1',
|
|
57
|
-
type: 'text',
|
|
58
|
-
bind: { expression: '{{qty * rate}}' },
|
|
59
|
-
visible: { field: '$state.showTotal', operator: 'eq', value: true },
|
|
60
|
-
props: { style: '{{if($state.bold, "bold", "body")}}' },
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
const map = buildDependencyMap(nodes);
|
|
64
|
-
expect(map.fields.get('qty')).toContain('w1');
|
|
65
|
-
expect(map.fields.get('rate')).toContain('w1');
|
|
66
|
-
expect(map.state.get('showTotal')).toContain('w1');
|
|
67
|
-
expect(map.state.get('bold')).toContain('w1');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('expression with function call tracks arguments', () => {
|
|
71
|
-
const nodes: WidgetNode[] = [
|
|
72
|
-
{
|
|
73
|
-
id: 'w1',
|
|
74
|
-
type: 'text',
|
|
75
|
-
bind: { expression: '{{format_currency(total, currency)}}' },
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
const map = buildDependencyMap(nodes);
|
|
79
|
-
expect(map.fields.get('total')).toEqual(new Set(['w1']));
|
|
80
|
-
expect(map.fields.get('currency')).toEqual(new Set(['w1']));
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('condition value with expression adds deps', () => {
|
|
84
|
-
const nodes: WidgetNode[] = [
|
|
85
|
-
{
|
|
86
|
-
id: 'w1',
|
|
87
|
-
type: 'section',
|
|
88
|
-
visible: { field: 'total', operator: 'gt', value: '{{$state.threshold}}' },
|
|
89
|
-
},
|
|
90
|
-
];
|
|
91
|
-
const map = buildDependencyMap(nodes);
|
|
92
|
-
expect(map.fields.get('total')).toContain('w1');
|
|
93
|
-
expect(map.state.get('threshold')).toContain('w1');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('malformed expression in props does not crash', () => {
|
|
97
|
-
const nodes: WidgetNode[] = [
|
|
98
|
-
{
|
|
99
|
-
id: 'w1',
|
|
100
|
-
type: 'text',
|
|
101
|
-
props: { label: '{{@invalid syntax}}' },
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
const map = buildDependencyMap(nodes);
|
|
105
|
-
expect(map.fields.size).toBe(0);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('Validator Edge Cases', () => {
|
|
110
|
-
const registry = new Map<string, WidgetDefinitionMeta>([
|
|
111
|
-
[
|
|
112
|
-
'input',
|
|
113
|
-
{
|
|
114
|
-
name: 'input',
|
|
115
|
-
label: 'Input',
|
|
116
|
-
category: 'input',
|
|
117
|
-
schema: { label: { type: 'string' } },
|
|
118
|
-
binding: 'field',
|
|
119
|
-
triggers: ['change'],
|
|
120
|
-
container: false,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
[
|
|
124
|
-
'group',
|
|
125
|
-
{
|
|
126
|
-
name: 'group',
|
|
127
|
-
label: 'Group',
|
|
128
|
-
category: 'layout',
|
|
129
|
-
schema: { direction: { type: 'enum', options: ['row', 'column'] } },
|
|
130
|
-
binding: 'none',
|
|
131
|
-
triggers: [],
|
|
132
|
-
container: true,
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
[
|
|
136
|
-
'table',
|
|
137
|
-
{
|
|
138
|
-
name: 'table',
|
|
139
|
-
label: 'Table',
|
|
140
|
-
category: 'layout',
|
|
141
|
-
schema: {},
|
|
142
|
-
binding: 'model',
|
|
143
|
-
triggers: ['rowClick'],
|
|
144
|
-
container: true,
|
|
145
|
-
accepts: ['column'],
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
[
|
|
149
|
-
'column',
|
|
150
|
-
{
|
|
151
|
-
name: 'column',
|
|
152
|
-
label: 'Column',
|
|
153
|
-
category: 'layout',
|
|
154
|
-
schema: { label: { type: 'string', required: true } },
|
|
155
|
-
binding: 'none',
|
|
156
|
-
triggers: [],
|
|
157
|
-
container: true,
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
]);
|
|
161
|
-
|
|
162
|
-
test('empty tree produces no errors', () => {
|
|
163
|
-
expect(validateWidgetTree([], registry)).toEqual([]);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test('multiple errors reported for same widget', () => {
|
|
167
|
-
const nodes: WidgetNode[] = [
|
|
168
|
-
{
|
|
169
|
-
type: 'input',
|
|
170
|
-
bind: { model: { name: 'test' } },
|
|
171
|
-
on: { invalid: { type: 'refreshSource' } },
|
|
172
|
-
children: [{ type: 'input' }],
|
|
173
|
-
},
|
|
174
|
-
];
|
|
175
|
-
const errors = validateWidgetTree(nodes, registry);
|
|
176
|
-
expect(errors.length).toBeGreaterThanOrEqual(3);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test('deeply nested error has full path', () => {
|
|
180
|
-
const nodes: WidgetNode[] = [
|
|
181
|
-
{
|
|
182
|
-
type: 'group',
|
|
183
|
-
children: [
|
|
184
|
-
{
|
|
185
|
-
type: 'group',
|
|
186
|
-
children: [
|
|
187
|
-
{
|
|
188
|
-
type: 'group',
|
|
189
|
-
children: [{ type: 'nonexistent' }],
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
];
|
|
196
|
-
const errors = validateWidgetTree(nodes, registry);
|
|
197
|
-
expect(errors[0].path).toBe('[0].children[0].children[0].children[0]');
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test('container with empty children is valid', () => {
|
|
201
|
-
const nodes: WidgetNode[] = [{ type: 'group', children: [] }];
|
|
202
|
-
expect(validateWidgetTree(nodes, registry)).toEqual([]);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test('container without children field is valid', () => {
|
|
206
|
-
const nodes: WidgetNode[] = [{ type: 'group' }];
|
|
207
|
-
expect(validateWidgetTree(nodes, registry)).toEqual([]);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
test('table accepts column children', () => {
|
|
211
|
-
const nodes: WidgetNode[] = [
|
|
212
|
-
{
|
|
213
|
-
type: 'table',
|
|
214
|
-
bind: { model: { name: 'test' } },
|
|
215
|
-
children: [
|
|
216
|
-
{ type: 'column', props: { label: 'Name' } },
|
|
217
|
-
{ type: 'column', props: { label: 'Email' } },
|
|
218
|
-
],
|
|
219
|
-
},
|
|
220
|
-
];
|
|
221
|
-
expect(validateWidgetTree(nodes, registry)).toEqual([]);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test('table rejects multiple invalid children', () => {
|
|
225
|
-
const nodes: WidgetNode[] = [
|
|
226
|
-
{
|
|
227
|
-
type: 'table',
|
|
228
|
-
bind: { model: { name: 'test' } },
|
|
229
|
-
children: [{ type: 'input', bind: { field: 'x' } }, { type: 'group' }],
|
|
230
|
-
},
|
|
231
|
-
];
|
|
232
|
-
const errors = validateWidgetTree(nodes, registry);
|
|
233
|
-
expect(errors).toHaveLength(2);
|
|
234
|
-
expect(errors[0].path).toContain('children[0]');
|
|
235
|
-
expect(errors[1].path).toContain('children[1]');
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
test('prop with boolean default not required', () => {
|
|
239
|
-
const nodes: WidgetNode[] = [{ type: 'group', props: {} }];
|
|
240
|
-
expect(validateWidgetTree(nodes, registry)).toEqual([]);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from 'vitest';
|
|
2
|
-
import { buildDependencyMap, getAffectedWidgets } from '../reactivity/tracker.js';
|
|
3
|
-
import type { WidgetNode } from '@rangka/shared';
|
|
4
|
-
|
|
5
|
-
describe('Dependency Tracker', () => {
|
|
6
|
-
test('tracks field binding dependency', () => {
|
|
7
|
-
const nodes: WidgetNode[] = [{ id: 'w1', type: 'input', bind: { field: 'name' } }];
|
|
8
|
-
const map = buildDependencyMap(nodes);
|
|
9
|
-
expect(map.fields.get('name')).toEqual(new Set(['w1']));
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('tracks expression binding dependencies', () => {
|
|
13
|
-
const nodes: WidgetNode[] = [
|
|
14
|
-
{ id: 'w1', type: 'text', bind: { expression: '{{qty * rate}}' } },
|
|
15
|
-
];
|
|
16
|
-
const map = buildDependencyMap(nodes);
|
|
17
|
-
expect(map.fields.get('qty')).toEqual(new Set(['w1']));
|
|
18
|
-
expect(map.fields.get('rate')).toEqual(new Set(['w1']));
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('tracks $state dependency in expression', () => {
|
|
22
|
-
const nodes: WidgetNode[] = [
|
|
23
|
-
{ id: 'w1', type: 'text', bind: { expression: '{{$state.step}}' } },
|
|
24
|
-
];
|
|
25
|
-
const map = buildDependencyMap(nodes);
|
|
26
|
-
expect(map.state.get('step')).toEqual(new Set(['w1']));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('tracks visible condition field dependency', () => {
|
|
30
|
-
const nodes: WidgetNode[] = [
|
|
31
|
-
{ id: 'w1', type: 'section', visible: { field: 'status', operator: 'eq', value: 'draft' } },
|
|
32
|
-
];
|
|
33
|
-
const map = buildDependencyMap(nodes);
|
|
34
|
-
expect(map.fields.get('status')).toEqual(new Set(['w1']));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('tracks $state dependency in visible condition', () => {
|
|
38
|
-
const nodes: WidgetNode[] = [
|
|
39
|
-
{ id: 'w1', type: 'section', visible: { field: '$state.step', operator: 'eq', value: 2 } },
|
|
40
|
-
];
|
|
41
|
-
const map = buildDependencyMap(nodes);
|
|
42
|
-
expect(map.state.get('step')).toEqual(new Set(['w1']));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('tracks multiple visible conditions', () => {
|
|
46
|
-
const nodes: WidgetNode[] = [
|
|
47
|
-
{
|
|
48
|
-
id: 'w1',
|
|
49
|
-
type: 'section',
|
|
50
|
-
visible: [
|
|
51
|
-
{ field: 'status', operator: 'eq', value: 'draft' },
|
|
52
|
-
{ field: '$state.editing', operator: 'eq', value: true },
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
const map = buildDependencyMap(nodes);
|
|
57
|
-
expect(map.fields.get('status')).toEqual(new Set(['w1']));
|
|
58
|
-
expect(map.state.get('editing')).toEqual(new Set(['w1']));
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('tracks props expression dependencies', () => {
|
|
62
|
-
const nodes: WidgetNode[] = [
|
|
63
|
-
{
|
|
64
|
-
id: 'w1',
|
|
65
|
-
type: 'button',
|
|
66
|
-
props: {
|
|
67
|
-
disabled: '{{$state.loading}}',
|
|
68
|
-
label: '{{if($state.step == 3, "Submit", "Next")}}',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
const map = buildDependencyMap(nodes);
|
|
73
|
-
expect(map.state.get('loading')).toEqual(new Set(['w1']));
|
|
74
|
-
expect(map.state.get('step')).toEqual(new Set(['w1']));
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('tracks children recursively', () => {
|
|
78
|
-
const nodes: WidgetNode[] = [
|
|
79
|
-
{
|
|
80
|
-
id: 'parent',
|
|
81
|
-
type: 'group',
|
|
82
|
-
children: [
|
|
83
|
-
{ id: 'child1', type: 'input', bind: { field: 'name' } },
|
|
84
|
-
{ id: 'child2', type: 'text', bind: { expression: '{{total}}' } },
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
|
-
const map = buildDependencyMap(nodes);
|
|
89
|
-
expect(map.fields.get('name')).toEqual(new Set(['child1']));
|
|
90
|
-
expect(map.fields.get('total')).toEqual(new Set(['child2']));
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('multiple widgets depending on same field', () => {
|
|
94
|
-
const nodes: WidgetNode[] = [
|
|
95
|
-
{ id: 'w1', type: 'input', bind: { field: 'qty' } },
|
|
96
|
-
{ id: 'w2', type: 'text', bind: { expression: '{{qty * rate}}' } },
|
|
97
|
-
];
|
|
98
|
-
const map = buildDependencyMap(nodes);
|
|
99
|
-
expect(map.fields.get('qty')).toEqual(new Set(['w1', 'w2']));
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('getAffectedWidgets returns correct set for field', () => {
|
|
103
|
-
const nodes: WidgetNode[] = [
|
|
104
|
-
{ id: 'w1', type: 'input', bind: { field: 'qty' } },
|
|
105
|
-
{ id: 'w2', type: 'text', bind: { expression: '{{qty * rate}}' } },
|
|
106
|
-
{ id: 'w3', type: 'text', bind: { field: 'name' } },
|
|
107
|
-
];
|
|
108
|
-
const map = buildDependencyMap(nodes);
|
|
109
|
-
expect(getAffectedWidgets(map, 'qty', false)).toEqual(new Set(['w1', 'w2']));
|
|
110
|
-
expect(getAffectedWidgets(map, 'name', false)).toEqual(new Set(['w3']));
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('getAffectedWidgets returns correct set for state key', () => {
|
|
114
|
-
const nodes: WidgetNode[] = [
|
|
115
|
-
{ id: 'w1', type: 'button', props: { disabled: '{{$state.loading}}' } },
|
|
116
|
-
{ id: 'w2', type: 'section', visible: { field: '$state.step', operator: 'eq', value: 2 } },
|
|
117
|
-
];
|
|
118
|
-
const map = buildDependencyMap(nodes);
|
|
119
|
-
expect(getAffectedWidgets(map, 'loading', true)).toEqual(new Set(['w1']));
|
|
120
|
-
expect(getAffectedWidgets(map, 'step', true)).toEqual(new Set(['w2']));
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test('getAffectedWidgets returns empty set for unknown key', () => {
|
|
124
|
-
const map = buildDependencyMap([]);
|
|
125
|
-
expect(getAffectedWidgets(map, 'unknown', false)).toEqual(new Set());
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('generates path-based id when node has no id', () => {
|
|
129
|
-
const nodes: WidgetNode[] = [{ type: 'input', bind: { field: 'name' } }];
|
|
130
|
-
const map = buildDependencyMap(nodes);
|
|
131
|
-
expect(map.fields.get('name')).toEqual(new Set(['[0]']));
|
|
132
|
-
});
|
|
133
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import { TreeWidget } from '../components/TreeWidget.js';
|
|
6
|
-
|
|
7
|
-
const defaultProps = {
|
|
8
|
-
props: {},
|
|
9
|
-
bind: {
|
|
10
|
-
value: null,
|
|
11
|
-
meta: {
|
|
12
|
-
type: 'tree',
|
|
13
|
-
label: 'Parent',
|
|
14
|
-
required: false,
|
|
15
|
-
readOnly: false,
|
|
16
|
-
options: [
|
|
17
|
-
{ label: 'Root', value: 'cat-1', path: 'Root' },
|
|
18
|
-
{ label: 'Electronics', value: 'cat-2', path: 'Root / Electronics' },
|
|
19
|
-
{ label: 'Phones', value: 'cat-3', path: 'Root / Electronics / Phones' },
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
on: {},
|
|
24
|
-
context: { record: {}, model: '', mode: 'view' as const },
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
afterEach(() => cleanup());
|
|
28
|
-
|
|
29
|
-
describe('TreeWidget', () => {
|
|
30
|
-
it('renders a combobox button', () => {
|
|
31
|
-
render(<TreeWidget {...defaultProps} />);
|
|
32
|
-
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('displays label', () => {
|
|
36
|
-
render(<TreeWidget {...defaultProps} />);
|
|
37
|
-
expect(screen.getByText('Parent')).toBeInTheDocument();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('shows placeholder when no value', () => {
|
|
41
|
-
render(<TreeWidget {...defaultProps} />);
|
|
42
|
-
expect(screen.getByText('Select parent...')).toBeInTheDocument();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('shows selected option path', () => {
|
|
46
|
-
render(<TreeWidget {...defaultProps} bind={{ ...defaultProps.bind, value: 'cat-3' }} />);
|
|
47
|
-
expect(screen.getByText('Root / Electronics / Phones')).toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('handles disabled state', () => {
|
|
51
|
-
render(<TreeWidget {...defaultProps} props={{ disabled: true }} />);
|
|
52
|
-
expect(screen.getByRole('combobox')).toBeDisabled();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it.skip('fires on.change when selecting', async () => {
|
|
56
|
-
const onChange = vi.fn();
|
|
57
|
-
render(<TreeWidget {...defaultProps} on={{ change: onChange }} />);
|
|
58
|
-
await userEvent.click(screen.getByRole('combobox'));
|
|
59
|
-
await userEvent.click(screen.getByText('Root / Electronics'));
|
|
60
|
-
expect(onChange).toHaveBeenCalledWith('cat-2');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it.skip('fires on.search when typing', async () => {
|
|
64
|
-
const onSearch = vi.fn();
|
|
65
|
-
render(<TreeWidget {...defaultProps} on={{ search: onSearch }} />);
|
|
66
|
-
await userEvent.click(screen.getByRole('combobox'));
|
|
67
|
-
fireEvent.change(screen.getByPlaceholderText('Search...'), { target: { value: 'phone' } });
|
|
68
|
-
expect(onSearch).toHaveBeenCalledWith('phone');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('handles null bind.value gracefully', () => {
|
|
72
|
-
render(<TreeWidget {...defaultProps} />);
|
|
73
|
-
expect(screen.getByText('Select parent...')).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it.skip('shows clear option when value selected', async () => {
|
|
77
|
-
render(<TreeWidget {...defaultProps} bind={{ ...defaultProps.bind, value: 'cat-1' }} />);
|
|
78
|
-
await userEvent.click(screen.getByRole('combobox'));
|
|
79
|
-
expect(screen.getByText('Clear selection')).toBeInTheDocument();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it.skip('clears value when clear option clicked', async () => {
|
|
83
|
-
const onChange = vi.fn();
|
|
84
|
-
const setValue = vi.fn();
|
|
85
|
-
render(
|
|
86
|
-
<TreeWidget
|
|
87
|
-
{...defaultProps}
|
|
88
|
-
bind={{ ...defaultProps.bind, value: 'cat-1', setValue }}
|
|
89
|
-
on={{ change: onChange }}
|
|
90
|
-
/>,
|
|
91
|
-
);
|
|
92
|
-
await userEvent.click(screen.getByRole('combobox'));
|
|
93
|
-
await userEvent.click(screen.getByText('Clear selection'));
|
|
94
|
-
expect(setValue).toHaveBeenCalledWith(null);
|
|
95
|
-
expect(onChange).toHaveBeenCalledWith(null);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { filtersToParams, sortToString } from '../data/useModelQuery.js';
|
|
3
|
-
import type { ParsedFilter, SortEntry } from '../reactivity/variables.js';
|
|
4
|
-
|
|
5
|
-
describe('useModelSource helpers', () => {
|
|
6
|
-
describe('filtersToParams', () => {
|
|
7
|
-
it('converts eq filter to simple key', () => {
|
|
8
|
-
const filters: ParsedFilter[] = [
|
|
9
|
-
{ model: 'sales.order', field: 'status', operator: 'eq', value: 'draft' },
|
|
10
|
-
];
|
|
11
|
-
expect(filtersToParams(filters)).toEqual({ 'filter[status]': 'draft' });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('converts operator filter to nested key', () => {
|
|
15
|
-
const filters: ParsedFilter[] = [
|
|
16
|
-
{ model: 'sales.order', field: 'total', operator: 'gt', value: 1000 },
|
|
17
|
-
];
|
|
18
|
-
expect(filtersToParams(filters)).toEqual({ 'filter[total][gt]': '1000' });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('converts multiple filters', () => {
|
|
22
|
-
const filters: ParsedFilter[] = [
|
|
23
|
-
{ model: 'sales.order', field: 'status', operator: 'eq', value: 'paid' },
|
|
24
|
-
{ model: 'sales.order', field: 'total', operator: 'gte', value: 500 },
|
|
25
|
-
{ model: 'sales.order', field: 'name', operator: 'like', value: 'acme' },
|
|
26
|
-
];
|
|
27
|
-
const result = filtersToParams(filters);
|
|
28
|
-
expect(result).toEqual({
|
|
29
|
-
'filter[status]': 'paid',
|
|
30
|
-
'filter[total][gte]': '500',
|
|
31
|
-
'filter[name][like]': 'acme',
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('returns empty object for empty filters', () => {
|
|
36
|
-
expect(filtersToParams([])).toEqual({});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('sortToString', () => {
|
|
41
|
-
it('converts single asc sort', () => {
|
|
42
|
-
const sort: SortEntry[] = [{ field: 'name', direction: 'asc' }];
|
|
43
|
-
expect(sortToString(sort)).toBe('name');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('converts single desc sort', () => {
|
|
47
|
-
const sort: SortEntry[] = [{ field: 'date', direction: 'desc' }];
|
|
48
|
-
expect(sortToString(sort)).toBe('-date');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('converts multi-field sort', () => {
|
|
52
|
-
const sort: SortEntry[] = [
|
|
53
|
-
{ field: 'date', direction: 'desc' },
|
|
54
|
-
{ field: 'name', direction: 'asc' },
|
|
55
|
-
];
|
|
56
|
-
expect(sortToString(sort)).toBe('-date,name');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('returns undefined for null sort', () => {
|
|
60
|
-
expect(sortToString(null)).toBeUndefined();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('returns undefined for empty array', () => {
|
|
64
|
-
expect(sortToString([])).toBeUndefined();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|