@nubitio/crud 0.5.16 → 0.5.19
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/index.cjs +43 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.mts +15 -1
- package/dist/index.mjs +42 -2
- package/dist/style.css +3 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -62,6 +62,17 @@ function defineResource(apiUrl, overrides) {
|
|
|
62
62
|
return resource;
|
|
63
63
|
}
|
|
64
64
|
//#endregion
|
|
65
|
+
//#region packages/crud/crud/embeddedLinesUrl.ts
|
|
66
|
+
/**
|
|
67
|
+
* Builds a formDetail reload URL for {@code #[EmbeddedLines]} line entities.
|
|
68
|
+
*
|
|
69
|
+
* @example embeddedLinesUrl('/api/sales_document_lines', 'document')
|
|
70
|
+
* → '/api/sales_document_lines?document={id}'
|
|
71
|
+
*/
|
|
72
|
+
function embeddedLinesUrl(route, parentQueryParam) {
|
|
73
|
+
return `${route}${route.includes("?") ? "&" : "?"}${parentQueryParam}={id}`;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
65
76
|
//#region packages/crud/datagrid/DataGridEvents.ts
|
|
66
77
|
const DATA_GRID_EVENTS = {
|
|
67
78
|
SELECTION_CHANGED: "datagrid:selection.changed",
|
|
@@ -3588,6 +3599,17 @@ function normalizeEntityField(row, field, adapter, prependDataByField) {
|
|
|
3588
3599
|
}
|
|
3589
3600
|
}
|
|
3590
3601
|
//#endregion
|
|
3602
|
+
//#region packages/crud/form/loadDetailRows.ts
|
|
3603
|
+
/**
|
|
3604
|
+
* Loads embedded line rows for formDetail edit mode. Accepts both plain JSON
|
|
3605
|
+
* arrays (nubit embedded-lines endpoint) and Hydra collections.
|
|
3606
|
+
*/
|
|
3607
|
+
async function loadDetailRows(httpClient, detailUrl, adapter) {
|
|
3608
|
+
const response = await httpClient.get(detailUrl);
|
|
3609
|
+
const { items } = (adapter ?? HydraAdapter).parseListResponse(response.data);
|
|
3610
|
+
return items;
|
|
3611
|
+
}
|
|
3612
|
+
//#endregion
|
|
3591
3613
|
//#region packages/crud/form/safeRandomId.ts
|
|
3592
3614
|
/**
|
|
3593
3615
|
* Generate a unique-enough id string for internal React keys.
|
|
@@ -4648,7 +4670,7 @@ const NativeFormView = (0, react.forwardRef)((options, ref) => {
|
|
|
4648
4670
|
const detailUrl = typeof detailId === "string" || typeof detailId === "number" ? options.detailUrl?.replace("{id}", String(detailId)) : void 0;
|
|
4649
4671
|
if (!detailUrl) return;
|
|
4650
4672
|
emit(FORM_EVENTS.LOADING, true);
|
|
4651
|
-
httpClient.
|
|
4673
|
+
loadDetailRows(httpClient, detailUrl, options.adapter).then((rows) => setNextDetailRows(rows)).finally(() => emit(FORM_EVENTS.LOADING, false));
|
|
4652
4674
|
}, [
|
|
4653
4675
|
captureExistingMedia,
|
|
4654
4676
|
emit,
|
|
@@ -8438,6 +8460,24 @@ function ToolbarSelect({ id, label, icon = "ph-funnel", value, options, onChange
|
|
|
8438
8460
|
});
|
|
8439
8461
|
}
|
|
8440
8462
|
//#endregion
|
|
8463
|
+
//#region packages/crud/workflow/buildWorkflowRowActions.ts
|
|
8464
|
+
function buildWorkflowRowActions(row, workflow, apiUrl, roles, onDone) {
|
|
8465
|
+
if (!workflow) return [];
|
|
8466
|
+
const current = String(row[workflow.field] ?? "");
|
|
8467
|
+
return workflow.transitions.filter((transition) => transition.from.includes(current)).filter((transition) => !transition.roles?.length || transition.roles.some((role) => roles.includes(role))).map((transition) => ({
|
|
8468
|
+
text: transition.label ?? transition.name,
|
|
8469
|
+
onClick: async () => {
|
|
8470
|
+
const base = apiUrl.replace(/\/$/, "");
|
|
8471
|
+
const id = row.id;
|
|
8472
|
+
await fetch(`${base}/${id}/transition/${transition.name}`, {
|
|
8473
|
+
method: "POST",
|
|
8474
|
+
credentials: "include"
|
|
8475
|
+
});
|
|
8476
|
+
onDone?.();
|
|
8477
|
+
}
|
|
8478
|
+
}));
|
|
8479
|
+
}
|
|
8480
|
+
//#endregion
|
|
8441
8481
|
//#region packages/crud/adapter/RestAdapter.ts
|
|
8442
8482
|
/**
|
|
8443
8483
|
* Backend adapter for plain OpenAPI / REST backends.
|
|
@@ -8617,6 +8657,7 @@ exports.SmartCrudRolesProvider = SmartCrudRolesProvider;
|
|
|
8617
8657
|
exports.ToolbarSelect = ToolbarSelect;
|
|
8618
8658
|
exports.buildFieldColSpanContext = buildFieldColSpanContext;
|
|
8619
8659
|
exports.buildFields = buildFields;
|
|
8660
|
+
exports.buildWorkflowRowActions = buildWorkflowRowActions;
|
|
8620
8661
|
exports.checkboxField = checkboxField;
|
|
8621
8662
|
exports.computeSummaryValue = computeSummaryValue;
|
|
8622
8663
|
Object.defineProperty(exports, "createCrudEvents", {
|
|
@@ -8633,6 +8674,7 @@ exports.datetimeField = datetimeField;
|
|
|
8633
8674
|
exports.defineFieldContract = defineFieldContract;
|
|
8634
8675
|
exports.defineFields = defineFields;
|
|
8635
8676
|
exports.defineResource = defineResource;
|
|
8677
|
+
exports.embeddedLinesUrl = embeddedLinesUrl;
|
|
8636
8678
|
exports.entityField = entityField;
|
|
8637
8679
|
exports.enumField = enumField;
|
|
8638
8680
|
exports.fileField = fileField;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode, RefObject } from "react";
|
|
2
2
|
import { CoreHttpClient, DataGridEventNames, DataRecord, DataRecord as DataRecord$1, DialogEventNames, FormEventNames, GridData, GridData as GridData$1, createCrudEvents } from "@nubitio/core";
|
|
3
3
|
import { AppDropdownOption } from "@nubitio/ui";
|
|
4
|
+
import { WorkflowSchema } from "@nubitio/hydra";
|
|
4
5
|
|
|
5
6
|
//#region packages/crud/field/FieldType.d.ts
|
|
6
7
|
declare enum FieldType {
|
|
@@ -1013,6 +1014,15 @@ declare function defineResource<T extends DataRecord$1>(apiUrl: string, override
|
|
|
1013
1014
|
id?: string;
|
|
1014
1015
|
}): ResourceConfig<T>;
|
|
1015
1016
|
//#endregion
|
|
1017
|
+
//#region packages/crud/crud/embeddedLinesUrl.d.ts
|
|
1018
|
+
/**
|
|
1019
|
+
* Builds a formDetail reload URL for {@code #[EmbeddedLines]} line entities.
|
|
1020
|
+
*
|
|
1021
|
+
* @example embeddedLinesUrl('/api/sales_document_lines', 'document')
|
|
1022
|
+
* → '/api/sales_document_lines?document={id}'
|
|
1023
|
+
*/
|
|
1024
|
+
declare function embeddedLinesUrl(route: string, parentQueryParam: string): string;
|
|
1025
|
+
//#endregion
|
|
1016
1026
|
//#region packages/crud/crud/CrudPage.d.ts
|
|
1017
1027
|
interface CrudPageProps<T extends DataRecord$1 = DataRecord$1> {
|
|
1018
1028
|
resource: ResourceConfig<T>;
|
|
@@ -1867,6 +1877,9 @@ interface ColumnPresetState {
|
|
|
1867
1877
|
}
|
|
1868
1878
|
declare function useColumnPreset(resource: ResourceConfig): ColumnPresetState;
|
|
1869
1879
|
//#endregion
|
|
1880
|
+
//#region packages/crud/workflow/buildWorkflowRowActions.d.ts
|
|
1881
|
+
declare function buildWorkflowRowActions<T extends DataRecord$1 = DataRecord$1>(row: T, workflow: WorkflowSchema | undefined, apiUrl: string, roles: string[], onDone?: () => void): ResourceToolbarAction[];
|
|
1882
|
+
//#endregion
|
|
1870
1883
|
//#region packages/crud/adapter/HydraAdapter.d.ts
|
|
1871
1884
|
/**
|
|
1872
1885
|
* Default backend adapter for API Platform / JSON-LD + Hydra backends.
|
|
@@ -1905,6 +1918,7 @@ interface ResourceSchemaResolution {
|
|
|
1905
1918
|
* resource publishes one. Explicit `ResourceConfig.formLayout` wins.
|
|
1906
1919
|
*/
|
|
1907
1920
|
formLayout?: FormLayout;
|
|
1921
|
+
workflow?: WorkflowSchema;
|
|
1908
1922
|
}
|
|
1909
1923
|
interface ResourceSchemaResolver {
|
|
1910
1924
|
useResourceSchema(request: ResourceSchemaRequest): ResourceSchemaResolution;
|
|
@@ -1999,4 +2013,4 @@ interface RestQueryDialect {
|
|
|
1999
2013
|
*/
|
|
2000
2014
|
declare function createRestResourceStore(dialect?: RestQueryDialect): ResourceStoreFactory;
|
|
2001
2015
|
//#endregion
|
|
2002
|
-
export { type AuditEntry, type AuditFieldLabelResolver, type AuditTrailConfig, AuditTrailPanel, type AuditTrailPanelProps, type BackendAdapter, type BulkAction, type ColSpan, type ColumnPreset, ColumnPresetSelector, type ColumnPresetState, CrudDialogShell, CrudDrawerShell, type CrudDrawerSize, type CrudDrawerViewEvents, type CrudDrawerViewOptions, CrudFormShell, type CrudFormShellProps, CrudPage, CrudPageShell, type CrudPageViewEvents, type CrudPageViewOptions, type CrudViewMode, type CrudViewModeConfig, DATA_GRID_EVENTS, DEFAULT_DRAWER_SIZE, DEFAULT_DRAWER_WIDTH, DRAWER_WIDTHS, type DataGridSelectionChangedEvent, type DataGridSummaryItem, NativeDataGridView as DataGridView, type DataGridViewOptions, type DataRecord, type DetailSummaryOptions, CrudDialogView as DialogView, type DrawerSize, CrudDrawerView as DrawerView, type EnumOption, FORM_EVENTS, type Field, FieldBuilder, type FieldColSpanContext, type FieldDef, type FieldInput, type FieldOverride, FieldType, type FilterRule, type FormHandle, type FormLayout, type FormLayoutHint, type FormOnChangeFn, type FormPresentationContext, type FormPresentationMode, type FormSection, type FormTab, NativeFormView as FormView, type FormViewOptions, type FormatterFn, type GridCellContext, type GridData, type GridHandle, type GridOnChangeFn, HydraAdapter, type ItemFormatterFn, type LoadOption, type OnChangeFn, CrudPageView as PageView, type ResolvedViewMode, type ResourceConfig, type ResourceEmptyState, type ResourceFilterDescriptor, type ResourceFilterRule, type ResourceFormDetail, type ResourceGridDetail, type ResourceLoadOption, type ResourceLoadOptions, type ResourcePermissions, type ResourceRouting, type ResourceRowActions, ResourceSchemaProvider, type ResourceSchemaProviderProps, type ResourceSchemaResolution, type ResourceSchemaResolver, type ResourceSortDescriptor, type ResourceStore, type ResourceStoreFactory, type ResourceStoreOptions, ResourceStoreProvider, type ResourceStoreProviderProps, type ResourceToolbar, type ResourceToolbarAction, type ResourceToolbarActionVariant, type ResourceToolbarContext, type ResourceToolbarItems, RestAdapter, type RestQueryDialect, type SmartCrudFieldContract, type SmartCrudFieldOperation, type SmartCrudFieldPatch, type SmartCrudHydraFieldContract, type SmartCrudHydraFieldDirective, type SmartCrudManualField, type SmartCrudManualFieldContract, type SmartCrudOperation, SmartCrudPage, SmartCrudRolesProvider, type SummaryCalculateContext, type SummaryFormat, type SummaryItem, type SummaryTextContext, type SummaryType, ToolbarSelect, type ToolbarSelectOption, type ToolbarSelectProps, type ValidationRule, buildFieldColSpanContext, buildFields, checkboxField, computeSummaryValue, createCrudEvents, createRestResourceStore, crudRoute, currencyField, dateField, datetimeField, defineFieldContract, defineFields, defineResource, entityField, enumField, fileField, formatSummaryValue, identityField, imageField, isLongTextField, isShortField, noneField, numberField, parseDrawerWidthPx, passwordField, resolveDrawerLayoutBucket, resolveDrawerSize, resolveDrawerWidth, resolveFieldColSpan, resolveFieldsColSpans, resolveSummaryText, resolveViewMode, selectField, switchField, textField, textareaField, useColumnPreset, useResourceStoreFactory, useSmartCrudRoles, validateFieldContract };
|
|
2016
|
+
export { type AuditEntry, type AuditFieldLabelResolver, type AuditTrailConfig, AuditTrailPanel, type AuditTrailPanelProps, type BackendAdapter, type BulkAction, type ColSpan, type ColumnPreset, ColumnPresetSelector, type ColumnPresetState, CrudDialogShell, CrudDrawerShell, type CrudDrawerSize, type CrudDrawerViewEvents, type CrudDrawerViewOptions, CrudFormShell, type CrudFormShellProps, CrudPage, CrudPageShell, type CrudPageViewEvents, type CrudPageViewOptions, type CrudViewMode, type CrudViewModeConfig, DATA_GRID_EVENTS, DEFAULT_DRAWER_SIZE, DEFAULT_DRAWER_WIDTH, DRAWER_WIDTHS, type DataGridSelectionChangedEvent, type DataGridSummaryItem, NativeDataGridView as DataGridView, type DataGridViewOptions, type DataRecord, type DetailSummaryOptions, CrudDialogView as DialogView, type DrawerSize, CrudDrawerView as DrawerView, type EnumOption, FORM_EVENTS, type Field, FieldBuilder, type FieldColSpanContext, type FieldDef, type FieldInput, type FieldOverride, FieldType, type FilterRule, type FormHandle, type FormLayout, type FormLayoutHint, type FormOnChangeFn, type FormPresentationContext, type FormPresentationMode, type FormSection, type FormTab, NativeFormView as FormView, type FormViewOptions, type FormatterFn, type GridCellContext, type GridData, type GridHandle, type GridOnChangeFn, HydraAdapter, type ItemFormatterFn, type LoadOption, type OnChangeFn, CrudPageView as PageView, type ResolvedViewMode, type ResourceConfig, type ResourceEmptyState, type ResourceFilterDescriptor, type ResourceFilterRule, type ResourceFormDetail, type ResourceGridDetail, type ResourceLoadOption, type ResourceLoadOptions, type ResourcePermissions, type ResourceRouting, type ResourceRowActions, ResourceSchemaProvider, type ResourceSchemaProviderProps, type ResourceSchemaResolution, type ResourceSchemaResolver, type ResourceSortDescriptor, type ResourceStore, type ResourceStoreFactory, type ResourceStoreOptions, ResourceStoreProvider, type ResourceStoreProviderProps, type ResourceToolbar, type ResourceToolbarAction, type ResourceToolbarActionVariant, type ResourceToolbarContext, type ResourceToolbarItems, RestAdapter, type RestQueryDialect, type SmartCrudFieldContract, type SmartCrudFieldOperation, type SmartCrudFieldPatch, type SmartCrudHydraFieldContract, type SmartCrudHydraFieldDirective, type SmartCrudManualField, type SmartCrudManualFieldContract, type SmartCrudOperation, SmartCrudPage, SmartCrudRolesProvider, type SummaryCalculateContext, type SummaryFormat, type SummaryItem, type SummaryTextContext, type SummaryType, ToolbarSelect, type ToolbarSelectOption, type ToolbarSelectProps, type ValidationRule, buildFieldColSpanContext, buildFields, buildWorkflowRowActions, checkboxField, computeSummaryValue, createCrudEvents, createRestResourceStore, crudRoute, currencyField, dateField, datetimeField, defineFieldContract, defineFields, defineResource, embeddedLinesUrl, entityField, enumField, fileField, formatSummaryValue, identityField, imageField, isLongTextField, isShortField, noneField, numberField, parseDrawerWidthPx, passwordField, resolveDrawerLayoutBucket, resolveDrawerSize, resolveDrawerWidth, resolveFieldColSpan, resolveFieldsColSpans, resolveSummaryText, resolveViewMode, selectField, switchField, textField, textareaField, useColumnPreset, useResourceStoreFactory, useSmartCrudRoles, validateFieldContract };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode, RefObject } from "react";
|
|
2
2
|
import { AppDropdownOption } from "@nubitio/ui";
|
|
3
3
|
import { CoreHttpClient, DataGridEventNames, DataRecord, DataRecord as DataRecord$1, DialogEventNames, FormEventNames, GridData, GridData as GridData$1, createCrudEvents } from "@nubitio/core";
|
|
4
|
+
import { WorkflowSchema } from "@nubitio/hydra";
|
|
4
5
|
|
|
5
6
|
//#region packages/crud/field/FieldType.d.ts
|
|
6
7
|
declare enum FieldType {
|
|
@@ -1013,6 +1014,15 @@ declare function defineResource<T extends DataRecord$1>(apiUrl: string, override
|
|
|
1013
1014
|
id?: string;
|
|
1014
1015
|
}): ResourceConfig<T>;
|
|
1015
1016
|
//#endregion
|
|
1017
|
+
//#region packages/crud/crud/embeddedLinesUrl.d.ts
|
|
1018
|
+
/**
|
|
1019
|
+
* Builds a formDetail reload URL for {@code #[EmbeddedLines]} line entities.
|
|
1020
|
+
*
|
|
1021
|
+
* @example embeddedLinesUrl('/api/sales_document_lines', 'document')
|
|
1022
|
+
* → '/api/sales_document_lines?document={id}'
|
|
1023
|
+
*/
|
|
1024
|
+
declare function embeddedLinesUrl(route: string, parentQueryParam: string): string;
|
|
1025
|
+
//#endregion
|
|
1016
1026
|
//#region packages/crud/crud/CrudPage.d.ts
|
|
1017
1027
|
interface CrudPageProps<T extends DataRecord$1 = DataRecord$1> {
|
|
1018
1028
|
resource: ResourceConfig<T>;
|
|
@@ -1867,6 +1877,9 @@ interface ColumnPresetState {
|
|
|
1867
1877
|
}
|
|
1868
1878
|
declare function useColumnPreset(resource: ResourceConfig): ColumnPresetState;
|
|
1869
1879
|
//#endregion
|
|
1880
|
+
//#region packages/crud/workflow/buildWorkflowRowActions.d.ts
|
|
1881
|
+
declare function buildWorkflowRowActions<T extends DataRecord$1 = DataRecord$1>(row: T, workflow: WorkflowSchema | undefined, apiUrl: string, roles: string[], onDone?: () => void): ResourceToolbarAction[];
|
|
1882
|
+
//#endregion
|
|
1870
1883
|
//#region packages/crud/adapter/HydraAdapter.d.ts
|
|
1871
1884
|
/**
|
|
1872
1885
|
* Default backend adapter for API Platform / JSON-LD + Hydra backends.
|
|
@@ -1905,6 +1918,7 @@ interface ResourceSchemaResolution {
|
|
|
1905
1918
|
* resource publishes one. Explicit `ResourceConfig.formLayout` wins.
|
|
1906
1919
|
*/
|
|
1907
1920
|
formLayout?: FormLayout;
|
|
1921
|
+
workflow?: WorkflowSchema;
|
|
1908
1922
|
}
|
|
1909
1923
|
interface ResourceSchemaResolver {
|
|
1910
1924
|
useResourceSchema(request: ResourceSchemaRequest): ResourceSchemaResolution;
|
|
@@ -1999,4 +2013,4 @@ interface RestQueryDialect {
|
|
|
1999
2013
|
*/
|
|
2000
2014
|
declare function createRestResourceStore(dialect?: RestQueryDialect): ResourceStoreFactory;
|
|
2001
2015
|
//#endregion
|
|
2002
|
-
export { type AuditEntry, type AuditFieldLabelResolver, type AuditTrailConfig, AuditTrailPanel, type AuditTrailPanelProps, type BackendAdapter, type BulkAction, type ColSpan, type ColumnPreset, ColumnPresetSelector, type ColumnPresetState, CrudDialogShell, CrudDrawerShell, type CrudDrawerSize, type CrudDrawerViewEvents, type CrudDrawerViewOptions, CrudFormShell, type CrudFormShellProps, CrudPage, CrudPageShell, type CrudPageViewEvents, type CrudPageViewOptions, type CrudViewMode, type CrudViewModeConfig, DATA_GRID_EVENTS, DEFAULT_DRAWER_SIZE, DEFAULT_DRAWER_WIDTH, DRAWER_WIDTHS, type DataGridSelectionChangedEvent, type DataGridSummaryItem, NativeDataGridView as DataGridView, type DataGridViewOptions, type DataRecord, type DetailSummaryOptions, CrudDialogView as DialogView, type DrawerSize, CrudDrawerView as DrawerView, type EnumOption, FORM_EVENTS, type Field, FieldBuilder, type FieldColSpanContext, type FieldDef, type FieldInput, type FieldOverride, FieldType, type FilterRule, type FormHandle, type FormLayout, type FormLayoutHint, type FormOnChangeFn, type FormPresentationContext, type FormPresentationMode, type FormSection, type FormTab, NativeFormView as FormView, type FormViewOptions, type FormatterFn, type GridCellContext, type GridData, type GridHandle, type GridOnChangeFn, HydraAdapter, type ItemFormatterFn, type LoadOption, type OnChangeFn, CrudPageView as PageView, type ResolvedViewMode, type ResourceConfig, type ResourceEmptyState, type ResourceFilterDescriptor, type ResourceFilterRule, type ResourceFormDetail, type ResourceGridDetail, type ResourceLoadOption, type ResourceLoadOptions, type ResourcePermissions, type ResourceRouting, type ResourceRowActions, ResourceSchemaProvider, type ResourceSchemaProviderProps, type ResourceSchemaResolution, type ResourceSchemaResolver, type ResourceSortDescriptor, type ResourceStore, type ResourceStoreFactory, type ResourceStoreOptions, ResourceStoreProvider, type ResourceStoreProviderProps, type ResourceToolbar, type ResourceToolbarAction, type ResourceToolbarActionVariant, type ResourceToolbarContext, type ResourceToolbarItems, RestAdapter, type RestQueryDialect, type SmartCrudFieldContract, type SmartCrudFieldOperation, type SmartCrudFieldPatch, type SmartCrudHydraFieldContract, type SmartCrudHydraFieldDirective, type SmartCrudManualField, type SmartCrudManualFieldContract, type SmartCrudOperation, SmartCrudPage, SmartCrudRolesProvider, type SummaryCalculateContext, type SummaryFormat, type SummaryItem, type SummaryTextContext, type SummaryType, ToolbarSelect, type ToolbarSelectOption, type ToolbarSelectProps, type ValidationRule, buildFieldColSpanContext, buildFields, checkboxField, computeSummaryValue, createCrudEvents, createRestResourceStore, crudRoute, currencyField, dateField, datetimeField, defineFieldContract, defineFields, defineResource, entityField, enumField, fileField, formatSummaryValue, identityField, imageField, isLongTextField, isShortField, noneField, numberField, parseDrawerWidthPx, passwordField, resolveDrawerLayoutBucket, resolveDrawerSize, resolveDrawerWidth, resolveFieldColSpan, resolveFieldsColSpans, resolveSummaryText, resolveViewMode, selectField, switchField, textField, textareaField, useColumnPreset, useResourceStoreFactory, useSmartCrudRoles, validateFieldContract };
|
|
2016
|
+
export { type AuditEntry, type AuditFieldLabelResolver, type AuditTrailConfig, AuditTrailPanel, type AuditTrailPanelProps, type BackendAdapter, type BulkAction, type ColSpan, type ColumnPreset, ColumnPresetSelector, type ColumnPresetState, CrudDialogShell, CrudDrawerShell, type CrudDrawerSize, type CrudDrawerViewEvents, type CrudDrawerViewOptions, CrudFormShell, type CrudFormShellProps, CrudPage, CrudPageShell, type CrudPageViewEvents, type CrudPageViewOptions, type CrudViewMode, type CrudViewModeConfig, DATA_GRID_EVENTS, DEFAULT_DRAWER_SIZE, DEFAULT_DRAWER_WIDTH, DRAWER_WIDTHS, type DataGridSelectionChangedEvent, type DataGridSummaryItem, NativeDataGridView as DataGridView, type DataGridViewOptions, type DataRecord, type DetailSummaryOptions, CrudDialogView as DialogView, type DrawerSize, CrudDrawerView as DrawerView, type EnumOption, FORM_EVENTS, type Field, FieldBuilder, type FieldColSpanContext, type FieldDef, type FieldInput, type FieldOverride, FieldType, type FilterRule, type FormHandle, type FormLayout, type FormLayoutHint, type FormOnChangeFn, type FormPresentationContext, type FormPresentationMode, type FormSection, type FormTab, NativeFormView as FormView, type FormViewOptions, type FormatterFn, type GridCellContext, type GridData, type GridHandle, type GridOnChangeFn, HydraAdapter, type ItemFormatterFn, type LoadOption, type OnChangeFn, CrudPageView as PageView, type ResolvedViewMode, type ResourceConfig, type ResourceEmptyState, type ResourceFilterDescriptor, type ResourceFilterRule, type ResourceFormDetail, type ResourceGridDetail, type ResourceLoadOption, type ResourceLoadOptions, type ResourcePermissions, type ResourceRouting, type ResourceRowActions, ResourceSchemaProvider, type ResourceSchemaProviderProps, type ResourceSchemaResolution, type ResourceSchemaResolver, type ResourceSortDescriptor, type ResourceStore, type ResourceStoreFactory, type ResourceStoreOptions, ResourceStoreProvider, type ResourceStoreProviderProps, type ResourceToolbar, type ResourceToolbarAction, type ResourceToolbarActionVariant, type ResourceToolbarContext, type ResourceToolbarItems, RestAdapter, type RestQueryDialect, type SmartCrudFieldContract, type SmartCrudFieldOperation, type SmartCrudFieldPatch, type SmartCrudHydraFieldContract, type SmartCrudHydraFieldDirective, type SmartCrudManualField, type SmartCrudManualFieldContract, type SmartCrudOperation, SmartCrudPage, SmartCrudRolesProvider, type SummaryCalculateContext, type SummaryFormat, type SummaryItem, type SummaryTextContext, type SummaryType, ToolbarSelect, type ToolbarSelectOption, type ToolbarSelectProps, type ValidationRule, buildFieldColSpanContext, buildFields, buildWorkflowRowActions, checkboxField, computeSummaryValue, createCrudEvents, createRestResourceStore, crudRoute, currencyField, dateField, datetimeField, defineFieldContract, defineFields, defineResource, embeddedLinesUrl, entityField, enumField, fileField, formatSummaryValue, identityField, imageField, isLongTextField, isShortField, noneField, numberField, parseDrawerWidthPx, passwordField, resolveDrawerLayoutBucket, resolveDrawerSize, resolveDrawerWidth, resolveFieldColSpan, resolveFieldsColSpans, resolveSummaryText, resolveViewMode, selectField, switchField, textField, textareaField, useColumnPreset, useResourceStoreFactory, useSmartCrudRoles, validateFieldContract };
|
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,17 @@ function defineResource(apiUrl, overrides) {
|
|
|
38
38
|
return resource;
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
|
+
//#region packages/crud/crud/embeddedLinesUrl.ts
|
|
42
|
+
/**
|
|
43
|
+
* Builds a formDetail reload URL for {@code #[EmbeddedLines]} line entities.
|
|
44
|
+
*
|
|
45
|
+
* @example embeddedLinesUrl('/api/sales_document_lines', 'document')
|
|
46
|
+
* → '/api/sales_document_lines?document={id}'
|
|
47
|
+
*/
|
|
48
|
+
function embeddedLinesUrl(route, parentQueryParam) {
|
|
49
|
+
return `${route}${route.includes("?") ? "&" : "?"}${parentQueryParam}={id}`;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
41
52
|
//#region packages/crud/datagrid/DataGridEvents.ts
|
|
42
53
|
const DATA_GRID_EVENTS = {
|
|
43
54
|
SELECTION_CHANGED: "datagrid:selection.changed",
|
|
@@ -3564,6 +3575,17 @@ function normalizeEntityField(row, field, adapter, prependDataByField) {
|
|
|
3564
3575
|
}
|
|
3565
3576
|
}
|
|
3566
3577
|
//#endregion
|
|
3578
|
+
//#region packages/crud/form/loadDetailRows.ts
|
|
3579
|
+
/**
|
|
3580
|
+
* Loads embedded line rows for formDetail edit mode. Accepts both plain JSON
|
|
3581
|
+
* arrays (nubit embedded-lines endpoint) and Hydra collections.
|
|
3582
|
+
*/
|
|
3583
|
+
async function loadDetailRows(httpClient, detailUrl, adapter) {
|
|
3584
|
+
const response = await httpClient.get(detailUrl);
|
|
3585
|
+
const { items } = (adapter ?? HydraAdapter).parseListResponse(response.data);
|
|
3586
|
+
return items;
|
|
3587
|
+
}
|
|
3588
|
+
//#endregion
|
|
3567
3589
|
//#region packages/crud/form/safeRandomId.ts
|
|
3568
3590
|
/**
|
|
3569
3591
|
* Generate a unique-enough id string for internal React keys.
|
|
@@ -4624,7 +4646,7 @@ const NativeFormView = forwardRef((options, ref) => {
|
|
|
4624
4646
|
const detailUrl = typeof detailId === "string" || typeof detailId === "number" ? options.detailUrl?.replace("{id}", String(detailId)) : void 0;
|
|
4625
4647
|
if (!detailUrl) return;
|
|
4626
4648
|
emit(FORM_EVENTS.LOADING, true);
|
|
4627
|
-
httpClient.
|
|
4649
|
+
loadDetailRows(httpClient, detailUrl, options.adapter).then((rows) => setNextDetailRows(rows)).finally(() => emit(FORM_EVENTS.LOADING, false));
|
|
4628
4650
|
}, [
|
|
4629
4651
|
captureExistingMedia,
|
|
4630
4652
|
emit,
|
|
@@ -8414,6 +8436,24 @@ function ToolbarSelect({ id, label, icon = "ph-funnel", value, options, onChange
|
|
|
8414
8436
|
});
|
|
8415
8437
|
}
|
|
8416
8438
|
//#endregion
|
|
8439
|
+
//#region packages/crud/workflow/buildWorkflowRowActions.ts
|
|
8440
|
+
function buildWorkflowRowActions(row, workflow, apiUrl, roles, onDone) {
|
|
8441
|
+
if (!workflow) return [];
|
|
8442
|
+
const current = String(row[workflow.field] ?? "");
|
|
8443
|
+
return workflow.transitions.filter((transition) => transition.from.includes(current)).filter((transition) => !transition.roles?.length || transition.roles.some((role) => roles.includes(role))).map((transition) => ({
|
|
8444
|
+
text: transition.label ?? transition.name,
|
|
8445
|
+
onClick: async () => {
|
|
8446
|
+
const base = apiUrl.replace(/\/$/, "");
|
|
8447
|
+
const id = row.id;
|
|
8448
|
+
await fetch(`${base}/${id}/transition/${transition.name}`, {
|
|
8449
|
+
method: "POST",
|
|
8450
|
+
credentials: "include"
|
|
8451
|
+
});
|
|
8452
|
+
onDone?.();
|
|
8453
|
+
}
|
|
8454
|
+
}));
|
|
8455
|
+
}
|
|
8456
|
+
//#endregion
|
|
8417
8457
|
//#region packages/crud/adapter/RestAdapter.ts
|
|
8418
8458
|
/**
|
|
8419
8459
|
* Backend adapter for plain OpenAPI / REST backends.
|
|
@@ -8565,4 +8605,4 @@ function createRestResourceStore(dialect = {}) {
|
|
|
8565
8605
|
};
|
|
8566
8606
|
}
|
|
8567
8607
|
//#endregion
|
|
8568
|
-
export { AuditTrailPanel, ColumnPresetSelector, CrudDialogShell, CrudDrawerShell, CrudFormShell, CrudPage, CrudPageShell, DATA_GRID_EVENTS, DEFAULT_DRAWER_SIZE, DEFAULT_DRAWER_WIDTH, DRAWER_WIDTHS, NativeDataGridView as DataGridView, CrudDialogView as DialogView, CrudDrawerView as DrawerView, FORM_EVENTS, FieldBuilder, FieldType, NativeFormView as FormView, HydraAdapter, CrudPageView as PageView, ResourceSchemaProvider, ResourceStoreProvider, RestAdapter, SmartCrudPage, SmartCrudRolesProvider, ToolbarSelect, buildFieldColSpanContext, buildFields, checkboxField, computeSummaryValue, createCrudEvents, createRestResourceStore, crudRoute, currencyField, dateField, datetimeField, defineFieldContract, defineFields, defineResource, entityField, enumField, fileField, formatSummaryValue, identityField, imageField, isLongTextField, isShortField, noneField, numberField, parseDrawerWidthPx, passwordField, resolveDrawerLayoutBucket, resolveDrawerSize, resolveDrawerWidth, resolveFieldColSpan, resolveFieldsColSpans, resolveSummaryText, resolveViewMode, selectField, switchField, textField, textareaField, useColumnPreset, useResourceStoreFactory, useSmartCrudRoles, validateFieldContract };
|
|
8608
|
+
export { AuditTrailPanel, ColumnPresetSelector, CrudDialogShell, CrudDrawerShell, CrudFormShell, CrudPage, CrudPageShell, DATA_GRID_EVENTS, DEFAULT_DRAWER_SIZE, DEFAULT_DRAWER_WIDTH, DRAWER_WIDTHS, NativeDataGridView as DataGridView, CrudDialogView as DialogView, CrudDrawerView as DrawerView, FORM_EVENTS, FieldBuilder, FieldType, NativeFormView as FormView, HydraAdapter, CrudPageView as PageView, ResourceSchemaProvider, ResourceStoreProvider, RestAdapter, SmartCrudPage, SmartCrudRolesProvider, ToolbarSelect, buildFieldColSpanContext, buildFields, buildWorkflowRowActions, checkboxField, computeSummaryValue, createCrudEvents, createRestResourceStore, crudRoute, currencyField, dateField, datetimeField, defineFieldContract, defineFields, defineResource, embeddedLinesUrl, entityField, enumField, fileField, formatSummaryValue, identityField, imageField, isLongTextField, isShortField, noneField, numberField, parseDrawerWidthPx, passwordField, resolveDrawerLayoutBucket, resolveDrawerSize, resolveDrawerWidth, resolveFieldColSpan, resolveFieldsColSpans, resolveSummaryText, resolveViewMode, selectField, switchField, textField, textareaField, useColumnPreset, useResourceStoreFactory, useSmartCrudRoles, validateFieldContract };
|
package/dist/style.css
CHANGED
|
@@ -617,7 +617,7 @@
|
|
|
617
617
|
font-size: var(--font-size-xs);
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
-
.nb-datagrid__filter-operator {
|
|
620
|
+
.nb-datagrid__filter-wrap > .nb-datagrid__filter-operator {
|
|
621
621
|
left: 5px;
|
|
622
622
|
position: absolute;
|
|
623
623
|
top: 50%;
|
|
@@ -625,7 +625,7 @@
|
|
|
625
625
|
width: 30px;
|
|
626
626
|
z-index: 2;
|
|
627
627
|
}
|
|
628
|
-
.nb-datagrid__filter-operator.nb-dropdown .nb-dropdown__trigger {
|
|
628
|
+
.nb-datagrid__filter-wrap > .nb-datagrid__filter-operator.nb-dropdown .nb-dropdown__trigger {
|
|
629
629
|
appearance: none;
|
|
630
630
|
background: color-mix(in srgb, var(--accent-color) 10%, transparent);
|
|
631
631
|
border: 1px solid color-mix(in srgb, var(--accent-color) 20%, transparent);
|
|
@@ -641,7 +641,7 @@
|
|
|
641
641
|
text-align: center;
|
|
642
642
|
width: 30px;
|
|
643
643
|
}
|
|
644
|
-
.nb-datagrid__filter-operator.nb-dropdown .nb-dropdown__caret {
|
|
644
|
+
.nb-datagrid__filter-wrap > .nb-datagrid__filter-operator.nb-dropdown .nb-dropdown__caret {
|
|
645
645
|
display: none;
|
|
646
646
|
}
|
|
647
647
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubitio/crud",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Declarative CRUD engine with field DSL, forms, datagrids, RBAC, conditional logic and pluggable adapters (Hydra/REST).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-dom": "^19.0.0",
|
|
57
57
|
"react-i18next": "^14.0.0",
|
|
58
58
|
"react-router-dom": "^6.0.0",
|
|
59
|
-
"@nubitio/core": "^0.5.
|
|
60
|
-
"@nubitio/ui": "^0.5.
|
|
59
|
+
"@nubitio/core": "^0.5.19",
|
|
60
|
+
"@nubitio/ui": "^0.5.19"
|
|
61
61
|
}
|
|
62
62
|
}
|