@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,189 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WidgetNode } from '@rangka/shared';
|
|
3
|
-
import type { WidgetProps } from '../types.js';
|
|
4
|
-
import { useModelRecord } from '../data/useModelRecord.js';
|
|
5
|
-
import { useModelQuery } from '../data/useModelQuery.js';
|
|
6
|
-
import { useWidgetContext, WidgetContextProvider } from '../hooks/useWidgetContext.js';
|
|
7
|
-
import { WidgetRenderer } from '../renderer/WidgetRenderer.js';
|
|
8
|
-
import type { WidgetContext } from '../context/types.js';
|
|
9
|
-
|
|
10
|
-
export function DataWidget({ bind, props, on, childNodes }: WidgetProps) {
|
|
11
|
-
const ctx = useWidgetContext();
|
|
12
|
-
const modelName = ctx.model;
|
|
13
|
-
const id = bind.id ?? undefined;
|
|
14
|
-
const pageSize = props.pageSize as number | undefined;
|
|
15
|
-
const placeholder = props.placeholder as string | undefined;
|
|
16
|
-
|
|
17
|
-
if (!modelName) return null;
|
|
18
|
-
|
|
19
|
-
if (id) {
|
|
20
|
-
return (
|
|
21
|
-
<DataRecordMode
|
|
22
|
-
model={modelName}
|
|
23
|
-
id={id}
|
|
24
|
-
placeholder={placeholder}
|
|
25
|
-
on={on}
|
|
26
|
-
childNodes={childNodes}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<DataListMode
|
|
33
|
-
model={modelName}
|
|
34
|
-
pageSize={pageSize}
|
|
35
|
-
placeholder={placeholder}
|
|
36
|
-
on={on}
|
|
37
|
-
childNodes={childNodes}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function DataRecordMode({
|
|
43
|
-
model,
|
|
44
|
-
id,
|
|
45
|
-
placeholder,
|
|
46
|
-
on,
|
|
47
|
-
childNodes,
|
|
48
|
-
}: {
|
|
49
|
-
model: string;
|
|
50
|
-
id: string;
|
|
51
|
-
placeholder?: string;
|
|
52
|
-
on: Record<string, (...args: unknown[]) => void>;
|
|
53
|
-
childNodes?: WidgetNode[];
|
|
54
|
-
}) {
|
|
55
|
-
const parentCtx = useWidgetContext();
|
|
56
|
-
const { data, isLoading, error } = useModelRecord({ model, id });
|
|
57
|
-
|
|
58
|
-
React.useEffect(() => {
|
|
59
|
-
if (error) on.error?.({ message: error.message });
|
|
60
|
-
}, [error, on]);
|
|
61
|
-
|
|
62
|
-
React.useEffect(() => {
|
|
63
|
-
if (data) on.load?.({ record: data });
|
|
64
|
-
}, [data, on]);
|
|
65
|
-
|
|
66
|
-
if (isLoading) {
|
|
67
|
-
if (placeholder)
|
|
68
|
-
return (
|
|
69
|
-
<div data-rangka-widget="data" data-state="loading">
|
|
70
|
-
{placeholder}
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!data) {
|
|
77
|
-
if (placeholder)
|
|
78
|
-
return (
|
|
79
|
-
<div data-rangka-widget="data" data-state="empty">
|
|
80
|
-
{placeholder}
|
|
81
|
-
</div>
|
|
82
|
-
);
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const ctx: WidgetContext = {
|
|
87
|
-
record: data,
|
|
88
|
-
model,
|
|
89
|
-
mode: 'view',
|
|
90
|
-
parent: parentCtx,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<WidgetContextProvider value={ctx}>
|
|
95
|
-
<div data-rangka-widget="data">
|
|
96
|
-
<DataChildren childNodes={childNodes} />
|
|
97
|
-
</div>
|
|
98
|
-
</WidgetContextProvider>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function DataListMode({
|
|
103
|
-
model,
|
|
104
|
-
pageSize,
|
|
105
|
-
placeholder,
|
|
106
|
-
on,
|
|
107
|
-
childNodes,
|
|
108
|
-
}: {
|
|
109
|
-
model: string;
|
|
110
|
-
pageSize?: number;
|
|
111
|
-
placeholder?: string;
|
|
112
|
-
on: Record<string, (...args: unknown[]) => void>;
|
|
113
|
-
childNodes?: WidgetNode[];
|
|
114
|
-
}) {
|
|
115
|
-
const parentCtx = useWidgetContext();
|
|
116
|
-
const { data, isLoading, error } = useModelQuery({
|
|
117
|
-
model,
|
|
118
|
-
pageSize: pageSize ?? 20,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
React.useEffect(() => {
|
|
122
|
-
if (error) on.error?.({ message: error.message });
|
|
123
|
-
}, [error, on]);
|
|
124
|
-
|
|
125
|
-
React.useEffect(() => {
|
|
126
|
-
if (data && data.length > 0) on.load?.({ records: data });
|
|
127
|
-
}, [data, on]);
|
|
128
|
-
|
|
129
|
-
if (isLoading) {
|
|
130
|
-
if (placeholder)
|
|
131
|
-
return (
|
|
132
|
-
<div data-rangka-widget="data" data-state="loading">
|
|
133
|
-
{placeholder}
|
|
134
|
-
</div>
|
|
135
|
-
);
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (!data || data.length === 0) {
|
|
140
|
-
if (placeholder)
|
|
141
|
-
return (
|
|
142
|
-
<div data-rangka-widget="data" data-state="empty">
|
|
143
|
-
{placeholder}
|
|
144
|
-
</div>
|
|
145
|
-
);
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const ctx: WidgetContext = {
|
|
150
|
-
record: data[0],
|
|
151
|
-
records: data,
|
|
152
|
-
model,
|
|
153
|
-
mode: 'view',
|
|
154
|
-
parent: parentCtx,
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<WidgetContextProvider value={ctx}>
|
|
159
|
-
<div data-rangka-widget="data">
|
|
160
|
-
<DataChildren childNodes={childNodes} />
|
|
161
|
-
</div>
|
|
162
|
-
</WidgetContextProvider>
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function DataChildren({ childNodes }: { childNodes?: WidgetNode[] }) {
|
|
167
|
-
if (!childNodes || childNodes.length === 0) return null;
|
|
168
|
-
|
|
169
|
-
return (
|
|
170
|
-
<>
|
|
171
|
-
{childNodes.map((child, i) => (
|
|
172
|
-
<WidgetRenderer key={child.id ?? i} node={child} />
|
|
173
|
-
))}
|
|
174
|
-
</>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
DataWidget.widgetMeta = {
|
|
179
|
-
name: 'data',
|
|
180
|
-
label: 'Data',
|
|
181
|
-
category: 'data' as const,
|
|
182
|
-
schema: {
|
|
183
|
-
placeholder: { type: 'string' as const },
|
|
184
|
-
pageSize: { type: 'number' as const },
|
|
185
|
-
},
|
|
186
|
-
binding: 'model' as const,
|
|
187
|
-
triggers: ['load', 'error'],
|
|
188
|
-
container: true,
|
|
189
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
|
|
3
|
-
import { Button } from '@/components/ui/button';
|
|
4
|
-
import { Calendar } from '@/components/ui/calendar';
|
|
5
|
-
import { Field, FieldLabel } from '@/components/ui/field';
|
|
6
|
-
import { CalendarIcon } from 'lucide-react';
|
|
7
|
-
import { format, parseISO } from 'date-fns';
|
|
8
|
-
import type { WidgetProps } from '../types.js';
|
|
9
|
-
|
|
10
|
-
export function DatePickerWidget({ props, bind, on }: WidgetProps) {
|
|
11
|
-
const label = (props.label as string) ?? bind.meta?.label ?? '';
|
|
12
|
-
const disabled = (props.disabled as boolean) ?? bind.meta?.readOnly ?? false;
|
|
13
|
-
const [open, setOpen] = useState(false);
|
|
14
|
-
const error = bind.error;
|
|
15
|
-
|
|
16
|
-
const rawValue = bind.value as string | null | undefined;
|
|
17
|
-
const dateValue = rawValue ? parseISO(rawValue) : undefined;
|
|
18
|
-
|
|
19
|
-
const handleSelect = (day: Date | undefined) => {
|
|
20
|
-
if (day) {
|
|
21
|
-
const iso = format(day, 'yyyy-MM-dd');
|
|
22
|
-
bind.setValue?.(iso);
|
|
23
|
-
on.change?.(iso);
|
|
24
|
-
}
|
|
25
|
-
setOpen(false);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Field>
|
|
30
|
-
{label && <FieldLabel>{label}</FieldLabel>}
|
|
31
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
32
|
-
<PopoverTrigger asChild>
|
|
33
|
-
<Button
|
|
34
|
-
variant="outline"
|
|
35
|
-
disabled={disabled}
|
|
36
|
-
className="w-full justify-start text-left font-normal h-8 text-xs"
|
|
37
|
-
>
|
|
38
|
-
<CalendarIcon className="mr-2 size-3.5 text-muted-foreground" />
|
|
39
|
-
{dateValue ? (
|
|
40
|
-
format(dateValue, 'PPP')
|
|
41
|
-
) : (
|
|
42
|
-
<span className="text-muted-foreground">Pick a date</span>
|
|
43
|
-
)}
|
|
44
|
-
</Button>
|
|
45
|
-
</PopoverTrigger>
|
|
46
|
-
<PopoverContent className="w-auto p-0" align="start">
|
|
47
|
-
<Calendar
|
|
48
|
-
mode="single"
|
|
49
|
-
selected={dateValue}
|
|
50
|
-
onSelect={handleSelect}
|
|
51
|
-
captionLayout="dropdown"
|
|
52
|
-
startMonth={new Date(1900, 0)}
|
|
53
|
-
endMonth={new Date(2100, 11)}
|
|
54
|
-
/>
|
|
55
|
-
</PopoverContent>
|
|
56
|
-
</Popover>
|
|
57
|
-
{error && <p className="text-xs text-destructive mt-1">{error}</p>}
|
|
58
|
-
</Field>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
DatePickerWidget.widgetMeta = {
|
|
63
|
-
name: 'datepicker',
|
|
64
|
-
label: 'Date Picker',
|
|
65
|
-
category: 'input' as const,
|
|
66
|
-
schema: {
|
|
67
|
-
label: { type: 'string' as const },
|
|
68
|
-
disabled: { type: 'boolean' as const, default: false },
|
|
69
|
-
},
|
|
70
|
-
binding: 'field' as const,
|
|
71
|
-
triggers: ['change'],
|
|
72
|
-
container: false,
|
|
73
|
-
};
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
|
|
3
|
-
import { Button } from '@/components/ui/button';
|
|
4
|
-
import {
|
|
5
|
-
Select,
|
|
6
|
-
SelectTrigger,
|
|
7
|
-
SelectValue,
|
|
8
|
-
SelectContent,
|
|
9
|
-
SelectItem,
|
|
10
|
-
} from '@/components/ui/select';
|
|
11
|
-
import { Calendar } from '@/components/ui/calendar';
|
|
12
|
-
import { Field, FieldLabel } from '@/components/ui/field';
|
|
13
|
-
import { CalendarIcon } from 'lucide-react';
|
|
14
|
-
import { format, parseISO, setHours, setMinutes } from 'date-fns';
|
|
15
|
-
import type { WidgetProps } from '../types.js';
|
|
16
|
-
|
|
17
|
-
const HOURS = Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i).toString());
|
|
18
|
-
const MINUTES = Array.from({ length: 60 }, (_, i) => i.toString().padStart(2, '0'));
|
|
19
|
-
const PERIODS = ['AM', 'PM'] as const;
|
|
20
|
-
|
|
21
|
-
export function DatetimeWidget({ props, bind, on }: WidgetProps) {
|
|
22
|
-
const label = (props.label as string) ?? bind.meta?.label ?? '';
|
|
23
|
-
const disabled = (props.disabled as boolean) ?? bind.meta?.readOnly ?? false;
|
|
24
|
-
const [open, setOpen] = useState(false);
|
|
25
|
-
|
|
26
|
-
const rawValue = bind.value as string | null | undefined;
|
|
27
|
-
const dateValue = rawValue ? parseISO(rawValue) : undefined;
|
|
28
|
-
|
|
29
|
-
const hours = dateValue ? dateValue.getHours() : 0;
|
|
30
|
-
const minutes = dateValue ? dateValue.getMinutes() : 0;
|
|
31
|
-
const period = hours >= 12 ? 'PM' : 'AM';
|
|
32
|
-
const displayHour = hours % 12 === 0 ? 12 : hours % 12;
|
|
33
|
-
|
|
34
|
-
const updateValue = (day: Date | undefined, h: number, m: number) => {
|
|
35
|
-
if (!day) return;
|
|
36
|
-
let d = setHours(day, h);
|
|
37
|
-
d = setMinutes(d, m);
|
|
38
|
-
const iso = d.toISOString();
|
|
39
|
-
bind.setValue?.(iso);
|
|
40
|
-
on.change?.(iso);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const handleSelect = (day: Date | undefined) => {
|
|
44
|
-
if (day) {
|
|
45
|
-
updateValue(day, hours, minutes);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const handleHourChange = (value: string) => {
|
|
50
|
-
const h12 = parseInt(value);
|
|
51
|
-
const h24 = period === 'AM' ? (h12 === 12 ? 0 : h12) : h12 === 12 ? 12 : h12 + 12;
|
|
52
|
-
const day = dateValue ?? new Date();
|
|
53
|
-
updateValue(day, h24, minutes);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const handleMinuteChange = (value: string) => {
|
|
57
|
-
const m = parseInt(value);
|
|
58
|
-
const day = dateValue ?? new Date();
|
|
59
|
-
updateValue(day, hours, m);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const handlePeriodChange = (value: string) => {
|
|
63
|
-
const h12 = displayHour;
|
|
64
|
-
const h24 = value === 'AM' ? (h12 === 12 ? 0 : h12) : h12 === 12 ? 12 : h12 + 12;
|
|
65
|
-
const day = dateValue ?? new Date();
|
|
66
|
-
updateValue(day, h24, minutes);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<Field>
|
|
71
|
-
{label && <FieldLabel>{label}</FieldLabel>}
|
|
72
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
73
|
-
<PopoverTrigger asChild>
|
|
74
|
-
<Button
|
|
75
|
-
variant="outline"
|
|
76
|
-
disabled={disabled}
|
|
77
|
-
className="w-full justify-start text-left font-normal h-8 text-xs"
|
|
78
|
-
>
|
|
79
|
-
<CalendarIcon className="mr-2 size-3.5 text-muted-foreground" />
|
|
80
|
-
{dateValue ? (
|
|
81
|
-
format(dateValue, 'PPP hh:mm a')
|
|
82
|
-
) : (
|
|
83
|
-
<span className="text-muted-foreground">Pick date and time</span>
|
|
84
|
-
)}
|
|
85
|
-
</Button>
|
|
86
|
-
</PopoverTrigger>
|
|
87
|
-
<PopoverContent className="w-auto p-0" align="start">
|
|
88
|
-
<Calendar
|
|
89
|
-
mode="single"
|
|
90
|
-
selected={dateValue}
|
|
91
|
-
onSelect={handleSelect}
|
|
92
|
-
captionLayout="dropdown"
|
|
93
|
-
startMonth={new Date(1900, 0)}
|
|
94
|
-
endMonth={new Date(2100, 11)}
|
|
95
|
-
/>
|
|
96
|
-
<div className="flex items-center gap-2 border-t border-border px-3 py-2">
|
|
97
|
-
<Select
|
|
98
|
-
value={displayHour.toString()}
|
|
99
|
-
onValueChange={handleHourChange}
|
|
100
|
-
disabled={disabled}
|
|
101
|
-
>
|
|
102
|
-
<SelectTrigger className="w-16 h-7 text-xs">
|
|
103
|
-
<SelectValue />
|
|
104
|
-
</SelectTrigger>
|
|
105
|
-
<SelectContent position="popper" className="max-h-48">
|
|
106
|
-
{HOURS.map((h) => (
|
|
107
|
-
<SelectItem key={h} value={h} className="text-xs">
|
|
108
|
-
{h}
|
|
109
|
-
</SelectItem>
|
|
110
|
-
))}
|
|
111
|
-
</SelectContent>
|
|
112
|
-
</Select>
|
|
113
|
-
<span className="text-xs text-muted-foreground">:</span>
|
|
114
|
-
<Select
|
|
115
|
-
value={minutes.toString().padStart(2, '0')}
|
|
116
|
-
onValueChange={handleMinuteChange}
|
|
117
|
-
disabled={disabled}
|
|
118
|
-
>
|
|
119
|
-
<SelectTrigger className="w-16 h-7 text-xs">
|
|
120
|
-
<SelectValue />
|
|
121
|
-
</SelectTrigger>
|
|
122
|
-
<SelectContent position="popper" className="max-h-48">
|
|
123
|
-
{MINUTES.map((m) => (
|
|
124
|
-
<SelectItem key={m} value={m} className="text-xs">
|
|
125
|
-
{m}
|
|
126
|
-
</SelectItem>
|
|
127
|
-
))}
|
|
128
|
-
</SelectContent>
|
|
129
|
-
</Select>
|
|
130
|
-
<Select value={period} onValueChange={handlePeriodChange} disabled={disabled}>
|
|
131
|
-
<SelectTrigger className="w-16 h-7 text-xs">
|
|
132
|
-
<SelectValue />
|
|
133
|
-
</SelectTrigger>
|
|
134
|
-
<SelectContent>
|
|
135
|
-
{PERIODS.map((p) => (
|
|
136
|
-
<SelectItem key={p} value={p} className="text-xs">
|
|
137
|
-
{p}
|
|
138
|
-
</SelectItem>
|
|
139
|
-
))}
|
|
140
|
-
</SelectContent>
|
|
141
|
-
</Select>
|
|
142
|
-
</div>
|
|
143
|
-
</PopoverContent>
|
|
144
|
-
</Popover>
|
|
145
|
-
</Field>
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
DatetimeWidget.widgetMeta = {
|
|
150
|
-
name: 'datetime',
|
|
151
|
-
label: 'Date & Time',
|
|
152
|
-
category: 'input' as const,
|
|
153
|
-
schema: {
|
|
154
|
-
label: { type: 'string' as const },
|
|
155
|
-
disabled: { type: 'boolean' as const, default: false },
|
|
156
|
-
},
|
|
157
|
-
binding: 'field' as const,
|
|
158
|
-
triggers: ['change'],
|
|
159
|
-
container: false,
|
|
160
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Separator } from '@/components/ui/separator';
|
|
3
|
-
import type { WidgetProps } from '../types.js';
|
|
4
|
-
|
|
5
|
-
const spacingMap: Record<string, string> = {
|
|
6
|
-
none: 'my-0',
|
|
7
|
-
sm: 'my-2',
|
|
8
|
-
md: 'my-4',
|
|
9
|
-
lg: 'my-6',
|
|
10
|
-
xl: 'my-8',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function DividerWidget({ props }: WidgetProps) {
|
|
14
|
-
const margin = (props.margin as string) ?? (props.marginY as string) ?? 'md';
|
|
15
|
-
const className = spacingMap[margin] ?? spacingMap.md;
|
|
16
|
-
|
|
17
|
-
return <Separator className={className} />;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
DividerWidget.widgetMeta = {
|
|
21
|
-
name: 'divider',
|
|
22
|
-
label: 'Divider',
|
|
23
|
-
category: 'layout' as const,
|
|
24
|
-
schema: {
|
|
25
|
-
margin: {
|
|
26
|
-
type: 'enum' as const,
|
|
27
|
-
options: ['none', 'sm', 'md', 'lg', 'xl'],
|
|
28
|
-
},
|
|
29
|
-
marginY: {
|
|
30
|
-
type: 'enum' as const,
|
|
31
|
-
options: ['none', 'sm', 'md', 'lg', 'xl'],
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
binding: 'none' as const,
|
|
35
|
-
triggers: [],
|
|
36
|
-
container: false,
|
|
37
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet';
|
|
3
|
-
import type { WidgetProps } from '../types.js';
|
|
4
|
-
import { usePageState } from '../hooks/usePageState.js';
|
|
5
|
-
|
|
6
|
-
const sizeMap = {
|
|
7
|
-
sm: 'w-80',
|
|
8
|
-
md: 'w-[28rem]',
|
|
9
|
-
lg: 'w-[40rem]',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function DrawerWidget({ props, children }: WidgetProps) {
|
|
13
|
-
const title = (props.title as string) ?? '';
|
|
14
|
-
const size = (props.width as 'sm' | 'md' | 'lg') ?? 'md';
|
|
15
|
-
const closable = (props.closable as boolean) ?? true;
|
|
16
|
-
const visibleField = props._visibleField as string | undefined;
|
|
17
|
-
const state = usePageState();
|
|
18
|
-
|
|
19
|
-
const handleOpenChange = (open: boolean) => {
|
|
20
|
-
if (!open && closable && visibleField && visibleField.startsWith('$state.')) {
|
|
21
|
-
const key = visibleField.slice(7);
|
|
22
|
-
state.set(key, false);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Sheet open={true} onOpenChange={handleOpenChange}>
|
|
28
|
-
<SheetContent className={sizeMap[size]} side="right">
|
|
29
|
-
{title && (
|
|
30
|
-
<SheetHeader>
|
|
31
|
-
<SheetTitle>{title}</SheetTitle>
|
|
32
|
-
</SheetHeader>
|
|
33
|
-
)}
|
|
34
|
-
<div className="flex-1 overflow-y-auto p-4">{children}</div>
|
|
35
|
-
</SheetContent>
|
|
36
|
-
</Sheet>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
DrawerWidget.widgetMeta = {
|
|
41
|
-
name: 'drawer',
|
|
42
|
-
label: 'Drawer',
|
|
43
|
-
category: 'layout' as const,
|
|
44
|
-
schema: {
|
|
45
|
-
width: { type: 'enum' as const, options: ['sm', 'md', 'lg'], default: 'md' },
|
|
46
|
-
title: { type: 'string' as const },
|
|
47
|
-
closable: { type: 'boolean' as const, default: true },
|
|
48
|
-
},
|
|
49
|
-
binding: 'none' as const,
|
|
50
|
-
triggers: [],
|
|
51
|
-
container: true,
|
|
52
|
-
};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
|
|
3
|
-
import {
|
|
4
|
-
Command,
|
|
5
|
-
CommandInput,
|
|
6
|
-
CommandList,
|
|
7
|
-
CommandEmpty,
|
|
8
|
-
CommandGroup,
|
|
9
|
-
CommandItem,
|
|
10
|
-
} from '@/components/ui/command';
|
|
11
|
-
import { Button } from '@/components/ui/button';
|
|
12
|
-
import {
|
|
13
|
-
Select,
|
|
14
|
-
SelectTrigger,
|
|
15
|
-
SelectValue,
|
|
16
|
-
SelectContent,
|
|
17
|
-
SelectItem,
|
|
18
|
-
} from '@/components/ui/select';
|
|
19
|
-
import { Field, FieldLabel } from '@/components/ui/field';
|
|
20
|
-
import { cn } from '@/lib/utils';
|
|
21
|
-
import type { WidgetProps } from '../types.js';
|
|
22
|
-
|
|
23
|
-
export function DynamicLinkWidget({ props, bind, on, context }: WidgetProps) {
|
|
24
|
-
const label = (props.label as string) ?? bind.meta?.label ?? '';
|
|
25
|
-
const disabled = (props.disabled as boolean) ?? bind.meta?.readOnly ?? false;
|
|
26
|
-
const models = (props.models as string[]) ?? [];
|
|
27
|
-
const [open, setOpen] = useState(false);
|
|
28
|
-
const [search, setSearch] = useState('');
|
|
29
|
-
|
|
30
|
-
const options = (bind.meta?.options ?? []) as { label: string; value: string }[];
|
|
31
|
-
const currentValue = bind.value as string | null | undefined;
|
|
32
|
-
const selectedOption = options.find((o) => o.value === currentValue);
|
|
33
|
-
|
|
34
|
-
// The model type field name from the dynamicLink config
|
|
35
|
-
const modelField = (props.modelField as string) ?? '';
|
|
36
|
-
const currentModel = (context.record[modelField] as string) ?? '';
|
|
37
|
-
|
|
38
|
-
const handleModelChange = (model: string) => {
|
|
39
|
-
// Update the model type field on the record
|
|
40
|
-
on.change?.({ model, value: null });
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const handleRecordSelect = (value: string) => {
|
|
44
|
-
bind.setValue?.(value);
|
|
45
|
-
on.change?.({ model: currentModel, value });
|
|
46
|
-
setOpen(false);
|
|
47
|
-
setSearch('');
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const handleSearchChange = (value: string) => {
|
|
51
|
-
setSearch(value);
|
|
52
|
-
on.search?.(value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Field>
|
|
57
|
-
{label && <FieldLabel>{label}</FieldLabel>}
|
|
58
|
-
<div className="flex gap-2">
|
|
59
|
-
<Select value={currentModel} onValueChange={handleModelChange} disabled={disabled}>
|
|
60
|
-
<SelectTrigger className="w-40 h-7 text-xs">
|
|
61
|
-
<SelectValue placeholder="Model..." />
|
|
62
|
-
</SelectTrigger>
|
|
63
|
-
<SelectContent>
|
|
64
|
-
{models.map((m) => (
|
|
65
|
-
<SelectItem key={m} value={m}>
|
|
66
|
-
{m}
|
|
67
|
-
</SelectItem>
|
|
68
|
-
))}
|
|
69
|
-
</SelectContent>
|
|
70
|
-
</Select>
|
|
71
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
72
|
-
<PopoverTrigger asChild>
|
|
73
|
-
<Button
|
|
74
|
-
variant="outline"
|
|
75
|
-
role="combobox"
|
|
76
|
-
aria-expanded={open}
|
|
77
|
-
disabled={disabled || !currentModel}
|
|
78
|
-
className="flex-1 justify-between font-normal h-7 text-xs"
|
|
79
|
-
>
|
|
80
|
-
{selectedOption ? (
|
|
81
|
-
selectedOption.label
|
|
82
|
-
) : (
|
|
83
|
-
<span className="text-muted-foreground">Select record...</span>
|
|
84
|
-
)}
|
|
85
|
-
</Button>
|
|
86
|
-
</PopoverTrigger>
|
|
87
|
-
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0" align="start">
|
|
88
|
-
<Command shouldFilter={false}>
|
|
89
|
-
<CommandInput
|
|
90
|
-
placeholder="Search..."
|
|
91
|
-
value={search}
|
|
92
|
-
onValueChange={handleSearchChange}
|
|
93
|
-
/>
|
|
94
|
-
<CommandList>
|
|
95
|
-
<CommandEmpty>No results found.</CommandEmpty>
|
|
96
|
-
<CommandGroup>
|
|
97
|
-
{options.map((opt) => (
|
|
98
|
-
<CommandItem
|
|
99
|
-
key={opt.value}
|
|
100
|
-
value={opt.value}
|
|
101
|
-
onSelect={() => handleRecordSelect(opt.value)}
|
|
102
|
-
className={cn(opt.value === currentValue && 'bg-accent')}
|
|
103
|
-
>
|
|
104
|
-
{opt.label}
|
|
105
|
-
</CommandItem>
|
|
106
|
-
))}
|
|
107
|
-
</CommandGroup>
|
|
108
|
-
</CommandList>
|
|
109
|
-
</Command>
|
|
110
|
-
</PopoverContent>
|
|
111
|
-
</Popover>
|
|
112
|
-
</div>
|
|
113
|
-
</Field>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
DynamicLinkWidget.widgetMeta = {
|
|
118
|
-
name: 'dynamic-link',
|
|
119
|
-
label: 'Dynamic Link',
|
|
120
|
-
category: 'input' as const,
|
|
121
|
-
schema: {
|
|
122
|
-
label: { type: 'string' as const },
|
|
123
|
-
modelField: { type: 'string' as const },
|
|
124
|
-
models: { type: 'array' as const },
|
|
125
|
-
disabled: { type: 'boolean' as const, default: false },
|
|
126
|
-
},
|
|
127
|
-
binding: 'field' as const,
|
|
128
|
-
triggers: ['change', 'search'],
|
|
129
|
-
container: false,
|
|
130
|
-
};
|