@zeedhi/common 1.66.0 → 1.68.0

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.
@@ -23,6 +23,10 @@ class Component {
23
23
  * @param props Components properties
24
24
  */
25
25
  constructor(props) {
26
+ /**
27
+ * Automatically add focus to input when it's created.
28
+ */
29
+ this.autofocus = false;
26
30
  /**
27
31
  * Children component structure if the component has children.
28
32
  */
@@ -77,6 +81,7 @@ class Component {
77
81
  this.parent = props.parent;
78
82
  this.name = props.name;
79
83
  this.events = Event.factory(props.events || this.events);
84
+ this.autofocus = this.getInitValue('autofocus', props.autofocus, this.autofocus);
80
85
  this.cssClass = this.getInitValue('cssClass', props.cssClass, this.cssClass);
81
86
  this.cssStyle = this.getInitValue('cssStyle', props.cssStyle, this.cssStyle);
82
87
  this.directives = this.getInitValue('directives', props.directives, this.directives);
@@ -1612,10 +1617,6 @@ class Input extends ComponentRender {
1612
1617
  * Input auto complete.
1613
1618
  */
1614
1619
  this.autofill = true;
1615
- /**
1616
- * Automatically add focus to input when it's created.
1617
- */
1618
- this.autofocus = false;
1619
1620
  /**
1620
1621
  * Add input clear functionality if the input isn't readonly or disabled.
1621
1622
  */
@@ -1704,7 +1705,6 @@ class Input extends ComponentRender {
1704
1705
  this.align = this.getInitValue('align', props.align, this.align);
1705
1706
  this.alwaysShowError = this.getInitValue('alwaysShowError', props.alwaysShowError, this.alwaysShowError);
1706
1707
  this.autofill = this.getInitValue('autofill', props.autofill, this.autofill);
1707
- this.autofocus = this.getInitValue('autofocus', props.autofocus, this.autofocus);
1708
1708
  this.clearable = this.getInitValue('clearable', props.clearable, this.clearable);
1709
1709
  this.color = this.getInitValue('color', props.color, this.color);
1710
1710
  this.dense = this.getInitValue('dense', props.dense, this.dense);
@@ -2948,6 +2948,37 @@ class LoadingService {
2948
2948
  }
2949
2949
  }
2950
2950
 
2951
+ class JsonCacheService {
2952
+ static saveJSONCache(jsonCollection) {
2953
+ return __awaiter(this, void 0, void 0, function* () {
2954
+ const jsonCollectionInCache = jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2955
+ const { path } = jsonItem;
2956
+ const metadata = yield Metadata.get(path, true);
2957
+ localStorage.setItem(path, JSON.stringify(metadata));
2958
+ }));
2959
+ yield Promise.all(jsonCollectionInCache);
2960
+ });
2961
+ }
2962
+ static getJSONCache(path) {
2963
+ const getMetadaFromCache = localStorage.getItem(path);
2964
+ let metadataValueReturn = false;
2965
+ if (typeof getMetadaFromCache === 'string') {
2966
+ metadataValueReturn = JSON.parse(getMetadaFromCache);
2967
+ }
2968
+ return metadataValueReturn;
2969
+ }
2970
+ static clearJSONCache(jsonCollection) {
2971
+ jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2972
+ const { path } = jsonItem;
2973
+ localStorage.removeItem(path);
2974
+ }));
2975
+ }
2976
+ }
2977
+ /**
2978
+ * jsons collection
2979
+ */
2980
+ JsonCacheService.jsonCollection = [];
2981
+
2951
2982
  /**
2952
2983
  * Base class for Dashboard component.
2953
2984
  */
@@ -4042,19 +4073,25 @@ class DateRange extends TextInput {
4042
4073
  const chars = replaced.split('');
4043
4074
  return chars.length ? chars.every((char) => Mask.isMaskDelimiter(char)) : true;
4044
4075
  }
4045
- updateHelperHint() {
4046
- if (this.helperValue) {
4076
+ updateHelperHint(helperValue) {
4077
+ const previousHelperHint = this.helperValue ? DateHelper.getLabel(this.helperValue) : '';
4078
+ if (!this.hint || previousHelperHint !== this.hint) {
4047
4079
  this.previousHint = this.hint;
4048
4080
  this.previousPersistentHint = this.persistentHint;
4049
- this.hint = DateHelper.getLabel(this.helperValue);
4050
- this.persistentHint = true;
4051
4081
  }
4082
+ this.helperValue = helperValue;
4083
+ const label = DateHelper.getLabel(helperValue);
4084
+ if (!helperValue || !label) {
4085
+ this.hint = this.previousHint;
4086
+ this.persistentHint = this.previousPersistentHint;
4087
+ return;
4088
+ }
4089
+ this.hint = label;
4090
+ this.persistentHint = true;
4052
4091
  }
4053
4092
  change(event, element) {
4054
4093
  super.change(event, element);
4055
- this.helperValue = '';
4056
- this.hint = this.previousHint;
4057
- this.persistentHint = this.previousPersistentHint;
4094
+ this.updateHelperHint('');
4058
4095
  }
4059
4096
  getMaskValue() {
4060
4097
  let mask = '';
@@ -4525,6 +4562,7 @@ class Frame extends ComponentRender {
4525
4562
  this.overrideNamedProps = {};
4526
4563
  this.path = '';
4527
4564
  this.cache = false;
4565
+ this.JSONCache = false;
4528
4566
  this.cacheDuration = 2 * 60 * 60 * 1000;
4529
4567
  this.height = 'auto';
4530
4568
  this.maxHeight = 'none';
@@ -4536,6 +4574,7 @@ class Frame extends ComponentRender {
4536
4574
  this.override = props.override || this.override;
4537
4575
  this.overrideNamedProps = props.overrideNamedProps || this.overrideNamedProps;
4538
4576
  this.cache = props.cache || this.cache;
4577
+ this.JSONCache = this.getInitValue('JSONCache', props.JSONCache, this.JSONCache);
4539
4578
  this.cacheDuration = this.getInitValue('cacheDuration', props.cacheDuration, this.cacheDuration);
4540
4579
  this.height = this.getInitValue('height', props.height, this.height);
4541
4580
  this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
@@ -4547,8 +4586,18 @@ class Frame extends ComponentRender {
4547
4586
  }
4548
4587
  getMetadata() {
4549
4588
  return __awaiter(this, void 0, void 0, function* () {
4589
+ let page;
4550
4590
  try {
4551
- const page = yield this.requestPage();
4591
+ if (this.JSONCache) {
4592
+ page = JsonCacheService.getJSONCache(this.path);
4593
+ if (page === false) {
4594
+ yield JsonCacheService.saveJSONCache([{ path: this.path }]);
4595
+ page = yield this.requestPage();
4596
+ }
4597
+ }
4598
+ else {
4599
+ page = yield this.requestPage();
4600
+ }
4552
4601
  if (typeof page !== 'object')
4553
4602
  throw new Error();
4554
4603
  this.metadata = merge(page, this.override);
@@ -7871,6 +7920,10 @@ class Menu extends ComponentRender {
7871
7920
  * Defines if the menu is an application menu
7872
7921
  */
7873
7922
  this.app = false;
7923
+ /**
7924
+ * Defines if the menu must be rendered inside an absolute div
7925
+ */
7926
+ this.absolute = false;
7874
7927
  /**
7875
7928
  * Defines if the menu should rests under the application toolbar
7876
7929
  */
@@ -7964,6 +8017,7 @@ class Menu extends ComponentRender {
7964
8017
  /** Store the current item focused */
7965
8018
  this.currentItem = null;
7966
8019
  this.app = this.getInitValue('app', props.app, this.app);
8020
+ this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
7967
8021
  this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
7968
8022
  this.fixed = this.getInitValue('fixed', props.fixed, this.fixed);
7969
8023
  this.floating = this.getInitValue('floating', props.floating, this.floating);
@@ -9230,6 +9284,7 @@ class TreeDataStructure {
9230
9284
  this.parentField = tree.parentField;
9231
9285
  this.fetchOnDemand = tree.fetchOnDemand;
9232
9286
  this.openLevelOnLoad = tree.openLevelOnLoad;
9287
+ this.tree = tree;
9233
9288
  this.init();
9234
9289
  }
9235
9290
  /**
@@ -9249,20 +9304,20 @@ class TreeDataStructure {
9249
9304
  this.searchValue = this.originalDatasource.search;
9250
9305
  this.searchHasNoData = false;
9251
9306
  if (this.fetchOnDemand) {
9252
- if (this.originalDatasource.search) {
9307
+ if (this.tree.detach || this.originalDatasource.search) {
9253
9308
  delete this.originalDatasource.filter[this.parentField];
9254
9309
  }
9255
9310
  else if (!this.originalDatasource.filter[this.parentField]) {
9256
9311
  this.originalDatasource.filter[this.parentField] = 'NULL';
9257
9312
  }
9258
9313
  }
9259
- if (!this.fetchOnDemand && this.searchValue) {
9314
+ if (!this.tree.detach && !this.fetchOnDemand && this.searchValue) {
9260
9315
  this.searchAllData();
9261
9316
  return Promise.resolve(this.originalDatasource.data);
9262
9317
  }
9263
9318
  return originalGet.call(this.originalDatasource).then((data) => {
9264
9319
  if (this.searchValue) {
9265
- this.searchOnDemand();
9320
+ this.buildDetached();
9266
9321
  }
9267
9322
  else {
9268
9323
  this.buildTree();
@@ -9275,7 +9330,10 @@ class TreeDataStructure {
9275
9330
  * search data
9276
9331
  */
9277
9332
  buildTree() {
9278
- if (this.fetchOnDemand) {
9333
+ if (this.tree.detach) {
9334
+ this.buildDetached();
9335
+ }
9336
+ else if (this.fetchOnDemand) {
9279
9337
  this.buildOnDemand();
9280
9338
  }
9281
9339
  else {
@@ -9528,13 +9586,12 @@ class TreeDataStructure {
9528
9586
  });
9529
9587
  }
9530
9588
  /**
9531
- * Search tree with fetchOnDemand
9532
- * @param data datasource data
9589
+ * Arrange treeData in a uniform structure
9533
9590
  */
9534
- searchOnDemand() {
9591
+ buildDetached() {
9535
9592
  this.treeData = [];
9536
9593
  this.treeStructure = {};
9537
- const childData = this.originalDatasource.data.map((row) => (Object.assign(Object.assign({}, row), { tree__children: [], tree__opened: false, tree__searched: true, tree__level: 1, tree__parent: undefined })));
9594
+ const childData = this.originalDatasource.data.map((row) => (Object.assign(Object.assign({}, row), { tree__children: [], tree__opened: false, tree__searched: !!this.searchValue, tree__level: 1, tree__parent: undefined })));
9538
9595
  this.treeData = childData;
9539
9596
  this.treeStructure['no-parent'] = childData;
9540
9597
  }
@@ -10999,11 +11056,15 @@ class Tooltip extends ComponentRender {
10999
11056
  */
11000
11057
  this.nudge = 0;
11001
11058
  /**
11002
- * Nudge the content to the top
11059
+ * Open the tooltip on activator click
11003
11060
  */
11004
11061
  this.openOnClick = false;
11005
11062
  /**
11006
- * Nudge the content to the top
11063
+ * Open the tooltip on activator focus
11064
+ */
11065
+ this.openOnFocus = true;
11066
+ /**
11067
+ * Open the tooltip on activator hover
11007
11068
  */
11008
11069
  this.openOnHover = true;
11009
11070
  /**
@@ -11023,6 +11084,7 @@ class Tooltip extends ComponentRender {
11023
11084
  this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
11024
11085
  this.nudge = this.getInitValue('nudge', props.nudge, this.nudge);
11025
11086
  this.openOnClick = this.getInitValue('openOnClick', props.openOnClick, this.openOnClick);
11087
+ this.openOnFocus = this.getInitValue('openOnFocus', props.openOnFocus, this.openOnFocus);
11026
11088
  this.openOnHover = this.getInitValue('openOnHover', props.openOnHover, this.openOnHover);
11027
11089
  this.right = this.getInitValue('right', props.right, this.right);
11028
11090
  this.top = this.getInitValue('top', props.top, this.top);
@@ -11452,6 +11514,10 @@ class TreeGrid extends Grid {
11452
11514
  * Even though all children are selected, the parent node is not
11453
11515
  */
11454
11516
  this.flat = false;
11517
+ /**
11518
+ * Display the rows detached from their parents
11519
+ */
11520
+ this.detach = false;
11455
11521
  this.navigationTreeKeyMapping = {
11456
11522
  right: {
11457
11523
  event: this.navigateToggle.bind(this, false),
@@ -11469,6 +11535,7 @@ class TreeGrid extends Grid {
11469
11535
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
11470
11536
  this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
11471
11537
  this.flat = this.getInitValue('flat', props.flat, this.flat);
11538
+ this.detach = this.getInitValue('detach', props.detach, this.detach);
11472
11539
  this.treeDataStructure = new TreeDataStructure(this);
11473
11540
  this.createAccessors();
11474
11541
  }
@@ -11483,17 +11550,15 @@ class TreeGrid extends Grid {
11483
11550
  * Build tree data
11484
11551
  */
11485
11552
  buildTree(doGet = true) {
11486
- if (doGet) {
11487
- if (this.fetchOnDemand) {
11488
- this.datasource.addFilter(this.parentField, 'NULL');
11489
- }
11490
- else {
11491
- this.datasource.get();
11492
- }
11493
- }
11494
- else {
11553
+ if (!doGet) {
11495
11554
  this.treeDataStructure.buildTree();
11555
+ return;
11556
+ }
11557
+ if (!this.fetchOnDemand) {
11558
+ this.datasource.get();
11559
+ return;
11496
11560
  }
11561
+ this.datasource.addFilter(this.parentField, 'NULL');
11497
11562
  }
11498
11563
  /**
11499
11564
  * This function takes an array of objects and updates the data in the tree.
@@ -13299,4 +13364,4 @@ const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
13299
13364
  const packageContent = require('../package.json');
13300
13365
  VersionService.addPackageVersion(packageContent.name, packageContent.version);
13301
13366
 
13302
- export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, Header, Icon, Icons, Image, Increment, Input, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
13367
+ export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, Header, Icon, Icons, Image, Increment, Input, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, JsonCacheService, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
@@ -30,6 +30,10 @@
30
30
  * @param props Components properties
31
31
  */
32
32
  constructor(props) {
33
+ /**
34
+ * Automatically add focus to input when it's created.
35
+ */
36
+ this.autofocus = false;
33
37
  /**
34
38
  * Children component structure if the component has children.
35
39
  */
@@ -84,6 +88,7 @@
84
88
  this.parent = props.parent;
85
89
  this.name = props.name;
86
90
  this.events = core.Event.factory(props.events || this.events);
91
+ this.autofocus = this.getInitValue('autofocus', props.autofocus, this.autofocus);
87
92
  this.cssClass = this.getInitValue('cssClass', props.cssClass, this.cssClass);
88
93
  this.cssStyle = this.getInitValue('cssStyle', props.cssStyle, this.cssStyle);
89
94
  this.directives = this.getInitValue('directives', props.directives, this.directives);
@@ -1619,10 +1624,6 @@
1619
1624
  * Input auto complete.
1620
1625
  */
1621
1626
  this.autofill = true;
1622
- /**
1623
- * Automatically add focus to input when it's created.
1624
- */
1625
- this.autofocus = false;
1626
1627
  /**
1627
1628
  * Add input clear functionality if the input isn't readonly or disabled.
1628
1629
  */
@@ -1711,7 +1712,6 @@
1711
1712
  this.align = this.getInitValue('align', props.align, this.align);
1712
1713
  this.alwaysShowError = this.getInitValue('alwaysShowError', props.alwaysShowError, this.alwaysShowError);
1713
1714
  this.autofill = this.getInitValue('autofill', props.autofill, this.autofill);
1714
- this.autofocus = this.getInitValue('autofocus', props.autofocus, this.autofocus);
1715
1715
  this.clearable = this.getInitValue('clearable', props.clearable, this.clearable);
1716
1716
  this.color = this.getInitValue('color', props.color, this.color);
1717
1717
  this.dense = this.getInitValue('dense', props.dense, this.dense);
@@ -2955,6 +2955,37 @@
2955
2955
  }
2956
2956
  }
2957
2957
 
2958
+ class JsonCacheService {
2959
+ static saveJSONCache(jsonCollection) {
2960
+ return __awaiter(this, void 0, void 0, function* () {
2961
+ const jsonCollectionInCache = jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2962
+ const { path } = jsonItem;
2963
+ const metadata = yield core.Metadata.get(path, true);
2964
+ localStorage.setItem(path, JSON.stringify(metadata));
2965
+ }));
2966
+ yield Promise.all(jsonCollectionInCache);
2967
+ });
2968
+ }
2969
+ static getJSONCache(path) {
2970
+ const getMetadaFromCache = localStorage.getItem(path);
2971
+ let metadataValueReturn = false;
2972
+ if (typeof getMetadaFromCache === 'string') {
2973
+ metadataValueReturn = JSON.parse(getMetadaFromCache);
2974
+ }
2975
+ return metadataValueReturn;
2976
+ }
2977
+ static clearJSONCache(jsonCollection) {
2978
+ jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2979
+ const { path } = jsonItem;
2980
+ localStorage.removeItem(path);
2981
+ }));
2982
+ }
2983
+ }
2984
+ /**
2985
+ * jsons collection
2986
+ */
2987
+ JsonCacheService.jsonCollection = [];
2988
+
2958
2989
  /**
2959
2990
  * Base class for Dashboard component.
2960
2991
  */
@@ -4049,19 +4080,25 @@
4049
4080
  const chars = replaced.split('');
4050
4081
  return chars.length ? chars.every((char) => core.Mask.isMaskDelimiter(char)) : true;
4051
4082
  }
4052
- updateHelperHint() {
4053
- if (this.helperValue) {
4083
+ updateHelperHint(helperValue) {
4084
+ const previousHelperHint = this.helperValue ? core.DateHelper.getLabel(this.helperValue) : '';
4085
+ if (!this.hint || previousHelperHint !== this.hint) {
4054
4086
  this.previousHint = this.hint;
4055
4087
  this.previousPersistentHint = this.persistentHint;
4056
- this.hint = core.DateHelper.getLabel(this.helperValue);
4057
- this.persistentHint = true;
4058
4088
  }
4089
+ this.helperValue = helperValue;
4090
+ const label = core.DateHelper.getLabel(helperValue);
4091
+ if (!helperValue || !label) {
4092
+ this.hint = this.previousHint;
4093
+ this.persistentHint = this.previousPersistentHint;
4094
+ return;
4095
+ }
4096
+ this.hint = label;
4097
+ this.persistentHint = true;
4059
4098
  }
4060
4099
  change(event, element) {
4061
4100
  super.change(event, element);
4062
- this.helperValue = '';
4063
- this.hint = this.previousHint;
4064
- this.persistentHint = this.previousPersistentHint;
4101
+ this.updateHelperHint('');
4065
4102
  }
4066
4103
  getMaskValue() {
4067
4104
  let mask = '';
@@ -4532,6 +4569,7 @@
4532
4569
  this.overrideNamedProps = {};
4533
4570
  this.path = '';
4534
4571
  this.cache = false;
4572
+ this.JSONCache = false;
4535
4573
  this.cacheDuration = 2 * 60 * 60 * 1000;
4536
4574
  this.height = 'auto';
4537
4575
  this.maxHeight = 'none';
@@ -4543,6 +4581,7 @@
4543
4581
  this.override = props.override || this.override;
4544
4582
  this.overrideNamedProps = props.overrideNamedProps || this.overrideNamedProps;
4545
4583
  this.cache = props.cache || this.cache;
4584
+ this.JSONCache = this.getInitValue('JSONCache', props.JSONCache, this.JSONCache);
4546
4585
  this.cacheDuration = this.getInitValue('cacheDuration', props.cacheDuration, this.cacheDuration);
4547
4586
  this.height = this.getInitValue('height', props.height, this.height);
4548
4587
  this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
@@ -4554,8 +4593,18 @@
4554
4593
  }
4555
4594
  getMetadata() {
4556
4595
  return __awaiter(this, void 0, void 0, function* () {
4596
+ let page;
4557
4597
  try {
4558
- const page = yield this.requestPage();
4598
+ if (this.JSONCache) {
4599
+ page = JsonCacheService.getJSONCache(this.path);
4600
+ if (page === false) {
4601
+ yield JsonCacheService.saveJSONCache([{ path: this.path }]);
4602
+ page = yield this.requestPage();
4603
+ }
4604
+ }
4605
+ else {
4606
+ page = yield this.requestPage();
4607
+ }
4559
4608
  if (typeof page !== 'object')
4560
4609
  throw new Error();
4561
4610
  this.metadata = merge__default["default"](page, this.override);
@@ -7878,6 +7927,10 @@
7878
7927
  * Defines if the menu is an application menu
7879
7928
  */
7880
7929
  this.app = false;
7930
+ /**
7931
+ * Defines if the menu must be rendered inside an absolute div
7932
+ */
7933
+ this.absolute = false;
7881
7934
  /**
7882
7935
  * Defines if the menu should rests under the application toolbar
7883
7936
  */
@@ -7971,6 +8024,7 @@
7971
8024
  /** Store the current item focused */
7972
8025
  this.currentItem = null;
7973
8026
  this.app = this.getInitValue('app', props.app, this.app);
8027
+ this.absolute = this.getInitValue('absolute', props.absolute, this.absolute);
7974
8028
  this.clipped = this.getInitValue('clipped', props.clipped, this.clipped);
7975
8029
  this.fixed = this.getInitValue('fixed', props.fixed, this.fixed);
7976
8030
  this.floating = this.getInitValue('floating', props.floating, this.floating);
@@ -9237,6 +9291,7 @@
9237
9291
  this.parentField = tree.parentField;
9238
9292
  this.fetchOnDemand = tree.fetchOnDemand;
9239
9293
  this.openLevelOnLoad = tree.openLevelOnLoad;
9294
+ this.tree = tree;
9240
9295
  this.init();
9241
9296
  }
9242
9297
  /**
@@ -9256,20 +9311,20 @@
9256
9311
  this.searchValue = this.originalDatasource.search;
9257
9312
  this.searchHasNoData = false;
9258
9313
  if (this.fetchOnDemand) {
9259
- if (this.originalDatasource.search) {
9314
+ if (this.tree.detach || this.originalDatasource.search) {
9260
9315
  delete this.originalDatasource.filter[this.parentField];
9261
9316
  }
9262
9317
  else if (!this.originalDatasource.filter[this.parentField]) {
9263
9318
  this.originalDatasource.filter[this.parentField] = 'NULL';
9264
9319
  }
9265
9320
  }
9266
- if (!this.fetchOnDemand && this.searchValue) {
9321
+ if (!this.tree.detach && !this.fetchOnDemand && this.searchValue) {
9267
9322
  this.searchAllData();
9268
9323
  return Promise.resolve(this.originalDatasource.data);
9269
9324
  }
9270
9325
  return originalGet.call(this.originalDatasource).then((data) => {
9271
9326
  if (this.searchValue) {
9272
- this.searchOnDemand();
9327
+ this.buildDetached();
9273
9328
  }
9274
9329
  else {
9275
9330
  this.buildTree();
@@ -9282,7 +9337,10 @@
9282
9337
  * search data
9283
9338
  */
9284
9339
  buildTree() {
9285
- if (this.fetchOnDemand) {
9340
+ if (this.tree.detach) {
9341
+ this.buildDetached();
9342
+ }
9343
+ else if (this.fetchOnDemand) {
9286
9344
  this.buildOnDemand();
9287
9345
  }
9288
9346
  else {
@@ -9535,13 +9593,12 @@
9535
9593
  });
9536
9594
  }
9537
9595
  /**
9538
- * Search tree with fetchOnDemand
9539
- * @param data datasource data
9596
+ * Arrange treeData in a uniform structure
9540
9597
  */
9541
- searchOnDemand() {
9598
+ buildDetached() {
9542
9599
  this.treeData = [];
9543
9600
  this.treeStructure = {};
9544
- const childData = this.originalDatasource.data.map((row) => (Object.assign(Object.assign({}, row), { tree__children: [], tree__opened: false, tree__searched: true, tree__level: 1, tree__parent: undefined })));
9601
+ const childData = this.originalDatasource.data.map((row) => (Object.assign(Object.assign({}, row), { tree__children: [], tree__opened: false, tree__searched: !!this.searchValue, tree__level: 1, tree__parent: undefined })));
9545
9602
  this.treeData = childData;
9546
9603
  this.treeStructure['no-parent'] = childData;
9547
9604
  }
@@ -11006,11 +11063,15 @@
11006
11063
  */
11007
11064
  this.nudge = 0;
11008
11065
  /**
11009
- * Nudge the content to the top
11066
+ * Open the tooltip on activator click
11010
11067
  */
11011
11068
  this.openOnClick = false;
11012
11069
  /**
11013
- * Nudge the content to the top
11070
+ * Open the tooltip on activator focus
11071
+ */
11072
+ this.openOnFocus = true;
11073
+ /**
11074
+ * Open the tooltip on activator hover
11014
11075
  */
11015
11076
  this.openOnHover = true;
11016
11077
  /**
@@ -11030,6 +11091,7 @@
11030
11091
  this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
11031
11092
  this.nudge = this.getInitValue('nudge', props.nudge, this.nudge);
11032
11093
  this.openOnClick = this.getInitValue('openOnClick', props.openOnClick, this.openOnClick);
11094
+ this.openOnFocus = this.getInitValue('openOnFocus', props.openOnFocus, this.openOnFocus);
11033
11095
  this.openOnHover = this.getInitValue('openOnHover', props.openOnHover, this.openOnHover);
11034
11096
  this.right = this.getInitValue('right', props.right, this.right);
11035
11097
  this.top = this.getInitValue('top', props.top, this.top);
@@ -11459,6 +11521,10 @@
11459
11521
  * Even though all children are selected, the parent node is not
11460
11522
  */
11461
11523
  this.flat = false;
11524
+ /**
11525
+ * Display the rows detached from their parents
11526
+ */
11527
+ this.detach = false;
11462
11528
  this.navigationTreeKeyMapping = {
11463
11529
  right: {
11464
11530
  event: this.navigateToggle.bind(this, false),
@@ -11476,6 +11542,7 @@
11476
11542
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
11477
11543
  this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
11478
11544
  this.flat = this.getInitValue('flat', props.flat, this.flat);
11545
+ this.detach = this.getInitValue('detach', props.detach, this.detach);
11479
11546
  this.treeDataStructure = new TreeDataStructure(this);
11480
11547
  this.createAccessors();
11481
11548
  }
@@ -11490,17 +11557,15 @@
11490
11557
  * Build tree data
11491
11558
  */
11492
11559
  buildTree(doGet = true) {
11493
- if (doGet) {
11494
- if (this.fetchOnDemand) {
11495
- this.datasource.addFilter(this.parentField, 'NULL');
11496
- }
11497
- else {
11498
- this.datasource.get();
11499
- }
11500
- }
11501
- else {
11560
+ if (!doGet) {
11502
11561
  this.treeDataStructure.buildTree();
11562
+ return;
11563
+ }
11564
+ if (!this.fetchOnDemand) {
11565
+ this.datasource.get();
11566
+ return;
11503
11567
  }
11568
+ this.datasource.addFilter(this.parentField, 'NULL');
11504
11569
  }
11505
11570
  /**
11506
11571
  * This function takes an array of objects and updates the data in the tree.
@@ -13360,6 +13425,7 @@
13360
13425
  exports.IterablePageInfo = IterablePageInfo;
13361
13426
  exports.IterablePageSize = IterablePageSize;
13362
13427
  exports.IterablePagination = IterablePagination;
13428
+ exports.JsonCacheService = JsonCacheService;
13363
13429
  exports.List = List;
13364
13430
  exports.ListGroup = ListGroup;
13365
13431
  exports.ListItem = ListItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.66.0",
3
+ "version": "1.68.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -39,5 +39,5 @@
39
39
  "lodash.times": "^4.3.2",
40
40
  "mockdate": "^3.0.2"
41
41
  },
42
- "gitHead": "e7d698eaa1de2b4158b12f383ffddd2707b31340"
42
+ "gitHead": "84cc6c01ee3c9aab7566b333f73e2aac50ad5c4f"
43
43
  }
@@ -4,6 +4,10 @@ import { IComponent, IComponentDirectives, IComponentEvents } from './interfaces
4
4
  * Base class for all Zeedhi components.
5
5
  */
6
6
  export declare class Component implements IComponent {
7
+ /**
8
+ * Automatically add focus to input when it's created.
9
+ */
10
+ autofocus: boolean;
7
11
  /**
8
12
  * Children component structure if the component has children.
9
13
  */
@@ -7,6 +7,7 @@ export interface IPropAccessor {
7
7
  };
8
8
  }
9
9
  export interface IComponent {
10
+ autofocus?: boolean;
10
11
  children?: IComponent[];
11
12
  componentId?: number;
12
13
  cssClass?: string;
@@ -127,7 +127,7 @@ export declare class DateRange extends TextInput implements IDateRange {
127
127
  protected isSimpleFormat(format: string): boolean;
128
128
  private previousHint;
129
129
  private previousPersistentHint;
130
- updateHelperHint(): void;
130
+ updateHelperHint(helperValue: string): void;
131
131
  change(event?: Event, element?: any): void;
132
132
  getMaskValue(): any;
133
133
  }
@@ -71,12 +71,16 @@ export declare class Form extends ComponentRender implements IForm {
71
71
  [key: string]: any;
72
72
  children?: import("..").IComponentRender[] | undefined;
73
73
  component: string;
74
+ autofocus?: boolean | undefined;
74
75
  componentId?: number | undefined;
75
76
  cssClass?: string | undefined;
76
77
  cssStyle?: string | object | undefined;
77
78
  events?: import("..").IComponentEvents<import("@zeedhi/core").IEventParam<any>> | undefined;
78
79
  directives?: import("..").IComponentDirectives | undefined;
79
- isVisible?: string | boolean | undefined;
80
+ isVisible?: string | boolean | undefined; /**
81
+ * Applies the align-items css property.
82
+ * Available options are start, center, end, space-between, space-around and stretch.
83
+ */
80
84
  dark?: boolean | undefined;
81
85
  light?: boolean | undefined;
82
86
  keyMap?: import("@zeedhi/core").IKeyMap<import("@zeedhi/core").IEventParam<any>> | undefined;
@@ -12,6 +12,7 @@ export declare class Frame extends ComponentRender implements IFrame {
12
12
  overrideNamedProps: any;
13
13
  path: string;
14
14
  cache: boolean;
15
+ JSONCache: boolean | string;
15
16
  events: IFrameEvents;
16
17
  cacheDuration: number;
17
18
  height: number | string;
@@ -12,6 +12,7 @@ export interface IFrame extends IComponentRender {
12
12
  params?: any;
13
13
  overrideNamedProps?: any;
14
14
  cache?: boolean;
15
+ JSONCache?: boolean | string;
15
16
  cacheDuration?: number;
16
17
  height?: number | string;
17
18
  maxHeight?: number | string;
@@ -18,6 +18,7 @@ export declare class GridColumn extends Column implements IGridColumn {
18
18
  [key: string]: any;
19
19
  children?: import("..").IComponentRender[] | undefined;
20
20
  component: string;
21
+ autofocus?: boolean | undefined;
21
22
  componentId?: number | undefined;
22
23
  cssClass?: string | undefined;
23
24
  cssStyle?: string | object | undefined;
@@ -27,10 +28,7 @@ export declare class GridColumn extends Column implements IGridColumn {
27
28
  dark?: boolean | undefined;
28
29
  light?: boolean | undefined;
29
30
  keyMap?: import("@zeedhi/core").IKeyMap<import("@zeedhi/core").IEventParam<any>> | undefined;
30
- name: string; /**
31
- * Creates a new Grid Column.
32
- * @param props Grid column properties
33
- */
31
+ name: string;
34
32
  parent?: import("..").Component | undefined;
35
33
  tabStop?: boolean | undefined;
36
34
  }[];
@@ -17,10 +17,6 @@ export declare class Input extends ComponentRender implements IInput {
17
17
  * Input auto complete.
18
18
  */
19
19
  autofill: boolean;
20
- /**
21
- * Automatically add focus to input when it's created.
22
- */
23
- autofocus: boolean;
24
20
  /**
25
21
  * Add input clear functionality if the input isn't readonly or disabled.
26
22
  */
@@ -12,7 +12,6 @@ export interface IInput extends IComponentRender {
12
12
  align?: string;
13
13
  alwaysShowError?: boolean;
14
14
  autofill?: boolean;
15
- autofocus?: boolean;
16
15
  clearable?: boolean;
17
16
  color?: string;
18
17
  dark?: boolean;
@@ -9,6 +9,7 @@ export declare type IMenuLinkEvents = IComponentEvents<IMenuLinkEvent>;
9
9
  */
10
10
  export interface IMenu extends IComponentRender {
11
11
  app?: boolean | string;
12
+ absolute?: boolean | string;
12
13
  clipped?: boolean | string;
13
14
  dense?: boolean | string;
14
15
  fixed?: boolean | string;
@@ -9,6 +9,10 @@ export declare class Menu extends ComponentRender implements IMenu {
9
9
  * Defines if the menu is an application menu
10
10
  */
11
11
  app: boolean | string;
12
+ /**
13
+ * Defines if the menu must be rendered inside an absolute div
14
+ */
15
+ absolute: boolean | string;
12
16
  /**
13
17
  * Defines if the menu should rests under the application toolbar
14
18
  */
@@ -12,6 +12,7 @@ export interface ITooltip extends IComponentRender {
12
12
  minWidth?: number | string;
13
13
  nudge?: number | string;
14
14
  openOnClick?: boolean;
15
+ openOnFocus?: boolean;
15
16
  openOnHover?: boolean;
16
17
  right?: boolean;
17
18
  top?: boolean;
@@ -34,11 +34,15 @@ export declare class Tooltip extends ComponentRender implements ITooltip {
34
34
  */
35
35
  nudge: number | string;
36
36
  /**
37
- * Nudge the content to the top
37
+ * Open the tooltip on activator click
38
38
  */
39
39
  openOnClick: boolean;
40
40
  /**
41
- * Nudge the content to the top
41
+ * Open the tooltip on activator focus
42
+ */
43
+ openOnFocus: boolean;
44
+ /**
45
+ * Open the tooltip on activator hover
42
46
  */
43
47
  openOnHover: boolean;
44
48
  /**
@@ -6,6 +6,7 @@ export interface ITreeGrid extends IGrid {
6
6
  openLevelOnLoad?: number | boolean;
7
7
  fetchOnDemand?: boolean;
8
8
  flat?: boolean;
9
+ detach?: boolean;
9
10
  }
10
11
  export interface ITreeGridEditable extends ITreeGrid {
11
12
  columns?: IGridColumnEditable[];
@@ -35,6 +35,10 @@ export declare class TreeGrid extends Grid implements ITreeGrid {
35
35
  * Even though all children are selected, the parent node is not
36
36
  */
37
37
  flat: boolean;
38
+ /**
39
+ * Display the rows detached from their parents
40
+ */
41
+ detach: boolean;
38
42
  viewUpdateScrollData?: () => void;
39
43
  /**
40
44
  * Creates a new Tree Grid.
@@ -2,3 +2,4 @@ export * from './zd-alert/alert-service';
2
2
  export * from './zd-dialog/dialog-service';
3
3
  export * from './zd-modal/modal-service';
4
4
  export * from './zd-loading/loading-service';
5
+ export * from './zd-json-cache/json-cache-service';
@@ -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
+ }
@@ -4,4 +4,5 @@ export interface ITreeDataStructure {
4
4
  parentField: string;
5
5
  openLevelOnLoad: number | boolean;
6
6
  fetchOnDemand: boolean;
7
+ detach?: boolean;
7
8
  }
@@ -29,6 +29,10 @@ export declare class TreeDataStructure {
29
29
  * Stores tree structure
30
30
  */
31
31
  private treeStructure;
32
+ /**
33
+ * Tree component
34
+ */
35
+ private tree;
32
36
  constructor(tree: ITreeDataStructure);
33
37
  /**
34
38
  * Creates properties and methods
@@ -122,10 +126,9 @@ export declare class TreeDataStructure {
122
126
  */
123
127
  private reloadAndUpdateSelectedRows;
124
128
  /**
125
- * Search tree with fetchOnDemand
126
- * @param data datasource data
129
+ * Arrange treeData in a uniform structure
127
130
  */
128
- private searchOnDemand;
131
+ buildDetached(): void;
129
132
  /**
130
133
  * Search value against a memory datasource
131
134
  */