@zeedhi/common 1.94.2 → 1.95.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.
@@ -83,6 +83,7 @@ class Component {
83
83
  * Return if component can receive focus using tab
84
84
  */
85
85
  this.tabStop = true;
86
+ this.userProperties = {};
86
87
  this.accessorManager = new AccessorManager();
87
88
  this.parent = props.parent;
88
89
  this.name = props.name;
@@ -96,6 +97,7 @@ class Component {
96
97
  this.dark = this.getInitValue('dark', props.dark, this.dark);
97
98
  this.light = this.getInitValue('light', props.light, this.light);
98
99
  this.tabStop = this.getInitValue('tabStop', props.tabStop, this.tabStop);
100
+ this.userProperties = this.getInitValue('userProperties', props.userProperties, this.userProperties);
99
101
  this.children = Array.isArray(props.children) ? props.children : this.children;
100
102
  this.keyMap = KeyMap.factory(props.keyMap || this.keyMap);
101
103
  this.createAccessors();
@@ -3895,6 +3897,7 @@ class Date$1 extends TextInput {
3895
3897
  this.parserFn = FormatterParserProvider.getParser('ZdDate');
3896
3898
  this.previousHint = '';
3897
3899
  this.previousPersistentHint = false;
3900
+ this.lastChangeValue = null;
3898
3901
  this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
3899
3902
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3900
3903
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
@@ -4025,8 +4028,11 @@ class Date$1 extends TextInput {
4025
4028
  return this.formatISODateValue(this.value);
4026
4029
  }
4027
4030
  set isoValue(newValue) {
4031
+ const lastValue = this.value;
4028
4032
  this.dateError = false;
4029
4033
  this.value = this.parseISODateValue(newValue);
4034
+ if (lastValue !== this.value)
4035
+ this.change(this.value);
4030
4036
  }
4031
4037
  formatISODateValue(value) {
4032
4038
  if (value && this.isValidFormatDate(value, this.dateFormat)) {
@@ -4122,6 +4128,9 @@ class Date$1 extends TextInput {
4122
4128
  }
4123
4129
  }
4124
4130
  change(event, element) {
4131
+ if (this.lastChangeValue && this.lastChangeValue === this.value)
4132
+ return;
4133
+ this.lastChangeValue = this.value;
4125
4134
  super.change(event, element);
4126
4135
  this.helperValue = '';
4127
4136
  this.hint = this.previousHint;
@@ -7203,6 +7212,10 @@ class Image extends ComponentRender {
7203
7212
  this.validImage = true;
7204
7213
  this.srcValue = src;
7205
7214
  }
7215
+ load(event, element) {
7216
+ this.loadImage();
7217
+ this.callEvent('load', { event, element, component: this });
7218
+ }
7206
7219
  }
7207
7220
 
7208
7221
  /**
@@ -8900,6 +8913,8 @@ class Menu extends ComponentRender {
8900
8913
  /** Store the current item focused */
8901
8914
  this.currentItem = null;
8902
8915
  this.cache = false;
8916
+ /** Disable watcher that close menu when route changes */
8917
+ this.disableRouteWatcher = false;
8903
8918
  this.app = this.getInitValue('app', props.app, this.app);
8904
8919
  this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
8905
8920
  this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
@@ -8919,8 +8934,9 @@ class Menu extends ComponentRender {
8919
8934
  this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
8920
8935
  this.width = this.getInitValue('width', props.width, this.width);
8921
8936
  this.cache = this.getInitValue('cache', props.cache, this.cache);
8937
+ this.disableRouteWatcher = this.getInitValue('disableRouteWatcher', props.disableRouteWatcher, this.disableRouteWatcher);
8922
8938
  this.mobileBreakpoint = this.getInitValue('mobileBreakpoint', props.mobileBreakpoint, this.mobileBreakpoint);
8923
- this.drawer = window.innerWidth > this.mobileBreakpoint;
8939
+ this.drawer = window.innerWidth > parseInt(this.mobileBreakpoint.toString(), 10);
8924
8940
  this.openedInitialValue = this.getInitValue('opened', props.opened, this.opened);
8925
8941
  if (this.openedInitialValue !== undefined) {
8926
8942
  this.opened = this.openedInitialValue;
@@ -9001,7 +9017,7 @@ class Menu extends ComponentRender {
9001
9017
  * Toggle menu
9002
9018
  */
9003
9019
  toggleMenu() {
9004
- const isMobile = window.innerWidth <= this.mobileBreakpoint;
9020
+ const isMobile = window.innerWidth <= parseInt(this.mobileBreakpoint.toString(), 10);
9005
9021
  if (this.closeToMini && !isMobile) {
9006
9022
  this.miniState = !this.miniState;
9007
9023
  if (this.miniState) {
@@ -90,6 +90,7 @@
90
90
  * Return if component can receive focus using tab
91
91
  */
92
92
  this.tabStop = true;
93
+ this.userProperties = {};
93
94
  this.accessorManager = new core.AccessorManager();
94
95
  this.parent = props.parent;
95
96
  this.name = props.name;
@@ -103,6 +104,7 @@
103
104
  this.dark = this.getInitValue('dark', props.dark, this.dark);
104
105
  this.light = this.getInitValue('light', props.light, this.light);
105
106
  this.tabStop = this.getInitValue('tabStop', props.tabStop, this.tabStop);
107
+ this.userProperties = this.getInitValue('userProperties', props.userProperties, this.userProperties);
106
108
  this.children = Array.isArray(props.children) ? props.children : this.children;
107
109
  this.keyMap = core.KeyMap.factory(props.keyMap || this.keyMap);
108
110
  this.createAccessors();
@@ -3902,6 +3904,7 @@
3902
3904
  this.parserFn = core.FormatterParserProvider.getParser('ZdDate');
3903
3905
  this.previousHint = '';
3904
3906
  this.previousPersistentHint = false;
3907
+ this.lastChangeValue = null;
3905
3908
  this.allowedDates = this.getInitValue('allowedDates', props.allowedDates, this.allowedDates);
3906
3909
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'calendar');
3907
3910
  this.autocomplete = this.getInitValue('autocomplete', props.autocomplete, this.autocomplete);
@@ -4032,8 +4035,11 @@
4032
4035
  return this.formatISODateValue(this.value);
4033
4036
  }
4034
4037
  set isoValue(newValue) {
4038
+ const lastValue = this.value;
4035
4039
  this.dateError = false;
4036
4040
  this.value = this.parseISODateValue(newValue);
4041
+ if (lastValue !== this.value)
4042
+ this.change(this.value);
4037
4043
  }
4038
4044
  formatISODateValue(value) {
4039
4045
  if (value && this.isValidFormatDate(value, this.dateFormat)) {
@@ -4129,6 +4135,9 @@
4129
4135
  }
4130
4136
  }
4131
4137
  change(event, element) {
4138
+ if (this.lastChangeValue && this.lastChangeValue === this.value)
4139
+ return;
4140
+ this.lastChangeValue = this.value;
4132
4141
  super.change(event, element);
4133
4142
  this.helperValue = '';
4134
4143
  this.hint = this.previousHint;
@@ -7210,6 +7219,10 @@
7210
7219
  this.validImage = true;
7211
7220
  this.srcValue = src;
7212
7221
  }
7222
+ load(event, element) {
7223
+ this.loadImage();
7224
+ this.callEvent('load', { event, element, component: this });
7225
+ }
7213
7226
  }
7214
7227
 
7215
7228
  /**
@@ -8907,6 +8920,8 @@
8907
8920
  /** Store the current item focused */
8908
8921
  this.currentItem = null;
8909
8922
  this.cache = false;
8923
+ /** Disable watcher that close menu when route changes */
8924
+ this.disableRouteWatcher = false;
8910
8925
  this.app = this.getInitValue('app', props.app, this.app);
8911
8926
  this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
8912
8927
  this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
@@ -8926,8 +8941,9 @@
8926
8941
  this.showSearch = this.getInitValue('showSearch', props.showSearch, this.showSearch);
8927
8942
  this.width = this.getInitValue('width', props.width, this.width);
8928
8943
  this.cache = this.getInitValue('cache', props.cache, this.cache);
8944
+ this.disableRouteWatcher = this.getInitValue('disableRouteWatcher', props.disableRouteWatcher, this.disableRouteWatcher);
8929
8945
  this.mobileBreakpoint = this.getInitValue('mobileBreakpoint', props.mobileBreakpoint, this.mobileBreakpoint);
8930
- this.drawer = window.innerWidth > this.mobileBreakpoint;
8946
+ this.drawer = window.innerWidth > parseInt(this.mobileBreakpoint.toString(), 10);
8931
8947
  this.openedInitialValue = this.getInitValue('opened', props.opened, this.opened);
8932
8948
  if (this.openedInitialValue !== undefined) {
8933
8949
  this.opened = this.openedInitialValue;
@@ -9008,7 +9024,7 @@
9008
9024
  * Toggle menu
9009
9025
  */
9010
9026
  toggleMenu() {
9011
- const isMobile = window.innerWidth <= this.mobileBreakpoint;
9027
+ const isMobile = window.innerWidth <= parseInt(this.mobileBreakpoint.toString(), 10);
9012
9028
  if (this.closeToMini && !isMobile) {
9013
9029
  this.miniState = !this.miniState;
9014
9030
  if (this.miniState) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.94.2",
3
+ "version": "1.95.1",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "ac867746a5fc37e3c064682a3557387f6a051cbb"
46
+ "gitHead": "61b544362928fc5b8e27258a628420d31345e6f3"
47
47
  }
@@ -1,4 +1,4 @@
1
- import { IKeyMap } from '@zeedhi/core';
1
+ import { IKeyMap, IDictionary } from '@zeedhi/core';
2
2
  import { IComponent, IComponentDirectives, IComponentEvents } from './interfaces';
3
3
  /**
4
4
  * Base class for all Zeedhi components.
@@ -75,6 +75,7 @@ export declare class Component implements IComponent {
75
75
  * Return if component can receive focus using tab
76
76
  */
77
77
  tabStop: boolean;
78
+ userProperties: IDictionary<any>;
78
79
  /**
79
80
  * Properties accessors to controller.
80
81
  */
@@ -1,4 +1,4 @@
1
- import { IEvent, IEvents, IEventParam, IKeyMap } from '@zeedhi/core';
1
+ import { IEvent, IEvents, IEventParam, IKeyMap, IDictionary } from '@zeedhi/core';
2
2
  import { Component } from './component';
3
3
  export interface IPropAccessor {
4
4
  [key: string]: {
@@ -22,6 +22,7 @@ export interface IComponent {
22
22
  name: string;
23
23
  parent?: Component;
24
24
  tabStop?: boolean;
25
+ userProperties?: IDictionary;
25
26
  [key: string]: any;
26
27
  }
27
28
  export interface IComponentRender extends IComponent {
@@ -146,5 +146,6 @@ export declare class Date extends TextInput implements IDate {
146
146
  private previousHint;
147
147
  private previousPersistentHint;
148
148
  updateHelperHint(): void;
149
+ private lastChangeValue;
149
150
  change(event?: Event, element?: any): void;
150
151
  }
@@ -115,6 +115,7 @@ export declare class Form extends ComponentRender implements IForm {
115
115
  name: string;
116
116
  parent?: import("..").Component | undefined;
117
117
  tabStop?: boolean | undefined;
118
+ userProperties?: IDictionary<any> | undefined;
118
119
  }[];
119
120
  /**
120
121
  * Grid system for each child.
@@ -32,6 +32,7 @@ export declare class GridColumn extends Column implements IGridColumn {
32
32
  name: string;
33
33
  parent?: import("..").Component | undefined;
34
34
  tabStop?: boolean | undefined;
35
+ userProperties?: IDictionary<any> | undefined;
35
36
  }[];
36
37
  /**
37
38
  * Get the Column without the conditions object
@@ -1,4 +1,4 @@
1
- import { IImage } from './interfaces';
1
+ import { IImage, IImageEvents } from './interfaces';
2
2
  import { ComponentRender } from '../zd-component/component-render';
3
3
  /**
4
4
  * The Image component <code>zd-image</code> is used to show images.
@@ -62,6 +62,10 @@ export declare class Image extends ComponentRender implements IImage {
62
62
  */
63
63
  private srcValue;
64
64
  validImage: any;
65
+ /**
66
+ * Defines image events.
67
+ */
68
+ events: IImageEvents;
65
69
  /**
66
70
  * Creates a new Image.
67
71
  * @param props Image properties
@@ -77,4 +81,5 @@ export declare class Image extends ComponentRender implements IImage {
77
81
  errorImage(): void;
78
82
  get src(): string;
79
83
  set src(src: string);
84
+ load(event?: Event, element?: HTMLElement): void;
80
85
  }
@@ -1,7 +1,10 @@
1
1
  import { IEventParam } from '@zeedhi/core';
2
2
  import { Image } from './image';
3
- import { IComponentRender } from '../zd-component/interfaces';
3
+ import { EventDef, IComponentEvents, IComponentRender } from '../zd-component/interfaces';
4
4
  export declare type IImageEvent = IEventParam<Image>;
5
+ export interface IImageEvents<T = IEventParam<any>> extends IComponentEvents<T> {
6
+ load?: EventDef<T>;
7
+ }
5
8
  export interface IImage extends IComponentRender {
6
9
  alt?: string;
7
10
  errorImagePath?: string;
@@ -15,4 +18,5 @@ export interface IImage extends IComponentRender {
15
18
  width?: number | string;
16
19
  maxWidth?: number | string;
17
20
  minWidth?: number | string;
21
+ events?: IImageEvents;
18
22
  }
@@ -27,6 +27,7 @@ export interface IMenu extends IComponentRender {
27
27
  width?: number | string;
28
28
  mobileBreakpoint?: number | string;
29
29
  cache?: boolean;
30
+ disableRouteWatcher?: boolean;
30
31
  }
31
32
  /**
32
33
  * Interface for menu itens
@@ -118,6 +118,8 @@ export declare class Menu extends ComponentRender implements IMenu {
118
118
  /** Store the current item focused */
119
119
  currentItem: IMenuItem | null;
120
120
  cache?: boolean;
121
+ /** Disable watcher that close menu when route changes */
122
+ disableRouteWatcher?: boolean;
121
123
  /**
122
124
  * Creates a new Menu.
123
125
  * @param props Menu properties
@@ -0,0 +1,12 @@
1
+ export interface IJSONObject {
2
+ path: string;
3
+ }
4
+ export declare class JsonCacheService {
5
+ /**
6
+ * jsons collection
7
+ */
8
+ static jsonCollection: IJSONObject[];
9
+ static saveJSONCache(jsonCollection: IJSONObject[]): Promise<void>;
10
+ static getJSONCache(path: string): any;
11
+ static clearJSONCache(jsonCollection: IJSONObject[]): void;
12
+ }