@smallpearl/ngx-helper 0.29.39 → 0.29.40

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 (33) hide show
  1. package/assets/i18n/sp-mat-entity-crud/en.json +5 -3
  2. package/assets/i18n/sp-mat-entity-crud/zh-hant.json +3 -1
  3. package/assets/i18n/sp-mat-select-entity/en.json +5 -0
  4. package/assets/i18n/sp-mat-select-entity/zh-hant.json +5 -0
  5. package/core/index.d.ts +0 -1
  6. package/entity-field/src/entity-field-spec.d.ts +1 -3
  7. package/fesm2022/smallpearl-ngx-helper-core.mjs +1 -16
  8. package/fesm2022/smallpearl-ngx-helper-core.mjs.map +1 -1
  9. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs +2 -4
  10. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs.map +1 -1
  11. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs +6 -14
  12. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs.map +1 -1
  13. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs +198 -178
  14. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs.map +1 -1
  15. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs +48 -55
  16. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs.map +1 -1
  17. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs +145 -166
  18. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs.map +1 -1
  19. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs +1 -4
  20. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs.map +1 -1
  21. package/mat-entity-crud/src/form-view-host.component.d.ts +2 -0
  22. package/mat-entity-crud/src/mat-entity-crud-form-base.d.ts +2 -0
  23. package/mat-entity-crud/src/mat-entity-crud-internal-types.d.ts +6 -0
  24. package/mat-entity-crud/src/mat-entity-crud-types.d.ts +6 -15
  25. package/mat-entity-crud/src/mat-entity-crud.component.d.ts +16 -5
  26. package/mat-entity-crud/src/preview-pane.component.d.ts +1 -4
  27. package/mat-entity-list/src/mat-entity-list.component.d.ts +2 -1
  28. package/mat-select-entity/index.d.ts +0 -1
  29. package/mat-select-entity/src/mat-select-entity.component.d.ts +6 -8
  30. package/package.json +13 -13
  31. package/stationary-with-line-items/src/stationary-with-line-items.component.d.ts +0 -2
  32. package/core/src/ngx-helper.d.ts +0 -7
  33. package/mat-select-entity/src/providers.d.ts +0 -9
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "save": "Save",
3
- "edit": "Edit",
3
+ "edit": "Update",
4
+ "delete": "Delete",
4
5
  "newItem": "New {{item}}",
5
- "editItem": "Edit {{item}}",
6
+ "editItem": "Update {{item}}",
6
7
  "deleteItem": "Delete {{item}}",
7
- "deleteItemConfirm": "Are you sure you want to delete {{item}}?",
8
+ "deleteItemConfirm": "Are you sure you want to delete this {{item}}?",
8
9
  "deleteItemSuccess": "{{item}} deleted successfully",
9
10
  "deleteItemError": "Failed to delete {{item}}",
10
11
  "saveSuccess": "{{item}} saved successfully",
@@ -13,6 +14,7 @@
13
14
  "createError": "Failed to create {{item}}",
14
15
  "updateSuccess": "{{item}} updated successfully",
15
16
  "updateError": "Failed to update {{item}}",
17
+ "loseChangesConfirm": "You have unsaved changes. Are you sure you want to leave?",
16
18
  "cancel": "Cancel",
17
19
  "confirm": "Confirm",
18
20
  "yes": "Yes",
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "save": "保存",
3
3
  "edit": "編輯",
4
+ "delete": "刪除",
4
5
  "newItem": "新建 {{item}}",
5
6
  "editItem": "編輯 {{item}}",
6
7
  "deleteItem": "刪除 {{item}}",
7
- "deleteItemConfirm": "確定要刪除 {{item}} 嗎?",
8
+ "deleteItemConfirm": "確定要刪除這個 {{item}} 嗎?",
8
9
  "deleteItemSuccess": "{{item}} 刪除成功",
9
10
  "deleteItemError": "{{item}} 刪除失敗",
10
11
  "saveSuccess": "{{item}} 保存成功",
@@ -13,6 +14,7 @@
13
14
  "createError": "{{item}} 創建失敗",
14
15
  "updateSuccess": "{{item}} 更新成功",
15
16
  "updateError": "{{item}} 更新失敗",
17
+ "loseChangesConfirm": "您有未保存的更改。確定要離開嗎?",
16
18
  "cancel": "取消",
17
19
  "confirm": "確認",
18
20
  "yes": "是",
@@ -0,0 +1,5 @@
1
+ {
2
+ "search": "Search",
3
+ "notFound": "Not found",
4
+ "addItem": "Add {{item}}"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "search": "搜索",
3
+ "notFound": "未找到",
4
+ "add": "添加"
5
+ }
package/core/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from './src/version';
2
- export * from './src/ngx-helper';
@@ -1,4 +1,3 @@
1
- import { SPNgxHelperConfig } from '@smallpearl/ngx-helper/core';
2
1
  import { SPIntlDateFormat } from '@smallpearl/ngx-helper/locale';
3
2
  import { SPEntityFieldConfig } from './provider';
4
3
  /**
@@ -29,10 +28,9 @@ export type SPEntityFieldSpec<TEntity extends {
29
28
  export declare class SPEntityField<TEntity extends {
30
29
  [P in IdKey]: PropertyKey;
31
30
  }, IdKey extends string = 'id'> {
32
- helperConfig: SPNgxHelperConfig;
33
31
  fieldConfig?: SPEntityFieldConfig | undefined;
34
32
  _fieldSpec: SPEntityFieldSpec<TEntity, IdKey>;
35
- constructor(spec: SPEntityFieldSpec<TEntity, IdKey> | string, helperConfig: SPNgxHelperConfig, fieldConfig?: SPEntityFieldConfig | undefined);
33
+ constructor(spec: SPEntityFieldSpec<TEntity, IdKey> | string, fieldConfig?: SPEntityFieldConfig | undefined);
36
34
  get spec(): SPEntityFieldSpec<TEntity, IdKey>;
37
35
  /**
38
36
  * Returns the effective fieldValueOptions by merging the global field
@@ -1,23 +1,8 @@
1
- import { InjectionToken, inject } from '@angular/core';
2
-
3
1
  const NGX_HELPER_VERSION = '0.1.0';
4
2
 
5
- /** Version of the ngx-helper library */
6
- const SP_NGX_HELPER_CONFIG = new InjectionToken('SPNgxHelperConfig');
7
- function getNgxHelperConfig() {
8
- const defaultNgxHelperConfig = {
9
- i18nTranslate: (label, context) => label
10
- };
11
- const helperConfig = inject(SP_NGX_HELPER_CONFIG, { optional: true });
12
- return {
13
- ...defaultNgxHelperConfig,
14
- ...(helperConfig ?? {}),
15
- };
16
- }
17
-
18
3
  /**
19
4
  * Generated bundle index. Do not edit.
20
5
  */
21
6
 
22
- export { NGX_HELPER_VERSION, SP_NGX_HELPER_CONFIG, getNgxHelperConfig };
7
+ export { NGX_HELPER_VERSION };
23
8
  //# sourceMappingURL=smallpearl-ngx-helper-core.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"smallpearl-ngx-helper-core.mjs","sources":["../../../../projects/smallpearl/ngx-helper/core/src/version.ts","../../../../projects/smallpearl/ngx-helper/core/src/ngx-helper.ts","../../../../projects/smallpearl/ngx-helper/core/smallpearl-ngx-helper-core.ts"],"sourcesContent":["export const NGX_HELPER_VERSION = '0.1.0';\n","/** Version of the ngx-helper library */\nimport { inject, InjectionToken } from '@angular/core';\n\nexport interface SPNgxHelperConfig {\n i18nTranslate: (label: string, context?: any) => string;\n}\n\nexport const SP_NGX_HELPER_CONFIG = new InjectionToken<SPNgxHelperConfig>(\n 'SPNgxHelperConfig'\n);\n\nexport function getNgxHelperConfig(): SPNgxHelperConfig {\n const defaultNgxHelperConfig: SPNgxHelperConfig = {\n i18nTranslate: (label: string, context?: any) => label\n }\n const helperConfig = inject(SP_NGX_HELPER_CONFIG, {optional: true});\n return {\n ...defaultNgxHelperConfig,\n ...(helperConfig ?? {}),\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAO,MAAM,kBAAkB,GAAG;;ACAlC;MAOa,oBAAoB,GAAG,IAAI,cAAc,CACpD,mBAAmB;SAGL,kBAAkB,GAAA;AAChC,IAAA,MAAM,sBAAsB,GAAsB;QAChD,aAAa,EAAE,CAAC,KAAa,EAAE,OAAa,KAAK;KAClD;AACD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,oBAAoB,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;IACnE,OAAO;AACL,QAAA,GAAG,sBAAsB;AACzB,QAAA,IAAI,YAAY,IAAI,EAAE,CAAC;KACxB;AACH;;ACpBA;;AAEG;;;;"}
1
+ {"version":3,"file":"smallpearl-ngx-helper-core.mjs","sources":["../../../../projects/smallpearl/ngx-helper/core/src/version.ts","../../../../projects/smallpearl/ngx-helper/core/smallpearl-ngx-helper-core.ts"],"sourcesContent":["export const NGX_HELPER_VERSION = '0.1.0';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAO,MAAM,kBAAkB,GAAG;;ACAlC;;AAEG;;;;"}
@@ -6,11 +6,9 @@ import { InjectionToken } from '@angular/core';
6
6
  * by the library to evaluate a SPEntityFieldSpec<> object.
7
7
  */
8
8
  class SPEntityField {
9
- helperConfig;
10
9
  fieldConfig;
11
10
  _fieldSpec;
12
- constructor(spec, helperConfig, fieldConfig) {
13
- this.helperConfig = helperConfig;
11
+ constructor(spec, fieldConfig) {
14
12
  this.fieldConfig = fieldConfig;
15
13
  if (typeof spec === 'string') {
16
14
  this._fieldSpec = {
@@ -43,7 +41,7 @@ class SPEntityField {
43
41
  * @returns the label for the field.
44
42
  */
45
43
  label() {
46
- return this.helperConfig.i18nTranslate(this._fieldSpec.label ?? this._fieldSpec.name);
44
+ return this._fieldSpec.label ?? this._fieldSpec.name;
47
45
  }
48
46
  /**
49
47
  * Given an entity, returns the value of the field matching the
@@ -1 +1 @@
1
- {"version":3,"file":"smallpearl-ngx-helper-entity-field.mjs","sources":["../../../../projects/smallpearl/ngx-helper/entity-field/src/entity-field-spec.ts","../../../../projects/smallpearl/ngx-helper/entity-field/src/provider.ts","../../../../projects/smallpearl/ngx-helper/entity-field/smallpearl-ngx-helper-entity-field.ts"],"sourcesContent":["import { SPNgxHelperConfig } from '@smallpearl/ngx-helper/core';\nimport {\n spFormatCurrency,\n spFormatDate,\n SPIntlDateFormat,\n} from '@smallpearl/ngx-helper/locale';\nimport { SPEntityFieldConfig } from './provider';\n\n/**\n * This structure defines the data formatting details for a field of the\n * entity. All entity fields need not necessarily be actual entity object's\n * properties. Fields can also be computed fields, in which case the valueFn\n * should be initialized with a valid function to provide the field's value.\n */\nexport type SPEntityFieldSpec<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'> = {\n // Column name. If valueFn is not specified, this will be used as the\n // key name to retrieve the value for the column from TEntity.\n name: string;\n // If omitted, 'name' will be used as field label.\n label?: string;\n // Column value specific formatting options. Currently, only used for\n // Date types.\n valueOptions?: {\n // Specify the same format string argument that is passed to DatePipe.\n dateTimeFormat?: SPIntlDateFormat;\n // If boolean, number field will be formatted using spFormatCurrency()\n // using the current currency or 'currency' value below.\n isCurrency?: boolean;\n // Currency code, if different from default locale.\n currency?: string;\n // CSS class name; if provided will be applied to field value's wrapper\n // element. This will be <td> & <th>.\n class?: string;\n // Alignment options. Field's value will be aligned based on this.\n alignment?: 'start'|'center'|'end';\n // A fixed string or a function that returns an array of strings\n // to be used as the routerlink for the column value.\n routerLink?: ((e: TEntity) => string[])|[string];\n };\n // If the column value cannot be derived by simple TEntity[name] lookup,\n // use this function to return a custom computed or formatted value.\n valueFn?: (item: TEntity) => string | number | Date | boolean;\n};\n\n/**\n * A class that represents a SPEntityFieldSpec<>. This is typically used\n * by the library to evaluate a SPEntityFieldSpec<> object.\n */\nexport class SPEntityField<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'> {\n public _fieldSpec!: SPEntityFieldSpec<TEntity, IdKey>;\n\n constructor(\n spec: SPEntityFieldSpec<TEntity, IdKey> | string,\n public helperConfig: SPNgxHelperConfig,\n public fieldConfig?: SPEntityFieldConfig\n ) {\n if (typeof spec === 'string') {\n this._fieldSpec = {\n name: spec,\n };\n } else {\n this._fieldSpec = spec;\n }\n }\n\n get spec() {\n return this._fieldSpec;\n }\n\n /**\n * Returns the effective fieldValueOptions by merging the global field\n * options (if one has been spefified) with the local field value options.\n * @returns SPEntityFieldSpec<any>['valueOptions']\n */\n get options() {\n let globalFieldValueOptions: SPEntityFieldSpec<any>['valueOptions'] = {};\n if (this.fieldConfig && this.fieldConfig?.fieldValueOptions && this.fieldConfig.fieldValueOptions.has(this._fieldSpec.name)) {\n globalFieldValueOptions = this.fieldConfig.fieldValueOptions.get(this._fieldSpec.name);\n }\n return {\n ...globalFieldValueOptions,\n ...(this._fieldSpec?.valueOptions ?? {})\n };\n }\n /**\n * @returns the label for the field.\n */\n label() {\n return this.helperConfig.i18nTranslate(\n this._fieldSpec.label ?? this._fieldSpec.name\n );\n }\n\n /**\n * Given an entity, returns the value of the field matching the\n * SPEntityFieldSpec<> in fieldSpec.\n * @param entity TEntity instance which will be evaluated for\n * SPEntityFieldSpec<>.\n * @returns\n */\n value(entity: TEntity) {\n let val = undefined;\n if (!this._fieldSpec.valueFn) {\n if (\n this.fieldConfig &&\n this.fieldConfig?.fieldValueFns &&\n this.fieldConfig.fieldValueFns.has(this._fieldSpec.name)\n ) {\n val = this.fieldConfig.fieldValueFns.get(this._fieldSpec.name)!(entity, this._fieldSpec.name);\n } else {\n val = (entity as any)[this._fieldSpec.name];\n }\n } else {\n val = this._fieldSpec.valueFn(entity);\n }\n const valueOptions = this.options;\n if (val instanceof Date) {\n val = spFormatDate(val);\n } else if (\n typeof val === 'number' &&\n valueOptions?.isCurrency\n ) {\n val = spFormatCurrency(val, this._fieldSpec?.valueOptions?.currency);\n } else if (typeof val === 'boolean') {\n val = val ? '✔' : '✖';\n }\n return val;\n }\n\n /**\n * If specified, will be added to the CSS classes of the field's wrapper\n * element.\n */\n get class() {\n return this._fieldSpec?.valueOptions?.class ?? '';\n }\n\n hasRouterLink(entity: TEntity) {\n return !!this._fieldSpec?.valueOptions?.routerLink;\n }\n\n getRouterLink(entity: TEntity) {\n const rl = this._fieldSpec?.valueOptions?.routerLink;\n if (rl) {\n if (typeof rl == 'function') {\n return rl(entity);\n }\n return rl\n }\n return [];\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport { SPEntityFieldSpec } from './entity-field-spec';\n\n\nexport type FIELD_VALUE_FN = (entity: any, fieldName: string) => string|number|Date|boolean;\n\n/**\n * Global config for SPEntityField component.\n */\nexport interface SPEntityFieldConfig {\n /**\n * These are global field value functions.\n *\n * If a value function for a field is not explicitly specified, this map is\n * looked up with the field name. If an entry exists in this table, it will\n * be used to render the field's value.\n *\n * This is useful for formatting certain fields which tend to have the\n * same name across the app. For instance fields such as 'amount', 'total'\n * or 'balance'. Or 'date', 'timestamp', etc.\n */\n fieldValueFns?: Map<string, FIELD_VALUE_FN>;\n /**\n * Similar to above, but allows setting the options for certain fields\n * globally. As in the case of `fieldValueFns`, the per field specification,\n * if one exists, takes precedence over the global setting.\n */\n fieldValueOptions?: Map<string, SPEntityFieldSpec<any>['valueOptions']>;\n}\n\nexport const SP_ENTITY_FIELD_CONFIG = new InjectionToken<SPEntityFieldConfig>(\n 'SPEntityFieldConfig'\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AA4CA;;;AAGG;MACU,aAAa,CAAA;AAKf,IAAA,YAAA;AACA,IAAA,WAAA;AALF,IAAA,UAAU;AAEjB,IAAA,WAAA,CACE,IAAgD,EACzC,YAA+B,EAC/B,WAAiC,EAAA;QADjC,IAAY,CAAA,YAAA,GAAZ,YAAY;QACZ,IAAW,CAAA,WAAA,GAAX,WAAW;AAElB,QAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,IAAI,CAAC,UAAU,GAAG;AAChB,gBAAA,IAAI,EAAE,IAAI;aACX;;aACI;AACL,YAAA,IAAI,CAAC,UAAU,GAAG,IAAI;;;AAI1B,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,UAAU;;AAGxB;;;;AAIG;AACH,IAAA,IAAI,OAAO,GAAA;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AAC,OAAO;AACjC,QAAA,IAAI,GAAG,YAAY,IAAI,EAAE;AACvB,YAAA,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;;aAClB,IACL,OAAO,GAAG,KAAK,QAAQ;YACvB,YAAY,EAAE,UAAU,EACxB;AACA,YAAA,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,CAAC;;AAC/D,aAAA,IAAI,OAAO,GAAG,KAAK,SAAS,EAAE;YACnC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;;AAEvB,QAAA,OAAO,GAAG;;AAGZ;;;AAGG;AACH,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,IAAI,EAAE;;AAGnD,IAAA,aAAa,CAAC,MAAe,EAAA;QAC3B,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU;;AAGpD,IAAA,aAAa,CAAC,MAAe,EAAA;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU;QACpD,IAAI,EAAE,EAAE;AACN,YAAA,IAAI,OAAO,EAAE,IAAI,UAAU,EAAE;AAC3B,gBAAA,OAAO,EAAE,CAAC,MAAM,CAAC;;AAEnB,YAAA,OAAO,EAAE;;AAEX,QAAA,OAAO,EAAE;;AAEZ;;MCzHY,sBAAsB,GAAG,IAAI,cAAc,CACtD,qBAAqB;;AC/BvB;;AAEG;;;;"}
1
+ {"version":3,"file":"smallpearl-ngx-helper-entity-field.mjs","sources":["../../../../projects/smallpearl/ngx-helper/entity-field/src/entity-field-spec.ts","../../../../projects/smallpearl/ngx-helper/entity-field/src/provider.ts","../../../../projects/smallpearl/ngx-helper/entity-field/smallpearl-ngx-helper-entity-field.ts"],"sourcesContent":["import {\n spFormatCurrency,\n spFormatDate,\n SPIntlDateFormat,\n} from '@smallpearl/ngx-helper/locale';\nimport { SPEntityFieldConfig } from './provider';\n\n/**\n * This structure defines the data formatting details for a field of the\n * entity. All entity fields need not necessarily be actual entity object's\n * properties. Fields can also be computed fields, in which case the valueFn\n * should be initialized with a valid function to provide the field's value.\n */\nexport type SPEntityFieldSpec<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'> = {\n // Column name. If valueFn is not specified, this will be used as the\n // key name to retrieve the value for the column from TEntity.\n name: string;\n // If omitted, 'name' will be used as field label.\n label?: string;\n // Column value specific formatting options. Currently, only used for\n // Date types.\n valueOptions?: {\n // Specify the same format string argument that is passed to DatePipe.\n dateTimeFormat?: SPIntlDateFormat;\n // If boolean, number field will be formatted using spFormatCurrency()\n // using the current currency or 'currency' value below.\n isCurrency?: boolean;\n // Currency code, if different from default locale.\n currency?: string;\n // CSS class name; if provided will be applied to field value's wrapper\n // element. This will be <td> & <th>.\n class?: string;\n // Alignment options. Field's value will be aligned based on this.\n alignment?: 'start'|'center'|'end';\n // A fixed string or a function that returns an array of strings\n // to be used as the routerlink for the column value.\n routerLink?: ((e: TEntity) => string[])|[string];\n };\n // If the column value cannot be derived by simple TEntity[name] lookup,\n // use this function to return a custom computed or formatted value.\n valueFn?: (item: TEntity) => string | number | Date | boolean;\n};\n\n/**\n * A class that represents a SPEntityFieldSpec<>. This is typically used\n * by the library to evaluate a SPEntityFieldSpec<> object.\n */\nexport class SPEntityField<TEntity extends { [P in IdKey]: PropertyKey }, IdKey extends string = 'id'> {\n public _fieldSpec!: SPEntityFieldSpec<TEntity, IdKey>;\n\n constructor(\n spec: SPEntityFieldSpec<TEntity, IdKey> | string,\n public fieldConfig?: SPEntityFieldConfig\n ) {\n if (typeof spec === 'string') {\n this._fieldSpec = {\n name: spec,\n };\n } else {\n this._fieldSpec = spec;\n }\n }\n\n get spec() {\n return this._fieldSpec;\n }\n\n /**\n * Returns the effective fieldValueOptions by merging the global field\n * options (if one has been spefified) with the local field value options.\n * @returns SPEntityFieldSpec<any>['valueOptions']\n */\n get options() {\n let globalFieldValueOptions: SPEntityFieldSpec<any>['valueOptions'] = {};\n if (this.fieldConfig && this.fieldConfig?.fieldValueOptions && this.fieldConfig.fieldValueOptions.has(this._fieldSpec.name)) {\n globalFieldValueOptions = this.fieldConfig.fieldValueOptions.get(this._fieldSpec.name);\n }\n return {\n ...globalFieldValueOptions,\n ...(this._fieldSpec?.valueOptions ?? {})\n };\n }\n /**\n * @returns the label for the field.\n */\n label() {\n return this._fieldSpec.label ?? this._fieldSpec.name\n }\n\n /**\n * Given an entity, returns the value of the field matching the\n * SPEntityFieldSpec<> in fieldSpec.\n * @param entity TEntity instance which will be evaluated for\n * SPEntityFieldSpec<>.\n * @returns\n */\n value(entity: TEntity) {\n let val = undefined;\n if (!this._fieldSpec.valueFn) {\n if (\n this.fieldConfig &&\n this.fieldConfig?.fieldValueFns &&\n this.fieldConfig.fieldValueFns.has(this._fieldSpec.name)\n ) {\n val = this.fieldConfig.fieldValueFns.get(this._fieldSpec.name)!(entity, this._fieldSpec.name);\n } else {\n val = (entity as any)[this._fieldSpec.name];\n }\n } else {\n val = this._fieldSpec.valueFn(entity);\n }\n const valueOptions = this.options;\n if (val instanceof Date) {\n val = spFormatDate(val);\n } else if (\n typeof val === 'number' &&\n valueOptions?.isCurrency\n ) {\n val = spFormatCurrency(val, this._fieldSpec?.valueOptions?.currency);\n } else if (typeof val === 'boolean') {\n val = val ? '✔' : '✖';\n }\n return val;\n }\n\n /**\n * If specified, will be added to the CSS classes of the field's wrapper\n * element.\n */\n get class() {\n return this._fieldSpec?.valueOptions?.class ?? '';\n }\n\n hasRouterLink(entity: TEntity) {\n return !!this._fieldSpec?.valueOptions?.routerLink;\n }\n\n getRouterLink(entity: TEntity) {\n const rl = this._fieldSpec?.valueOptions?.routerLink;\n if (rl) {\n if (typeof rl == 'function') {\n return rl(entity);\n }\n return rl\n }\n return [];\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport { SPEntityFieldSpec } from './entity-field-spec';\n\n\nexport type FIELD_VALUE_FN = (entity: any, fieldName: string) => string|number|Date|boolean;\n\n/**\n * Global config for SPEntityField component.\n */\nexport interface SPEntityFieldConfig {\n /**\n * These are global field value functions.\n *\n * If a value function for a field is not explicitly specified, this map is\n * looked up with the field name. If an entry exists in this table, it will\n * be used to render the field's value.\n *\n * This is useful for formatting certain fields which tend to have the\n * same name across the app. For instance fields such as 'amount', 'total'\n * or 'balance'. Or 'date', 'timestamp', etc.\n */\n fieldValueFns?: Map<string, FIELD_VALUE_FN>;\n /**\n * Similar to above, but allows setting the options for certain fields\n * globally. As in the case of `fieldValueFns`, the per field specification,\n * if one exists, takes precedence over the global setting.\n */\n fieldValueOptions?: Map<string, SPEntityFieldSpec<any>['valueOptions']>;\n}\n\nexport const SP_ENTITY_FIELD_CONFIG = new InjectionToken<SPEntityFieldConfig>(\n 'SPEntityFieldConfig'\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AA2CA;;;AAGG;MACU,aAAa,CAAA;AAKf,IAAA,WAAA;AAJF,IAAA,UAAU;IAEjB,WACE,CAAA,IAAgD,EACzC,WAAiC,EAAA;QAAjC,IAAW,CAAA,WAAA,GAAX,WAAW;AAElB,QAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,IAAI,CAAC,UAAU,GAAG;AAChB,gBAAA,IAAI,EAAE,IAAI;aACX;;aACI;AACL,YAAA,IAAI,CAAC,UAAU,GAAG,IAAI;;;AAI1B,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,UAAU;;AAGxB;;;;AAIG;AACH,IAAA,IAAI,OAAO,GAAA;QACT,IAAI,uBAAuB,GAA2C,EAAE;QACxE,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,iBAAiB,IAAI,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;AAC3H,YAAA,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CAAC;;AAC/D,aAAA,IAAI,OAAO,GAAG,KAAK,SAAS,EAAE;YACnC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;;AAEvB,QAAA,OAAO,GAAG;;AAGZ;;;AAGG;AACH,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,IAAI,EAAE;;AAGnD,IAAA,aAAa,CAAC,MAAe,EAAA;QAC3B,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU;;AAGpD,IAAA,aAAa,CAAC,MAAe,EAAA;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU;QACpD,IAAI,EAAE,EAAE;AACN,YAAA,IAAI,OAAO,EAAE,IAAI,UAAU,EAAE;AAC3B,gBAAA,OAAO,EAAE,CAAC,MAAM,CAAC;;AAEnB,YAAA,OAAO,EAAE;;AAEX,QAAA,OAAO,EAAE;;AAEZ;;MCrHY,sBAAsB,GAAG,IAAI,cAAc,CACtD,qBAAqB;;AC/BvB;;AAEG;;;;"}
@@ -73,7 +73,6 @@ class SPMatContextMenuComponent {
73
73
  <mat-menu #contextMenu="matMenu" [hasBackdrop]="hasBackdrop()">
74
74
  @for (menuItem of menuItems(); track $index) {
75
75
  @if (menuItem.role) {
76
- @if (!itemDisabled(menuItem)) {
77
76
  <button
78
77
  mat-menu-item
79
78
  [routerLink]="menuItem.route ? menuItem.route : undefined"
@@ -85,13 +84,10 @@ class SPMatContextMenuComponent {
85
84
  }
86
85
  {{ menuItem.label }}
87
86
  </button>
88
- }
89
87
  } @else {
90
- @if (!itemDisabled(menuItem)) {
91
- <div style="padding: .2em 0.6em;">
92
- <strong>{{ menuItem.label }}</strong>
93
- </div>
94
- }
88
+ <div style="padding: .2em 0.6em;">
89
+ <strong>{{ menuItem.label }}</strong>
90
+ </div>
95
91
  }
96
92
  <!-- <button
97
93
  mat-menu-item
@@ -136,7 +132,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImpor
136
132
  <mat-menu #contextMenu="matMenu" [hasBackdrop]="hasBackdrop()">
137
133
  @for (menuItem of menuItems(); track $index) {
138
134
  @if (menuItem.role) {
139
- @if (!itemDisabled(menuItem)) {
140
135
  <button
141
136
  mat-menu-item
142
137
  [routerLink]="menuItem.route ? menuItem.route : undefined"
@@ -148,13 +143,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImpor
148
143
  }
149
144
  {{ menuItem.label }}
150
145
  </button>
151
- }
152
146
  } @else {
153
- @if (!itemDisabled(menuItem)) {
154
- <div style="padding: .2em 0.6em;">
155
- <strong>{{ menuItem.label }}</strong>
156
- </div>
157
- }
147
+ <div style="padding: .2em 0.6em;">
148
+ <strong>{{ menuItem.label }}</strong>
149
+ </div>
158
150
  }
159
151
  <!-- <button
160
152
  mat-menu-item
@@ -1 +1 @@
1
- {"version":3,"file":"smallpearl-ngx-helper-mat-context-menu.mjs","sources":["../../../../projects/smallpearl/ngx-helper/mat-context-menu/src/mat-context-menu.component.ts","../../../../projects/smallpearl/ngx-helper/mat-context-menu/smallpearl-ngx-helper-mat-context-menu.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n input,\n OnInit,\n Output,\n} from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatMenuModule } from '@angular/material/menu';\nimport { RouterModule } from '@angular/router';\nimport { HoverDropDownDirective } from '@smallpearl/ngx-helper/hover-dropdown';\n\n/**\n * Describes each item in the context menu.\n */\nexport interface SPContextMenuItem {\n // Menu item label\n label: string;\n // Menu icon, A material icon\n icon?: string;\n // Angular route to navigate to when the menu item is selected.\n route?: string | string[];\n // Argument to the (selected) event when this menu item is selected\n // by the user and the corresponding ContextMenuItem does not have a\n // 'route' property value.\n role?: string;\n // Whether the menu item should be disabled\n disable?: (arg: any) => boolean;\n}\n\n@Component({\n imports: [\n RouterModule,\n MatButtonModule,\n MatIconModule,\n MatMenuModule,\n HoverDropDownDirective,\n ],\n selector: 'sp-mat-context-menu',\n template: `\n <button\n #menuTrigger=\"matMenuTrigger\"\n mat-icon-button\n [matMenuTriggerFor]=\"contextMenu\"\n hoverDropDown\n [menu]=\"contextMenu\"\n [hoverTrigger]=\"enableHover() ? menuTrigger : null\"\n >\n @if (menuIconName()) {\n <mat-icon>{{ menuIconName() }}</mat-icon>\n }\n {{ label() }}\n </button>\n <mat-menu #contextMenu=\"matMenu\" [hasBackdrop]=\"hasBackdrop()\">\n @for (menuItem of menuItems(); track $index) {\n @if (menuItem.role) {\n @if (!itemDisabled(menuItem)) {\n <button\n mat-menu-item\n [routerLink]=\"menuItem.route ? menuItem.route : undefined\"\n (click)=\"$event.preventDefault(); onSelectMenuItem(menuItem)\"\n [disabled]=\"itemDisabled(menuItem)\"\n >\n @if (menuItem.icon) {\n <mat-icon>{{ menuItem.icon }}</mat-icon>\n }\n {{ menuItem.label }}\n </button>\n }\n } @else {\n @if (!itemDisabled(menuItem)) {\n <div style=\"padding: .2em 0.6em;\">\n <strong>{{ menuItem.label }}</strong>\n </div>\n }\n }\n <!-- <button\n mat-menu-item\n [routerLink]=\"menuItem.route ? menuItem.route : undefined\"\n (click)=\"$event.preventDefault(); onSelectMenuItem(menuItem)\"\n [disabled]=\"itemDisabled(menuItem)\"\n >\n @if (menuItem.icon) {\n <mat-icon>{{ menuItem.icon }}</mat-icon>\n }\n {{ menuItem.label }}\n </button> -->\n }\n </mat-menu>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SPMatContextMenuComponent implements OnInit {\n /**\n * The menu items to display. Refer to ContextMenuItem doc for details\n * on the menu items.\n */\n menuItems = input.required<SPContextMenuItem[]>();\n /**\n * Label to display for the context menu. If omitted will just show the\n * menuIcon.\n */\n label = input<string>('');\n /**\n * Button icon. defaults to more_vert.\n */\n menuIconName = input<string>('more_vert');\n /**\n * By default the context menu is activated whenever the mouse cursor hovers\n * over the button. Set this to 'true' to disable this feature.\n */\n enableHover = input<boolean>(false);\n /**\n * Context data for menu item disabled callback\n */\n contextData = input<any>();\n /**\n * enable menu backdrop\n */\n hasBackdrop = input<boolean>(false);\n /**\n * Event generated when use selects an item in the context menu. This event\n * is generated only if the context menu item does not specify a route to\n * activate. The string event parameter is ContextMenuItem.role property\n * value.\n */\n @Output() selected = new EventEmitter<string>();\n\n constructor() {}\n\n ngOnInit() {}\n\n\n onSelectMenuItem(item: SPContextMenuItem) {\n if (!item.route) {\n this.selected.emit(item?.role || item.label);\n }\n }\n\n itemDisabled(menuItem: SPContextMenuItem) {\n return menuItem?.disable && menuItem.disable(this.contextData());\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;MA8Fa,yBAAyB,CAAA;AACpC;;;AAGG;AACH,IAAA,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAuB;AACjD;;;AAGG;AACH,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,CAAC;AACzB;;AAEG;AACH,IAAA,YAAY,GAAG,KAAK,CAAS,WAAW,CAAC;AACzC;;;AAGG;AACH,IAAA,WAAW,GAAG,KAAK,CAAU,KAAK,CAAC;AACnC;;AAEG;IACH,WAAW,GAAG,KAAK,EAAO;AAC1B;;AAEG;AACH,IAAA,WAAW,GAAG,KAAK,CAAU,KAAK,CAAC;AACnC;;;;;AAKG;AACO,IAAA,QAAQ,GAAG,IAAI,YAAY,EAAU;AAE/C,IAAA,WAAA,GAAA;AAEA,IAAA,QAAQ;AAGR,IAAA,gBAAgB,CAAC,IAAuB,EAAA;AACtC,QAAA,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;AACf,YAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC;;;AAIhD,IAAA,YAAY,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDX,EAAA,CAAA;oBACC,eAAe,EAAE,uBAAuB,CAAC;AAC5C,iBAAA;wDAmCW,QAAQ,EAAA,CAAA;sBAAjB;;;AChIH;;AAEG;;;;"}
1
+ {"version":3,"file":"smallpearl-ngx-helper-mat-context-menu.mjs","sources":["../../../../projects/smallpearl/ngx-helper/mat-context-menu/src/mat-context-menu.component.ts","../../../../projects/smallpearl/ngx-helper/mat-context-menu/smallpearl-ngx-helper-mat-context-menu.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n input,\n OnInit,\n Output,\n} from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatMenuModule } from '@angular/material/menu';\nimport { RouterModule } from '@angular/router';\nimport { HoverDropDownDirective } from '@smallpearl/ngx-helper/hover-dropdown';\n\n/**\n * Describes each item in the context menu.\n */\nexport interface SPContextMenuItem {\n // Menu item label\n label: string;\n // Menu icon, A material icon\n icon?: string;\n // Angular route to navigate to when the menu item is selected.\n route?: string | string[];\n // Argument to the (selected) event when this menu item is selected\n // by the user and the corresponding ContextMenuItem does not have a\n // 'route' property value.\n role?: string;\n // Whether the menu item should be disabled\n disable?: (arg: any) => boolean;\n}\n\n@Component({\n imports: [\n RouterModule,\n MatButtonModule,\n MatIconModule,\n MatMenuModule,\n HoverDropDownDirective,\n ],\n selector: 'sp-mat-context-menu',\n template: `\n <button\n #menuTrigger=\"matMenuTrigger\"\n mat-icon-button\n [matMenuTriggerFor]=\"contextMenu\"\n hoverDropDown\n [menu]=\"contextMenu\"\n [hoverTrigger]=\"enableHover() ? menuTrigger : null\"\n >\n @if (menuIconName()) {\n <mat-icon>{{ menuIconName() }}</mat-icon>\n }\n {{ label() }}\n </button>\n <mat-menu #contextMenu=\"matMenu\" [hasBackdrop]=\"hasBackdrop()\">\n @for (menuItem of menuItems(); track $index) {\n @if (menuItem.role) {\n <button\n mat-menu-item\n [routerLink]=\"menuItem.route ? menuItem.route : undefined\"\n (click)=\"$event.preventDefault(); onSelectMenuItem(menuItem)\"\n [disabled]=\"itemDisabled(menuItem)\"\n >\n @if (menuItem.icon) {\n <mat-icon>{{ menuItem.icon }}</mat-icon>\n }\n {{ menuItem.label }}\n </button>\n } @else {\n <div style=\"padding: .2em 0.6em;\">\n <strong>{{ menuItem.label }}</strong>\n </div>\n }\n <!-- <button\n mat-menu-item\n [routerLink]=\"menuItem.route ? menuItem.route : undefined\"\n (click)=\"$event.preventDefault(); onSelectMenuItem(menuItem)\"\n [disabled]=\"itemDisabled(menuItem)\"\n >\n @if (menuItem.icon) {\n <mat-icon>{{ menuItem.icon }}</mat-icon>\n }\n {{ menuItem.label }}\n </button> -->\n }\n </mat-menu>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SPMatContextMenuComponent implements OnInit {\n /**\n * The menu items to display. Refer to ContextMenuItem doc for details\n * on the menu items.\n */\n menuItems = input.required<SPContextMenuItem[]>();\n /**\n * Label to display for the context menu. If omitted will just show the\n * menuIcon.\n */\n label = input<string>('');\n /**\n * Button icon. defaults to more_vert.\n */\n menuIconName = input<string>('more_vert');\n /**\n * By default the context menu is activated whenever the mouse cursor hovers\n * over the button. Set this to 'true' to disable this feature.\n */\n enableHover = input<boolean>(false);\n /**\n * Context data for menu item disabled callback\n */\n contextData = input<any>();\n /**\n * enable menu backdrop\n */\n hasBackdrop = input<boolean>(false);\n /**\n * Event generated when use selects an item in the context menu. This event\n * is generated only if the context menu item does not specify a route to\n * activate. The string event parameter is ContextMenuItem.role property\n * value.\n */\n @Output() selected = new EventEmitter<string>();\n\n constructor() {}\n\n ngOnInit() {}\n\n\n onSelectMenuItem(item: SPContextMenuItem) {\n if (!item.route) {\n this.selected.emit(item?.role || item.label);\n }\n }\n\n itemDisabled(menuItem: SPContextMenuItem) {\n return menuItem?.disable && menuItem.disable(this.contextData());\n }\n}\n","/**\n * Generated bundle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