@praxisui/core 3.0.0-beta.0 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/praxisui-core.mjs +157 -1
- package/fesm2022/praxisui-core.mjs.map +1 -1
- package/index.d.ts +140 -1
- package/package.json +1 -1
|
@@ -308,6 +308,9 @@ const FieldControlType = {
|
|
|
308
308
|
INLINE_MULTISELECT: 'inlineMultiSelect',
|
|
309
309
|
INLINE_TOGGLE: 'inlineToggle',
|
|
310
310
|
INLINE_RANGE: 'inlineRange',
|
|
311
|
+
INLINE_PERIOD_RANGE: 'inlinePeriodRange',
|
|
312
|
+
INLINE_YEAR_RANGE: 'inlineYearRange',
|
|
313
|
+
INLINE_MONTH_RANGE: 'inlineMonthRange',
|
|
311
314
|
INLINE_DATE: 'inlineDate',
|
|
312
315
|
INLINE_DATE_RANGE: 'inlineDateRange',
|
|
313
316
|
INLINE_TIME: 'inlineTime',
|
|
@@ -394,6 +397,9 @@ const INLINE_FILTER_CONTROL_TYPES = Object.freeze({
|
|
|
394
397
|
INPUT: FieldControlType.INLINE_INPUT,
|
|
395
398
|
TOGGLE: FieldControlType.INLINE_TOGGLE,
|
|
396
399
|
RANGE: FieldControlType.INLINE_RANGE,
|
|
400
|
+
PERIOD_RANGE: FieldControlType.INLINE_PERIOD_RANGE,
|
|
401
|
+
YEAR_RANGE: FieldControlType.INLINE_YEAR_RANGE,
|
|
402
|
+
MONTH_RANGE: FieldControlType.INLINE_MONTH_RANGE,
|
|
397
403
|
DATE: FieldControlType.INLINE_DATE,
|
|
398
404
|
DATE_RANGE: FieldControlType.INLINE_DATE_RANGE,
|
|
399
405
|
TIME: FieldControlType.INLINE_TIME,
|
|
@@ -428,6 +434,9 @@ const INLINE_FILTER_TOKEN_TO_CONTROL_TYPE_MAP = {
|
|
|
428
434
|
inlineinput: INLINE_FILTER_CONTROL_TYPES.INPUT,
|
|
429
435
|
inlinetoggle: INLINE_FILTER_CONTROL_TYPES.TOGGLE,
|
|
430
436
|
inlinerange: INLINE_FILTER_CONTROL_TYPES.RANGE,
|
|
437
|
+
inlineperiodrange: INLINE_FILTER_CONTROL_TYPES.PERIOD_RANGE,
|
|
438
|
+
inlineyearrange: INLINE_FILTER_CONTROL_TYPES.YEAR_RANGE,
|
|
439
|
+
inlinemonthrange: INLINE_FILTER_CONTROL_TYPES.MONTH_RANGE,
|
|
431
440
|
inlinedate: INLINE_FILTER_CONTROL_TYPES.DATE,
|
|
432
441
|
inlinedaterange: INLINE_FILTER_CONTROL_TYPES.DATE_RANGE,
|
|
433
442
|
inlinetime: INLINE_FILTER_CONTROL_TYPES.TIME,
|
|
@@ -456,6 +465,9 @@ const INLINE_FILTER_TOKEN_TO_BASE_CONTROL_TYPE_MAP = {
|
|
|
456
465
|
inlineinput: FieldControlType.INPUT,
|
|
457
466
|
inlinetoggle: FieldControlType.TOGGLE,
|
|
458
467
|
inlinerange: FieldControlType.RANGE_SLIDER,
|
|
468
|
+
inlineperiodrange: FieldControlType.RANGE_SLIDER,
|
|
469
|
+
inlineyearrange: FieldControlType.YEAR_INPUT,
|
|
470
|
+
inlinemonthrange: FieldControlType.MONTH_INPUT,
|
|
459
471
|
inlinedate: FieldControlType.DATE_PICKER,
|
|
460
472
|
inlinedaterange: FieldControlType.DATE_RANGE,
|
|
461
473
|
inlinetime: FieldControlType.TIME_PICKER,
|
|
@@ -635,6 +647,50 @@ class SchemaNormalizerService {
|
|
|
635
647
|
return { key: String(opt), value: String(opt) };
|
|
636
648
|
});
|
|
637
649
|
}
|
|
650
|
+
parseOptionSource(value) {
|
|
651
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
652
|
+
return undefined;
|
|
653
|
+
}
|
|
654
|
+
const optionSource = {
|
|
655
|
+
key: String(value.key ?? '').trim(),
|
|
656
|
+
};
|
|
657
|
+
if (!optionSource.key) {
|
|
658
|
+
return undefined;
|
|
659
|
+
}
|
|
660
|
+
if (value.type !== undefined)
|
|
661
|
+
optionSource.type = String(value.type);
|
|
662
|
+
if (value.resourcePath !== undefined) {
|
|
663
|
+
optionSource.resourcePath = String(value.resourcePath);
|
|
664
|
+
}
|
|
665
|
+
if (value.filterField !== undefined) {
|
|
666
|
+
optionSource.filterField = String(value.filterField);
|
|
667
|
+
}
|
|
668
|
+
if (value.propertyPath !== undefined) {
|
|
669
|
+
optionSource.propertyPath = String(value.propertyPath);
|
|
670
|
+
}
|
|
671
|
+
if (value.labelPropertyPath !== undefined) {
|
|
672
|
+
optionSource.labelPropertyPath = String(value.labelPropertyPath);
|
|
673
|
+
}
|
|
674
|
+
if (value.valuePropertyPath !== undefined) {
|
|
675
|
+
optionSource.valuePropertyPath = String(value.valuePropertyPath);
|
|
676
|
+
}
|
|
677
|
+
if (value.dependsOn !== undefined) {
|
|
678
|
+
optionSource.dependsOn = this.parseStringArray(value.dependsOn);
|
|
679
|
+
}
|
|
680
|
+
if (value.excludeSelfField !== undefined) {
|
|
681
|
+
optionSource.excludeSelfField = this.parseBoolean(value.excludeSelfField);
|
|
682
|
+
}
|
|
683
|
+
if (value.searchMode !== undefined) {
|
|
684
|
+
optionSource.searchMode = String(value.searchMode);
|
|
685
|
+
}
|
|
686
|
+
if (value.pageSize !== undefined && !Number.isNaN(Number(value.pageSize))) {
|
|
687
|
+
optionSource.pageSize = Number(value.pageSize);
|
|
688
|
+
}
|
|
689
|
+
if (value.includeIds !== undefined) {
|
|
690
|
+
optionSource.includeIds = this.parseBoolean(value.includeIds);
|
|
691
|
+
}
|
|
692
|
+
return optionSource;
|
|
693
|
+
}
|
|
638
694
|
/**
|
|
639
695
|
* Converte string/Function em função real.
|
|
640
696
|
* Atenção: usa `new Function` para avaliar strings – requer backend confiável.
|
|
@@ -1060,12 +1116,21 @@ class SchemaNormalizerService {
|
|
|
1060
1116
|
if (ui.endpoint !== undefined) {
|
|
1061
1117
|
field.endpoint = ui.endpoint;
|
|
1062
1118
|
}
|
|
1119
|
+
if (ui.resourcePath !== undefined) {
|
|
1120
|
+
field.resourcePath = ui.resourcePath;
|
|
1121
|
+
}
|
|
1122
|
+
if (ui.optionSource !== undefined) {
|
|
1123
|
+
field.optionSource = this.parseOptionSource(ui.optionSource);
|
|
1124
|
+
}
|
|
1063
1125
|
if (ui.valueField !== undefined) {
|
|
1064
1126
|
field.valueField = ui.valueField;
|
|
1065
1127
|
}
|
|
1066
1128
|
if (ui.displayField !== undefined) {
|
|
1067
1129
|
field.displayField = ui.displayField;
|
|
1068
1130
|
}
|
|
1131
|
+
if (ui.filterField !== undefined) {
|
|
1132
|
+
field.filterField = ui.filterField;
|
|
1133
|
+
}
|
|
1069
1134
|
if (ui.multiple !== undefined) {
|
|
1070
1135
|
field.multiple = this.parseBoolean(ui.multiple);
|
|
1071
1136
|
}
|
|
@@ -2743,6 +2808,45 @@ class GenericCrudService {
|
|
|
2743
2808
|
return version ? { ...body, dataVersion: version } : body;
|
|
2744
2809
|
}), catchError(this.handleError));
|
|
2745
2810
|
}
|
|
2811
|
+
/** OPTION SOURCES: POST /option-sources/{sourceKey}/options/filter */
|
|
2812
|
+
filterOptionSourceOptions(sourceKey, criteria, pageable, opts) {
|
|
2813
|
+
let params = new HttpParams()
|
|
2814
|
+
.set('page', pageable.pageNumber)
|
|
2815
|
+
.set('size', pageable.pageSize);
|
|
2816
|
+
pageable.sort?.forEach((s) => (params = params.append('sort', s)));
|
|
2817
|
+
opts?.includeIds?.forEach((id) => {
|
|
2818
|
+
params = params.append('includeIds', String(id));
|
|
2819
|
+
});
|
|
2820
|
+
if (opts?.search) {
|
|
2821
|
+
params = params.set('search', opts.search);
|
|
2822
|
+
}
|
|
2823
|
+
this.ensureConfigured();
|
|
2824
|
+
const entry = this.resolveEndpointEntry(opts?.endpointKey);
|
|
2825
|
+
const base = `${this.getResourceBaseUrl(opts)}/option-sources/${encodeURIComponent(sourceKey)}/options`;
|
|
2826
|
+
const url = `${base}/filter`;
|
|
2827
|
+
const normalizedCriteria = this.normalizeRangeCriteria(criteria);
|
|
2828
|
+
const observeVersion = !!opts?.observeVersionHeader;
|
|
2829
|
+
const req$ = observeVersion
|
|
2830
|
+
? this.http.post(url, normalizedCriteria, {
|
|
2831
|
+
params,
|
|
2832
|
+
observe: 'response',
|
|
2833
|
+
headers: composeHeadersWithVersion(entry),
|
|
2834
|
+
context: opts?.httpContext,
|
|
2835
|
+
})
|
|
2836
|
+
: this.http.post(url, normalizedCriteria, {
|
|
2837
|
+
params,
|
|
2838
|
+
headers: composeHeadersWithVersion(entry),
|
|
2839
|
+
context: opts?.httpContext,
|
|
2840
|
+
});
|
|
2841
|
+
if (!observeVersion) {
|
|
2842
|
+
return req$.pipe(catchError(this.handleError));
|
|
2843
|
+
}
|
|
2844
|
+
return req$.pipe(map((resp) => {
|
|
2845
|
+
const body = resp.body;
|
|
2846
|
+
const version = resp.headers.get('X-Data-Version') || undefined;
|
|
2847
|
+
return version ? { ...body, dataVersion: version } : body;
|
|
2848
|
+
}), catchError(this.handleError));
|
|
2849
|
+
}
|
|
2746
2850
|
/** OPTIONS: GET /options/by-ids */
|
|
2747
2851
|
getOptionsByIds(ids, options) {
|
|
2748
2852
|
if (!ids?.length)
|
|
@@ -2761,6 +2865,24 @@ class GenericCrudService {
|
|
|
2761
2865
|
})
|
|
2762
2866
|
.pipe(catchError(this.handleError));
|
|
2763
2867
|
}
|
|
2868
|
+
/** OPTION SOURCES: GET /option-sources/{sourceKey}/options/by-ids */
|
|
2869
|
+
getOptionSourceOptionsByIds(sourceKey, ids, options) {
|
|
2870
|
+
if (!ids?.length)
|
|
2871
|
+
return of([]);
|
|
2872
|
+
let params = new HttpParams();
|
|
2873
|
+
ids.forEach((id) => (params = params.append('ids', String(id))));
|
|
2874
|
+
this.ensureConfigured();
|
|
2875
|
+
const entry = this.resolveEndpointEntry(options?.endpointKey);
|
|
2876
|
+
const base = `${this.getResourceBaseUrl(options)}/option-sources/${encodeURIComponent(sourceKey)}/options`;
|
|
2877
|
+
const url = `${base}/by-ids`;
|
|
2878
|
+
return this.http
|
|
2879
|
+
.get(url, {
|
|
2880
|
+
params,
|
|
2881
|
+
headers: composeHeadersWithVersion(entry),
|
|
2882
|
+
context: options?.httpContext,
|
|
2883
|
+
})
|
|
2884
|
+
.pipe(catchError(this.handleError));
|
|
2885
|
+
}
|
|
2764
2886
|
/** CURSOR: POST /filter/cursor */
|
|
2765
2887
|
filterByCursor(criteria, cursorReq = {}, options) {
|
|
2766
2888
|
let params = new HttpParams();
|
|
@@ -9636,6 +9758,16 @@ const RULE_PROPERTY_SCHEMA = {
|
|
|
9636
9758
|
{ value: 'none', label: 'Nada' },
|
|
9637
9759
|
],
|
|
9638
9760
|
},
|
|
9761
|
+
{
|
|
9762
|
+
name: 'sectionHeader.size',
|
|
9763
|
+
type: 'enum',
|
|
9764
|
+
label: 'Tamanho do avatar',
|
|
9765
|
+
enumValues: [
|
|
9766
|
+
{ value: 'sm', label: 'Pequeno' },
|
|
9767
|
+
{ value: 'md', label: 'Médio' },
|
|
9768
|
+
{ value: 'lg', label: 'Grande' },
|
|
9769
|
+
],
|
|
9770
|
+
},
|
|
9639
9771
|
{ name: 'sectionHeader.initialsMaxLength', type: 'number', label: 'Máximo de iniciais' },
|
|
9640
9772
|
{ name: 'className', type: 'string', label: 'Classe CSS' },
|
|
9641
9773
|
{ name: 'style', type: 'object', label: 'Estilos inline' },
|
|
@@ -10971,6 +11103,19 @@ function normalizeEndpoint(path) {
|
|
|
10971
11103
|
// Remove leading slashes and any duplicated `api` segments
|
|
10972
11104
|
return path.replace(/^\/+/, '').replace(/^(?:api\/)+/, '');
|
|
10973
11105
|
}
|
|
11106
|
+
function normalizeOptionSource(optionSource) {
|
|
11107
|
+
if (!optionSource?.key) {
|
|
11108
|
+
return undefined;
|
|
11109
|
+
}
|
|
11110
|
+
const dependsOn = Array.isArray(optionSource.dependsOn)
|
|
11111
|
+
? optionSource.dependsOn.filter((value) => typeof value === 'string' && value.trim().length > 0)
|
|
11112
|
+
: undefined;
|
|
11113
|
+
return {
|
|
11114
|
+
...optionSource,
|
|
11115
|
+
resourcePath: normalizeEndpoint(optionSource.resourcePath),
|
|
11116
|
+
dependsOn: dependsOn?.length ? dependsOn : undefined,
|
|
11117
|
+
};
|
|
11118
|
+
}
|
|
10974
11119
|
/**
|
|
10975
11120
|
* Converte um FieldDefinition em FieldMetadata.
|
|
10976
11121
|
*
|
|
@@ -11024,6 +11169,7 @@ function mapFieldDefinitionToMetadata(field) {
|
|
|
11024
11169
|
'iconClass',
|
|
11025
11170
|
'iconStyle',
|
|
11026
11171
|
'iconFontSize',
|
|
11172
|
+
'filterField',
|
|
11027
11173
|
];
|
|
11028
11174
|
for (const prop of simpleProps) {
|
|
11029
11175
|
const value = field[prop];
|
|
@@ -11031,7 +11177,11 @@ function mapFieldDefinitionToMetadata(field) {
|
|
|
11031
11177
|
metadata[prop] = value;
|
|
11032
11178
|
}
|
|
11033
11179
|
}
|
|
11034
|
-
const
|
|
11180
|
+
const normalizedOptionSource = normalizeOptionSource(field.optionSource);
|
|
11181
|
+
if (normalizedOptionSource) {
|
|
11182
|
+
metadata.optionSource = normalizedOptionSource;
|
|
11183
|
+
}
|
|
11184
|
+
const endpointPath = normalizeEndpoint(normalizedOptionSource?.resourcePath ?? field.resourcePath ?? field.endpoint);
|
|
11035
11185
|
if (endpointPath) {
|
|
11036
11186
|
// Canonicalize: only expose resourcePath; do not write legacy alias
|
|
11037
11187
|
metadata.resourcePath = endpointPath;
|
|
@@ -11073,9 +11223,15 @@ function mapFieldDefinitionToMetadata(field) {
|
|
|
11073
11223
|
if (field.displayField) {
|
|
11074
11224
|
metadata.optionLabelKey = field.displayField;
|
|
11075
11225
|
}
|
|
11226
|
+
else if (normalizedOptionSource) {
|
|
11227
|
+
metadata.optionLabelKey = 'label';
|
|
11228
|
+
}
|
|
11076
11229
|
if (field.valueField) {
|
|
11077
11230
|
metadata.optionValueKey = field.valueField;
|
|
11078
11231
|
}
|
|
11232
|
+
else if (normalizedOptionSource) {
|
|
11233
|
+
metadata.optionValueKey = 'id';
|
|
11234
|
+
}
|
|
11079
11235
|
if (field.filter) {
|
|
11080
11236
|
metadata.filterCriteria = field.filter;
|
|
11081
11237
|
}
|