@trismegisto/angular 2.1.2 → 3.0.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.
Files changed (33) hide show
  1. package/fesm2022/trismegisto-angular-data-grid.mjs +32 -18
  2. package/fesm2022/trismegisto-angular-data-grid.mjs.map +1 -1
  3. package/fesm2022/trismegisto-angular-i18n.mjs +22 -2
  4. package/fesm2022/trismegisto-angular-i18n.mjs.map +1 -1
  5. package/fesm2022/trismegisto-angular-list-editor.mjs +320 -0
  6. package/fesm2022/trismegisto-angular-list-editor.mjs.map +1 -0
  7. package/fesm2022/trismegisto-angular-motion.mjs +58 -4
  8. package/fesm2022/trismegisto-angular-motion.mjs.map +1 -1
  9. package/fesm2022/trismegisto-angular-reorder-list.mjs +5 -3
  10. package/fesm2022/trismegisto-angular-reorder-list.mjs.map +1 -1
  11. package/fesm2022/trismegisto-angular-settings.mjs +11 -2
  12. package/fesm2022/trismegisto-angular-settings.mjs.map +1 -1
  13. package/fesm2022/trismegisto-angular-zoom.mjs +16 -1
  14. package/fesm2022/trismegisto-angular-zoom.mjs.map +1 -1
  15. package/fesm2022/trismegisto-angular.mjs +3 -2
  16. package/fesm2022/trismegisto-angular.mjs.map +1 -1
  17. package/package.json +9 -5
  18. package/types/trismegisto-angular-data-grid.d.ts +18 -9
  19. package/types/trismegisto-angular-data-grid.d.ts.map +1 -1
  20. package/types/trismegisto-angular-i18n.d.ts +20 -1
  21. package/types/trismegisto-angular-i18n.d.ts.map +1 -1
  22. package/types/trismegisto-angular-list-editor.d.ts +167 -0
  23. package/types/trismegisto-angular-list-editor.d.ts.map +1 -0
  24. package/types/trismegisto-angular-motion.d.ts +32 -1
  25. package/types/trismegisto-angular-motion.d.ts.map +1 -1
  26. package/types/trismegisto-angular-reorder-list.d.ts +3 -1
  27. package/types/trismegisto-angular-reorder-list.d.ts.map +1 -1
  28. package/types/trismegisto-angular-settings.d.ts +4 -1
  29. package/types/trismegisto-angular-settings.d.ts.map +1 -1
  30. package/types/trismegisto-angular-zoom.d.ts +9 -0
  31. package/types/trismegisto-angular-zoom.d.ts.map +1 -1
  32. package/types/trismegisto-angular.d.ts +3 -2
  33. package/types/trismegisto-angular.d.ts.map +1 -1
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, signal, inject, computed, DOCUMENT, effect, Injectable } from '@angular/core';
3
- import { HERMES_MESSAGES_PT_BR, mergeMessages, formatMessage, pluralMessage } from '@trismegisto/primitives';
3
+ import { HERMES_MESSAGES_PT_BR, mergeMessages, localeWithRegionalFormat, formatMessage, pluralMessage } from '@trismegisto/primitives';
4
4
 
5
5
  const HERMES_I18N_CONFIG = new InjectionToken('HERMES_I18N_CONFIG', {
6
6
  providedIn: 'root',
@@ -73,19 +73,28 @@ class HermesI18nService {
73
73
  overrides = signal(this.config.override ?? {}, ...(ngDevMode ? [{ debugName: "overrides" }] : /* istanbul ignore next */ []));
74
74
  /** Idioma ativo. */
75
75
  locale = signal(this.config.locale ?? this.config.base?.meta.locale ?? 'pt-BR', ...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
76
+ /** Relógio e primeiro dia da semana escolhidos (vazio = os do idioma). Ver `setRegionalFormat`. */
77
+ regionalFormat = signal(this.config.regionalFormat ?? {}, ...(ngDevMode ? [{ debugName: "regionalFormat" }] : /* istanbul ignore next */ []));
76
78
  /**
77
79
  * Catálogo ativo, já com as sobrescritas. Quando o idioma pedido é uma variante regional da língua do
78
80
  * catálogo (`en-GB` servido pelo catálogo `en`), `meta.locale` passa a ser o pedido: todo formato via
79
81
  * `Intl` (data digitada, início da semana, números, plural) segue a região — dd/mm e segunda-feira no
80
82
  * Reino Unido. Se o pedido caiu num catálogo de outra língua, fica o do catálogo, para formato e texto
81
83
  * não se contradizerem.
84
+ *
85
+ * O formato regional escolhido (`setRegionalFormat`) entra no mesmo `meta.locale` como extensão Unicode
86
+ * (`pt-BR-u-hc-h12`): data e hora (pipes, `hm-time-picker`, `hm-event-calendar`) e início da semana
87
+ * (`hm-date-picker`, `hm-event-calendar`) seguem a escolha sem input novo em componente nenhum.
82
88
  */
83
89
  messages = computed(() => {
84
90
  const requested = this.locale();
85
91
  const merged = mergeMessages(this.overrides(), this.resolve(requested));
86
92
  const sameLanguage = requested.split('-')[0].toLowerCase() === merged.meta.locale.split('-')[0].toLowerCase();
87
- return sameLanguage && requested !== merged.meta.locale ? { ...merged, meta: { ...merged.meta, locale: requested } } : merged;
93
+ const locale = localeWithRegionalFormat(sameLanguage ? requested : merged.meta.locale, this.regionalFormat());
94
+ return locale !== merged.meta.locale ? { ...merged, meta: { ...merged.meta, locale } } : merged;
88
95
  }, ...(ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []));
96
+ /** Locale de formatação (`Intl`): o idioma ativo com o formato regional escolhido — o mesmo `meta.locale`. */
97
+ formatLocale = computed(() => this.messages().meta.locale, ...(ngDevMode ? [{ debugName: "formatLocale" }] : /* istanbul ignore next */ []));
89
98
  constructor() {
90
99
  // Idioma inicial com catálogo sob demanda: baixa já; até chegar, vale o `base`/pt-BR.
91
100
  this.ensure(this.locale()).catch(() => undefined);
@@ -120,6 +129,17 @@ class HermesI18nService {
120
129
  this.locale.set(locale);
121
130
  });
122
131
  }
132
+ /**
133
+ * Relógio de 12/24 horas e primeiro dia da semana por cima do padrão do idioma — preferência da pessoa
134
+ * (Configurações › Região, no spine). `null`/ausente volta ao do idioma. Vale na hora, sem recarregar.
135
+ *
136
+ * ```ts
137
+ * i18n.setRegionalFormat({ hourCycle: 'h23', firstDayOfWeek: 1 }); // 24 h, semana na segunda
138
+ * ```
139
+ */
140
+ setRegionalFormat(format) {
141
+ this.regionalFormat.set({ hourCycle: format.hourCycle ?? null, firstDayOfWeek: format.firstDayOfWeek ?? null });
142
+ }
123
143
  registerCatalog(locale, catalog) {
124
144
  this.own.update((all) => ({ ...all, [locale]: catalog }));
125
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"trismegisto-angular-i18n.mjs","sources":["../../src/i18n/i18n.ts","../../src/i18n/index.ts","../../src/i18n/trismegisto-angular-i18n.ts"],"sourcesContent":["import { DOCUMENT, Injectable, InjectionToken, Provider, computed, effect, inject, signal } from '@angular/core';\nimport {\n HERMES_MESSAGES_PT_BR,\n HermesMessages,\n HermesMessagesOverride,\n MessageParams,\n PluralMessage,\n formatMessage,\n mergeMessages,\n pluralMessage,\n} from '@trismegisto/primitives';\n\nexport interface HermesI18nConfig {\n /** Idioma inicial (BCP 47). Padrão: o do catálogo `base`, senão `pt-BR`. */\n readonly locale?: string;\n /** Catálogo usado quando o idioma pedido não tem um registrado. */\n readonly base?: HermesMessages;\n /**\n * Catálogos extras ou substitutos, por idioma: o catálogo em si (vai embutido no bundle) ou um\n * carregador `() => import(...)` (vira um chunk à parte, baixado no primeiro `setLocale` daquele idioma).\n * en e es já vêm com carregador (`HERMES_CATALOG_LOADERS`); para embuti-los, passe o catálogo:\n * `catalogs: { en: HERMES_MESSAGES_EN }` com `import { HERMES_MESSAGES_EN } from '@trismegisto/primitives/messages/en'`.\n */\n readonly catalogs?: Readonly<Record<string, HermesMessages | HermesCatalogLoader>>;\n /** Textos avulsos sobrescritos por cima do catálogo ativo (vale para todos os idiomas). */\n readonly override?: HermesMessagesOverride;\n}\n\nexport const HERMES_I18N_CONFIG = new InjectionToken<HermesI18nConfig>('HERMES_I18N_CONFIG', {\n providedIn: 'root',\n factory: () => ({}),\n});\n\n/** Carrega um catálogo sob demanda (o `import()` vira um chunk à parte no bundle do app). */\nexport type HermesCatalogLoader = () => Promise<HermesMessages>;\n\n/**\n * Carregadores dos catálogos que acompanham a lib, fora o pt-BR (o único embutido): só o idioma que a\n * pessoa escolher é baixado, e só quando escolher. Mantém leve o bundle de quem usa um idioma só.\n */\nexport const HERMES_CATALOG_LOADERS: Readonly<Record<string, HermesCatalogLoader>> = {\n en: () => import('@trismegisto/primitives/messages/en').then((m) => m.HERMES_MESSAGES_EN),\n es: () => import('@trismegisto/primitives/messages/es').then((m) => m.HERMES_MESSAGES_ES),\n};\n\n/**\n * Catálogos já baixados, compartilhados por todas as instâncias do serviço (um idioma é baixado uma vez\n * por página). Signal: um catálogo que chega depois re-renderiza quem lê o texto.\n */\nconst loadedCatalogs = signal<Readonly<Record<string, HermesMessages>>>({ 'pt-BR': HERMES_MESSAGES_PT_BR });\nconst pendingLoads = new Map<string, Promise<HermesMessages>>();\n\n/** Baixa (uma vez) e guarda o catálogo de `locale` com o carregador dado. */\nfunction loadCatalog(locale: string, loader: HermesCatalogLoader): Promise<HermesMessages> {\n const done = loadedCatalogs()[locale];\n if (done) return Promise.resolve(done);\n let pending = pendingLoads.get(locale);\n if (!pending) {\n pending = loader().then(\n (catalog) => {\n loadedCatalogs.update((all) => ({ ...all, [locale]: catalog }));\n pendingLoads.delete(locale);\n return catalog;\n },\n (error: unknown) => {\n pendingLoads.delete(locale);\n throw error;\n },\n );\n pendingLoads.set(locale, pending);\n }\n return pending;\n}\n\n/**\n * Baixa antes um catálogo da lib (`'en'`, `'es'`) — ex.: num `provideAppInitializer`, para o primeiro\n * `setLocale` daquele idioma ser síncrono. Idioma sem carregador conhecido: resolve `undefined`.\n */\nexport function preloadHermesCatalog(locale: string): Promise<HermesMessages | undefined> {\n const key = locale in HERMES_CATALOG_LOADERS ? locale : locale.split('-')[0];\n const loader = HERMES_CATALOG_LOADERS[key];\n return loader ? loadCatalog(key, loader) : Promise.resolve(undefined);\n}\n\n/**\n * Idioma e textos dos componentes Hermes, reativos: `setLocale('en')` troca todo texto que a lib exibe\n * ou anuncia — sem recarregar a página. Só o pt-BR vem embutido; en e es são baixados sob demanda no\n * primeiro `setLocale` daquele idioma (texto e formato trocam juntos quando o catálogo chega). Outros\n * idiomas entram por `registerCatalog` ou `catalogs` em `provideHermesI18n` (catálogo ou carregador).\n *\n * Os componentes leem por `HERMES_MESSAGES` (uma vista viva deste serviço); o app normalmente só chama\n * `setLocale` quando a pessoa troca de idioma.\n */\n@Injectable({ providedIn: 'root' })\nexport class HermesI18nService {\n private readonly config = inject(HERMES_I18N_CONFIG);\n private readonly own = signal<Readonly<Record<string, HermesMessages>>>({\n ...(this.config.base ? { [this.config.base.meta.locale]: this.config.base } : {}),\n ...(Object.fromEntries(\n Object.entries(this.config.catalogs ?? {}).filter(([, c]) => typeof c !== 'function'),\n ) as Record<string, HermesMessages>),\n });\n private readonly loaders: Readonly<Record<string, HermesCatalogLoader>> = {\n ...HERMES_CATALOG_LOADERS,\n ...(Object.fromEntries(\n Object.entries(this.config.catalogs ?? {}).filter(([, c]) => typeof c === 'function'),\n ) as Record<string, HermesCatalogLoader>),\n };\n /** Os da lib já baixados + os deste app (os do app vencem). */\n private readonly catalogs = computed(() => ({ ...loadedCatalogs(), ...this.own() }));\n private requested = 0;\n private readonly overrides = signal<HermesMessagesOverride>(this.config.override ?? {});\n\n /** Idioma ativo. */\n readonly locale = signal(this.config.locale ?? this.config.base?.meta.locale ?? 'pt-BR');\n\n /**\n * Catálogo ativo, já com as sobrescritas. Quando o idioma pedido é uma variante regional da língua do\n * catálogo (`en-GB` servido pelo catálogo `en`), `meta.locale` passa a ser o pedido: todo formato via\n * `Intl` (data digitada, início da semana, números, plural) segue a região — dd/mm e segunda-feira no\n * Reino Unido. Se o pedido caiu num catálogo de outra língua, fica o do catálogo, para formato e texto\n * não se contradizerem.\n */\n readonly messages = computed<HermesMessages>(() => {\n const requested = this.locale();\n const merged = mergeMessages(this.overrides(), this.resolve(requested));\n const sameLanguage = requested.split('-')[0].toLowerCase() === merged.meta.locale.split('-')[0].toLowerCase();\n return sameLanguage && requested !== merged.meta.locale ? { ...merged, meta: { ...merged.meta, locale: requested } } : merged;\n });\n\n constructor() {\n // Idioma inicial com catálogo sob demanda: baixa já; até chegar, vale o `base`/pt-BR.\n this.ensure(this.locale()).catch(() => undefined);\n // `<html lang>` acompanha o idioma (WCAG 3.1.1): leitor de tela pronuncia certo, hifenização e\n // tradução automática do navegador acertam o idioma. Só quando o idioma muda — o valor inicial\n // é o que o app já pôs no index.html.\n const document = inject(DOCUMENT, { optional: true });\n const initial = this.locale();\n effect(() => {\n const locale = this.locale();\n if (document?.documentElement && locale !== initial) document.documentElement.lang = locale;\n });\n }\n\n /**\n * Troca o idioma. Com o catálogo à mão (pt-BR, embutido, já baixado), troca na hora; se ele ainda\n * precisa ser baixado, o idioma só muda quando chegar (sem piscar pt-BR no meio) — a Promise resolve\n * nesse momento. Chamadas seguidas: vale a última.\n */\n setLocale(locale: string): Promise<void> {\n const ticket = ++this.requested;\n if (this.available(locale)) {\n this.locale.set(locale);\n return Promise.resolve();\n }\n return this.ensure(locale).then(\n () => {\n if (ticket === this.requested) this.locale.set(locale);\n },\n () => {\n // Falha ao baixar (rede): troca mesmo assim — o texto cai no `base`/pt-BR, mas o app não trava.\n if (ticket === this.requested) this.locale.set(locale);\n },\n );\n }\n\n registerCatalog(locale: string, catalog: HermesMessages): void {\n this.own.update((all) => ({ ...all, [locale]: catalog }));\n }\n\n setOverride(override: HermesMessagesOverride): void {\n this.overrides.set(override);\n }\n\n /** `'Selecionar {name}'` + `{ name }` → texto final. */\n format(template: string, params?: MessageParams): string {\n return formatMessage(template, params);\n }\n\n /** Forma plural certa para `count` no idioma ativo, com `{count}` e os demais parâmetros. */\n plural(message: PluralMessage, count: number, params?: MessageParams): string {\n return pluralMessage(message, count, this.messages().meta.locale, params);\n }\n\n /**\n * Num mapa por idioma (catálogo de outra camada, conteúdo do app), o do idioma ativo, com a mesma\n * regra da lib: exato → só a língua (`en-GB` → `en`) → `fallback`. Reativo: lido dentro de um\n * `computed`, acompanha `setLocale`.\n */\n pick<T>(byLocale: Readonly<Record<string, T>>, fallback: T): T {\n const locale = this.locale();\n return byLocale[locale] ?? byLocale[locale.split('-')[0]] ?? fallback;\n }\n\n private available(locale: string): boolean {\n const all = this.catalogs();\n return !!(all[locale] ?? all[locale.split('-')[0]]) || !this.loaderKey(locale);\n }\n\n private loaderKey(locale: string): string | null {\n if (locale in this.loaders) return locale;\n const language = locale.split('-')[0];\n return language in this.loaders ? language : null;\n }\n\n private ensure(locale: string): Promise<void> {\n const key = this.loaderKey(locale);\n const all = this.catalogs();\n if (!key || all[locale] || all[locale.split('-')[0]]) return Promise.resolve();\n return loadCatalog(key, this.loaders[key]).then(() => undefined);\n }\n\n /** Idioma exato → só a língua (`en-GB` → `en`) → `base` → pt-BR. */\n private resolve(locale: string): HermesMessages {\n const all = this.catalogs();\n return all[locale] ?? all[locale.split('-')[0]] ?? this.config.base ?? HERMES_MESSAGES_PT_BR;\n }\n}\n\n/**\n * Vista viva de um catálogo de duas camadas (`seção.chave`): cada leitura (`messages.modal.close`)\n * consulta `source()`, então um template que mostra o texto é re-renderizado quando o signal por trás\n * muda — mesmo lendo por propriedade, sem chamar função. Seções e chaves funcionam também com\n * `Object.keys`/spread. Exportada para catálogos de outras camadas (spine, apps) seguirem o mesmo idioma\n * da lib: `liveCatalog(computed(() => meusCatalogos[i18n.locale()]))`.\n */\nexport function liveCatalog<T extends object>(source: () => T): T {\n const all = () => source() as unknown as Record<string, Record<string, unknown>>;\n const sections = new Map<string, object>();\n const section = (name: string): object => {\n let proxy = sections.get(name);\n if (!proxy) {\n const current = () => all()[name] ?? {};\n proxy = new Proxy(\n {},\n {\n get: (_target, key) => current()[key as string],\n has: (_target, key) => key in current(),\n ownKeys: () => Reflect.ownKeys(current()),\n getOwnPropertyDescriptor: (_target, key) =>\n key in current() ? { enumerable: true, configurable: true, writable: false, value: current()[key as string] } : undefined,\n },\n );\n sections.set(name, proxy);\n }\n return proxy;\n };\n return new Proxy({} as T, {\n get: (_target, key) => (typeof key === 'string' ? section(key) : undefined),\n has: (_target, key) => key in all(),\n ownKeys: () => Reflect.ownKeys(all()),\n getOwnPropertyDescriptor: (_target, key) =>\n typeof key === 'string' && key in all() ? { enumerable: true, configurable: true, writable: false, value: section(key) } : undefined,\n });\n}\n\n/** Catálogo de textos dos componentes — vista viva do `HermesI18nService` (pt-BR por padrão). */\nexport const HERMES_MESSAGES = new InjectionToken<HermesMessages>('HERMES_MESSAGES', {\n providedIn: 'root',\n factory: () => {\n const service = inject(HermesI18nService);\n return liveCatalog(() => service.messages());\n },\n});\n\n/** Configura idioma, catálogos e sobrescritas dos textos da lib. */\nexport function provideHermesI18n(config: HermesI18nConfig): Provider {\n return { provide: HERMES_I18N_CONFIG, useValue: config };\n}\n\n/**\n * Atalho compatível com a 0.1.x: troca o catálogo (`base`) e/ou sobrescreve textos avulsos. Equivale a\n * `provideHermesI18n({ base, override })`; para trocar de idioma em tempo de execução, use\n * `HermesI18nService.setLocale`.\n */\nexport function provideHermesMessages(override: HermesMessagesOverride = {}, base: HermesMessages = HERMES_MESSAGES_PT_BR): Provider {\n return provideHermesI18n({ base, override, locale: base.meta.locale });\n}\n","// Ponto de import `@trismegisto/angular/i18n` (secundário do ng-packagr): o que o public-api e as outras pastas usam\n// daqui. Gerado em 2026-10-03; ao criar arquivo público novo na pasta, acrescente a linha.\nexport * from './i18n';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MA4Ba,kBAAkB,GAAG,IAAI,cAAc,CAAmB,oBAAoB,EAAE;AAC3F,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,OAAO,EAAE,CAAC;AACpB,CAAA;AAKD;;;AAGG;AACI,MAAM,sBAAsB,GAAkD;AACnF,IAAA,EAAE,EAAE,MAAM,OAAO,qCAAqC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC;AACzF,IAAA,EAAE,EAAE,MAAM,OAAO,qCAAqC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC;;AAG3F;;;AAGG;AACH,MAAM,cAAc,GAAG,MAAM,CAA2C,EAAE,OAAO,EAAE,qBAAqB,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,gBAAA,EAAA,CAAA,8BAAA,EAA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AAO,WAAW,CAAC,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC9C,CAAC;AACF,CAAA;AAED;AACM,SAAU,iBAAiB,CAAC,MAAwB,EAAA;IACxD,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1D;AAEA;;;;AAIG;SACa,qBAAqB,CAAC,WAAmC,EAAE,EAAE,OAAuB,qBAAqB,EAAA;AACvH,IAAA,OAAO,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;AACxE;;ACrRA;AACA;;ACDA;;AAEG;;"}
1
+ {"version":3,"file":"trismegisto-angular-i18n.mjs","sources":["../../src/i18n/i18n.ts","../../src/i18n/index.ts","../../src/i18n/trismegisto-angular-i18n.ts"],"sourcesContent":["import { DOCUMENT, Injectable, InjectionToken, Provider, computed, effect, inject, signal } from '@angular/core';\nimport {\n HERMES_MESSAGES_PT_BR,\n HermesMessages,\n HermesMessagesOverride,\n HermesRegionalFormat,\n MessageParams,\n PluralMessage,\n formatMessage,\n localeWithRegionalFormat,\n mergeMessages,\n pluralMessage,\n} from '@trismegisto/primitives';\n\nexport interface HermesI18nConfig {\n /** Idioma inicial (BCP 47). Padrão: o do catálogo `base`, senão `pt-BR`. */\n readonly locale?: string;\n /** Catálogo usado quando o idioma pedido não tem um registrado. */\n readonly base?: HermesMessages;\n /**\n * Catálogos extras ou substitutos, por idioma: o catálogo em si (vai embutido no bundle) ou um\n * carregador `() => import(...)` (vira um chunk à parte, baixado no primeiro `setLocale` daquele idioma).\n * en e es já vêm com carregador (`HERMES_CATALOG_LOADERS`); para embuti-los, passe o catálogo:\n * `catalogs: { en: HERMES_MESSAGES_EN }` com `import { HERMES_MESSAGES_EN } from '@trismegisto/primitives/messages/en'`.\n */\n readonly catalogs?: Readonly<Record<string, HermesMessages | HermesCatalogLoader>>;\n /** Textos avulsos sobrescritos por cima do catálogo ativo (vale para todos os idiomas). */\n readonly override?: HermesMessagesOverride;\n /** Relógio de 12/24 h e primeiro dia da semana por cima do padrão do idioma (ver `setRegionalFormat`). */\n readonly regionalFormat?: HermesRegionalFormat;\n}\n\nexport const HERMES_I18N_CONFIG = new InjectionToken<HermesI18nConfig>('HERMES_I18N_CONFIG', {\n providedIn: 'root',\n factory: () => ({}),\n});\n\n/** Carrega um catálogo sob demanda (o `import()` vira um chunk à parte no bundle do app). */\nexport type HermesCatalogLoader = () => Promise<HermesMessages>;\n\n/**\n * Carregadores dos catálogos que acompanham a lib, fora o pt-BR (o único embutido): só o idioma que a\n * pessoa escolher é baixado, e só quando escolher. Mantém leve o bundle de quem usa um idioma só.\n */\nexport const HERMES_CATALOG_LOADERS: Readonly<Record<string, HermesCatalogLoader>> = {\n en: () => import('@trismegisto/primitives/messages/en').then((m) => m.HERMES_MESSAGES_EN),\n es: () => import('@trismegisto/primitives/messages/es').then((m) => m.HERMES_MESSAGES_ES),\n};\n\n/**\n * Catálogos já baixados, compartilhados por todas as instâncias do serviço (um idioma é baixado uma vez\n * por página). Signal: um catálogo que chega depois re-renderiza quem lê o texto.\n */\nconst loadedCatalogs = signal<Readonly<Record<string, HermesMessages>>>({ 'pt-BR': HERMES_MESSAGES_PT_BR });\nconst pendingLoads = new Map<string, Promise<HermesMessages>>();\n\n/** Baixa (uma vez) e guarda o catálogo de `locale` com o carregador dado. */\nfunction loadCatalog(locale: string, loader: HermesCatalogLoader): Promise<HermesMessages> {\n const done = loadedCatalogs()[locale];\n if (done) return Promise.resolve(done);\n let pending = pendingLoads.get(locale);\n if (!pending) {\n pending = loader().then(\n (catalog) => {\n loadedCatalogs.update((all) => ({ ...all, [locale]: catalog }));\n pendingLoads.delete(locale);\n return catalog;\n },\n (error: unknown) => {\n pendingLoads.delete(locale);\n throw error;\n },\n );\n pendingLoads.set(locale, pending);\n }\n return pending;\n}\n\n/**\n * Baixa antes um catálogo da lib (`'en'`, `'es'`) — ex.: num `provideAppInitializer`, para o primeiro\n * `setLocale` daquele idioma ser síncrono. Idioma sem carregador conhecido: resolve `undefined`.\n */\nexport function preloadHermesCatalog(locale: string): Promise<HermesMessages | undefined> {\n const key = locale in HERMES_CATALOG_LOADERS ? locale : locale.split('-')[0];\n const loader = HERMES_CATALOG_LOADERS[key];\n return loader ? loadCatalog(key, loader) : Promise.resolve(undefined);\n}\n\n/**\n * Idioma e textos dos componentes Hermes, reativos: `setLocale('en')` troca todo texto que a lib exibe\n * ou anuncia — sem recarregar a página. Só o pt-BR vem embutido; en e es são baixados sob demanda no\n * primeiro `setLocale` daquele idioma (texto e formato trocam juntos quando o catálogo chega). Outros\n * idiomas entram por `registerCatalog` ou `catalogs` em `provideHermesI18n` (catálogo ou carregador).\n *\n * Os componentes leem por `HERMES_MESSAGES` (uma vista viva deste serviço); o app normalmente só chama\n * `setLocale` quando a pessoa troca de idioma.\n */\n@Injectable({ providedIn: 'root' })\nexport class HermesI18nService {\n private readonly config = inject(HERMES_I18N_CONFIG);\n private readonly own = signal<Readonly<Record<string, HermesMessages>>>({\n ...(this.config.base ? { [this.config.base.meta.locale]: this.config.base } : {}),\n ...(Object.fromEntries(\n Object.entries(this.config.catalogs ?? {}).filter(([, c]) => typeof c !== 'function'),\n ) as Record<string, HermesMessages>),\n });\n private readonly loaders: Readonly<Record<string, HermesCatalogLoader>> = {\n ...HERMES_CATALOG_LOADERS,\n ...(Object.fromEntries(\n Object.entries(this.config.catalogs ?? {}).filter(([, c]) => typeof c === 'function'),\n ) as Record<string, HermesCatalogLoader>),\n };\n /** Os da lib já baixados + os deste app (os do app vencem). */\n private readonly catalogs = computed(() => ({ ...loadedCatalogs(), ...this.own() }));\n private requested = 0;\n private readonly overrides = signal<HermesMessagesOverride>(this.config.override ?? {});\n\n /** Idioma ativo. */\n readonly locale = signal(this.config.locale ?? this.config.base?.meta.locale ?? 'pt-BR');\n\n /** Relógio e primeiro dia da semana escolhidos (vazio = os do idioma). Ver `setRegionalFormat`. */\n readonly regionalFormat = signal<HermesRegionalFormat>(this.config.regionalFormat ?? {});\n\n /**\n * Catálogo ativo, já com as sobrescritas. Quando o idioma pedido é uma variante regional da língua do\n * catálogo (`en-GB` servido pelo catálogo `en`), `meta.locale` passa a ser o pedido: todo formato via\n * `Intl` (data digitada, início da semana, números, plural) segue a região — dd/mm e segunda-feira no\n * Reino Unido. Se o pedido caiu num catálogo de outra língua, fica o do catálogo, para formato e texto\n * não se contradizerem.\n *\n * O formato regional escolhido (`setRegionalFormat`) entra no mesmo `meta.locale` como extensão Unicode\n * (`pt-BR-u-hc-h12`): data e hora (pipes, `hm-time-picker`, `hm-event-calendar`) e início da semana\n * (`hm-date-picker`, `hm-event-calendar`) seguem a escolha sem input novo em componente nenhum.\n */\n readonly messages = computed<HermesMessages>(() => {\n const requested = this.locale();\n const merged = mergeMessages(this.overrides(), this.resolve(requested));\n const sameLanguage = requested.split('-')[0].toLowerCase() === merged.meta.locale.split('-')[0].toLowerCase();\n const locale = localeWithRegionalFormat(sameLanguage ? requested : merged.meta.locale, this.regionalFormat());\n return locale !== merged.meta.locale ? { ...merged, meta: { ...merged.meta, locale } } : merged;\n });\n\n /** Locale de formatação (`Intl`): o idioma ativo com o formato regional escolhido — o mesmo `meta.locale`. */\n readonly formatLocale = computed(() => this.messages().meta.locale);\n\n constructor() {\n // Idioma inicial com catálogo sob demanda: baixa já; até chegar, vale o `base`/pt-BR.\n this.ensure(this.locale()).catch(() => undefined);\n // `<html lang>` acompanha o idioma (WCAG 3.1.1): leitor de tela pronuncia certo, hifenização e\n // tradução automática do navegador acertam o idioma. Só quando o idioma muda — o valor inicial\n // é o que o app já pôs no index.html.\n const document = inject(DOCUMENT, { optional: true });\n const initial = this.locale();\n effect(() => {\n const locale = this.locale();\n if (document?.documentElement && locale !== initial) document.documentElement.lang = locale;\n });\n }\n\n /**\n * Troca o idioma. Com o catálogo à mão (pt-BR, embutido, já baixado), troca na hora; se ele ainda\n * precisa ser baixado, o idioma só muda quando chegar (sem piscar pt-BR no meio) — a Promise resolve\n * nesse momento. Chamadas seguidas: vale a última.\n */\n setLocale(locale: string): Promise<void> {\n const ticket = ++this.requested;\n if (this.available(locale)) {\n this.locale.set(locale);\n return Promise.resolve();\n }\n return this.ensure(locale).then(\n () => {\n if (ticket === this.requested) this.locale.set(locale);\n },\n () => {\n // Falha ao baixar (rede): troca mesmo assim — o texto cai no `base`/pt-BR, mas o app não trava.\n if (ticket === this.requested) this.locale.set(locale);\n },\n );\n }\n\n /**\n * Relógio de 12/24 horas e primeiro dia da semana por cima do padrão do idioma — preferência da pessoa\n * (Configurações › Região, no spine). `null`/ausente volta ao do idioma. Vale na hora, sem recarregar.\n *\n * ```ts\n * i18n.setRegionalFormat({ hourCycle: 'h23', firstDayOfWeek: 1 }); // 24 h, semana na segunda\n * ```\n */\n setRegionalFormat(format: HermesRegionalFormat): void {\n this.regionalFormat.set({ hourCycle: format.hourCycle ?? null, firstDayOfWeek: format.firstDayOfWeek ?? null });\n }\n\n registerCatalog(locale: string, catalog: HermesMessages): void {\n this.own.update((all) => ({ ...all, [locale]: catalog }));\n }\n\n setOverride(override: HermesMessagesOverride): void {\n this.overrides.set(override);\n }\n\n /** `'Selecionar {name}'` + `{ name }` → texto final. */\n format(template: string, params?: MessageParams): string {\n return formatMessage(template, params);\n }\n\n /** Forma plural certa para `count` no idioma ativo, com `{count}` e os demais parâmetros. */\n plural(message: PluralMessage, count: number, params?: MessageParams): string {\n return pluralMessage(message, count, this.messages().meta.locale, params);\n }\n\n /**\n * Num mapa por idioma (catálogo de outra camada, conteúdo do app), o do idioma ativo, com a mesma\n * regra da lib: exato → só a língua (`en-GB` → `en`) → `fallback`. Reativo: lido dentro de um\n * `computed`, acompanha `setLocale`.\n */\n pick<T>(byLocale: Readonly<Record<string, T>>, fallback: T): T {\n const locale = this.locale();\n return byLocale[locale] ?? byLocale[locale.split('-')[0]] ?? fallback;\n }\n\n private available(locale: string): boolean {\n const all = this.catalogs();\n return !!(all[locale] ?? all[locale.split('-')[0]]) || !this.loaderKey(locale);\n }\n\n private loaderKey(locale: string): string | null {\n if (locale in this.loaders) return locale;\n const language = locale.split('-')[0];\n return language in this.loaders ? language : null;\n }\n\n private ensure(locale: string): Promise<void> {\n const key = this.loaderKey(locale);\n const all = this.catalogs();\n if (!key || all[locale] || all[locale.split('-')[0]]) return Promise.resolve();\n return loadCatalog(key, this.loaders[key]).then(() => undefined);\n }\n\n /** Idioma exato → só a língua (`en-GB` → `en`) → `base` → pt-BR. */\n private resolve(locale: string): HermesMessages {\n const all = this.catalogs();\n return all[locale] ?? all[locale.split('-')[0]] ?? this.config.base ?? HERMES_MESSAGES_PT_BR;\n }\n}\n\n/**\n * Vista viva de um catálogo de duas camadas (`seção.chave`): cada leitura (`messages.modal.close`)\n * consulta `source()`, então um template que mostra o texto é re-renderizado quando o signal por trás\n * muda — mesmo lendo por propriedade, sem chamar função. Seções e chaves funcionam também com\n * `Object.keys`/spread. Exportada para catálogos de outras camadas (spine, apps) seguirem o mesmo idioma\n * da lib: `liveCatalog(computed(() => meusCatalogos[i18n.locale()]))`.\n */\nexport function liveCatalog<T extends object>(source: () => T): T {\n const all = () => source() as unknown as Record<string, Record<string, unknown>>;\n const sections = new Map<string, object>();\n const section = (name: string): object => {\n let proxy = sections.get(name);\n if (!proxy) {\n const current = () => all()[name] ?? {};\n proxy = new Proxy(\n {},\n {\n get: (_target, key) => current()[key as string],\n has: (_target, key) => key in current(),\n ownKeys: () => Reflect.ownKeys(current()),\n getOwnPropertyDescriptor: (_target, key) =>\n key in current() ? { enumerable: true, configurable: true, writable: false, value: current()[key as string] } : undefined,\n },\n );\n sections.set(name, proxy);\n }\n return proxy;\n };\n return new Proxy({} as T, {\n get: (_target, key) => (typeof key === 'string' ? section(key) : undefined),\n has: (_target, key) => key in all(),\n ownKeys: () => Reflect.ownKeys(all()),\n getOwnPropertyDescriptor: (_target, key) =>\n typeof key === 'string' && key in all() ? { enumerable: true, configurable: true, writable: false, value: section(key) } : undefined,\n });\n}\n\n/** Catálogo de textos dos componentes — vista viva do `HermesI18nService` (pt-BR por padrão). */\nexport const HERMES_MESSAGES = new InjectionToken<HermesMessages>('HERMES_MESSAGES', {\n providedIn: 'root',\n factory: () => {\n const service = inject(HermesI18nService);\n return liveCatalog(() => service.messages());\n },\n});\n\n/** Configura idioma, catálogos e sobrescritas dos textos da lib. */\nexport function provideHermesI18n(config: HermesI18nConfig): Provider {\n return { provide: HERMES_I18N_CONFIG, useValue: config };\n}\n\n/**\n * Atalho compatível com a 0.1.x: troca o catálogo (`base`) e/ou sobrescreve textos avulsos. Equivale a\n * `provideHermesI18n({ base, override })`; para trocar de idioma em tempo de execução, use\n * `HermesI18nService.setLocale`.\n */\nexport function provideHermesMessages(override: HermesMessagesOverride = {}, base: HermesMessages = HERMES_MESSAGES_PT_BR): Provider {\n return provideHermesI18n({ base, override, locale: base.meta.locale });\n}\n","// Ponto de import `@trismegisto/angular/i18n` (secundário do ng-packagr): o que o public-api e as outras pastas usam\n// daqui. Gerado em 2026-10-03; ao criar arquivo público novo na pasta, acrescente a linha.\nexport * from './i18n';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAgCa,kBAAkB,GAAG,IAAI,cAAc,CAAmB,oBAAoB,EAAE;AAC3F,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,OAAO,EAAE,CAAC;AACpB,CAAA;AAKD;;;AAGG;AACI,MAAM,sBAAsB,GAAkD;AACnF,IAAA,EAAE,EAAE,MAAM,OAAO,qCAAqC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC;AACzF,IAAA,EAAE,EAAE,MAAM,OAAO,qCAAqC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC;;AAG3F;;;AAGG;AACH,MAAM,cAAc,GAAG,MAAM,CAA2C,EAAE,OAAO,EAAE,qBAAqB,EAAE,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AAG,MAAM,OAAO,GAAG,KAAK,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;QAC3E,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,IAAI,GAAG,EAAE;QACnC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;AACrC,QAAA,wBAAwB,EAAE,CAAC,OAAO,EAAE,GAAG,KACrC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS;AACvI,KAAA,CAAC;AACJ;AAEA;MACa,eAAe,GAAG,IAAI,cAAc,CAAiB,iBAAiB,EAAE;AACnF,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAK;AACZ,QAAA,MAAM,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACzC,OAAO,WAAW,CAAC,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC9C,CAAC;AACF,CAAA;AAED;AACM,SAAU,iBAAiB,CAAC,MAAwB,EAAA;IACxD,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1D;AAEA;;;;AAIG;SACa,qBAAqB,CAAC,WAAmC,EAAE,EAAE,OAAuB,qBAAqB,EAAA;AACvH,IAAA,OAAO,iBAAiB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;AACxE;;AChTA;AACA;;ACDA;;AAEG;;"}
@@ -0,0 +1,320 @@
1
+ import * as i0 from '@angular/core';
2
+ import { numberAttribute, model, input, booleanAttribute, output, inject, ElementRef, Injector, computed, signal, afterNextRender, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { listEditorDescription, listEditorTitle, formatMessage, buildListEditorItem, checkListEditorItem, pluralMessage } from '@trismegisto/primitives';
4
+ import { ButtonComponent } from '@trismegisto/angular/button';
5
+ import { HermesFormFieldBase } from '@trismegisto/angular/forms';
6
+ import { HERMES_MESSAGES } from '@trismegisto/angular/i18n';
7
+ import { ICON_CHECK, ICON_EXCLAMATION_TRIANGLE, ICON_PENCIL, ICON_PLUS, useHermesIcons, IconComponent } from '@trismegisto/angular/icon';
8
+ import { IconButtonComponent } from '@trismegisto/angular/icon-button';
9
+ import { InputComponent } from '@trismegisto/angular/input';
10
+ import { ReorderListComponent } from '@trismegisto/angular/reorder-list';
11
+
12
+ const LIST_EDITOR_ICONS = [ICON_CHECK, ICON_EXCLAMATION_TRIANGLE, ICON_PENCIL, ICON_PLUS];
13
+
14
+ const optionalNumber = (value) => value === null || value === undefined || value === '' ? null : numberAttribute(value, NaN);
15
+ let sequence = 0;
16
+ /**
17
+ * Editor de lista (`hm-list-editor`): um campo para acrescentar itens e, embaixo, a lista ordenável dos
18
+ * itens (o `hm-reorder-list`: arrasto pela alça e teclado), com ✕ por item e edição opcional. Para listas
19
+ * curtas em que a ORDEM importa: URIs de redirecionamento, funcionalidades de um plano, etapas.
20
+ *
21
+ * ```html
22
+ * <!-- texto simples -->
23
+ * <hm-list-editor label="Redirect URIs" placeholder="https://app.exemplo.com/callback" [validate]="url" formControlName="redirectUris" />
24
+ * <!-- título + descrição -->
25
+ * <hm-list-editor pair label="Funcionalidades" [(items)]="features" editable />
26
+ * ```
27
+ *
28
+ * - **Modos**: texto simples (`string[]`, um campo) ou `pair` (`{ title, description }[]`, dois campos;
29
+ * na lista o título em destaque e a descrição como texto de apoio embaixo). O tipo é genérico
30
+ * (`ListEditorComponent<T>`); no modo par, campos extras do app (`id`, `sortOrder`...) sobrevivem à edição.
31
+ * - **Adicionar**: Enter em qualquer campo ou o botão "Adicionar". O texto é aparado; vazio, repetido
32
+ * (`allowDuplicates`, `ignoreCase`), acima do `max` ou recusado por `validate` mostra o erro no campo e
33
+ * não entra. Depois de adicionar, os campos limpam e o foco volta ao primeiro.
34
+ * - **Reordenar e remover**: os do `hm-reorder-list` (alça, Espaço/setas, ✕ com foco no vizinho). A lista
35
+ * esvaziada devolve o foco ao campo.
36
+ * - **Editar** (`editable`): o lápis do item leva o texto aos campos; o botão vira "Salvar" (Enter salva,
37
+ * Esc ou "Cancelar" desistem) e o foco volta ao lápis do item.
38
+ * - **Valor**: `[(items)]`, Reactive Forms ou `[(ngModel)]` (ver `HermesFormFieldBase`). `readonly` mostra
39
+ * só a lista, sem campo nem ações; `disabled` mantém tudo visível e inoperante.
40
+ *
41
+ * Acessibilidade: grupo nomeado pelo `label`; a lista é um grupo "Itens de {label}"; uma região viva
42
+ * educada anuncia adição, edição e (pelo `hm-reorder-list`) remoção; os movimentos são anunciados pelo
43
+ * serviço de arrastar e soltar.
44
+ */
45
+ class ListEditorComponent extends HermesFormFieldBase {
46
+ #icons = useHermesIcons(LIST_EDITOR_ICONS);
47
+ /** Os itens, na ordem atual. Two-way: recebe a lista nova a cada adição, remoção, edição ou movimento. */
48
+ items = model([], ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
49
+ /** Nome da lista (visível, salvo `labelHidden`). */
50
+ label = input.required(...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
51
+ labelHidden = input(false, { ...(ngDevMode ? { debugName: "labelHidden" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
52
+ hint = input('', ...(ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []));
53
+ /** Exemplo no campo de texto (ou no título, no modo par). */
54
+ placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
55
+ /** Exemplo no campo de descrição (modo par). */
56
+ descriptionPlaceholder = input('', ...(ngDevMode ? [{ debugName: "descriptionPlaceholder" }] : /* istanbul ignore next */ []));
57
+ /** Itens com título + descrição (`{ title, description }`) em vez de texto simples. */
58
+ pair = input(false, { ...(ngDevMode ? { debugName: "pair" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
59
+ /** Rótulo do campo de texto simples (fica só para leitor de tela). Vazio = catálogo ("Novo item"). */
60
+ itemLabel = input('', ...(ngDevMode ? [{ debugName: "itemLabel" }] : /* istanbul ignore next */ []));
61
+ /** Rótulo do campo de título (modo par). Vazio = catálogo ("Título"). */
62
+ titleLabel = input('', ...(ngDevMode ? [{ debugName: "titleLabel" }] : /* istanbul ignore next */ []));
63
+ /** Rótulo do campo de descrição (modo par). Vazio = catálogo ("Descrição"). */
64
+ descriptionLabel = input('', ...(ngDevMode ? [{ debugName: "descriptionLabel" }] : /* istanbul ignore next */ []));
65
+ /** Texto do botão de adicionar. Vazio = catálogo ("Adicionar"). */
66
+ addLabel = input('', ...(ngDevMode ? [{ debugName: "addLabel" }] : /* istanbul ignore next */ []));
67
+ /** Texto da lista vazia. Vazio = catálogo ("Nenhum item na lista."). */
68
+ emptyText = input('', ...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
69
+ /** No modo par, a descrição também é obrigatória. */
70
+ descriptionRequired = input(false, { ...(ngDevMode ? { debugName: "descriptionRequired" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
71
+ /** Aceita itens repetidos (comparados pelo texto, ou pelo título no modo par). */
72
+ allowDuplicates = input(false, { ...(ngDevMode ? { debugName: "allowDuplicates" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
73
+ /** Ao procurar repetidos, ignora maiúsculas/minúsculas. */
74
+ ignoreCase = input(false, { ...(ngDevMode ? { debugName: "ignoreCase" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
75
+ /** Quantidade máxima de itens (`null` = sem limite). Com limite, o rótulo mostra "{n} de {max}". */
76
+ max = input(null, { ...(ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {}), transform: optionalNumber });
77
+ /** Validação do item novo/editado: devolve a mensagem de erro ou `null`. */
78
+ validate = input(null, ...(ngDevMode ? [{ debugName: "validate" }] : /* istanbul ignore next */ []));
79
+ /** Lápis por item para editar o texto no lugar. */
80
+ editable = input(false, { ...(ngDevMode ? { debugName: "editable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
81
+ /** Só leitura: mostra a lista, sem campo, alças nem ações. */
82
+ readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
83
+ added = output();
84
+ removed = output();
85
+ moved = output();
86
+ edited = output();
87
+ valueModel = this.items;
88
+ #catalog = inject(HERMES_MESSAGES);
89
+ #host = inject(ElementRef);
90
+ #injector = inject(Injector);
91
+ text = computed(() => this.#catalog.listEditor, ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
92
+ #locale = computed(() => this.#catalog.meta.locale, ...(ngDevMode ? [{ debugName: "#locale" }] : /* istanbul ignore next */ []));
93
+ id = `hm-list-editor-${++sequence}`;
94
+ labelId = `${this.id}-label`;
95
+ hintId = `${this.id}-hint`;
96
+ errorId = `${this.id}-error`;
97
+ draftTitle = signal('', ...(ngDevMode ? [{ debugName: "draftTitle" }] : /* istanbul ignore next */ []));
98
+ draftDescription = signal('', ...(ngDevMode ? [{ debugName: "draftDescription" }] : /* istanbul ignore next */ []));
99
+ rejection = signal(null, ...(ngDevMode ? [{ debugName: "rejection" }] : /* istanbul ignore next */ []));
100
+ /** Id (da linha) do item em edição. */
101
+ editingId = signal(null, ...(ngDevMode ? [{ debugName: "editingId" }] : /* istanbul ignore next */ []));
102
+ announcement = signal('', ...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
103
+ // Ids estáveis por linha (o `hm-reorder-list` rastreia por id). Valores vindos de fora (writeValue,
104
+ // binding) ganham ids novos; as mudanças feitas aqui levam os ids junto.
105
+ #ids = [];
106
+ #idsFor = null;
107
+ #previous = [];
108
+ values = computed(() => this.items() ?? [], ...(ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []));
109
+ rows = computed(() => {
110
+ const list = this.values();
111
+ if (list !== this.#idsFor) {
112
+ this.#ids = list.map(() => this.#newId());
113
+ this.#idsFor = list;
114
+ }
115
+ return list.map((value, index) => {
116
+ const description = listEditorDescription(value);
117
+ return { id: this.#ids[index], label: listEditorTitle(value), ...(description ? { description } : {}) };
118
+ });
119
+ }, ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
120
+ /** Posição do item em edição (-1 = adicionando). Some sozinho se o item sair da lista. */
121
+ editingIndex = computed(() => {
122
+ this.rows();
123
+ const id = this.editingId();
124
+ return id === null ? -1 : this.#ids.indexOf(id);
125
+ }, ...(ngDevMode ? [{ debugName: "editingIndex" }] : /* istanbul ignore next */ []));
126
+ firstFieldLabel = computed(() => this.pair() ? this.titleLabel() || this.text().title : this.itemLabel() || this.text().item, ...(ngDevMode ? [{ debugName: "firstFieldLabel" }] : /* istanbul ignore next */ []));
127
+ secondFieldLabel = computed(() => this.descriptionLabel() || this.text().description, ...(ngDevMode ? [{ debugName: "secondFieldLabel" }] : /* istanbul ignore next */ []));
128
+ listLabel = computed(() => formatMessage(this.text().list, { label: this.label() }), ...(ngDevMode ? [{ debugName: "listLabel" }] : /* istanbul ignore next */ []));
129
+ emptyLabel = computed(() => this.emptyText() || this.text().empty, ...(ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []));
130
+ submitLabel = computed(() => this.editingIndex() >= 0 ? this.text().save : this.addLabel() || this.text().add, ...(ngDevMode ? [{ debugName: "submitLabel" }] : /* istanbul ignore next */ []));
131
+ countText = computed(() => {
132
+ const max = this.max();
133
+ return max === null ? '' : formatMessage(this.text().count, { count: this.values().length, max });
134
+ }, ...(ngDevMode ? [{ debugName: "countText" }] : /* istanbul ignore next */ []));
135
+ /** Erro mostrado no primeiro campo (texto ou título). */
136
+ firstError = computed(() => {
137
+ const rejection = this.rejection();
138
+ if (!rejection || rejection.reason === 'emptyDescription')
139
+ return '';
140
+ return this.#rejectionText(rejection);
141
+ }, ...(ngDevMode ? [{ debugName: "firstError" }] : /* istanbul ignore next */ []));
142
+ /** Erro mostrado no campo de descrição (modo par). */
143
+ secondError = computed(() => this.rejection()?.reason === 'emptyDescription' ? this.text().requiredDescription : '', ...(ngDevMode ? [{ debugName: "secondError" }] : /* istanbul ignore next */ []));
144
+ describedBy = computed(() => [this.hint() ? this.hintId : '', this.errorText() ? this.errorId : ''].filter(Boolean).join(' ') || null, ...(ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []));
145
+ editLabel(row) {
146
+ return formatMessage(this.text().edit, { label: row.label });
147
+ }
148
+ onTitleInput(value) {
149
+ this.draftTitle.set(value == null ? '' : String(value));
150
+ this.rejection.set(null);
151
+ }
152
+ onDescriptionInput(value) {
153
+ this.draftDescription.set(value == null ? '' : String(value));
154
+ if (this.rejection()?.reason === 'emptyDescription')
155
+ this.rejection.set(null);
156
+ }
157
+ /** Enter adiciona (ou salva); Esc, durante a edição, desiste. */
158
+ onFieldKeydown(event) {
159
+ if (event.key === 'Enter' && !event.isComposing) {
160
+ event.preventDefault();
161
+ this.submit();
162
+ }
163
+ else if ((event.key === 'Escape' || event.key === 'Esc') && this.editingIndex() >= 0) {
164
+ event.preventDefault();
165
+ this.cancelEdit();
166
+ }
167
+ }
168
+ /** Adiciona o item dos campos (ou salva a edição), se ele passar nas regras. */
169
+ submit() {
170
+ if (this.isDisabled() || this.readonly())
171
+ return;
172
+ const list = this.values();
173
+ const editing = this.editingIndex();
174
+ const previous = editing >= 0 ? list[editing] : null;
175
+ const item = buildListEditorItem(this.pair(), this.draftTitle(), this.draftDescription(), previous);
176
+ const rejection = checkListEditorItem(item, list, {
177
+ allowDuplicates: this.allowDuplicates(),
178
+ ignoreCase: this.ignoreCase(),
179
+ max: this.max(),
180
+ descriptionRequired: this.descriptionRequired(),
181
+ validate: this.validate(),
182
+ editing: editing >= 0 ? editing : null,
183
+ });
184
+ if (rejection) {
185
+ this.rejection.set(rejection);
186
+ this.#focusField(rejection.reason === 'emptyDescription' ? 1 : 0);
187
+ return;
188
+ }
189
+ this.rejection.set(null);
190
+ this.draftTitle.set('');
191
+ this.draftDescription.set('');
192
+ const label = listEditorTitle(item);
193
+ if (previous !== null) {
194
+ const next = list.map((value, index) => (index === editing ? item : value));
195
+ this.#publish(next, [...this.#ids]);
196
+ this.editingId.set(null);
197
+ this.edited.emit({ item, previous, index: editing });
198
+ this.#announce(formatMessage(this.text().edited, { label }));
199
+ this.#focusEditButton(editing);
200
+ return;
201
+ }
202
+ const next = [...list, item];
203
+ this.#publish(next, [...this.#ids, this.#newId()]);
204
+ this.added.emit({ item, index: next.length - 1 });
205
+ this.#announce(formatMessage(this.text().added, { label }));
206
+ this.#focusField(0);
207
+ }
208
+ /** Leva o item aos campos para editar. */
209
+ startEdit(index) {
210
+ if (this.isDisabled() || this.readonly())
211
+ return;
212
+ this.rows();
213
+ const value = this.values()[index];
214
+ if (value === undefined)
215
+ return;
216
+ this.editingId.set(this.#ids[index]);
217
+ this.draftTitle.set(listEditorTitle(value));
218
+ this.draftDescription.set(listEditorDescription(value));
219
+ this.rejection.set(null);
220
+ this.#announce(formatMessage(this.text().editing, { label: listEditorTitle(value) }));
221
+ this.#focusField(0);
222
+ }
223
+ /** Desiste da edição: limpa os campos e devolve o foco ao lápis do item. */
224
+ cancelEdit() {
225
+ const index = this.editingIndex();
226
+ this.editingId.set(null);
227
+ this.draftTitle.set('');
228
+ this.draftDescription.set('');
229
+ this.rejection.set(null);
230
+ if (index >= 0)
231
+ this.#focusEditButton(index);
232
+ }
233
+ /** Lista nova vinda do `hm-reorder-list` (soltou num lugar novo ou removeu pelo ✕). */
234
+ onRowsChange(rows) {
235
+ const list = this.values();
236
+ const byId = new Map(this.#ids.map((id, index) => [id, list[index]]));
237
+ const next = rows.filter((row) => byId.has(row.id)).map((row) => byId.get(row.id));
238
+ this.#previous = list;
239
+ this.#publish(next, rows.filter((row) => byId.has(row.id)).map((row) => row.id));
240
+ }
241
+ onRowMoved(move) {
242
+ const item = this.values()[move.to];
243
+ if (item !== undefined)
244
+ this.moved.emit({ item, from: move.from, to: move.to });
245
+ }
246
+ onRowRemoved(removal) {
247
+ const item = this.#previous[removal.index];
248
+ if (item !== undefined)
249
+ this.removed.emit({ item, index: removal.index });
250
+ // Item em edição removido: os campos voltam a "adicionar".
251
+ if (this.editingId() !== null && this.editingIndex() < 0)
252
+ this.cancelEdit();
253
+ // Lista vazia: o foco vai para o campo (o `hm-reorder-list` o poria na mensagem de vazio).
254
+ if (!this.values().length)
255
+ this.#focusField(0);
256
+ }
257
+ onFocusOut(event) {
258
+ const next = event.relatedTarget;
259
+ if (next && this.#host.nativeElement.contains(next))
260
+ return;
261
+ // O foco também sai quando o editor é tirado da página (um modal fechando, um @if): isso acontece no meio da
262
+ // detecção de mudanças, e marcar "tocado" ali muda o que o template já leu (NG0100 em modo dev). Fica para logo
263
+ // depois, e só se o editor ainda está na página.
264
+ queueMicrotask(() => {
265
+ if (this.#host.nativeElement.isConnected)
266
+ this.markTouched();
267
+ });
268
+ }
269
+ #publish(next, ids) {
270
+ this.#ids = ids;
271
+ this.#idsFor = next;
272
+ this.commit(next);
273
+ }
274
+ #newId() {
275
+ return `${this.id}-item-${++sequence}`;
276
+ }
277
+ #rejectionText(rejection) {
278
+ const text = this.text();
279
+ switch (rejection.reason) {
280
+ case 'empty':
281
+ return text.required;
282
+ case 'emptyDescription':
283
+ return text.requiredDescription;
284
+ case 'duplicate':
285
+ return formatMessage(text.duplicate, { label: this.draftTitle().trim() });
286
+ case 'limit':
287
+ return pluralMessage(text.limit, this.max() ?? 0, this.#locale());
288
+ default:
289
+ return rejection.message ?? '';
290
+ }
291
+ }
292
+ #announce(message) {
293
+ // Limpa antes: a mesma frase duas vezes seguidas não seria anunciada de novo.
294
+ this.announcement.set('');
295
+ queueMicrotask(() => this.announcement.set(message));
296
+ }
297
+ #focusField(position) {
298
+ afterNextRender(() => this.#host.nativeElement.querySelectorAll('.hm-list-editor__field input')[position]?.focus(), { injector: this.#injector });
299
+ }
300
+ #focusEditButton(index) {
301
+ afterNextRender(() => this.#host.nativeElement
302
+ .querySelectorAll('.hm-list-editor__edit button')[index]?.focus(), { injector: this.#injector });
303
+ }
304
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: ListEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
305
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.24", type: ListEditorComponent, isStandalone: true, selector: "hm-list-editor", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, labelHidden: { classPropertyName: "labelHidden", publicName: "labelHidden", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, descriptionPlaceholder: { classPropertyName: "descriptionPlaceholder", publicName: "descriptionPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, pair: { classPropertyName: "pair", publicName: "pair", isSignal: true, isRequired: false, transformFunction: null }, itemLabel: { classPropertyName: "itemLabel", publicName: "itemLabel", isSignal: true, isRequired: false, transformFunction: null }, titleLabel: { classPropertyName: "titleLabel", publicName: "titleLabel", isSignal: true, isRequired: false, transformFunction: null }, descriptionLabel: { classPropertyName: "descriptionLabel", publicName: "descriptionLabel", isSignal: true, isRequired: false, transformFunction: null }, addLabel: { classPropertyName: "addLabel", publicName: "addLabel", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null }, descriptionRequired: { classPropertyName: "descriptionRequired", publicName: "descriptionRequired", isSignal: true, isRequired: false, transformFunction: null }, allowDuplicates: { classPropertyName: "allowDuplicates", publicName: "allowDuplicates", isSignal: true, isRequired: false, transformFunction: null }, ignoreCase: { classPropertyName: "ignoreCase", publicName: "ignoreCase", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, validate: { classPropertyName: "validate", publicName: "validate", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { items: "itemsChange", added: "added", removed: "removed", moved: "moved", edited: "edited" }, host: { listeners: { "focusout": "onFocusOut($event)" }, classAttribute: "hm-list-editor-host" }, usesInheritance: true, ngImport: i0, template: "<div\n class=\"hm-list-editor\"\n [class.hm-list-editor--pair]=\"pair()\"\n [class.hm-list-editor--disabled]=\"isDisabled()\"\n [class.hm-list-editor--readonly]=\"readonly()\"\n [class.hm-list-editor--invalid]=\"!!errorText()\"\n role=\"group\"\n [attr.aria-labelledby]=\"labelId\"\n [attr.aria-describedby]=\"describedBy()\"\n>\n <!-- R\u00F3tulo e texto de apoio antes dos campos: quem l\u00EA de cima para baixo v\u00EA a orienta\u00E7\u00E3o antes de digitar. -->\n <div class=\"hm-list-editor__header\">\n <div class=\"hm-list-editor__label-row\" [class.hm-visually-hidden]=\"labelHidden()\">\n <span class=\"hm-list-editor__label\" [id]=\"labelId\">{{ label() }}</span>\n @if (isRequired()) {\n <span class=\"hm-list-editor__required\">{{ fieldText.required }}</span>\n }\n @if (countText()) {\n <span class=\"hm-list-editor__count\">{{ countText() }}</span>\n }\n </div>\n @if (hint()) {\n <p class=\"hm-list-editor__hint\" [id]=\"hintId\">{{ hint() }}</p>\n }\n </div>\n\n @if (!readonly()) {\n <!-- Campo(s) de adicionar: Enter em qualquer campo adiciona (ou salva a edi\u00E7\u00E3o). -->\n <div class=\"hm-list-editor__add\" (keydown)=\"onFieldKeydown($event)\">\n <div class=\"hm-list-editor__fields\">\n <hm-input\n class=\"hm-list-editor__field\"\n [label]=\"firstFieldLabel()\"\n [labelHidden]=\"!pair()\"\n [placeholder]=\"placeholder()\"\n [value]=\"draftTitle()\"\n [error]=\"firstError()\"\n [disabled]=\"isDisabled()\"\n (valueChange)=\"onTitleInput($event)\"\n />\n @if (pair()) {\n <hm-input\n class=\"hm-list-editor__field\"\n [label]=\"secondFieldLabel()\"\n [placeholder]=\"descriptionPlaceholder()\"\n [value]=\"draftDescription()\"\n [error]=\"secondError()\"\n [disabled]=\"isDisabled()\"\n (valueChange)=\"onDescriptionInput($event)\"\n />\n }\n </div>\n <div class=\"hm-list-editor__actions\">\n <hm-button\n class=\"hm-list-editor__submit\"\n emphasis=\"medium\"\n [icon]=\"editingIndex() >= 0 ? 'check' : 'plus'\"\n [disabled]=\"isDisabled()\"\n (clicked)=\"submit()\"\n >\n {{ submitLabel() }}\n </hm-button>\n @if (editingIndex() >= 0) {\n <hm-button class=\"hm-list-editor__cancel\" emphasis=\"minimal\" [disabled]=\"isDisabled()\" (clicked)=\"cancelEdit()\">\n {{ text().cancel }}\n </hm-button>\n }\n </div>\n </div>\n\n <hm-reorder-list\n class=\"hm-list-editor__list\"\n [items]=\"rows()\"\n [label]=\"listLabel()\"\n labelHidden\n removable\n [emptyText]=\"emptyLabel()\"\n [disabled]=\"isDisabled()\"\n (itemsChange)=\"onRowsChange($event)\"\n (moved)=\"onRowMoved($event)\"\n (removed)=\"onRowRemoved($event)\"\n >\n <ng-template let-row let-index=\"index\">\n <div class=\"hm-list-editor__row\" [class.hm-list-editor__row--editing]=\"editingIndex() === index\">\n <span class=\"hm-list-editor__text\">\n <span class=\"hm-list-editor__title\">{{ row.label }}</span>\n @if (row.description) {\n <span class=\"hm-list-editor__description\">{{ row.description }}</span>\n }\n </span>\n @if (editable()) {\n <hm-icon-button\n class=\"hm-list-editor__edit\"\n icon=\"pencil\"\n emphasis=\"subtle\"\n size=\"small\"\n [label]=\"editLabel(row)\"\n [disabled]=\"isDisabled()\"\n (clicked)=\"startEdit(index)\"\n />\n }\n </div>\n </ng-template>\n </hm-reorder-list>\n } @else {\n @if (rows().length) {\n <ul class=\"hm-list-editor__static\" [attr.aria-label]=\"listLabel()\">\n @for (row of rows(); track row.id) {\n <li class=\"hm-list-editor__static-item\">\n <span class=\"hm-list-editor__title\">{{ row.label }}</span>\n @if (row.description) {\n <span class=\"hm-list-editor__description\">{{ row.description }}</span>\n }\n </li>\n }\n </ul>\n } @else {\n <p class=\"hm-list-editor__empty\">{{ emptyLabel() }}</p>\n }\n }\n\n <div class=\"hm-visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">{{ announcement() }}</div>\n\n @if (errorText()) {\n <p class=\"hm-list-editor__error\" role=\"alert\" [id]=\"errorId\">\n <hm-icon shape=\"exclamation-triangle\" />\n {{ errorText() }}\n </p>\n }\n</div>\n", dependencies: [{ kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: IconButtonComponent, selector: "hm-icon-button", inputs: ["label", "icon", "solid", "iconDirection", "emphasis", "intent", "size", "disabled", "toggle", "pressed", "keyShortcuts"], outputs: ["pressedChange", "clicked"] }, { kind: "component", type: IconComponent, selector: "hm-icon", inputs: ["shape", "direction", "size", "solid", "badge", "status", "flip", "inverse", "label"] }, { kind: "component", type: InputComponent, selector: "hm-input", inputs: ["value", "label", "type", "placeholder", "icon", "labelHidden", "hint", "prefix", "suffix", "prefixIcon", "mask", "maskValue", "min", "max", "step", "stepButtons", "maxLength", "autocomplete", "inputMode"], outputs: ["valueChange"] }, { kind: "component", type: ReorderListComponent, selector: "hm-reorder-list", inputs: ["items", "label", "labelHidden", "hint", "size", "removable", "emptyText"], outputs: ["itemsChange", "moved", "removed"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
306
+ }
307
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: ListEditorComponent, decorators: [{
308
+ type: Component,
309
+ args: [{ selector: 'hm-list-editor', imports: [ButtonComponent, IconButtonComponent, IconComponent, InputComponent, ReorderListComponent], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'hm-list-editor-host', '(focusout)': 'onFocusOut($event)' }, template: "<div\n class=\"hm-list-editor\"\n [class.hm-list-editor--pair]=\"pair()\"\n [class.hm-list-editor--disabled]=\"isDisabled()\"\n [class.hm-list-editor--readonly]=\"readonly()\"\n [class.hm-list-editor--invalid]=\"!!errorText()\"\n role=\"group\"\n [attr.aria-labelledby]=\"labelId\"\n [attr.aria-describedby]=\"describedBy()\"\n>\n <!-- R\u00F3tulo e texto de apoio antes dos campos: quem l\u00EA de cima para baixo v\u00EA a orienta\u00E7\u00E3o antes de digitar. -->\n <div class=\"hm-list-editor__header\">\n <div class=\"hm-list-editor__label-row\" [class.hm-visually-hidden]=\"labelHidden()\">\n <span class=\"hm-list-editor__label\" [id]=\"labelId\">{{ label() }}</span>\n @if (isRequired()) {\n <span class=\"hm-list-editor__required\">{{ fieldText.required }}</span>\n }\n @if (countText()) {\n <span class=\"hm-list-editor__count\">{{ countText() }}</span>\n }\n </div>\n @if (hint()) {\n <p class=\"hm-list-editor__hint\" [id]=\"hintId\">{{ hint() }}</p>\n }\n </div>\n\n @if (!readonly()) {\n <!-- Campo(s) de adicionar: Enter em qualquer campo adiciona (ou salva a edi\u00E7\u00E3o). -->\n <div class=\"hm-list-editor__add\" (keydown)=\"onFieldKeydown($event)\">\n <div class=\"hm-list-editor__fields\">\n <hm-input\n class=\"hm-list-editor__field\"\n [label]=\"firstFieldLabel()\"\n [labelHidden]=\"!pair()\"\n [placeholder]=\"placeholder()\"\n [value]=\"draftTitle()\"\n [error]=\"firstError()\"\n [disabled]=\"isDisabled()\"\n (valueChange)=\"onTitleInput($event)\"\n />\n @if (pair()) {\n <hm-input\n class=\"hm-list-editor__field\"\n [label]=\"secondFieldLabel()\"\n [placeholder]=\"descriptionPlaceholder()\"\n [value]=\"draftDescription()\"\n [error]=\"secondError()\"\n [disabled]=\"isDisabled()\"\n (valueChange)=\"onDescriptionInput($event)\"\n />\n }\n </div>\n <div class=\"hm-list-editor__actions\">\n <hm-button\n class=\"hm-list-editor__submit\"\n emphasis=\"medium\"\n [icon]=\"editingIndex() >= 0 ? 'check' : 'plus'\"\n [disabled]=\"isDisabled()\"\n (clicked)=\"submit()\"\n >\n {{ submitLabel() }}\n </hm-button>\n @if (editingIndex() >= 0) {\n <hm-button class=\"hm-list-editor__cancel\" emphasis=\"minimal\" [disabled]=\"isDisabled()\" (clicked)=\"cancelEdit()\">\n {{ text().cancel }}\n </hm-button>\n }\n </div>\n </div>\n\n <hm-reorder-list\n class=\"hm-list-editor__list\"\n [items]=\"rows()\"\n [label]=\"listLabel()\"\n labelHidden\n removable\n [emptyText]=\"emptyLabel()\"\n [disabled]=\"isDisabled()\"\n (itemsChange)=\"onRowsChange($event)\"\n (moved)=\"onRowMoved($event)\"\n (removed)=\"onRowRemoved($event)\"\n >\n <ng-template let-row let-index=\"index\">\n <div class=\"hm-list-editor__row\" [class.hm-list-editor__row--editing]=\"editingIndex() === index\">\n <span class=\"hm-list-editor__text\">\n <span class=\"hm-list-editor__title\">{{ row.label }}</span>\n @if (row.description) {\n <span class=\"hm-list-editor__description\">{{ row.description }}</span>\n }\n </span>\n @if (editable()) {\n <hm-icon-button\n class=\"hm-list-editor__edit\"\n icon=\"pencil\"\n emphasis=\"subtle\"\n size=\"small\"\n [label]=\"editLabel(row)\"\n [disabled]=\"isDisabled()\"\n (clicked)=\"startEdit(index)\"\n />\n }\n </div>\n </ng-template>\n </hm-reorder-list>\n } @else {\n @if (rows().length) {\n <ul class=\"hm-list-editor__static\" [attr.aria-label]=\"listLabel()\">\n @for (row of rows(); track row.id) {\n <li class=\"hm-list-editor__static-item\">\n <span class=\"hm-list-editor__title\">{{ row.label }}</span>\n @if (row.description) {\n <span class=\"hm-list-editor__description\">{{ row.description }}</span>\n }\n </li>\n }\n </ul>\n } @else {\n <p class=\"hm-list-editor__empty\">{{ emptyLabel() }}</p>\n }\n }\n\n <div class=\"hm-visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">{{ announcement() }}</div>\n\n @if (errorText()) {\n <p class=\"hm-list-editor__error\" role=\"alert\" [id]=\"errorId\">\n <hm-icon shape=\"exclamation-triangle\" />\n {{ errorText() }}\n </p>\n }\n</div>\n" }]
310
+ }], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }, { type: i0.Output, args: ["itemsChange"] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], labelHidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelHidden", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], descriptionPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "descriptionPlaceholder", required: false }] }], pair: [{ type: i0.Input, args: [{ isSignal: true, alias: "pair", required: false }] }], itemLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemLabel", required: false }] }], titleLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "titleLabel", required: false }] }], descriptionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "descriptionLabel", required: false }] }], addLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "addLabel", required: false }] }], emptyText: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyText", required: false }] }], descriptionRequired: [{ type: i0.Input, args: [{ isSignal: true, alias: "descriptionRequired", required: false }] }], allowDuplicates: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowDuplicates", required: false }] }], ignoreCase: [{ type: i0.Input, args: [{ isSignal: true, alias: "ignoreCase", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], validate: [{ type: i0.Input, args: [{ isSignal: true, alias: "validate", required: false }] }], editable: [{ type: i0.Input, args: [{ isSignal: true, alias: "editable", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], added: [{ type: i0.Output, args: ["added"] }], removed: [{ type: i0.Output, args: ["removed"] }], moved: [{ type: i0.Output, args: ["moved"] }], edited: [{ type: i0.Output, args: ["edited"] }] } });
311
+
312
+ // Ponto de import `@trismegisto/angular/list-editor` (secundário do ng-packagr): o que o public-api e as outras pastas usam
313
+ // daqui. Ao criar arquivo público novo na pasta, acrescente a linha.
314
+
315
+ /**
316
+ * Generated bundle index. Do not edit.
317
+ */
318
+
319
+ export { ListEditorComponent };
320
+ //# sourceMappingURL=trismegisto-angular-list-editor.mjs.map