@agorapulse/ui-components 22.5.7-beta.1 → 22.5.8-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agorapulse-ui-components-22.5.8-beta.1.tgz +0 -0
- package/fesm2022/agorapulse-ui-components-filter-dropdown.mjs +16 -27
- package/fesm2022/agorapulse-ui-components-filter-dropdown.mjs.map +1 -1
- package/fesm2022/agorapulse-ui-components-i18n.mjs +5 -2
- package/fesm2022/agorapulse-ui-components-i18n.mjs.map +1 -1
- package/package.json +1 -1
- package/types/agorapulse-ui-components-filter-dropdown.d.ts +7 -5
- package/types/agorapulse-ui-components-i18n.d.ts +38 -6
- package/agorapulse-ui-components-22.5.7-beta.1.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agorapulse-ui-components-i18n.mjs","sources":["../../../libs/ui-components/i18n/src/default-texts.ts","../../../libs/ui-components/i18n/src/key-guard.ts","../../../libs/ui-components/i18n/src/raw.pipe.ts","../../../libs/ui-components/i18n/src/translation.model.ts","../../../libs/ui-components/i18n/src/translation.provider.ts","../../../libs/ui-components/i18n/src/resolve-texts.ts","../../../libs/ui-components/i18n/src/agorapulse-ui-components-i18n.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const DEFAULT_TEXTS: Readonly<Record<string, string>> = Object.freeze({\n 'ui-components.filters.trigger': 'Filters',\n 'ui-components.filters.aria-label': 'Filters',\n 'ui-components.filters.apply': 'Apply filters',\n 'ui-components.filters.clear': 'Clear filters',\n 'ui-components.filters.reset': 'Reset filters',\n 'ui-components.filters.save-preset': 'Save preset',\n 'ui-components.filters.save-new-presets': 'Save new presets',\n 'ui-components.filters.save-as-new-preset': 'Save as new preset',\n 'ui-components.filters.update-existing-preset': 'Update existing preset',\n 'ui-components.filters.date-range-placeholder': 'Select date range',\n 'ui-components.search.placeholder': 'Search',\n 'ui-components.select.only': 'Only',\n 'ui-components.select.placeholder': 'Select an option',\n});\n\n/**\n * Holds the fallback table read by `injectTranslate`; provide another table to override it, for instance in a test.\n *\n * @example\n * TestBed.configureTestingModule({ providers: [{ provide: UI_COMPONENTS_DEFAULT_TEXTS, useValue: { 'ui-components.ok': 'OK' } }] });\n */\nexport const UI_COMPONENTS_DEFAULT_TEXTS = new InjectionToken<Readonly<Record<string, string>>>('UI_COMPONENTS_DEFAULT_TEXTS', {\n providedIn: 'root',\n factory: () => DEFAULT_TEXTS,\n});\n\nexport function fallbackText(\n key: string,\n params?: Record<string, unknown>,\n table: Readonly<Record<string, string>> = DEFAULT_TEXTS\n): string | undefined {\n if (!Object.prototype.hasOwnProperty.call(table, key)) return undefined;\n\n return table[key].replace(/\\{\\{\\s*([^{}\\s]+)\\s*\\}\\}/g, (placeholder, name: string) =>\n params?.[name] !== undefined && params[name] !== null && Object.prototype.hasOwnProperty.call(params, name)\n ? String(params[name])\n : placeholder\n );\n}\n","import { isDevMode } from '@angular/core';\n\n/**\n * The default `isKey`: dotted segments, so dotted data such as `example.com` passes too.\n *\n * @example\n * DEFAULT_IS_KEY('report.filter.apply'); // true\n * DEFAULT_IS_KEY('Black Friday 2026'); // false\n */\nexport const DEFAULT_IS_KEY = (text: string): boolean => /^[\\w-]+(\\.[\\w-]+)+$/.test(text);\n\nconst warnedValues = new Set<string>();\n\nexport function warnIfNotKey(text: string, isKey: (text: string) => boolean, devMode: boolean = isDevMode()): void {\n if (!devMode || isKey(text) || warnedValues.has(text)) return;\n\n warnedValues.add(text);\n console.warn(`[ui-components/i18n] \"${text}\" is not a translation key. Wrap displayed data with raw() (or | apRaw).`);\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { RawText } from './translation.model';\n\n/**\n * Turns a text into a {@link RawText} so a component displays it as is. `null` and `undefined` give an empty text.\n *\n * @example\n * <ap-button [i18n]=\"{ label: user.name | apRaw }\" />\n */\n@Pipe({ name: 'apRaw' })\nexport class RawPipe implements PipeTransform {\n transform(text: string | null | undefined): RawText {\n return { raw: text ?? '' };\n }\n}\n","/**\n * A translation key with optional interpolation parameters.\n *\n * @example\n * const request: TranslationKeyRequest = { key: 'inbox.unread', params: { count: 3 } };\n */\nexport type TranslationKeyRequest = { key: string; params?: Record<string, unknown> };\n\n/**\n * A text displayed as is, never looked up in a catalogue (user content, names, handles).\n *\n * @example\n * const text: RawText = { raw: 'jordan.amar' };\n */\nexport type RawText = { raw: string };\n\n/**\n * What a component accepts for a displayed text: a string is a translation key,\n * `{ key, params }` a key with parameters, `{ raw }` a text displayed as is.\n *\n * @example\n * const label: TranslationRequest = 'common.save';\n */\nexport type TranslationRequest = string | TranslationKeyRequest | RawText;\n\n/**\n * Declares the translatable inputs of a component: `Req` are required, `Opt` optional.\n *\n * @example\n * type ButtonI18n = I18nOf<'label', 'caption'>;\n * const i18n: ButtonI18n = { label: 'common.save' };\n */\nexport type I18nOf<Req extends string, Opt extends string = never> = Record<Req, TranslationRequest> &\n Partial<Record<Opt, TranslationRequest>>;\n\n/**\n * Marks a text to display as is: it never reaches the app's `translate`.\n *\n * @example\n * raw('jordan.amar'); // { raw: 'jordan.amar' }\n */\nexport function raw(text: string): RawText {\n return { raw: text };\n}\n\n/**\n * Checks the shape only: an object with a string `raw`, whatever other keys it carries.\n *\n * @example\n * isRawText({ raw: 'x' }); // true\n * isRawText('a.b'); // false\n */\nexport function isRawText(value: unknown): value is RawText {\n return typeof value === 'object' && value !== null && 'raw' in value && typeof value.raw === 'string';\n}\n\n/**\n * Checks the shape only: an object with a string `key`; `params` is not validated.\n *\n * @example\n * isKeyRequest({ key: 'a.b' }); // true\n * isKeyRequest({ label: 'x' }); // false\n */\nexport function isKeyRequest(value: unknown): value is TranslationKeyRequest {\n return typeof value === 'object' && value !== null && 'key' in value && typeof value.key === 'string';\n}\n","import { computed, inject, InjectionToken, isDevMode, Provider, Signal } from '@angular/core';\nimport { fallbackText, UI_COMPONENTS_DEFAULT_TEXTS } from './default-texts';\nimport { DEFAULT_IS_KEY, warnIfNotKey } from './key-guard';\nimport { isKeyRequest, isRawText, TranslationRequest } from './translation.model';\n\n/**\n * How the DS translates the texts it renders, provided by the consuming app.\n *\n * @example\n * const config: UiComponentsTranslation = { translate: (key, params) => catalogue.instant(key, params), language: currentLanguage };\n */\nexport interface UiComponentsTranslation {\n /** Turns a key and its simple params into the text to render. */\n translate: (key: string, params?: Record<string, unknown>) => string;\n /** The app's current language, such as `fr`; texts are recomputed when it changes. */\n language?: Signal<string>;\n /** Used by the dev guard only, never for rendering; defaults to `DEFAULT_IS_KEY`. */\n isKey?: (text: string) => boolean;\n}\n\n/**\n * Holds the app's translation; absent when the app provides none.\n *\n * @example\n * const translation = inject(UI_COMPONENTS_TRANSLATION, { optional: true });\n */\nexport const UI_COMPONENTS_TRANSLATION = new InjectionToken<UiComponentsTranslation>('UI_COMPONENTS_TRANSLATION');\n\n/**\n * Plugs the app's translation into the DS components.\n *\n * @param config the translation, or a factory run in an injection context when it needs `inject()`.\n *\n * @example\n * provideUiComponentsTranslation(() => {\n * const translateService = inject(TranslateService);\n * return { translate: (key, params) => translateService.instant(key, params) };\n * });\n */\nexport function provideUiComponentsTranslation(config: UiComponentsTranslation | (() => UiComponentsTranslation)): Provider {\n return typeof config === 'function'\n ? { provide: UI_COMPONENTS_TRANSLATION, useFactory: config }\n : { provide: UI_COMPONENTS_TRANSLATION, useValue: config };\n}\n\n/**\n * Call in an injection context; the returned function renders a {@link TranslationRequest} and, read inside a\n * `computed`, follows language changes. Resolution rules: `design-specs/patterns/translation.md`.\n *\n * @example\n * const t = injectTranslate();\n * const title = computed(() => t(this.i18n().title, { count: this.count() }));\n */\nexport function injectTranslate(): (request: TranslationRequest | null | undefined, params?: Record<string, unknown>) => string {\n const translation = inject(UI_COMPONENTS_TRANSLATION, { optional: true });\n const defaultTexts = inject(UI_COMPONENTS_DEFAULT_TEXTS);\n const isKey = translation?.isKey ?? DEFAULT_IS_KEY;\n\n function resolve(request: unknown, dsParams?: Record<string, unknown>): string {\n translation?.language?.();\n\n if (request === null || request === undefined || request === '') return '';\n if (typeof request === 'string') {\n warnIfNotKey(request, isKey);\n return translateKey(request, dsParams);\n }\n if (isRawText(request)) return request.raw;\n if (isKeyRequest(request)) {\n if (request.key === '') return '';\n return translateKey(request.key, request.params || dsParams ? { ...request.params, ...definedEntries(dsParams) } : undefined);\n }\n\n if (isDevMode()) {\n console.warn(\n '[ui-components/i18n] Unsupported translation request, expected a key string, { key, params } or { raw }:',\n request\n );\n }\n return '';\n }\n\n function translateKey(key: string, params: Record<string, unknown> | undefined): string {\n const resolvedParams = resolveParams(params);\n if (!translation) return fallbackText(key, resolvedParams, defaultTexts) ?? key;\n\n const translated = translation.translate(key, resolvedParams);\n return translated === key ? (fallbackText(key, resolvedParams, defaultTexts) ?? translated) : translated;\n }\n\n function definedEntries(params: Record<string, unknown> | undefined): Record<string, unknown> {\n return Object.fromEntries(Object.entries(params ?? {}).filter(([, value]) => value !== undefined));\n }\n\n function resolveParams(params: Record<string, unknown> | undefined): Record<string, unknown> | undefined {\n if (!params) return undefined;\n return Object.fromEntries(\n Object.entries(params).map(([name, value]) => [name, isRawText(value) || isKeyRequest(value) ? resolve(value) : value])\n );\n }\n\n return resolve;\n}\n\n/**\n * The app's current language, `undefined` when the app gives none.\n *\n * @example\n * const language = injectLanguage();\n * const locale = computed(() => language() ?? 'en');\n */\nexport function injectLanguage(): Signal<string | undefined> {\n const translation = inject(UI_COMPONENTS_TRANSLATION, { optional: true });\n\n return computed(() => translation?.language?.());\n}\n","import { TranslationRequest } from './translation.model';\nimport { injectTranslate } from './translation.provider';\n\n/**\n * The text roles a component renders: per role, the DS default key, or `null` when the role has no default.\n *\n * @example\n * const ROLES = { title: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRoles;\n */\nexport type TextRoles = Readonly<Record<string, string | null>>;\n\n/**\n * Resolves every role of `roles` from `i18n` in one call: an absent role (`null` or `undefined`) takes its default key,\n * an explicit request wins even when it renders empty. A model `i18n` carrying more roles than `roles` lists is accepted.\n */\nexport type ResolveTexts = <R extends TextRoles>(\n i18n: Readonly<Partial<Record<keyof NoInfer<R> & string, TranslationRequest | null | undefined>>> | null | undefined,\n roles: R\n) => { [K in keyof R]: string };\n\n/**\n * Call in an injection context; built on {@link injectTranslate}, so read inside a `computed` the texts follow language changes.\n * Resolution rules: `design-specs/patterns/translation.md`.\n *\n * @example\n * const ROLES = { title: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRoles;\n * const resolveTexts = injectResolveTexts();\n * const texts = computed(() => resolveTexts(this.i18n(), ROLES));\n */\nexport function injectResolveTexts(): ResolveTexts {\n const t = injectTranslate();\n\n return <R extends TextRoles>(\n i18n: Readonly<Partial<Record<keyof R & string, TranslationRequest | null | undefined>>> | null | undefined,\n roles: R\n ) => {\n const requests: Readonly<Partial<Record<string, TranslationRequest | null | undefined>>> = i18n ?? {};\n // A mapped type over a generic R cannot be built key by key; the keys are exactly those of `roles`.\n return Object.fromEntries(Object.entries(roles).map(([role, defaultKey]) => [role, t(requests[role] ?? defaultKey)])) as {\n [K in keyof R]: string;\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAqC,MAAM,CAAC,MAAM,CAAC;AACzE,IAAA,+BAA+B,EAAE,SAAS;AAC1C,IAAA,kCAAkC,EAAE,SAAS;AAC7C,IAAA,6BAA6B,EAAE,eAAe;AAC9C,IAAA,6BAA6B,EAAE,eAAe;AAC9C,IAAA,6BAA6B,EAAE,eAAe;AAC9C,IAAA,mCAAmC,EAAE,aAAa;AAClD,IAAA,wCAAwC,EAAE,kBAAkB;AAC5D,IAAA,0CAA0C,EAAE,oBAAoB;AAChE,IAAA,8CAA8C,EAAE,wBAAwB;AACxE,IAAA,8CAA8C,EAAE,mBAAmB;AACnE,IAAA,kCAAkC,EAAE,QAAQ;AAC5C,IAAA,2BAA2B,EAAE,MAAM;AACnC,IAAA,kCAAkC,EAAE,kBAAkB;AACzD,CAAA,CAAC;A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AI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAEnH;AACL,IAAA,CAAC;AACL;;AC1CA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"agorapulse-ui-components-i18n.mjs","sources":["../../../libs/ui-components/i18n/src/default-texts.ts","../../../libs/ui-components/i18n/src/key-guard.ts","../../../libs/ui-components/i18n/src/raw.pipe.ts","../../../libs/ui-components/i18n/src/translation.model.ts","../../../libs/ui-components/i18n/src/translation.provider.ts","../../../libs/ui-components/i18n/src/resolve-texts.ts","../../../libs/ui-components/i18n/src/agorapulse-ui-components-i18n.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const DEFAULT_TEXTS = Object.freeze({\n 'ui-components.filters.trigger': 'Filters',\n 'ui-components.filters.aria-label': 'Filters',\n 'ui-components.filters.apply': 'Apply filters',\n 'ui-components.filters.clear': 'Clear filters',\n 'ui-components.filters.reset': 'Reset filters',\n 'ui-components.filters.save-preset': 'Save preset',\n 'ui-components.filters.save-new-presets': 'Save new presets',\n 'ui-components.filters.save-as-new-preset': 'Save as new preset',\n 'ui-components.filters.update-existing-preset': 'Update existing preset',\n 'ui-components.filters.date-range-placeholder': 'Select date range',\n 'ui-components.search.placeholder': 'Search',\n 'ui-components.select.only': 'Only',\n 'ui-components.select.placeholder': 'Select an option',\n} as const);\n\n/**\n * A key of the DS default texts, the only keys a component may fall back to.\n *\n * @example\n * const key: DefaultTextKey = 'ui-components.search.placeholder';\n */\nexport type DefaultTextKey = keyof typeof DEFAULT_TEXTS;\n\n/**\n * Holds the fallback table read by `injectTranslate`; provide another table to override it, for instance in a test.\n *\n * @example\n * TestBed.configureTestingModule({ providers: [{ provide: UI_COMPONENTS_DEFAULT_TEXTS, useValue: { 'ui-components.ok': 'OK' } }] });\n */\nexport const UI_COMPONENTS_DEFAULT_TEXTS = new InjectionToken<Readonly<Record<string, string>>>('UI_COMPONENTS_DEFAULT_TEXTS', {\n providedIn: 'root',\n factory: () => DEFAULT_TEXTS,\n});\n\nexport function fallbackText(\n key: string,\n params?: Record<string, unknown>,\n table: Readonly<Record<string, string>> = DEFAULT_TEXTS\n): string | undefined {\n if (!Object.prototype.hasOwnProperty.call(table, key)) return undefined;\n\n return table[key].replace(/\\{\\{\\s*([^{}\\s]+)\\s*\\}\\}/g, (placeholder, name: string) =>\n params?.[name] !== undefined && params[name] !== null && Object.prototype.hasOwnProperty.call(params, name)\n ? String(params[name])\n : placeholder\n );\n}\n","import { isDevMode } from '@angular/core';\n\n/**\n * The default `isKey`: dotted segments, so dotted data such as `example.com` passes too.\n *\n * @example\n * DEFAULT_IS_KEY('report.filter.apply'); // true\n * DEFAULT_IS_KEY('Black Friday 2026'); // false\n */\nexport const DEFAULT_IS_KEY = (text: string): boolean => /^[\\w-]+(\\.[\\w-]+)+$/.test(text);\n\nconst warnedValues = new Set<string>();\n\nexport function warnIfNotKey(text: string, isKey: (text: string) => boolean, devMode: boolean = isDevMode()): void {\n if (!devMode || isKey(text) || warnedValues.has(text)) return;\n\n warnedValues.add(text);\n console.warn(`[ui-components/i18n] \"${text}\" is not a translation key. Wrap displayed data with raw() (or | apRaw).`);\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { RawText } from './translation.model';\n\n/**\n * Turns a text into a {@link RawText} so a component displays it as is. `null` and `undefined` give an empty text.\n *\n * @example\n * <ap-button [i18n]=\"{ label: user.name | apRaw }\" />\n */\n@Pipe({ name: 'apRaw' })\nexport class RawPipe implements PipeTransform {\n transform(text: string | null | undefined): RawText {\n return { raw: text ?? '' };\n }\n}\n","/**\n * A translation key with optional interpolation parameters.\n *\n * @example\n * const request: TranslationKeyRequest = { key: 'inbox.unread', params: { count: 3 } };\n */\nexport type TranslationKeyRequest = { key: string; params?: Record<string, unknown> };\n\n/**\n * A text displayed as is, never looked up in a catalogue (user content, names, handles).\n *\n * @example\n * const text: RawText = { raw: 'jordan.amar' };\n */\nexport type RawText = { raw: string };\n\n/**\n * What a component accepts for a displayed text: a string is a translation key,\n * `{ key, params }` a key with parameters, `{ raw }` a text displayed as is.\n *\n * @example\n * const label: TranslationRequest = 'common.save';\n */\nexport type TranslationRequest = string | TranslationKeyRequest | RawText;\n\n/**\n * Declares the translatable inputs of a component: `Req` are required, `Opt` optional.\n *\n * @example\n * type ButtonI18n = I18nOf<'label', 'caption'>;\n * const i18n: ButtonI18n = { label: 'common.save' };\n */\nexport type I18nOf<Req extends string, Opt extends string = never> = Record<Req, TranslationRequest> &\n Partial<Record<Opt, TranslationRequest>>;\n\n/**\n * Marks a text to display as is: it never reaches the app's `translate`.\n *\n * @example\n * raw('jordan.amar'); // { raw: 'jordan.amar' }\n */\nexport function raw(text: string): RawText {\n return { raw: text };\n}\n\n/**\n * Checks the shape only: an object with a string `raw`, whatever other keys it carries.\n *\n * @example\n * isRawText({ raw: 'x' }); // true\n * isRawText('a.b'); // false\n */\nexport function isRawText(value: unknown): value is RawText {\n return typeof value === 'object' && value !== null && 'raw' in value && typeof value.raw === 'string';\n}\n\n/**\n * Checks the shape only: an object with a string `key`; `params` is not validated.\n *\n * @example\n * isKeyRequest({ key: 'a.b' }); // true\n * isKeyRequest({ label: 'x' }); // false\n */\nexport function isKeyRequest(value: unknown): value is TranslationKeyRequest {\n return typeof value === 'object' && value !== null && 'key' in value && typeof value.key === 'string';\n}\n","import { computed, inject, InjectionToken, isDevMode, Provider, Signal } from '@angular/core';\nimport { fallbackText, UI_COMPONENTS_DEFAULT_TEXTS } from './default-texts';\nimport { DEFAULT_IS_KEY, warnIfNotKey } from './key-guard';\nimport { isKeyRequest, isRawText, TranslationRequest } from './translation.model';\n\n/**\n * How the DS translates the texts it renders, provided by the consuming app.\n *\n * @example\n * const config: UiComponentsTranslation = { translate: (key, params) => catalogue.instant(key, params), language: currentLanguage };\n */\nexport interface UiComponentsTranslation {\n /** Turns a key and its simple params into the text to render. */\n translate: (key: string, params?: Record<string, unknown>) => string;\n /** The app's current language, such as `fr`; texts are recomputed when it changes. */\n language?: Signal<string>;\n /** Used by the dev guard only, never for rendering; defaults to `DEFAULT_IS_KEY`. */\n isKey?: (text: string) => boolean;\n}\n\n/**\n * Holds the app's translation; absent when the app provides none.\n *\n * @example\n * const translation = inject(UI_COMPONENTS_TRANSLATION, { optional: true });\n */\nexport const UI_COMPONENTS_TRANSLATION = new InjectionToken<UiComponentsTranslation>('UI_COMPONENTS_TRANSLATION');\n\n/**\n * Plugs the app's translation into the DS components.\n *\n * @param config the translation, or a factory run in an injection context when it needs `inject()`.\n *\n * @example\n * provideUiComponentsTranslation(() => {\n * const translateService = inject(TranslateService);\n * return { translate: (key, params) => translateService.instant(key, params) };\n * });\n */\nexport function provideUiComponentsTranslation(config: UiComponentsTranslation | (() => UiComponentsTranslation)): Provider {\n return typeof config === 'function'\n ? { provide: UI_COMPONENTS_TRANSLATION, useFactory: config }\n : { provide: UI_COMPONENTS_TRANSLATION, useValue: config };\n}\n\n/**\n * Call in an injection context; the returned function renders a {@link TranslationRequest} and, read inside a\n * `computed`, follows language changes. Resolution rules: `design-specs/patterns/translation.md`.\n *\n * @example\n * const t = injectTranslate();\n * const title = computed(() => t(this.i18n().title, { count: this.count() }));\n */\nexport function injectTranslate(): (request: TranslationRequest | null | undefined, params?: Record<string, unknown>) => string {\n const translation = inject(UI_COMPONENTS_TRANSLATION, { optional: true });\n const defaultTexts = inject(UI_COMPONENTS_DEFAULT_TEXTS);\n const isKey = translation?.isKey ?? DEFAULT_IS_KEY;\n\n function resolve(request: unknown, dsParams?: Record<string, unknown>): string {\n translation?.language?.();\n\n if (request === null || request === undefined || request === '') return '';\n if (typeof request === 'string') {\n warnIfNotKey(request, isKey);\n return translateKey(request, dsParams);\n }\n if (isRawText(request)) return request.raw;\n if (isKeyRequest(request)) {\n if (request.key === '') return '';\n return translateKey(request.key, request.params || dsParams ? { ...request.params, ...definedEntries(dsParams) } : undefined);\n }\n\n if (isDevMode()) {\n console.warn(\n '[ui-components/i18n] Unsupported translation request, expected a key string, { key, params } or { raw }:',\n request\n );\n }\n return '';\n }\n\n function translateKey(key: string, params: Record<string, unknown> | undefined): string {\n const resolvedParams = resolveParams(params);\n if (!translation) return fallbackText(key, resolvedParams, defaultTexts) ?? key;\n\n const translated = translation.translate(key, resolvedParams);\n return translated === key ? (fallbackText(key, resolvedParams, defaultTexts) ?? translated) : translated;\n }\n\n function definedEntries(params: Record<string, unknown> | undefined): Record<string, unknown> {\n return Object.fromEntries(Object.entries(params ?? {}).filter(([, value]) => value !== undefined));\n }\n\n function resolveParams(params: Record<string, unknown> | undefined): Record<string, unknown> | undefined {\n if (!params) return undefined;\n return Object.fromEntries(\n Object.entries(params).map(([name, value]) => [name, isRawText(value) || isKeyRequest(value) ? resolve(value) : value])\n );\n }\n\n return resolve;\n}\n\n/**\n * The app's current language, `undefined` when the app gives none.\n *\n * @example\n * const language = injectLanguage();\n * const locale = computed(() => language() ?? 'en');\n */\nexport function injectLanguage(): Signal<string | undefined> {\n const translation = inject(UI_COMPONENTS_TRANSLATION, { optional: true });\n\n return computed(() => translation?.language?.());\n}\n","import { DefaultTextKey } from './default-texts';\nimport { TranslationRequest } from './translation.model';\nimport { injectTranslate } from './translation.provider';\n\n/**\n * The text roles a component renders: per role, the DS default key, or `null` when the role has no default.\n *\n * @example\n * const ROLES = { title: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRoles;\n */\nexport type TextRoles = Readonly<Record<string, DefaultTextKey | null>>;\n\n/**\n * The text roles a component renders from a model `i18n` type: any subset of its keys, each with a DS default key or `null`.\n * Checked with `satisfies`, a role the model does not declare fails compilation.\n *\n * @example\n * const ROLES = { caption: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRolesOf<Group['i18n']>;\n */\nexport type TextRolesOf<I18n> = Readonly<Partial<Record<keyof I18n & string, DefaultTextKey | null>>>;\n\n/**\n * Resolves every role of `roles` from `i18n` in one call: an absent role (`null` or `undefined`) takes its default key,\n * or stays `undefined` without one; an explicit request wins even when it renders empty.\n * A model `i18n` carrying more roles than `roles` lists is accepted.\n */\nexport type ResolveTexts = <R extends TextRoles>(\n i18n: Readonly<Partial<Record<keyof NoInfer<R> & string, TranslationRequest | null | undefined>>> | null | undefined,\n roles: R\n) => ResolvedTexts<R>;\n\ntype ResolvedTexts<R extends TextRoles> = { [K in keyof R]: R[K] extends string ? string : string | undefined };\n\n/**\n * Call in an injection context; built on {@link injectTranslate}, so read inside a `computed` the texts follow language changes.\n * Resolution rules: `design-specs/patterns/translation.md`.\n *\n * @example\n * const ROLES = { title: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRolesOf<Group['i18n']>;\n * const resolveTexts = injectResolveTexts();\n * const texts = computed(() => resolveTexts(this.i18n(), ROLES));\n */\nexport function injectResolveTexts(): ResolveTexts {\n const t = injectTranslate();\n\n return <R extends TextRoles>(\n i18n: Readonly<Partial<Record<keyof R & string, TranslationRequest | null | undefined>>> | null | undefined,\n roles: R\n ) => {\n const requests: Readonly<Partial<Record<string, TranslationRequest | null | undefined>>> = i18n ?? {};\n // A mapped type over a generic R cannot be built key by key; the keys are exactly those of `roles`.\n return Object.fromEntries(\n Object.entries(roles).map(([role, defaultKey]) => {\n const request = requests[role] ?? defaultKey;\n return [role, request === null ? undefined : t(request)];\n })\n ) as ResolvedTexts<R>;\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;AACvC,IAAA,+BAA+B,EAAE,SAAS;AAC1C,IAAA,kCAAkC,EAAE,SAAS;AAC7C,IAAA,6BAA6B,EAAE,eAAe;AAC9C,IAAA,6BAA6B,EAAE,eAAe;AAC9C,IAAA,6BAA6B,EAAE,eAAe;AAC9C,IAAA,mCAAmC,EAAE,aAAa;AAClD,IAAA,wCAAwC,EAAE,kBAAkB;AAC5D,IAAA,0CAA0C,EAAE,oBAAoB;AAChE,IAAA,8CAA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,KAAQ,KACR;AACA,QAAA,MAAM,QAAQ,GAA6E,IAAI,IAAI,EAAE;;QAErG,OAAO,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,KAAI;YAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,UAAU;AAC5C,YAAA,OAAO,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5D,CAAC,CAAC,CACe;AACzB,IAAA,CAAC;AACL;;AC1DA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -283,13 +283,13 @@ declare class FilterDropdownComponent implements DropdownOverlay {
|
|
|
283
283
|
/** An optional infobox shown at the bottom of the popup content, above the footer (e.g. a link). */
|
|
284
284
|
infobox: _angular_core.InputSignal<FilterDropdownInfobox | null>;
|
|
285
285
|
protected readonly infoboxView: _angular_core.Signal<{
|
|
286
|
-
type: _agorapulse_ui_components_infobox.InfoboxType;
|
|
287
|
-
title: string | undefined;
|
|
288
|
-
message: string;
|
|
289
286
|
link: {
|
|
290
287
|
href: string | undefined;
|
|
291
|
-
label: string;
|
|
288
|
+
label: string | undefined;
|
|
292
289
|
} | undefined;
|
|
290
|
+
title: string | undefined;
|
|
291
|
+
message: string | undefined;
|
|
292
|
+
type: _agorapulse_ui_components_infobox.InfoboxType;
|
|
293
293
|
} | null>;
|
|
294
294
|
/**
|
|
295
295
|
* The filter groups to display: STRUCTURE only (keys, titles, options, locks, display type, and the
|
|
@@ -411,7 +411,9 @@ declare class FilterDropdownButtonComponent {
|
|
|
411
411
|
* {@link FilterDropdownActionKey} goes as is to the dropdown, which applies its own defaults.
|
|
412
412
|
*/
|
|
413
413
|
readonly i18n: _angular_core.InputSignal<I18nOf<never, "trigger" | FilterDropdownActionKey>>;
|
|
414
|
-
protected readonly
|
|
414
|
+
protected readonly texts: _angular_core.Signal<{
|
|
415
|
+
readonly trigger: string;
|
|
416
|
+
}>;
|
|
415
417
|
protected readonly dropdownI18n: _angular_core.Signal<{
|
|
416
418
|
trigger?: _agorapulse_ui_components_i18n.TranslationRequest | undefined;
|
|
417
419
|
applyFilters?: _agorapulse_ui_components_i18n.TranslationRequest | undefined;
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, PipeTransform, Signal, Provider } from '@angular/core';
|
|
3
3
|
|
|
4
|
+
declare const DEFAULT_TEXTS: Readonly<{
|
|
5
|
+
readonly 'ui-components.filters.trigger': "Filters";
|
|
6
|
+
readonly 'ui-components.filters.aria-label': "Filters";
|
|
7
|
+
readonly 'ui-components.filters.apply': "Apply filters";
|
|
8
|
+
readonly 'ui-components.filters.clear': "Clear filters";
|
|
9
|
+
readonly 'ui-components.filters.reset': "Reset filters";
|
|
10
|
+
readonly 'ui-components.filters.save-preset': "Save preset";
|
|
11
|
+
readonly 'ui-components.filters.save-new-presets': "Save new presets";
|
|
12
|
+
readonly 'ui-components.filters.save-as-new-preset': "Save as new preset";
|
|
13
|
+
readonly 'ui-components.filters.update-existing-preset': "Update existing preset";
|
|
14
|
+
readonly 'ui-components.filters.date-range-placeholder': "Select date range";
|
|
15
|
+
readonly 'ui-components.search.placeholder': "Search";
|
|
16
|
+
readonly 'ui-components.select.only': "Only";
|
|
17
|
+
readonly 'ui-components.select.placeholder': "Select an option";
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* A key of the DS default texts, the only keys a component may fall back to.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const key: DefaultTextKey = 'ui-components.search.placeholder';
|
|
24
|
+
*/
|
|
25
|
+
type DefaultTextKey = keyof typeof DEFAULT_TEXTS;
|
|
4
26
|
/**
|
|
5
27
|
* Holds the fallback table read by `injectTranslate`; provide another table to override it, for instance in a test.
|
|
6
28
|
*
|
|
@@ -95,20 +117,30 @@ declare class RawPipe implements PipeTransform {
|
|
|
95
117
|
* @example
|
|
96
118
|
* const ROLES = { title: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRoles;
|
|
97
119
|
*/
|
|
98
|
-
type TextRoles = Readonly<Record<string,
|
|
120
|
+
type TextRoles = Readonly<Record<string, DefaultTextKey | null>>;
|
|
121
|
+
/**
|
|
122
|
+
* The text roles a component renders from a model `i18n` type: any subset of its keys, each with a DS default key or `null`.
|
|
123
|
+
* Checked with `satisfies`, a role the model does not declare fails compilation.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* const ROLES = { caption: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRolesOf<Group['i18n']>;
|
|
127
|
+
*/
|
|
128
|
+
type TextRolesOf<I18n> = Readonly<Partial<Record<keyof I18n & string, DefaultTextKey | null>>>;
|
|
99
129
|
/**
|
|
100
130
|
* Resolves every role of `roles` from `i18n` in one call: an absent role (`null` or `undefined`) takes its default key,
|
|
101
|
-
* an explicit request wins even when it renders empty.
|
|
131
|
+
* or stays `undefined` without one; an explicit request wins even when it renders empty.
|
|
132
|
+
* A model `i18n` carrying more roles than `roles` lists is accepted.
|
|
102
133
|
*/
|
|
103
|
-
type ResolveTexts = <R extends TextRoles>(i18n: Readonly<Partial<Record<keyof NoInfer<R> & string, TranslationRequest | null | undefined>>> | null | undefined, roles: R) =>
|
|
104
|
-
|
|
134
|
+
type ResolveTexts = <R extends TextRoles>(i18n: Readonly<Partial<Record<keyof NoInfer<R> & string, TranslationRequest | null | undefined>>> | null | undefined, roles: R) => ResolvedTexts<R>;
|
|
135
|
+
type ResolvedTexts<R extends TextRoles> = {
|
|
136
|
+
[K in keyof R]: R[K] extends string ? string : string | undefined;
|
|
105
137
|
};
|
|
106
138
|
/**
|
|
107
139
|
* Call in an injection context; built on {@link injectTranslate}, so read inside a `computed` the texts follow language changes.
|
|
108
140
|
* Resolution rules: `design-specs/patterns/translation.md`.
|
|
109
141
|
*
|
|
110
142
|
* @example
|
|
111
|
-
* const ROLES = { title: null, placeholder: 'ui-components.select.placeholder' } as const satisfies
|
|
143
|
+
* const ROLES = { title: null, placeholder: 'ui-components.select.placeholder' } as const satisfies TextRolesOf<Group['i18n']>;
|
|
112
144
|
* const resolveTexts = injectResolveTexts();
|
|
113
145
|
* const texts = computed(() => resolveTexts(this.i18n(), ROLES));
|
|
114
146
|
*/
|
|
@@ -166,4 +198,4 @@ declare function injectTranslate(): (request: TranslationRequest | null | undefi
|
|
|
166
198
|
declare function injectLanguage(): Signal<string | undefined>;
|
|
167
199
|
|
|
168
200
|
export { DEFAULT_IS_KEY, RawPipe, UI_COMPONENTS_DEFAULT_TEXTS, UI_COMPONENTS_TRANSLATION, injectLanguage, injectResolveTexts, injectTranslate, isKeyRequest, isRawText, provideUiComponentsTranslation, raw };
|
|
169
|
-
export type { I18nOf, RawText, TextRoles, TranslationKeyRequest, TranslationRequest, UiComponentsTranslation };
|
|
201
|
+
export type { DefaultTextKey, I18nOf, RawText, ResolveTexts, TextRoles, TextRolesOf, TranslationKeyRequest, TranslationRequest, UiComponentsTranslation };
|
|
Binary file
|