@masterteam/components 0.0.278 → 0.0.280
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 +22 -2
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-runtime-action.mjs +76 -27
- package/fesm2022/masterteam-components-runtime-action.mjs.map +1 -1
- package/fesm2022/masterteam-components-sidebar.mjs +10 -3
- package/fesm2022/masterteam-components-sidebar.mjs.map +1 -1
- package/fesm2022/masterteam-components-topbar.mjs +10 -3
- package/fesm2022/masterteam-components-topbar.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +2 -0
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-business-fields.d.ts +10 -2
- package/types/masterteam-components-runtime-action.d.ts +37 -2
- package/types/masterteam-components-sidebar.d.ts +3 -0
- package/types/masterteam-components-topbar.d.ts +3 -0
- package/types/masterteam-components.d.ts +13 -1
|
@@ -52,7 +52,12 @@ function buildTemplatePayload(action, formValue, externalResolvers) {
|
|
|
52
52
|
const payloadKeys = action.payloadKeys ?? Object.keys(template);
|
|
53
53
|
for (const key of payloadKeys) {
|
|
54
54
|
if (key === 'fields') {
|
|
55
|
-
|
|
55
|
+
// The backend declares the operation's inputs as a `fields` template of
|
|
56
|
+
// `{ propertyKey, value: null }` placeholders. Only a host that rendered
|
|
57
|
+
// the operation's real form can fill them (see `hasActionInputFields`),
|
|
58
|
+
// so the values are taken whole from the form or left as declared —
|
|
59
|
+
// never patched per property key from here.
|
|
60
|
+
payload[key] = formValue?.['fields'] ?? template['fields'];
|
|
56
61
|
continue;
|
|
57
62
|
}
|
|
58
63
|
const formFieldValue = formValue?.[key];
|
|
@@ -109,6 +114,27 @@ function resolveDefaultPayloadValue(key) {
|
|
|
109
114
|
return undefined;
|
|
110
115
|
}
|
|
111
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* The declared operation inputs the payload would submit with no value — the
|
|
119
|
+
* `{ propertyKey, value: null }` placeholders the backend sent, still unfilled.
|
|
120
|
+
*
|
|
121
|
+
* A non-empty result means the action was fired without rendering its form, and
|
|
122
|
+
* submitting it would write nulls over the record (or fail the contract's
|
|
123
|
+
* `operation_input.required` rule). Hosts fill these by running the operation
|
|
124
|
+
* through `process-form-load` / `process-submit` instead.
|
|
125
|
+
*/
|
|
126
|
+
function getUnfilledActionInputKeys(payload) {
|
|
127
|
+
const fields = payload?.['fields'];
|
|
128
|
+
if (!Array.isArray(fields)) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
return fields
|
|
132
|
+
.filter((field) => !!field &&
|
|
133
|
+
typeof field === 'object' &&
|
|
134
|
+
field.value == null)
|
|
135
|
+
.map((field) => field.propertyKey)
|
|
136
|
+
.filter((key) => typeof key === 'string' && key.trim() !== '');
|
|
137
|
+
}
|
|
112
138
|
function getMissingRequiredPayloadKeys(action, payload) {
|
|
113
139
|
return (action.requiredPayloadKeys ?? []).filter((key) => isMissingPayloadValue(payload?.[key]));
|
|
114
140
|
}
|
|
@@ -143,36 +169,49 @@ function buildRequestOptions(method, payload) {
|
|
|
143
169
|
observe: 'body',
|
|
144
170
|
};
|
|
145
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* The action collects free-form request metadata — a reason, a note, a
|
|
174
|
+
* delegate, attachments — which the generic confirm dialog can render on its
|
|
175
|
+
* own because the keys are fixed and operation-independent.
|
|
176
|
+
*
|
|
177
|
+
* Operation *inputs* are a different thing entirely: see
|
|
178
|
+
* {@link hasActionInputFields}.
|
|
179
|
+
*/
|
|
146
180
|
function hasActionFormFields(action) {
|
|
147
|
-
return (
|
|
181
|
+
return (action.payloadKeys ?? []).some((key) => ['delegatedUser', 'reason', 'note', 'attachments'].includes(key));
|
|
148
182
|
}
|
|
149
|
-
|
|
183
|
+
/**
|
|
184
|
+
* The action declares operation inputs the user still has to supply — its
|
|
185
|
+
* `payloadTemplate.fields` is a non-empty list of `{ propertyKey, value: null }`
|
|
186
|
+
* placeholders.
|
|
187
|
+
*
|
|
188
|
+
* Firing such an action straight from its template submits those nulls, so a
|
|
189
|
+
* host must instead run the operation through its own form: `process-form-load`
|
|
190
|
+
* for the effective form and current values, `process-submit/validate`, then
|
|
191
|
+
* `process-submit`. The backend owns which fields those are — never infer them
|
|
192
|
+
* from the operation key.
|
|
193
|
+
*/
|
|
194
|
+
function hasActionInputFields(action) {
|
|
150
195
|
const fields = action.payloadTemplate
|
|
151
196
|
?.fields;
|
|
152
|
-
return
|
|
153
|
-
fields.some((field) => !!field &&
|
|
154
|
-
typeof field === 'object' &&
|
|
155
|
-
field.propertyKey === 'Progress'));
|
|
197
|
+
return Array.isArray(fields) && fields.length > 0;
|
|
156
198
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
199
|
+
/**
|
|
200
|
+
* The property keys an action declares as its operation inputs, in the
|
|
201
|
+
* backend's own casing. Pass them to `mt-client-form`'s `allowedFieldKeys` to
|
|
202
|
+
* scope a configured form down to the inputs this action actually writes.
|
|
203
|
+
*/
|
|
204
|
+
function getActionInputFieldKeys(action) {
|
|
205
|
+
const fields = action.payloadTemplate
|
|
206
|
+
?.fields;
|
|
207
|
+
if (!Array.isArray(fields)) {
|
|
208
|
+
return [];
|
|
164
209
|
}
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
...field,
|
|
173
|
-
value: formValue?.['progress'] ?? field.value,
|
|
174
|
-
};
|
|
175
|
-
});
|
|
210
|
+
return fields
|
|
211
|
+
.map((field) => field && typeof field === 'object'
|
|
212
|
+
? field.propertyKey
|
|
213
|
+
: null)
|
|
214
|
+
.filter((key) => typeof key === 'string' && key.trim() !== '');
|
|
176
215
|
}
|
|
177
216
|
|
|
178
217
|
class RuntimeActionContextStore {
|
|
@@ -218,7 +257,17 @@ class RuntimeActionRunner {
|
|
|
218
257
|
if (options.transformPayload) {
|
|
219
258
|
payload = options.transformPayload(payload, action);
|
|
220
259
|
}
|
|
221
|
-
|
|
260
|
+
// An action that declares operation inputs cannot be fired from its
|
|
261
|
+
// template alone: the backend sends those fields as `value: null`
|
|
262
|
+
// placeholders for a form to fill, so submitting them as-is writes nulls
|
|
263
|
+
// over the record. Only checked when no form value was collected — a host
|
|
264
|
+
// that supplied one owns what it put in `fields`, cleared values included.
|
|
265
|
+
// The way to run such an action is `process-form-load` →
|
|
266
|
+
// `process-submit/validate` → `process-submit`; see `hasActionInputFields`.
|
|
267
|
+
const missing = [
|
|
268
|
+
...getMissingRequiredPayloadKeys(action, payload),
|
|
269
|
+
...(formValue ? [] : getUnfilledActionInputKeys(payload)),
|
|
270
|
+
];
|
|
222
271
|
if (missing.length) {
|
|
223
272
|
const message = this.transloco.translate('components.runtimeAction.missingArgs', { action: resolveActionLabel(action), missing: missing.join(', ') });
|
|
224
273
|
if (!options.silent) {
|
|
@@ -402,5 +451,5 @@ function resolveHttpErrorMessage(error, fallback) {
|
|
|
402
451
|
* Generated bundle index. Do not edit.
|
|
403
452
|
*/
|
|
404
453
|
|
|
405
|
-
export { RUNTIME_ACTION_CONFIRM_DIALOG, RuntimeActionContextStore, RuntimeActionRunner, buildActionPayload, buildRequestOptions, getMissingRequiredPayloadKeys, hasActionFormFields,
|
|
454
|
+
export { RUNTIME_ACTION_CONFIRM_DIALOG, RuntimeActionContextStore, RuntimeActionRunner, buildActionPayload, buildRequestOptions, getActionInputFieldKeys, getMissingRequiredPayloadKeys, getUnfilledActionInputKeys, hasActionFormFields, hasActionInputFields, isMissingPayloadValue, methodSupportsBody, normalizeHttpMethod, normalizePayloadValue, resolveActionLabel, resolveDefaultPayloadValue };
|
|
406
455
|
//# sourceMappingURL=masterteam-components-runtime-action.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-components-runtime-action.mjs","sources":["../../../../packages/masterteam/components/runtime-action/runtime-action.types.ts","../../../../packages/masterteam/components/runtime-action/payload-builder.ts","../../../../packages/masterteam/components/runtime-action/runtime-action-context.store.ts","../../../../packages/masterteam/components/runtime-action/runtime-action.runner.ts","../../../../packages/masterteam/components/runtime-action/masterteam-components-runtime-action.ts"],"sourcesContent":["export interface RuntimeActionTranslatable {\r\n display?: string;\r\n en?: string;\r\n ar?: string;\r\n}\r\n\r\nexport type RuntimeActionAfterSuccess = 'refresh' | 'close';\r\n\r\nexport interface RuntimeActionReason {\r\n source?: string;\r\n code?: string;\r\n message?: string;\r\n blocking?: boolean;\r\n details?: string | null;\r\n ruleKey?: string | null;\r\n requestId?: number | null;\r\n requestStatus?: string | null;\r\n requestSchemaId?: number | null;\r\n relatedRequestIds?: number[];\r\n}\r\n\r\nexport interface RuntimeAction {\r\n actionKey: string;\r\n actionName?: RuntimeActionTranslatable | string | null;\r\n httpMethod?: string | null;\r\n url?: string | null;\r\n isAvailable?: boolean;\r\n afterSuccess?: RuntimeActionAfterSuccess | null;\r\n stepIds?: Array<number | string>;\r\n needConfirmation?: boolean;\r\n payloadKeys?: string[];\r\n requiredPayloadKeys?: string[];\r\n payloadTemplate?: Record<string, unknown> | null;\r\n formId?: string | number | null;\r\n\r\n targetType?: string;\r\n targetId?: number;\r\n moduleKey?: string;\r\n operationKey?: string;\r\n primaryReasonCode?: string | null;\r\n reasons?: RuntimeActionReason[];\r\n}\r\n\r\nexport type RuntimeActionStatus = 'success' | 'error' | 'cancelled';\r\n\r\nexport interface RuntimeActionResult {\r\n status: RuntimeActionStatus;\r\n actionKey: string;\r\n afterSuccess: RuntimeActionAfterSuccess | null;\r\n response?: unknown;\r\n error?: unknown;\r\n}\r\n\r\nexport interface RuntimeActionExecuteOptions {\r\n externalPayloadResolvers?: Record<string, () => unknown>;\r\n defaultAfterSuccess?: RuntimeActionAfterSuccess;\r\n successMessage?: (response: unknown, action: RuntimeAction) => string;\r\n errorMessage?: (error: unknown, action: RuntimeAction) => string;\r\n transformPayload?: (\r\n payload: Record<string, unknown> | undefined,\r\n action: RuntimeAction,\r\n ) => Record<string, unknown> | undefined;\r\n silent?: boolean;\r\n}\r\n\r\nexport interface RuntimeActionFormValue {\r\n requestPropertyId?: number;\r\n propertyKey: string;\r\n value: unknown;\r\n}\r\n\r\nexport interface RuntimeActionFormSource {\r\n getSubmitValues(): RuntimeActionFormValue[] | undefined;\r\n}\r\n\r\nexport function resolveActionLabel(action: RuntimeAction): string {\r\n const name = action.actionName;\r\n if (typeof name === 'string') {\r\n return name || action.actionKey;\r\n }\r\n return name?.display || action.actionKey;\r\n}\r\n","import { RuntimeAction } from './runtime-action.types';\r\n\r\nexport function buildActionPayload(\r\n action: RuntimeAction,\r\n formValue: Record<string, unknown> | undefined,\r\n externalResolvers: Record<string, () => unknown> = {},\r\n): Record<string, unknown> | undefined {\r\n const templatePayload = buildTemplatePayload(\r\n action,\r\n formValue,\r\n externalResolvers,\r\n );\r\n if (templatePayload) {\r\n return templatePayload;\r\n }\r\n\r\n const payloadKeys = action.payloadKeys ?? [];\r\n if (!payloadKeys.length) {\r\n return undefined;\r\n }\r\n\r\n const payload: Record<string, unknown> = {};\r\n\r\n for (const key of payloadKeys) {\r\n const formFieldValue = formValue?.[key];\r\n if (formFieldValue !== undefined) {\r\n payload[key] = normalizePayloadValue(key, formFieldValue);\r\n continue;\r\n }\r\n\r\n const externalValue = resolveExternalPayloadValue(\r\n key,\r\n action,\r\n externalResolvers,\r\n );\r\n if (externalValue !== undefined) {\r\n payload[key] = externalValue;\r\n continue;\r\n }\r\n\r\n const defaultValue = resolveDefaultPayloadValue(key);\r\n if (defaultValue !== undefined) {\r\n payload[key] = defaultValue;\r\n }\r\n }\r\n\r\n return Object.keys(payload).length ? payload : undefined;\r\n}\r\n\r\nfunction buildTemplatePayload(\r\n action: RuntimeAction,\r\n formValue: Record<string, unknown> | undefined,\r\n externalResolvers: Record<string, () => unknown>,\r\n): Record<string, unknown> | null {\r\n const template = action.payloadTemplate as Record<string, unknown> | null;\r\n if (!template || typeof template !== 'object') {\r\n return null;\r\n }\r\n\r\n const payload: Record<string, unknown> = {};\r\n const payloadKeys = action.payloadKeys ?? Object.keys(template);\r\n\r\n for (const key of payloadKeys) {\r\n if (key === 'fields') {\r\n payload[key] = resolveTemplateFieldsValue(action, template, formValue);\r\n continue;\r\n }\r\n\r\n const formFieldValue = formValue?.[key];\r\n if (formFieldValue !== undefined) {\r\n payload[key] = normalizePayloadValue(key, formFieldValue);\r\n continue;\r\n }\r\n\r\n const externalValue = resolveExternalPayloadValue(\r\n key,\r\n action,\r\n externalResolvers,\r\n );\r\n if (externalValue !== undefined) {\r\n payload[key] = externalValue;\r\n continue;\r\n }\r\n\r\n if (template[key] !== undefined) {\r\n payload[key] = template[key];\r\n continue;\r\n }\r\n\r\n const defaultValue = resolveDefaultPayloadValue(key);\r\n if (defaultValue !== undefined) {\r\n payload[key] = defaultValue;\r\n }\r\n }\r\n\r\n return Object.keys(payload).length ? payload : null;\r\n}\r\n\r\nfunction resolveExternalPayloadValue(\r\n key: string,\r\n action: RuntimeAction,\r\n externalResolvers: Record<string, () => unknown>,\r\n): unknown {\r\n const resolver = externalResolvers[key];\r\n if (resolver) {\r\n return resolver();\r\n }\r\n\r\n if (key === 'stepId') {\r\n return action.stepIds?.[0];\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nexport function normalizePayloadValue(key: string, value: unknown): unknown {\r\n if (key === 'attachments') {\r\n if (value == null) {\r\n return [];\r\n }\r\n return Array.isArray(value) ? value : [value];\r\n }\r\n\r\n return value;\r\n}\r\n\r\nexport function resolveDefaultPayloadValue(key: string): unknown {\r\n switch (key) {\r\n case 'attachments':\r\n return [];\r\n case 'delegatedUser':\r\n case 'note':\r\n case 'reason':\r\n return null;\r\n case 'values':\r\n return [];\r\n default:\r\n return undefined;\r\n }\r\n}\r\n\r\nexport function getMissingRequiredPayloadKeys(\r\n action: RuntimeAction,\r\n payload: Record<string, unknown> | undefined,\r\n): string[] {\r\n return (action.requiredPayloadKeys ?? []).filter((key) =>\r\n isMissingPayloadValue(payload?.[key]),\r\n );\r\n}\r\n\r\nexport function isMissingPayloadValue(value: unknown): boolean {\r\n if (value == null) {\r\n return true;\r\n }\r\n\r\n if (typeof value === 'string') {\r\n return value.trim().length === 0;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n return value.length === 0;\r\n }\r\n\r\n return false;\r\n}\r\n\r\nexport function normalizeHttpMethod(\r\n value: string | null | undefined,\r\n): string | null {\r\n if (!value || typeof value !== 'string') {\r\n return null;\r\n }\r\n\r\n const method = value.trim().toUpperCase();\r\n return method.length ? method : null;\r\n}\r\n\r\nexport function methodSupportsBody(method: string): boolean {\r\n return ['POST', 'PUT', 'PATCH', 'DELETE'].includes(method);\r\n}\r\n\r\nexport function buildRequestOptions(\r\n method: string,\r\n payload: Record<string, unknown> | undefined,\r\n): Record<string, unknown> {\r\n if (!payload || !methodSupportsBody(method)) {\r\n return { observe: 'body' };\r\n }\r\n\r\n return {\r\n body: payload,\r\n observe: 'body',\r\n };\r\n}\r\n\r\nexport function hasActionFormFields(action: RuntimeAction): boolean {\r\n return (\r\n (action.payloadKeys ?? []).some((key) =>\r\n ['delegatedUser', 'reason', 'note', 'attachments'].includes(key),\r\n ) || hasProgressTemplateField(action)\r\n );\r\n}\r\n\r\nexport function hasProgressTemplateField(action: RuntimeAction): boolean {\r\n const fields = (action.payloadTemplate as { fields?: unknown } | null)\r\n ?.fields;\r\n return (\r\n Array.isArray(fields) &&\r\n fields.some(\r\n (field) =>\r\n !!field &&\r\n typeof field === 'object' &&\r\n (field as { propertyKey?: string }).propertyKey === 'Progress',\r\n )\r\n );\r\n}\r\n\r\nfunction resolveTemplateFieldsValue(\r\n action: RuntimeAction,\r\n template: Record<string, unknown>,\r\n formValue: Record<string, unknown> | undefined,\r\n): unknown {\r\n const templateFields = template['fields'];\r\n if (!Array.isArray(templateFields)) {\r\n return formValue?.['fields'] ?? templateFields;\r\n }\r\n\r\n if (!hasProgressTemplateField(action)) {\r\n return formValue?.['fields'] ?? templateFields;\r\n }\r\n\r\n return templateFields.map((field) => {\r\n if (\r\n !field ||\r\n typeof field !== 'object' ||\r\n (field as { propertyKey?: string }).propertyKey !== 'Progress'\r\n ) {\r\n return field;\r\n }\r\n\r\n return {\r\n ...(field as Record<string, unknown>),\r\n value: formValue?.['progress'] ?? (field as { value?: unknown }).value,\r\n };\r\n });\r\n}\r\n","import { Injectable, signal } from '@angular/core';\r\n\r\nimport {\r\n RuntimeActionFormSource,\r\n RuntimeActionFormValue,\r\n} from './runtime-action.types';\r\n\r\n@Injectable()\r\nexport class RuntimeActionContextStore {\r\n private readonly formSource = signal<RuntimeActionFormSource | null>(null);\r\n\r\n setFormSource(source: RuntimeActionFormSource | null): void {\r\n this.formSource.set(source);\r\n }\r\n\r\n resolveFormValues(): RuntimeActionFormValue[] {\r\n const values = this.formSource()?.getSubmitValues();\r\n return Array.isArray(values)\r\n ? values.map((value) => ({\r\n requestPropertyId: value.requestPropertyId,\r\n propertyKey: value.propertyKey,\r\n value: value.value,\r\n }))\r\n : [];\r\n }\r\n}\r\n","import { HttpClient } from '@angular/common/http';\r\nimport { Injectable, InjectionToken, Type, inject } from '@angular/core';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport { ConfirmationService } from '@masterteam/components/confirmation';\r\nimport { ModalService } from '@masterteam/components/modal';\r\nimport { ToastService } from '@masterteam/components/toast';\r\nimport { firstValueFrom, map } from 'rxjs';\r\n\r\nimport {\r\n buildActionPayload,\r\n buildRequestOptions,\r\n getMissingRequiredPayloadKeys,\r\n hasActionFormFields,\r\n normalizeHttpMethod,\r\n} from './payload-builder';\r\nimport {\r\n RuntimeAction,\r\n RuntimeActionAfterSuccess,\r\n RuntimeActionExecuteOptions,\r\n RuntimeActionResult,\r\n resolveActionLabel,\r\n} from './runtime-action.types';\r\n\r\nexport const RUNTIME_ACTION_CONFIRM_DIALOG = new InjectionToken<Type<unknown>>(\r\n 'RUNTIME_ACTION_CONFIRM_DIALOG',\r\n);\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class RuntimeActionRunner {\r\n private readonly http = inject(HttpClient);\r\n private readonly confirmation = inject(ConfirmationService);\r\n private readonly modal = inject(ModalService);\r\n private readonly toast = inject(ToastService);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly confirmDialogClass = inject(RUNTIME_ACTION_CONFIRM_DIALOG, {\r\n optional: true,\r\n });\r\n\r\n async execute(\r\n action: RuntimeAction,\r\n options: RuntimeActionExecuteOptions = {},\r\n ): Promise<RuntimeActionResult> {\r\n const method = normalizeHttpMethod(action.httpMethod);\r\n const url = action.url?.trim();\r\n\r\n if (!method || !url || action.isAvailable === false) {\r\n return cancelledOrError(\r\n action,\r\n 'error',\r\n new Error(this.notExecutableMessage(action)),\r\n );\r\n }\r\n\r\n const performRun = (\r\n formValue?: Record<string, unknown>,\r\n ): Promise<RuntimeActionResult> => {\r\n let payload = buildActionPayload(\r\n action,\r\n formValue,\r\n options.externalPayloadResolvers ?? {},\r\n );\r\n\r\n if (options.transformPayload) {\r\n payload = options.transformPayload(payload, action);\r\n }\r\n\r\n const missing = getMissingRequiredPayloadKeys(action, payload);\r\n if (missing.length) {\r\n const message = this.transloco.translate(\r\n 'components.runtimeAction.missingArgs',\r\n { action: resolveActionLabel(action), missing: missing.join(', ') },\r\n );\r\n if (!options.silent) {\r\n this.toast.error(message);\r\n }\r\n return Promise.resolve({\r\n status: 'error',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error: new Error(message),\r\n });\r\n }\r\n\r\n return this.run(action, method, url, payload, options);\r\n };\r\n\r\n if (action.needConfirmation) {\r\n if (hasActionFormFields(action) && this.confirmDialogClass) {\r\n return this.runWithFormDialog(action, performRun);\r\n }\r\n\r\n const confirmed = await this.confirmPlain(action);\r\n if (!confirmed) {\r\n return {\r\n status: 'cancelled',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n };\r\n }\r\n }\r\n\r\n return performRun();\r\n }\r\n\r\n private runWithFormDialog(\r\n action: RuntimeAction,\r\n performRun: (\r\n value: Record<string, unknown>,\r\n ) => Promise<RuntimeActionResult>,\r\n ): Promise<RuntimeActionResult> {\r\n return new Promise((resolve) => {\r\n let pendingRun: Promise<RuntimeActionResult> | null = null;\r\n let finalResult: RuntimeActionResult | null = null;\r\n\r\n const ref = this.modal.openModal(this.confirmDialogClass!, 'dialog', {\r\n header: resolveActionLabel(action),\r\n width: '40rem',\r\n dismissableMask: true,\r\n inputValues: {\r\n action,\r\n onSubmit: async (value: Record<string, unknown>) => {\r\n pendingRun = performRun(value);\r\n const result = await pendingRun;\r\n finalResult = result;\r\n return result.status === 'success';\r\n },\r\n },\r\n });\r\n\r\n ref.onClose.subscribe(async () => {\r\n if (finalResult) {\r\n resolve(finalResult);\r\n return;\r\n }\r\n if (pendingRun) {\r\n try {\r\n resolve(await pendingRun);\r\n } catch (error) {\r\n resolve({\r\n status: 'error',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error,\r\n });\r\n }\r\n return;\r\n }\r\n resolve({\r\n status: 'cancelled',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n });\r\n });\r\n });\r\n }\r\n\r\n private confirmPlain(action: RuntimeAction): Promise<boolean> {\r\n return new Promise((resolve) => {\r\n const label = resolveActionLabel(action);\r\n this.confirmation.confirm({\r\n type: 'dialog',\r\n header: label,\r\n message: this.transloco.translate(\r\n 'components.runtimeAction.confirmDefault',\r\n { action: label },\r\n ),\r\n acceptLabel: label,\r\n icon: 'alert.alert-triangle',\r\n accept: () => resolve(true),\r\n reject: () => resolve(false),\r\n });\r\n });\r\n }\r\n\r\n private async run(\r\n action: RuntimeAction,\r\n method: string,\r\n url: string,\r\n payload: Record<string, unknown> | undefined,\r\n options: RuntimeActionExecuteOptions,\r\n ): Promise<RuntimeActionResult> {\r\n const fallbackErrorMessage = this.transloco.translate(\r\n 'components.runtimeAction.executeFailed',\r\n { action: resolveActionLabel(action) },\r\n );\r\n\r\n try {\r\n const response = await firstValueFrom(\r\n this.http\r\n .request<unknown>(method, url, buildRequestOptions(method, payload))\r\n .pipe(\r\n map((res) => ensureSuccessfulEnvelope(res, fallbackErrorMessage)),\r\n ),\r\n );\r\n\r\n if (options.successMessage && !options.silent) {\r\n this.toast.success(options.successMessage(response, action));\r\n }\r\n\r\n return {\r\n status: 'success',\r\n actionKey: action.actionKey,\r\n afterSuccess: resolveAfterSuccess(action, options.defaultAfterSuccess),\r\n response,\r\n };\r\n } catch (error) {\r\n const message =\r\n options.errorMessage?.(error, action) ??\r\n resolveHttpErrorMessage(error, fallbackErrorMessage);\r\n\r\n if (!options.silent) {\r\n this.toast.error(message);\r\n }\r\n\r\n return {\r\n status: 'error',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error,\r\n };\r\n }\r\n }\r\n\r\n private notExecutableMessage(action: RuntimeAction): string {\r\n if (action.isAvailable === false) {\r\n return this.transloco.translate('components.runtimeAction.notAvailable', {\r\n action: action.actionKey,\r\n });\r\n }\r\n if (!action.url) {\r\n return this.transloco.translate('components.runtimeAction.noUrl', {\r\n action: action.actionKey,\r\n });\r\n }\r\n return this.transloco.translate('components.runtimeAction.noHttpMethod', {\r\n action: action.actionKey,\r\n });\r\n }\r\n}\r\n\r\nfunction cancelledOrError(\r\n action: RuntimeAction,\r\n status: 'error' | 'cancelled',\r\n error?: unknown,\r\n): RuntimeActionResult {\r\n return {\r\n status,\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error,\r\n };\r\n}\r\n\r\nfunction resolveAfterSuccess(\r\n action: RuntimeAction,\r\n fallback: RuntimeActionAfterSuccess | undefined,\r\n): RuntimeActionAfterSuccess {\r\n if (action.afterSuccess === 'close' || action.afterSuccess === 'refresh') {\r\n return action.afterSuccess;\r\n }\r\n return fallback ?? 'refresh';\r\n}\r\n\r\nfunction ensureSuccessfulEnvelope(\r\n response: unknown,\r\n fallback: string,\r\n): unknown {\r\n if (!response || typeof response !== 'object') {\r\n return response;\r\n }\r\n\r\n const envelope = response as { code?: number };\r\n if (typeof envelope.code === 'number' && envelope.code !== 1) {\r\n throw new Error(resolveEnvelopeErrorMessage(response, fallback));\r\n }\r\n return response;\r\n}\r\n\r\nfunction resolveEnvelopeErrorMessage(\r\n response: unknown,\r\n fallback: string,\r\n): string {\r\n if (!response || typeof response !== 'object') {\r\n return fallback;\r\n }\r\n const envelope = response as {\r\n message?: string | null;\r\n errors?: { message?: string } | null;\r\n };\r\n return envelope.errors?.message ?? envelope.message ?? fallback;\r\n}\r\n\r\nfunction resolveHttpErrorMessage(error: unknown, fallback: string): string {\r\n if (!error || typeof error !== 'object') {\r\n return fallback;\r\n }\r\n const httpError = error as {\r\n message?: string;\r\n error?: { message?: string | null } | null;\r\n };\r\n return httpError.error?.message ?? httpError.message ?? fallback;\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AA2EM,SAAU,kBAAkB,CAAC,MAAqB,EAAA;AACtD,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU;AAC9B,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAC5B,QAAA,OAAO,IAAI,IAAI,MAAM,CAAC,SAAS;IACjC;AACA,IAAA,OAAO,IAAI,EAAE,OAAO,IAAI,MAAM,CAAC,SAAS;AAC1C;;AC/EM,SAAU,kBAAkB,CAChC,MAAqB,EACrB,SAA8C,EAC9C,oBAAmD,EAAE,EAAA;IAErD,MAAM,eAAe,GAAG,oBAAoB,CAC1C,MAAM,EACN,SAAS,EACT,iBAAiB,CAClB;IACD,IAAI,eAAe,EAAE;AACnB,QAAA,OAAO,eAAe;IACxB;AAEA,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE;AAC5C,IAAA,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;AACvB,QAAA,OAAO,SAAS;IAClB;IAEA,MAAM,OAA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IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACvC,QAAA,OAAO,QAAQ;IACjB;IACA,MAAM,SAAS,GAAG,KAGjB;IACD,OAAO,SAAS,CAAC,KAAK,EAAE,OAAO,IAAI,SAAS,CAAC,OAAO,IAAI,QAAQ;AAClE;;AC7SA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"masterteam-components-runtime-action.mjs","sources":["../../../../packages/masterteam/components/runtime-action/runtime-action.types.ts","../../../../packages/masterteam/components/runtime-action/payload-builder.ts","../../../../packages/masterteam/components/runtime-action/runtime-action-context.store.ts","../../../../packages/masterteam/components/runtime-action/runtime-action.runner.ts","../../../../packages/masterteam/components/runtime-action/masterteam-components-runtime-action.ts"],"sourcesContent":["export interface RuntimeActionTranslatable {\r\n display?: string;\r\n en?: string;\r\n ar?: string;\r\n}\r\n\r\nexport type RuntimeActionAfterSuccess = 'refresh' | 'close';\r\n\r\nexport interface RuntimeActionReason {\r\n source?: string;\r\n code?: string;\r\n message?: string;\r\n blocking?: boolean;\r\n details?: string | null;\r\n ruleKey?: string | null;\r\n requestId?: number | null;\r\n requestStatus?: string | null;\r\n requestSchemaId?: number | null;\r\n relatedRequestIds?: number[];\r\n}\r\n\r\nexport interface RuntimeAction {\r\n actionKey: string;\r\n actionName?: RuntimeActionTranslatable | string | null;\r\n httpMethod?: string | null;\r\n url?: string | null;\r\n isAvailable?: boolean;\r\n afterSuccess?: RuntimeActionAfterSuccess | null;\r\n stepIds?: Array<number | string>;\r\n needConfirmation?: boolean;\r\n payloadKeys?: string[];\r\n requiredPayloadKeys?: string[];\r\n payloadTemplate?: Record<string, unknown> | null;\r\n formId?: string | number | null;\r\n\r\n targetType?: string;\r\n targetId?: number;\r\n moduleKey?: string;\r\n operationKey?: string;\r\n primaryReasonCode?: string | null;\r\n reasons?: RuntimeActionReason[];\r\n}\r\n\r\nexport type RuntimeActionStatus = 'success' | 'error' | 'cancelled';\r\n\r\nexport interface RuntimeActionResult {\r\n status: RuntimeActionStatus;\r\n actionKey: string;\r\n afterSuccess: RuntimeActionAfterSuccess | null;\r\n response?: unknown;\r\n error?: unknown;\r\n}\r\n\r\nexport interface RuntimeActionExecuteOptions {\r\n externalPayloadResolvers?: Record<string, () => unknown>;\r\n defaultAfterSuccess?: RuntimeActionAfterSuccess;\r\n successMessage?: (response: unknown, action: RuntimeAction) => string;\r\n errorMessage?: (error: unknown, action: RuntimeAction) => string;\r\n transformPayload?: (\r\n payload: Record<string, unknown> | undefined,\r\n action: RuntimeAction,\r\n ) => Record<string, unknown> | undefined;\r\n silent?: boolean;\r\n}\r\n\r\nexport interface RuntimeActionFormValue {\r\n requestPropertyId?: number;\r\n propertyKey: string;\r\n value: unknown;\r\n}\r\n\r\nexport interface RuntimeActionFormSource {\r\n getSubmitValues(): RuntimeActionFormValue[] | undefined;\r\n}\r\n\r\nexport function resolveActionLabel(action: RuntimeAction): string {\r\n const name = action.actionName;\r\n if (typeof name === 'string') {\r\n return name || action.actionKey;\r\n }\r\n return name?.display || action.actionKey;\r\n}\r\n","import { RuntimeAction } from './runtime-action.types';\r\n\r\nexport function buildActionPayload(\r\n action: RuntimeAction,\r\n formValue: Record<string, unknown> | undefined,\r\n externalResolvers: Record<string, () => unknown> = {},\r\n): Record<string, unknown> | undefined {\r\n const templatePayload = buildTemplatePayload(\r\n action,\r\n formValue,\r\n externalResolvers,\r\n );\r\n if (templatePayload) {\r\n return templatePayload;\r\n }\r\n\r\n const payloadKeys = action.payloadKeys ?? [];\r\n if (!payloadKeys.length) {\r\n return undefined;\r\n }\r\n\r\n const payload: Record<string, unknown> = {};\r\n\r\n for (const key of payloadKeys) {\r\n const formFieldValue = formValue?.[key];\r\n if (formFieldValue !== undefined) {\r\n payload[key] = normalizePayloadValue(key, formFieldValue);\r\n continue;\r\n }\r\n\r\n const externalValue = resolveExternalPayloadValue(\r\n key,\r\n action,\r\n externalResolvers,\r\n );\r\n if (externalValue !== undefined) {\r\n payload[key] = externalValue;\r\n continue;\r\n }\r\n\r\n const defaultValue = resolveDefaultPayloadValue(key);\r\n if (defaultValue !== undefined) {\r\n payload[key] = defaultValue;\r\n }\r\n }\r\n\r\n return Object.keys(payload).length ? payload : undefined;\r\n}\r\n\r\nfunction buildTemplatePayload(\r\n action: RuntimeAction,\r\n formValue: Record<string, unknown> | undefined,\r\n externalResolvers: Record<string, () => unknown>,\r\n): Record<string, unknown> | null {\r\n const template = action.payloadTemplate as Record<string, unknown> | null;\r\n if (!template || typeof template !== 'object') {\r\n return null;\r\n }\r\n\r\n const payload: Record<string, unknown> = {};\r\n const payloadKeys = action.payloadKeys ?? Object.keys(template);\r\n\r\n for (const key of payloadKeys) {\r\n if (key === 'fields') {\r\n // The backend declares the operation's inputs as a `fields` template of\r\n // `{ propertyKey, value: null }` placeholders. Only a host that rendered\r\n // the operation's real form can fill them (see `hasActionInputFields`),\r\n // so the values are taken whole from the form or left as declared —\r\n // never patched per property key from here.\r\n payload[key] = formValue?.['fields'] ?? template['fields'];\r\n continue;\r\n }\r\n\r\n const formFieldValue = formValue?.[key];\r\n if (formFieldValue !== undefined) {\r\n payload[key] = normalizePayloadValue(key, formFieldValue);\r\n continue;\r\n }\r\n\r\n const externalValue = resolveExternalPayloadValue(\r\n key,\r\n action,\r\n externalResolvers,\r\n );\r\n if (externalValue !== undefined) {\r\n payload[key] = externalValue;\r\n continue;\r\n }\r\n\r\n if (template[key] !== undefined) {\r\n payload[key] = template[key];\r\n continue;\r\n }\r\n\r\n const defaultValue = resolveDefaultPayloadValue(key);\r\n if (defaultValue !== undefined) {\r\n payload[key] = defaultValue;\r\n }\r\n }\r\n\r\n return Object.keys(payload).length ? payload : null;\r\n}\r\n\r\nfunction resolveExternalPayloadValue(\r\n key: string,\r\n action: RuntimeAction,\r\n externalResolvers: Record<string, () => unknown>,\r\n): unknown {\r\n const resolver = externalResolvers[key];\r\n if (resolver) {\r\n return resolver();\r\n }\r\n\r\n if (key === 'stepId') {\r\n return action.stepIds?.[0];\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nexport function normalizePayloadValue(key: string, value: unknown): unknown {\r\n if (key === 'attachments') {\r\n if (value == null) {\r\n return [];\r\n }\r\n return Array.isArray(value) ? value : [value];\r\n }\r\n\r\n return value;\r\n}\r\n\r\nexport function resolveDefaultPayloadValue(key: string): unknown {\r\n switch (key) {\r\n case 'attachments':\r\n return [];\r\n case 'delegatedUser':\r\n case 'note':\r\n case 'reason':\r\n return null;\r\n case 'values':\r\n return [];\r\n default:\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * The declared operation inputs the payload would submit with no value — the\r\n * `{ propertyKey, value: null }` placeholders the backend sent, still unfilled.\r\n *\r\n * A non-empty result means the action was fired without rendering its form, and\r\n * submitting it would write nulls over the record (or fail the contract's\r\n * `operation_input.required` rule). Hosts fill these by running the operation\r\n * through `process-form-load` / `process-submit` instead.\r\n */\r\nexport function getUnfilledActionInputKeys(\r\n payload: Record<string, unknown> | undefined,\r\n): string[] {\r\n const fields = payload?.['fields'];\r\n if (!Array.isArray(fields)) {\r\n return [];\r\n }\r\n\r\n return fields\r\n .filter(\r\n (field) =>\r\n !!field &&\r\n typeof field === 'object' &&\r\n (field as { value?: unknown }).value == null,\r\n )\r\n .map((field) => (field as { propertyKey?: unknown }).propertyKey)\r\n .filter(\r\n (key): key is string => typeof key === 'string' && key.trim() !== '',\r\n );\r\n}\r\n\r\nexport function getMissingRequiredPayloadKeys(\r\n action: RuntimeAction,\r\n payload: Record<string, unknown> | undefined,\r\n): string[] {\r\n return (action.requiredPayloadKeys ?? []).filter((key) =>\r\n isMissingPayloadValue(payload?.[key]),\r\n );\r\n}\r\n\r\nexport function isMissingPayloadValue(value: unknown): boolean {\r\n if (value == null) {\r\n return true;\r\n }\r\n\r\n if (typeof value === 'string') {\r\n return value.trim().length === 0;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n return value.length === 0;\r\n }\r\n\r\n return false;\r\n}\r\n\r\nexport function normalizeHttpMethod(\r\n value: string | null | undefined,\r\n): string | null {\r\n if (!value || typeof value !== 'string') {\r\n return null;\r\n }\r\n\r\n const method = value.trim().toUpperCase();\r\n return method.length ? method : null;\r\n}\r\n\r\nexport function methodSupportsBody(method: string): boolean {\r\n return ['POST', 'PUT', 'PATCH', 'DELETE'].includes(method);\r\n}\r\n\r\nexport function buildRequestOptions(\r\n method: string,\r\n payload: Record<string, unknown> | undefined,\r\n): Record<string, unknown> {\r\n if (!payload || !methodSupportsBody(method)) {\r\n return { observe: 'body' };\r\n }\r\n\r\n return {\r\n body: payload,\r\n observe: 'body',\r\n };\r\n}\r\n\r\n/**\r\n * The action collects free-form request metadata — a reason, a note, a\r\n * delegate, attachments — which the generic confirm dialog can render on its\r\n * own because the keys are fixed and operation-independent.\r\n *\r\n * Operation *inputs* are a different thing entirely: see\r\n * {@link hasActionInputFields}.\r\n */\r\nexport function hasActionFormFields(action: RuntimeAction): boolean {\r\n return (action.payloadKeys ?? []).some((key) =>\r\n ['delegatedUser', 'reason', 'note', 'attachments'].includes(key),\r\n );\r\n}\r\n\r\n/**\r\n * The action declares operation inputs the user still has to supply — its\r\n * `payloadTemplate.fields` is a non-empty list of `{ propertyKey, value: null }`\r\n * placeholders.\r\n *\r\n * Firing such an action straight from its template submits those nulls, so a\r\n * host must instead run the operation through its own form: `process-form-load`\r\n * for the effective form and current values, `process-submit/validate`, then\r\n * `process-submit`. The backend owns which fields those are — never infer them\r\n * from the operation key.\r\n */\r\nexport function hasActionInputFields(action: RuntimeAction): boolean {\r\n const fields = (action.payloadTemplate as { fields?: unknown } | null)\r\n ?.fields;\r\n return Array.isArray(fields) && fields.length > 0;\r\n}\r\n\r\n/**\r\n * The property keys an action declares as its operation inputs, in the\r\n * backend's own casing. Pass them to `mt-client-form`'s `allowedFieldKeys` to\r\n * scope a configured form down to the inputs this action actually writes.\r\n */\r\nexport function getActionInputFieldKeys(action: RuntimeAction): string[] {\r\n const fields = (action.payloadTemplate as { fields?: unknown } | null)\r\n ?.fields;\r\n if (!Array.isArray(fields)) {\r\n return [];\r\n }\r\n\r\n return fields\r\n .map((field) =>\r\n field && typeof field === 'object'\r\n ? (field as { propertyKey?: unknown }).propertyKey\r\n : null,\r\n )\r\n .filter(\r\n (key): key is string => typeof key === 'string' && key.trim() !== '',\r\n );\r\n}\r\n","import { Injectable, signal } from '@angular/core';\r\n\r\nimport {\r\n RuntimeActionFormSource,\r\n RuntimeActionFormValue,\r\n} from './runtime-action.types';\r\n\r\n@Injectable()\r\nexport class RuntimeActionContextStore {\r\n private readonly formSource = signal<RuntimeActionFormSource | null>(null);\r\n\r\n setFormSource(source: RuntimeActionFormSource | null): void {\r\n this.formSource.set(source);\r\n }\r\n\r\n resolveFormValues(): RuntimeActionFormValue[] {\r\n const values = this.formSource()?.getSubmitValues();\r\n return Array.isArray(values)\r\n ? values.map((value) => ({\r\n requestPropertyId: value.requestPropertyId,\r\n propertyKey: value.propertyKey,\r\n value: value.value,\r\n }))\r\n : [];\r\n }\r\n}\r\n","import { HttpClient } from '@angular/common/http';\r\nimport { Injectable, InjectionToken, Type, inject } from '@angular/core';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport { ConfirmationService } from '@masterteam/components/confirmation';\r\nimport { ModalService } from '@masterteam/components/modal';\r\nimport { ToastService } from '@masterteam/components/toast';\r\nimport { firstValueFrom, map } from 'rxjs';\r\n\r\nimport {\r\n buildActionPayload,\r\n buildRequestOptions,\r\n getMissingRequiredPayloadKeys,\r\n getUnfilledActionInputKeys,\r\n hasActionFormFields,\r\n normalizeHttpMethod,\r\n} from './payload-builder';\r\nimport {\r\n RuntimeAction,\r\n RuntimeActionAfterSuccess,\r\n RuntimeActionExecuteOptions,\r\n RuntimeActionResult,\r\n resolveActionLabel,\r\n} from './runtime-action.types';\r\n\r\nexport const RUNTIME_ACTION_CONFIRM_DIALOG = new InjectionToken<Type<unknown>>(\r\n 'RUNTIME_ACTION_CONFIRM_DIALOG',\r\n);\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class RuntimeActionRunner {\r\n private readonly http = inject(HttpClient);\r\n private readonly confirmation = inject(ConfirmationService);\r\n private readonly modal = inject(ModalService);\r\n private readonly toast = inject(ToastService);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly confirmDialogClass = inject(RUNTIME_ACTION_CONFIRM_DIALOG, {\r\n optional: true,\r\n });\r\n\r\n async execute(\r\n action: RuntimeAction,\r\n options: RuntimeActionExecuteOptions = {},\r\n ): Promise<RuntimeActionResult> {\r\n const method = normalizeHttpMethod(action.httpMethod);\r\n const url = action.url?.trim();\r\n\r\n if (!method || !url || action.isAvailable === false) {\r\n return cancelledOrError(\r\n action,\r\n 'error',\r\n new Error(this.notExecutableMessage(action)),\r\n );\r\n }\r\n\r\n const performRun = (\r\n formValue?: Record<string, unknown>,\r\n ): Promise<RuntimeActionResult> => {\r\n let payload = buildActionPayload(\r\n action,\r\n formValue,\r\n options.externalPayloadResolvers ?? {},\r\n );\r\n\r\n if (options.transformPayload) {\r\n payload = options.transformPayload(payload, action);\r\n }\r\n\r\n // An action that declares operation inputs cannot be fired from its\r\n // template alone: the backend sends those fields as `value: null`\r\n // placeholders for a form to fill, so submitting them as-is writes nulls\r\n // over the record. Only checked when no form value was collected — a host\r\n // that supplied one owns what it put in `fields`, cleared values included.\r\n // The way to run such an action is `process-form-load` →\r\n // `process-submit/validate` → `process-submit`; see `hasActionInputFields`.\r\n const missing = [\r\n ...getMissingRequiredPayloadKeys(action, payload),\r\n ...(formValue ? [] : getUnfilledActionInputKeys(payload)),\r\n ];\r\n if (missing.length) {\r\n const message = this.transloco.translate(\r\n 'components.runtimeAction.missingArgs',\r\n { action: resolveActionLabel(action), missing: missing.join(', ') },\r\n );\r\n if (!options.silent) {\r\n this.toast.error(message);\r\n }\r\n return Promise.resolve({\r\n status: 'error',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error: new Error(message),\r\n });\r\n }\r\n\r\n return this.run(action, method, url, payload, options);\r\n };\r\n\r\n if (action.needConfirmation) {\r\n if (hasActionFormFields(action) && this.confirmDialogClass) {\r\n return this.runWithFormDialog(action, performRun);\r\n }\r\n\r\n const confirmed = await this.confirmPlain(action);\r\n if (!confirmed) {\r\n return {\r\n status: 'cancelled',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n };\r\n }\r\n }\r\n\r\n return performRun();\r\n }\r\n\r\n private runWithFormDialog(\r\n action: RuntimeAction,\r\n performRun: (\r\n value: Record<string, unknown>,\r\n ) => Promise<RuntimeActionResult>,\r\n ): Promise<RuntimeActionResult> {\r\n return new Promise((resolve) => {\r\n let pendingRun: Promise<RuntimeActionResult> | null = null;\r\n let finalResult: RuntimeActionResult | null = null;\r\n\r\n const ref = this.modal.openModal(this.confirmDialogClass!, 'dialog', {\r\n header: resolveActionLabel(action),\r\n width: '40rem',\r\n dismissableMask: true,\r\n inputValues: {\r\n action,\r\n onSubmit: async (value: Record<string, unknown>) => {\r\n pendingRun = performRun(value);\r\n const result = await pendingRun;\r\n finalResult = result;\r\n return result.status === 'success';\r\n },\r\n },\r\n });\r\n\r\n ref.onClose.subscribe(async () => {\r\n if (finalResult) {\r\n resolve(finalResult);\r\n return;\r\n }\r\n if (pendingRun) {\r\n try {\r\n resolve(await pendingRun);\r\n } catch (error) {\r\n resolve({\r\n status: 'error',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error,\r\n });\r\n }\r\n return;\r\n }\r\n resolve({\r\n status: 'cancelled',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n });\r\n });\r\n });\r\n }\r\n\r\n private confirmPlain(action: RuntimeAction): Promise<boolean> {\r\n return new Promise((resolve) => {\r\n const label = resolveActionLabel(action);\r\n this.confirmation.confirm({\r\n type: 'dialog',\r\n header: label,\r\n message: this.transloco.translate(\r\n 'components.runtimeAction.confirmDefault',\r\n { action: label },\r\n ),\r\n acceptLabel: label,\r\n icon: 'alert.alert-triangle',\r\n accept: () => resolve(true),\r\n reject: () => resolve(false),\r\n });\r\n });\r\n }\r\n\r\n private async run(\r\n action: RuntimeAction,\r\n method: string,\r\n url: string,\r\n payload: Record<string, unknown> | undefined,\r\n options: RuntimeActionExecuteOptions,\r\n ): Promise<RuntimeActionResult> {\r\n const fallbackErrorMessage = this.transloco.translate(\r\n 'components.runtimeAction.executeFailed',\r\n { action: resolveActionLabel(action) },\r\n );\r\n\r\n try {\r\n const response = await firstValueFrom(\r\n this.http\r\n .request<unknown>(method, url, buildRequestOptions(method, payload))\r\n .pipe(\r\n map((res) => ensureSuccessfulEnvelope(res, fallbackErrorMessage)),\r\n ),\r\n );\r\n\r\n if (options.successMessage && !options.silent) {\r\n this.toast.success(options.successMessage(response, action));\r\n }\r\n\r\n return {\r\n status: 'success',\r\n actionKey: action.actionKey,\r\n afterSuccess: resolveAfterSuccess(action, options.defaultAfterSuccess),\r\n response,\r\n };\r\n } catch (error) {\r\n const message =\r\n options.errorMessage?.(error, action) ??\r\n resolveHttpErrorMessage(error, fallbackErrorMessage);\r\n\r\n if (!options.silent) {\r\n this.toast.error(message);\r\n }\r\n\r\n return {\r\n status: 'error',\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error,\r\n };\r\n }\r\n }\r\n\r\n private notExecutableMessage(action: RuntimeAction): string {\r\n if (action.isAvailable === false) {\r\n return this.transloco.translate('components.runtimeAction.notAvailable', {\r\n action: action.actionKey,\r\n });\r\n }\r\n if (!action.url) {\r\n return this.transloco.translate('components.runtimeAction.noUrl', {\r\n action: action.actionKey,\r\n });\r\n }\r\n return this.transloco.translate('components.runtimeAction.noHttpMethod', {\r\n action: action.actionKey,\r\n });\r\n }\r\n}\r\n\r\nfunction cancelledOrError(\r\n action: RuntimeAction,\r\n status: 'error' | 'cancelled',\r\n error?: unknown,\r\n): RuntimeActionResult {\r\n return {\r\n status,\r\n actionKey: action.actionKey,\r\n afterSuccess: null,\r\n error,\r\n };\r\n}\r\n\r\nfunction resolveAfterSuccess(\r\n action: RuntimeAction,\r\n fallback: RuntimeActionAfterSuccess | undefined,\r\n): RuntimeActionAfterSuccess {\r\n if (action.afterSuccess === 'close' || action.afterSuccess === 'refresh') {\r\n return action.afterSuccess;\r\n }\r\n return fallback ?? 'refresh';\r\n}\r\n\r\nfunction ensureSuccessfulEnvelope(\r\n response: unknown,\r\n fallback: string,\r\n): unknown {\r\n if (!response || typeof response !== 'object') {\r\n return response;\r\n }\r\n\r\n const envelope = response as { code?: number };\r\n if (typeof envelope.code === 'number' && envelope.code !== 1) {\r\n throw new Error(resolveEnvelopeErrorMessage(response, fallback));\r\n }\r\n return response;\r\n}\r\n\r\nfunction resolveEnvelopeErrorMessage(\r\n response: unknown,\r\n fallback: string,\r\n): string {\r\n if (!response || typeof response !== 'object') {\r\n return fallback;\r\n }\r\n const envelope = response as {\r\n message?: string | null;\r\n errors?: { message?: string } | null;\r\n };\r\n return envelope.errors?.message ?? envelope.message ?? fallback;\r\n}\r\n\r\nfunction resolveHttpErrorMessage(error: unknown, fallback: string): string {\r\n if (!error || typeof error !== 'object') {\r\n return fallback;\r\n }\r\n const httpError = error as {\r\n message?: string;\r\n error?: { message?: string | null } | null;\r\n };\r\n return httpError.error?.message ?? httpError.message ?? fallback;\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AA2EM,SAAU,kBAAkB,CAAC,MAAqB,EAAA;AACtD,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU;AAC9B,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;AAC5B,QAAA,OAAO,IAAI,IAAI,MAAM,CAAC,SAAS;IACjC;AACA,IAAA,OAAO,IAAI,EAAE,OAAO,IAAI,MAAM,CAAC,SAAS;AAC1C;;AC/EM,SAAU,kBAAkB,CAChC,MAAqB,EACrB,SAA8C,EAC9C,oBAAmD,EAAE,EAAA;IAErD,MAAM,eAAe,GAAG,oBAAoB,CAC1C,MAAM,EACN,SAAS,EACT,iBAAiB,CAClB;IACD,IAAI,eAAe,EAAE;AACnB,QAAA,OAA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AC5D,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClE;AACA,IAAA,OAAO,QAAQ;AACjB;AAEA,SAAS,2BAA2B,CAClC,QAAiB,EACjB,QAAgB,EAAA;IAEhB,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAC7C,QAAA,OAAO,QAAQ;IACjB;IACA,MAAM,QAAQ,GAAG,QAGhB;IACD,OAAO,QAAQ,CAAC,MAAM,EAAE,OAAO,IAAI,QAAQ,CAAC,OAAO,IAAI,QAAQ;AACjE;AAEA,SAAS,uBAAuB,CAAC,KAAc,EAAE,QAAgB,EAAA;IAC/D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACvC,QAAA,OAAO,QAAQ;IACjB;IACA,MAAM,SAAS,GAAG,KAGjB;IACD,OAAO,SAAS,CAAC,KAAK,EAAE,OAAO,IAAI,SAAS,CAAC,OAAO,IAAI,QAAQ;AAClE;;ACxTA;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, booleanAttribute, signal, output,
|
|
2
|
+
import { inject, input, computed, booleanAttribute, signal, output, HostListener, Component } from '@angular/core';
|
|
3
3
|
import { TranslocoPipe } from '@jsverse/transloco';
|
|
4
4
|
import { Icon } from '@masterteam/icons';
|
|
5
5
|
import { Router, NavigationEnd, RouterLinkActive, RouterLink } from '@angular/router';
|
|
@@ -20,6 +20,13 @@ class Sidebar {
|
|
|
20
20
|
logoLink = input(...(ngDevMode ? [undefined, { debugName: "logoLink" }] : /* istanbul ignore next */ []));
|
|
21
21
|
title = input(...(ngDevMode ? [undefined, { debugName: "title" }] : /* istanbul ignore next */ []));
|
|
22
22
|
subTitle = input(...(ngDevMode ? [undefined, { debugName: "subTitle" }] : /* istanbul ignore next */ []));
|
|
23
|
+
// Each half renders only when it carries text. A host can legitimately have
|
|
24
|
+
// one and not the other — clearing the tagline in the branding editor is how
|
|
25
|
+
// a tenant hides it — and an empty `<span>` still holds a line box, which
|
|
26
|
+
// left the surviving half sitting off-centre.
|
|
27
|
+
hasTitle = computed(() => !!this.title()?.trim(), ...(ngDevMode ? [{ debugName: "hasTitle" }] : /* istanbul ignore next */ []));
|
|
28
|
+
hasSubTitle = computed(() => !!this.subTitle()?.trim(), ...(ngDevMode ? [{ debugName: "hasSubTitle" }] : /* istanbul ignore next */ []));
|
|
29
|
+
hasBrandText = computed(() => this.hasTitle() || this.hasSubTitle(), ...(ngDevMode ? [{ debugName: "hasBrandText" }] : /* istanbul ignore next */ []));
|
|
23
30
|
bgColor = input(...(ngDevMode ? [undefined, { debugName: "bgColor" }] : /* istanbul ignore next */ []));
|
|
24
31
|
bgImage = input(...(ngDevMode ? [undefined, { debugName: "bgImage" }] : /* istanbul ignore next */ []));
|
|
25
32
|
bgRepeat = input(false, { ...(ngDevMode ? { debugName: "bgRepeat" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
@@ -137,11 +144,11 @@ class Sidebar {
|
|
|
137
144
|
this.closeFlyout();
|
|
138
145
|
}
|
|
139
146
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Sidebar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
140
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: Sidebar, isStandalone: true, selector: "mt-sidebar", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, logo: { classPropertyName: "logo", publicName: "logo", isSignal: true, isRequired: false, transformFunction: null }, logoLink: { classPropertyName: "logoLink", publicName: "logoLink", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, subTitle: { classPropertyName: "subTitle", publicName: "subTitle", isSignal: true, isRequired: false, transformFunction: null }, bgColor: { classPropertyName: "bgColor", publicName: "bgColor", isSignal: true, isRequired: false, transformFunction: null }, bgImage: { classPropertyName: "bgImage", publicName: "bgImage", isSignal: true, isRequired: false, transformFunction: null }, bgRepeat: { classPropertyName: "bgRepeat", publicName: "bgRepeat", isSignal: true, isRequired: false, transformFunction: null }, iconsColor: { classPropertyName: "iconsColor", publicName: "iconsColor", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expandedChange: "expandedChange" }, host: { listeners: { "window:resize": "onViewportChange()" }, properties: { "attr.title": "null" } }, ngImport: i0, template: "<div\r\n class=\"flex h-full min-h-0 flex-col overflow-hidden border-e-1 border-surface-300 bg-surface-200 transition-all duration-400 ease-in-out dark:bg-surface-800\"\r\n [style.width]=\"expanded() ? '18rem' : '4rem'\"\r\n>\r\n <div\r\n class=\"flex h-full min-h-0 flex-col gap-3 px-2 py-4\"\r\n [style.backgroundColor]=\"bgColor()\"\r\n [style.backgroundImage]=\"bgImage() ? 'url(' + bgImage() + ')' : null\"\r\n [style.backgroundSize]=\"bgImage() && !bgRepeat() ? 'cover' : null\"\r\n [style.backgroundPosition]=\"bgImage() && !bgRepeat() ? 'center' : null\"\r\n [class.bg-no-repeat]=\"!bgRepeat()\"\r\n [class.bg-repeat]=\"bgRepeat()\"\r\n >\r\n <!-- Toggle Button & Branding -->\r\n <div class=\"flex shrink-0 items-center gap-2\">\r\n <button\r\n type=\"button\"\r\n size=\"large\"\r\n class=\"flex items-center justify-center w-[47px] h-[40px] hover:bg-surface-100 dark:hover:bg-surface-900 transition-colors rounded-xl cursor-pointer shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n (click)=\"toggleSidebar()\"\r\n >\r\n <mt-icon\r\n icon=\"general.menu-01\"\r\n class=\"text-lg transition-transform duration-400 ease-in-out\"\r\n [class.rotate-180]=\"expanded()\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </button>\r\n\r\n @if (logo() || title()) {\r\n <div\r\n class=\"flex items-center gap-2 overflow-hidden transition-all duration-400 ease-in-out\"\r\n [class.max-w-0]=\"!expanded()\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n @if (logo()) {\r\n <img\r\n [src]=\"logo()\"\r\n [alt]=\"'components.sidebar.logoAlt' | transloco\"\r\n class=\"h-8 shrink-0\"\r\n [routerLink]=\"logoLink()\"\r\n [class.cursor-pointer]=\"logoLink()\"\r\n />\r\n }\r\n @if (logo() && (title() || subTitle())) {\r\n <div\r\n class=\"h-6 w-[1px] bg-current opacity-30 shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n ></div>\r\n }\r\n @if (title() || subTitle()) {\r\n <div\r\n class=\"flex flex-col gap-0.5 min-w-0\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <span class=\"text-sm font-semibold truncate\">{{ title() }}</span>\r\n @if (subTitle()) {\r\n <span class=\"text-xs opacity-70 truncate\">{{\r\n subTitle()\r\n }}</span>\r\n }\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex min-h-0 flex-1 flex-col gap-1 overflow-x-hidden overflow-y-auto overscroll-contain\"\r\n [class.mt-sidebar-menu-collapsed]=\"!expanded()\"\r\n [class.pr-1]=\"expanded()\"\r\n [class.pr-px]=\"!expanded()\"\r\n (scroll)=\"closeFlyout()\"\r\n >\r\n @for (item of items(); track item.id) {\r\n <!-- ============ Submenu parent (has children) ============ -->\r\n @if (hasChildren(item)) {\r\n @if (expanded()) {\r\n <!-- Expanded: inline accordion -->\r\n <div class=\"flex flex-col\">\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"flex-1 truncate whitespace-nowrap text-sm font-medium\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n <button\r\n type=\"button\"\r\n class=\"me-2 grid h-6 w-6 shrink-0 cursor-pointer place-items-center rounded hover:bg-surface-300/60 dark:hover:bg-surface-700/60 transition-colors\"\r\n [attr.aria-expanded]=\"isGroupOpen(item)\"\r\n (click)=\"toggleGroup(item, $event)\"\r\n >\r\n <mt-icon\r\n icon=\"arrow.chevron-down\"\r\n class=\"text-xs transition-transform duration-300 ease-in-out\"\r\n [class.rotate-180]=\"isGroupOpen(item)\"\r\n [style.--mt-icon-prev-width]=\"'14px'\"\r\n [style.--mt-icon-prev-height]=\"'14px'\"\r\n />\r\n </button>\r\n </a>\r\n\r\n <div\r\n class=\"grid transition-[grid-template-rows] duration-300 ease-in-out\"\r\n [style.gridTemplateRows]=\"isGroupOpen(item) ? '1fr' : '0fr'\"\r\n >\r\n <div class=\"overflow-hidden\">\r\n <div class=\"flex flex-col gap-0.5 py-1\">\r\n @if (item.loading && !item.children?.length) {\r\n <div\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 text-sm opacity-70\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <mt-icon\r\n icon=\"general.loading-01\"\r\n class=\"animate-spin\"\r\n />\r\n <span class=\"truncate\">{{\r\n \"components.sidebar.loading\" | transloco\r\n }}</span>\r\n </div>\r\n }\r\n @for (child of item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #crla=\"routerLinkActive\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"\r\n crla.isActive\r\n ? 'var(--p-primary-500)'\r\n : iconsColor()\r\n \"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <!-- Collapsed: icon trigger + hover/focus flyout -->\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n (mouseenter)=\"openFlyout(item, $event)\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n (focus)=\"openFlyout(item, $event)\"\r\n (blur)=\"scheduleFlyoutClose()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n </a>\r\n }\r\n } @else {\r\n <!-- ============ Leaf item ============ -->\r\n @if (item.href) {\r\n <a\r\n [href]=\"item.href\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #rla=\"routerLinkActive\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"\r\n rla.isActive ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n }\r\n }\r\n }\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<!-- ============ Collapsed-mode flyout panel ============ -->\r\n@if (flyout(); as fly) {\r\n <div\r\n class=\"mt-sidebar-flyout flex w-60 flex-col overflow-hidden rounded-xl border border-surface-300 bg-surface-0 shadow-2xl dark:border-surface-700 dark:bg-surface-800\"\r\n [style.top.px]=\"fly.top\"\r\n [style.left.px]=\"fly.left\"\r\n [style.right.px]=\"fly.right\"\r\n (mouseenter)=\"cancelFlyoutClose()\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n >\r\n <div\r\n class=\"flex items-center gap-2 border-b border-surface-200 px-4 py-2.5 dark:border-surface-700\"\r\n >\r\n @if (fly.item.icon) {\r\n <mt-icon\r\n [icon]=\"fly.item.icon\"\r\n class=\"text-primary-500 shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'18px'\"\r\n [style.--mt-icon-prev-height]=\"'18px'\"\r\n />\r\n }\r\n <span class=\"truncate text-sm font-semibold\">{{ fly.item.title }}</span>\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex flex-col gap-0.5 overflow-y-auto p-1.5\"\r\n [style.maxHeight.px]=\"fly.maxHeight\"\r\n >\r\n @if (fly.item.loading && !fly.item.children?.length) {\r\n <div class=\"flex items-center gap-2 px-3 py-2 text-sm text-muted-color\">\r\n <mt-icon icon=\"general.loading-01\" class=\"animate-spin\" />\r\n <span>{{ \"components.sidebar.loading\" | transloco }}</span>\r\n </div>\r\n } @else if (!fly.item.children?.length) {\r\n <div class=\"px-3 py-2 text-sm text-muted-color\">\r\n {{ \"components.sidebar.empty\" | transloco }}\r\n </div>\r\n }\r\n @for (child of fly.item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 text-(--p-primary-500) dark:bg-primary-900\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: [":host{display:block;height:100%;min-height:0}.mt-sidebar-menu{scrollbar-width:thin;scrollbar-color:var(--p-surface-400) transparent}.mt-sidebar-menu::-webkit-scrollbar{width:6px}.mt-sidebar-menu::-webkit-scrollbar-track{background:transparent}.mt-sidebar-menu::-webkit-scrollbar-thumb{border-radius:9999px;background:color-mix(in srgb,var(--p-surface-500) 58%,transparent)}.mt-sidebar-menu::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--p-surface-600) 72%,transparent)}.mt-sidebar-menu-collapsed{scrollbar-color:var(--p-surface-500) transparent}.mt-sidebar-menu-collapsed::-webkit-scrollbar{width:2px}.mt-sidebar-menu-collapsed::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--p-surface-600) 82%,transparent)}.mt-sidebar-flyout{position:fixed;z-index:1200;animation:mt-sidebar-flyout-in .14s ease-out}@keyframes mt-sidebar-flyout-in{0%{opacity:0;transform:translateY(2px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media(prefers-reduced-motion:reduce){.mt-sidebar-flyout{animation:none}}\n"], dependencies: [{ kind: "directive", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
|
|
147
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: Sidebar, isStandalone: true, selector: "mt-sidebar", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, logo: { classPropertyName: "logo", publicName: "logo", isSignal: true, isRequired: false, transformFunction: null }, logoLink: { classPropertyName: "logoLink", publicName: "logoLink", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, subTitle: { classPropertyName: "subTitle", publicName: "subTitle", isSignal: true, isRequired: false, transformFunction: null }, bgColor: { classPropertyName: "bgColor", publicName: "bgColor", isSignal: true, isRequired: false, transformFunction: null }, bgImage: { classPropertyName: "bgImage", publicName: "bgImage", isSignal: true, isRequired: false, transformFunction: null }, bgRepeat: { classPropertyName: "bgRepeat", publicName: "bgRepeat", isSignal: true, isRequired: false, transformFunction: null }, iconsColor: { classPropertyName: "iconsColor", publicName: "iconsColor", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expandedChange: "expandedChange" }, host: { listeners: { "window:resize": "onViewportChange()" }, properties: { "attr.title": "null" } }, ngImport: i0, template: "<div\r\n class=\"flex h-full min-h-0 flex-col overflow-hidden border-e-1 border-surface-300 bg-surface-200 transition-all duration-400 ease-in-out dark:bg-surface-800\"\r\n [style.width]=\"expanded() ? '18rem' : '4rem'\"\r\n>\r\n <div\r\n class=\"flex h-full min-h-0 flex-col gap-3 px-2 py-4\"\r\n [style.backgroundColor]=\"bgColor()\"\r\n [style.backgroundImage]=\"bgImage() ? 'url(' + bgImage() + ')' : null\"\r\n [style.backgroundSize]=\"bgImage() && !bgRepeat() ? 'cover' : null\"\r\n [style.backgroundPosition]=\"bgImage() && !bgRepeat() ? 'center' : null\"\r\n [class.bg-no-repeat]=\"!bgRepeat()\"\r\n [class.bg-repeat]=\"bgRepeat()\"\r\n >\r\n <!-- Toggle Button & Branding -->\r\n <div class=\"flex shrink-0 items-center gap-2\">\r\n <button\r\n type=\"button\"\r\n size=\"large\"\r\n class=\"flex items-center justify-center w-[47px] h-[40px] hover:bg-surface-100 dark:hover:bg-surface-900 transition-colors rounded-xl cursor-pointer shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n (click)=\"toggleSidebar()\"\r\n >\r\n <mt-icon\r\n icon=\"general.menu-01\"\r\n class=\"text-lg transition-transform duration-400 ease-in-out\"\r\n [class.rotate-180]=\"expanded()\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </button>\r\n\r\n @if (logo() || hasBrandText()) {\r\n <div\r\n class=\"flex items-center gap-2 overflow-hidden transition-all duration-400 ease-in-out\"\r\n [class.max-w-0]=\"!expanded()\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n @if (logo()) {\r\n <img\r\n [src]=\"logo()\"\r\n [alt]=\"'components.sidebar.logoAlt' | transloco\"\r\n class=\"h-8 shrink-0\"\r\n [routerLink]=\"logoLink()\"\r\n [class.cursor-pointer]=\"logoLink()\"\r\n />\r\n }\r\n @if (logo() && hasBrandText()) {\r\n <div\r\n class=\"h-6 w-[1px] bg-current opacity-30 shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n ></div>\r\n }\r\n @if (hasBrandText()) {\r\n <div\r\n class=\"flex flex-col gap-0.5 min-w-0\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n @if (hasTitle()) {\r\n <span class=\"text-sm font-semibold truncate\">{{\r\n title()\r\n }}</span>\r\n }\r\n @if (hasSubTitle()) {\r\n <span class=\"text-xs opacity-70 truncate\">{{\r\n subTitle()\r\n }}</span>\r\n }\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex min-h-0 flex-1 flex-col gap-1 overflow-x-hidden overflow-y-auto overscroll-contain\"\r\n [class.mt-sidebar-menu-collapsed]=\"!expanded()\"\r\n [class.pr-1]=\"expanded()\"\r\n [class.pr-px]=\"!expanded()\"\r\n (scroll)=\"closeFlyout()\"\r\n >\r\n @for (item of items(); track item.id) {\r\n <!-- ============ Submenu parent (has children) ============ -->\r\n @if (hasChildren(item)) {\r\n @if (expanded()) {\r\n <!-- Expanded: inline accordion -->\r\n <div class=\"flex flex-col\">\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"flex-1 truncate whitespace-nowrap text-sm font-medium\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n <button\r\n type=\"button\"\r\n class=\"me-2 grid h-6 w-6 shrink-0 cursor-pointer place-items-center rounded hover:bg-surface-300/60 dark:hover:bg-surface-700/60 transition-colors\"\r\n [attr.aria-expanded]=\"isGroupOpen(item)\"\r\n (click)=\"toggleGroup(item, $event)\"\r\n >\r\n <mt-icon\r\n icon=\"arrow.chevron-down\"\r\n class=\"text-xs transition-transform duration-300 ease-in-out\"\r\n [class.rotate-180]=\"isGroupOpen(item)\"\r\n [style.--mt-icon-prev-width]=\"'14px'\"\r\n [style.--mt-icon-prev-height]=\"'14px'\"\r\n />\r\n </button>\r\n </a>\r\n\r\n <div\r\n class=\"grid transition-[grid-template-rows] duration-300 ease-in-out\"\r\n [style.gridTemplateRows]=\"isGroupOpen(item) ? '1fr' : '0fr'\"\r\n >\r\n <div class=\"overflow-hidden\">\r\n <div class=\"flex flex-col gap-0.5 py-1\">\r\n @if (item.loading && !item.children?.length) {\r\n <div\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 text-sm opacity-70\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <mt-icon\r\n icon=\"general.loading-01\"\r\n class=\"animate-spin\"\r\n />\r\n <span class=\"truncate\">{{\r\n \"components.sidebar.loading\" | transloco\r\n }}</span>\r\n </div>\r\n }\r\n @for (child of item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #crla=\"routerLinkActive\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"\r\n crla.isActive\r\n ? 'var(--p-primary-500)'\r\n : iconsColor()\r\n \"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <!-- Collapsed: icon trigger + hover/focus flyout -->\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n (mouseenter)=\"openFlyout(item, $event)\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n (focus)=\"openFlyout(item, $event)\"\r\n (blur)=\"scheduleFlyoutClose()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n </a>\r\n }\r\n } @else {\r\n <!-- ============ Leaf item ============ -->\r\n @if (item.href) {\r\n <a\r\n [href]=\"item.href\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #rla=\"routerLinkActive\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"\r\n rla.isActive ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n }\r\n }\r\n }\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<!-- ============ Collapsed-mode flyout panel ============ -->\r\n@if (flyout(); as fly) {\r\n <div\r\n class=\"mt-sidebar-flyout flex w-60 flex-col overflow-hidden rounded-xl border border-surface-300 bg-surface-0 shadow-2xl dark:border-surface-700 dark:bg-surface-800\"\r\n [style.top.px]=\"fly.top\"\r\n [style.left.px]=\"fly.left\"\r\n [style.right.px]=\"fly.right\"\r\n (mouseenter)=\"cancelFlyoutClose()\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n >\r\n <div\r\n class=\"flex items-center gap-2 border-b border-surface-200 px-4 py-2.5 dark:border-surface-700\"\r\n >\r\n @if (fly.item.icon) {\r\n <mt-icon\r\n [icon]=\"fly.item.icon\"\r\n class=\"text-primary-500 shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'18px'\"\r\n [style.--mt-icon-prev-height]=\"'18px'\"\r\n />\r\n }\r\n <span class=\"truncate text-sm font-semibold\">{{ fly.item.title }}</span>\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex flex-col gap-0.5 overflow-y-auto p-1.5\"\r\n [style.maxHeight.px]=\"fly.maxHeight\"\r\n >\r\n @if (fly.item.loading && !fly.item.children?.length) {\r\n <div class=\"flex items-center gap-2 px-3 py-2 text-sm text-muted-color\">\r\n <mt-icon icon=\"general.loading-01\" class=\"animate-spin\" />\r\n <span>{{ \"components.sidebar.loading\" | transloco }}</span>\r\n </div>\r\n } @else if (!fly.item.children?.length) {\r\n <div class=\"px-3 py-2 text-sm text-muted-color\">\r\n {{ \"components.sidebar.empty\" | transloco }}\r\n </div>\r\n }\r\n @for (child of fly.item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 text-(--p-primary-500) dark:bg-primary-900\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: [":host{display:block;height:100%;min-height:0}.mt-sidebar-menu{scrollbar-width:thin;scrollbar-color:var(--p-surface-400) transparent}.mt-sidebar-menu::-webkit-scrollbar{width:6px}.mt-sidebar-menu::-webkit-scrollbar-track{background:transparent}.mt-sidebar-menu::-webkit-scrollbar-thumb{border-radius:9999px;background:color-mix(in srgb,var(--p-surface-500) 58%,transparent)}.mt-sidebar-menu::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--p-surface-600) 72%,transparent)}.mt-sidebar-menu-collapsed{scrollbar-color:var(--p-surface-500) transparent}.mt-sidebar-menu-collapsed::-webkit-scrollbar{width:2px}.mt-sidebar-menu-collapsed::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--p-surface-600) 82%,transparent)}.mt-sidebar-flyout{position:fixed;z-index:1200;animation:mt-sidebar-flyout-in .14s ease-out}@keyframes mt-sidebar-flyout-in{0%{opacity:0;transform:translateY(2px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media(prefers-reduced-motion:reduce){.mt-sidebar-flyout{animation:none}}\n"], dependencies: [{ kind: "directive", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "directive", type: Tooltip, selector: "[mtTooltip]" }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
|
|
141
148
|
}
|
|
142
149
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Sidebar, decorators: [{
|
|
143
150
|
type: Component,
|
|
144
|
-
args: [{ selector: 'mt-sidebar', standalone: true, imports: [RouterLinkActive, RouterLink, Icon, Tooltip, TranslocoPipe], host: { '[attr.title]': 'null' }, template: "<div\r\n class=\"flex h-full min-h-0 flex-col overflow-hidden border-e-1 border-surface-300 bg-surface-200 transition-all duration-400 ease-in-out dark:bg-surface-800\"\r\n [style.width]=\"expanded() ? '18rem' : '4rem'\"\r\n>\r\n <div\r\n class=\"flex h-full min-h-0 flex-col gap-3 px-2 py-4\"\r\n [style.backgroundColor]=\"bgColor()\"\r\n [style.backgroundImage]=\"bgImage() ? 'url(' + bgImage() + ')' : null\"\r\n [style.backgroundSize]=\"bgImage() && !bgRepeat() ? 'cover' : null\"\r\n [style.backgroundPosition]=\"bgImage() && !bgRepeat() ? 'center' : null\"\r\n [class.bg-no-repeat]=\"!bgRepeat()\"\r\n [class.bg-repeat]=\"bgRepeat()\"\r\n >\r\n <!-- Toggle Button & Branding -->\r\n <div class=\"flex shrink-0 items-center gap-2\">\r\n <button\r\n type=\"button\"\r\n size=\"large\"\r\n class=\"flex items-center justify-center w-[47px] h-[40px] hover:bg-surface-100 dark:hover:bg-surface-900 transition-colors rounded-xl cursor-pointer shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n (click)=\"toggleSidebar()\"\r\n >\r\n <mt-icon\r\n icon=\"general.menu-01\"\r\n class=\"text-lg transition-transform duration-400 ease-in-out\"\r\n [class.rotate-180]=\"expanded()\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </button>\r\n\r\n @if (logo() || title()) {\r\n <div\r\n class=\"flex items-center gap-2 overflow-hidden transition-all duration-400 ease-in-out\"\r\n [class.max-w-0]=\"!expanded()\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n @if (logo()) {\r\n <img\r\n [src]=\"logo()\"\r\n [alt]=\"'components.sidebar.logoAlt' | transloco\"\r\n class=\"h-8 shrink-0\"\r\n [routerLink]=\"logoLink()\"\r\n [class.cursor-pointer]=\"logoLink()\"\r\n />\r\n }\r\n @if (logo() && (title() || subTitle())) {\r\n <div\r\n class=\"h-6 w-[1px] bg-current opacity-30 shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n ></div>\r\n }\r\n @if (title() || subTitle()) {\r\n <div\r\n class=\"flex flex-col gap-0.5 min-w-0\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <span class=\"text-sm font-semibold truncate\">{{ title() }}</span>\r\n @if (subTitle()) {\r\n <span class=\"text-xs opacity-70 truncate\">{{\r\n subTitle()\r\n }}</span>\r\n }\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex min-h-0 flex-1 flex-col gap-1 overflow-x-hidden overflow-y-auto overscroll-contain\"\r\n [class.mt-sidebar-menu-collapsed]=\"!expanded()\"\r\n [class.pr-1]=\"expanded()\"\r\n [class.pr-px]=\"!expanded()\"\r\n (scroll)=\"closeFlyout()\"\r\n >\r\n @for (item of items(); track item.id) {\r\n <!-- ============ Submenu parent (has children) ============ -->\r\n @if (hasChildren(item)) {\r\n @if (expanded()) {\r\n <!-- Expanded: inline accordion -->\r\n <div class=\"flex flex-col\">\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"flex-1 truncate whitespace-nowrap text-sm font-medium\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n <button\r\n type=\"button\"\r\n class=\"me-2 grid h-6 w-6 shrink-0 cursor-pointer place-items-center rounded hover:bg-surface-300/60 dark:hover:bg-surface-700/60 transition-colors\"\r\n [attr.aria-expanded]=\"isGroupOpen(item)\"\r\n (click)=\"toggleGroup(item, $event)\"\r\n >\r\n <mt-icon\r\n icon=\"arrow.chevron-down\"\r\n class=\"text-xs transition-transform duration-300 ease-in-out\"\r\n [class.rotate-180]=\"isGroupOpen(item)\"\r\n [style.--mt-icon-prev-width]=\"'14px'\"\r\n [style.--mt-icon-prev-height]=\"'14px'\"\r\n />\r\n </button>\r\n </a>\r\n\r\n <div\r\n class=\"grid transition-[grid-template-rows] duration-300 ease-in-out\"\r\n [style.gridTemplateRows]=\"isGroupOpen(item) ? '1fr' : '0fr'\"\r\n >\r\n <div class=\"overflow-hidden\">\r\n <div class=\"flex flex-col gap-0.5 py-1\">\r\n @if (item.loading && !item.children?.length) {\r\n <div\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 text-sm opacity-70\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <mt-icon\r\n icon=\"general.loading-01\"\r\n class=\"animate-spin\"\r\n />\r\n <span class=\"truncate\">{{\r\n \"components.sidebar.loading\" | transloco\r\n }}</span>\r\n </div>\r\n }\r\n @for (child of item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #crla=\"routerLinkActive\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"\r\n crla.isActive\r\n ? 'var(--p-primary-500)'\r\n : iconsColor()\r\n \"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <!-- Collapsed: icon trigger + hover/focus flyout -->\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n (mouseenter)=\"openFlyout(item, $event)\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n (focus)=\"openFlyout(item, $event)\"\r\n (blur)=\"scheduleFlyoutClose()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n </a>\r\n }\r\n } @else {\r\n <!-- ============ Leaf item ============ -->\r\n @if (item.href) {\r\n <a\r\n [href]=\"item.href\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #rla=\"routerLinkActive\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"\r\n rla.isActive ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n }\r\n }\r\n }\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<!-- ============ Collapsed-mode flyout panel ============ -->\r\n@if (flyout(); as fly) {\r\n <div\r\n class=\"mt-sidebar-flyout flex w-60 flex-col overflow-hidden rounded-xl border border-surface-300 bg-surface-0 shadow-2xl dark:border-surface-700 dark:bg-surface-800\"\r\n [style.top.px]=\"fly.top\"\r\n [style.left.px]=\"fly.left\"\r\n [style.right.px]=\"fly.right\"\r\n (mouseenter)=\"cancelFlyoutClose()\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n >\r\n <div\r\n class=\"flex items-center gap-2 border-b border-surface-200 px-4 py-2.5 dark:border-surface-700\"\r\n >\r\n @if (fly.item.icon) {\r\n <mt-icon\r\n [icon]=\"fly.item.icon\"\r\n class=\"text-primary-500 shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'18px'\"\r\n [style.--mt-icon-prev-height]=\"'18px'\"\r\n />\r\n }\r\n <span class=\"truncate text-sm font-semibold\">{{ fly.item.title }}</span>\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex flex-col gap-0.5 overflow-y-auto p-1.5\"\r\n [style.maxHeight.px]=\"fly.maxHeight\"\r\n >\r\n @if (fly.item.loading && !fly.item.children?.length) {\r\n <div class=\"flex items-center gap-2 px-3 py-2 text-sm text-muted-color\">\r\n <mt-icon icon=\"general.loading-01\" class=\"animate-spin\" />\r\n <span>{{ \"components.sidebar.loading\" | transloco }}</span>\r\n </div>\r\n } @else if (!fly.item.children?.length) {\r\n <div class=\"px-3 py-2 text-sm text-muted-color\">\r\n {{ \"components.sidebar.empty\" | transloco }}\r\n </div>\r\n }\r\n @for (child of fly.item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 text-(--p-primary-500) dark:bg-primary-900\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: [":host{display:block;height:100%;min-height:0}.mt-sidebar-menu{scrollbar-width:thin;scrollbar-color:var(--p-surface-400) transparent}.mt-sidebar-menu::-webkit-scrollbar{width:6px}.mt-sidebar-menu::-webkit-scrollbar-track{background:transparent}.mt-sidebar-menu::-webkit-scrollbar-thumb{border-radius:9999px;background:color-mix(in srgb,var(--p-surface-500) 58%,transparent)}.mt-sidebar-menu::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--p-surface-600) 72%,transparent)}.mt-sidebar-menu-collapsed{scrollbar-color:var(--p-surface-500) transparent}.mt-sidebar-menu-collapsed::-webkit-scrollbar{width:2px}.mt-sidebar-menu-collapsed::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--p-surface-600) 82%,transparent)}.mt-sidebar-flyout{position:fixed;z-index:1200;animation:mt-sidebar-flyout-in .14s ease-out}@keyframes mt-sidebar-flyout-in{0%{opacity:0;transform:translateY(2px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media(prefers-reduced-motion:reduce){.mt-sidebar-flyout{animation:none}}\n"] }]
|
|
151
|
+
args: [{ selector: 'mt-sidebar', standalone: true, imports: [RouterLinkActive, RouterLink, Icon, Tooltip, TranslocoPipe], host: { '[attr.title]': 'null' }, template: "<div\r\n class=\"flex h-full min-h-0 flex-col overflow-hidden border-e-1 border-surface-300 bg-surface-200 transition-all duration-400 ease-in-out dark:bg-surface-800\"\r\n [style.width]=\"expanded() ? '18rem' : '4rem'\"\r\n>\r\n <div\r\n class=\"flex h-full min-h-0 flex-col gap-3 px-2 py-4\"\r\n [style.backgroundColor]=\"bgColor()\"\r\n [style.backgroundImage]=\"bgImage() ? 'url(' + bgImage() + ')' : null\"\r\n [style.backgroundSize]=\"bgImage() && !bgRepeat() ? 'cover' : null\"\r\n [style.backgroundPosition]=\"bgImage() && !bgRepeat() ? 'center' : null\"\r\n [class.bg-no-repeat]=\"!bgRepeat()\"\r\n [class.bg-repeat]=\"bgRepeat()\"\r\n >\r\n <!-- Toggle Button & Branding -->\r\n <div class=\"flex shrink-0 items-center gap-2\">\r\n <button\r\n type=\"button\"\r\n size=\"large\"\r\n class=\"flex items-center justify-center w-[47px] h-[40px] hover:bg-surface-100 dark:hover:bg-surface-900 transition-colors rounded-xl cursor-pointer shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n (click)=\"toggleSidebar()\"\r\n >\r\n <mt-icon\r\n icon=\"general.menu-01\"\r\n class=\"text-lg transition-transform duration-400 ease-in-out\"\r\n [class.rotate-180]=\"expanded()\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </button>\r\n\r\n @if (logo() || hasBrandText()) {\r\n <div\r\n class=\"flex items-center gap-2 overflow-hidden transition-all duration-400 ease-in-out\"\r\n [class.max-w-0]=\"!expanded()\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n @if (logo()) {\r\n <img\r\n [src]=\"logo()\"\r\n [alt]=\"'components.sidebar.logoAlt' | transloco\"\r\n class=\"h-8 shrink-0\"\r\n [routerLink]=\"logoLink()\"\r\n [class.cursor-pointer]=\"logoLink()\"\r\n />\r\n }\r\n @if (logo() && hasBrandText()) {\r\n <div\r\n class=\"h-6 w-[1px] bg-current opacity-30 shrink-0\"\r\n [style.color]=\"iconsColor()\"\r\n ></div>\r\n }\r\n @if (hasBrandText()) {\r\n <div\r\n class=\"flex flex-col gap-0.5 min-w-0\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n @if (hasTitle()) {\r\n <span class=\"text-sm font-semibold truncate\">{{\r\n title()\r\n }}</span>\r\n }\r\n @if (hasSubTitle()) {\r\n <span class=\"text-xs opacity-70 truncate\">{{\r\n subTitle()\r\n }}</span>\r\n }\r\n </div>\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex min-h-0 flex-1 flex-col gap-1 overflow-x-hidden overflow-y-auto overscroll-contain\"\r\n [class.mt-sidebar-menu-collapsed]=\"!expanded()\"\r\n [class.pr-1]=\"expanded()\"\r\n [class.pr-px]=\"!expanded()\"\r\n (scroll)=\"closeFlyout()\"\r\n >\r\n @for (item of items(); track item.id) {\r\n <!-- ============ Submenu parent (has children) ============ -->\r\n @if (hasChildren(item)) {\r\n @if (expanded()) {\r\n <!-- Expanded: inline accordion -->\r\n <div class=\"flex flex-col\">\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"flex-1 truncate whitespace-nowrap text-sm font-medium\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n <button\r\n type=\"button\"\r\n class=\"me-2 grid h-6 w-6 shrink-0 cursor-pointer place-items-center rounded hover:bg-surface-300/60 dark:hover:bg-surface-700/60 transition-colors\"\r\n [attr.aria-expanded]=\"isGroupOpen(item)\"\r\n (click)=\"toggleGroup(item, $event)\"\r\n >\r\n <mt-icon\r\n icon=\"arrow.chevron-down\"\r\n class=\"text-xs transition-transform duration-300 ease-in-out\"\r\n [class.rotate-180]=\"isGroupOpen(item)\"\r\n [style.--mt-icon-prev-width]=\"'14px'\"\r\n [style.--mt-icon-prev-height]=\"'14px'\"\r\n />\r\n </button>\r\n </a>\r\n\r\n <div\r\n class=\"grid transition-[grid-template-rows] duration-300 ease-in-out\"\r\n [style.gridTemplateRows]=\"isGroupOpen(item) ? '1fr' : '0fr'\"\r\n >\r\n <div class=\"overflow-hidden\">\r\n <div class=\"flex flex-col gap-0.5 py-1\">\r\n @if (item.loading && !item.children?.length) {\r\n <div\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 text-sm opacity-70\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <mt-icon\r\n icon=\"general.loading-01\"\r\n class=\"animate-spin\"\r\n />\r\n <span class=\"truncate\">{{\r\n \"components.sidebar.loading\" | transloco\r\n }}</span>\r\n </div>\r\n }\r\n @for (child of item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #crla=\"routerLinkActive\"\r\n class=\"flex items-center gap-2.5 h-10 ps-11 pe-3 shrink-0 rounded-md hover:bg-primary-50 dark:hover:bg-surface-900 transition-colors overflow-hidden\"\r\n mtTooltip=\"{{ child.title }}\"\r\n [style.color]=\"\r\n crla.isActive\r\n ? 'var(--p-primary-500)'\r\n : iconsColor()\r\n \"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate text-sm\">{{\r\n child.title\r\n }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <!-- Collapsed: icon trigger + hover/focus flyout -->\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n [style.color]=\"\r\n isSectionActive(item) ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n (mouseenter)=\"openFlyout(item, $event)\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n (focus)=\"openFlyout(item, $event)\"\r\n (blur)=\"scheduleFlyoutClose()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n </a>\r\n }\r\n } @else {\r\n <!-- ============ Leaf item ============ -->\r\n @if (item.href) {\r\n <a\r\n [href]=\"item.href\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"iconsColor()\"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"item.routerLink\"\r\n routerLinkActive=\"bg-primary-50 dark:bg-primary-900\"\r\n #rla=\"routerLinkActive\"\r\n class=\"flex items-center gap-3 h-[47px] min-w-[47px] shrink-0 dark:hover:bg-surface-900 hover:bg-primary-50 transition-colors rounded-md overflow-hidden\"\r\n mtTooltip=\"{{ item.title }}\"\r\n [style.color]=\"\r\n rla.isActive ? 'var(--p-primary-500)' : iconsColor()\r\n \"\r\n >\r\n <div class=\"px-3.5\">\r\n <mt-icon\r\n [icon]=\"item.icon\"\r\n class=\"shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'20px'\"\r\n [style.--mt-icon-prev-height]=\"'20px'\"\r\n />\r\n </div>\r\n <div\r\n class=\"whitespace-nowrap text-sm font-medium transition-all duration-400 ease-in-out overflow-hidden\"\r\n [class.opacity-0]=\"!expanded()\"\r\n [class.max-w-xs]=\"expanded()\"\r\n [class.opacity-100]=\"expanded()\"\r\n >\r\n {{ item.title }}\r\n </div>\r\n </a>\r\n }\r\n }\r\n }\r\n </div>\r\n </div>\r\n</div>\r\n\r\n<!-- ============ Collapsed-mode flyout panel ============ -->\r\n@if (flyout(); as fly) {\r\n <div\r\n class=\"mt-sidebar-flyout flex w-60 flex-col overflow-hidden rounded-xl border border-surface-300 bg-surface-0 shadow-2xl dark:border-surface-700 dark:bg-surface-800\"\r\n [style.top.px]=\"fly.top\"\r\n [style.left.px]=\"fly.left\"\r\n [style.right.px]=\"fly.right\"\r\n (mouseenter)=\"cancelFlyoutClose()\"\r\n (mouseleave)=\"scheduleFlyoutClose()\"\r\n >\r\n <div\r\n class=\"flex items-center gap-2 border-b border-surface-200 px-4 py-2.5 dark:border-surface-700\"\r\n >\r\n @if (fly.item.icon) {\r\n <mt-icon\r\n [icon]=\"fly.item.icon\"\r\n class=\"text-primary-500 shrink-0\"\r\n [style.--mt-icon-prev-width]=\"'18px'\"\r\n [style.--mt-icon-prev-height]=\"'18px'\"\r\n />\r\n }\r\n <span class=\"truncate text-sm font-semibold\">{{ fly.item.title }}</span>\r\n </div>\r\n\r\n <div\r\n class=\"mt-sidebar-menu flex flex-col gap-0.5 overflow-y-auto p-1.5\"\r\n [style.maxHeight.px]=\"fly.maxHeight\"\r\n >\r\n @if (fly.item.loading && !fly.item.children?.length) {\r\n <div class=\"flex items-center gap-2 px-3 py-2 text-sm text-muted-color\">\r\n <mt-icon icon=\"general.loading-01\" class=\"animate-spin\" />\r\n <span>{{ \"components.sidebar.loading\" | transloco }}</span>\r\n </div>\r\n } @else if (!fly.item.children?.length) {\r\n <div class=\"px-3 py-2 text-sm text-muted-color\">\r\n {{ \"components.sidebar.empty\" | transloco }}\r\n </div>\r\n }\r\n @for (child of fly.item.children ?? []; track child.id) {\r\n @if (child.href) {\r\n <a\r\n [href]=\"child.href\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n } @else {\r\n <a\r\n [routerLink]=\"child.routerLink\"\r\n routerLinkActive=\"bg-primary-50 text-(--p-primary-500) dark:bg-primary-900\"\r\n class=\"flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm hover:bg-surface-100 dark:hover:bg-surface-700 transition-colors\"\r\n (click)=\"closeFlyout()\"\r\n >\r\n @if (child.icon) {\r\n <mt-icon\r\n [icon]=\"child.icon\"\r\n class=\"shrink-0 opacity-80\"\r\n [style.--mt-icon-prev-width]=\"'16px'\"\r\n [style.--mt-icon-prev-height]=\"'16px'\"\r\n />\r\n } @else {\r\n <span\r\n class=\"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-50\"\r\n ></span>\r\n }\r\n <span class=\"truncate\">{{ child.title }}</span>\r\n </a>\r\n }\r\n }\r\n </div>\r\n </div>\r\n}\r\n", styles: [":host{display:block;height:100%;min-height:0}.mt-sidebar-menu{scrollbar-width:thin;scrollbar-color:var(--p-surface-400) transparent}.mt-sidebar-menu::-webkit-scrollbar{width:6px}.mt-sidebar-menu::-webkit-scrollbar-track{background:transparent}.mt-sidebar-menu::-webkit-scrollbar-thumb{border-radius:9999px;background:color-mix(in srgb,var(--p-surface-500) 58%,transparent)}.mt-sidebar-menu::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--p-surface-600) 72%,transparent)}.mt-sidebar-menu-collapsed{scrollbar-color:var(--p-surface-500) transparent}.mt-sidebar-menu-collapsed::-webkit-scrollbar{width:2px}.mt-sidebar-menu-collapsed::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--p-surface-600) 82%,transparent)}.mt-sidebar-flyout{position:fixed;z-index:1200;animation:mt-sidebar-flyout-in .14s ease-out}@keyframes mt-sidebar-flyout-in{0%{opacity:0;transform:translateY(2px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}@media(prefers-reduced-motion:reduce){.mt-sidebar-flyout{animation:none}}\n"] }]
|
|
145
152
|
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], logo: [{ type: i0.Input, args: [{ isSignal: true, alias: "logo", required: false }] }], logoLink: [{ type: i0.Input, args: [{ isSignal: true, alias: "logoLink", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], subTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "subTitle", required: false }] }], bgColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "bgColor", required: false }] }], bgImage: [{ type: i0.Input, args: [{ isSignal: true, alias: "bgImage", required: false }] }], bgRepeat: [{ type: i0.Input, args: [{ isSignal: true, alias: "bgRepeat", required: false }] }], iconsColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconsColor", required: false }] }], expandedChange: [{ type: i0.Output, args: ["expandedChange"] }], onViewportChange: [{
|
|
146
153
|
type: HostListener,
|
|
147
154
|
args: ['window:resize']
|