@rangka/client 0.1.0 → 0.1.2
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/components/ui/input-group.d.ts +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/AttachmentWidget-BTTGroHP.js +1 -0
- package/dist/shell/assets/AttachmentsWidget-DZgvmO9P.js +1 -0
- package/dist/shell/assets/BadgeWidget-DN6GsAAG.js +1 -0
- package/dist/shell/assets/CardWidget-qX-UvqJh.js +1 -0
- package/dist/shell/assets/CheckboxWidget-CYPZ85ih.js +1 -0
- package/dist/shell/assets/CodeWidget-DnVtHG1d.js +1 -0
- package/dist/shell/assets/ColumnWidget-CYmFCVOf.js +1 -0
- package/dist/shell/assets/ComputedWidget-BQApkfir.js +1 -0
- package/dist/shell/assets/DatePickerWidget-pEusSy9D.js +1 -0
- package/dist/shell/assets/DatetimeWidget-M0fEGDTD.js +1 -0
- package/dist/shell/assets/DividerWidget-hXVGhIKC.js +1 -0
- package/dist/shell/assets/DrawerWidget-DynL7EIy.js +1 -0
- package/dist/shell/assets/DynamicLinkWidget-ChMJ5DAf.js +1 -0
- package/dist/shell/assets/IconWidget-Cgo9txq1.js +1 -0
- package/dist/shell/assets/ImageWidget-YUv1_OQK.js +1 -0
- package/dist/shell/assets/JsonWidget-RHUHhXHJ.js +1 -0
- package/dist/shell/assets/LinkWidget-CIu7qmb2.js +1 -0
- package/dist/shell/assets/ManyToManyWidget-DCQnygvZ.js +1 -0
- package/dist/shell/assets/ModalWidget-FggzYaS2.js +1 -0
- package/dist/shell/assets/MoneyWidget-CKjOSucD.js +1 -0
- package/dist/shell/assets/RepeatWidget-Dfp4zW4d.js +1 -0
- package/dist/shell/assets/ScrollAreaWidget-CdFdf4rv.js +1 -0
- package/dist/shell/assets/SequenceWidget-DIXHZslz.js +1 -0
- package/dist/shell/assets/SpacerWidget-BgM4dC6x.js +1 -0
- package/dist/shell/assets/SplitWidget-_mcQkjQk.js +1 -0
- package/dist/shell/assets/StackWidget-BI_VIreo.js +1 -0
- package/dist/shell/assets/TableWidget-DuIvd6qR.js +1 -0
- package/dist/shell/assets/TextareaWidget-CATua7Ls.js +1 -0
- package/dist/shell/assets/TreeWidget-BoHlhfza.js +1 -0
- package/dist/shell/assets/calendar-DqckiKt1.js +1 -0
- package/dist/shell/assets/index-63v1sBS3.css +1 -0
- package/dist/shell/assets/index-D1wStSrO.js +8635 -0
- package/dist/shell/assets/popover-DywIKFaQ.js +1 -0
- package/dist/shell/assets/textarea-BVCZevA6.js +1 -0
- package/dist/shell/assets/useSurfaceContext-kzu9770H.js +1 -0
- package/dist/shell/assets/vendor-query-dRdWN_eK.js +1 -0
- package/dist/shell/assets/vendor-radix-D-Trh8JA.js +69 -0
- package/dist/shell/assets/vendor-router-B1WM9yRc.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.d.ts.map +1 -1
- package/dist/widgets/components/register.js +0 -58
- 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 +99 -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 -18
- 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,133 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render, cleanup } from '@testing-library/react';
|
|
4
|
-
import { registerWidget, clearWidgetRegistry } from '../registry.js';
|
|
5
|
-
import { SplitWidget } from '../components/SplitWidget.js';
|
|
6
|
-
import { WidgetContextProvider } from '../hooks/useWidgetContext.js';
|
|
7
|
-
import { PageStateProvider } from '../hooks/usePageState.js';
|
|
8
|
-
import { StateStore } from '../state/store.js';
|
|
9
|
-
import type { WidgetProps } from '../types.js';
|
|
10
|
-
import type { ComponentType } from 'react';
|
|
11
|
-
import type { WidgetNode } from '@rangka/shared';
|
|
12
|
-
|
|
13
|
-
vi.mock('react-resizable-panels', () => ({
|
|
14
|
-
Group: ({ children, className }: { children: React.ReactNode; className?: string }) => (
|
|
15
|
-
<div data-testid="panel-group" className={className}>
|
|
16
|
-
{children}
|
|
17
|
-
</div>
|
|
18
|
-
),
|
|
19
|
-
Panel: ({ children, defaultSize }: { children: React.ReactNode; defaultSize?: number }) => (
|
|
20
|
-
<div data-testid="panel" data-default-size={defaultSize}>
|
|
21
|
-
{children}
|
|
22
|
-
</div>
|
|
23
|
-
),
|
|
24
|
-
Separator: ({ children }: { children?: React.ReactNode }) => (
|
|
25
|
-
<div data-testid="separator">{children}</div>
|
|
26
|
-
),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
function TestChild({ props }: WidgetProps) {
|
|
30
|
-
return <div data-testid="child">{String(props.label ?? '')}</div>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
clearWidgetRegistry();
|
|
35
|
-
registerWidget(
|
|
36
|
-
{
|
|
37
|
-
name: 'split',
|
|
38
|
-
label: 'Split',
|
|
39
|
-
category: 'layout',
|
|
40
|
-
schema: {},
|
|
41
|
-
binding: 'none',
|
|
42
|
-
triggers: [],
|
|
43
|
-
container: true,
|
|
44
|
-
},
|
|
45
|
-
SplitWidget as unknown as ComponentType<WidgetProps>,
|
|
46
|
-
);
|
|
47
|
-
registerWidget(
|
|
48
|
-
{
|
|
49
|
-
name: 'test-child',
|
|
50
|
-
label: 'Test Child',
|
|
51
|
-
category: 'display',
|
|
52
|
-
schema: {},
|
|
53
|
-
binding: 'none',
|
|
54
|
-
triggers: [],
|
|
55
|
-
container: false,
|
|
56
|
-
},
|
|
57
|
-
TestChild,
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
afterEach(() => {
|
|
62
|
-
cleanup();
|
|
63
|
-
clearWidgetRegistry();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const makeChildNodes = (labels: string[]): WidgetNode[] =>
|
|
67
|
-
labels.map((label) => ({ type: 'test-child', props: { label } }));
|
|
68
|
-
|
|
69
|
-
const defaultCtx = { record: {}, model: '', mode: 'view' as const };
|
|
70
|
-
|
|
71
|
-
function renderSplit(props: Record<string, unknown>, childNodes: WidgetNode[]) {
|
|
72
|
-
const store = new StateStore();
|
|
73
|
-
return render(
|
|
74
|
-
<PageStateProvider value={store}>
|
|
75
|
-
<WidgetContextProvider value={defaultCtx}>
|
|
76
|
-
<SplitWidget
|
|
77
|
-
props={props}
|
|
78
|
-
bind={{ value: undefined }}
|
|
79
|
-
on={{}}
|
|
80
|
-
context={defaultCtx}
|
|
81
|
-
childNodes={childNodes}
|
|
82
|
-
/>
|
|
83
|
-
</WidgetContextProvider>
|
|
84
|
-
</PageStateProvider>,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
describe('SplitWidget', () => {
|
|
89
|
-
it('renders children in resizable panels', () => {
|
|
90
|
-
const { container } = renderSplit(
|
|
91
|
-
{ sizes: [60, 40], direction: 'horizontal' },
|
|
92
|
-
makeChildNodes(['Left', 'Right']),
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const panels = container.querySelectorAll('[data-testid="panel"]');
|
|
96
|
-
expect(panels).toHaveLength(2);
|
|
97
|
-
expect(panels[0].getAttribute('data-default-size')).toBe('60');
|
|
98
|
-
expect(panels[1].getAttribute('data-default-size')).toBe('40');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('distributes equally when sizes not provided', () => {
|
|
102
|
-
const { container } = renderSplit({}, makeChildNodes(['A', 'B', 'C']));
|
|
103
|
-
|
|
104
|
-
const panels = container.querySelectorAll('[data-testid="panel"]');
|
|
105
|
-
expect(panels).toHaveLength(3);
|
|
106
|
-
const expectedSize = String(100 / 3);
|
|
107
|
-
expect(panels[0].getAttribute('data-default-size')).toBe(expectedSize);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('renders with vertical orientation', () => {
|
|
111
|
-
const { container } = renderSplit(
|
|
112
|
-
{ sizes: [50, 50], direction: 'vertical' },
|
|
113
|
-
makeChildNodes(['Top', 'Bottom']),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const panels = container.querySelectorAll('[data-testid="panel"]');
|
|
117
|
-
expect(panels).toHaveLength(2);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('defaults to horizontal direction', () => {
|
|
121
|
-
const { container } = renderSplit({ sizes: [70, 30] }, makeChildNodes(['Left', 'Right']));
|
|
122
|
-
|
|
123
|
-
const panels = container.querySelectorAll('[data-testid="panel"]');
|
|
124
|
-
expect(panels).toHaveLength(2);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('renders resize handles between panels', () => {
|
|
128
|
-
const { container } = renderSplit({ sizes: [25, 50, 25] }, makeChildNodes(['A', 'B', 'C']));
|
|
129
|
-
|
|
130
|
-
const separators = container.querySelectorAll('[data-testid="separator"]');
|
|
131
|
-
expect(separators).toHaveLength(2);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from 'vitest';
|
|
2
|
-
import { StateStore } from '../state/store.js';
|
|
3
|
-
|
|
4
|
-
describe('StateStore Edge Cases', () => {
|
|
5
|
-
test('set with undefined value', () => {
|
|
6
|
-
const store = new StateStore();
|
|
7
|
-
store.set('key', undefined);
|
|
8
|
-
expect(store.get('key')).toBeUndefined();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('set distinguishes null from undefined', () => {
|
|
12
|
-
const store = new StateStore();
|
|
13
|
-
store.set('a', null);
|
|
14
|
-
store.set('b', undefined);
|
|
15
|
-
expect(store.get('a')).toBeNull();
|
|
16
|
-
expect(store.get('b')).toBeUndefined();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('multiple subscribers on same key all fire', () => {
|
|
20
|
-
const store = new StateStore();
|
|
21
|
-
const calls1: unknown[] = [];
|
|
22
|
-
const calls2: unknown[] = [];
|
|
23
|
-
store.subscribe('k', (v) => calls1.push(v));
|
|
24
|
-
store.subscribe('k', (v) => calls2.push(v));
|
|
25
|
-
store.set('k', 'hello');
|
|
26
|
-
expect(calls1).toEqual(['hello']);
|
|
27
|
-
expect(calls2).toEqual(['hello']);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('subscriber added during notification fires on next change', () => {
|
|
31
|
-
const store = new StateStore();
|
|
32
|
-
const calls: unknown[] = [];
|
|
33
|
-
store.subscribe('k', () => {
|
|
34
|
-
store.subscribe('k', (v) => calls.push(v));
|
|
35
|
-
});
|
|
36
|
-
store.set('k', 1);
|
|
37
|
-
calls.length = 0;
|
|
38
|
-
store.set('k', 2);
|
|
39
|
-
expect(calls.length).toBeGreaterThanOrEqual(1);
|
|
40
|
-
expect(calls).toContain(2);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('set with same reference value does not notify', () => {
|
|
44
|
-
const store = new StateStore();
|
|
45
|
-
const obj = { a: 1 };
|
|
46
|
-
store.set('k', obj);
|
|
47
|
-
const calls: unknown[] = [];
|
|
48
|
-
store.subscribe('k', (v) => calls.push(v));
|
|
49
|
-
store.set('k', obj);
|
|
50
|
-
expect(calls).toEqual([]);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('set with different object reference does notify', () => {
|
|
54
|
-
const store = new StateStore();
|
|
55
|
-
store.set('k', { a: 1 });
|
|
56
|
-
const calls: unknown[] = [];
|
|
57
|
-
store.subscribe('k', (v) => calls.push(v));
|
|
58
|
-
store.set('k', { a: 1 });
|
|
59
|
-
expect(calls).toHaveLength(1);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('setMany with all unchanged keys does not notify', () => {
|
|
63
|
-
const store = new StateStore();
|
|
64
|
-
store.set('a', 1);
|
|
65
|
-
store.set('b', 2);
|
|
66
|
-
const calls: unknown[] = [];
|
|
67
|
-
store.subscribe('a', (v) => calls.push(v));
|
|
68
|
-
store.subscribe('b', (v) => calls.push(v));
|
|
69
|
-
store.setMany({ a: 1, b: 2 });
|
|
70
|
-
expect(calls).toEqual([]);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test('unsubscribe same function twice is safe', () => {
|
|
74
|
-
const store = new StateStore();
|
|
75
|
-
const fn = () => {};
|
|
76
|
-
const unsub = store.subscribe('k', fn);
|
|
77
|
-
unsub();
|
|
78
|
-
unsub();
|
|
79
|
-
store.set('k', 1);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('keys after clear is empty', () => {
|
|
83
|
-
const store = new StateStore();
|
|
84
|
-
store.set('a', 1);
|
|
85
|
-
store.set('b', 2);
|
|
86
|
-
store.clear();
|
|
87
|
-
expect(store.keys()).toEqual([]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('set after clear works normally', () => {
|
|
91
|
-
const store = new StateStore();
|
|
92
|
-
store.set('a', 1);
|
|
93
|
-
store.clear();
|
|
94
|
-
store.set('a', 2);
|
|
95
|
-
expect(store.get('a')).toBe(2);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('subscribe after clear works normally', () => {
|
|
99
|
-
const store = new StateStore();
|
|
100
|
-
store.subscribe('k', () => {});
|
|
101
|
-
store.clear();
|
|
102
|
-
const calls: unknown[] = [];
|
|
103
|
-
store.subscribe('k', (v) => calls.push(v));
|
|
104
|
-
store.set('k', 'new');
|
|
105
|
-
expect(calls).toEqual(['new']);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
test('handles rapid set cycles', () => {
|
|
109
|
-
const store = new StateStore();
|
|
110
|
-
const calls: unknown[] = [];
|
|
111
|
-
store.subscribe('counter', (v) => calls.push(v));
|
|
112
|
-
for (let i = 0; i < 100; i++) {
|
|
113
|
-
store.set('counter', i);
|
|
114
|
-
}
|
|
115
|
-
expect(calls).toHaveLength(100);
|
|
116
|
-
expect(calls[99]).toBe(99);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from 'vitest';
|
|
2
|
-
import { StateStore } from '../state/store.js';
|
|
3
|
-
|
|
4
|
-
describe('StateStore', () => {
|
|
5
|
-
test('get returns undefined for unset key', () => {
|
|
6
|
-
const store = new StateStore();
|
|
7
|
-
expect(store.get('missing')).toBeUndefined();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test('set and get a value', () => {
|
|
11
|
-
const store = new StateStore();
|
|
12
|
-
store.set('step', 1);
|
|
13
|
-
expect(store.get('step')).toBe(1);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('set overwrites existing value', () => {
|
|
17
|
-
const store = new StateStore();
|
|
18
|
-
store.set('step', 1);
|
|
19
|
-
store.set('step', 2);
|
|
20
|
-
expect(store.get('step')).toBe(2);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('subscribe is called on change', () => {
|
|
24
|
-
const store = new StateStore();
|
|
25
|
-
const calls: unknown[] = [];
|
|
26
|
-
store.subscribe('step', (v) => calls.push(v));
|
|
27
|
-
store.set('step', 1);
|
|
28
|
-
store.set('step', 2);
|
|
29
|
-
expect(calls).toEqual([1, 2]);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('subscribe is not called when value unchanged', () => {
|
|
33
|
-
const store = new StateStore();
|
|
34
|
-
store.set('step', 1);
|
|
35
|
-
const calls: unknown[] = [];
|
|
36
|
-
store.subscribe('step', (v) => calls.push(v));
|
|
37
|
-
store.set('step', 1);
|
|
38
|
-
expect(calls).toEqual([]);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('unsubscribe stops notifications', () => {
|
|
42
|
-
const store = new StateStore();
|
|
43
|
-
const calls: unknown[] = [];
|
|
44
|
-
const unsub = store.subscribe('step', (v) => calls.push(v));
|
|
45
|
-
store.set('step', 1);
|
|
46
|
-
unsub();
|
|
47
|
-
store.set('step', 2);
|
|
48
|
-
expect(calls).toEqual([1]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('setMany updates multiple keys', () => {
|
|
52
|
-
const store = new StateStore();
|
|
53
|
-
store.setMany({ step: 1, loading: true });
|
|
54
|
-
expect(store.get('step')).toBe(1);
|
|
55
|
-
expect(store.get('loading')).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('setMany notifies subscribers for each changed key', () => {
|
|
59
|
-
const store = new StateStore();
|
|
60
|
-
const stepCalls: unknown[] = [];
|
|
61
|
-
const loadingCalls: unknown[] = [];
|
|
62
|
-
store.subscribe('step', (v) => stepCalls.push(v));
|
|
63
|
-
store.subscribe('loading', (v) => loadingCalls.push(v));
|
|
64
|
-
store.setMany({ step: 1, loading: true });
|
|
65
|
-
expect(stepCalls).toEqual([1]);
|
|
66
|
-
expect(loadingCalls).toEqual([true]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('setMany skips unchanged keys', () => {
|
|
70
|
-
const store = new StateStore();
|
|
71
|
-
store.set('step', 1);
|
|
72
|
-
const calls: unknown[] = [];
|
|
73
|
-
store.subscribe('step', (v) => calls.push(v));
|
|
74
|
-
store.setMany({ step: 1, loading: true });
|
|
75
|
-
expect(calls).toEqual([]);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test('writing one key does not affect others', () => {
|
|
79
|
-
const store = new StateStore();
|
|
80
|
-
store.set('a', 1);
|
|
81
|
-
store.set('b', 2);
|
|
82
|
-
const calls: unknown[] = [];
|
|
83
|
-
store.subscribe('b', (v) => calls.push(v));
|
|
84
|
-
store.set('a', 10);
|
|
85
|
-
expect(calls).toEqual([]);
|
|
86
|
-
expect(store.get('b')).toBe(2);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('clear removes all state and subscribers', () => {
|
|
90
|
-
const store = new StateStore();
|
|
91
|
-
store.set('a', 1);
|
|
92
|
-
const calls: unknown[] = [];
|
|
93
|
-
store.subscribe('a', (v) => calls.push(v));
|
|
94
|
-
store.clear();
|
|
95
|
-
expect(store.get('a')).toBeUndefined();
|
|
96
|
-
store.set('a', 2);
|
|
97
|
-
expect(calls).toEqual([]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('keys returns all set keys', () => {
|
|
101
|
-
const store = new StateStore();
|
|
102
|
-
store.set('a', 1);
|
|
103
|
-
store.set('b', 2);
|
|
104
|
-
expect(store.keys().sort()).toEqual(['a', 'b']);
|
|
105
|
-
});
|
|
106
|
-
});
|