@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,366 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { ChevronUpIcon, ChevronDownIcon } from 'lucide-react';
|
|
3
|
-
import type { WidgetNode } from '@rangka/shared';
|
|
4
|
-
import type { WidgetProps } from '../types.js';
|
|
5
|
-
import { useWidgetContext, WidgetContextProvider } from '../hooks/useWidgetContext.js';
|
|
6
|
-
import { usePageState } from '../hooks/usePageState.js';
|
|
7
|
-
import { useModelQuery } from '../data/useModelQuery.js';
|
|
8
|
-
import { useSurfaceContext } from '../hooks/useSurfaceContext.js';
|
|
9
|
-
import { buildRowContext } from '../context/builder.js';
|
|
10
|
-
import { useModelMeta } from '../../data/useModelMeta.js';
|
|
11
|
-
import { Skeleton } from '../../components/ui/skeleton.js';
|
|
12
|
-
import type { SortEntry } from '../reactivity/variables.js';
|
|
13
|
-
import { TableToolbar } from './table/TableToolbar.js';
|
|
14
|
-
import { TablePagination } from './table/TablePagination.js';
|
|
15
|
-
import { ColumnChildRenderer, CellValue } from './table/CellRenderers.js';
|
|
16
|
-
|
|
17
|
-
// --- Main Component ---
|
|
18
|
-
|
|
19
|
-
export function TableWidget({ props, on }: WidgetProps) {
|
|
20
|
-
const ctx = useWidgetContext();
|
|
21
|
-
const store = usePageState();
|
|
22
|
-
const surface = useSurfaceContext();
|
|
23
|
-
|
|
24
|
-
// Props
|
|
25
|
-
const variant =
|
|
26
|
-
(props.variant as 'card' | 'flat' | undefined) ?? (surface === 'card' ? 'flat' : 'card');
|
|
27
|
-
const selectable = props.selectable as boolean | undefined;
|
|
28
|
-
const bordered = props.bordered as boolean | undefined;
|
|
29
|
-
const striped = props.striped as boolean | undefined;
|
|
30
|
-
const pageSize = props.pageSize as number | undefined;
|
|
31
|
-
|
|
32
|
-
// Data source
|
|
33
|
-
const model = ctx.model;
|
|
34
|
-
const columns = ctx.__columns ?? [];
|
|
35
|
-
const smartMode = Boolean(model && pageSize);
|
|
36
|
-
|
|
37
|
-
const source = useModelQuery({
|
|
38
|
-
model: model || '',
|
|
39
|
-
pageSize: pageSize ?? 20,
|
|
40
|
-
enabled: smartMode,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const records = smartMode ? source.data : (ctx.records ?? []);
|
|
44
|
-
const isFetching = smartMode && source.isFetching;
|
|
45
|
-
|
|
46
|
-
// Model metadata for search/filter capabilities
|
|
47
|
-
const { modelMeta } = useModelMeta(model);
|
|
48
|
-
const hasSearchableFields = useMemo(() => {
|
|
49
|
-
if (!modelMeta) return false;
|
|
50
|
-
return modelMeta.fields.some((f) => f.searchable);
|
|
51
|
-
}, [modelMeta]);
|
|
52
|
-
|
|
53
|
-
const filterableColumns = columns.filter((col) => col.props?.filterable && col.bind?.field);
|
|
54
|
-
|
|
55
|
-
// Sorting
|
|
56
|
-
const handleSort = useCallback(
|
|
57
|
-
(field: string) => {
|
|
58
|
-
if (!model) return;
|
|
59
|
-
const current = source.sort?.[0];
|
|
60
|
-
let newSort: string | undefined;
|
|
61
|
-
|
|
62
|
-
if (current?.field === field && current.direction === 'asc') {
|
|
63
|
-
newSort = `-${field}`;
|
|
64
|
-
} else if (current?.field === field && current.direction === 'desc') {
|
|
65
|
-
newSort = undefined;
|
|
66
|
-
} else {
|
|
67
|
-
newSort = field;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
store.set(`$sort.${model}`, newSort ?? null);
|
|
71
|
-
store.set(`$page.${model}`, 1);
|
|
72
|
-
},
|
|
73
|
-
[model, source.sort, store],
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// Pagination
|
|
77
|
-
const handlePageChange = useCallback(
|
|
78
|
-
(newPage: number) => {
|
|
79
|
-
if (!model) return;
|
|
80
|
-
store.set(`$page.${model}`, newPage);
|
|
81
|
-
on.pageChange?.(newPage);
|
|
82
|
-
},
|
|
83
|
-
[model, store, on],
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Styles
|
|
87
|
-
const wrapperClasses = [
|
|
88
|
-
'flex flex-col',
|
|
89
|
-
variant === 'card'
|
|
90
|
-
? 'bg-card text-card-foreground ring-1 ring-foreground/10'
|
|
91
|
-
: '-mx-(--card-spacing)',
|
|
92
|
-
]
|
|
93
|
-
.filter(Boolean)
|
|
94
|
-
.join(' ');
|
|
95
|
-
|
|
96
|
-
const tableClasses = [
|
|
97
|
-
'w-full text-sm border-collapse table-fixed',
|
|
98
|
-
bordered && variant === 'card' ? 'ring-1 ring-border' : '',
|
|
99
|
-
]
|
|
100
|
-
.filter(Boolean)
|
|
101
|
-
.join(' ');
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<div data-widget="table" className={wrapperClasses}>
|
|
105
|
-
{smartMode && (hasSearchableFields || filterableColumns.length > 0) && (
|
|
106
|
-
<TableToolbar
|
|
107
|
-
model={model!}
|
|
108
|
-
store={store}
|
|
109
|
-
columns={filterableColumns}
|
|
110
|
-
hasSearch={hasSearchableFields}
|
|
111
|
-
hasFilters={filterableColumns.length > 0}
|
|
112
|
-
/>
|
|
113
|
-
)}
|
|
114
|
-
|
|
115
|
-
<div className="overflow-auto">
|
|
116
|
-
<table className={tableClasses}>
|
|
117
|
-
<TableHead
|
|
118
|
-
columns={columns}
|
|
119
|
-
selectable={selectable}
|
|
120
|
-
smartMode={smartMode}
|
|
121
|
-
currentSort={source.sort}
|
|
122
|
-
onSort={handleSort}
|
|
123
|
-
/>
|
|
124
|
-
<TableBody
|
|
125
|
-
columns={columns}
|
|
126
|
-
records={records}
|
|
127
|
-
selectable={selectable}
|
|
128
|
-
striped={striped}
|
|
129
|
-
isFetching={isFetching}
|
|
130
|
-
isLoading={source.isLoading}
|
|
131
|
-
pageSize={pageSize ?? 20}
|
|
132
|
-
emptyText={(props.emptyText as string) ?? 'No data'}
|
|
133
|
-
ctx={ctx}
|
|
134
|
-
onRowClick={on.rowClick}
|
|
135
|
-
onSelect={on.select}
|
|
136
|
-
/>
|
|
137
|
-
</table>
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
{smartMode && (
|
|
141
|
-
<TablePagination
|
|
142
|
-
page={source.page}
|
|
143
|
-
pageSize={source.pageSize}
|
|
144
|
-
total={source.total}
|
|
145
|
-
recordCount={records.length}
|
|
146
|
-
onPageChange={handlePageChange}
|
|
147
|
-
/>
|
|
148
|
-
)}
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// --- Table Head ---
|
|
154
|
-
|
|
155
|
-
interface TableHeadProps {
|
|
156
|
-
columns: WidgetNode[];
|
|
157
|
-
selectable: boolean | undefined;
|
|
158
|
-
smartMode: boolean;
|
|
159
|
-
currentSort: SortEntry[] | null;
|
|
160
|
-
onSort: (field: string) => void;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function TableHead({ columns, selectable, smartMode, currentSort, onSort }: TableHeadProps) {
|
|
164
|
-
return (
|
|
165
|
-
<thead>
|
|
166
|
-
<tr className="border-b-2 border-border">
|
|
167
|
-
{selectable && (
|
|
168
|
-
<th className="w-10 px-5 py-2 text-center">
|
|
169
|
-
<input type="checkbox" className="cursor-pointer" aria-label="Select all" />
|
|
170
|
-
</th>
|
|
171
|
-
)}
|
|
172
|
-
{columns.map((col, i) => {
|
|
173
|
-
const align = (col.props?.align as string) ?? 'left';
|
|
174
|
-
const width = col.props?.width as string | undefined;
|
|
175
|
-
const sortable = smartMode && (col.props?.sortable as boolean | undefined);
|
|
176
|
-
const field = col.bind?.field;
|
|
177
|
-
const alignClass =
|
|
178
|
-
align === 'center' ? 'text-center' : align === 'right' ? 'text-right' : 'text-left';
|
|
179
|
-
const sortState = sortable && field ? getSortState(currentSort, field) : null;
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<th
|
|
183
|
-
key={col.id ?? i}
|
|
184
|
-
data-rangka-widget="column"
|
|
185
|
-
data-rangka-id={col.id ?? undefined}
|
|
186
|
-
data-rangka-field={field ?? undefined}
|
|
187
|
-
className={`px-5 py-2 text-xs font-semibold text-muted-foreground ${alignClass} ${sortable ? 'cursor-pointer select-none transition-colors hover:text-foreground' : ''}`}
|
|
188
|
-
style={width ? { width } : undefined}
|
|
189
|
-
onClick={sortable && field ? () => onSort(field) : undefined}
|
|
190
|
-
>
|
|
191
|
-
<span className="inline-flex items-center gap-1">
|
|
192
|
-
{String(col.props?.label ?? '')}
|
|
193
|
-
{sortState === 'asc' && <ChevronUpIcon className="h-3 w-3 text-foreground" />}
|
|
194
|
-
{sortState === 'desc' && <ChevronDownIcon className="h-3 w-3 text-foreground" />}
|
|
195
|
-
</span>
|
|
196
|
-
</th>
|
|
197
|
-
);
|
|
198
|
-
})}
|
|
199
|
-
</tr>
|
|
200
|
-
</thead>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// --- Table Body ---
|
|
205
|
-
|
|
206
|
-
interface TableBodyProps {
|
|
207
|
-
columns: WidgetNode[];
|
|
208
|
-
records: unknown[];
|
|
209
|
-
selectable: boolean | undefined;
|
|
210
|
-
striped: boolean | undefined;
|
|
211
|
-
isFetching: boolean;
|
|
212
|
-
isLoading: boolean;
|
|
213
|
-
pageSize: number;
|
|
214
|
-
emptyText: string;
|
|
215
|
-
ctx: ReturnType<typeof useWidgetContext>;
|
|
216
|
-
onRowClick?: (row: unknown) => void;
|
|
217
|
-
onSelect?: (row: unknown) => void;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function TableBody({
|
|
221
|
-
columns,
|
|
222
|
-
records,
|
|
223
|
-
selectable,
|
|
224
|
-
striped,
|
|
225
|
-
isFetching,
|
|
226
|
-
isLoading,
|
|
227
|
-
pageSize,
|
|
228
|
-
emptyText,
|
|
229
|
-
ctx,
|
|
230
|
-
onRowClick,
|
|
231
|
-
onSelect,
|
|
232
|
-
}: TableBodyProps) {
|
|
233
|
-
const bodyOpacity =
|
|
234
|
-
isFetching && records.length > 0
|
|
235
|
-
? 'opacity-50 transition-opacity duration-150'
|
|
236
|
-
: 'transition-opacity duration-150';
|
|
237
|
-
|
|
238
|
-
if (isLoading) {
|
|
239
|
-
return (
|
|
240
|
-
<tbody className={bodyOpacity}>
|
|
241
|
-
{Array.from({ length: pageSize }, (_, i) => (
|
|
242
|
-
<tr key={`skeleton-${i}`} className="border-b border-border/50 last:border-b-0">
|
|
243
|
-
{selectable && (
|
|
244
|
-
<td className="w-10 px-5 py-2 text-center">
|
|
245
|
-
<Skeleton className="h-4 w-4 mx-auto" />
|
|
246
|
-
</td>
|
|
247
|
-
)}
|
|
248
|
-
{columns.map((col, colIndex) => (
|
|
249
|
-
<td key={col.id ?? colIndex} className="px-5 py-2">
|
|
250
|
-
<Skeleton className="h-4 w-full max-w-[80%]" />
|
|
251
|
-
</td>
|
|
252
|
-
))}
|
|
253
|
-
</tr>
|
|
254
|
-
))}
|
|
255
|
-
</tbody>
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (records.length === 0) {
|
|
260
|
-
return (
|
|
261
|
-
<tbody>
|
|
262
|
-
<tr>
|
|
263
|
-
<td
|
|
264
|
-
colSpan={columns.length + (selectable ? 1 : 0)}
|
|
265
|
-
className="px-5 py-8 text-center text-muted-foreground"
|
|
266
|
-
>
|
|
267
|
-
{emptyText}
|
|
268
|
-
</td>
|
|
269
|
-
</tr>
|
|
270
|
-
</tbody>
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return (
|
|
275
|
-
<tbody className={bodyOpacity}>
|
|
276
|
-
{records.map((row, rowIndex) => {
|
|
277
|
-
const rowCtx = buildRowContext(row as Record<string, unknown>, rowIndex, ctx);
|
|
278
|
-
return (
|
|
279
|
-
<tr
|
|
280
|
-
key={((row as Record<string, unknown>).id as string) ?? rowIndex}
|
|
281
|
-
data-rangka-widget="row"
|
|
282
|
-
data-rangka-id={`row-${rowIndex}`}
|
|
283
|
-
className={[
|
|
284
|
-
'border-b border-border/50 last:border-b-0',
|
|
285
|
-
striped && rowIndex % 2 === 1 ? 'bg-muted/30' : '',
|
|
286
|
-
onRowClick ? 'cursor-pointer transition-colors hover:bg-muted/50' : '',
|
|
287
|
-
]
|
|
288
|
-
.filter(Boolean)
|
|
289
|
-
.join(' ')}
|
|
290
|
-
onClick={() => onRowClick?.(row)}
|
|
291
|
-
>
|
|
292
|
-
{selectable && (
|
|
293
|
-
<td className="w-10 px-5 py-2 text-center">
|
|
294
|
-
<input
|
|
295
|
-
type="checkbox"
|
|
296
|
-
className="cursor-pointer"
|
|
297
|
-
aria-label={`Select row ${rowIndex + 1}`}
|
|
298
|
-
onClick={(e) => {
|
|
299
|
-
e.stopPropagation();
|
|
300
|
-
onSelect?.(row);
|
|
301
|
-
}}
|
|
302
|
-
/>
|
|
303
|
-
</td>
|
|
304
|
-
)}
|
|
305
|
-
{columns.map((col, colIndex) => {
|
|
306
|
-
const align = (col.props?.align as string) ?? 'left';
|
|
307
|
-
const alignClass =
|
|
308
|
-
align === 'center'
|
|
309
|
-
? 'text-center'
|
|
310
|
-
: align === 'right'
|
|
311
|
-
? 'text-right tabular-nums'
|
|
312
|
-
: 'text-left';
|
|
313
|
-
return (
|
|
314
|
-
<td
|
|
315
|
-
key={col.id ?? colIndex}
|
|
316
|
-
data-rangka-widget="column"
|
|
317
|
-
data-rangka-id={col.id ?? undefined}
|
|
318
|
-
data-rangka-field={col.bind?.field ?? undefined}
|
|
319
|
-
className={`px-5 py-2 ${alignClass}`}
|
|
320
|
-
>
|
|
321
|
-
<WidgetContextProvider value={rowCtx}>
|
|
322
|
-
{col.children && col.children.length > 0 ? (
|
|
323
|
-
col.children.map((child, ci) => (
|
|
324
|
-
<ColumnChildRenderer key={child.id ?? ci} node={child} rowCtx={rowCtx} />
|
|
325
|
-
))
|
|
326
|
-
) : (
|
|
327
|
-
<CellValue col={col} row={row as Record<string, unknown>} />
|
|
328
|
-
)}
|
|
329
|
-
</WidgetContextProvider>
|
|
330
|
-
</td>
|
|
331
|
-
);
|
|
332
|
-
})}
|
|
333
|
-
</tr>
|
|
334
|
-
);
|
|
335
|
-
})}
|
|
336
|
-
</tbody>
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// --- Helpers ---
|
|
341
|
-
|
|
342
|
-
function getSortState(sort: SortEntry[] | null, field: string): 'asc' | 'desc' | null {
|
|
343
|
-
if (!sort) return null;
|
|
344
|
-
const entry = sort.find((s) => s.field === field);
|
|
345
|
-
return entry?.direction ?? null;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// --- Widget Meta ---
|
|
349
|
-
|
|
350
|
-
TableWidget.widgetMeta = {
|
|
351
|
-
name: 'table',
|
|
352
|
-
label: 'Table',
|
|
353
|
-
category: 'data' as const,
|
|
354
|
-
schema: {
|
|
355
|
-
variant: { type: 'enum' as const, options: ['card', 'flat'], default: 'card' },
|
|
356
|
-
selectable: { type: 'boolean' as const },
|
|
357
|
-
bordered: { type: 'boolean' as const },
|
|
358
|
-
striped: { type: 'boolean' as const },
|
|
359
|
-
pageSize: { type: 'number' as const },
|
|
360
|
-
emptyText: { type: 'string' as const },
|
|
361
|
-
},
|
|
362
|
-
binding: 'model' as const,
|
|
363
|
-
triggers: ['rowClick', 'select', 'pageChange'],
|
|
364
|
-
container: true,
|
|
365
|
-
accepts: ['column'],
|
|
366
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WidgetProps } from '../types.js';
|
|
3
|
-
|
|
4
|
-
export function TextWidget({ props, bind }: WidgetProps) {
|
|
5
|
-
const style = props.style as string | undefined;
|
|
6
|
-
const align = props.align as string | undefined;
|
|
7
|
-
const value = bind.value ?? props.content ?? '';
|
|
8
|
-
|
|
9
|
-
const classMap: Record<string, string> = {
|
|
10
|
-
heading: 'text-lg font-semibold',
|
|
11
|
-
body: 'text-sm',
|
|
12
|
-
caption: 'text-xs text-muted-foreground',
|
|
13
|
-
bold: 'text-sm font-medium',
|
|
14
|
-
muted: 'text-sm text-muted-foreground',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const alignMap: Record<string, string> = {
|
|
18
|
-
left: 'text-left',
|
|
19
|
-
center: 'text-center',
|
|
20
|
-
right: 'text-right',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const classes = [classMap[style ?? 'body'] ?? classMap.body, align ? alignMap[align] : '']
|
|
24
|
-
.filter(Boolean)
|
|
25
|
-
.join(' ');
|
|
26
|
-
|
|
27
|
-
return <p className={classes}>{String(value)}</p>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
TextWidget.widgetMeta = {
|
|
31
|
-
name: 'text',
|
|
32
|
-
label: 'Text',
|
|
33
|
-
category: 'display' as const,
|
|
34
|
-
schema: {
|
|
35
|
-
style: {
|
|
36
|
-
type: 'enum' as const,
|
|
37
|
-
options: ['heading', 'body', 'caption', 'bold'],
|
|
38
|
-
default: 'body',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
binding: 'field' as const,
|
|
42
|
-
triggers: [],
|
|
43
|
-
container: false,
|
|
44
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Textarea } from '@/components/ui/textarea';
|
|
3
|
-
import { Field, FieldLabel } from '@/components/ui/field';
|
|
4
|
-
import type { WidgetProps } from '../types.js';
|
|
5
|
-
|
|
6
|
-
export function TextareaWidget({ props, bind, on }: WidgetProps) {
|
|
7
|
-
const label = (props.label as string) ?? bind.meta?.label ?? '';
|
|
8
|
-
const placeholder = (props.placeholder as string) ?? '';
|
|
9
|
-
const rows = (props.rows as number) ?? 4;
|
|
10
|
-
const disabled = (props.disabled as boolean) ?? bind.meta?.readOnly ?? false;
|
|
11
|
-
const readOnly = (props.readOnly as boolean) ?? bind.meta?.readOnly ?? false;
|
|
12
|
-
const error = bind.error;
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Field>
|
|
16
|
-
{label && <FieldLabel>{label}</FieldLabel>}
|
|
17
|
-
<Textarea
|
|
18
|
-
value={(bind.value as string) ?? ''}
|
|
19
|
-
onChange={(e) => {
|
|
20
|
-
bind.setValue?.(e.target.value);
|
|
21
|
-
on.change?.(e.target.value);
|
|
22
|
-
}}
|
|
23
|
-
onFocus={() => on.focus?.()}
|
|
24
|
-
onBlur={() => on.blur?.()}
|
|
25
|
-
placeholder={placeholder}
|
|
26
|
-
rows={rows}
|
|
27
|
-
disabled={disabled}
|
|
28
|
-
readOnly={readOnly}
|
|
29
|
-
/>
|
|
30
|
-
{error && <p className="text-xs text-destructive mt-1">{error}</p>}
|
|
31
|
-
</Field>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
TextareaWidget.widgetMeta = {
|
|
36
|
-
name: 'textarea',
|
|
37
|
-
label: 'Textarea',
|
|
38
|
-
category: 'input' as const,
|
|
39
|
-
schema: {
|
|
40
|
-
label: { type: 'string' as const },
|
|
41
|
-
placeholder: { type: 'string' as const },
|
|
42
|
-
rows: { type: 'number' as const, default: 4 },
|
|
43
|
-
disabled: { type: 'boolean' as const, default: false },
|
|
44
|
-
readOnly: { type: 'boolean' as const, default: false },
|
|
45
|
-
},
|
|
46
|
-
binding: 'field' as const,
|
|
47
|
-
triggers: ['change', 'focus', 'blur'],
|
|
48
|
-
container: false,
|
|
49
|
-
};
|
|
@@ -1,109 +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 { Field, FieldLabel } from '@/components/ui/field';
|
|
13
|
-
import { cn } from '@/lib/utils';
|
|
14
|
-
import type { WidgetProps } from '../types.js';
|
|
15
|
-
|
|
16
|
-
export function TreeWidget({ props, bind, on }: WidgetProps) {
|
|
17
|
-
const label = (props.label as string) ?? bind.meta?.label ?? '';
|
|
18
|
-
const placeholder = (props.placeholder as string) ?? 'Select parent...';
|
|
19
|
-
const disabled = (props.disabled as boolean) ?? bind.meta?.readOnly ?? false;
|
|
20
|
-
const [open, setOpen] = useState(false);
|
|
21
|
-
const [search, setSearch] = useState('');
|
|
22
|
-
|
|
23
|
-
const options = (bind.meta?.options ?? []) as { label: string; value: string; path?: string }[];
|
|
24
|
-
const currentValue = bind.value as string | null | undefined;
|
|
25
|
-
const selectedOption = options.find((o) => o.value === currentValue);
|
|
26
|
-
|
|
27
|
-
const handleSelect = (value: string) => {
|
|
28
|
-
bind.setValue?.(value);
|
|
29
|
-
on.change?.(value);
|
|
30
|
-
setOpen(false);
|
|
31
|
-
setSearch('');
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const handleClear = () => {
|
|
35
|
-
bind.setValue?.(null);
|
|
36
|
-
on.change?.(null);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const handleSearchChange = (value: string) => {
|
|
40
|
-
setSearch(value);
|
|
41
|
-
on.search?.(value);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<Field>
|
|
46
|
-
{label && <FieldLabel>{label}</FieldLabel>}
|
|
47
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
48
|
-
<PopoverTrigger asChild>
|
|
49
|
-
<Button
|
|
50
|
-
variant="outline"
|
|
51
|
-
role="combobox"
|
|
52
|
-
aria-expanded={open}
|
|
53
|
-
disabled={disabled}
|
|
54
|
-
className="w-full justify-between font-normal h-7 text-xs"
|
|
55
|
-
>
|
|
56
|
-
{selectedOption ? (
|
|
57
|
-
<span className="truncate">{selectedOption.path ?? selectedOption.label}</span>
|
|
58
|
-
) : (
|
|
59
|
-
<span className="text-muted-foreground">{placeholder}</span>
|
|
60
|
-
)}
|
|
61
|
-
</Button>
|
|
62
|
-
</PopoverTrigger>
|
|
63
|
-
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0" align="start">
|
|
64
|
-
<Command shouldFilter={false}>
|
|
65
|
-
<CommandInput
|
|
66
|
-
placeholder="Search..."
|
|
67
|
-
value={search}
|
|
68
|
-
onValueChange={handleSearchChange}
|
|
69
|
-
/>
|
|
70
|
-
<CommandList>
|
|
71
|
-
<CommandEmpty>No results found.</CommandEmpty>
|
|
72
|
-
<CommandGroup>
|
|
73
|
-
{currentValue && (
|
|
74
|
-
<CommandItem value="" onSelect={handleClear} className="text-muted-foreground">
|
|
75
|
-
Clear selection
|
|
76
|
-
</CommandItem>
|
|
77
|
-
)}
|
|
78
|
-
{options.map((opt) => (
|
|
79
|
-
<CommandItem
|
|
80
|
-
key={opt.value}
|
|
81
|
-
value={opt.value}
|
|
82
|
-
onSelect={() => handleSelect(opt.value)}
|
|
83
|
-
className={cn(opt.value === currentValue && 'bg-accent')}
|
|
84
|
-
>
|
|
85
|
-
<span className="truncate">{opt.path ?? opt.label}</span>
|
|
86
|
-
</CommandItem>
|
|
87
|
-
))}
|
|
88
|
-
</CommandGroup>
|
|
89
|
-
</CommandList>
|
|
90
|
-
</Command>
|
|
91
|
-
</PopoverContent>
|
|
92
|
-
</Popover>
|
|
93
|
-
</Field>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
TreeWidget.widgetMeta = {
|
|
98
|
-
name: 'tree',
|
|
99
|
-
label: 'Tree',
|
|
100
|
-
category: 'input' as const,
|
|
101
|
-
schema: {
|
|
102
|
-
label: { type: 'string' as const },
|
|
103
|
-
placeholder: { type: 'string' as const },
|
|
104
|
-
disabled: { type: 'boolean' as const, default: false },
|
|
105
|
-
},
|
|
106
|
-
binding: 'field' as const,
|
|
107
|
-
triggers: ['change', 'search'],
|
|
108
|
-
container: false,
|
|
109
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export { ButtonWidget } from './ButtonWidget.js';
|
|
2
|
-
export { InputWidget } from './InputWidget.js';
|
|
3
|
-
export { TextWidget } from './TextWidget.js';
|
|
4
|
-
export { BadgeWidget } from './BadgeWidget.js';
|
|
5
|
-
export { IconWidget } from './IconWidget.js';
|
|
6
|
-
export { GroupWidget } from './GroupWidget.js';
|
|
7
|
-
export { SectionWidget } from './SectionWidget.js';
|
|
8
|
-
export { DividerWidget } from './DividerWidget.js';
|
|
9
|
-
export { SpacerWidget } from './SpacerWidget.js';
|
|
10
|
-
export { ImageWidget } from './ImageWidget.js';
|
|
11
|
-
export { SplitWidget } from './SplitWidget.js';
|
|
12
|
-
export { GridWidget } from './GridWidget.js';
|
|
13
|
-
export { DataWidget } from './DataWidget.js';
|
|
14
|
-
export { RepeatWidget } from './RepeatWidget.js';
|
|
15
|
-
export { DrawerWidget } from './DrawerWidget.js';
|
|
16
|
-
export { ModalWidget } from './ModalWidget.js';
|
|
17
|
-
export { TextareaWidget } from './TextareaWidget.js';
|
|
18
|
-
export { DatePickerWidget } from './DatePickerWidget.js';
|
|
19
|
-
export { DatetimeWidget } from './DatetimeWidget.js';
|
|
20
|
-
export { MoneyWidget } from './MoneyWidget.js';
|
|
21
|
-
export { LinkWidget } from './LinkWidget.js';
|
|
22
|
-
export { ManyToManyWidget } from './ManyToManyWidget.js';
|
|
23
|
-
export { DynamicLinkWidget } from './DynamicLinkWidget.js';
|
|
24
|
-
export { AttachmentWidget } from './AttachmentWidget.js';
|
|
25
|
-
export { AttachmentsWidget } from './AttachmentsWidget.js';
|
|
26
|
-
export { SequenceWidget } from './SequenceWidget.js';
|
|
27
|
-
export { ComputedWidget } from './ComputedWidget.js';
|
|
28
|
-
export { CodeWidget } from './CodeWidget.js';
|
|
29
|
-
export { JsonWidget } from './JsonWidget.js';
|
|
30
|
-
export { TreeWidget } from './TreeWidget.js';
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { registerWidget } from '../registry.js';
|
|
2
|
-
import { ButtonWidget } from './ButtonWidget.js';
|
|
3
|
-
import { InputWidget } from './InputWidget.js';
|
|
4
|
-
import { SelectWidget } from './SelectWidget.js';
|
|
5
|
-
import { CheckboxWidget } from './CheckboxWidget.js';
|
|
6
|
-
import { TextWidget } from './TextWidget.js';
|
|
7
|
-
import { BadgeWidget } from './BadgeWidget.js';
|
|
8
|
-
import { IconWidget } from './IconWidget.js';
|
|
9
|
-
import { ImageWidget } from './ImageWidget.js';
|
|
10
|
-
import { GroupWidget } from './GroupWidget.js';
|
|
11
|
-
import { SectionWidget } from './SectionWidget.js';
|
|
12
|
-
import { DividerWidget } from './DividerWidget.js';
|
|
13
|
-
import { SpacerWidget } from './SpacerWidget.js';
|
|
14
|
-
import { SplitWidget } from './SplitWidget.js';
|
|
15
|
-
import { GridWidget } from './GridWidget.js';
|
|
16
|
-
import { CardWidget } from './CardWidget.js';
|
|
17
|
-
import { ScrollAreaWidget } from './ScrollAreaWidget.js';
|
|
18
|
-
import { StackWidget } from './StackWidget.js';
|
|
19
|
-
import { TableWidget } from './TableWidget.js';
|
|
20
|
-
import { ColumnWidget } from './ColumnWidget.js';
|
|
21
|
-
import { DataWidget } from './DataWidget.js';
|
|
22
|
-
import { RepeatWidget } from './RepeatWidget.js';
|
|
23
|
-
import { DrawerWidget } from './DrawerWidget.js';
|
|
24
|
-
import { ModalWidget } from './ModalWidget.js';
|
|
25
|
-
import { TextareaWidget } from './TextareaWidget.js';
|
|
26
|
-
import { DatePickerWidget } from './DatePickerWidget.js';
|
|
27
|
-
import { DatetimeWidget } from './DatetimeWidget.js';
|
|
28
|
-
import { MoneyWidget } from './MoneyWidget.js';
|
|
29
|
-
import { LinkWidget } from './LinkWidget.js';
|
|
30
|
-
import { ManyToManyWidget } from './ManyToManyWidget.js';
|
|
31
|
-
import { DynamicLinkWidget } from './DynamicLinkWidget.js';
|
|
32
|
-
import { AttachmentWidget } from './AttachmentWidget.js';
|
|
33
|
-
import { AttachmentsWidget } from './AttachmentsWidget.js';
|
|
34
|
-
import { SequenceWidget } from './SequenceWidget.js';
|
|
35
|
-
import { ComputedWidget } from './ComputedWidget.js';
|
|
36
|
-
import { CodeWidget } from './CodeWidget.js';
|
|
37
|
-
import { JsonWidget } from './JsonWidget.js';
|
|
38
|
-
import { TreeWidget } from './TreeWidget.js';
|
|
39
|
-
import { FormWidget } from '../form/FormWidget.js';
|
|
40
|
-
import type { WidgetDefinitionMeta } from '@rangka/shared';
|
|
41
|
-
import type { WidgetProps } from '../types.js';
|
|
42
|
-
import type { ComponentType } from 'react';
|
|
43
|
-
|
|
44
|
-
type WidgetWithMeta = ComponentType<WidgetProps> & {
|
|
45
|
-
widgetMeta: WidgetDefinitionMeta;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const builtInWidgets: WidgetWithMeta[] = [
|
|
49
|
-
ButtonWidget as unknown as WidgetWithMeta,
|
|
50
|
-
InputWidget as unknown as WidgetWithMeta,
|
|
51
|
-
SelectWidget as unknown as WidgetWithMeta,
|
|
52
|
-
CheckboxWidget as unknown as WidgetWithMeta,
|
|
53
|
-
TextWidget as unknown as WidgetWithMeta,
|
|
54
|
-
BadgeWidget as unknown as WidgetWithMeta,
|
|
55
|
-
IconWidget as unknown as WidgetWithMeta,
|
|
56
|
-
ImageWidget as unknown as WidgetWithMeta,
|
|
57
|
-
GroupWidget as unknown as WidgetWithMeta,
|
|
58
|
-
SectionWidget as unknown as WidgetWithMeta,
|
|
59
|
-
DividerWidget as unknown as WidgetWithMeta,
|
|
60
|
-
SpacerWidget as unknown as WidgetWithMeta,
|
|
61
|
-
SplitWidget as unknown as WidgetWithMeta,
|
|
62
|
-
GridWidget as unknown as WidgetWithMeta,
|
|
63
|
-
CardWidget as unknown as WidgetWithMeta,
|
|
64
|
-
ScrollAreaWidget as unknown as WidgetWithMeta,
|
|
65
|
-
StackWidget as unknown as WidgetWithMeta,
|
|
66
|
-
TableWidget as unknown as WidgetWithMeta,
|
|
67
|
-
ColumnWidget as unknown as WidgetWithMeta,
|
|
68
|
-
DataWidget as unknown as WidgetWithMeta,
|
|
69
|
-
RepeatWidget as unknown as WidgetWithMeta,
|
|
70
|
-
DrawerWidget as unknown as WidgetWithMeta,
|
|
71
|
-
ModalWidget as unknown as WidgetWithMeta,
|
|
72
|
-
TextareaWidget as unknown as WidgetWithMeta,
|
|
73
|
-
DatePickerWidget as unknown as WidgetWithMeta,
|
|
74
|
-
DatetimeWidget as unknown as WidgetWithMeta,
|
|
75
|
-
MoneyWidget as unknown as WidgetWithMeta,
|
|
76
|
-
LinkWidget as unknown as WidgetWithMeta,
|
|
77
|
-
ManyToManyWidget as unknown as WidgetWithMeta,
|
|
78
|
-
DynamicLinkWidget as unknown as WidgetWithMeta,
|
|
79
|
-
AttachmentWidget as unknown as WidgetWithMeta,
|
|
80
|
-
AttachmentsWidget as unknown as WidgetWithMeta,
|
|
81
|
-
SequenceWidget as unknown as WidgetWithMeta,
|
|
82
|
-
ComputedWidget as unknown as WidgetWithMeta,
|
|
83
|
-
CodeWidget as unknown as WidgetWithMeta,
|
|
84
|
-
JsonWidget as unknown as WidgetWithMeta,
|
|
85
|
-
TreeWidget as unknown as WidgetWithMeta,
|
|
86
|
-
FormWidget as unknown as WidgetWithMeta,
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
export function registerBuiltInWidgets(): void {
|
|
90
|
-
for (const widget of builtInWidgets) {
|
|
91
|
-
registerWidget(widget.widgetMeta, widget);
|
|
92
|
-
}
|
|
93
|
-
}
|