@fuentis/phoenix-ui 0.0.9-alpha.630 → 0.0.9-alpha.632

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.
@@ -8142,12 +8142,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
8142
8142
 
8143
8143
  class QuickPickSidePanelComponent {
8144
8144
  drawer;
8145
- title = 'Default Title';
8146
- data = [];
8147
- columns = [];
8148
- tableConfiguration = {};
8149
- widthClass = 'w-6';
8150
- isFullScreen = false;
8145
+ title = input('Default Title', ...(ngDevMode ? [{ debugName: "title" }] : []));
8146
+ data = input([], ...(ngDevMode ? [{ debugName: "data" }] : []));
8147
+ columns = input([], ...(ngDevMode ? [{ debugName: "columns" }] : []));
8148
+ tableConfiguration = input(...(ngDevMode ? [undefined, { debugName: "tableConfiguration" }] : []));
8149
+ widthClass = input('w-6', ...(ngDevMode ? [{ debugName: "widthClass" }] : []));
8150
+ isFullScreen = input(false, ...(ngDevMode ? [{ debugName: "isFullScreen" }] : []));
8151
+ filters = computed(() => {
8152
+ return this.createDynamicFilters(this.data(), this.tableConfiguration()?.filters);
8153
+ }, ...(ngDevMode ? [{ debugName: "filters" }] : []));
8151
8154
  _panelVisible = signal(false, ...(ngDevMode ? [{ debugName: "_panelVisible" }] : []));
8152
8155
  set panelState(value) {
8153
8156
  this._panelVisible.set(value);
@@ -8170,8 +8173,102 @@ class QuickPickSidePanelComponent {
8170
8173
  onTableRowClick(row) {
8171
8174
  this.onRowClick.emit(row);
8172
8175
  }
8176
+ createDynamicFilters(data, fields, defaultFilterType = 'multiselect') {
8177
+ const filters = [];
8178
+ fields?.forEach((field) => {
8179
+ const type = field.type ?? defaultFilterType;
8180
+ if (type === 'boolean-multiselect') {
8181
+ filters.push({
8182
+ ...field,
8183
+ type,
8184
+ optionLabel: field.optionLabel ?? 'label',
8185
+ optionValue: field.optionValue ?? 'key',
8186
+ options: Array.isArray(field.options) && field.options.length
8187
+ ? field.options
8188
+ : [
8189
+ { key: false, label: 'ACTION.NO' },
8190
+ { key: true, label: 'ACTION.YES' },
8191
+ ],
8192
+ selected: Array.isArray(field.selected)
8193
+ ? field.selected
8194
+ : field.selected != null
8195
+ ? [field.selected]
8196
+ : [],
8197
+ });
8198
+ return;
8199
+ }
8200
+ const unique = new Set(); // Holds already added display values for deduplication
8201
+ const options = [];
8202
+ // Helper to add a candidate option if valid and not yet added
8203
+ const addOption = (display) => {
8204
+ if (display === null || display === undefined || display === '')
8205
+ return;
8206
+ const str = this.toDisplay(display);
8207
+ if (!unique.has(str)) {
8208
+ unique.add(str);
8209
+ options.push({ key: str, label: str });
8210
+ }
8211
+ };
8212
+ // Extract values for the current field across all rows
8213
+ data?.forEach((row) => {
8214
+ const value = this.getNestedValue(row, field.key);
8215
+ if (value === null || value === undefined || value === '')
8216
+ return;
8217
+ if (Array.isArray(value)) {
8218
+ // LIST field: process each element individually
8219
+ value.forEach((item) => addOption(this.extractItemNameOrValue(item)));
8220
+ }
8221
+ else if (typeof value === 'object') {
8222
+ // Single object: extract display value
8223
+ addOption(this.extractItemNameOrValue(value));
8224
+ }
8225
+ else {
8226
+ // Primitive value (string, number, boolean)
8227
+ addOption(value);
8228
+ }
8229
+ });
8230
+ // Sort options alphabetically by label
8231
+ options.sort((a, b) => a.label.localeCompare(b.label));
8232
+ // Final filter configuration for this field
8233
+ filters.push({
8234
+ ...field,
8235
+ type: field.type ?? defaultFilterType,
8236
+ options,
8237
+ });
8238
+ });
8239
+ return filters;
8240
+ }
8241
+ toDisplay(val) {
8242
+ if (typeof val === 'boolean') {
8243
+ return val ? 'Yes' : 'No';
8244
+ // return val
8245
+ // ? translate.instant('ACTION.YES')
8246
+ // : translate.instant('ACTION.NO');
8247
+ }
8248
+ return String(val);
8249
+ }
8250
+ /**
8251
+ * Extracts a displayable value from an object or primitive.
8252
+ * - Prefers object.name, then object.label, object.value, or object.title.
8253
+ * - Falls back to JSON stringification for objects without display fields.
8254
+ * - Returns primitive values as-is.
8255
+ */
8256
+ extractItemNameOrValue(item) {
8257
+ if (item === null || item === undefined)
8258
+ return null;
8259
+ if (typeof item === 'object') {
8260
+ const cand = item.name ?? item.label ?? item.value ?? item.title;
8261
+ return cand !== undefined ? cand : JSON.stringify(item);
8262
+ }
8263
+ return item;
8264
+ }
8265
+ getNestedValue(obj, path) {
8266
+ return path.split('.').reduce((curr, key) => {
8267
+ return curr && curr[key] !== undefined ? curr[key] : null;
8268
+ }, obj);
8269
+ }
8173
8270
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: QuickPickSidePanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
8174
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: QuickPickSidePanelComponent, isStandalone: true, selector: "phoenix-quick-pick-sidepanel", inputs: { title: "title", data: "data", columns: "columns", tableConfiguration: "tableConfiguration", widthClass: "widthClass", isFullScreen: "isFullScreen", panelState: "panelState" }, outputs: { panelStateChange: "panelStateChange", onRowClick: "onRowClick", lazyLoadData: "lazyLoadData", handlePanelFullScreen: "handlePanelFullScreen" }, viewQueries: [{ propertyName: "drawer", first: true, predicate: ["drawer"], descendants: true }], ngImport: i0, template: "<p-drawer\n #drawer\n [visible]=\"drawerVisible()\"\n (visibleChange)=\"visibleChange($event)\"\n [header]=\"title | translate\"\n appendTo=\"body\"\n position=\"right\"\n [styleClass]=\"widthClass\"\n>\n <!-- Content -->\n <ng-container *ngIf=\"tableConfiguration\">\n <div class=\"px-2\">\n <phoenix-table\n [data]=\"data\"\n [columns]=\"columns\"\n [tableConfiguration]=\"tableConfiguration\"\n (rowSelection)=\"onTableRowClick($event)\"\n ></phoenix-table>\n </div>\n </ng-container>\n</p-drawer>", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: DrawerModule }, { kind: "component", type: i2$2.Drawer, selector: "p-drawer", inputs: ["appendTo", "blockScroll", "style", "styleClass", "ariaCloseLabel", "autoZIndex", "baseZIndex", "modal", "closeButtonProps", "dismissible", "showCloseIcon", "closeOnEscape", "transitionOptions", "visible", "position", "fullScreen", "header", "maskStyle", "closable"], outputs: ["onShow", "onHide", "visibleChange"] }, { kind: "component", type: TableComponent, selector: "phoenix-table", inputs: ["columns", "selectedColumnsInput", "tableConfiguration", "filters", "data"], outputs: ["actionClick", "rowSelection", "checkBoxSelection", "saveColumns"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: ButtonModule }, { kind: "pipe", type: i4$2.TranslatePipe, name: "translate" }] });
8271
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: QuickPickSidePanelComponent, isStandalone: true, selector: "phoenix-quick-pick-sidepanel", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, tableConfiguration: { classPropertyName: "tableConfiguration", publicName: "tableConfiguration", isSignal: true, isRequired: false, transformFunction: null }, widthClass: { classPropertyName: "widthClass", publicName: "widthClass", isSignal: true, isRequired: false, transformFunction: null }, isFullScreen: { classPropertyName: "isFullScreen", publicName: "isFullScreen", isSignal: true, isRequired: false, transformFunction: null }, panelState: { classPropertyName: "panelState", publicName: "panelState", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { panelStateChange: "panelStateChange", onRowClick: "onRowClick", lazyLoadData: "lazyLoadData", handlePanelFullScreen: "handlePanelFullScreen" }, viewQueries: [{ propertyName: "drawer", first: true, predicate: ["drawer"], descendants: true }], ngImport: i0, template: "<p-drawer\n #drawer\n [visible]=\"drawerVisible()\"\n (visibleChange)=\"visibleChange($event)\"\n [header]=\"title() | translate\"\n appendTo=\"body\"\n position=\"right\"\n [styleClass]=\"widthClass()\"\n>\n <!-- Content -->\n @if (tableConfiguration()) {\n <div class=\"px-2\">\n <phoenix-table\n [data]=\"data()\"\n [columns]=\"columns()\"\n [tableConfiguration]=\"tableConfiguration()\"\n [filters]=\"filters()\"\n (rowSelection)=\"onTableRowClick($event)\"\n ></phoenix-table>\n </div>\n }\n</p-drawer>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: DrawerModule }, { kind: "component", type: i2$2.Drawer, selector: "p-drawer", inputs: ["appendTo", "blockScroll", "style", "styleClass", "ariaCloseLabel", "autoZIndex", "baseZIndex", "modal", "closeButtonProps", "dismissible", "showCloseIcon", "closeOnEscape", "transitionOptions", "visible", "position", "fullScreen", "header", "maskStyle", "closable"], outputs: ["onShow", "onHide", "visibleChange"] }, { kind: "component", type: TableComponent, selector: "phoenix-table", inputs: ["columns", "selectedColumnsInput", "tableConfiguration", "filters", "data"], outputs: ["actionClick", "rowSelection", "checkBoxSelection", "saveColumns"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: ButtonModule }, { kind: "pipe", type: i4$2.TranslatePipe, name: "translate" }] });
8175
8272
  }
8176
8273
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: QuickPickSidePanelComponent, decorators: [{
8177
8274
  type: Component,
@@ -8181,23 +8278,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
8181
8278
  TableComponent,
8182
8279
  TranslateModule,
8183
8280
  ButtonModule,
8184
- ], template: "<p-drawer\n #drawer\n [visible]=\"drawerVisible()\"\n (visibleChange)=\"visibleChange($event)\"\n [header]=\"title | translate\"\n appendTo=\"body\"\n position=\"right\"\n [styleClass]=\"widthClass\"\n>\n <!-- Content -->\n <ng-container *ngIf=\"tableConfiguration\">\n <div class=\"px-2\">\n <phoenix-table\n [data]=\"data\"\n [columns]=\"columns\"\n [tableConfiguration]=\"tableConfiguration\"\n (rowSelection)=\"onTableRowClick($event)\"\n ></phoenix-table>\n </div>\n </ng-container>\n</p-drawer>" }]
8281
+ ], template: "<p-drawer\n #drawer\n [visible]=\"drawerVisible()\"\n (visibleChange)=\"visibleChange($event)\"\n [header]=\"title() | translate\"\n appendTo=\"body\"\n position=\"right\"\n [styleClass]=\"widthClass()\"\n>\n <!-- Content -->\n @if (tableConfiguration()) {\n <div class=\"px-2\">\n <phoenix-table\n [data]=\"data()\"\n [columns]=\"columns()\"\n [tableConfiguration]=\"tableConfiguration()\"\n [filters]=\"filters()\"\n (rowSelection)=\"onTableRowClick($event)\"\n ></phoenix-table>\n </div>\n }\n</p-drawer>\n" }]
8185
8282
  }], propDecorators: { drawer: [{
8186
8283
  type: ViewChild,
8187
8284
  args: ['drawer']
8188
- }], title: [{
8189
- type: Input
8190
- }], data: [{
8191
- type: Input
8192
- }], columns: [{
8193
- type: Input
8194
- }], tableConfiguration: [{
8195
- type: Input
8196
- }], widthClass: [{
8197
- type: Input
8198
- }], isFullScreen: [{
8199
- type: Input
8200
- }], panelState: [{
8285
+ }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], tableConfiguration: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableConfiguration", required: false }] }], widthClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "widthClass", required: false }] }], isFullScreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isFullScreen", required: false }] }], panelState: [{
8201
8286
  type: Input
8202
8287
  }], panelStateChange: [{
8203
8288
  type: Output