@zeedhi/common 1.85.0 → 1.85.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.
@@ -5604,6 +5604,17 @@ class Iterable extends ComponentRender {
5604
5604
  }
5605
5605
  }
5606
5606
 
5607
+ /**
5608
+ * Delete rows error
5609
+ */
5610
+ class DeleteRowsError extends Error {
5611
+ constructor() {
5612
+ super('Grid can\'t automatically delete rows when selectAllPages property is true.'
5613
+ + ' You should delete them manually');
5614
+ this.name = 'DeleteRowsError';
5615
+ }
5616
+ }
5617
+
5607
5618
  /**
5608
5619
  * Base class for Grid column
5609
5620
  */
@@ -5766,17 +5777,6 @@ const toggleableFormatter = ({ value, componentProps }) => {
5766
5777
  FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
5767
5778
  FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
5768
5779
 
5769
- /**
5770
- * Delete rows error
5771
- */
5772
- class DeleteRowsError extends Error {
5773
- constructor() {
5774
- super('Grid can\'t automatically delete rows when selectAllPages property is true.'
5775
- + ' You should delete them manually');
5776
- this.name = 'DeleteRowsError';
5777
- }
5778
- }
5779
-
5780
5780
  /**
5781
5781
  * Base class for Grid component
5782
5782
  */
@@ -6218,16 +6218,9 @@ class Grid extends Iterable {
6218
6218
  const compName = actionComponent.name;
6219
6219
  const instanceName = `${compName}_${rowKey}`;
6220
6220
  const path = parentPath ? `${parentPath}.${compName}` : compName;
6221
- const props = merge({}, actionComponent, (_b = (_a = this.actionsApplied[rowKey]) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b[path]);
6222
- let newClickEvt;
6223
- if ((_c = props.events) === null || _c === void 0 ? void 0 : _c.click) {
6224
- const compEvents = Event.factory(props.events);
6225
- if (typeof compEvents.click === 'function') {
6226
- newClickEvt = ({ component, event, element }) => compEvents.click({
6227
- component, event, element, row, column,
6228
- });
6229
- }
6230
- }
6221
+ const compActivator = (_a = actionComponent.activator) !== null && _a !== void 0 ? _a : undefined;
6222
+ const props = merge({}, actionComponent, (_c = (_b = this.actionsApplied[rowKey]) === null || _b === void 0 ? void 0 : _b[column.name]) === null || _c === void 0 ? void 0 : _c[path]);
6223
+ const newClickEvt = this.setGridRowsInEvents(props, column, row);
6231
6224
  const children = props.children || [];
6232
6225
  const newChildren = children.map((child) => this.getActionProps(child, column, row, path).props);
6233
6226
  props.children = newChildren;
@@ -6247,6 +6240,12 @@ class Grid extends Iterable {
6247
6240
  }
6248
6241
  if (newClickEvt)
6249
6242
  props.events.click = newClickEvt;
6243
+ if (compActivator) {
6244
+ const newActivatorClickEvt = this.setGridRowsInEvents(compActivator, column, row);
6245
+ if (newActivatorClickEvt) {
6246
+ props.activator.events.click = newActivatorClickEvt;
6247
+ }
6248
+ }
6250
6249
  return { props, instance };
6251
6250
  }
6252
6251
  updateActionInstance(instanceName, newComponent) {
@@ -6278,6 +6277,18 @@ class Grid extends Iterable {
6278
6277
  }
6279
6278
  return {};
6280
6279
  }
6280
+ setGridRowsInEvents(comp, column, row) {
6281
+ var _a;
6282
+ if ((_a = comp.events) === null || _a === void 0 ? void 0 : _a.click) {
6283
+ const compEvents = Event.factory(comp.events);
6284
+ if (typeof compEvents.click === 'function') {
6285
+ return ({ component, event, element }) => compEvents.click({
6286
+ component, event, element, row, column,
6287
+ });
6288
+ }
6289
+ }
6290
+ return undefined;
6291
+ }
6281
6292
  }
6282
6293
 
6283
6294
  /**
@@ -7950,6 +7961,7 @@ class Search extends TextInput {
7950
7961
  */
7951
7962
  constructor(props) {
7952
7963
  super(props);
7964
+ this.lazyAttach = false;
7953
7965
  this.debounceSetSearch = debounce(this.setSearch, 500);
7954
7966
  this.iterableComponentName = this.getInitValue('iterableComponentName', props.iterableComponentName, this.iterableComponent);
7955
7967
  this.showHelper = this.getInitValue('showHelper', props.showHelper, false);
@@ -7957,10 +7969,13 @@ class Search extends TextInput {
7957
7969
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'magnify');
7958
7970
  this.placeholder = this.getInitValue('placeholder', props.placeholder, 'SEARCH');
7959
7971
  this.cssClass = this.getInitValue('cssClass', props.cssClass, 'zd-float-right');
7960
- this.setIterableComponent();
7972
+ this.lazyAttach = this.getInitValue('lazyAttach', props.lazyAttach, this.lazyAttach);
7973
+ if (!this.lazyAttach)
7974
+ this.setIterableComponent();
7961
7975
  this.createAccessors();
7962
7976
  }
7963
- setIterableComponent() {
7977
+ setIterableComponent(name) {
7978
+ this.iterableComponentName = name || this.iterableComponentName;
7964
7979
  if (this.iterableComponentName && Metadata.getInstances(this.iterableComponentName).length > 0) {
7965
7980
  this.iterableComponent = Metadata.getInstance(this.iterableComponentName);
7966
7981
  }
@@ -5611,6 +5611,17 @@
5611
5611
  }
5612
5612
  }
5613
5613
 
5614
+ /**
5615
+ * Delete rows error
5616
+ */
5617
+ class DeleteRowsError extends Error {
5618
+ constructor() {
5619
+ super('Grid can\'t automatically delete rows when selectAllPages property is true.'
5620
+ + ' You should delete them manually');
5621
+ this.name = 'DeleteRowsError';
5622
+ }
5623
+ }
5624
+
5614
5625
  /**
5615
5626
  * Base class for Grid column
5616
5627
  */
@@ -5773,17 +5784,6 @@
5773
5784
  core.FormatterParserProvider.registerFormatter('column_ZdCheckbox', toggleableFormatter);
5774
5785
  core.FormatterParserProvider.registerFormatter('column_ZdSwitch', toggleableFormatter);
5775
5786
 
5776
- /**
5777
- * Delete rows error
5778
- */
5779
- class DeleteRowsError extends Error {
5780
- constructor() {
5781
- super('Grid can\'t automatically delete rows when selectAllPages property is true.'
5782
- + ' You should delete them manually');
5783
- this.name = 'DeleteRowsError';
5784
- }
5785
- }
5786
-
5787
5787
  /**
5788
5788
  * Base class for Grid component
5789
5789
  */
@@ -6225,16 +6225,9 @@
6225
6225
  const compName = actionComponent.name;
6226
6226
  const instanceName = `${compName}_${rowKey}`;
6227
6227
  const path = parentPath ? `${parentPath}.${compName}` : compName;
6228
- const props = merge__default["default"]({}, actionComponent, (_b = (_a = this.actionsApplied[rowKey]) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b[path]);
6229
- let newClickEvt;
6230
- if ((_c = props.events) === null || _c === void 0 ? void 0 : _c.click) {
6231
- const compEvents = core.Event.factory(props.events);
6232
- if (typeof compEvents.click === 'function') {
6233
- newClickEvt = ({ component, event, element }) => compEvents.click({
6234
- component, event, element, row, column,
6235
- });
6236
- }
6237
- }
6228
+ const compActivator = (_a = actionComponent.activator) !== null && _a !== void 0 ? _a : undefined;
6229
+ const props = merge__default["default"]({}, actionComponent, (_c = (_b = this.actionsApplied[rowKey]) === null || _b === void 0 ? void 0 : _b[column.name]) === null || _c === void 0 ? void 0 : _c[path]);
6230
+ const newClickEvt = this.setGridRowsInEvents(props, column, row);
6238
6231
  const children = props.children || [];
6239
6232
  const newChildren = children.map((child) => this.getActionProps(child, column, row, path).props);
6240
6233
  props.children = newChildren;
@@ -6254,6 +6247,12 @@
6254
6247
  }
6255
6248
  if (newClickEvt)
6256
6249
  props.events.click = newClickEvt;
6250
+ if (compActivator) {
6251
+ const newActivatorClickEvt = this.setGridRowsInEvents(compActivator, column, row);
6252
+ if (newActivatorClickEvt) {
6253
+ props.activator.events.click = newActivatorClickEvt;
6254
+ }
6255
+ }
6257
6256
  return { props, instance };
6258
6257
  }
6259
6258
  updateActionInstance(instanceName, newComponent) {
@@ -6285,6 +6284,18 @@
6285
6284
  }
6286
6285
  return {};
6287
6286
  }
6287
+ setGridRowsInEvents(comp, column, row) {
6288
+ var _a;
6289
+ if ((_a = comp.events) === null || _a === void 0 ? void 0 : _a.click) {
6290
+ const compEvents = core.Event.factory(comp.events);
6291
+ if (typeof compEvents.click === 'function') {
6292
+ return ({ component, event, element }) => compEvents.click({
6293
+ component, event, element, row, column,
6294
+ });
6295
+ }
6296
+ }
6297
+ return undefined;
6298
+ }
6288
6299
  }
6289
6300
 
6290
6301
  /**
@@ -7957,6 +7968,7 @@
7957
7968
  */
7958
7969
  constructor(props) {
7959
7970
  super(props);
7971
+ this.lazyAttach = false;
7960
7972
  this.debounceSetSearch = debounce__default["default"](this.setSearch, 500);
7961
7973
  this.iterableComponentName = this.getInitValue('iterableComponentName', props.iterableComponentName, this.iterableComponent);
7962
7974
  this.showHelper = this.getInitValue('showHelper', props.showHelper, false);
@@ -7964,10 +7976,13 @@
7964
7976
  this.appendIcon = this.getInitValue('appendIcon', props.appendIcon, 'magnify');
7965
7977
  this.placeholder = this.getInitValue('placeholder', props.placeholder, 'SEARCH');
7966
7978
  this.cssClass = this.getInitValue('cssClass', props.cssClass, 'zd-float-right');
7967
- this.setIterableComponent();
7979
+ this.lazyAttach = this.getInitValue('lazyAttach', props.lazyAttach, this.lazyAttach);
7980
+ if (!this.lazyAttach)
7981
+ this.setIterableComponent();
7968
7982
  this.createAccessors();
7969
7983
  }
7970
- setIterableComponent() {
7984
+ setIterableComponent(name) {
7985
+ this.iterableComponentName = name || this.iterableComponentName;
7971
7986
  if (this.iterableComponentName && core.Metadata.getInstances(this.iterableComponentName).length > 0) {
7972
7987
  this.iterableComponent = core.Metadata.getInstance(this.iterableComponentName);
7973
7988
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.85.0",
3
+ "version": "1.85.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": "8324a7087a2b3daa9349bb5551bc1c708ad1c38f"
46
+ "gitHead": "13bfb6936e5027a14c02d4ecde838100992a57d0"
47
47
  }
@@ -1,9 +1,9 @@
1
1
  import { IDictionary } from '@zeedhi/core';
2
- import { IGrid, IGridColumn, IGridEvents } from './interfaces';
3
- import { Iterable } from '../zd-iterable/iterable';
2
+ import { Component } from '../zd-component/component';
4
3
  import { IComponent, IComponentRender } from '../zd-component/interfaces';
4
+ import { Iterable } from '../zd-iterable/iterable';
5
5
  import { GridColumn } from './grid-column';
6
- import { Component } from '../zd-component/component';
6
+ import { IGrid, IGridColumn, IGridEvents } from './interfaces';
7
7
  /**
8
8
  * Base class for Grid component
9
9
  */
@@ -212,4 +212,5 @@ export declare class Grid extends Iterable implements IGrid {
212
212
  protected changeDefaultSlotNames(slot: IComponentRender[]): any;
213
213
  callDisableSelection(row: IDictionary<any>): boolean;
214
214
  getRowStyleConditions(row: IDictionary<any>): IDictionary<any>;
215
+ private setGridRowsInEvents;
215
216
  }
@@ -61,6 +61,7 @@ export interface ISearch extends ITextInput {
61
61
  showLabel?: boolean;
62
62
  showHelper?: boolean;
63
63
  appendIcon?: string;
64
+ lazyAttach?: boolean;
64
65
  }
65
66
  export interface IIterableColumnsButton extends IButton {
66
67
  iterableComponentName?: string;
@@ -13,12 +13,13 @@ export declare class Search extends TextInput implements ISearch {
13
13
  * Iterable component name
14
14
  */
15
15
  iterableComponent: Iterable;
16
+ lazyAttach: boolean;
16
17
  /**
17
18
  * Creates a new Iterable Page component.
18
19
  * @param props Iterable page component properties
19
20
  */
20
21
  constructor(props: ISearch);
21
- private setIterableComponent;
22
+ setIterableComponent(name?: string): void;
22
23
  protected setSearch(search: string): Promise<void>;
23
24
  debounceSetSearch: (search: string) => void;
24
25
  }