@haiilo/catalyst 9.1.0 → 10.0.2

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 (35) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/index.esm.js +1 -1
  3. package/dist/catalyst/{p-609000a1.entry.js → p-3c7a135c.entry.js} +3 -3
  4. package/dist/catalyst/{p-609000a1.entry.js.map → p-3c7a135c.entry.js.map} +1 -1
  5. package/dist/catalyst/p-f5febe1f.js +2 -0
  6. package/dist/catalyst/p-f5febe1f.js.map +1 -0
  7. package/dist/cjs/cat-alert_26.cjs.entry.js +1 -2
  8. package/dist/cjs/cat-alert_26.cjs.entry.js.map +1 -1
  9. package/dist/cjs/index.cjs.js +1 -1
  10. package/dist/cjs/{of-4c3bdf21.js → of-30c47b72.js} +10 -10
  11. package/dist/cjs/of-30c47b72.js.map +1 -0
  12. package/dist/collection/components/cat-i18n/cat-i18n-registry.js +6 -6
  13. package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
  14. package/dist/collection/components/cat-icon/cat-icon-registry.js +3 -3
  15. package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
  16. package/dist/collection/components/cat-radio/cat-radio.js +0 -1
  17. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  18. package/dist/collection/utils/coerce.js.map +1 -1
  19. package/dist/components/cat-i18n-registry.js +6 -6
  20. package/dist/components/cat-i18n-registry.js.map +1 -1
  21. package/dist/components/cat-icon-registry.js +3 -3
  22. package/dist/components/cat-icon-registry.js.map +1 -1
  23. package/dist/components/cat-radio.js +0 -1
  24. package/dist/components/cat-radio.js.map +1 -1
  25. package/dist/components/coerce.js.map +1 -1
  26. package/dist/esm/cat-alert_26.entry.js +1 -2
  27. package/dist/esm/cat-alert_26.entry.js.map +1 -1
  28. package/dist/esm/index.js +2 -2
  29. package/dist/esm/{of-ec88a583.js → of-4b71dda1.js} +10 -10
  30. package/dist/esm/of-4b71dda1.js.map +1 -0
  31. package/package.json +2 -2
  32. package/dist/catalyst/p-f65e3491.js +0 -2
  33. package/dist/catalyst/p-f65e3491.js.map +0 -1
  34. package/dist/cjs/of-4c3bdf21.js.map +0 -1
  35. package/dist/esm/of-ec88a583.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"coerce.js","sourceRoot":"","sources":["../../src/utils/coerce.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,MAAM,UAAU,aAAa,CAAC,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,KAAK,OAAO,CAAC;AACjD,CAAC;AAID,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,aAAa,GAAG,CAAC;IACxD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9D,CAAC;AAED,SAAS,aAAa,CAAC,KAAU;IAC/B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAY,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport function coerceBoolean(value: any): boolean {\n return value != null && `${value}` !== 'false';\n}\n\nexport function coerceNumber(value: any): number;\nexport function coerceNumber<D>(value: any, fallback: D): number | D;\nexport function coerceNumber(value: any, fallbackValue = 0) {\n return isNumberValue(value) ? Number(value) : fallbackValue;\n}\n\nfunction isNumberValue(value: any): boolean {\n return !isNaN(parseFloat(value as any)) && !isNaN(Number(value));\n}\n"]}
1
+ {"version":3,"file":"coerce.js","sourceRoot":"","sources":["../../src/utils/coerce.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,MAAM,UAAU,aAAa,CAAC,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,KAAK,OAAO,CAAC;AACjD,CAAC;AAID,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,aAAa,GAAG,CAAC;IACxD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9D,CAAC;AAED,SAAS,aAAa,CAAC,KAAU;IAC/B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport function coerceBoolean(value: any): boolean {\n return value != null && `${value}` !== 'false';\n}\n\nexport function coerceNumber(value: any): number;\nexport function coerceNumber<D>(value: any, fallback: D): number | D;\nexport function coerceNumber(value: any, fallbackValue = 0) {\n return isNumberValue(value) ? Number(value) : fallbackValue;\n}\n\nfunction isNumberValue(value: any): boolean {\n return !isNaN(parseFloat(value)) && !isNaN(Number(value));\n}\n"]}
@@ -43,35 +43,35 @@ class CatI18nRegistry {
43
43
  setLocale(locale, silent = false) {
44
44
  try {
45
45
  this._locale = Intl.getCanonicalLocales(locale)[0];
46
- loglevel.info(`[CatI18nRegistry] Set locale: ${this._locale}`);
46
+ loglevel.info(`[CatI18nRegistry::${this.id}] Set locale: ${this._locale}`);
47
47
  !silent && window.dispatchEvent(this.buildEvent('cat-i18n-setLocale', { locale, id: this.id }));
48
48
  }
49
49
  catch (err) {
50
- loglevel.error(`[CatI18nRegistry] Invalid locale: ${locale}`);
50
+ loglevel.error(`[CatI18nRegistry::${this.id}] Invalid locale: ${locale}`);
51
51
  }
52
52
  }
53
53
  set(i18n, silent = false) {
54
54
  if (typeof i18n === 'function') {
55
55
  this._translator = i18n;
56
- loglevel.info(`[CatI18nRegistry] Registered translator`);
56
+ loglevel.info(`[CatI18nRegistry::${this.id}] Registered translator`);
57
57
  }
58
58
  else {
59
59
  const i18nEntries = Object.entries(i18n);
60
60
  i18nEntries.forEach(([key, message]) => this.i18n.set(key, message));
61
- loglevel.info(`[CatI18nRegistry] Registered ${i18nEntries.length !== 1 ? 'messages' : 'message'}`);
61
+ loglevel.info(`[CatI18nRegistry::${this.id}] Registered ${i18nEntries.length !== 1 ? 'messages' : 'message'}`);
62
62
  }
63
63
  !silent && window.dispatchEvent(this.buildEvent('cat-i18n-set', { i18n, id: this.id }));
64
64
  }
65
65
  clear(silent = false) {
66
66
  this.i18n.clear();
67
- loglevel.info(`[CatI18nRegistry] Cleared messages`);
67
+ loglevel.info(`[CatI18nRegistry::${this.id}] Cleared messages`);
68
68
  !silent && window.dispatchEvent(this.buildEvent('cat-i18n-clear'));
69
69
  }
70
70
  t(key, params) {
71
71
  const message = this._translator?.(key, params) ??
72
72
  this.i18n.get(key)?.replace(/{{\s*([-a-zA-Z._]+)\s*}}/g, (_match, key) => `${params?.[key] ?? ''}`);
73
73
  if (message === undefined) {
74
- loglevel.error(`[CatI18nRegistry] Unknown message key: ${key}`);
74
+ loglevel.error(`[CatI18nRegistry::${this.id}] Unknown message key: ${key}`);
75
75
  return key;
76
76
  }
77
77
  return message;
@@ -1 +1 @@
1
- {"file":"cat-i18n-registry.js","mappings":";;MAIa,eAAe;IAS1B;;QANiB,OAAE,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACnD,SAAI,GAAwB,IAAI,GAAG,EAAE,CAAC;;;;;;;;QAerD,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,KAAK;YACjD,MAAM,EAAE,MAAM,EAAE,GAAI,KAAqB,IAAI,EAAE,CAAC;YAChD,IAAI,MAAM,IAAI,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE;gBACnC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;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AE,GAAG,KAAK,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtG,IAAI,OAAO,KAAK,SAAS,EAAE;YACzBA,QAAG,CAAC,KAAK,CAAC,0CAA0C,GAAG,EAAE,CAAC,CAAC;YAC3D,OAAO,GAAG,CAAC;SACZ;QACD,OAAO,OAAO,CAAC;KAChB;IAEO,UAAU,CAAI,IAAY,EAAE,MAAU;QAC5C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;YAC3B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM;SACP,CAAC,CAAC;KACJ;CACF;MAEY,eAAe,GAAG,eAAe,CAAC,WAAW;;;;","names":["log"],"sources":["src/components/cat-i18n/cat-i18n-registry.ts"],"sourcesContent":["import log from 'loglevel';\n\nexport type CatI18nTranslationFn = (key: string, params?: unknown) => string;\n\nexport class CatI18nRegistry {\n private static instance: CatI18nRegistry;\n\n private readonly id = (Math.random() + 1).toString(36).substring(2);\n private readonly i18n: Map<string, string> = new Map();\n\n private _locale?: string;\n private _translator?: CatI18nTranslationFn;\n\n private constructor() {\n // hide constructor\n\n // In rare cases, the registry can be initialized twice. This can happen in\n // a micro frontend architecture where the registry is initialized in the\n // host application and in the micro frontend. To prevent the registry in\n // one application from overwriting the registry in the other, we listen for\n // events that are dispatched when messages are added or removed in other\n // applications and add or remove messages if the event was not dispatched\n // by this registry.\n window.addEventListener('cat-i18n-setLocale', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.setLocale(detail.locale, true);\n }\n });\n window.addEventListener('cat-i18n-set', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.set(detail.i18n, true);\n }\n });\n window.addEventListener('cat-i18n-clear', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.clear(true);\n }\n });\n }\n\n static getInstance(): CatI18nRegistry {\n if (!CatI18nRegistry.instance) {\n CatI18nRegistry.instance = new CatI18nRegistry();\n }\n return CatI18nRegistry.instance;\n }\n\n getLocale(): string {\n return this._locale ?? window?.navigator?.language ?? 'en';\n }\n\n setLocale(locale: string, silent = false): void {\n try {\n this._locale = Intl.getCanonicalLocales(locale)[0];\n log.info(`[CatI18nRegistry] Set locale: ${this._locale}`);\n !silent && window.dispatchEvent(this.buildEvent('cat-i18n-setLocale', { locale, id: this.id }));\n } catch (err) {\n log.error(`[CatI18nRegistry] Invalid locale: ${locale}`);\n }\n }\n\n set(i18n: { [key: string]: string } | CatI18nTranslationFn, silent = false): void {\n if (typeof i18n === 'function') {\n this._translator = i18n;\n log.info(`[CatI18nRegistry] Registered translator`);\n } else {\n const i18nEntries = Object.entries(i18n);\n i18nEntries.forEach(([key, message]) => this.i18n.set(key, message));\n log.info(`[CatI18nRegistry] Registered ${i18nEntries.length !== 1 ? 'messages' : 'message'}`);\n }\n !silent && window.dispatchEvent(this.buildEvent('cat-i18n-set', { i18n, id: this.id }));\n }\n\n clear(silent = false): void {\n this.i18n.clear();\n log.info(`[CatI18nRegistry] Cleared messages`);\n !silent && window.dispatchEvent(this.buildEvent('cat-i18n-clear'));\n }\n\n t(key: string, params?: { [key: string]: unknown }): string {\n const message =\n this._translator?.(key, params) ??\n this.i18n.get(key)?.replace(/{{\\s*([-a-zA-Z._]+)\\s*}}/g, (_match, key) => `${params?.[key] ?? ''}`);\n if (message === undefined) {\n log.error(`[CatI18nRegistry] Unknown message key: ${key}`);\n return key;\n }\n return message;\n }\n\n private buildEvent<T>(name: string, detail?: T) {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail\n });\n }\n}\n\nexport const catI18nRegistry = CatI18nRegistry.getInstance();\n"],"version":3}
1
+ {"file":"cat-i18n-registry.js","mappings":";;MAIa,eAAe;IAS1B;;QANiB,OAAE,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,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MAAM,GAAG,KAAK;QAClB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAClBA,QAAG,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC3D,CAAC,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;KACpE;IAED,CAAC,CAAC,GAAW,EAAE,MAAmC;QAChD,MAAM,OAAO,GACX,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE,MAAM,CAAC;YAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,2BAA2B,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtG,IAAI,OAAO,KAAK,SAAS,EAAE;YACzBA,QAAG,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,EAAE,0BAA0B,GAAG,EAAE,CAAC,CAAC;YACvE,OAAO,GAAG,CAAC;SACZ;QACD,OAAO,OAAO,CAAC;KAChB;IAEO,UAAU,CAAI,IAAY,EAAE,MAAU;QAC5C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;YAC3B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM;SACP,CAAC,CAAC;KACJ;CACF;MAEY,eAAe,GAAG,eAAe,CAAC,WAAW;;;;","names":["log"],"sources":["src/components/cat-i18n/cat-i18n-registry.ts"],"sourcesContent":["import log from 'loglevel';\n\nexport type CatI18nTranslationFn = (key: string, params?: unknown) => string;\n\nexport class CatI18nRegistry {\n private static instance: CatI18nRegistry;\n\n private readonly id = (Math.random() + 1).toString(36).substring(2);\n private readonly i18n: Map<string, string> = new Map();\n\n private _locale?: string;\n private _translator?: CatI18nTranslationFn;\n\n private constructor() {\n // hide constructor\n\n // In rare cases, the registry can be initialized twice. This can happen in\n // a micro frontend architecture where the registry is initialized in the\n // host application and in the micro frontend. To prevent the registry in\n // one application from overwriting the registry in the other, we listen for\n // events that are dispatched when messages are added or removed in other\n // applications and add or remove messages if the event was not dispatched\n // by this registry.\n window.addEventListener('cat-i18n-setLocale', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.setLocale(detail.locale, true);\n }\n });\n window.addEventListener('cat-i18n-set', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.set(detail.i18n, true);\n }\n });\n window.addEventListener('cat-i18n-clear', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.clear(true);\n }\n });\n }\n\n static getInstance(): CatI18nRegistry {\n if (!CatI18nRegistry.instance) {\n CatI18nRegistry.instance = new CatI18nRegistry();\n }\n return CatI18nRegistry.instance;\n }\n\n getLocale(): string {\n return this._locale ?? window?.navigator?.language ?? 'en';\n }\n\n setLocale(locale: string, silent = false): void {\n try {\n this._locale = Intl.getCanonicalLocales(locale)[0];\n log.info(`[CatI18nRegistry::${this.id}] Set locale: ${this._locale}`);\n !silent && window.dispatchEvent(this.buildEvent('cat-i18n-setLocale', { locale, id: this.id }));\n } catch (err) {\n log.error(`[CatI18nRegistry::${this.id}] Invalid locale: ${locale}`);\n }\n }\n\n set(i18n: { [key: string]: string } | CatI18nTranslationFn, silent = false): void {\n if (typeof i18n === 'function') {\n this._translator = i18n;\n log.info(`[CatI18nRegistry::${this.id}] Registered translator`);\n } else {\n const i18nEntries = Object.entries(i18n);\n i18nEntries.forEach(([key, message]) => this.i18n.set(key, message));\n log.info(`[CatI18nRegistry::${this.id}] Registered ${i18nEntries.length !== 1 ? 'messages' : 'message'}`);\n }\n !silent && window.dispatchEvent(this.buildEvent('cat-i18n-set', { i18n, id: this.id }));\n }\n\n clear(silent = false): void {\n this.i18n.clear();\n log.info(`[CatI18nRegistry::${this.id}] Cleared messages`);\n !silent && window.dispatchEvent(this.buildEvent('cat-i18n-clear'));\n }\n\n t(key: string, params?: { [key: string]: unknown }): string {\n const message =\n this._translator?.(key, params) ??\n this.i18n.get(key)?.replace(/{{\\s*([-a-zA-Z._]+)\\s*}}/g, (_match, key) => `${params?.[key] ?? ''}`);\n if (message === undefined) {\n log.error(`[CatI18nRegistry::${this.id}] Unknown message key: ${key}`);\n return key;\n }\n return message;\n }\n\n private buildEvent<T>(name: string, detail?: T) {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail\n });\n }\n}\n\nexport const catI18nRegistry = CatI18nRegistry.getInstance();\n"],"version":3}
@@ -86,7 +86,7 @@ class CatIconRegistry {
86
86
  getIcon(name, setName) {
87
87
  const icon = this.icons.get(this.buildName(name, setName));
88
88
  if (!icon) {
89
- loglevel.error(`[CatIconRegistry] Unknown icon${setName ? ` in set ${setName}` : ''}: ${name}`);
89
+ loglevel.error(`[CatIconRegistry::${this.id}] Unknown icon${setName ? ` in set ${setName}` : ''}: ${name}`);
90
90
  }
91
91
  return icon;
92
92
  }
@@ -94,14 +94,14 @@ class CatIconRegistry {
94
94
  const iconEntries = Object.entries(icons);
95
95
  const iconSize = iconEntries.length;
96
96
  iconEntries.forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));
97
- loglevel.info(`[CatIconRegistry] Added ${iconSize !== 1 ? 'icons' : 'icon'}${setName ? ` to set ${setName}` : ''}`);
97
+ loglevel.info(`[CatIconRegistry::${this.id}] Added ${iconSize !== 1 ? 'icons' : 'icon'}${setName ? ` to set ${setName}` : ''}`);
98
98
  !silent && window.dispatchEvent(this.buildEvent('cat-icons-added', { id: this.id, icons, setName }));
99
99
  return this;
100
100
  }
101
101
  removeIcons(names, setName, silent = false) {
102
102
  const iconSize = names.length;
103
103
  names.forEach(name => this.icons.delete(this.buildName(name, setName)));
104
- loglevel.info(`[CatIconRegistry] Removed ${iconSize !== 1 ? 'icons' : 'icon'}${setName ? ` from set ${setName}` : ''}`);
104
+ loglevel.info(`[CatIconRegistry::${this.id}] Removed ${iconSize !== 1 ? 'icons' : 'icon'}${setName ? ` from set ${setName}` : ''}`);
105
105
  !silent && window.dispatchEvent(this.buildEvent('cat-icons-removed', { id: this.id, names, setName }));
106
106
  return this;
107
107
  }
@@ -1 +1 @@
1
- {"file":"cat-icon-registry.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiBa,eAAe;IAM1B;;QAHiB,OAAE,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACnD,UAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;;QAMtD,IAAI,CAAC,QAAQ,CACX;YACE,eAAe,EAAE,gBAAgB;YACjC,iBAAiB,EAAE,WAAW;YAC9B,YAAY,EAAE,gBAAgB;YAC9B,eAAe,EAAE,iBAAiB;YAClC,eAAe,EAAE,YAAY;YAC7B,cAAc,EAAE,iBAAiB;YACjC,cAAc,EAAE,aAAa;YAC7B,aAAa,EAAE,mBAAmB;YAClC,aAAa,EAAE,mBAAmB;YAClC,qBAAqB,EAAE,eAAe;YACtC,qBAAqB,EAAE,iBAAiB;YACxC,oBAAoB,EAAE,mBAAmB;YACzC,iBAAiB,EAAE,mBAAmB;YACtC,kBAAkB,EAAE,oBAAoB;YACxC,cAAc,EAAE,OAAO;YACvB,aAAa,EAAE,mBAAmB;SACnC,EACD,MAAM,EACN,IAAI,CACL,CAAC;;;;;;;;QASF,MAAM,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAK;YAC9C,MAAM,EAAE,MAAM,EAAE,GAAI,KAAqB,IAAI,EAAE,CAAC;YAChD,IAAI,MAAM,IAAI,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE;gBACnC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;aACnD;SACF,CAAC,CA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":["log"],"sources":["src/components/cat-icon/cat-icon-registry.ts"],"sourcesContent":["import cross16 from '@haiilo/catalyst-icons/tmp/assets/16-cross.svg';\nimport alertCircleOutlined from '@haiilo/catalyst-icons/tmp/assets/alert-circle-outlined.svg';\nimport checkCircleFilled from '@haiilo/catalyst-icons/tmp/assets/check-circle-filled.svg';\nimport chevronDownOutlined from '@haiilo/catalyst-icons/tmp/assets/chevron-down-outlined.svg';\nimport chevronLeftOutlined from '@haiilo/catalyst-icons/tmp/assets/chevron-left-outlined.svg';\nimport chevronRightOutlined from '@haiilo/catalyst-icons/tmp/assets/chevron-right-outlined.svg';\nimport clockFilled from '@haiilo/catalyst-icons/tmp/assets/clock-filled.svg';\nimport crossCircleFilled from '@haiilo/catalyst-icons/tmp/assets/cross-circle-filled.svg';\nimport crossCircleOutlined from '@haiilo/catalyst-icons/tmp/assets/cross-circle-outlined.svg';\nimport crossOutlined from '@haiilo/catalyst-icons/tmp/assets/cross-outlined.svg';\nimport dangerFilled from '@haiilo/catalyst-icons/tmp/assets/danger-filled.svg';\nimport eyeClosedOutlined from '@haiilo/catalyst-icons/tmp/assets/eye-closed-outlined.svg';\nimport eyeOpenOutlined from '@haiilo/catalyst-icons/tmp/assets/eye-open-outlined.svg';\nimport infoCircleFilled from '@haiilo/catalyst-icons/tmp/assets/info-circle-filled.svg';\nimport starCircleFilled from '@haiilo/catalyst-icons/tmp/assets/star-circle-filled.svg';\nimport log from 'loglevel';\n\nexport class CatIconRegistry {\n private static instance: CatIconRegistry;\n\n private readonly id = (Math.random() + 1).toString(36).substring(2);\n private readonly icons: Map<string, string> = new Map();\n\n private constructor() {\n // hide constructor\n\n // register default icons that are used in the framework by other components\n this.addIcons(\n {\n 'alert-primary': starCircleFilled,\n 'alert-secondary': clockFilled,\n 'alert-info': infoCircleFilled,\n 'alert-success': checkCircleFilled,\n 'alert-warning': dangerFilled,\n 'alert-danger': crossCircleFilled,\n 'dialog-close': crossOutlined,\n 'input-close': crossCircleOutlined,\n 'input-error': alertCircleOutlined,\n 'input-password-show': eyeOpenOutlined,\n 'input-password-hide': eyeClosedOutlined,\n 'notification-close': crossCircleOutlined,\n 'pagination-left': chevronLeftOutlined,\n 'pagination-right': chevronRightOutlined,\n 'select-clear': cross16,\n 'select-open': chevronDownOutlined\n },\n '$cat',\n true\n );\n\n // In rare cases, the registry can be initialized twice. This can happen in\n // a micro frontend architecture where the registry is initialized in the\n // host application and in the micro frontend. To prevent the registry in\n // one application from overwriting the registry in the other, we listen for\n // events that are dispatched when icons are added or removed in other\n // applications and add or remove icons if the event was not dispatched by\n // this registry.\n window.addEventListener('cat-icons-added', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.addIcons(detail.icons, detail.setName, true);\n }\n });\n window.addEventListener('cat-icons-removed', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.removeIcons(detail.names, detail.setName, true);\n }\n });\n }\n\n static getInstance(): CatIconRegistry {\n if (!CatIconRegistry.instance) {\n CatIconRegistry.instance = new CatIconRegistry();\n }\n return CatIconRegistry.instance;\n }\n\n getIcon(name: string, setName?: string): string | undefined {\n const icon = this.icons.get(this.buildName(name, setName));\n if (!icon) {\n log.error(`[CatIconRegistry] Unknown icon${setName ? ` in set ${setName}` : ''}: ${name}`);\n }\n return icon;\n }\n\n addIcons(icons: { [name: string]: string }, setName?: string, silent = false): CatIconRegistry {\n const iconEntries = Object.entries(icons);\n const iconSize = iconEntries.length;\n iconEntries.forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));\n log.info(`[CatIconRegistry] Added ${iconSize !== 1 ? 'icons' : 'icon'}${setName ? ` to set ${setName}` : ''}`);\n !silent && window.dispatchEvent(this.buildEvent('cat-icons-added', { id: this.id, icons, setName }));\n return this;\n }\n\n removeIcons(names: string[], setName?: string, silent = false): CatIconRegistry {\n const iconSize = names.length;\n names.forEach(name => this.icons.delete(this.buildName(name, setName)));\n log.info(`[CatIconRegistry] Removed ${iconSize !== 1 ? 'icons' : 'icon'}${setName ? ` from set ${setName}` : ''}`);\n !silent && window.dispatchEvent(this.buildEvent('cat-icons-removed', { id: this.id, names, setName }));\n return this;\n }\n\n private buildName(name: string, setName?: string) {\n return setName ? `${setName}:${name}` : name;\n }\n\n private buildEvent<T>(name: string, detail?: T) {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail\n });\n }\n}\n\nexport const catIconRegistry = CatIconRegistry.getInstance();\n"],"version":3}
1
+ {"file":"cat-icon-registry.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiBa,eAAe;IAM1B;;QAHiB,OAAE,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACnD,UAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;;QAMtD,IAAI,CAAC,QAAQ,CACX;YACE,eAAe,EAAE,gBAAgB;YACjC,iBAAiB,EAAE,WAAW;YAC9B,YAAY,EAAE,gBAAgB;YAC9B,eAAe,EAAE,iBAAiB;YAClC,eAAe,EAAE,YAAY;YAC7B,cAAc,EAAE,iBAAiB;YACjC,cAAc,EAAE,aAAa;YAC7B,aAAa,EAAE,mBAAmB;YAClC,aAAa,EAAE,mBAAmB;YAClC,qBAAqB,EAAE,eAAe;YACtC,qBAAqB,EAAE,iBAAiB;YACxC,oBAAoB,EAAE,mBAAmB;YACzC,iBAAiB,EAAE,mBAAmB;YACtC,kBAAkB,EAAE,oBAAoB;YACxC,cAAc,EAAE,OAAO;YACvB,aAAa,EAAE,mBAAmB;SACnC,EACD,MAAM,EACN,IAAI,CACL,CAAC;;;;;;;;QASF,MAAM,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAK;YAC9C,MAAM,EAAE,MAAM,EAAE,GAAI,KAAqB,IAAI,EAAE,CAAC;YAChD,IAAI,MAAM,IAAI,MAAM,CAAC,EAAE,KAAK,I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EO,UAAU,CAAI,IAAY,EAAE,MAAU;QAC5C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;YAC3B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM;SACP,CAAC,CAAC;KACJ;CACF;MAEY,eAAe,GAAG,eAAe,CAAC,WAAW;;;;","names":["log"],"sources":["src/components/cat-icon/cat-icon-registry.ts"],"sourcesContent":["import cross16 from '@haiilo/catalyst-icons/tmp/assets/16-cross.svg';\nimport alertCircleOutlined from '@haiilo/catalyst-icons/tmp/assets/alert-circle-outlined.svg';\nimport checkCircleFilled from '@haiilo/catalyst-icons/tmp/assets/check-circle-filled.svg';\nimport chevronDownOutlined from '@haiilo/catalyst-icons/tmp/assets/chevron-down-outlined.svg';\nimport chevronLeftOutlined from '@haiilo/catalyst-icons/tmp/assets/chevron-left-outlined.svg';\nimport chevronRightOutlined from '@haiilo/catalyst-icons/tmp/assets/chevron-right-outlined.svg';\nimport clockFilled from '@haiilo/catalyst-icons/tmp/assets/clock-filled.svg';\nimport crossCircleFilled from '@haiilo/catalyst-icons/tmp/assets/cross-circle-filled.svg';\nimport crossCircleOutlined from '@haiilo/catalyst-icons/tmp/assets/cross-circle-outlined.svg';\nimport crossOutlined from '@haiilo/catalyst-icons/tmp/assets/cross-outlined.svg';\nimport dangerFilled from '@haiilo/catalyst-icons/tmp/assets/danger-filled.svg';\nimport eyeClosedOutlined from '@haiilo/catalyst-icons/tmp/assets/eye-closed-outlined.svg';\nimport eyeOpenOutlined from '@haiilo/catalyst-icons/tmp/assets/eye-open-outlined.svg';\nimport infoCircleFilled from '@haiilo/catalyst-icons/tmp/assets/info-circle-filled.svg';\nimport starCircleFilled from '@haiilo/catalyst-icons/tmp/assets/star-circle-filled.svg';\nimport log from 'loglevel';\n\nexport class CatIconRegistry {\n private static instance: CatIconRegistry;\n\n private readonly id = (Math.random() + 1).toString(36).substring(2);\n private readonly icons: Map<string, string> = new Map();\n\n private constructor() {\n // hide constructor\n\n // register default icons that are used in the framework by other components\n this.addIcons(\n {\n 'alert-primary': starCircleFilled,\n 'alert-secondary': clockFilled,\n 'alert-info': infoCircleFilled,\n 'alert-success': checkCircleFilled,\n 'alert-warning': dangerFilled,\n 'alert-danger': crossCircleFilled,\n 'dialog-close': crossOutlined,\n 'input-close': crossCircleOutlined,\n 'input-error': alertCircleOutlined,\n 'input-password-show': eyeOpenOutlined,\n 'input-password-hide': eyeClosedOutlined,\n 'notification-close': crossCircleOutlined,\n 'pagination-left': chevronLeftOutlined,\n 'pagination-right': chevronRightOutlined,\n 'select-clear': cross16,\n 'select-open': chevronDownOutlined\n },\n '$cat',\n true\n );\n\n // In rare cases, the registry can be initialized twice. This can happen in\n // a micro frontend architecture where the registry is initialized in the\n // host application and in the micro frontend. To prevent the registry in\n // one application from overwriting the registry in the other, we listen for\n // events that are dispatched when icons are added or removed in other\n // applications and add or remove icons if the event was not dispatched by\n // this registry.\n window.addEventListener('cat-icons-added', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.addIcons(detail.icons, detail.setName, true);\n }\n });\n window.addEventListener('cat-icons-removed', event => {\n const { detail } = (event as CustomEvent) || {};\n if (detail && detail.id !== this.id) {\n this.removeIcons(detail.names, detail.setName, true);\n }\n });\n }\n\n static getInstance(): CatIconRegistry {\n if (!CatIconRegistry.instance) {\n CatIconRegistry.instance = new CatIconRegistry();\n }\n return CatIconRegistry.instance;\n }\n\n getIcon(name: string, setName?: string): string | undefined {\n const icon = this.icons.get(this.buildName(name, setName));\n if (!icon) {\n log.error(`[CatIconRegistry::${this.id}] Unknown icon${setName ? ` in set ${setName}` : ''}: ${name}`);\n }\n return icon;\n }\n\n addIcons(icons: { [name: string]: string }, setName?: string, silent = false): CatIconRegistry {\n const iconEntries = Object.entries(icons);\n const iconSize = iconEntries.length;\n iconEntries.forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));\n log.info(\n `[CatIconRegistry::${this.id}] Added ${iconSize !== 1 ? 'icons' : 'icon'}${setName ? ` to set ${setName}` : ''}`\n );\n !silent && window.dispatchEvent(this.buildEvent('cat-icons-added', { id: this.id, icons, setName }));\n return this;\n }\n\n removeIcons(names: string[], setName?: string, silent = false): CatIconRegistry {\n const iconSize = names.length;\n names.forEach(name => this.icons.delete(this.buildName(name, setName)));\n log.info(\n `[CatIconRegistry::${this.id}] Removed ${iconSize !== 1 ? 'icons' : 'icon'}${\n setName ? ` from set ${setName}` : ''\n }`\n );\n !silent && window.dispatchEvent(this.buildEvent('cat-icons-removed', { id: this.id, names, setName }));\n return this;\n }\n\n private buildName(name: string, setName?: string) {\n return setName ? `${setName}:${name}` : name;\n }\n\n private buildEvent<T>(name: string, detail?: T) {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail\n });\n }\n}\n\nexport const catIconRegistry = CatIconRegistry.getInstance();\n"],"version":3}
@@ -63,7 +63,6 @@ const CatRadio$1 = /*@__PURE__*/ proxyCustomElement(class CatRadio extends HTMLE
63
63
  }
64
64
  onInput() {
65
65
  this.checked = true;
66
- console.log('onInput', this.value);
67
66
  this.catChange.emit(this.value);
68
67
  }
69
68
  onFocus(event) {
@@ -1 +1 @@
1
- {"file":"cat-radio.js","mappings":";;;;AAAA,MAAM,WAAW,GAAG,m+DAAm+D;;ACIv/D,IAAI,YAAY,GAAG,CAAC,CAAC;MAgBRA,UAAQ;;;;;;;;QACF,QAAG,GAAG,aAAa,EAAE,YAAY,EAAE,CAAC;+BAS1B,KAAK;8BAEN,KAAK;uBAKI,KAAK;wBAKrB,KAAK;;qBAUR,EAAE;2BAKI,KAAK;;wBAUR,KAAK;qBAMH,EAAE;;yBAUH,KAAK;;;IA7DzB,IAAY,EAAE;QACZ,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC;KACpC;IAiFD,mBAAmB;QACjB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatRadio","log"],"sources":["src/components/cat-radio/cat-radio.scss?tag=cat-radio&encapsulation=shadow","src/components/cat-radio/cat-radio.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n@use 'src/components/cat-form-hint/cat-form-hint';\n\n$radio-width: 1.25rem;\n$radio-height: 1.25rem;\n\n:host {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n}\n\n:host([hidden]) {\n display: none;\n}\n\nlabel {\n display: flex;\n gap: 0.5rem;\n @include cat-body('m');\n cursor: pointer;\n}\n\n.label-left {\n flex-direction: row-reverse;\n}\n\n.radio {\n display: flex;\n position: relative;\n align-self: flex-start;\n}\n\n.circle-placeholder {\n width: calc($radio-width + 1px);\n flex-shrink: 0;\n}\n\n.circle {\n position: absolute;\n width: 0.75rem;\n height: 0.75rem;\n background-color: cat-token('color.theme.primary.bg');\n border-radius: 10rem;\n top: calc(50% - 0.375rem);\n left: calc(50% - 0.375rem);\n visibility: hidden;\n pointer-events: none;\n}\n\ninput {\n margin: 0;\n width: $radio-width;\n height: $radio-height;\n appearance: none;\n background-color: cat-token('color.ui.background.input');\n border: 1px solid cat-token('color.ui.border.dark');\n border-radius: 10rem;\n cursor: inherit;\n\n &:checked {\n border-color: cat-token('color.theme.primary.bg');\n\n + .circle {\n visibility: visible;\n }\n }\n\n &:focus-visible {\n outline: 2px solid cat-token('color.ui.border.focus');\n outline-offset: 1px;\n }\n}\n\n:host(.cat-error) {\n input {\n border-color: cat-token('color.theme.danger.bg');\n }\n\n .circle {\n background-color: cat-token('color.theme.danger.bg');\n }\n}\n\n.label {\n flex: 1 1 auto;\n\n .is-hidden & {\n @include cat-visually-hidden;\n }\n}\n\n.is-disabled {\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n\n input {\n background-color: cat-token('color.ui.background.muted');\n\n &:checked {\n border-color: cat-token('color.ui.border.dark');\n }\n }\n\n .circle {\n background-color: cat-token('color.ui.border.dark');\n }\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\n/**\n * Radio Buttons are graphical interface elements that allow user to choose\n * only one of a predefined set of mutually exclusive options.\n *\n * @slot hint - Optional hint element to be displayed with the radio.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n * @part input - The native input element.\n */\n@Component({\n tag: 'cat-radio',\n styleUrl: 'cat-radio.scss',\n shadow: true\n})\nexport class CatRadio {\n private readonly _id = `cat-radio-${++nextUniqueId}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n /**\n * Whether this radio is checked.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * Whether this radio is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label of the radio that is visible.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the radio component.\n */\n @Prop() name?: string;\n\n /**\n * Whether the radio is required.\n */\n @Prop() required = false;\n\n /**\n * The value of the radio component.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n @Prop() value: any = '';\n\n /**\n * Optional hint text(s) to be displayed with the radio.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Whether the label should appear to the left of the radio component.\n */\n @Prop() labelLeft = false;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the radio is changed.\n */\n @Event() catChange!: EventEmitter<boolean | string>;\n\n /**\n * Emitted when the radio received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the radio loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on radio', this);\n }\n }\n\n /**\n * Programmatically move focus to the radio button. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the radio button. Use this method\n * instead of `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n render() {\n return (\n <Host>\n <label\n htmlFor={this.id}\n class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft }}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n >\n <span class=\"radio\">\n <input\n {...this.nativeAttributes}\n part=\"input\"\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.identifier || this.id}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n aria-describedby={this.hasHint ? this.id + '-hint' : undefined}\n />\n <span class=\"circle\"></span>\n </span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hasHint && (\n <div class={{ 'hint-wrapper': true, 'label-left': this.labelLeft }}>\n <div class=\"circle-placeholder\"></div>\n <CatFormHint id={this.id} hint={this.hint} slottedHint={this.hasSlottedHint && <slot name=\"hint\"></slot>} />\n </div>\n )}\n </Host>\n );\n }\n\n private get hasHint() {\n return !!this.hint || !!this.hasSlottedHint;\n }\n\n private onInput() {\n this.checked = true;\n console.log('onInput', this.value);\n this.catChange.emit(this.value);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"],"version":3}
1
+ {"file":"cat-radio.js","mappings":";;;;AAAA,MAAM,WAAW,GAAG,m+DAAm+D;;ACIv/D,IAAI,YAAY,GAAG,CAAC,CAAC;MAgBRA,UAAQ;;;;;;;;QACF,QAAG,GAAG,aAAa,EAAE,YAAY,EAAE,CAAC;+BAS1B,KAAK;8BAEN,KAAK;uBAKI,KAAK;wBAKrB,KAAK;;qBAUR,EAAE;2BAKI,KAAK;;wBAUR,KAAK;qBAMH,EAAE;;yBAUH,KAAK;;;IA7DzB,IAAY,EAAE;QACZ,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC;KACpC;IAiFD,mBAAmB;QACjB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAC1E,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACxCC,QAAG,CAAC,IAAI,CAAC,oCAAoC,EAAE,IAAI,CAAC,CAAC;SACtD;KACF;;;;;;;;IAUD,MAAM,OAAO,CAAC,OAAsB;QAClC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC3B;;;;;IAOD,MAAM,MAAM;QACV,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;KACnB;IAED,MAAM;QACJ,QACE,EAAC,IAAI,QACH,aACE,OAAO,EAAE,IAAI,CAAC,EAAE,EAChB,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,IAAI,CAAC,Q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AE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,cAAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CACxG,CACP,CACI,EACP;KACH;IAED,IAAY,OAAO;QACjB,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;KAC7C;IAEO,OAAO;QACb,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACjC;IAEO,OAAO,CAAC,KAAiB;QAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC3B;IAEO,MAAM,CAAC,KAAiB;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatRadio","log"],"sources":["src/components/cat-radio/cat-radio.scss?tag=cat-radio&encapsulation=shadow","src/components/cat-radio/cat-radio.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n@use 'src/components/cat-form-hint/cat-form-hint';\n\n$radio-width: 1.25rem;\n$radio-height: 1.25rem;\n\n:host {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n}\n\n:host([hidden]) {\n display: none;\n}\n\nlabel {\n display: flex;\n gap: 0.5rem;\n @include cat-body('m');\n cursor: pointer;\n}\n\n.label-left {\n flex-direction: row-reverse;\n}\n\n.radio {\n display: flex;\n position: relative;\n align-self: flex-start;\n}\n\n.circle-placeholder {\n width: calc($radio-width + 1px);\n flex-shrink: 0;\n}\n\n.circle {\n position: absolute;\n width: 0.75rem;\n height: 0.75rem;\n background-color: cat-token('color.theme.primary.bg');\n border-radius: 10rem;\n top: calc(50% - 0.375rem);\n left: calc(50% - 0.375rem);\n visibility: hidden;\n pointer-events: none;\n}\n\ninput {\n margin: 0;\n width: $radio-width;\n height: $radio-height;\n appearance: none;\n background-color: cat-token('color.ui.background.input');\n border: 1px solid cat-token('color.ui.border.dark');\n border-radius: 10rem;\n cursor: inherit;\n\n &:checked {\n border-color: cat-token('color.theme.primary.bg');\n\n + .circle {\n visibility: visible;\n }\n }\n\n &:focus-visible {\n outline: 2px solid cat-token('color.ui.border.focus');\n outline-offset: 1px;\n }\n}\n\n:host(.cat-error) {\n input {\n border-color: cat-token('color.theme.danger.bg');\n }\n\n .circle {\n background-color: cat-token('color.theme.danger.bg');\n }\n}\n\n.label {\n flex: 1 1 auto;\n\n .is-hidden & {\n @include cat-visually-hidden;\n }\n}\n\n.is-disabled {\n cursor: not-allowed;\n color: cat-token('color.ui.font.muted');\n\n input {\n background-color: cat-token('color.ui.background.muted');\n\n &:checked {\n border-color: cat-token('color.ui.border.dark');\n }\n }\n\n .circle {\n background-color: cat-token('color.ui.border.dark');\n }\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\n/**\n * Radio Buttons are graphical interface elements that allow user to choose\n * only one of a predefined set of mutually exclusive options.\n *\n * @slot hint - Optional hint element to be displayed with the radio.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n * @part input - The native input element.\n */\n@Component({\n tag: 'cat-radio',\n styleUrl: 'cat-radio.scss',\n shadow: true\n})\nexport class CatRadio {\n private readonly _id = `cat-radio-${++nextUniqueId}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n /**\n * Whether this radio is checked.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * Whether this radio is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label of the radio that is visible.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the radio component.\n */\n @Prop() name?: string;\n\n /**\n * Whether the radio is required.\n */\n @Prop() required = false;\n\n /**\n * The value of the radio component.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n @Prop() value: any = '';\n\n /**\n * Optional hint text(s) to be displayed with the radio.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Whether the label should appear to the left of the radio component.\n */\n @Prop() labelLeft = false;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the radio is changed.\n */\n @Event() catChange!: EventEmitter<boolean | string>;\n\n /**\n * Emitted when the radio received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the radio loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on radio', this);\n }\n }\n\n /**\n * Programmatically move focus to the radio button. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the radio button. Use this method\n * instead of `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n render() {\n return (\n <Host>\n <label\n htmlFor={this.id}\n class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft }}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n >\n <span class=\"radio\">\n <input\n {...this.nativeAttributes}\n part=\"input\"\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.identifier || this.id}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n aria-describedby={this.hasHint ? this.id + '-hint' : undefined}\n />\n <span class=\"circle\"></span>\n </span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hasHint && (\n <div class={{ 'hint-wrapper': true, 'label-left': this.labelLeft }}>\n <div class=\"circle-placeholder\"></div>\n <CatFormHint id={this.id} hint={this.hint} slottedHint={this.hasSlottedHint && <slot name=\"hint\"></slot>} />\n </div>\n )}\n </Host>\n );\n }\n\n private get hasHint() {\n return !!this.hint || !!this.hasSlottedHint;\n }\n\n private onInput() {\n this.checked = true;\n this.catChange.emit(this.value);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"file":"coerce.js","mappings":"AAAA;SAEgB,aAAa,CAAC,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,KAAK,OAAO,CAAC;AACjD,CAAC;SAIe,YAAY,CAAC,KAAU,EAAE,aAAa,GAAG,CAAC;IACxD,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC;AAC9D,CAAC;AAED,SAAS,aAAa,CAAC,KAAU;IAC/B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAY,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACnE;;;;","names":[],"sources":["src/utils/coerce.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport function coerceBoolean(value: any): boolean {\n return value != null && `${value}` !== 'false';\n}\n\nexport function coerceNumber(value: any): number;\nexport function coerceNumber<D>(value: any, fallback: D): number | D;\nexport function coerceNumber(value: any, fallbackValue = 0) {\n return isNumberValue(value) ? Number(value) : fallbackValue;\n}\n\nfunction isNumberValue(value: any): boolean {\n return !isNaN(parseFloat(value as any)) && !isNaN(Number(value));\n}\n"],"version":3}
1
+ {"file":"coerce.js","mappings":"AAAA;SAEgB,aAAa,CAAC,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,KAAK,OAAO,CAAC;AACjD,CAAC;SAIe,YAAY,CAAC,KAAU,EAAE,aAAa,GAAG,CAAC;IACxD,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC;AAC9D,CAAC;AAED,SAAS,aAAa,CAAC,KAAU;IAC/B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5D;;;;","names":[],"sources":["src/utils/coerce.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport function coerceBoolean(value: any): boolean {\n return value != null && `${value}` !== 'false';\n}\n\nexport function coerceNumber(value: any): number;\nexport function coerceNumber<D>(value: any, fallback: D): number | D;\nexport function coerceNumber(value: any, fallbackValue = 0) {\n return isNumberValue(value) ? Number(value) : fallbackValue;\n}\n\nfunction isNumberValue(value: any): boolean {\n return !isNaN(parseFloat(value)) && !isNaN(Number(value));\n}\n"],"version":3}
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-acddba36.js';
2
- import { f as createErrorClass, O as Observable, g as errorContext, E as EMPTY_SUBSCRIPTION, S as Subscription, h as arrRemove, i as operate, j as createOperatorSubscriber, k as innerFrom, l as executeSchedule, m as isFunction, n as identity, p as from, q as popScheduler, r as isArrayLike, s as isScheduler, t as popNumber, u as noop, v as loglevel, b as catI18nRegistry, c as createCommonjsModule, a as commonjsGlobal, e as catIconRegistry, o as of } from './of-ec88a583.js';
2
+ import { f as createErrorClass, O as Observable, g as errorContext, E as EMPTY_SUBSCRIPTION, S as Subscription, h as arrRemove, i as operate, j as createOperatorSubscriber, k as innerFrom, l as executeSchedule, m as isFunction, n as identity, p as from, q as popScheduler, r as isArrayLike, s as isScheduler, t as popNumber, u as noop, v as loglevel, b as catI18nRegistry, c as createCommonjsModule, a as commonjsGlobal, e as catIconRegistry, o as of } from './of-4b71dda1.js';
3
3
 
4
4
  const ObjectUnsubscribedError = createErrorClass((_super) => function ObjectUnsubscribedErrorImpl() {
5
5
  _super(this);
@@ -7796,7 +7796,6 @@ const CatRadio = class {
7796
7796
  }
7797
7797
  onInput() {
7798
7798
  this.checked = true;
7799
- console.log('onInput', this.value);
7800
7799
  this.catChange.emit(this.value);
7801
7800
  }
7802
7801
  onFocus(event) {