@masterteam/components 0.0.317 → 0.0.318
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/masterteam-components-business-fields.mjs +4 -4
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +44 -44
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components-field-validation.mjs.map +1 -1
- package/fesm2022/masterteam-components-table.mjs +53 -6
- package/fesm2022/masterteam-components-table.mjs.map +1 -1
- package/fesm2022/masterteam-components-treeselect-field.mjs +2 -2
- package/fesm2022/masterteam-components-treeselect-field.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-table.d.ts +12 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-field-validation.mjs","sources":["../../../../packages/masterteam/components/field-validation/error-message.pipe.ts","../../../../packages/masterteam/components/field-validation/field-validation.ts","../../../../packages/masterteam/components/field-validation/character-limit.validator.ts","../../../../packages/masterteam/components/field-validation/masterteam-components-field-validation.ts"],"sourcesContent":["import { inject, Pipe, PipeTransform } from '@angular/core';\r\nimport { ValidationErrors } from '@angular/forms';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\n\r\n@Pipe({\r\n name: 'errorMessage',\r\n standalone: true,\r\n pure: false,\r\n})\r\nexport class ErrorMessagePipe implements PipeTransform {\r\n private readonly translocoService = inject(TranslocoService);\r\n\r\n transform(errors: ValidationErrors | null): string {\r\n if (!errors) {\r\n return '';\r\n }\r\n\r\n const t = (key: string, params?: object) =>\r\n this.translocoService.translate(`components.validation.${key}`, params);\r\n\r\n // A `.message` on the error object means a caller deliberately configured\r\n // field-specific copy for this failure — ValidatorConfig with an explicit message\r\n // (buildValidators → wrapValidatorWithMessage), or ValidatorConfig.custom\r\n // (createCustomValidator). It must win over the generic translations below,\r\n // otherwise that copy is silently replaced by the generic string, e.g. every\r\n // pattern mismatch reading \"The format is invalid\" no matter what the field\r\n // configured.\r\n //\r\n // The inverse matters just as much: ValidatorConfig's type-specific factories\r\n // deliberately do NOT default `message` (see the note on ValidatorConfig in\r\n // dynamic-form.model.ts). With no message configured the raw Angular validator is\r\n // pushed unwrapped, so nothing reaches this loop and the translated — and, where\r\n // relevant, parameter-interpolated — generic branch below runs instead. Re-adding\r\n // a default there would shadow those translations in every locale but English.\r\n for (const key in errors) {\r\n const errorValue = errors[key];\r\n if (errorValue && typeof errorValue === 'object' && errorValue.message) {\r\n return errorValue.message;\r\n }\r\n }\r\n\r\n if (errors['required']) {\r\n return t('required');\r\n }\r\n if (errors['email']) {\r\n return t('email');\r\n }\r\n if (errors['minlength']) {\r\n const { requiredLength } = errors['minlength'];\r\n return t('minLength', { requiredLength });\r\n }\r\n if (errors['maxlength']) {\r\n const { requiredLength } = errors['maxlength'];\r\n return t('maxLength', { requiredLength });\r\n }\r\n if (errors['characterLimit']) {\r\n const { requiredLength } = errors['characterLimit'];\r\n return t('maxLength', { requiredLength });\r\n }\r\n if (errors['min']) {\r\n const { min } = errors['min'];\r\n return t('min', { min });\r\n }\r\n if (errors['max']) {\r\n const { max } = errors['max'];\r\n return t('max', { max });\r\n }\r\n if (errors['pattern']) {\r\n return t('pattern');\r\n }\r\n if (errors['fileSizeLimited']) {\r\n const { size } = errors['fileSizeLimited'] ?? {};\r\n return t('fileSizeLimited', { size });\r\n }\r\n\r\n // Fallback for any other error\r\n const firstErrorKey = Object.keys(errors)[0];\r\n return t('invalid', { key: firstErrorKey });\r\n }\r\n}\r\n","import {\r\n booleanAttribute,\r\n Component,\r\n computed,\r\n DoCheck,\r\n ElementRef,\r\n inject,\r\n input,\r\n} from '@angular/core';\r\nimport { Message } from 'primeng/message';\r\nimport { AbstractControl } from '@angular/forms';\r\nimport { ErrorMessagePipe } from './error-message.pipe';\r\nimport { _IdGenerator } from '@angular/cdk/a11y';\r\nimport { isInvalid } from '@masterteam/components';\r\n\r\n/**\r\n * First focusable thing inside a field host — the element a screen reader is on\r\n * when it needs to hear that the value was rejected. Covers the native controls\r\n * and the inner input every PrimeNG wrapper renders.\r\n */\r\nconst CONTROL_SELECTOR =\r\n 'input, textarea, select, [contenteditable=\"true\"], [role=\"combobox\"], [role=\"listbox\"], [role=\"spinbutton\"]';\r\n\r\n@Component({\r\n selector: 'mt-field-validation',\r\n standalone: true,\r\n imports: [Message, ErrorMessagePipe],\r\n template: `\r\n @if (isInvalid(control())) {\r\n <p-message\r\n severity=\"error\"\r\n variant=\"simple\"\r\n size=\"small\"\r\n role=\"alert\"\r\n [id]=\"resolvedMessageId()\"\r\n [text]=\"control().errors | errorMessage\"\r\n >\r\n </p-message>\r\n }\r\n `,\r\n host: {\r\n class: 'mt-field-validation',\r\n // Reserve one line of space for fields that can produce an error so the\r\n // message appears/disappears without shifting the field height (and the\r\n // rest of the form). Fields with no validators stay compact.\r\n '[class.mt-field-validation--reserved]': 'shouldReserveSpace()',\r\n },\r\n styles: `\r\n .mt-field-validation {\r\n display: none;\r\n }\r\n .mt-field-validation--reserved {\r\n display: block;\r\n min-height: 1.25rem;\r\n }\r\n `,\r\n})\r\nexport class FieldValidation implements DoCheck {\r\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\r\n\r\n readonly control = input<AbstractControl | null>(null);\r\n readonly touched = input<boolean, unknown>(false, {\r\n transform: booleanAttribute,\r\n });\r\n\r\n /**\r\n * Id the failing control points at with `aria-describedby`. Generated when\r\n * not supplied, so no caller has to pass anything for the wiring below to\r\n * work; override it only when a host needs a predictable id (a test, or a\r\n * second `aria-describedby` target it is composing itself).\r\n */\r\n readonly messageId = input<string | null>(null);\r\n\r\n private readonly fallbackMessageId =\r\n inject(_IdGenerator).getId('mt-field-error-');\r\n\r\n readonly resolvedMessageId = computed(\r\n () => this.messageId()?.trim() || this.fallbackMessageId,\r\n );\r\n\r\n isInvalid = isInvalid;\r\n\r\n /** Cached lookup — the control element never changes for a given field. */\r\n private controlElement: HTMLElement | null | undefined;\r\n private describedApplied = false;\r\n\r\n /**\r\n * Keep `aria-invalid` / `aria-describedby` on the field's own control in step\r\n * with the message below it.\r\n *\r\n * The message used to be loose text with no relationship to anything: a\r\n * screen-reader user heard the field, then — separately, later, if they kept\r\n * reading — an unattributed error (findings C-02, H-04). Wiring it here rather\r\n * than in each of the 23 field templates means every field that already\r\n * renders `mt-field-validation` gets it, including the ones whose control is\r\n * an input PrimeNG renders and the template cannot reach.\r\n *\r\n * `ngDoCheck` rather than an `effect` because `AbstractControl` validity is\r\n * not a signal — the template re-reads it every cycle, and so does this.\r\n */\r\n ngDoCheck(): void {\r\n const target = this.resolveControlElement();\r\n if (!target) {\r\n return;\r\n }\r\n\r\n const invalid = isInvalid(this.control());\r\n if (invalid === this.describedApplied) {\r\n return;\r\n }\r\n\r\n this.describedApplied = invalid;\r\n\r\n if (invalid) {\r\n target.setAttribute('aria-invalid', 'true');\r\n target.setAttribute('aria-describedby', this.resolvedMessageId());\r\n return;\r\n }\r\n\r\n target.removeAttribute('aria-invalid');\r\n if (target.getAttribute('aria-describedby') === this.resolvedMessageId()) {\r\n target.removeAttribute('aria-describedby');\r\n }\r\n }\r\n\r\n /**\r\n * Reserve the error-message line whenever the control can surface an error —\r\n * i.e. it has sync/async validators, or is already showing one. This keeps the\r\n * field's height constant so showing the error never pushes sibling fields or\r\n * the content below the row. Re-evaluated each change-detection cycle, so it\r\n * picks up validators that fields add asynchronously after init.\r\n */\r\n shouldReserveSpace(): boolean {\r\n const control = this.control();\r\n if (!control) {\r\n return false;\r\n }\r\n return (\r\n control.validator !== null ||\r\n control.asyncValidator !== null ||\r\n isInvalid(control)\r\n );\r\n }\r\n\r\n /**\r\n * The control this message belongs to: the first focusable element inside the\r\n * field component that hosts us. `undefined` means \"not looked up yet\",\r\n * `null` means \"looked up and there is nothing to annotate\" — a distinction\r\n * that matters, because the second case must not re-query every cycle.\r\n */\r\n private resolveControlElement(): HTMLElement | null {\r\n if (this.controlElement !== undefined) {\r\n return this.controlElement;\r\n }\r\n\r\n const host = this.elementRef.nativeElement.parentElement;\r\n this.controlElement =\r\n host?.querySelector<HTMLElement>(CONTROL_SELECTOR) ?? null;\r\n\r\n return this.controlElement;\r\n }\r\n}\r\n","import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';\r\n\r\nexport const characterLimitValidator =\r\n (maxLength: number): ValidatorFn =>\r\n (control: AbstractControl): ValidationErrors | null => {\r\n const value = control.value;\r\n\r\n if (value === null || value === undefined) {\r\n return null;\r\n }\r\n\r\n const length = String(value).length;\r\n\r\n return length > maxLength\r\n ? {\r\n characterLimit: {\r\n requiredLength: maxLength,\r\n actualLength: length,\r\n },\r\n }\r\n : null;\r\n };\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MASa,gBAAgB,CAAA;AACV,IAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAE5D,IAAA,SAAS,CAAC,MAA+B,EAAA;QACvC,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,OAAO,EAAE;QACX;QAEA,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,MAAe,KACrC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA,sBAAA,EAAyB,GAAG,CAAA,CAAE,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;AAgBzE,QAAA,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;AACxB,YAAA,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC;YAC9B,IAAI,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,OAAO,EAAE;gBACtE,OAAO,UAAU,CAAC,OAAO;YAC3B;QACF;AAEA,QAAA,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE;AACtB,YAAA,OAAO,CAAC,CAAC,UAAU,CAAC;QACtB;AACA,QAAA,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE;AACnB,YAAA,OAAO,CAAC,C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GAYT,EAAA,IAAA,EACK;AACJ,wBAAA,KAAK,EAAE,qBAAqB;;;;AAI5B,wBAAA,uCAAuC,EAAE,sBAAsB;AAChE,qBAAA,EAAA,MAAA,EAAA,CAAA,sGAAA,CAAA,EAAA;;;AC5CI,MAAM,uBAAuB,GAClC,CAAC,SAAiB,KAClB,CAAC,OAAwB,KAA6B;AACpD,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK;IAE3B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;AACzC,QAAA,OAAO,IAAI;IACb;IAEA,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM;IAEnC,OAAO,MAAM,GAAG;AACd,UAAE;AACE,YAAA,cAAc,EAAE;AACd,gBAAA,cAAc,EAAE,SAAS;AACzB,gBAAA,YAAY,EAAE,MAAM;AACrB,aAAA;AACF;UACD,IAAI;AACV;;ACrBF;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"masterteam-components-field-validation.mjs","sources":["../../../../packages/masterteam/components/field-validation/error-message.pipe.ts","../../../../packages/masterteam/components/field-validation/field-validation.ts","../../../../packages/masterteam/components/field-validation/character-limit.validator.ts","../../../../packages/masterteam/components/field-validation/masterteam-components-field-validation.ts"],"sourcesContent":["import { inject, Pipe, PipeTransform } from '@angular/core';\r\nimport { ValidationErrors } from '@angular/forms';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\n\r\n@Pipe({\r\n name: 'errorMessage',\r\n standalone: true,\r\n pure: false,\r\n})\r\nexport class ErrorMessagePipe implements PipeTransform {\r\n private readonly translocoService = inject(TranslocoService);\r\n\r\n transform(errors: ValidationErrors | null): string {\r\n if (!errors) {\r\n return '';\r\n }\r\n\r\n const t = (key: string, params?: object) =>\r\n this.translocoService.translate(`components.validation.${key}`, params);\r\n\r\n // A `.message` on the error object means a caller deliberately configured\r\n // field-specific copy for this failure — ValidatorConfig with an explicit message\r\n // (buildValidators → wrapValidatorWithMessage), or ValidatorConfig.custom\r\n // (createCustomValidator). It must win over the generic translations below,\r\n // otherwise that copy is silently replaced by the generic string, e.g. every\r\n // pattern mismatch reading \"The format is invalid\" no matter what the field\r\n // configured.\r\n //\r\n // The inverse matters just as much: ValidatorConfig's type-specific factories\r\n // deliberately do NOT default `message` (see the note on ValidatorConfig in\r\n // dynamic-form.model.ts). With no message configured the raw Angular validator is\r\n // pushed unwrapped, so nothing reaches this loop and the translated — and, where\r\n // relevant, parameter-interpolated — generic branch below runs instead. Re-adding\r\n // a default there would shadow those translations in every locale but English.\r\n for (const key in errors) {\r\n const errorValue = errors[key];\r\n if (errorValue && typeof errorValue === 'object' && errorValue.message) {\r\n return errorValue.message;\r\n }\r\n }\r\n\r\n if (errors['required']) {\r\n return t('required');\r\n }\r\n if (errors['email']) {\r\n return t('email');\r\n }\r\n if (errors['minlength']) {\r\n const { requiredLength } = errors['minlength'];\r\n return t('minLength', { requiredLength });\r\n }\r\n if (errors['maxlength']) {\r\n const { requiredLength } = errors['maxlength'];\r\n return t('maxLength', { requiredLength });\r\n }\r\n if (errors['characterLimit']) {\r\n const { requiredLength } = errors['characterLimit'];\r\n return t('maxLength', { requiredLength });\r\n }\r\n if (errors['min']) {\r\n const { min } = errors['min'];\r\n return t('min', { min });\r\n }\r\n if (errors['max']) {\r\n const { max } = errors['max'];\r\n return t('max', { max });\r\n }\r\n if (errors['pattern']) {\r\n return t('pattern');\r\n }\r\n if (errors['fileSizeLimited']) {\r\n const { size } = errors['fileSizeLimited'] ?? {};\r\n return t('fileSizeLimited', { size });\r\n }\r\n\r\n // Fallback for any other error\r\n const firstErrorKey = Object.keys(errors)[0];\r\n return t('invalid', { key: firstErrorKey });\r\n }\r\n}\r\n","import {\r\n booleanAttribute,\r\n Component,\r\n computed,\r\n DoCheck,\r\n ElementRef,\r\n inject,\r\n input,\r\n} from '@angular/core';\r\nimport { Message } from 'primeng/message';\r\nimport { AbstractControl } from '@angular/forms';\r\nimport { ErrorMessagePipe } from './error-message.pipe';\r\nimport { _IdGenerator } from '@angular/cdk/a11y';\r\nimport { isInvalid } from '@masterteam/components';\r\n\r\n/**\r\n * First focusable thing inside a field host — the element a screen reader is on\r\n * when it needs to hear that the value was rejected. Covers the native controls\r\n * and the inner input every PrimeNG wrapper renders.\r\n */\r\nconst CONTROL_SELECTOR =\r\n 'input, textarea, select, [contenteditable=\"true\"], [role=\"combobox\"], [role=\"listbox\"], [role=\"spinbutton\"]';\r\n\r\n@Component({\r\n selector: 'mt-field-validation',\r\n standalone: true,\r\n imports: [Message, ErrorMessagePipe],\r\n template: `\r\n @if (isInvalid(control())) {\r\n <p-message\r\n severity=\"error\"\r\n variant=\"simple\"\r\n size=\"small\"\r\n role=\"alert\"\r\n [id]=\"resolvedMessageId()\"\r\n [text]=\"control().errors | errorMessage\"\r\n >\r\n </p-message>\r\n }\r\n `,\r\n host: {\r\n class: 'mt-field-validation',\r\n // Reserve one line of space for fields that can produce an error so the\r\n // message appears/disappears without shifting the field height (and the\r\n // rest of the form). Fields with no validators stay compact.\r\n '[class.mt-field-validation--reserved]': 'shouldReserveSpace()',\r\n },\r\n styles: `\r\n .mt-field-validation {\r\n display: none;\r\n }\r\n .mt-field-validation--reserved {\r\n display: block;\r\n min-height: 1.25rem;\r\n }\r\n `,\r\n})\r\nexport class FieldValidation implements DoCheck {\r\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\r\n\r\n readonly control = input<AbstractControl | null>(null);\r\n readonly touched = input<boolean, unknown>(false, {\r\n transform: booleanAttribute,\r\n });\r\n\r\n /**\r\n * Id the failing control points at with `aria-describedby`. Generated when\r\n * not supplied, so no caller has to pass anything for the wiring below to\r\n * work; override it only when a host needs a predictable id (a test, or a\r\n * second `aria-describedby` target it is composing itself).\r\n */\r\n readonly messageId = input<string | null>(null);\r\n\r\n private readonly fallbackMessageId =\r\n inject(_IdGenerator).getId('mt-field-error-');\r\n\r\n readonly resolvedMessageId = computed(\r\n () => this.messageId()?.trim() || this.fallbackMessageId,\r\n );\r\n\r\n isInvalid = isInvalid;\r\n\r\n /** Cached lookup — the control element never changes for a given field. */\r\n private controlElement: HTMLElement | null | undefined;\r\n private describedApplied = false;\r\n\r\n /**\r\n * Keep `aria-invalid` / `aria-describedby` on the field's own control in step\r\n * with the message below it.\r\n *\r\n * The message used to be loose text with no relationship to anything: a\r\n * screen-reader user heard the field, then — separately, later, if they kept\r\n * reading — an unattributed error (findings C-02, H-04). Wiring it here rather\r\n * than in each of the 23 field templates means every field that already\r\n * renders `mt-field-validation` gets it, including the ones whose control is\r\n * an input PrimeNG renders and the template cannot reach.\r\n *\r\n * `ngDoCheck` rather than an `effect` because `AbstractControl` validity is\r\n * not a signal — the template re-reads it every cycle, and so does this.\r\n */\r\n ngDoCheck(): void {\r\n const target = this.resolveControlElement();\r\n if (!target) {\r\n return;\r\n }\r\n\r\n const invalid = isInvalid(this.control());\r\n if (invalid === this.describedApplied) {\r\n return;\r\n }\r\n\r\n this.describedApplied = invalid;\r\n\r\n if (invalid) {\r\n target.setAttribute('aria-invalid', 'true');\r\n target.setAttribute('aria-describedby', this.resolvedMessageId());\r\n return;\r\n }\r\n\r\n target.removeAttribute('aria-invalid');\r\n if (target.getAttribute('aria-describedby') === this.resolvedMessageId()) {\r\n target.removeAttribute('aria-describedby');\r\n }\r\n }\r\n\r\n /**\r\n * Reserve the error-message line whenever the control can surface an error —\r\n * i.e. it has sync/async validators, or is already showing one. This keeps the\r\n * field's height constant so showing the error never pushes sibling fields or\r\n * the content below the row. Re-evaluated each change-detection cycle, so it\r\n * picks up validators that fields add asynchronously after init.\r\n */\r\n shouldReserveSpace(): boolean {\r\n const control = this.control();\r\n if (!control) {\r\n return false;\r\n }\r\n return (\r\n control.validator !== null ||\r\n control.asyncValidator !== null ||\r\n isInvalid(control)\r\n );\r\n }\r\n\r\n /**\r\n * The control this message belongs to: the first focusable element inside the\r\n * field component that hosts us. `undefined` means \"not looked up yet\",\r\n * `null` means \"looked up and there is nothing to annotate\" — a distinction\r\n * that matters, because the second case must not re-query every cycle.\r\n */\r\n private resolveControlElement(): HTMLElement | null {\r\n if (this.controlElement !== undefined) {\r\n return this.controlElement;\r\n }\r\n\r\n const host = this.elementRef.nativeElement.parentElement;\r\n this.controlElement =\r\n host?.querySelector<HTMLElement>(CONTROL_SELECTOR) ?? null;\r\n\r\n return this.controlElement;\r\n }\r\n}\r\n","import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';\n\nexport const characterLimitValidator =\n (maxLength: number): ValidatorFn =>\n (control: AbstractControl): ValidationErrors | null => {\n const value = control.value;\n\n if (value === null || value === undefined) {\n return null;\n }\n\n const length = String(value).length;\n\n return length > maxLength\n ? {\n characterLimit: {\n requiredLength: maxLength,\n actualLength: length,\n },\n }\n : null;\n };\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MASa,gBAAgB,CAAA;AACV,IAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAE5D,IAAA,SAAS,CAAC,MAA+B,EAAA;QACvC,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,OAAO,EAAE;QACX;QAEA,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,MAAe,KACrC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA,sBAAA,EAAyB,GAAG,CAAA,CAAE,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;AAgBzE,QAAA,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;AACxB,YAAA,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC;YAC9B,IAAI,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,OAAO,EAAE;gBACtE,OAAO,UAAU,CAAC,OAAO;YAC3B;QACF;AAEA,QAAA,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE;AACtB,YAAA,OAAO,CAAC,CAAC,UAAU,CAAC;QACtB;AACA,QAAA,IAAI,MAAM,CAAC,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AAC,EAAA,QAAA,EAC1B,CAAA;;;;;;;;;;;;GAYT,EAAA,IAAA,EACK;AACJ,wBAAA,KAAK,EAAE,qBAAqB;;;;AAI5B,wBAAA,uCAAuC,EAAE,sBAAsB;AAChE,qBAAA,EAAA,MAAA,EAAA,CAAA,sGAAA,CAAA,EAAA;;;AC5CI,MAAM,uBAAuB,GAClC,CAAC,SAAiB,KAClB,CAAC,OAAwB,KAA6B;AACpD,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK;IAE3B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;AACzC,QAAA,OAAO,IAAI;IACb;IAEA,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM;IAEnC,OAAO,MAAM,GAAG;AACd,UAAE;AACE,YAAA,cAAc,EAAE;AACd,gBAAA,cAAc,EAAE,SAAS;AACzB,gBAAA,YAAY,EAAE,MAAM;AACrB,aAAA;AACF;UACD,IAAI;AACV;;ACrBF;;AAEG;;;;"}
|
|
@@ -39,6 +39,29 @@ import { ProgressBarModule } from 'primeng/progressbar';
|
|
|
39
39
|
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
40
40
|
import { EmptyState } from '@masterteam/components/empty-state';
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Export and print wear their file format's brand colour, so they read as
|
|
44
|
+
* "spreadsheet" and "PDF" on sight — the theme's success/info hues said
|
|
45
|
+
* neither. Deliberately not theme tokens: these colours are the brands'.
|
|
46
|
+
*/
|
|
47
|
+
const BRAND_COLOR = {
|
|
48
|
+
excel: '#10793F', // Microsoft Excel green
|
|
49
|
+
pdf: '#FA0F00', // Adobe Acrobat red
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Re-points one outlined-button severity's PrimeNG tokens at a brand colour.
|
|
53
|
+
* Set on the `mt-button` host, the custom properties inherit into the inner
|
|
54
|
+
* `p-button`, so border, hover and pressed states all follow without CSS.
|
|
55
|
+
*/
|
|
56
|
+
function outlinedButtonTokens(severity, color) {
|
|
57
|
+
const token = `--p-button-outlined-${severity}`;
|
|
58
|
+
return {
|
|
59
|
+
[`${token}-color`]: color,
|
|
60
|
+
[`${token}-border-color`]: `color-mix(in srgb, ${color} 35%, transparent)`,
|
|
61
|
+
[`${token}-hover-background`]: `color-mix(in srgb, ${color} 6%, transparent)`,
|
|
62
|
+
[`${token}-active-background`]: `color-mix(in srgb, ${color} 12%, transparent)`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
42
65
|
/**
|
|
43
66
|
* Up to this many actions render as their own buttons instead of hiding behind
|
|
44
67
|
* the `⋯`. Export / print / group-by is exactly three, so the common table
|
|
@@ -64,18 +87,42 @@ class TableActionsMenu {
|
|
|
64
87
|
menu = viewChild('menu', ...(ngDevMode ? [{ debugName: "menu" }] : /* istanbul ignore next */ []));
|
|
65
88
|
/** Tailwind classes for flat tone chips, keyed by `iconTone`. */
|
|
66
89
|
toneClass = {
|
|
67
|
-
|
|
68
|
-
|
|
90
|
+
excel: '',
|
|
91
|
+
pdf: '',
|
|
69
92
|
indigo: 'bg-indigo-50 text-indigo-700',
|
|
70
93
|
secondary: 'bg-gray-100 text-gray-700',
|
|
71
94
|
};
|
|
95
|
+
/** Brand-coloured chips, which Tailwind's palette cannot name. */
|
|
96
|
+
toneChipStyle = Object.fromEntries(Object.entries(BRAND_COLOR).map(([tone, color]) => [
|
|
97
|
+
tone,
|
|
98
|
+
{
|
|
99
|
+
color,
|
|
100
|
+
'background-color': `color-mix(in srgb, ${color} 10%, transparent)`,
|
|
101
|
+
},
|
|
102
|
+
]));
|
|
103
|
+
/**
|
|
104
|
+
* The same hues for flat mode, as button severities. Rendered as their own
|
|
105
|
+
* buttons the actions were all `secondary` grey, so export, print and
|
|
106
|
+
* group-by looked identical until hovered. The brand tones keep a fitting
|
|
107
|
+
* severity as the fallback and re-point its tokens (`toneButtonStyle`).
|
|
108
|
+
*/
|
|
109
|
+
toneSeverity = {
|
|
110
|
+
excel: 'success',
|
|
111
|
+
pdf: 'danger',
|
|
112
|
+
indigo: 'help',
|
|
113
|
+
secondary: 'secondary',
|
|
114
|
+
};
|
|
115
|
+
toneButtonStyle = {
|
|
116
|
+
excel: outlinedButtonTokens('success', BRAND_COLOR.excel),
|
|
117
|
+
pdf: outlinedButtonTokens('danger', BRAND_COLOR.pdf),
|
|
118
|
+
};
|
|
72
119
|
items = computed(() => {
|
|
73
120
|
const items = [];
|
|
74
121
|
if (this.exportable()) {
|
|
75
122
|
items.push({
|
|
76
123
|
labelKey: 'components.table.exportExcel',
|
|
77
124
|
iconKey: 'file.file-download-02',
|
|
78
|
-
iconTone: '
|
|
125
|
+
iconTone: 'excel',
|
|
79
126
|
command: () => this.exportRequested.emit(),
|
|
80
127
|
});
|
|
81
128
|
}
|
|
@@ -83,7 +130,7 @@ class TableActionsMenu {
|
|
|
83
130
|
items.push({
|
|
84
131
|
labelKey: 'components.table.printPdf',
|
|
85
132
|
iconKey: 'media.printer',
|
|
86
|
-
iconTone: '
|
|
133
|
+
iconTone: 'pdf',
|
|
87
134
|
command: () => this.printRequested.emit(),
|
|
88
135
|
});
|
|
89
136
|
}
|
|
@@ -143,11 +190,11 @@ class TableActionsMenu {
|
|
|
143
190
|
this.menu()?.toggle(event);
|
|
144
191
|
}
|
|
145
192
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableActionsMenu, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
146
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: TableActionsMenu, isStandalone: true, selector: "mt-table-actions-menu", inputs: { exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: true, isRequired: false, transformFunction: null }, printable: { classPropertyName: "printable", publicName: "printable", isSignal: true, isRequired: false, transformFunction: null }, groupable: { classPropertyName: "groupable", publicName: "groupable", isSignal: true, isRequired: false, transformFunction: null }, groupColumns: { classPropertyName: "groupColumns", publicName: "groupColumns", isSignal: true, isRequired: false, transformFunction: null }, activeGroup: { classPropertyName: "activeGroup", publicName: "activeGroup", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { exportRequested: "exportRequested", printRequested: "printRequested", groupChange: "groupChange" }, host: { classAttribute: "flex items-center gap-2" }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (isFlat()) {\r\n @for (item of items(); track item.labelKey ?? item.rawLabel) {\r\n <mt-button\r\n (click)=\"activate($event, item)\"\r\n [icon]=\"item.iconKey\"\r\n [label]=\"item.badge\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"\r\n item.labelKey ? (item.labelKey | transloco) : (item.rawLabel ?? '')\r\n \"\r\n />\r\n }\r\n} @else {\r\n <mt-button\r\n (click)=\"toggle($event)\"\r\n icon=\"general.dots-horizontal\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"'components.table.actions' | transloco\"\r\n />\r\n}\r\n\r\n<p-tieredMenu\r\n #menu\r\n [model]=\"menuModel()\"\r\n [popup]=\"true\"\r\n appendTo=\"body\"\r\n styleClass=\"mt-table-actions-menu\"\r\n>\r\n <ng-template #item let-item let-hasSubmenu=\"hasSubmenu\">\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center gap-2.5 w-full px-2.5 py-2 text-sm cursor-pointer text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-surface-700 transition-colors\"\r\n [class.bg-primary-50]=\"item.selected\"\r\n [class.dark:bg-primary-950]=\"item.selected\"\r\n [class.text-primary-700]=\"item.selected\"\r\n >\r\n @if (item.iconKey) {\r\n @if (item.useAvatar) {\r\n <mt-avatar [icon]=\"item.iconKey\" shape=\"circle\" />\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center justify-center w-7 h-7 rounded-full shrink-0\"\r\n [class]=\"toneClass[item.iconTone ?? 'secondary']\"\r\n >\r\n <mt-icon [icon]=\"item.iconKey\" class=\"text-sm\" />\r\n </span>\r\n }\r\n }\r\n <span class=\"flex-1 text-start truncate\">\r\n @if (item.labelKey) {\r\n {{ item.labelKey | transloco }}\r\n } @else {\r\n {{ item.rawLabel }}\r\n }\r\n </span>\r\n @if (item.badge) {\r\n <span\r\n class=\"text-xs px-1.5 py-0.5 rounded-full bg-primary-50 text-primary-700 dark:bg-primary-950 dark:text-primary-300 shrink-0\"\r\n >\r\n {{ item.badge }}\r\n </span>\r\n }\r\n @if (hasSubmenu) {\r\n <mt-icon\r\n icon=\"arrow.chevron-right\"\r\n class=\"text-xs text-gray-400 shrink-0\"\r\n />\r\n }\r\n </button>\r\n </ng-template>\r\n</p-tieredMenu>\r\n", dependencies: [{ kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "ngmodule", type: TieredMenuModule }, { kind: "component", type: i1.TieredMenu, selector: "p-tieredMenu, p-tieredmenu, p-tiered-menu", inputs: ["model", "popup", "style", "styleClass", "breakpoint", "autoZIndex", "baseZIndex", "autoDisplay", "showTransitionOptions", "hideTransitionOptions", "id", "ariaLabel", "ariaLabelledBy", "disabled", "tabindex", "appendTo", "motionOptions"], outputs: ["onShow", "onHide"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i2.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
193
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: TableActionsMenu, isStandalone: true, selector: "mt-table-actions-menu", inputs: { exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: true, isRequired: false, transformFunction: null }, printable: { classPropertyName: "printable", publicName: "printable", isSignal: true, isRequired: false, transformFunction: null }, groupable: { classPropertyName: "groupable", publicName: "groupable", isSignal: true, isRequired: false, transformFunction: null }, groupColumns: { classPropertyName: "groupColumns", publicName: "groupColumns", isSignal: true, isRequired: false, transformFunction: null }, activeGroup: { classPropertyName: "activeGroup", publicName: "activeGroup", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { exportRequested: "exportRequested", printRequested: "printRequested", groupChange: "groupChange" }, host: { classAttribute: "flex items-center gap-2" }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (isFlat()) {\r\n @for (item of items(); track item.labelKey ?? item.rawLabel) {\r\n <mt-button\r\n (click)=\"activate($event, item)\"\r\n [icon]=\"item.iconKey\"\r\n [label]=\"item.badge\"\r\n [severity]=\"toneSeverity[item.iconTone ?? 'secondary']\"\r\n [style]=\"toneButtonStyle[item.iconTone ?? 'secondary'] ?? null\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"\r\n item.labelKey ? (item.labelKey | transloco) : (item.rawLabel ?? '')\r\n \"\r\n />\r\n }\r\n} @else {\r\n <mt-button\r\n (click)=\"toggle($event)\"\r\n icon=\"general.dots-horizontal\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"'components.table.actions' | transloco\"\r\n />\r\n}\r\n\r\n<p-tieredMenu\r\n #menu\r\n [model]=\"menuModel()\"\r\n [popup]=\"true\"\r\n appendTo=\"body\"\r\n styleClass=\"mt-table-actions-menu\"\r\n>\r\n <ng-template #item let-item let-hasSubmenu=\"hasSubmenu\">\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center gap-2.5 w-full px-2.5 py-2 text-sm cursor-pointer text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-surface-700 transition-colors\"\r\n [class.bg-primary-50]=\"item.selected\"\r\n [class.dark:bg-primary-950]=\"item.selected\"\r\n [class.text-primary-700]=\"item.selected\"\r\n >\r\n @if (item.iconKey) {\r\n @if (item.useAvatar) {\r\n <mt-avatar [icon]=\"item.iconKey\" shape=\"circle\" />\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center justify-center w-7 h-7 rounded-full shrink-0\"\r\n [class]=\"toneClass[item.iconTone ?? 'secondary']\"\r\n [style]=\"toneChipStyle[item.iconTone ?? 'secondary'] ?? null\"\r\n >\r\n <mt-icon [icon]=\"item.iconKey\" class=\"text-sm\" />\r\n </span>\r\n }\r\n }\r\n <span class=\"flex-1 text-start truncate\">\r\n @if (item.labelKey) {\r\n {{ item.labelKey | transloco }}\r\n } @else {\r\n {{ item.rawLabel }}\r\n }\r\n </span>\r\n @if (item.badge) {\r\n <span\r\n class=\"text-xs px-1.5 py-0.5 rounded-full bg-primary-50 text-primary-700 dark:bg-primary-950 dark:text-primary-300 shrink-0\"\r\n >\r\n {{ item.badge }}\r\n </span>\r\n }\r\n @if (hasSubmenu) {\r\n <mt-icon\r\n icon=\"arrow.chevron-right\"\r\n class=\"text-xs text-gray-400 shrink-0\"\r\n />\r\n }\r\n </button>\r\n </ng-template>\r\n</p-tieredMenu>\r\n", dependencies: [{ kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "ngmodule", type: TieredMenuModule }, { kind: "component", type: i1.TieredMenu, selector: "p-tieredMenu, p-tieredmenu, p-tiered-menu", inputs: ["model", "popup", "style", "styleClass", "breakpoint", "autoZIndex", "baseZIndex", "autoDisplay", "showTransitionOptions", "hideTransitionOptions", "id", "ariaLabel", "ariaLabelledBy", "disabled", "tabindex", "appendTo", "motionOptions"], outputs: ["onShow", "onHide"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i2.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
147
194
|
}
|
|
148
195
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableActionsMenu, decorators: [{
|
|
149
196
|
type: Component,
|
|
150
|
-
args: [{ selector: 'mt-table-actions-menu', standalone: true, imports: [Avatar, Button, Icon, TieredMenuModule, TranslocoModule], host: { class: 'flex items-center gap-2' }, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (isFlat()) {\r\n @for (item of items(); track item.labelKey ?? item.rawLabel) {\r\n <mt-button\r\n (click)=\"activate($event, item)\"\r\n [icon]=\"item.iconKey\"\r\n [label]=\"item.badge\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"\r\n item.labelKey ? (item.labelKey | transloco) : (item.rawLabel ?? '')\r\n \"\r\n />\r\n }\r\n} @else {\r\n <mt-button\r\n (click)=\"toggle($event)\"\r\n icon=\"general.dots-horizontal\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"'components.table.actions' | transloco\"\r\n />\r\n}\r\n\r\n<p-tieredMenu\r\n #menu\r\n [model]=\"menuModel()\"\r\n [popup]=\"true\"\r\n appendTo=\"body\"\r\n styleClass=\"mt-table-actions-menu\"\r\n>\r\n <ng-template #item let-item let-hasSubmenu=\"hasSubmenu\">\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center gap-2.5 w-full px-2.5 py-2 text-sm cursor-pointer text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-surface-700 transition-colors\"\r\n [class.bg-primary-50]=\"item.selected\"\r\n [class.dark:bg-primary-950]=\"item.selected\"\r\n [class.text-primary-700]=\"item.selected\"\r\n >\r\n @if (item.iconKey) {\r\n @if (item.useAvatar) {\r\n <mt-avatar [icon]=\"item.iconKey\" shape=\"circle\" />\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center justify-center w-7 h-7 rounded-full shrink-0\"\r\n [class]=\"toneClass[item.iconTone ?? 'secondary']\"\r\n >\r\n <mt-icon [icon]=\"item.iconKey\" class=\"text-sm\" />\r\n </span>\r\n }\r\n }\r\n <span class=\"flex-1 text-start truncate\">\r\n @if (item.labelKey) {\r\n {{ item.labelKey | transloco }}\r\n } @else {\r\n {{ item.rawLabel }}\r\n }\r\n </span>\r\n @if (item.badge) {\r\n <span\r\n class=\"text-xs px-1.5 py-0.5 rounded-full bg-primary-50 text-primary-700 dark:bg-primary-950 dark:text-primary-300 shrink-0\"\r\n >\r\n {{ item.badge }}\r\n </span>\r\n }\r\n @if (hasSubmenu) {\r\n <mt-icon\r\n icon=\"arrow.chevron-right\"\r\n class=\"text-xs text-gray-400 shrink-0\"\r\n />\r\n }\r\n </button>\r\n </ng-template>\r\n</p-tieredMenu>\r\n" }]
|
|
197
|
+
args: [{ selector: 'mt-table-actions-menu', standalone: true, imports: [Avatar, Button, Icon, TieredMenuModule, TranslocoModule], host: { class: 'flex items-center gap-2' }, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (isFlat()) {\r\n @for (item of items(); track item.labelKey ?? item.rawLabel) {\r\n <mt-button\r\n (click)=\"activate($event, item)\"\r\n [icon]=\"item.iconKey\"\r\n [label]=\"item.badge\"\r\n [severity]=\"toneSeverity[item.iconTone ?? 'secondary']\"\r\n [style]=\"toneButtonStyle[item.iconTone ?? 'secondary'] ?? null\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"\r\n item.labelKey ? (item.labelKey | transloco) : (item.rawLabel ?? '')\r\n \"\r\n />\r\n }\r\n} @else {\r\n <mt-button\r\n (click)=\"toggle($event)\"\r\n icon=\"general.dots-horizontal\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"'components.table.actions' | transloco\"\r\n />\r\n}\r\n\r\n<p-tieredMenu\r\n #menu\r\n [model]=\"menuModel()\"\r\n [popup]=\"true\"\r\n appendTo=\"body\"\r\n styleClass=\"mt-table-actions-menu\"\r\n>\r\n <ng-template #item let-item let-hasSubmenu=\"hasSubmenu\">\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center gap-2.5 w-full px-2.5 py-2 text-sm cursor-pointer text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-surface-700 transition-colors\"\r\n [class.bg-primary-50]=\"item.selected\"\r\n [class.dark:bg-primary-950]=\"item.selected\"\r\n [class.text-primary-700]=\"item.selected\"\r\n >\r\n @if (item.iconKey) {\r\n @if (item.useAvatar) {\r\n <mt-avatar [icon]=\"item.iconKey\" shape=\"circle\" />\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center justify-center w-7 h-7 rounded-full shrink-0\"\r\n [class]=\"toneClass[item.iconTone ?? 'secondary']\"\r\n [style]=\"toneChipStyle[item.iconTone ?? 'secondary'] ?? null\"\r\n >\r\n <mt-icon [icon]=\"item.iconKey\" class=\"text-sm\" />\r\n </span>\r\n }\r\n }\r\n <span class=\"flex-1 text-start truncate\">\r\n @if (item.labelKey) {\r\n {{ item.labelKey | transloco }}\r\n } @else {\r\n {{ item.rawLabel }}\r\n }\r\n </span>\r\n @if (item.badge) {\r\n <span\r\n class=\"text-xs px-1.5 py-0.5 rounded-full bg-primary-50 text-primary-700 dark:bg-primary-950 dark:text-primary-300 shrink-0\"\r\n >\r\n {{ item.badge }}\r\n </span>\r\n }\r\n @if (hasSubmenu) {\r\n <mt-icon\r\n icon=\"arrow.chevron-right\"\r\n class=\"text-xs text-gray-400 shrink-0\"\r\n />\r\n }\r\n </button>\r\n </ng-template>\r\n</p-tieredMenu>\r\n" }]
|
|
151
198
|
}], propDecorators: { exportable: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportable", required: false }] }], printable: [{ type: i0.Input, args: [{ isSignal: true, alias: "printable", required: false }] }], groupable: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupable", required: false }] }], groupColumns: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupColumns", required: false }] }], activeGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeGroup", required: false }] }], exportRequested: [{ type: i0.Output, args: ["exportRequested"] }], printRequested: [{ type: i0.Output, args: ["printRequested"] }], groupChange: [{ type: i0.Output, args: ["groupChange"] }], menu: [{ type: i0.ViewChild, args: ['menu', { isSignal: true }] }] } });
|
|
152
199
|
|
|
153
200
|
class TableValueResolver {
|