@brickclay-org/ui 0.0.62 → 0.0.63

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.
@@ -6669,6 +6669,158 @@ const DOT_POSITION_MAP = {
6669
6669
  'top-left': 'top-0.5 -left-0.5'
6670
6670
  };
6671
6671
 
6672
+ class ColumnFilterOption {
6673
+ columnName;
6674
+ selected = true;
6675
+ constructor(columnName, selected = false) {
6676
+ if (columnName) {
6677
+ this.columnName = columnName;
6678
+ }
6679
+ this.selected = selected;
6680
+ }
6681
+ }
6682
+
6683
+ class BkColumnFilterService {
6684
+ constructor() { }
6685
+ intializeColumnsFilter(key, fields) {
6686
+ var columnsList = fields.map((f) => new ColumnFilterOption(f, true));
6687
+ localStorage.setItem(key, JSON.stringify(columnsList));
6688
+ }
6689
+ getColumnsFilterList(key, fields) {
6690
+ let stored = localStorage.getItem(key);
6691
+ if (!fields || fields.length === 0) {
6692
+ return [];
6693
+ }
6694
+ if (!stored) {
6695
+ this.intializeColumnsFilter(key, fields);
6696
+ stored = localStorage.getItem(key);
6697
+ }
6698
+ let storedColumns = stored ? JSON.parse(stored) : [];
6699
+ // Sync stored columns with current fields
6700
+ storedColumns = this.syncColumnsWithFields(storedColumns, fields);
6701
+ // Update localStorage with synced data
6702
+ localStorage.setItem(key, JSON.stringify(storedColumns));
6703
+ return storedColumns;
6704
+ // return stored ? (JSON.parse(stored) as ColumnFilterOption[]) : [];
6705
+ }
6706
+ syncColumnsWithFields(storedColumns, currentFields) {
6707
+ // Map of existing columns for quick lookup
6708
+ const existingColumnsMap = new Map();
6709
+ storedColumns.forEach(col => existingColumnsMap.set(col.columnName, col));
6710
+ // New list based on current fields
6711
+ const syncedColumns = [];
6712
+ currentFields.forEach(field => {
6713
+ if (existingColumnsMap.has(field)) {
6714
+ // Keep existing column with its selection state
6715
+ syncedColumns.push(existingColumnsMap.get(field));
6716
+ }
6717
+ else {
6718
+ // Add new column as selected by default
6719
+ syncedColumns.push(new ColumnFilterOption(field, true));
6720
+ }
6721
+ });
6722
+ return syncedColumns;
6723
+ }
6724
+ updateColumnFilterList(key, list) {
6725
+ localStorage.removeItem(key);
6726
+ localStorage.setItem(key, JSON.stringify(list));
6727
+ }
6728
+ showColumn(field, columnsFilterList) {
6729
+ return columnsFilterList.find((i) => i.columnName === field)?.selected || false;
6730
+ }
6731
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BkColumnFilterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6732
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BkColumnFilterService, providedIn: 'root' });
6733
+ }
6734
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BkColumnFilterService, decorators: [{
6735
+ type: Injectable,
6736
+ args: [{
6737
+ providedIn: 'root'
6738
+ }]
6739
+ }], ctorParameters: () => [] });
6740
+
6741
+ class BkColumnSelect {
6742
+ columnFilterService;
6743
+ searchable = false;
6744
+ cacheKey;
6745
+ columns;
6746
+ isOpened = false;
6747
+ formBoxRef;
6748
+ change = new EventEmitter();
6749
+ isOpenedChange = new EventEmitter();
6750
+ columnsFilterList = [];
6751
+ search = '';
6752
+ constructor(columnFilterService) {
6753
+ this.columnFilterService = columnFilterService;
6754
+ }
6755
+ ngOnInit() {
6756
+ this.getColumnsFilterList();
6757
+ }
6758
+ ngOnChanges(changes) {
6759
+ if (changes['columns'] && !changes['columns'].firstChange) {
6760
+ this.getColumnsFilterList();
6761
+ }
6762
+ }
6763
+ getColumnsFilterList() {
6764
+ this.columnsFilterList = this.columnFilterService.getColumnsFilterList(this.cacheKey, this.columns);
6765
+ this.change.emit(this.columnsFilterList);
6766
+ }
6767
+ filterButtonClicked(event) {
6768
+ event.stopPropagation();
6769
+ this.isOpenedChange.emit(!this.isOpened);
6770
+ }
6771
+ onChangeColumnFilter(evt) {
6772
+ this.columnFilterService.updateColumnFilterList(this.cacheKey, this.columnsFilterList);
6773
+ this.change.emit(this.columnsFilterList);
6774
+ }
6775
+ onClick(event) {
6776
+ // Check if the click target is inside the form_box
6777
+ if ((this.isOpened) &&
6778
+ this.formBoxRef.nativeElement.contains(event.target)) {
6779
+ return; // Do nothing if click occurred inside the form_box
6780
+ }
6781
+ // Check if the click target is .ng-value-icon
6782
+ if (event.target instanceof HTMLElement &&
6783
+ event.target.classList.contains('ng-value-icon')) {
6784
+ // Do nothing if click is on .ng-value-icon
6785
+ return;
6786
+ }
6787
+ // Check if the click target is the button
6788
+ if (!(event.target instanceof HTMLElement) ||
6789
+ !event.target.closest('.btn-light-primary-custom')) {
6790
+ // Close the popup if the click is not on the button
6791
+ this.isOpened = false;
6792
+ this.isOpenedChange.emit(this.isOpened);
6793
+ }
6794
+ }
6795
+ get list() {
6796
+ return this.columnsFilterList.filter((x) => x.columnName.toLowerCase().includes(this.search.toLowerCase()));
6797
+ }
6798
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BkColumnSelect, deps: [{ token: BkColumnFilterService }], target: i0.ɵɵFactoryTarget.Component });
6799
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: BkColumnSelect, isStandalone: true, selector: "bk-column-select", inputs: { searchable: "searchable", cacheKey: "cacheKey", columns: "columns", isOpened: "isOpened" }, outputs: { change: "change", isOpenedChange: "isOpenedChange" }, host: { listeners: { "document:click": "onClick($event)" } }, viewQueries: [{ propertyName: "formBoxRef", first: true, predicate: ["formBox"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"relative\">\r\n\r\n <bk-button [size]=\"'xsm'\" [variant]=\"'secondary'\" [leftIcon]=\"'images/icons/tickets/columns-black.svg'\"\r\n (click)=\"filterButtonClicked($event)\" [label]=\"'Columns'\" [buttonClass]=\"'!text-black'\"></bk-button>\r\n\r\n <!-- Dropdown Box -->\r\n @if(isOpened){\r\n\r\n <div #formBox\r\n class=\"absolute right-0 mt-2 w-[178px] bg-white border border-[#EFEFF1] rounded-xl shadow-xl p-3 pe-1 z-[9999]\">\r\n @if(searchable){\r\n <bk-input [id]=\"'search-input-1'\" [name]=\"'search-input-1'\"\r\n [iconSrc]=\"'../../assets/images/icons/global/search-input.svg'\" type=\"text\" [(ngModel)]=\"search\"\r\n placeholder=\"Search\"></bk-input>\r\n }\r\n <div class=\"flex flex-col gap-0.5 max-h-[360px] overflow-y-auto\">\r\n @for (column of list; track $index;let i=$index) {\r\n <div class=\"flex items-center gap-2 px-3 py-2\">\r\n <bk-checkbox id=\"columnsFilterList-{{i}}\" checkboxClass=\"sm\" [(ngModel)]=\"column.selected\"\r\n (change)=\"onChangeColumnFilter($event)\">\r\n\r\n </bk-checkbox>\r\n\r\n\r\n\r\n <label class=\"text-xs cursor-pointer text-[#141414] select-none truncate font-medium\"\r\n for=\"columnsFilterList-{{i}}\">\r\n {{column.columnName}}\r\n </label>\r\n </div>\r\n }\r\n @if(!list.length){\r\n <p class=\"text-sm font-medium text-gray-500 mt-3 text-center\">No Records Found</p>\r\n }\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: BkButton, selector: "bk-button", inputs: ["variant", "size", "label", "leftIcon", "rightIcon", "iconAlt", "type", "loading", "disabled", "buttonClass", "textClass", "spinnerClass"], outputs: ["clicked"] }, { kind: "component", type: BkCheckbox, selector: "bk-checkbox", inputs: ["checkboxClass", "label", "labelClass", "disabled"], outputs: ["change"] }, { kind: "component", type: BkInput, selector: "bk-input", inputs: ["id", "name", "mask", "autoComplete", "label", "placeholder", "hint", "required", "type", "value", "hasError", "showErrorIcon", "errorMessage", "disabled", "tabIndex", "readOnly", "autoCapitalize", "inputMode", "iconSrc", "iconAlt", "showIcon", "phone", "countryCode", "countryOptions", "iconOrientation", "password", "showPassword", "pattern", "max", "min", "step", "maxlength", "minlength"], outputs: ["input", "change", "focus", "blur", "clicked"] }] });
6800
+ }
6801
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BkColumnSelect, decorators: [{
6802
+ type: Component,
6803
+ args: [{ selector: 'bk-column-select', imports: [FormsModule, BkButton, BkCheckbox, BkInput], standalone: true, template: "<div class=\"relative\">\r\n\r\n <bk-button [size]=\"'xsm'\" [variant]=\"'secondary'\" [leftIcon]=\"'images/icons/tickets/columns-black.svg'\"\r\n (click)=\"filterButtonClicked($event)\" [label]=\"'Columns'\" [buttonClass]=\"'!text-black'\"></bk-button>\r\n\r\n <!-- Dropdown Box -->\r\n @if(isOpened){\r\n\r\n <div #formBox\r\n class=\"absolute right-0 mt-2 w-[178px] bg-white border border-[#EFEFF1] rounded-xl shadow-xl p-3 pe-1 z-[9999]\">\r\n @if(searchable){\r\n <bk-input [id]=\"'search-input-1'\" [name]=\"'search-input-1'\"\r\n [iconSrc]=\"'../../assets/images/icons/global/search-input.svg'\" type=\"text\" [(ngModel)]=\"search\"\r\n placeholder=\"Search\"></bk-input>\r\n }\r\n <div class=\"flex flex-col gap-0.5 max-h-[360px] overflow-y-auto\">\r\n @for (column of list; track $index;let i=$index) {\r\n <div class=\"flex items-center gap-2 px-3 py-2\">\r\n <bk-checkbox id=\"columnsFilterList-{{i}}\" checkboxClass=\"sm\" [(ngModel)]=\"column.selected\"\r\n (change)=\"onChangeColumnFilter($event)\">\r\n\r\n </bk-checkbox>\r\n\r\n\r\n\r\n <label class=\"text-xs cursor-pointer text-[#141414] select-none truncate font-medium\"\r\n for=\"columnsFilterList-{{i}}\">\r\n {{column.columnName}}\r\n </label>\r\n </div>\r\n }\r\n @if(!list.length){\r\n <p class=\"text-sm font-medium text-gray-500 mt-3 text-center\">No Records Found</p>\r\n }\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n" }]
6804
+ }], ctorParameters: () => [{ type: BkColumnFilterService }], propDecorators: { searchable: [{
6805
+ type: Input
6806
+ }], cacheKey: [{
6807
+ type: Input
6808
+ }], columns: [{
6809
+ type: Input
6810
+ }], isOpened: [{
6811
+ type: Input
6812
+ }], formBoxRef: [{
6813
+ type: ViewChild,
6814
+ args: ['formBox']
6815
+ }], change: [{
6816
+ type: Output
6817
+ }], isOpenedChange: [{
6818
+ type: Output
6819
+ }], onClick: [{
6820
+ type: HostListener,
6821
+ args: ['document:click', ['$event']]
6822
+ }] } });
6823
+
6672
6824
  /*
6673
6825
  * Public API Surface of brickclay-lib
6674
6826
  */
@@ -6678,5 +6830,5 @@ const DOT_POSITION_MAP = {
6678
6830
  * Generated bundle index. Do not edit.
6679
6831
  */
6680
6832
 
6681
- export { BKTooltipDirective, BK_DEFAULT_DIALOG_CONFIG, BK_DIALOG_DATA, BK_DIALOG_GLOBAL_CONFIG, BkAvatarProfile, BkBadge, BkButton, BkButtonGroup, BkCheckbox, BkCustomCalendar, BkDialogActions, BkDialogClose, BkDialogContent, BkDialogModule, BkDialogRef, BkDialogService, BkDialogTitle, BkGrid, BkHierarchicalSelect, BkIconButton, BkInput, BkInputChips, BkPill, BkRadioButton, BkScheduledDatePicker, BkSelect, BkSpinner, BkTabs, BkTextarea, BkTimePicker, BkToastr, BkToastrService, BkToggle, BkUiAvatar, BkValidator, BrickclayIcons, BrickclayLib, CalendarManagerService, CalendarModule, CalendarSelection, getDialogBackdropAnimation, getDialogPanelAnimation };
6833
+ export { BKTooltipDirective, BK_DEFAULT_DIALOG_CONFIG, BK_DIALOG_DATA, BK_DIALOG_GLOBAL_CONFIG, BkAvatarProfile, BkBadge, BkButton, BkButtonGroup, BkCheckbox, BkColumnFilterService, BkColumnSelect, BkCustomCalendar, BkDialogActions, BkDialogClose, BkDialogContent, BkDialogModule, BkDialogRef, BkDialogService, BkDialogTitle, BkGrid, BkHierarchicalSelect, BkIconButton, BkInput, BkInputChips, BkPill, BkRadioButton, BkScheduledDatePicker, BkSelect, BkSpinner, BkTabs, BkTextarea, BkTimePicker, BkToastr, BkToastrService, BkToggle, BkUiAvatar, BkValidator, BrickclayIcons, BrickclayLib, CalendarManagerService, CalendarModule, CalendarSelection, ColumnFilterOption, getDialogBackdropAnimation, getDialogPanelAnimation };
6682
6834
  //# sourceMappingURL=brickclay-org-ui.mjs.map