@sankhyalabs/ezui 4.6.0 → 4.6.1

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.
Files changed (37) hide show
  1. package/dist/cjs/{constants-5d588e38.js → constants-5a75e2f3.js} +0 -2
  2. package/dist/cjs/ez-combo-box.cjs.entry.js +1 -1
  3. package/dist/cjs/ez-form-view.cjs.entry.js +1 -1
  4. package/dist/cjs/ez-form.cjs.entry.js +0 -1
  5. package/dist/cjs/ez-grid.cjs.entry.js +112 -213
  6. package/dist/cjs/ezui.cjs.js +1 -1
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +86 -84
  9. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +5 -16
  10. package/dist/collection/components/ez-grid/ez-grid.js +21 -110
  11. package/dist/collection/components/ez-grid/subcomponents/selection-counter.js +3 -5
  12. package/dist/collection/utils/form/DataBinder.js +0 -1
  13. package/dist/custom-elements/index.js +113 -215
  14. package/dist/esm/constants-ca136201.js +3 -0
  15. package/dist/esm/ez-combo-box.entry.js +1 -1
  16. package/dist/esm/ez-form-view.entry.js +1 -1
  17. package/dist/esm/ez-form.entry.js +0 -1
  18. package/dist/esm/ez-grid.entry.js +112 -213
  19. package/dist/esm/ezui.js +1 -1
  20. package/dist/esm/loader.js +1 -1
  21. package/dist/ezui/ezui.esm.js +1 -1
  22. package/dist/ezui/p-03164b9f.entry.js +1 -0
  23. package/dist/ezui/p-3f4ae3a3.js +1 -0
  24. package/dist/ezui/{p-878646a0.entry.js → p-50883460.entry.js} +1 -1
  25. package/dist/ezui/{p-ef705232.entry.js → p-8654802d.entry.js} +2 -2
  26. package/dist/ezui/{p-b7ea9791.entry.js → p-e748b5d3.entry.js} +1 -1
  27. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +6 -10
  28. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +3 -5
  29. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +0 -1
  30. package/dist/types/components/ez-grid/ez-grid.d.ts +2 -9
  31. package/dist/types/components/ez-grid/subcomponents/selection-counter.d.ts +2 -2
  32. package/package.json +1 -1
  33. package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +0 -73
  34. package/dist/esm/constants-76d2e931.js +0 -4
  35. package/dist/ezui/p-1f841f3c.entry.js +0 -1
  36. package/dist/ezui/p-b01e3085.js +0 -1
  37. package/dist/types/components/ez-grid/controller/DataUnitBridge.d.ts +0 -11
@@ -1 +1 @@
1
- import{h as e,r as a,c as l,H as t,g as n}from"./p-7ffd12e7.js";import{UserInterface as o,ElementIDUtils as d}from"@sankhyalabs/core";import{R as i}from"./p-b01e3085.js";import{C as s}from"./p-b853763b.js";function r(a,l,t,n,o){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!t,label:l,mode:o?s.SWITCH:s.REGULAR,"data-field-name":a,"data-context-name":n,key:a}))}function c(a,l,t,n,o,d){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!t,label:l,precision:n,prettyPrecision:o,"data-field-name":a,"data-context-name":d,key:a}))}const m=({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:l,"data-field-name":a,"data-context-name":n,key:a,enabled:!t})),z=new Map;z.set(o.CHECKBOX,(e=>r(e.name,e.label,e.readOnly,e.contextName,!1))),z.set(o.SWITCH,(e=>r(e.name,e.label,e.readOnly,e.contextName,!0))),z.set(o.OPTIONSELECTOR,(({name:a,label:l,readOnly:t,required:n,props:o,contextName:d})=>{const i=null==o?void 0:o.options;let s;if("string"==typeof i){const e=JSON.parse(i);s=Object.keys(e).map((a=>({value:a,label:e[a]})))}else s=i;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!t,suppressEmptyOption:n,label:l,"data-field-name":a,"data-context-name":d,key:a,options:s}))})),z.set(o.DATE,(({name:a,label:l,readOnly:t})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!t,label:l,"data-field-name":a,key:a})))),z.set(o.TIME,(({name:a,label:l,readOnly:t})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!t,label:l,"data-field-name":a,key:a})))),z.set(o.DATETIME,(({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!t,label:l,"data-field-name":a,"data-context-name":n,key:a})))),z.set(o.FILE,(({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!t,label:l,"data-field-name":a,"data-context-name":n,key:a})))),z.set(o.DECIMALNUMBER,(({name:e,label:a,readOnly:l,props:t,contextName:n})=>{const o=Number((null==t?void 0:t.precision)||2);return c(e,a,l,o,Number((null==t?void 0:t.prettyPrecision)||o),n)})),z.set(o.INTEGERNUMBER,(({name:e,label:a,readOnly:l,contextName:t})=>c(e,a,l,0,0,t))),z.set(o.SEARCH,(({name:a,label:l,readOnly:t,required:n,contextName:o})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!t,suppressEmptyOption:n,label:l,"data-field-name":a,"data-context-name":o,key:a})))),z.set(o.LONGTEXT,(({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:a},e("ez-text-area",{enabled:!t,label:l,"data-field-name":a,"data-context-name":n}))));const b=e=>{const a=z.get(e.userInterface)||m,l=e.required?`${e.label}${i}`:e.label;return a(Object.assign(Object.assign({},e),{label:l}))},p=class{constructor(e){a(this,e),this.ezContentReady=l(this,"ezContentReady",7),this.fields=void 0}async showUp(){this._element.scrollIntoView({behavior:"smooth",block:"start"})}groupFields(e){const a=new Map;return e.forEach((e=>{const l=e.group;if(l){let t=a.get(l);null==t&&(t=[],a.set(l,t)),t.push(e)}else a.set(e.name,e)})),a}componentDidRender(){this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")))}render(){if(d.addIDInfoIfNotExists(this._element,"ezFormView"),null!=this.fields)return e(t,null,Array.from(this.groupFields(this.fields).entries()).map((([a,l])=>Array.isArray(l)?e("ez-collapsible-box",{id:`group-${a}`,label:a,"header-size":"large",key:a},l.map((e=>b(e)))):b(l))))}get _element(){return n(this)}};p.style=".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";export{p as ez_form_view}
1
+ import{h as e,r as a,c as l,H as t,g as n}from"./p-7ffd12e7.js";import{UserInterface as o,ElementIDUtils as d}from"@sankhyalabs/core";import{R as i}from"./p-3f4ae3a3.js";import{C as s}from"./p-b853763b.js";function r(a,l,t,n,o){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!t,label:l,mode:o?s.SWITCH:s.REGULAR,"data-field-name":a,"data-context-name":n,key:a}))}function c(a,l,t,n,o,d){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!t,label:l,precision:n,prettyPrecision:o,"data-field-name":a,"data-context-name":d,key:a}))}const m=({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:l,"data-field-name":a,"data-context-name":n,key:a,enabled:!t})),z=new Map;z.set(o.CHECKBOX,(e=>r(e.name,e.label,e.readOnly,e.contextName,!1))),z.set(o.SWITCH,(e=>r(e.name,e.label,e.readOnly,e.contextName,!0))),z.set(o.OPTIONSELECTOR,(({name:a,label:l,readOnly:t,required:n,props:o,contextName:d})=>{const i=null==o?void 0:o.options;let s;if("string"==typeof i){const e=JSON.parse(i);s=Object.keys(e).map((a=>({value:a,label:e[a]})))}else s=i;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!t,suppressEmptyOption:n,label:l,"data-field-name":a,"data-context-name":d,key:a,options:s}))})),z.set(o.DATE,(({name:a,label:l,readOnly:t})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!t,label:l,"data-field-name":a,key:a})))),z.set(o.TIME,(({name:a,label:l,readOnly:t})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!t,label:l,"data-field-name":a,key:a})))),z.set(o.DATETIME,(({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!t,label:l,"data-field-name":a,"data-context-name":n,key:a})))),z.set(o.FILE,(({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!t,label:l,"data-field-name":a,"data-context-name":n,key:a})))),z.set(o.DECIMALNUMBER,(({name:e,label:a,readOnly:l,props:t,contextName:n})=>{const o=Number((null==t?void 0:t.precision)||2);return c(e,a,l,o,Number((null==t?void 0:t.prettyPrecision)||o),n)})),z.set(o.INTEGERNUMBER,(({name:e,label:a,readOnly:l,contextName:t})=>c(e,a,l,0,0,t))),z.set(o.SEARCH,(({name:a,label:l,readOnly:t,required:n,contextName:o})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!t,suppressEmptyOption:n,label:l,"data-field-name":a,"data-context-name":o,key:a})))),z.set(o.LONGTEXT,(({name:a,label:l,readOnly:t,contextName:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:a},e("ez-text-area",{enabled:!t,label:l,"data-field-name":a,"data-context-name":n}))));const b=e=>{const a=z.get(e.userInterface)||m,l=e.required?`${e.label}${i}`:e.label;return a(Object.assign(Object.assign({},e),{label:l}))},p=class{constructor(e){a(this,e),this.ezContentReady=l(this,"ezContentReady",7),this.fields=void 0}async showUp(){this._element.scrollIntoView({behavior:"smooth",block:"start"})}groupFields(e){const a=new Map;return e.forEach((e=>{const l=e.group;if(l){let t=a.get(l);null==t&&(t=[],a.set(l,t)),t.push(e)}else a.set(e.name,e)})),a}componentDidRender(){this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")))}render(){if(d.addIDInfoIfNotExists(this._element,"ezFormView"),null!=this.fields)return e(t,null,Array.from(this.groupFields(this.fields).entries()).map((([a,l])=>Array.isArray(l)?e("ez-collapsible-box",{id:`group-${a}`,label:a,"header-size":"large",key:a},l.map((e=>b(e)))):b(l))))}get _element(){return n(this)}};p.style=".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";export{p as ez_form_view}
@@ -1,4 +1,4 @@
1
- import { DataUnit, Record } from "@sankhyalabs/core";
1
+ import { DataUnit } from "@sankhyalabs/core";
2
2
  /**
3
3
  * O intuito desta abstração, é isolar o componente EzGrid de uma implementação
4
4
  * específica, permitindo que usemos componentes de terceiros sem um acoplamento
@@ -71,7 +71,11 @@ export default interface EzGridController {
71
71
  /**
72
72
  * Método responsável por selecionar linhas
73
73
  */
74
- selectRows(rowIds: Array<Record>): void;
74
+ selectRows(rowIds: Array<string>, quietly?: boolean): void;
75
+ /**
76
+ * Método responsável por selecionar todas as de uma vez.
77
+ */
78
+ selectAll(quietly?: boolean): void;
75
79
  /**
76
80
  * Método responsável por alterar o valores nos registros
77
81
  */
@@ -92,14 +96,6 @@ export default interface EzGridController {
92
96
  * Foca a primeira linha da grade, usado durante a troca de página
93
97
  */
94
98
  setFocusFirstRow(): void;
95
- /**
96
- * Limpa toda a seleção da grade.
97
- */
98
- deselectAll(): void;
99
- /**
100
- * Atualizar checkbox da grade.
101
- */
102
- updateCheckbox(): void;
103
99
  }
104
100
  /**
105
101
  * Carrega as informações necessárias para contextualizar corretamente a instância.
@@ -1,4 +1,4 @@
1
- import { Sort, SortingProvider, Record } from "@sankhyalabs/core";
1
+ import { Sort, SortingProvider } from "@sankhyalabs/core";
2
2
  import EzGridController, { EzGridColumn, EzGridColumnConfig, EzGridColumnMenuItemDef, EzGridOptions } from "../EzGridController";
3
3
  export default class AgGridController implements EzGridController, SortingProvider {
4
4
  private readonly DEFAULT_ROW_HEIGHT;
@@ -33,13 +33,13 @@ export default class AgGridController implements EzGridController, SortingProvid
33
33
  private defineRowModelType;
34
34
  private setOptionsEvents;
35
35
  private setOptionsSupress;
36
- private isAllRecordSetted;
37
36
  private getSelectionHeaderStatus;
38
37
  private updateSelectionForAll;
39
38
  setData(data: Array<any>): void;
40
39
  addRows(): void;
41
40
  updateRows(): void;
42
- selectRows(rowIds: Array<Record>): void;
41
+ selectAll(quietly?: boolean): void;
42
+ selectRows(rowIds: Array<string>, quietly?: boolean): void;
43
43
  removeRows(): void;
44
44
  changeValues(changes: any, rowIds?: Array<string>): void;
45
45
  refresh(): void;
@@ -54,8 +54,6 @@ export default class AgGridController implements EzGridController, SortingProvid
54
54
  addColumnMenuItem(item: EzGridColumnMenuItemDef): void;
55
55
  quickFilter(term: string): void;
56
56
  setSelectedIndex(index: number): void;
57
- deselectAll(): void;
58
- updateCheckbox(): void;
59
57
  private buildColDef;
60
58
  private getInitCellStyle;
61
59
  private getStyleByColumn;
@@ -12,7 +12,6 @@ export default class DataSource implements IServerSideDatasource {
12
12
  private duObserver;
13
13
  constructor(dataUnit: DataUnit, controller: EzGridController, options: EzGridOptions);
14
14
  private updateSelection;
15
- private isSelectionEquals;
16
15
  getRows(params: IServerSideGetRowsParams): void;
17
16
  needReload(currentLoading: IServerSideGetRowsParams): boolean;
18
17
  private callbackGetRows;
@@ -6,16 +6,15 @@ export declare class EzGrid {
6
6
  private _container;
7
7
  private _refPaginationControl;
8
8
  private _gridController;
9
- private _debounceTimer;
10
9
  private _gridSelectionCounter;
11
- private _selectionAll;
12
10
  private _resizeObserver;
13
11
  _element: HTMLElement;
14
12
  private _paginationInfo;
15
13
  private _paginationChangedByKeyboard;
16
14
  private _showSelectionCounter;
15
+ private _isAllSelection;
16
+ private _currentPageSelected;
17
17
  private _selectionCount;
18
- private _selectionPageCount;
19
18
  /**
20
19
  * Emitido quando acontece a alteração de estado das colunas do grid: Ordenação, largura, etc.
21
20
  */
@@ -87,13 +86,7 @@ export declare class EzGrid {
87
86
  quickFilter(term: string): Promise<void>;
88
87
  observeConfig(config: IGridConfig): void;
89
88
  onSelectionChange(evt: CustomEvent): void;
90
- private updateSelectionPage;
91
- private isAllRecordSetted;
92
89
  private setSelection;
93
- private setAutoSelectAll;
94
- private controlSelectionCounter;
95
- private setSelectionCount;
96
- private isPaginationActived;
97
90
  private onSelectAllRecords;
98
91
  private onSelectPageRecords;
99
92
  private onClearSelectedRecords;
@@ -1,9 +1,9 @@
1
1
  import { FunctionalComponent } from "../../../stencil-public-runtime";
2
2
  interface SelectionCounterProps {
3
3
  selectionCount: number;
4
- selectionPageCount: number;
5
4
  total: number;
6
- recordsLength: number;
5
+ allRecordSelected: boolean;
6
+ currentPageSelected: boolean;
7
7
  onSelectAll: () => void;
8
8
  onSelectPage: () => void;
9
9
  onClearAll: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/ezui",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "Biblioteca de componentes Sankhya.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/custom-elements/index.js",
@@ -1,73 +0,0 @@
1
- import { Action } from "@sankhyalabs/core";
2
- export default class DataUnitBridge {
3
- constructor(gridController, dataUnit) {
4
- this.RECORD_ARCHIVE = "__RECORD_ARCHIVE__";
5
- this.processAction = (action) => {
6
- switch (action.type) {
7
- case Action.METADATA_LOADED:
8
- this._gridController.setColumnsDef(this.buildColumnDefs());
9
- break;
10
- case Action.RECORDS_REMOVED:
11
- const { records } = action.payload;
12
- this._gridController.removeRows(records);
13
- break;
14
- case Action.DATA_SAVED:
15
- case Action.EDITION_CANCELED:
16
- this._gridController.updateRows();
17
- case Action.SELECTION_CHANGED:
18
- const { selection } = action.payload;
19
- this._gridController.selectRows(selection);
20
- break;
21
- case Action.SELECTION_REMOVED:
22
- const { unselection } = action.payload;
23
- const filteredRecords = this._dataUnit.getSelection()
24
- .filter((selectedRecord) => {
25
- return !unselection.some((unselectedRecord) => {
26
- return unselectedRecord.__record__id__ === selectedRecord.__record__id__;
27
- });
28
- });
29
- if ((filteredRecords === null || filteredRecords === void 0 ? void 0 : filteredRecords.length) > 0) {
30
- this._gridController.selectRows(filteredRecords);
31
- }
32
- else {
33
- this._gridController.deselectAll();
34
- }
35
- break;
36
- case Action.NEXT_SELECTED:
37
- case Action.PREVIOUS_SELECTED:
38
- this._gridController.selectRows(this._dataUnit.getSelection());
39
- break;
40
- case Action.DATA_CHANGED:
41
- const changes = Object.assign({}, action.payload);
42
- delete changes.records;
43
- this._gridController.changeValues(changes, action.payload.records);
44
- break;
45
- case Action.RECORD_LOADED:
46
- this._gridController.changeValues(changes, action.payload.records);
47
- }
48
- };
49
- this._gridController = gridController;
50
- this._dataUnit = dataUnit;
51
- this._dataUnit.subscribe(this.processAction);
52
- }
53
- buildColumnDefs() {
54
- const columnDefs = [];
55
- if (this._dataUnit.metadata) {
56
- this._dataUnit.metadata.fields.forEach(f => {
57
- var _a;
58
- if (f.visible !== false && f.name !== this.RECORD_ARCHIVE) {
59
- const props = new Map();
60
- const properties = this._dataUnit.getField(f.name).properties;
61
- for (const value in properties) {
62
- props.set(value, properties[value]);
63
- }
64
- columnDefs.push({ label: f.label, name: f.name, userInterface: f.userInterface, options: (_a = this._dataUnit.getField(f.name).properties) === null || _a === void 0 ? void 0 : _a.options, props });
65
- }
66
- });
67
- }
68
- return columnDefs;
69
- }
70
- onDisconnectedCallback() {
71
- this._dataUnit.unsubscribe(this.processAction);
72
- }
73
- }
@@ -1,4 +0,0 @@
1
- const REQUIRED_INFO = " (obrigatório) *";
2
- const ALL_RECORD = "ALL_RECORD";
3
-
4
- export { ALL_RECORD as A, REQUIRED_INFO as R };
@@ -1 +0,0 @@
1
- import{r as t,c as e,h as i,f as s,H as n,g as r}from"./p-7ffd12e7.js";import{UserInterface as o,DateUtils as a,Action as l,WaitingChangeException as h,ApplicationContext as c,DataUnitAction as u,StringUtils as d,DataUnit as f,ElementIDUtils as v}from"@sankhyalabs/core";import{A as p}from"./p-efb43dd8.js";import"./p-ab574d59.js";const b=/child\[([^\]]+)\]/,m=/\$\{.+\}/;class g{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}static getDetailName(t){const e=b.exec(t);return e?e[1]:void 0}getSheet(t){return this._sheets.get(t)}getAllSheets(){return this._sheets}addSheet(t){this._sheets.set(t.name,t)}addRequiredFields(t){this._requiredFields=this._requiredFields.concat(t)}getRequiredFields(){return this._requiredFields}addCleanOnCopyFields(t){this._cleanOnCopyFields=this._cleanOnCopyFields.concat(t)}getCleanOnCopyFields(){return this._cleanOnCopyFields}addDefaultValues(t){return this._defaultValues=Object.assign(Object.assign({},this._defaultValues),t)}getDefaultValues(){const t={};return Object.entries(this._defaultValues).forEach((([e,i])=>{if("string"==typeof i){const t=m.exec(i);t&&(i=this.getDefaultVar(t[0]))}t[e]=i})),t}getDefaultVar(t){return"${data}"===t?a.getToday():"${datahora}"===t?a.getToday(!0):this._defaultVars?this._defaultVars.get(t):void 0}setDefaultVars(t){this._defaultVars=t}}const y=(t,e)=>"__main"==t[0].label?-1:(t[0].order||1e4)-(e[0].order||1e4);class _{constructor(t){this.onDataUnitEvent=t=>{var e,i;switch(t.type){case l.DATA_LOADED:case l.DATA_SAVED:case l.RECORDS_REMOVED:case l.RECORDS_ADDED:case l.RECORDS_COPIED:case l.EDITION_CANCELED:case l.SELECTION_CHANGED:case l.SELECTION_REMOVED:case l.NEXT_SELECTED:case l.PREVIOUS_SELECTED:this.clearInvalid();case l.DATA_CHANGED:case l.CHANGE_UNDONE:case l.CHANGE_REDONE:case l.RECORD_LOADED:null===(e=this._fields)||void 0===e||e.forEach((t=>{this.updateValue(t.fieldName,t.field)}));break;case l.FIELD_INVALIDATED:null===(i=this._fields)||void 0===i||i.forEach((t=>{this.updateErrorMessage(t.fieldName,t.field)}))}},this._fields=new Map,this._dataUnit=t,this.applyDefaultValues(),this._dataUnit.subscribe(this.onDataUnitEvent),this._dataUnit.addInterceptor(this)}applyDefaultValues(){const t=(this._dataUnit.getAddedRecords()||[]).map((t=>t.__record__id__));if(t.length>0){const e=this.getDefaultValues();e&&Object.keys(e).forEach((i=>{this._dataUnit.setFieldValue(i,e[i],t)}))}}bind(t,e,i,s){t.forEach((t=>{const{fieldName:i,contextName:s}=t.dataset;null!=s&&s!==e||this.updateBind(i,t)})),this._formMetadata=i,this._recordsValidator=s}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent),this._dataUnit.removeInterceptor(this)}getCurrentRecordId(){const t=this._dataUnit.getSelectedRecord();return null==t?void 0:t.__record__id__}markInvalid(t){if(this._dataUnit.setInvalidField(t.name,t.message,this.getCurrentRecordId()),this._fields.has(t.name)){const e=this._fields.get(t.name).field;this.updateErrorMessage(t.name,e,t.message)}}clearInvalid(t){this._dataUnit.clearInvalid(t),this._fields.forEach((t=>{t.field.errorMessage=""}))}updateValue(t,e){const i=this._fields.get(t);try{i&&(i.listen=!1),e.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,e)}finally{i&&(i.listen=!0)}}validate(){return new Promise(((t,e)=>{var i;const s=this._dataUnit.getModifiedRecords();for(let t=0;t<s.length;t++){const n=s[t],r=[];let o=this.validateRequired(n);if(o&&!o.isValid&&r.push(o),o=null===(i=this._recordsValidator)||void 0===i?void 0:i.validateRecord(n),o&&!o.isValid&&r.push(o),r.length>0){this.processValidationResult(r),e();break}}return t()}))}validateRequired(t){const e=this._formMetadata.getRequiredFields(),i=[];if(new Set(e).forEach((e=>{const s=t[e];if(null==s||""===s){const t=this.getErrorMessage(e);i.push(t?{name:e,message:t}:{name:e,message:"Essa informação é obrigatória"})}})),i.length>0)return{isValid:!1,invalidFields:i,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(t){t.forEach((t=>{const e=t.invalidFields;if(e&&e.forEach((t=>{this.markInvalid(t)})),t.infoMessage&&p.info(t.infoMessage),t.errorMessage){const{errorTitle:e,errorMessage:i}=t;p.error(e,i)}}))}updateErrorMessage(t,e,i){null==i&&(i=this._dataUnit.getInvalidMessage(this.getCurrentRecordId(),t)),e.errorMessage||(e.errorMessage=i)}getErrorMessage(t){if(this._fields.has(t))return this._fields.get(t).field.errorMessage}updateBind(t,e){const i=this._fields.get(t);i&&i.destroy(),e.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,e),this._fields.set(t,w.create(t,e,((t,e)=>this.changeStarted(t,e)),(t=>this.cancelWaitingChange(t)),((t,e)=>this.setFieldValue(t,e)))),this.bindSearchOptionsLoader(t,e),this.applyEzUploadContext(t,e)}changeStarted(t,e){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!e.blocking&&null==e.promise){const i=this._fields.get(t);i&&(e.promise=new Promise(((t,e)=>{i.waitingChangePromiseResolve=t,i.waitingChangePromiseReject=e})))}this._dataUnit.startChange(t,e)}cancelWaitingChange(t){if(this._dataUnit.waitingForChange(t)){this._dataUnit.cancelWaitingChange(t);const e=this._fields.get(t);e&&e.rejectWaitingChange(new h("Change canceled",t))}}setFieldValue(t,e){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.clearInvalid(this.getCurrentRecordId(),t),this._dataUnit.setFieldValue(t,e),this._dataUnit.waitingForChange(t)){const e=this._fields.get(t);e&&e.acceptWaitingChange()}}bindSearchOptionsLoader(t,e){if("EZ-SEARCH"===e.nodeName&&null==e.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(e.optionLoader=e=>i(e,t,this._dataUnit))}}applyEzUploadContext(t,e){var i,s;if("EZ-UPLOAD"===e.nodeName){e.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),e.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const n=this._dataUnit.getField(t),r=null===(i=n.properties)||void 0===i?void 0:i.DESTINATION;r&&(e.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),e.maxFiles=(null===(s=n.properties)||void 0===s?void 0:s.MAX_FILES)||0}}interceptAction(t){if(t.type===l.RECORDS_COPIED){const e=this._formMetadata.getCleanOnCopyFields();if(e)return new u(l.RECORDS_COPIED,t.payload.map((t=>{const i=Object.assign({},t);return e.forEach((t=>delete i[t])),i})))}if(t.type===l.SAVING_DATA)return new Promise((e=>{this.validate().then((()=>e(t))).catch((()=>{}))}));if(t.type===l.RECORDS_ADDED){const e=this.getDefaultValues();if(e)return new u(l.RECORDS_ADDED,t.payload.map((t=>Object.assign(Object.assign({},t),e))))}return t}getDefaultValues(){var t;const e=null===(t=this._formMetadata)||void 0===t?void 0:t.getDefaultValues();if(e){const t={};for(const i in e)t[i]=this._dataUnit.valueFromString(i,e[i]);return t}}}class w{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(t){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(t),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(t,e,i,s,n){const r=new w;return r.field=e,r.fieldName=t,r.startChangeListener=e=>{r.listen&&i(t,e.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&s(t)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=e=>{r.listen&&n(t,e.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}function O(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var E="function"==typeof Symbol&&Symbol.observable||"@@observable",C=function(){return Math.random().toString(36).substring(7).split("").join(".")},A={INIT:"@@redux/INIT"+C(),REPLACE:"@@redux/REPLACE"+C(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+C()}};function j(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function R(t,e,i){var s;if("function"==typeof e&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(O(0));if("function"==typeof e&&void 0===i&&(i=e,e=void 0),void 0!==i){if("function"!=typeof i)throw new Error(O(1));return i(R)(t,e)}if("function"!=typeof t)throw new Error(O(2));var n=t,r=e,o=[],a=o,l=!1;function h(){a===o&&(a=o.slice())}function c(){if(l)throw new Error(O(3));return r}function u(t){if("function"!=typeof t)throw new Error(O(4));if(l)throw new Error(O(5));var e=!0;return h(),a.push(t),function(){if(e){if(l)throw new Error(O(6));e=!1,h();var i=a.indexOf(t);a.splice(i,1),o=null}}}function d(t){if(!j(t))throw new Error(O(7));if(void 0===t.type)throw new Error(O(8));if(l)throw new Error(O(9));try{l=!0,r=n(r,t)}finally{l=!1}for(var e=o=a,i=0;i<e.length;i++)(0,e[i])();return t}function f(t){if("function"!=typeof t)throw new Error(O(10));n=t,d({type:A.REPLACE})}function v(){var t,e=u;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(O(11));function i(){t.next&&t.next(c())}return i(),{unsubscribe:e(i)}}})[E]=function(){return this},t}return d({type:A.INIT}),(s={dispatch:d,subscribe:u,getState:c,replaceReducer:f})[E]=v,s}const D={};function z(t=D,e){switch(e.type){case S.METADATA_LOADED:return Object.assign(Object.assign({},t),{formMetadata:e.payload,currentSheet:void 0});case S.CHANGE_TAB:return Object.assign(Object.assign({},t),{currentSheet:e.payload});default:return t}}function N(t){return t.formMetadata}var S;!function(t){t.METADATA_LOADED="FORM/METADATA_LOADED",t.CHANGE_TAB="FORM/CHANGE_TAB"}(S||(S={}));const x=class{constructor(i){t(this,i),this.ezReady=e(this,"ezReady",7),this.onDataUnitAction=t=>{t.type===l.METADATA_LOADED&&this.processMetadata()},this.dataUnit=void 0,this.config=void 0,this.recordsValidator=void 0}validate(){return this._dataBinder.validate()}observeConfig(){this.processMetadata()}getDynamicContent(){var t;const e=N(this._store.getState());if(!e)return null;const s=Array.from(e.getAllSheets().values()),n=function(t){const e=function(t){return t.currentSheet}(t);return e?t.formMetadata.getSheet(e):Array.from(t.formMetadata.getAllSheets().values())[0]}(null===(t=this._store)||void 0===t?void 0:t.getState());let r=[];if(s.length>1){const t=s.map(((t,e)=>({tabKey:t.name,label:t.label,index:e}))),e="selector";r.push(i("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:t=>this._store.dispatch(function(t){return{type:S.CHANGE_TAB,payload:"string"==typeof t?t:t.tabKey}}(t.detail)),selectedTab:n.name,"data-element-id":e}))}return r=r.concat(this.buildFormContent(n)),r}buildFormContent(t){const e=null==t?void 0:t.fields;if(null==t)return;const s=`${d.replaceAccentuatedChars(d.toCamelCase(null==t?void 0:t.label),!1)}_selectorContainer`;return i("div",{class:"dynamic-content","data-element-id":s},i("ez-form-view",{class:"ez-row ez-padding-vertical--small",fields:e}))}processMetadata(){if(!this.isStatic()&&this.dataUnit&&this._store){const t=((t,e,i=!1)=>{var s,n;null!=t&&!0!==(null==t?void 0:t.emptyConfig)||(t=(t=>{const e=t.metadata;let i;return e&&(i=e.fields.filter((t=>!1!==t.visible)).map((t=>({name:t.name,defaultValue:t.defaultValue})))),{emptyConfig:!1,fields:i}})(e));const r=new Map,a=new Map,l=[],h=[],c={};null===(s=null==t?void 0:t.tabs)||void 0===s||s.forEach((t=>{a.has(t.label)||!1!==t.visible||a.set(t.label,t)})),null===(n=null==t?void 0:t.fields)||void 0===n||n.forEach((t=>{var i,s,n;if(!1!==t.visible){const u=((t,e)=>("string"==typeof t?Array.from(e.keys()).find((e=>e.label===t)):t)||{label:t,visible:!0})(t.tab||"__main",r);if(a.has(u.label))return;const d=e.getField(t.name);if(d&&u.visible){r.has(u)||r.set(u,[]);const e=((t,e)=>{let i,s,{name:n,label:r,group:a}=Object.assign({},e),{readOnly:l,required:h}=Object.assign({},e);return t&&(r=r||t.label,n=n||t.name,h=t.required||(null==e?void 0:e.required),l=t.readOnly||(null==e?void 0:e.readOnly),i=t.properties,s=t.userInterface),{name:n,label:r,group:a,readOnly:l,required:h,props:i,userInterface:s||o.SHORTTEXT}})(d,t);r.get(u).push(e),e.required&&l.push(t.name),((null==t.cleanOnCopy?null===(i=d.properties)||void 0===i?void 0:i.cleanOnCopy:t.cleanOnCopy)||(null===(s=d.properties)||void 0===s?void 0:s.cleanOnCopy))&&h.push(t.name);let a=null==t.defaultValue?null===(n=d.properties)||void 0===n?void 0:n.defaultValue:t.defaultValue;if(a){const{type:e,value:i}=a;if(e)if("V"===e)a=i;else try{const t=JSON.parse(i);a=t&&"value"in t?t:i}catch(t){}c[t.name]=a}}}}));const u=new g;if(u.setDefaultVars(t.defaultVars),i){const t=e.metadata;null!=t&&null!=t.children&&t.children.forEach((t=>{const{label:e,name:i,fields:s}=(t=>({name:`child[${t.name}]`,label:t.label,fields:[]}))(t);r.set({name:i,label:e},s)}))}return Array.from(r.entries()).sort(y).forEach((([t,e])=>{u.addSheet({label:"__main"===t.label?"Principal":t.label,name:t.name||t.label,fields:e})})),u.addRequiredFields(l),u.addCleanOnCopyFields(h),u.addDefaultValues(c),u})(this.config,this.dataUnit);this._store.dispatch({type:S.METADATA_LOADED,payload:t})}}isStatic(){var t;return(null===(t=this._staticFields)||void 0===t?void 0:t.length)>0}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new f("ez-form")),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new _(this.dataUnit),this._store=R(z),this._store.subscribe((()=>s(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),v.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){const t=N(this._store.getState());t.addRequiredFields(this._staticFields.filter((t=>t.dataset.required)).map((t=>t.dataset.fieldName))),this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")),this.dataUnit.dataUnitId,t,this.recordsValidator),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(t){return t&&t.forEach((t=>t[v.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=d.toCamelCase(t.label))),t}render(){return i(n,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};x.style=".sc-ez-form-h{display:flex;flex-direction:column;width:100%}.dynamic-content.sc-ez-form ez-collapsible-box.sc-ez-form{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{x as ez_form}
@@ -1 +0,0 @@
1
- const o=" (obrigatório) *",a="ALL_RECORD";export{a as A,o as R}
@@ -1,11 +0,0 @@
1
- import { DataUnit } from "@sankhyalabs/core";
2
- import EzGridController, { EzGridColumn } from "./EzGridController";
3
- export default class DataUnitBridge {
4
- private _gridController;
5
- private _dataUnit;
6
- readonly RECORD_ARCHIVE = "__RECORD_ARCHIVE__";
7
- constructor(gridController: EzGridController, dataUnit: DataUnit);
8
- private processAction;
9
- buildColumnDefs(): Array<EzGridColumn>;
10
- onDisconnectedCallback(): void;
11
- }