@asteby/metacore-runtime-react 53.24.0 → 53.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/action-modal-dispatcher.d.ts +3 -3
- package/dist/action-modal-dispatcher.js +31 -31
- package/dist/action-priority.d.ts +1 -1
- package/dist/activity-diff.d.ts +1 -1
- package/dist/activity-diff.js +1 -1
- package/dist/activity-timeline.d.ts +2 -2
- package/dist/activity-timeline.js +3 -3
- package/dist/activity-value-renderer.d.ts +1 -1
- package/dist/activity-value-renderer.js +3 -3
- package/dist/addon-loader.d.ts +1 -1
- package/dist/addon-loader.js +3 -3
- package/dist/addon-page-host.js +1 -1
- package/dist/addon-page-loader.d.ts +2 -2
- package/dist/addon-page-loader.js +3 -3
- package/dist/api-context.js +4 -4
- package/dist/approval-gate.d.ts +1 -1
- package/dist/approval-gate.js +5 -5
- package/dist/assist-interview.d.ts +1 -1
- package/dist/assist-interview.js +1 -1
- package/dist/attention/index.d.ts +3 -3
- package/dist/attention/index.js +3 -3
- package/dist/attention/use-nav-badges.js +2 -2
- package/dist/attribute-classes.d.ts +1 -1
- package/dist/audit-info.d.ts +1 -1
- package/dist/audit-info.js +5 -5
- package/dist/bulk-image-dialog.d.ts +1 -1
- package/dist/bulk-image-dialog.js +5 -5
- package/dist/bulk-image-import.d.ts +2 -2
- package/dist/bulk-image-import.js +1 -1
- package/dist/bulk-image-target.d.ts +1 -1
- package/dist/bulk-image-target.js +1 -1
- package/dist/bulk-image-wizard.d.ts +1 -1
- package/dist/bulk-image-wizard.js +5 -5
- package/dist/business/catalog-product-search.d.ts +1 -1
- package/dist/business/customer-picker.js +4 -4
- package/dist/business/document-editor-model.d.ts +3 -3
- package/dist/business/document-editor-model.js +4 -4
- package/dist/business/document-editor-panels.d.ts +3 -3
- package/dist/business/document-editor-panels.js +1 -1
- package/dist/business/document-editor.d.ts +2 -2
- package/dist/business/document-editor.js +22 -22
- package/dist/business/document-lines.d.ts +2 -2
- package/dist/business/document-lines.js +3 -3
- package/dist/business/field-errors.d.ts +1 -1
- package/dist/business/field-errors.js +1 -1
- package/dist/business/format.js +1 -1
- package/dist/business/index.d.ts +29 -29
- package/dist/business/index.js +29 -29
- package/dist/business/inspection-checklist.d.ts +1 -1
- package/dist/business/inspection-checklist.js +2 -2
- package/dist/business/inspection.d.ts +1 -1
- package/dist/business/inspection.js +2 -2
- package/dist/business/line-items-editor.d.ts +3 -3
- package/dist/business/line-items-editor.js +5 -5
- package/dist/business/line-items.d.ts +1 -1
- package/dist/business/line-items.js +2 -2
- package/dist/business/line-product-cell.d.ts +2 -2
- package/dist/business/line-product-cell.js +2 -2
- package/dist/business/payment-allocator.d.ts +1 -1
- package/dist/business/payment-allocator.js +2 -2
- package/dist/business/payment-capture.d.ts +1 -1
- package/dist/business/payment-capture.js +3 -3
- package/dist/business/payment.js +1 -1
- package/dist/business/print-send-dialog.js +1 -1
- package/dist/business/product-display.d.ts +1 -1
- package/dist/business/product-options.d.ts +1 -1
- package/dist/business/product-options.js +4 -4
- package/dist/business/product-picker.d.ts +1 -1
- package/dist/business/product-picker.js +3 -3
- package/dist/business/product-search.d.ts +2 -2
- package/dist/business/product-search.js +1 -1
- package/dist/business/refund-destination.d.ts +1 -1
- package/dist/business/refund-destination.js +2 -2
- package/dist/business/refund.js +1 -1
- package/dist/business/relate-documents.js +1 -1
- package/dist/business/return-wizard.d.ts +2 -2
- package/dist/business/return-wizard.js +4 -4
- package/dist/business/return.d.ts +2 -2
- package/dist/business/return.js +2 -2
- package/dist/business/vehicle-picker.js +3 -3
- package/dist/cache-coherence.js +3 -3
- package/dist/capability-providers/index.d.ts +3 -3
- package/dist/capability-providers/index.js +3 -3
- package/dist/capability-providers/provider-sortable-list.d.ts +1 -1
- package/dist/capability-providers/provider-sortable-list.js +1 -1
- package/dist/collection-cell.js +1 -1
- package/dist/column-filter-field.d.ts +1 -1
- package/dist/column-visibility.d.ts +1 -1
- package/dist/custom-stages.d.ts +2 -2
- package/dist/custom-stages.js +1 -1
- package/dist/dashboard-grid.d.ts +2 -2
- package/dist/dashboard-grid.d.ts.map +1 -1
- package/dist/dashboard-grid.js +22 -20
- package/dist/dashboard-types.d.ts +6 -0
- package/dist/dashboard-types.d.ts.map +1 -1
- package/dist/dialogs/create-record-dialog.d.ts +1 -1
- package/dist/dialogs/create-record-dialog.js +1 -1
- package/dist/dialogs/dynamic-record.d.ts +5 -5
- package/dist/dialogs/dynamic-record.js +41 -41
- package/dist/dialogs/export.d.ts +1 -1
- package/dist/dialogs/export.js +2 -2
- package/dist/dialogs/import.d.ts +1 -1
- package/dist/dialogs/import.js +3 -3
- package/dist/dialogs/inline-relation-rows.d.ts +3 -3
- package/dist/dialogs/inline-relation-rows.js +3 -3
- package/dist/dialogs/inline-relations.d.ts +3 -3
- package/dist/dialogs/inline-relations.js +3 -3
- package/dist/dialogs/normalize-submit.d.ts +1 -1
- package/dist/dialogs/normalize-submit.js +3 -3
- package/dist/dialogs/use-inline-relations.d.ts +1 -1
- package/dist/dialogs/use-inline-relations.js +3 -3
- package/dist/dialogs/view-record-dialog.d.ts +1 -1
- package/dist/dialogs/view-record-dialog.js +1 -1
- package/dist/display-value.js +1 -1
- package/dist/document/action-bar.d.ts +1 -1
- package/dist/document/action-bar.js +1 -1
- package/dist/document/document-header.d.ts +2 -2
- package/dist/document/document-header.js +2 -2
- package/dist/document/document-page.d.ts +3 -3
- package/dist/document/document-page.js +9 -9
- package/dist/document/document-timeline.d.ts +2 -2
- package/dist/document/document-timeline.js +2 -2
- package/dist/document/evaluate.d.ts +1 -1
- package/dist/document/evaluate.js +1 -1
- package/dist/document/format.d.ts +1 -1
- package/dist/document/index.d.ts +13 -13
- package/dist/document/index.js +13 -13
- package/dist/document/registry.d.ts +1 -1
- package/dist/document/secondary-bar.js +2 -2
- package/dist/document/smart-buttons.js +1 -1
- package/dist/document/status-badge.d.ts +1 -1
- package/dist/document/use-document-sources.d.ts +1 -1
- package/dist/document/use-document-sources.js +2 -2
- package/dist/document-form-dialog.d.ts +2 -2
- package/dist/document-form-dialog.js +16 -16
- package/dist/document-template-editor.js +1 -1
- package/dist/dynamic-columns-shim.d.ts +1 -1
- package/dist/dynamic-columns.d.ts +11 -3
- package/dist/dynamic-columns.d.ts.map +1 -1
- package/dist/dynamic-columns.js +52 -26
- package/dist/dynamic-crud-page.d.ts +2 -2
- package/dist/dynamic-crud-page.d.ts.map +1 -1
- package/dist/dynamic-crud-page.js +22 -19
- package/dist/dynamic-date-field.d.ts +1 -1
- package/dist/dynamic-date-field.js +1 -1
- package/dist/dynamic-form-schema.d.ts +2 -2
- package/dist/dynamic-form-schema.js +4 -4
- package/dist/dynamic-form.d.ts +10 -10
- package/dist/dynamic-form.js +24 -24
- package/dist/dynamic-icon.js +1 -1
- package/dist/dynamic-kanban.d.ts +3 -3
- package/dist/dynamic-kanban.js +25 -25
- package/dist/dynamic-line-items.d.ts +1 -1
- package/dist/dynamic-line-items.js +6 -6
- package/dist/dynamic-multi-select-field.d.ts +1 -1
- package/dist/dynamic-multi-select-field.js +7 -7
- package/dist/dynamic-relation-helpers.d.ts +1 -1
- package/dist/dynamic-relation-helpers.js +2 -2
- package/dist/dynamic-relation.d.ts +2 -2
- package/dist/dynamic-relation.js +15 -15
- package/dist/dynamic-relations.d.ts +2 -2
- package/dist/dynamic-relations.js +1 -1
- package/dist/dynamic-row-actions.d.ts +1 -1
- package/dist/dynamic-row-actions.js +5 -5
- package/dist/dynamic-select-field.d.ts +3 -3
- package/dist/dynamic-select-field.js +11 -11
- package/dist/dynamic-table.d.ts +5 -3
- package/dist/dynamic-table.d.ts.map +1 -1
- package/dist/dynamic-table.js +48 -36
- package/dist/dynamic-view.d.ts +4 -4
- package/dist/dynamic-view.js +7 -7
- package/dist/entity-select.js +4 -4
- package/dist/field-validation-ui.d.ts +2 -2
- package/dist/field-widget-registry.d.ts +1 -1
- package/dist/form-layout-ui.d.ts +1 -1
- package/dist/form-layout.d.ts +1 -1
- package/dist/form-layout.js +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/genui/index.js +1 -1
- package/dist/genui/settings-block.d.ts +1 -1
- package/dist/genui/settings-block.js +3 -3
- package/dist/host-api-client.d.ts +11 -1
- package/dist/host-api-client.d.ts.map +1 -1
- package/dist/host-api-client.js +21 -14
- package/dist/host-api.d.ts +9 -1
- package/dist/host-api.d.ts.map +1 -1
- package/dist/host-api.js +57 -2
- package/dist/hotswap-reload-policy.d.ts +1 -1
- package/dist/hotswap-reload-policy.js +1 -1
- package/dist/icon-picker-field.d.ts +1 -1
- package/dist/icon-picker-field.js +3 -3
- package/dist/icon-resolvers.d.ts +1 -1
- package/dist/icon-resolvers.js +1 -1
- package/dist/icon-spec.js +1 -1
- package/dist/index.d.ts +165 -163
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -147
- package/dist/license/index.d.ts +6 -6
- package/dist/license/index.js +6 -6
- package/dist/license/license-expiry-banner.d.ts +1 -1
- package/dist/license/license-expiry-banner.js +3 -3
- package/dist/license/license-gate.d.ts +1 -1
- package/dist/license/license-gate.js +5 -5
- package/dist/license/license-status-badge.d.ts +1 -1
- package/dist/license/license-status-badge.js +1 -1
- package/dist/license/use-license-t.d.ts +1 -1
- package/dist/license/use-license-t.js +1 -1
- package/dist/license/view.d.ts +1 -1
- package/dist/license/view.js +1 -1
- package/dist/list-include.d.ts +1 -1
- package/dist/manifest-hotswap-subscriber.d.ts +1 -1
- package/dist/manifest-hotswap-subscriber.js +1 -1
- package/dist/metadata-cache.d.ts +1 -1
- package/dist/metadata-cache.js +1 -1
- package/dist/model-action-toolbar.d.ts +1 -1
- package/dist/model-action-toolbar.js +7 -7
- package/dist/model-labels.d.ts +38 -0
- package/dist/model-labels.d.ts.map +1 -0
- package/dist/model-labels.js +35 -0
- package/dist/nav-permissions.d.ts +1 -1
- package/dist/nav-permissions.js +1 -1
- package/dist/navigation-builder.d.ts +1 -1
- package/dist/navigation-builder.js +1 -1
- package/dist/option-display.d.ts +1 -1
- package/dist/option-display.js +2 -2
- package/dist/option-filter.d.ts +1 -1
- package/dist/option-when.d.ts +1 -1
- package/dist/org-runtime-provider.d.ts +2 -2
- package/dist/org-runtime-provider.js +2 -2
- package/dist/permissions-context.d.ts +1 -1
- package/dist/permissions-manager.js +4 -4
- package/dist/primitives/aging.js +1 -1
- package/dist/primitives/allocation.js +1 -1
- package/dist/primitives/approvals.d.ts +1 -1
- package/dist/primitives/contributions.js +1 -1
- package/dist/primitives/document-kinds.d.ts +1 -1
- package/dist/primitives/index.d.ts +7 -7
- package/dist/primitives/index.js +7 -7
- package/dist/primitives/panels.d.ts +1 -1
- package/dist/primitives/use-contributions.d.ts +2 -2
- package/dist/primitives/use-contributions.js +2 -2
- package/dist/print-document-button.d.ts +1 -1
- package/dist/print-document-button.js +1 -1
- package/dist/provenance.js +3 -3
- package/dist/query-batch.d.ts +1 -1
- package/dist/query-batch.js +1 -1
- package/dist/record-actions.d.ts +2 -2
- package/dist/record-actions.js +2 -2
- package/dist/record-history.d.ts +2 -2
- package/dist/record-history.js +3 -3
- package/dist/record-picker-dialog.js +3 -3
- package/dist/record-picker-option.d.ts +1 -1
- package/dist/record-picker-option.js +1 -1
- package/dist/record-picker.js +2 -2
- package/dist/record-prefill-bar.js +1 -1
- package/dist/relation-gallery.js +1 -1
- package/dist/requires-addon.d.ts +1 -1
- package/dist/rich-cells.js +2 -2
- package/dist/rich-url.js +1 -1
- package/dist/row-actions-menu.js +5 -5
- package/dist/server-error.js +2 -2
- package/dist/setup/addon-config-surface.d.ts +3 -3
- package/dist/setup/addon-config-surface.js +10 -10
- package/dist/setup/connector-blocks-model.d.ts +1 -1
- package/dist/setup/connector-blocks.d.ts +1 -1
- package/dist/setup/connector-blocks.js +6 -6
- package/dist/setup/flow-model.d.ts +1 -1
- package/dist/setup/health-card.d.ts +1 -1
- package/dist/setup/health-card.js +2 -2
- package/dist/setup/index.d.ts +12 -12
- package/dist/setup/index.js +12 -12
- package/dist/setup/records-table.d.ts +1 -1
- package/dist/setup/records-table.js +2 -2
- package/dist/setup/setup-flow.d.ts +1 -1
- package/dist/setup/setup-flow.js +7 -7
- package/dist/setup/setup-form-step.d.ts +1 -1
- package/dist/setup/setup-form-step.js +4 -4
- package/dist/setup/step-status-badge.d.ts +1 -1
- package/dist/setup/step-status-badge.js +2 -2
- package/dist/setup/tone.d.ts +1 -1
- package/dist/setup/types.d.ts +2 -2
- package/dist/sidebar-layout-manager.d.ts +1 -1
- package/dist/sidebar-layout-manager.js +2 -2
- package/dist/slot.js +1 -1
- package/dist/slots/addon-slot.js +4 -4
- package/dist/slots/index.d.ts +2 -2
- package/dist/slots/index.js +2 -2
- package/dist/stage-automations.d.ts +2 -2
- package/dist/stage-automations.js +1 -1
- package/dist/stage-layout.js +1 -1
- package/dist/stage-overrides.d.ts +1 -1
- package/dist/stage-overrides.js +1 -1
- package/dist/supervised-action.js +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/tri-state-boolean.d.ts +2 -2
- package/dist/tri-state-boolean.js +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/upload-field.d.ts +1 -1
- package/dist/upload-field.js +4 -4
- package/dist/use-addon-installed-probe.js +3 -3
- package/dist/use-addon-settings.d.ts +1 -1
- package/dist/use-addon-settings.js +1 -1
- package/dist/use-dynamic-filters.d.ts +2 -2
- package/dist/use-dynamic-filters.js +6 -6
- package/dist/use-edge-device.d.ts +1 -1
- package/dist/use-edge-device.js +2 -2
- package/dist/use-facet-loaders.d.ts +1 -1
- package/dist/use-facet-loaders.js +1 -1
- package/dist/use-flip-animation.d.ts +1 -1
- package/dist/use-flip-animation.js +1 -1
- package/dist/use-host-api-client.d.ts +2 -2
- package/dist/use-host-api-client.d.ts.map +1 -1
- package/dist/use-host-api-client.js +6 -4
- package/dist/use-option-ids.d.ts +1 -1
- package/dist/use-option-ids.js +2 -2
- package/dist/use-options-resolver.d.ts +2 -2
- package/dist/use-options-resolver.js +4 -4
- package/dist/use-org-document-templates.js +1 -1
- package/dist/use-print-document.js +1 -1
- package/dist/use-record-mutation-tick.js +1 -1
- package/dist/validator.d.ts +2 -2
- package/dist/validator.js +1 -1
- package/dist/view-system/card-spec.d.ts +1 -1
- package/dist/view-system/cards-view.d.ts +1 -1
- package/dist/view-system/cards-view.js +2 -2
- package/dist/view-system/index.d.ts +9 -9
- package/dist/view-system/index.js +9 -9
- package/dist/view-system/model-view.d.ts +3 -3
- package/dist/view-system/model-view.js +7 -7
- package/dist/view-system/saved-views.d.ts +1 -1
- package/dist/view-system/use-view-mode.d.ts +1 -1
- package/dist/view-system/view-state.d.ts +1 -1
- package/dist/view-system/view-switcher.d.ts +1 -1
- package/dist/view-system/view-toolbar.d.ts +1 -1
- package/dist/view-system/view-toolbar.js +2 -2
- package/dist/views/calendar-view.d.ts +1 -1
- package/dist/views/calendar-view.js +2 -2
- package/dist/views/chart-view.d.ts +2 -2
- package/dist/views/chart-view.js +2 -2
- package/dist/views/data-source.d.ts +2 -2
- package/dist/views/index.d.ts +3 -3
- package/dist/views/index.js +2 -2
- package/dist/views/map-view.d.ts +1 -1
- package/dist/views/map-view.js +3 -3
- package/dist/views/panels.d.ts +1 -1
- package/dist/views/panels.js +3 -3
- package/dist/views/registry.d.ts +2 -2
- package/dist/views/registry.js +12 -12
- package/dist/views/split-view.d.ts +1 -1
- package/dist/views/split-view.js +4 -4
- package/dist/views/timeline-view.d.ts +1 -1
- package/dist/views/timeline-view.js +3 -3
- package/dist/views/types.d.ts +2 -2
- package/dist/widgets/charts.d.ts +1 -1
- package/dist/widgets/charts.js +2 -2
- package/dist/widgets/lazy-charts.d.ts +1 -1
- package/dist/widgets/lazy-charts.js +2 -2
- package/dist/widgets/renderers.d.ts +2 -2
- package/dist/widgets/renderers.js +2 -2
- package/dist/widgets/widget-card.d.ts +1 -1
- package/dist/widgets/widget-card.js +2 -2
- package/dist/widgets/widget-renderer.d.ts +1 -1
- package/dist/widgets/widget-renderer.js +4 -4
- package/package.json +10 -10
- package/src/__tests__/host-api-client.test.tsx +16 -0
- package/src/__tests__/host-api.test.ts +50 -0
- package/src/__tests__/initials-avatar-cell.test.tsx +54 -0
- package/src/__tests__/load-guard.test.tsx +94 -0
- package/src/__tests__/model-labels.test.tsx +31 -0
- package/src/dashboard-grid.tsx +49 -35
- package/src/dashboard-types.ts +6 -0
- package/src/dynamic-columns.tsx +40 -9
- package/src/dynamic-crud-page.tsx +10 -7
- package/src/dynamic-table.tsx +38 -12
- package/src/host-api-client.ts +31 -14
- package/src/host-api.ts +54 -1
- package/src/index.ts +5 -1
- package/src/model-labels.ts +80 -0
- package/src/types.ts +3 -0
- package/src/use-host-api-client.ts +5 -3
package/dist/dynamic-table.js
CHANGED
|
@@ -13,39 +13,40 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
13
13
|
// column cells are tightly coupled to their design system).
|
|
14
14
|
import { useEffect, useState, useMemo, useCallback, useRef } from 'react';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import { useTimeZone, useCurrency, useNumberLocale } from './org-runtime-context';
|
|
16
|
+
import { useTimeZone, useCurrency, useNumberLocale } from './org-runtime-context.js';
|
|
17
17
|
import { format } from 'date-fns';
|
|
18
18
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
19
19
|
import { flexRender, getCoreRowModel, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
20
20
|
import { cn } from '@asteby/metacore-ui/lib';
|
|
21
21
|
import { preloadGlyphs } from '@asteby/metacore-ui/icons';
|
|
22
|
-
import {
|
|
22
|
+
import { useLoadingGuard } from '@asteby/metacore-ui/hooks';
|
|
23
|
+
import { Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Button, Skeleton, LoadState, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@asteby/metacore-ui/primitives';
|
|
23
24
|
import { DataTablePagination, DataTableToolbar, DataTableBulkActions, } from '@asteby/metacore-ui/data-table';
|
|
24
25
|
import { Inbox, Download, Upload, Trash2 } from 'lucide-react';
|
|
25
26
|
import { toast } from 'sonner';
|
|
26
|
-
import { Progress } from './dialogs/_primitives';
|
|
27
|
-
import { useMetadataCache } from './metadata-cache';
|
|
28
|
-
import { cacheScope, onCacheScopeChange, peekCacheScope } from './cache-scope';
|
|
29
|
-
import { useRecordMutationTick } from './use-record-mutation-tick';
|
|
30
|
-
import { useApi, useCurrentBranch } from './api-context';
|
|
31
|
-
import { useReasonPrompt } from './reason-prompt';
|
|
32
|
-
import { defaultGetDynamicColumns, DATE_CELL_TYPES, aggregateOf, formatAggregateTotal } from './dynamic-columns';
|
|
33
|
-
import { useFacetLoaders, isLongTextColumn } from './use-facet-loaders';
|
|
34
|
-
import { translateOptionLabels } from './filter-chips';
|
|
35
|
-
import { withBooleanUnsetOption } from './nullable-boolean';
|
|
36
|
-
import { applyColumnFilterFields } from './column-filter-field';
|
|
37
|
-
import { dedupeById, useInfiniteScrollSentinel } from './use-infinite-scroll';
|
|
38
|
-
import { DYNAMIC_TABLE_CARD_ESTIMATE_PX, DYNAMIC_TABLE_ROW_ESTIMATE_PX, resolveVirtualizeThreshold, } from './table-virtualization';
|
|
39
|
-
import { OptionsContext } from './options-context';
|
|
40
|
-
import { RowActionsModelContext } from './row-actions-menu';
|
|
41
|
-
import { getSearchableColumnKeys } from './column-visibility';
|
|
42
|
-
import { visibleRelationInclude } from './list-include';
|
|
43
|
-
import { useDebouncedValue } from './use-debounced-value';
|
|
44
|
-
import { useCan, usePermissionsActive, useRoleGate, gateTableMetadata, modelCapability } from './permissions-context';
|
|
45
|
-
import { useDynamicRowActions } from './dynamic-row-actions';
|
|
46
|
-
import { ExportDialog } from './dialogs/export';
|
|
47
|
-
import { ImportDialog } from './dialogs/import';
|
|
48
|
-
import { buildListScopeValues, evaluateVisibleWhenForListScope, getVisibleWhen, scopeValueFromFilterToken, } from './dynamic-form-schema';
|
|
27
|
+
import { Progress } from './dialogs/_primitives.js';
|
|
28
|
+
import { useMetadataCache } from './metadata-cache.js';
|
|
29
|
+
import { cacheScope, onCacheScopeChange, peekCacheScope } from './cache-scope.js';
|
|
30
|
+
import { useRecordMutationTick } from './use-record-mutation-tick.js';
|
|
31
|
+
import { useApi, useCurrentBranch } from './api-context.js';
|
|
32
|
+
import { useReasonPrompt } from './reason-prompt.js';
|
|
33
|
+
import { defaultGetDynamicColumns, DATE_CELL_TYPES, aggregateOf, formatAggregateTotal } from './dynamic-columns.js';
|
|
34
|
+
import { useFacetLoaders, isLongTextColumn } from './use-facet-loaders.js';
|
|
35
|
+
import { translateOptionLabels } from './filter-chips.js';
|
|
36
|
+
import { withBooleanUnsetOption } from './nullable-boolean.js';
|
|
37
|
+
import { applyColumnFilterFields } from './column-filter-field.js';
|
|
38
|
+
import { dedupeById, useInfiniteScrollSentinel } from './use-infinite-scroll.js';
|
|
39
|
+
import { DYNAMIC_TABLE_CARD_ESTIMATE_PX, DYNAMIC_TABLE_ROW_ESTIMATE_PX, resolveVirtualizeThreshold, } from './table-virtualization.js';
|
|
40
|
+
import { OptionsContext } from './options-context.js';
|
|
41
|
+
import { RowActionsModelContext } from './row-actions-menu.js';
|
|
42
|
+
import { getSearchableColumnKeys } from './column-visibility.js';
|
|
43
|
+
import { visibleRelationInclude } from './list-include.js';
|
|
44
|
+
import { useDebouncedValue } from './use-debounced-value.js';
|
|
45
|
+
import { useCan, usePermissionsActive, useRoleGate, gateTableMetadata, modelCapability } from './permissions-context.js';
|
|
46
|
+
import { useDynamicRowActions } from './dynamic-row-actions.js';
|
|
47
|
+
import { ExportDialog } from './dialogs/export.js';
|
|
48
|
+
import { ImportDialog } from './dialogs/import.js';
|
|
49
|
+
import { buildListScopeValues, evaluateVisibleWhenForListScope, getVisibleWhen, scopeValueFromFilterToken, } from './dynamic-form-schema.js';
|
|
49
50
|
// ---------------------------------------------------------------------------
|
|
50
51
|
// Row-data cache (perceived performance).
|
|
51
52
|
//
|
|
@@ -190,7 +191,7 @@ function groupBulkReasons(failed, more) {
|
|
|
190
191
|
lines.push(more(entries.length - BULK_REASON_MAX_GROUPS));
|
|
191
192
|
return lines.join('\n');
|
|
192
193
|
}
|
|
193
|
-
export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync = true, defaultSort, hideImport, hideExport, hiddenColumns = [], allowedActionKeys, onAction, onRowClick, isRowActionVisible: rowActionPredicate, refreshTrigger, defaultFilters, extraColumns = [], getDynamicColumns = defaultGetDynamicColumns, timeZone: timeZoneProp, currency: currencyProp, pagination: paginationMode, infiniteScroll: infiniteScrollProp = false, virtualizeRows, extraBulkActions, hideBulkDelete, onBulkDeleteResult, emptyState, }) {
|
|
194
|
+
export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync = true, defaultSort, hideImport, hideExport, hiddenColumns = [], allowedActionKeys, onAction, onRowClick, isRowActionVisible: rowActionPredicate, refreshTrigger, defaultFilters, extraColumns = [], getDynamicColumns = defaultGetDynamicColumns, timeZone: timeZoneProp, currency: currencyProp, pagination: paginationMode, infiniteScroll: infiniteScrollProp = false, loadTimeoutMs, virtualizeRows, extraBulkActions, hideBulkDelete, onBulkDeleteResult, emptyState, }) {
|
|
194
195
|
// The org's timezone/currency: an explicit prop wins, else the app-wide
|
|
195
196
|
// OrgRuntimeProvider (without it, money fell back to USD).
|
|
196
197
|
const orgTimeZone = useTimeZone();
|
|
@@ -244,6 +245,12 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
|
|
|
244
245
|
// A list request that failed for a reason other than 403 (500, network,
|
|
245
246
|
// `success: false`). Shown with a retry instead of a misleading "no results".
|
|
246
247
|
const [loadError, setLoadError] = useState(false);
|
|
248
|
+
// A list request that never answers must not leave the skeleton up forever:
|
|
249
|
+
// after the guard's timeout it is shown as a load error with retry.
|
|
250
|
+
const dataGuard = useLoadingGuard(loadingData && data.length === 0, { timeoutMs: loadTimeoutMs });
|
|
251
|
+
const showLoadError = loadError || dataGuard.timedOut;
|
|
252
|
+
const showDataSkeleton = loadingData && data.length === 0 && !dataGuard.timedOut;
|
|
253
|
+
const [metaReload, setMetaReload] = useState(0);
|
|
247
254
|
const infPageRef = useRef(1);
|
|
248
255
|
const [optionsMap, setOptionsMap] = useState(new Map());
|
|
249
256
|
const [exportOpen, setExportOpen] = useState(false);
|
|
@@ -674,7 +681,11 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
|
|
|
674
681
|
}
|
|
675
682
|
};
|
|
676
683
|
initMetadataAndOptions();
|
|
677
|
-
}, [model]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
684
|
+
}, [model, metaReload]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
685
|
+
const retryMetadata = useCallback(() => {
|
|
686
|
+
metaInitRef.current = false;
|
|
687
|
+
setMetaReload((n) => n + 1);
|
|
688
|
+
}, []);
|
|
678
689
|
// Derived from `metadata.columns[].searchable`. `null` means the kernel
|
|
679
690
|
// didn't emit the flag for any column → preserve legacy "search every
|
|
680
691
|
// column" behaviour by not narrowing the request. An empty array means
|
|
@@ -1054,6 +1065,10 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
|
|
|
1054
1065
|
}
|
|
1055
1066
|
fetchAggregates();
|
|
1056
1067
|
}, [infiniteScroll, fetchPage, fetchData, fetchAggregates]);
|
|
1068
|
+
const retryLoad = useCallback(() => {
|
|
1069
|
+
dataGuard.retry();
|
|
1070
|
+
handleRefresh();
|
|
1071
|
+
}, [dataGuard.retry, handleRefresh]);
|
|
1057
1072
|
// Per-row action dispatch (view/edit/delete/link/custom) + its dialogs live
|
|
1058
1073
|
// in the shared hook so DynamicKanban's card menu behaves identically.
|
|
1059
1074
|
const { handleInternalAction, dialogs: rowActionDialogs } = useDynamicRowActions({
|
|
@@ -1404,16 +1419,13 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
|
|
|
1404
1419
|
enabled: shouldVirtualize,
|
|
1405
1420
|
});
|
|
1406
1421
|
const TableSkeleton = () => (_jsx(_Fragment, { children: Array.from({ length: 5 }).map((_, i) => (_jsxs(TableRow, { className: "hover:bg-transparent", children: [_jsx(TableCell, { className: "py-3 w-10", children: _jsx(Skeleton, { className: "h-4 w-4" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(Skeleton, { className: "h-4 w-[70%]" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(Skeleton, { className: "h-4 w-[50%]" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(Skeleton, { className: "h-4 w-[60%]" }) }), _jsx(TableCell, { className: "py-3 w-16", children: _jsx(Skeleton, { className: "h-6 w-6" }) })] }, `skeleton-${i}`))) }));
|
|
1407
|
-
if (loading) {
|
|
1408
|
-
return (_jsxs("div", { className: 'flex flex-col h-full min-h-0 w-full', children: [_jsx("div", { className: 'pb-4 shrink-0', children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx(Skeleton, { className: "h-9 w-[280px]" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Skeleton, { className: "h-9 w-9" }), _jsx(Skeleton, { className: "h-9 w-[70px]" })] })] }) }), _jsx("div", { className: 'flex-1 min-h-0 overflow-auto border rounded-md bg-card', children: _jsxs(Table, { noWrapper: true, className: "min-w-max w-full", children: [_jsx(TableHeader, { className: 'sticky top-0 z-10', children: _jsxs(TableRow, { className: 'border-b-0 hover:bg-transparent', children: [_jsx(TableHead, { className: 'bg-card border-b h-10 w-10', children: _jsx(Skeleton, { className: "h-4 w-4" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-16" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-14" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-20" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10 w-16', children: _jsx(Skeleton, { className: "h-4 w-12" }) })] }) }), _jsx(TableBody, { children: _jsx(TableSkeleton, {}) })] }) })] }));
|
|
1409
|
-
}
|
|
1410
|
-
if (!metadata) {
|
|
1411
|
-
return _jsx("div", { className: "text-center text-muted-foreground py-8", children: "Error al cargar la configuraci\u00F3n de la tabla." });
|
|
1422
|
+
if (loading || !metadata) {
|
|
1423
|
+
return (_jsx(LoadState, { loading: loading, timeoutMs: loadTimeoutMs, error: !loading && !metadata, onRetry: retryMetadata, className: 'flex flex-col h-full min-h-0 w-full', skeleton: _jsxs("div", { className: 'flex flex-col h-full min-h-0 w-full', children: [_jsx("div", { className: 'pb-4 shrink-0', children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx(Skeleton, { className: "h-9 w-[280px]" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Skeleton, { className: "h-9 w-9" }), _jsx(Skeleton, { className: "h-9 w-[70px]" })] })] }) }), _jsx("div", { className: 'flex-1 min-h-0 overflow-auto border rounded-md bg-card', children: _jsxs(Table, { noWrapper: true, className: "min-w-max w-full", children: [_jsx(TableHeader, { className: 'sticky top-0 z-10', children: _jsxs(TableRow, { className: 'border-b-0 hover:bg-transparent', children: [_jsx(TableHead, { className: 'bg-card border-b h-10 w-10', children: _jsx(Skeleton, { className: "h-4 w-4" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-16" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-14" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-20" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10 w-16', children: _jsx(Skeleton, { className: "h-4 w-12" }) })] }) }), _jsx(TableBody, { children: _jsx(TableSkeleton, {}) })] }) })] }) }));
|
|
1412
1424
|
}
|
|
1413
1425
|
return (_jsx(RowActionsModelContext.Provider, { value: model, children: _jsxs(OptionsContext.Provider, { value: { optionsMap }, children: [_jsxs("div", { className: 'flex flex-col h-full min-h-0 w-full', children: [_jsx("div", { className: 'pb-4 shrink-0', children: _jsx(DataTableToolbar, { table: table, searchPlaceholder: metadata.searchPlaceholder || 'Buscar...', filters: filters, activeFilters: dynamicFilters, onDynamicFilterChange: handleDynamicFilterChange, dateFilter: { value: dateRange, onChange: setDateRange, placeholder: 'Filtrar por fecha' }, perPageOptions: metadata.perPageOptions, onRefresh: handleRefresh, isLoading: loadingData, selectedCount: Object.keys(rowSelection).length, onBulkDelete: () => setShowBulkDeleteConfirm(true), extraActions: _jsxs(_Fragment, { children: [exportEnabled && (_jsxs(Button, { variant: "outline", size: "sm", className: "h-8", onClick: () => setExportOpen(true), children: [_jsx(Download, { className: "h-4 w-4 mr-1" }), " Exportar"] })), importEnabled && (_jsxs(Button, { variant: "outline", size: "sm", className: "h-8", onClick: () => setImportOpen(true), children: [_jsx(Upload, { className: "h-4 w-4 mr-1" }), " Importar"] }))] }) }) }), _jsxs("div", { ref: infDesktopRoot, className: 'hidden sm:block flex-1 min-h-0 overflow-auto border rounded-md bg-card', children: [_jsxs(Table, { noWrapper: true, className: cn('min-w-max w-full', aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && 'h-full'), children: [_jsx(TableHeader, { className: 'sticky top-0 z-10', children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { className: 'border-b-0 hover:bg-transparent', children: headerGroup.headers.map((header) => {
|
|
1414
1426
|
const isActionsColumn = header.id === 'actions';
|
|
1415
1427
|
return (_jsx(TableHead, { colSpan: header.colSpan, style: header.column.columnDef.size ? { width: header.column.columnDef.size } : undefined, className: cn('bg-card border-b h-10', isActionsColumn && 'sticky right-0 z-20 bg-card [background:linear-gradient(var(--card),var(--card)),var(--background)] shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]'), children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id));
|
|
1416
|
-
}) }, headerGroup.id))) }), _jsx(TableBody, { children:
|
|
1428
|
+
}) }, headerGroup.id))) }), _jsx(TableBody, { children: showDataSkeleton ? (_jsx(TableSkeleton, {})) : tableRows.length ? (_jsxs(_Fragment, { children: [shouldVirtualize ? (_jsxs(_Fragment, { children: [desktopVirtualizer.getVirtualItems().length > 0 && (_jsx(TableRow, { className: 'border-0 hover:bg-transparent', "aria-hidden": true, children: _jsx(TableCell, { colSpan: colSpan, className: 'p-0', style: {
|
|
1417
1429
|
height: desktopVirtualizer.getVirtualItems()[0]?.start ?? 0,
|
|
1418
1430
|
} }) })), desktopVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
1419
1431
|
const row = tableRows[virtualRow.index];
|
|
@@ -1437,7 +1449,7 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
|
|
|
1437
1449
|
const isActionsColumn = cell.column.id === 'actions';
|
|
1438
1450
|
const isSelectColumn = cell.column.id === 'select';
|
|
1439
1451
|
return (_jsx(TableCell, { style: cell.column.columnDef.size ? { width: cell.column.columnDef.size } : undefined, className: cn('py-2', isActionsColumn && 'sticky right-0 bg-card [background:linear-gradient(var(--card),var(--card)),var(--background)] shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]'), onClick: (isActionsColumn || isSelectColumn) ? (e) => e.stopPropagation() : undefined, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
1440
|
-
}) }, row.id)))), aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && (_jsx(TableRow, { className: 'border-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0' }) }))] })) : (_jsx(TableRow, { className: 'border-b-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0', children: _jsxs("div", { className: "flex h-full py-12 flex-col items-center justify-center gap-2 text-muted-foreground", children: [_jsx("div", { className: "flex h-20 w-20 items-center justify-center rounded-full bg-muted/50", children: _jsx(Inbox, { className: "h-10 w-10" }) }), _jsx("div", { className: "flex flex-col items-center gap-1", children: forbidden ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: "text-lg font-semibold text-foreground", role: "alert", children: t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' }) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' }) })] })) :
|
|
1452
|
+
}) }, row.id)))), aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && (_jsx(TableRow, { className: 'border-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0' }) }))] })) : (_jsx(TableRow, { className: 'border-b-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0', children: _jsxs("div", { className: "flex h-full py-12 flex-col items-center justify-center gap-2 text-muted-foreground", children: [_jsx("div", { className: "flex h-20 w-20 items-center justify-center rounded-full bg-muted/50", children: _jsx(Inbox, { className: "h-10 w-10" }) }), _jsx("div", { className: "flex flex-col items-center gap-1", children: forbidden ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: "text-lg font-semibold text-foreground", role: "alert", children: t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' }) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' }) })] })) : showLoadError ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: "text-lg font-semibold text-foreground", role: "alert", children: t('dynamic.load_error_title', { defaultValue: 'No se pudieron cargar los datos' }) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('dynamic.load_error_hint', { defaultValue: 'Ocurrió un error al consultar la lista. Inténtalo de nuevo.' }) }), _jsx(Button, { variant: "outline", size: "sm", className: "mt-2", onClick: retryLoad, children: t('dynamic.retry', { defaultValue: 'Reintentar' }) })] })) : emptyState && !hasActiveFilters ? (emptyState) : (_jsxs(_Fragment, { children: [_jsx("h3", { className: "text-lg font-semibold text-foreground", children: "No se encontraron resultados" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "No hay datos para mostrar en este momento." })] })) })] }) }) })) }), aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && (_jsx(TableFooter, { className: "bg-transparent", children: _jsx(TableRow, { className: "hover:bg-transparent", children: table.getVisibleLeafColumns().map((leaf, idx) => {
|
|
1441
1453
|
const col = (metadata?.columns ?? []).find((c) => c.key === leaf.id);
|
|
1442
1454
|
const isFirst = idx === 0;
|
|
1443
1455
|
const stickyBase = 'sticky bottom-0 z-10 border-t bg-background py-2 font-semibold';
|
|
@@ -1447,7 +1459,7 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
|
|
|
1447
1459
|
}
|
|
1448
1460
|
// First non-aggregate column carries the "Total" label.
|
|
1449
1461
|
return (_jsx(TableCell, { className: stickyBase, children: isFirst ? t('common.total', 'Total') : '' }, leaf.id));
|
|
1450
|
-
}) }) }))] }), infiniteScroll && (_jsxs(_Fragment, { children: [loadingMore && (_jsx("div", { className: 'p-2', children: _jsx(Skeleton, { className: 'h-8 w-full', "data-testid": 'table-loading-more' }) })), _jsx("div", { ref: infDesktopSentinel, className: 'h-1 w-full', "aria-hidden": true })] }))] }), _jsxs("div", { ref: infMobileRoot, className: 'flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto sm:hidden', children: [
|
|
1462
|
+
}) }) }))] }), infiniteScroll && (_jsxs(_Fragment, { children: [loadingMore && (_jsx("div", { className: 'p-2', children: _jsx(Skeleton, { className: 'h-8 w-full', "data-testid": 'table-loading-more' }) })), _jsx("div", { ref: infDesktopSentinel, className: 'h-1 w-full', "aria-hidden": true })] }))] }), _jsxs("div", { ref: infMobileRoot, className: 'flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto sm:hidden', children: [showDataSkeleton ? (Array.from({ length: 5 }).map((_, i) => (_jsxs("div", { className: 'rounded-lg border bg-card p-3', children: [_jsx(Skeleton, { className: 'h-4 w-24' }), _jsx(Skeleton, { className: 'mt-2 h-4 w-40' }), _jsx(Skeleton, { className: 'mt-2 h-4 w-32' })] }, i)))) : tableRows.length ? (shouldVirtualize ? (_jsx("div", { className: 'relative w-full', style: { height: mobileVirtualizer.getTotalSize() }, children: mobileVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
1451
1463
|
const row = tableRows[virtualRow.index];
|
|
1452
1464
|
if (!row)
|
|
1453
1465
|
return null;
|
|
@@ -1477,7 +1489,7 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
|
|
|
1477
1489
|
(typeof header === 'string' ? header : cell.column.id);
|
|
1478
1490
|
return (_jsxs("div", { className: 'flex items-start justify-between gap-3 text-sm', children: [_jsx("span", { className: 'shrink-0 text-muted-foreground', children: label }), _jsx("span", { className: 'min-w-0 overflow-hidden break-words text-right font-medium [&_[data-slot=badge]]:max-w-full [&_[data-slot=badge]]:whitespace-normal [&_[data-slot=badge]]:text-start', children: flexRender(cell.column.columnDef.cell, cell.getContext()) })] }, cell.id));
|
|
1479
1491
|
}), actionsCell && (_jsx("div", { className: 'flex justify-end border-t pt-2', onClick: onRowClick ? (e) => e.stopPropagation() : undefined, children: flexRender(actionsCell.column.columnDef.cell, actionsCell.getContext()) }))] }, row.id));
|
|
1480
|
-
}))) : (_jsxs("div", { className: 'flex flex-col items-center justify-center gap-2 rounded-lg border bg-card py-12 text-muted-foreground', children: [_jsx("div", { className: 'flex h-16 w-16 items-center justify-center rounded-full bg-muted/50', children: _jsx(Inbox, { className: 'h-8 w-8' }) }), forbidden ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: 'text-base font-semibold text-foreground', role: 'alert', children: t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' }) }), _jsx("p", { className: 'text-sm text-muted-foreground', children: t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' }) })] })) :
|
|
1492
|
+
}))) : (_jsxs("div", { className: 'flex flex-col items-center justify-center gap-2 rounded-lg border bg-card py-12 text-muted-foreground', children: [_jsx("div", { className: 'flex h-16 w-16 items-center justify-center rounded-full bg-muted/50', children: _jsx(Inbox, { className: 'h-8 w-8' }) }), forbidden ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: 'text-base font-semibold text-foreground', role: 'alert', children: t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' }) }), _jsx("p", { className: 'text-sm text-muted-foreground', children: t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' }) })] })) : showLoadError ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: 'text-base font-semibold text-foreground', role: 'alert', children: t('dynamic.load_error_title', { defaultValue: 'No se pudieron cargar los datos' }) }), _jsx("p", { className: 'text-sm text-muted-foreground', children: t('dynamic.load_error_hint', { defaultValue: 'Ocurrió un error al consultar la lista. Inténtalo de nuevo.' }) }), _jsx(Button, { variant: 'outline', size: 'sm', onClick: retryLoad, children: t('dynamic.retry', { defaultValue: 'Reintentar' }) })] })) : emptyState && !hasActiveFilters ? (emptyState) : (_jsxs(_Fragment, { children: [_jsx("h3", { className: 'text-base font-semibold text-foreground', children: "No se encontraron resultados" }), _jsx("p", { className: 'text-sm text-muted-foreground', children: "No hay datos para mostrar en este momento." })] }))] })), infiniteScroll && (_jsxs(_Fragment, { children: [loadingMore && (_jsx(Skeleton, { className: 'h-16 w-full shrink-0', "data-testid": 'table-loading-more-mobile' })), _jsx("div", { ref: infMobileSentinel, className: 'h-1 w-full shrink-0', "aria-hidden": true })] }))] }), _jsx("div", { className: 'shrink-0 pt-4', children: infiniteScroll ? (data.length > 0 && (_jsx("p", { className: 'text-center text-xs text-muted-foreground tabular-nums', children: t('common.showingCount', {
|
|
1481
1493
|
defaultValue: '{{count}} de {{total}}',
|
|
1482
1494
|
count: data.length,
|
|
1483
1495
|
total: rowCount,
|
package/dist/dynamic-view.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type DynamicTableProps } from './dynamic-table';
|
|
2
|
-
import { type DynamicKanbanProps } from './dynamic-kanban';
|
|
3
|
-
import type { TableMetadata } from './types';
|
|
4
|
-
import type { ViewDataSource } from './views/types';
|
|
1
|
+
import { type DynamicTableProps } from './dynamic-table.js';
|
|
2
|
+
import { type DynamicKanbanProps } from './dynamic-kanban.js';
|
|
3
|
+
import type { TableMetadata } from './types.js';
|
|
4
|
+
import type { ViewDataSource } from './views/types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Pure routing decision: which renderer a `view_type` maps onto. Exported so a
|
|
7
7
|
* host that resolves metadata itself can branch without mounting this wrapper.
|
package/dist/dynamic-view.js
CHANGED
|
@@ -15,13 +15,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
15
15
|
// read this wrapper does to learn `view_type` is served from the same cache —
|
|
16
16
|
// no duplicate network round-trip in practice.
|
|
17
17
|
import { useEffect, useMemo, useState } from 'react';
|
|
18
|
-
import { useApi } from './api-context';
|
|
19
|
-
import { useMetadataCache } from './metadata-cache';
|
|
20
|
-
import { cacheScope } from './cache-scope';
|
|
21
|
-
import { DynamicTable } from './dynamic-table';
|
|
22
|
-
import { DynamicKanban } from './dynamic-kanban';
|
|
23
|
-
import { DeclarativeView, isDeclarativeViewType } from './views/registry';
|
|
24
|
-
import { createApiViewDataSource } from './views/data-source';
|
|
18
|
+
import { useApi } from './api-context.js';
|
|
19
|
+
import { useMetadataCache } from './metadata-cache.js';
|
|
20
|
+
import { cacheScope } from './cache-scope.js';
|
|
21
|
+
import { DynamicTable } from './dynamic-table.js';
|
|
22
|
+
import { DynamicKanban } from './dynamic-kanban.js';
|
|
23
|
+
import { DeclarativeView, isDeclarativeViewType } from './views/registry.js';
|
|
24
|
+
import { createApiViewDataSource } from './views/data-source.js';
|
|
25
25
|
/**
|
|
26
26
|
* Pure routing decision: which renderer a `view_type` maps onto. Exported so a
|
|
27
27
|
* host that resolves metadata itself can branch without mounting this wrapper.
|
package/dist/entity-select.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { RecordPicker, useLatestSearch } from './record-picker';
|
|
3
|
-
import { recordLabel } from './record-picker-actions';
|
|
4
|
-
import { useRecordPickerDialog } from './record-picker-dialog';
|
|
5
|
-
import { useCan } from './permissions-context';
|
|
2
|
+
import { RecordPicker, useLatestSearch } from './record-picker.js';
|
|
3
|
+
import { recordLabel } from './record-picker-actions.js';
|
|
4
|
+
import { useRecordPickerDialog } from './record-picker-dialog.js';
|
|
5
|
+
import { useCan } from './permissions-context.js';
|
|
6
6
|
/** Lowercase model → permission capability namespace (Supplier → supplier). */
|
|
7
7
|
function capabilityNamespace(model) {
|
|
8
8
|
return model.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ActionFieldDef } from './types';
|
|
2
|
-
import type { Translate } from './server-error';
|
|
1
|
+
import type { ActionFieldDef } from './types.js';
|
|
2
|
+
import type { Translate } from './server-error.js';
|
|
3
3
|
/**
|
|
4
4
|
* Resolve a validation path (`customer_id`, `lines.0.unit_price`) to a
|
|
5
5
|
* human label using the action/modal field schema. Nested line-item paths
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { ActionFieldDef } from './types';
|
|
2
|
+
import type { ActionFieldDef } from './types.js';
|
|
3
3
|
export interface FieldWidgetProps {
|
|
4
4
|
/** The served field definition (key, label, type, widget, options…). */
|
|
5
5
|
field: ActionFieldDef;
|
package/dist/form-layout-ui.d.ts
CHANGED
package/dist/form-layout.d.ts
CHANGED
package/dist/form-layout.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// (`dynamic-form.tsx`, `dialogs/dynamic-record.tsx`) share one tested
|
|
14
14
|
// implementation and the modal-render machinery never has to be booted under
|
|
15
15
|
// happy-dom just to assert the grouping (same approach as PR #673).
|
|
16
|
-
import { evaluateVisibleWhen, getVisibleWhen } from './dynamic-form-schema';
|
|
16
|
+
import { evaluateVisibleWhen, getVisibleWhen } from './dynamic-form-schema.js';
|
|
17
17
|
/** The synthetic key of the orphan group (fields with no / unknown `section`). */
|
|
18
18
|
export const DEFAULT_SECTION_KEY = '__default__';
|
|
19
19
|
/** Reads a field's `section` reference, tolerating a camelCase alias. */
|
package/dist/genui/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SettingsBlock, coerceSettings, registerGenUISettingsBlock, settingsToFields, type SettingDefLike } from './settings-block';
|
|
1
|
+
export { SettingsBlock, coerceSettings, registerGenUISettingsBlock, settingsToFields, type SettingDefLike } from './settings-block.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/genui/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { SettingsBlock, coerceSettings, registerGenUISettingsBlock, settingsToFields } from './settings-block';
|
|
1
|
+
export { SettingsBlock, coerceSettings, registerGenUISettingsBlock, settingsToFields } from './settings-block.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type GenUIBlockRendererProps } from '@asteby/metacore-genui';
|
|
3
|
-
import type { ActionFieldDef } from '../types';
|
|
3
|
+
import type { ActionFieldDef } from '../types.js';
|
|
4
4
|
export interface SettingDefLike {
|
|
5
5
|
key: string;
|
|
6
6
|
label?: string;
|
|
@@ -14,9 +14,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import * as React from 'react';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { registerGenUIBlockRenderer } from '@asteby/metacore-genui';
|
|
17
|
-
import { useApi } from '../api-context';
|
|
18
|
-
import { useAddonSettings } from '../use-addon-settings';
|
|
19
|
-
import { DynamicForm } from '../dynamic-form';
|
|
17
|
+
import { useApi } from '../api-context.js';
|
|
18
|
+
import { useAddonSettings } from '../use-addon-settings.js';
|
|
19
|
+
import { DynamicForm } from '../dynamic-form.js';
|
|
20
20
|
const humanize = (k) => k.replace(/[_.-]+/g, ' ').replace(/^\w/, (c) => c.toUpperCase());
|
|
21
21
|
/**
|
|
22
22
|
* `FromSettings`: projects an addon's setting definitions to form fields.
|
|
@@ -4,6 +4,16 @@ export { ApiError, isAbortError };
|
|
|
4
4
|
export interface HostRequestConfig {
|
|
5
5
|
params?: HostApiParams;
|
|
6
6
|
signal?: AbortSignal;
|
|
7
|
+
/**
|
|
8
|
+
* Extra headers for this call (e.g. `X-Correlation-ID`), merged over the
|
|
9
|
+
* client's `defaultHeaders`. The host drops Authorization, X-Organization-ID
|
|
10
|
+
* and the other headers it owns; they can never be overridden from here.
|
|
11
|
+
*/
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export interface HostApiClientOptions {
|
|
15
|
+
/** Headers sent on every call; per-call `headers` win over them. */
|
|
16
|
+
defaultHeaders?: Record<string, string>;
|
|
7
17
|
}
|
|
8
18
|
/** Minimal axios-like surface (what DynamicSelectField & co. call). */
|
|
9
19
|
export interface AxiosLikeClient {
|
|
@@ -51,5 +61,5 @@ export interface HostApiClient {
|
|
|
51
61
|
axiosLike(): AxiosLikeClient;
|
|
52
62
|
}
|
|
53
63
|
/** Build the client over the host-injected {@link HostApi}. */
|
|
54
|
-
export declare function createHostApiClient(api: HostApi): HostApiClient;
|
|
64
|
+
export declare function createHostApiClient(api: HostApi, options?: HostApiClientOptions): HostApiClient;
|
|
55
65
|
//# sourceMappingURL=host-api-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-api-client.d.ts","sourceRoot":"","sources":["../src/host-api-client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EACH,QAAQ,EACR,YAAY,EAIZ,KAAK,aAAa,EACrB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;AAEjC,MAAM,WAAW,iBAAiB;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,MAAM,CAAC,EAAE,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"host-api-client.d.ts","sourceRoot":"","sources":["../src/host-api-client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EACH,QAAQ,EACR,YAAY,EAIZ,KAAK,aAAa,EACrB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;AAEjC,MAAM,WAAW,iBAAiB;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,oBAAoB;IACjC,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1C;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC5B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACxE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACzF,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACxF,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAC1F,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;CAC9E;AAED,MAAM,WAAW,aAAa;IAC1B,mEAAmE;IACnE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACtE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACvF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACtF,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACxF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACzE,sEAAsE;IACtE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IACtF,+CAA+C;IAC/C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7D;;;;OAIG;IACH,MAAM,CAAC,CAAC,GAAG,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,QAAQ,EAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACpD,OAAO,CAAC,CAAC,CAAC,CAAA;IACb;;;;OAIG;IACH,SAAS,IAAI,eAAe,CAAA;CAC/B;AAqBD,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAyDnG"}
|
package/dist/host-api-client.js
CHANGED
|
@@ -32,7 +32,14 @@ function toApiError(e, signal) {
|
|
|
32
32
|
return new ApiError('request failed', { cause: e });
|
|
33
33
|
}
|
|
34
34
|
/** Build the client over the host-injected {@link HostApi}. */
|
|
35
|
-
export function createHostApiClient(api) {
|
|
35
|
+
export function createHostApiClient(api, options = {}) {
|
|
36
|
+
const defaults = options.defaultHeaders;
|
|
37
|
+
// Additive: without defaults or per-call headers the config is untouched.
|
|
38
|
+
const cfg = (c) => {
|
|
39
|
+
if (!defaults)
|
|
40
|
+
return c;
|
|
41
|
+
return { ...(c ?? {}), headers: { ...defaults, ...(c?.headers ?? {}) } };
|
|
42
|
+
};
|
|
36
43
|
const run = async (p, signal) => {
|
|
37
44
|
try {
|
|
38
45
|
return await p();
|
|
@@ -43,13 +50,13 @@ export function createHostApiClient(api) {
|
|
|
43
50
|
};
|
|
44
51
|
const body = (p, signal) => run(async () => unwrapEnvelope(await p()), signal);
|
|
45
52
|
const client = {
|
|
46
|
-
get: (path, c) => body(() => api.get(path, c), c?.signal),
|
|
47
|
-
post: (path, b, c) => body(() => api.post(path, b, c), c?.signal),
|
|
48
|
-
put: (path, b, c) => body(() => api.put(path, b, c), c?.signal),
|
|
49
|
-
patch: (path, b, c) => body(() => api.patch(path, b, c), c?.signal),
|
|
50
|
-
delete: (path, c) => body(() => api.delete(path, c), c?.signal),
|
|
51
|
-
list: (path, c) => run(async () => unwrapList(await api.get(path, c)), c?.signal),
|
|
52
|
-
blob: (path, c) => run(() => api.get(path, { ...c, responseType: 'blob' }), c?.signal),
|
|
53
|
+
get: (path, c) => body(() => api.get(path, cfg(c)), c?.signal),
|
|
54
|
+
post: (path, b, c) => body(() => api.post(path, b, cfg(c)), c?.signal),
|
|
55
|
+
put: (path, b, c) => body(() => api.put(path, b, cfg(c)), c?.signal),
|
|
56
|
+
patch: (path, b, c) => body(() => api.patch(path, b, cfg(c)), c?.signal),
|
|
57
|
+
delete: (path, c) => body(() => api.delete(path, cfg(c)), c?.signal),
|
|
58
|
+
list: (path, c) => run(async () => unwrapList(await api.get(path, cfg(c))), c?.signal),
|
|
59
|
+
blob: (path, c) => run(() => api.get(path, { ...cfg(c), responseType: 'blob' }), c?.signal),
|
|
53
60
|
upload: (path, file, fields, opts) => {
|
|
54
61
|
let form;
|
|
55
62
|
if (typeof FormData !== 'undefined' && file instanceof FormData) {
|
|
@@ -61,7 +68,7 @@ export function createHostApiClient(api) {
|
|
|
61
68
|
for (const [k, v] of Object.entries(fields ?? {}))
|
|
62
69
|
form.append(k, v);
|
|
63
70
|
}
|
|
64
|
-
return body(() => api.post(path, form, opts?.signal ? { signal: opts.signal } : undefined), opts?.signal);
|
|
71
|
+
return body(() => api.post(path, form, cfg(opts?.signal ? { signal: opts.signal } : undefined)), opts?.signal);
|
|
65
72
|
},
|
|
66
73
|
axiosLike: () => {
|
|
67
74
|
// Envelope kept (the runtime-react fields unwrap it themselves),
|
|
@@ -73,11 +80,11 @@ export function createHostApiClient(api) {
|
|
|
73
80
|
return { data };
|
|
74
81
|
}, signal);
|
|
75
82
|
return {
|
|
76
|
-
get: (u, c) => raw(() => api.get(u, c), c?.signal),
|
|
77
|
-
post: (u, b, c) => raw(() => api.post(u, b, c), c?.signal),
|
|
78
|
-
put: (u, b, c) => raw(() => api.put(u, b, c), c?.signal),
|
|
79
|
-
patch: (u, b, c) => raw(() => api.patch(u, b, c), c?.signal),
|
|
80
|
-
delete: (u, c) => raw(() => api.delete(u, c), c?.signal),
|
|
83
|
+
get: (u, c) => raw(() => api.get(u, cfg(c)), c?.signal),
|
|
84
|
+
post: (u, b, c) => raw(() => api.post(u, b, cfg(c)), c?.signal),
|
|
85
|
+
put: (u, b, c) => raw(() => api.put(u, b, cfg(c)), c?.signal),
|
|
86
|
+
patch: (u, b, c) => raw(() => api.patch(u, b, cfg(c)), c?.signal),
|
|
87
|
+
delete: (u, c) => raw(() => api.delete(u, cfg(c)), c?.signal),
|
|
81
88
|
};
|
|
82
89
|
},
|
|
83
90
|
};
|
package/dist/host-api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HostApiError } from '@asteby/metacore-sdk';
|
|
2
2
|
import type { HostApi } from '@asteby/metacore-sdk';
|
|
3
|
-
import type { ApiClient } from './api-context';
|
|
3
|
+
import type { ApiClient } from './api-context.js';
|
|
4
4
|
export interface CreateHostApiOptions {
|
|
5
5
|
/**
|
|
6
6
|
* Endpoint the host serves capability queries on (`POST`, body
|
|
@@ -17,6 +17,14 @@ export interface CreateHostApiOptions {
|
|
|
17
17
|
}
|
|
18
18
|
/** Strip transport details from any error before it reaches remote code. */
|
|
19
19
|
export declare function toHostApiError(e: unknown): HostApiError;
|
|
20
|
+
/**
|
|
21
|
+
* Headers the host owns. A remote may add headers but never set these: they
|
|
22
|
+
* carry the credentials, the tenant scope or transport framing. Compared
|
|
23
|
+
* lowercase.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PROTECTED_HOST_HEADERS: ReadonlySet<string>;
|
|
26
|
+
/** Drop protected / malformed headers; returns undefined when none remain. */
|
|
27
|
+
export declare function sanitizeRemoteHeaders(headers: Record<string, string> | undefined): Record<string, string> | undefined;
|
|
20
28
|
/** Build the remote-facing {@link HostApi} over the host's ApiClient. */
|
|
21
29
|
export declare function createHostApi(client: ApiClient, options?: CreateHostApiOptions): HostApi;
|
|
22
30
|
//# sourceMappingURL=host-api.d.ts.map
|
package/dist/host-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-api.d.ts","sourceRoot":"","sources":["../src/host-api.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EACR,OAAO,EAGV,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C,MAAM,WAAW,oBAAoB;IACjC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB;AAkBD,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,YAAY,CAWvD;
|
|
1
|
+
{"version":3,"file":"host-api.d.ts","sourceRoot":"","sources":["../src/host-api.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EACR,OAAO,EAGV,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C,MAAM,WAAW,oBAAoB;IACjC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB;AAkBD,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,YAAY,CAWvD;AAcD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAyBrD,CAAA;AAGF,8EAA8E;AAC9E,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAC5C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAYpC;AA6CD,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAgD5F"}
|
package/dist/host-api.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// credentials the host attaches.
|
|
13
13
|
import { HostApiError } from '@asteby/metacore-sdk';
|
|
14
14
|
import { isAbortError } from '@asteby/metacore-lib/envelope';
|
|
15
|
-
import { batchGet } from './query-batch';
|
|
15
|
+
import { batchGet } from './query-batch.js';
|
|
16
16
|
function errorMessage(data, fallback) {
|
|
17
17
|
if (data && typeof data === 'object') {
|
|
18
18
|
const d = data;
|
|
@@ -50,6 +50,57 @@ function safeData(data) {
|
|
|
50
50
|
return undefined;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Headers the host owns. A remote may add headers but never set these: they
|
|
55
|
+
* carry the credentials, the tenant scope or transport framing. Compared
|
|
56
|
+
* lowercase.
|
|
57
|
+
*/
|
|
58
|
+
export const PROTECTED_HOST_HEADERS = new Set([
|
|
59
|
+
'authorization',
|
|
60
|
+
'proxy-authorization',
|
|
61
|
+
'cookie',
|
|
62
|
+
'x-organization-id',
|
|
63
|
+
'x-org-id',
|
|
64
|
+
'x-branch-id',
|
|
65
|
+
'accept-language',
|
|
66
|
+
'host',
|
|
67
|
+
'content-length',
|
|
68
|
+
'content-type',
|
|
69
|
+
'transfer-encoding',
|
|
70
|
+
'origin',
|
|
71
|
+
'referer',
|
|
72
|
+
// Reenvio / identidad de origen: el backend arma URLs publicas y decide
|
|
73
|
+
// tenant a partir de ellas.
|
|
74
|
+
'x-forwarded-host',
|
|
75
|
+
'x-forwarded-proto',
|
|
76
|
+
'x-forwarded-for',
|
|
77
|
+
'x-forwarded-port',
|
|
78
|
+
'forwarded',
|
|
79
|
+
'x-real-ip',
|
|
80
|
+
'x-storefront-domain',
|
|
81
|
+
'x-api-key',
|
|
82
|
+
'x-http-method-override',
|
|
83
|
+
]);
|
|
84
|
+
const PROTECTED_HEADER_PREFIXES = ['proxy-'];
|
|
85
|
+
/** Drop protected / malformed headers; returns undefined when none remain. */
|
|
86
|
+
export function sanitizeRemoteHeaders(headers) {
|
|
87
|
+
if (!headers || typeof headers !== 'object')
|
|
88
|
+
return undefined;
|
|
89
|
+
const out = {};
|
|
90
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
91
|
+
if (typeof value !== 'string')
|
|
92
|
+
continue;
|
|
93
|
+
if (!/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/.test(name))
|
|
94
|
+
continue;
|
|
95
|
+
if (/[\r\n]/.test(value))
|
|
96
|
+
continue;
|
|
97
|
+
const lower = name.toLowerCase();
|
|
98
|
+
if (PROTECTED_HOST_HEADERS.has(lower) || PROTECTED_HEADER_PREFIXES.some((p) => lower.startsWith(p)))
|
|
99
|
+
continue;
|
|
100
|
+
out[name] = value;
|
|
101
|
+
}
|
|
102
|
+
return Object.keys(out).length ? out : undefined;
|
|
103
|
+
}
|
|
53
104
|
function toConfig(opts) {
|
|
54
105
|
if (!opts)
|
|
55
106
|
return undefined;
|
|
@@ -60,6 +111,9 @@ function toConfig(opts) {
|
|
|
60
111
|
config.signal = opts.signal;
|
|
61
112
|
if (opts.responseType === 'blob')
|
|
62
113
|
config.responseType = 'blob';
|
|
114
|
+
const headers = sanitizeRemoteHeaders(opts.headers);
|
|
115
|
+
if (headers)
|
|
116
|
+
config.headers = headers;
|
|
63
117
|
return config;
|
|
64
118
|
}
|
|
65
119
|
// With `responseType: 'blob'` axios also delivers the error body as a Blob.
|
|
@@ -109,7 +163,8 @@ export function createHostApi(client, options = {}) {
|
|
|
109
163
|
return Object.freeze({
|
|
110
164
|
get: (path, opts) => {
|
|
111
165
|
const args = withConfig([path], opts);
|
|
112
|
-
|
|
166
|
+
// A GET with per-call headers cannot share a POST /q: it goes on its own.
|
|
167
|
+
const batch = options.batchGets && opts?.responseType !== 'blob' && !sanitizeRemoteHeaders(opts?.headers);
|
|
113
168
|
return bodyOf(batch ? batchGet(client, ...args) : client.get(...args), opts);
|
|
114
169
|
},
|
|
115
170
|
post: (path, body, opts) => bodyOf(client.post(...withConfig([path, body], opts)), opts),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AddonManifestChangedMessage, type ManifestHotSwapClient, type WireHotSwapInvalidationOptions } from './manifest-hotswap-subscriber';
|
|
1
|
+
import { type AddonManifestChangedMessage, type ManifestHotSwapClient, type WireHotSwapInvalidationOptions } from './manifest-hotswap-subscriber.js';
|
|
2
2
|
/**
|
|
3
3
|
* One of three strategies for reacting to an `ADDON_MANIFEST_CHANGED` event:
|
|
4
4
|
*
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
// for backward compatibility (legacy hosts may still call it from `onSwap`) but
|
|
55
55
|
// is a no-op under the MF runtime.
|
|
56
56
|
import { useMemo, useRef, useState } from 'react';
|
|
57
|
-
import { useManifestHotSwapSubscriber, } from './manifest-hotswap-subscriber';
|
|
57
|
+
import { useManifestHotSwapSubscriber, } from './manifest-hotswap-subscriber.js';
|
|
58
58
|
/**
|
|
59
59
|
* Pure (testable) implementation of the swap handler. Decides the action
|
|
60
60
|
* given a message + config + deps, applies side effects via `deps`, and
|
|
@@ -14,10 +14,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
// means image, anything else means icon.
|
|
15
15
|
import { useMemo, useState } from 'react';
|
|
16
16
|
import { ChevronsUpDown } from 'lucide-react';
|
|
17
|
-
import { lucideIconNames } from './dynamic-icon';
|
|
17
|
+
import { lucideIconNames } from './dynamic-icon.js';
|
|
18
18
|
import { Button, Input, Popover, PopoverContent, PopoverTrigger, } from '@asteby/metacore-ui/primitives';
|
|
19
|
-
import { DynamicIcon, resolveLucideIconName } from './dynamic-icon';
|
|
20
|
-
import { UploadField } from './upload-field';
|
|
19
|
+
import { DynamicIcon, resolveLucideIconName } from './dynamic-icon.js';
|
|
20
|
+
import { UploadField } from './upload-field.js';
|
|
21
21
|
/** Icons rendered per "page" — grows as the user scrolls to the bottom. Keeps
|
|
22
22
|
* the DOM light: the lucide catalog is ~1500 glyphs, so we never mount them all. */
|
|
23
23
|
const PAGE = 60;
|
package/dist/icon-resolvers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { type IconSpec } from './icon-spec';
|
|
2
|
+
import { type IconSpec } from './icon-spec.js';
|
|
3
3
|
export type IconResolver = (spec: string) => IconSpec | ReactNode | null | undefined;
|
|
4
4
|
/** Outcome of resolving: a built-in spec, or a node the host rendered itself. */
|
|
5
5
|
export type ResolvedIcon = IconSpec | {
|
package/dist/icon-resolvers.js
CHANGED
package/dist/icon-spec.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// ("mdi mdi-home", "bi bi-house", "ti ti-home", "ri-home-line") and Iconify ids
|
|
14
14
|
// ("mdi:home") only get the generic normalisation against Lucide; no tables.
|
|
15
15
|
import dynamicIconImports from 'lucide-react/dynamicIconImports';
|
|
16
|
-
import { FONT_AWESOME_ALIASES } from './icon-aliases';
|
|
16
|
+
import { FONT_AWESOME_ALIASES } from './icon-aliases.js';
|
|
17
17
|
const LUCIDE_KEYS = dynamicIconImports;
|
|
18
18
|
function kebabToPascal(kebab) {
|
|
19
19
|
return kebab
|