@fto-consult/expo-ui 2.43.1 → 2.43.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.43.1",
3
+ "version": "2.43.2",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1403,8 +1403,9 @@ export default class CommonDatagridComponent extends AppComponent {
1403
1403
  },true);
1404
1404
  },TIMEOUT);
1405
1405
  }
1406
- formatValue(value,format){
1407
- return formatValue(value,format,this.state.abreviateValues);
1406
+ formatValue(value,format,columnField){
1407
+ const formatter = isNonNullString(columnField) && isObj(this.state.columns[columnField]) && typeof this.state.columns[columnField].formatValue =='function' && this.state.columns[columnField].formatValue|| undefined;
1408
+ return formatValue(value,format,this.state.abreviateValues,formatter);
1408
1409
  }
1409
1410
  renderAggregatorFunctionsMenu(){
1410
1411
  const m = this.getAggregatorFunctionsMenuItems(false,false);
@@ -2187,7 +2188,7 @@ export default class CommonDatagridComponent extends AppComponent {
2187
2188
  if(dataLabelFormatter){
2188
2189
  return dataLabelFormatter({value,column,columnDef:column,columnField,serie,serieName,seriesIndex})
2189
2190
  }
2190
- return this.formatValue(value,column.format);
2191
+ return this.formatValue(value,column.format,columnField);
2191
2192
  }
2192
2193
  }),
2193
2194
  title :extendObj(true,{}, {
@@ -2247,7 +2248,7 @@ export default class CommonDatagridComponent extends AppComponent {
2247
2248
  }
2248
2249
  yLabels.formatter = (value)=>{
2249
2250
  const format = (yLabelFormat =='money' || (isDonut && yAxisColumn.format =="money")) || (yLabelsColumn && yLabelsColumn.format =='money') ? 'money' : '';
2250
- return this.formatValue(value,format);
2251
+ return this.formatValue(value,format,yAxisColumn.field);
2251
2252
  }
2252
2253
  chartOptions.chart.id = this.chartIdPrefix+"-"+defaultStr(chartType.key,"no-key");
2253
2254
  if(!chartType.isDonut){
@@ -122,7 +122,8 @@ export const renderRowCell = (arg)=>{
122
122
  renderProps = renderProps.call(context,renderArgs);
123
123
  }
124
124
  if(canFormatValue){
125
- _render = formatValue(_render,columnDef.format,abreviateValues);
125
+ const formatter = typeof columnDef.formatValue =='function'? columnDef.formatValue : undefined;
126
+ _render = formatValue(_render,columnDef.format,abreviateValues,formatter);
126
127
  }
127
128
  if(!renderText && _render && isObj(renderProps)){
128
129
  let Component = defaultVal(renderProps.Component,Label);
@@ -182,12 +183,15 @@ export const renderSelectFieldCell= ({rowData,columnDef,columnField})=>{
182
183
  return _render
183
184
  }
184
185
 
185
- export const formatValue = (value,format,abreviateValues)=>{
186
+ export const formatValue = (value,format,abreviateValues,formatter)=>{
186
187
  if(typeof value !='number') return value;
187
188
  if(typeof value =='boolean'){
188
189
  return value ? "Oui" : "Non";
189
190
  }
190
191
  format = typeof format =='string'? format.toLowerCase().trim() : "";
192
+ if(typeof formatter =='function'){
193
+ return formatter({value,format,abreviateValues,abreviate:abreviateValues});
194
+ }
191
195
  if(format =='money'){
192
196
  return abreviateValues? value.abreviate2FormatMoney() : value.formatMoney();
193
197
  }
@@ -53,9 +53,9 @@ export default class Field extends AppComponent {
53
53
  } = props;
54
54
  Object.defineProperties(this,{
55
55
  type : {value : defaultStr(jsType,type,"text").trim().toLowerCase()},
56
- __disabledSymbol : {value : Symbol('_disabled'),override:false,writable:false},
57
- __isDisabledSymbol : { value : Symbol('_isDisabled'),override:false,writable:false},
58
- __isReadOnlySymbol : { value : Symbol('_isReadOnly'),override:false,writable:false},
56
+ isEditableSymbol : {value : Symbol('isEditableSymbol'),override:false,writable:false},
57
+ ///pour rendre le champ enabled à partir du symbol
58
+ forceEnableSymbol : {value : Symbol('enableSymbol'),override:false,writable:false},
59
59
  isEnabled : {
60
60
  value : ()=>{
61
61
  return !this.isDisabled();
@@ -64,31 +64,69 @@ export default class Field extends AppComponent {
64
64
  isFilter : {
65
65
  value : ()=>defaultVal(renderfilter,render_filter) ? true : false,override : false,writable : false,
66
66
  },
67
- isReadOnly : {
67
+ isEditableBySymbol : {
68
68
  value : ()=>{
69
- return this[this.__isReadOnlySymbol] == true;
70
- },override : false, writable : false
69
+ return !!this[this.isEditableSymbol];
70
+ }
71
+ },
72
+ isEnabledBySymbol : {
73
+ value : ()=>{
74
+ return !!this[this.forceEnableSymbol];
75
+ }
71
76
  },
72
77
  isEditable : {
73
- value : x=> this.isReadOnly(), override : false, writable : false,
78
+ value : ()=>{
79
+ return this.isEditableBySymbol() && this.state.isFieldEditable && !this.state.isReadOnlyOrDisabled && true || false;
80
+ }
81
+ },
82
+ forceEnableBySymbol : {
83
+ value : (toggle)=>{
84
+ if(typeof toggle =='boolean'){
85
+ this[this.forceEnableSymbol] = toggle;
86
+ }
87
+ }
88
+ },
89
+ isReadOnly : {
90
+ value : ()=>{
91
+ return !!this.state.isReadOnlyOrDisabled || !this.isEditableBySymbol();
92
+ },override : false, writable : false
74
93
  },
75
94
  isDisabled : {
76
95
  value : ()=>{
77
- return this[this.__isDisabledSymbol] === true;
96
+ return !!this.state.isReadOnlyOrDisabled || !this.isEditableBySymbol();
78
97
  }, override : false,writable : false
79
98
  }
80
99
  /*** désactive le champ */
81
100
  ,disable : {
82
101
  value : ()=>{
83
- this[this.__disabledSymbol] = true;
84
- this.setState({_sKey:!this.state._sKey})
102
+ this.setState({isReadOnlyOrDisabled:true})
85
103
  }, override : false, writable : false
86
104
  }
87
105
  /**** active le champ */
88
106
  ,enable : {
89
107
  value : () => {
90
- this[this.__disabledSymbol] = false;
91
- this.setState({_sKey:!this.state._sKey});
108
+ this.forceEnableBySymbol(true);
109
+ this.setState({isReadOnlyOrDisabled:false});
110
+ }, override : false, writable : false
111
+ },
112
+ show : {
113
+ value : () => {
114
+ this.setState({isFieldVisible:true})
115
+ }, override : false, writable : false
116
+ },
117
+ hide : {
118
+ value : () => {
119
+ this.setState({isFieldVisible:false})
120
+ }, override : false, writable : false
121
+ },
122
+ isVisible : {
123
+ value : () => {
124
+ return this.state.isFieldVisible;
125
+ }, override : false, writable : false
126
+ },
127
+ isHidden : {
128
+ value : () => {
129
+ return !this.state.isFieldVisible;
92
130
  }, override : false, writable : false
93
131
  },
94
132
  /** si la valeur valide à retourner par le field est de type decimal */
@@ -181,6 +219,9 @@ export default class Field extends AppComponent {
181
219
  this.keybaordEvents = [...Object.keys(defaultKeyboardEvents),...this.keybaordEvents]
182
220
  this.state.isMobile = isMobileMedia();
183
221
  this.state.textFieldMode = theme.textFieldMode;
222
+ this.state.isReadOnlyOrDisabled = false;
223
+ this.state.isFieldEditable = true;
224
+ this.state.isFieldVisible = typeof this.props.visible =='boolean'? this.props.visible : true;
184
225
  }
185
226
  validatorBeforeValidate({value,validRule,validParams,event,...rest}){
186
227
  let _result = undefined;
@@ -813,63 +854,58 @@ export default class Field extends AppComponent {
813
854
  rest.name = this.name;
814
855
  rest.label = label;
815
856
  rest.data = data;
816
-
817
-
818
857
  rest.validRule = rest.validType = this.INITIAL_STATE.validType;
819
858
  rest.validParams = this.INITIAL_STATE.validParams;
820
-
821
- if(!isUndefined(this.___visible)){
822
- visible = this.___visible;
823
- }
824
- this.___visible = undefined;
825
- if(!isUndefined(this[this.__disabledSymbol])){
826
- disabled = this[this.__disabledSymbol];
827
- }
828
-
829
- let callArgs = {context:this,field:this.name,name:this.name,
830
- value:this.validatingValue,//rest.defaultValue,
831
- validValue:this.state.validValue,...rest,data,props:this.props};
832
- readOnly = defaultVal(readOnly);
833
- if(isFunction(readOnly)){
834
- //windowResized spécifie tout simplement que le composant est rendu après rédimensionnemnet de la page
835
- readOnly = readOnly.call(this,callArgs);
836
- }
837
- if(!isUndefined(readOnly)) rest.readOnly = readOnly?true:false;
838
-
839
- if(isFunction(editable)){
840
- editable = editable.call(this,callArgs);
841
- }
842
- if(isBool(editable)) rest.editable = editable;
843
- else rest.editable = rest.readOnly ? false : true;
844
- if(isFunction(disabled)){
845
- disabled = disabled.call(this,callArgs);
846
- }
847
- if(!isBool(disabled)) rest.disabled = disabled;
848
- else rest.disabled = disabled ? true : false;
849
-
850
- if(isFunction(archived)){
851
- archived = archived.call(this,callArgs);
852
- }
853
- if(archived === true){
854
- editable = false;
859
+ if(this.state.isReadOnlyOrDisabled){
855
860
  disabled = true;
856
- }
857
-
858
- if(rest.readOnly || rest.disabled){
861
+ readOnly = true;
862
+ rest.disabled = rest.readOnly = true;
859
863
  rest.editable = false;
860
- }
861
- if(!disabled){
862
- disabled = defaultBool(this.props.disabled,false);
863
- }
864
- rest.disabled = disabled;
864
+ } else if(this.isEnabledBySymbol()){
865
+ rest.disabled = rest.readOnly = false;
866
+ rest.editable = true;
867
+ } else {
868
+ const callArgs = {context:this,field:this.name,name:this.name,value:this.validatingValue,validValue:this.state.validValue,...rest,data,props:this.props};
869
+ readOnly = defaultVal(readOnly);
870
+ if(isFunction(readOnly)){
871
+ readOnly = readOnly.call(this,callArgs);
872
+ }
873
+ if(!isUndefined(readOnly)) readOnly = readOnly?true:false;
874
+ if(isFunction(editable)){
875
+ editable = editable.call(this,callArgs);
876
+ }
877
+ if(isBool(editable)) editable = editable;
878
+ else rest.editable = readOnly ? false : true;
879
+ if(isFunction(disabled)){
880
+ disabled = disabled.call(this,callArgs);
881
+ }
882
+ if(!isBool(disabled)) disabled = disabled ? true : false;
865
883
 
866
- this[this.__isDisabledSymbol] = rest.disabled;
867
- this[this.__isReadOnlySymbol] = rest.readOnly || rest.editable === false ? true : false;
868
-
869
- if(isFunction(visible)){
870
- visible = visible({field:this.name,name:this.name,...rest,value:this.validatingValue,data});
884
+ if(isFunction(archived)){
885
+ archived = archived.call(this,callArgs);
886
+ }
887
+ if(archived === true){
888
+ editable = false;
889
+ disabled = true;
890
+ }
891
+ if(readOnly || disabled){
892
+ editable = false;
893
+ }
894
+ rest.disabled = disabled;
895
+ rest.readOnly = readOnly;
896
+ rest.editable = editable;
897
+ if(disabled || readOnly || !editable){
898
+ this[this.isEditableSymbol] = false;
899
+ }
900
+ }
901
+ if(this.state.isFieldVisible){
902
+ if(isFunction(visible)){
903
+ visible = visible({field:this.name,name:this.name,...rest,value:this.validatingValue,data});
904
+ }
905
+ visible = typeof visible =='boolean'? visible : true;
906
+ } else{
907
+ visible = false;
871
908
  }
872
- visible = defaultVal(visible,true);
873
909
  rest.defaultValue = this.validatingValue;
874
910
  rest.style = [{backgroundColor:'transparent'},rest.style,!visible?{display:'none'}:undefined];
875
911
 
@@ -877,17 +913,14 @@ export default class Field extends AppComponent {
877
913
  if(!isFunction(rest.filter)){
878
914
  delete rest.filter;
879
915
  }
880
-
881
916
  delete rest.export;
882
917
  delete rest.colIndex;
883
918
  delete rest.accordion;
884
919
  delete rest._id;
885
920
  delete rest.import;
886
921
  delete rest.dataFilesInterest;
887
-
888
922
  delete rest.archivable;
889
923
  delete rest.archivable;
890
-
891
924
  this.___formattedField = undefined;
892
925
  let _type = this.type;
893
926
  format = defaultStr(format);
@@ -926,6 +959,7 @@ export default class Field extends AppComponent {
926
959
  }
927
960
  const hasWrapper = !isFilter ? true : false;
928
961
  const wrapperProps = hasWrapper ? Object.assign({},responsiveProps) : {};
962
+ const visibleStyle = !visible && {display:"none",opacity:0};
929
963
  if(hasWrapper){
930
964
  const rP = {};
931
965
  if(_type =='switch' || _type =='checkbox' || _type =='image'){
@@ -938,7 +972,7 @@ export default class Field extends AppComponent {
938
972
  rP.width = "100%";
939
973
  }
940
974
  }
941
- wrapperProps.style = [{marginVertical:10},responsive !== false?grid.col(windowWidth):{width:'100%'},rP,wrapperProps.style];
975
+ wrapperProps.style = [{marginVertical:10},responsive !== false?grid.col(windowWidth):{width:'100%'},rP,wrapperProps.style,visibleStyle];
942
976
  }
943
977
  if(isFunction(getProps)){
944
978
  rest = {...rest,...defaultObj(getProps.call(this,{...rest,context:this}))};
@@ -971,6 +1005,7 @@ export default class Field extends AppComponent {
971
1005
  handleKeys={this.keybaordEvents}
972
1006
  onKeyEvent = {this.onKeyEvent.bind(this)}
973
1007
  isDisabled = {rest.disabled}
1008
+ style = {[wrapperProps.style,visibleStyle]}
974
1009
  >
975
1010
  {(kProps)=>{
976
1011
  return this._render({...rest,...kProps},this.setRef.bind(this))