@haiilo/catalyst 0.9.0 → 0.10.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 (105) hide show
  1. package/dist/catalyst/catalyst.css +1 -1
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.esm.js +1 -1
  5. package/dist/catalyst/{p-6a8a4dc0.js → p-8121572a.js} +3 -3
  6. package/dist/catalyst/p-8121572a.js.map +1 -0
  7. package/dist/catalyst/p-942b9736.entry.js +12 -0
  8. package/dist/catalyst/p-942b9736.entry.js.map +1 -0
  9. package/dist/catalyst/scss/_variables.scss +2 -1
  10. package/dist/catalyst/scss/core/_typography.scss +7 -7
  11. package/dist/catalyst/scss/index.scss +1 -5
  12. package/dist/cjs/{cat-alert_20.cjs.entry.js → cat-alert_21.cjs.entry.js} +152 -30
  13. package/dist/cjs/cat-alert_21.cjs.entry.js.map +1 -0
  14. package/dist/cjs/{cat-notification-fe237312.js → cat-notification-c2859ed7.js} +121 -1
  15. package/dist/cjs/cat-notification-c2859ed7.js.map +1 -0
  16. package/dist/cjs/catalyst.cjs.js +1 -5
  17. package/dist/cjs/catalyst.cjs.js.map +1 -1
  18. package/dist/cjs/index.cjs.js +3 -4
  19. package/dist/cjs/index.cjs.js.map +1 -1
  20. package/dist/cjs/loader.cjs.js +1 -5
  21. package/dist/cjs/loader.cjs.js.map +1 -1
  22. package/dist/collection/collection-manifest.json +2 -2
  23. package/dist/collection/components/cat-button/cat-button.css +12 -11
  24. package/dist/collection/components/cat-card/cat-card.css +35 -1
  25. package/dist/collection/components/cat-checkbox/cat-checkbox.css +4 -0
  26. package/dist/collection/components/cat-checkbox/cat-checkbox.js +23 -1
  27. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  28. package/dist/collection/components/cat-i18n/cat-i18n-registry.js +3 -2
  29. package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
  30. package/dist/collection/components/cat-radio/cat-radio.css +7 -0
  31. package/dist/collection/components/cat-radio/cat-radio.js +25 -2
  32. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  33. package/dist/collection/components/cat-radio-group/cat-radio-group.css +12 -0
  34. package/dist/collection/components/cat-radio-group/cat-radio-group.js +179 -0
  35. package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -0
  36. package/dist/collection/components/cat-select/cat-select.css +35 -20
  37. package/dist/collection/components/cat-select/cat-select.js +54 -14
  38. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  39. package/dist/collection/components/cat-toggle/cat-toggle.css +4 -0
  40. package/dist/collection/components/cat-toggle/cat-toggle.js +25 -3
  41. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  42. package/dist/collection/index.js.map +1 -1
  43. package/dist/collection/scss/_variables.scss +2 -1
  44. package/dist/collection/scss/core/_typography.scss +7 -7
  45. package/dist/collection/scss/index.scss +1 -5
  46. package/dist/components/cat-button2.js +1 -1
  47. package/dist/components/cat-button2.js.map +1 -1
  48. package/dist/components/cat-card.js +1 -1
  49. package/dist/components/cat-card.js.map +1 -1
  50. package/dist/components/cat-checkbox.js +7 -2
  51. package/dist/components/cat-checkbox.js.map +1 -1
  52. package/dist/components/cat-i18n-registry.js +3 -2
  53. package/dist/components/cat-i18n-registry.js.map +1 -1
  54. package/dist/components/cat-radio-group.d.ts +11 -0
  55. package/dist/components/cat-radio-group.js +111 -0
  56. package/dist/components/cat-radio-group.js.map +1 -0
  57. package/dist/components/cat-radio.js +9 -3
  58. package/dist/components/cat-radio.js.map +1 -1
  59. package/dist/components/cat-select.js +41 -15
  60. package/dist/components/cat-select.js.map +1 -1
  61. package/dist/components/cat-toggle.js +8 -3
  62. package/dist/components/cat-toggle.js.map +1 -1
  63. package/dist/components/index.d.ts +1 -0
  64. package/dist/components/index.js +1 -253
  65. package/dist/components/index.js.map +1 -1
  66. package/dist/esm/{cat-alert_20.entry.js → cat-alert_21.entry.js} +149 -28
  67. package/dist/esm/cat-alert_21.entry.js.map +1 -0
  68. package/dist/esm/{cat-notification-a9655c00.js → cat-notification-3da6ddb1.js} +121 -3
  69. package/dist/esm/cat-notification-3da6ddb1.js.map +1 -0
  70. package/dist/esm/catalyst.js +1 -5
  71. package/dist/esm/catalyst.js.map +1 -1
  72. package/dist/esm/index.js +1 -2
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/loader.js +1 -5
  75. package/dist/esm/loader.js.map +1 -1
  76. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +4 -0
  77. package/dist/types/components/cat-radio/cat-radio.d.ts +4 -0
  78. package/dist/types/components/cat-radio-group/cat-radio-group.d.ts +29 -0
  79. package/dist/types/components/cat-select/cat-select.d.ts +7 -1
  80. package/dist/types/components/cat-toggle/cat-toggle.d.ts +5 -1
  81. package/dist/types/components.d.ts +75 -2
  82. package/dist/types/index.d.ts +1 -0
  83. package/package.json +2 -2
  84. package/dist/catalyst/p-0c1a611f.entry.js +0 -12
  85. package/dist/catalyst/p-0c1a611f.entry.js.map +0 -1
  86. package/dist/catalyst/p-6a8a4dc0.js.map +0 -1
  87. package/dist/catalyst/p-decdc6f1.js +0 -2
  88. package/dist/catalyst/p-decdc6f1.js.map +0 -1
  89. package/dist/catalyst/p-f45bcfd6.js +0 -2
  90. package/dist/catalyst/p-f45bcfd6.js.map +0 -1
  91. package/dist/cjs/app-globals-79765026.js +0 -256
  92. package/dist/cjs/app-globals-79765026.js.map +0 -1
  93. package/dist/cjs/cat-alert_20.cjs.entry.js.map +0 -1
  94. package/dist/cjs/cat-icon-registry-b015a65f.js +0 -125
  95. package/dist/cjs/cat-icon-registry-b015a65f.js.map +0 -1
  96. package/dist/cjs/cat-notification-fe237312.js.map +0 -1
  97. package/dist/collection/init.js +0 -17
  98. package/dist/collection/init.js.map +0 -1
  99. package/dist/esm/app-globals-7d163b94.js +0 -254
  100. package/dist/esm/app-globals-7d163b94.js.map +0 -1
  101. package/dist/esm/cat-alert_20.entry.js.map +0 -1
  102. package/dist/esm/cat-icon-registry-dc1ef79a.js +0 -122
  103. package/dist/esm/cat-icon-registry-dc1ef79a.js.map +0 -1
  104. package/dist/esm/cat-notification-a9655c00.js.map +0 -1
  105. package/dist/types/init.d.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"cat-checkbox.js","sourceRoot":"","sources":["../../../src/components/cat-checkbox/cat-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;GAQG;AAMH,MAAM,OAAO,WAAW;EALxB;IAMmB,OAAE,GAAG,gBAAgB,YAAY,EAAE,EAAE,CAAC;IAK9C,oBAAe,GAAG,KAAK,CAAC;IAEjC;;OAEG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,kBAAa,GAAG,KAAK,CAAC;IAE9B;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IAO5B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;GA0G1B;EA/EC,gBAAgB;IACd,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE;MACpC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;KACjC;EACH,CAAC;EAED,mBAAmB;IACjB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1E,IAAI,C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;;;;CACF","sourcesContent":["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 * Checkboxes are used to let a user choose one or more options from a limited\n * number of options.\n *\n * @slot hint - Optional hint element to be displayed with the checkbox.\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 checkbox - The checkbox element.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-checkbox',\n styleUrls: ['cat-checkbox.scss'],\n shadow: true\n})\nexport class CatCheckbox {\n private readonly id = `cat-checkbox-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Checked state of the checkbox\n */\n @Prop() checked = false;\n\n /**\n * Disabled state of the checkbox\n */\n @Prop() disabled = false;\n\n /**\n * Indeterminate state of the checkbox\n */\n @Prop() indeterminate = false;\n\n /**\n * Label of the checkbox which is presented in the UI\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 input\n */\n @Prop() name?: string;\n\n /**\n * Required state of the checkbox\n */\n @Prop() required = false;\n\n /**\n * The value of the checkbox\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the checkbox.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Emitted when the checked status of the checkbox is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the checkbox received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentDidLoad() {\n if (this.input && this.indeterminate) {\n this.input.indeterminate = true;\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on checkbox', this);\n }\n }\n\n /**\n * Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n render() {\n return (\n <Host>\n <label htmlFor={this.id} class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled }}>\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"checkbox\"\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 />\n <span class=\"box\" aria-hidden=\"true\" part=\"checkbox\">\n <svg class=\"check\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n <svg class=\"dash\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 5 10.5 5\"></polyline>\n </svg>\n </span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onInput(event: Event) {\n this.value = this.input.value;\n this.catChange.emit(event);\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"]}
1
+ {"version":3,"file":"cat-checkbox.js","sourceRoot":"","sources":["../../../src/components/cat-checkbox/cat-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAA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,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzE,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,CAAC,IAAI,CAC/B,EAAC,WAAW,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CAC3F,CACF,CAAC;EACJ,CAAC;EAEO,OAAO,CAAC,KAAY;IAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC7B,CAAC;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5B,CAAC;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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 * Checkboxes are used to let a user choose one or more options from a limited\n * number of options.\n *\n * @slot hint - Optional hint element to be displayed with the checkbox.\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 checkbox - The checkbox element.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-checkbox',\n styleUrls: ['cat-checkbox.scss'],\n shadow: true\n})\nexport class CatCheckbox {\n private readonly id = `cat-checkbox-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Checked state of the checkbox\n */\n @Prop() checked = false;\n\n /**\n * Disabled state of the checkbox\n */\n @Prop() disabled = false;\n\n /**\n * Indeterminate state of the checkbox\n */\n @Prop() indeterminate = false;\n\n /**\n * Label of the checkbox which is presented in the UI\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 input\n */\n @Prop() name?: string;\n\n /**\n * Required state of the checkbox\n */\n @Prop() required = false;\n\n /**\n * The value of the checkbox\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the checkbox.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Whether the label should appear to the left of the checkbox.\n */\n @Prop() labelLeft = false;\n\n /**\n * Emitted when the checked status of the checkbox is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the checkbox received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentDidLoad() {\n if (this.input && this.indeterminate) {\n this.input.indeterminate = true;\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on checkbox', this);\n }\n }\n\n /**\n * Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\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 >\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"checkbox\"\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 />\n <span class=\"box\" aria-hidden=\"true\" part=\"checkbox\">\n <svg class=\"check\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 6 4.5 9 10.5 1\"></polyline>\n </svg>\n <svg class=\"dash\" viewBox=\"0 0 12 10\">\n <polyline points=\"1.5 5 10.5 5\"></polyline>\n </svg>\n </span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onInput(event: Event) {\n this.value = this.input.value;\n this.catChange.emit(event);\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"]}
@@ -40,10 +40,11 @@ export class CatI18nRegistry {
40
40
  t(key, params) {
41
41
  var _a;
42
42
  const message = (_a = this._dicts.get(this._locale)) === null || _a === void 0 ? void 0 : _a.get(key);
43
- if (!message) {
43
+ if (message === undefined) {
44
44
  log.error(`[CatI18nRegistry] Unknown message for ${this._locale}: ${key}`);
45
+ return '';
45
46
  }
46
- return (message === null || message === void 0 ? void 0 : message.replace(/{{\s*([-a-zA-Z._]+)\s*}}/g, (_match, key) => { var _a; return `${(_a = params === null || params === void 0 ? void 0 : params[key]) !== null && _a !== void 0 ? _a : ''}`; })) || '';
47
+ return message.replace(/{{\s*([-a-zA-Z._]+)\s*}}/g, (_match, key) => { var _a; return `${(_a = params === null || params === void 0 ? void 0 : params[key]) !== null && _a !== void 0 ? _a : ''}`; });
47
48
  }
48
49
  buildEvent(name, detail) {
49
50
  return new CustomEvent(name, {
@@ -1 +1 @@
1
- {"version":3,"file":"cat-i18n-registry.js","sourceRoot":"","sources":["../../../src/components/cat-i18n/cat-i18n-registry.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,MAAM,OAAO,eAAe;EAM1B;IAHQ,YAAO,GAAG,IAAI,CAAC;IACN,WAAM,GAAqC,IAAI,GAAG,EAAE,CAAC;IAGpE,mBAAmB;EACrB,CAAC;EAED,MAAM,CAAC,WAAW;IAChB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;MAC7B,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;KAClD;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC;EAClC,CAAC;EAED,MAAM,CAAC,MAAe;IACpB,IAAI,MAAM,EAAE;MACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;MACtB,GAAG,CAAC,IAAI,CAAC,mCAAmC,MAAM,EAAE,CAAC,CAAC;MACtD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;KACtE;IACD,OAAO,IAAI,CAAC,OAAO,CAAC;EACtB,CAAC;EAED,QAAQ,CAAC,MAAc,EAAE,IAA+B;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE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E,CAAC;EACxG,CAAC;EAEO,UAAU,CAAI,IAAY,EAAE,MAAU;IAC5C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;MAC3B,OAAO,EAAE,IAAI;MACb,QAAQ,EAAE,IAAI;MACd,MAAM;KACP,CAAC,CAAC;EACL,CAAC;EAEO,OAAO,CAAC,IAAY;IAC1B,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE;MACT,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;MACjB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KAC7B;IACD,OAAO,IAAI,CAAC;EACd,CAAC;CACF","sourcesContent":["import log from 'loglevel';\n\nexport class CatI18nRegistry {\n private static instance: CatI18nRegistry;\n\n private _locale = 'en';\n private readonly _dicts: Map<string, Map<string, string>> = new Map();\n\n private constructor() {\n // hide constructor\n }\n\n static getInstance(): CatI18nRegistry {\n if (!CatI18nRegistry.instance) {\n CatI18nRegistry.instance = new CatI18nRegistry();\n }\n return CatI18nRegistry.instance;\n }\n\n locale(locale?: string): string {\n if (locale) {\n this._locale = locale;\n log.info(`[CatI18nRegistry] Locale set to ${locale}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-locale', { locale }));\n }\n return this._locale;\n }\n\n register(locale: string, i18n: { [key: string]: string }): void {\n const dict = this.getDict(locale);\n Object.entries(i18n).forEach(([key, message]) => dict.set(key, message));\n log.info(`[CatI18nRegistry] Registered messages for ${locale}`, i18n);\n window.dispatchEvent(this.buildEvent('cat-i18n-register', { i18n }));\n }\n\n clear(locale?: string): void {\n if (locale) {\n this.getDict(locale).clear();\n log.info(`[CatI18nRegistry] Cleared messages for ${locale}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-clear', { locale }));\n } else {\n this._dicts.clear();\n log.info(`[CatI18nRegistry] Cleared messages`);\n window.dispatchEvent(this.buildEvent('cat-i18n-clear'));\n }\n }\n\n t(key: string, params?: { [key: string]: string | number }): string {\n const message = this._dicts.get(this._locale)?.get(key);\n if (!message) {\n log.error(`[CatI18nRegistry] Unknown message for ${this._locale}: ${key}`);\n }\n return message?.replace(/{{\\s*([-a-zA-Z._]+)\\s*}}/g, (_match, key) => `${params?.[key] ?? ''}`) || '';\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 private getDict(lang: string) {\n let dict = this._dicts.get(lang);\n if (!dict) {\n dict = new Map();\n this._dicts.set(lang, dict);\n }\n return dict;\n }\n}\n"]}
1
+ {"version":3,"file":"cat-i18n-registry.js","sourceRoot":"","sources":["../../../src/components/cat-i18n/cat-i18n-registry.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,MAAM,OAAO,eAAe;EAM1B;IAHQ,YAAO,GAAG,IAAI,CAAC;IACN,WAAM,GAAqC,IAAI,GAAG,EAAE,CAAC;IAGpE,mBAAmB;EACrB,CAAC;EAED,MAAM,CAAC,WAAW;IAChB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;MAC7B,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;KAClD;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC;EAClC,CAAC;EAED,MAAM,CAAC,MAAe;IACpB,IAAI,MAAM,EAAE;MACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;MACtB,GAAG,CAAC,IAAI,CAAC,mCAAmC,MAAM,EAAE,CAAC,CAAC;MACtD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;KACtE;IACD,OAAO,IAAI,CAAC,OAAO,CAAC;EACtB,CAAC;EAED,QAAQ,CAAC,MAAc,EAAE,IAA+B;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OA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AC,2BAA2B,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,WAAC,OAAA,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,GAAG,CAAC,mCAAI,EAAE,EAAE,CAAA,EAAA,CAAC,CAAC;EACjG,CAAC;EAEO,UAAU,CAAI,IAAY,EAAE,MAAU;IAC5C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;MAC3B,OAAO,EAAE,IAAI;MACb,QAAQ,EAAE,IAAI;MACd,MAAM;KACP,CAAC,CAAC;EACL,CAAC;EAEO,OAAO,CAAC,IAAY;IAC1B,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE;MACT,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;MACjB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KAC7B;IACD,OAAO,IAAI,CAAC;EACd,CAAC;CACF","sourcesContent":["import log from 'loglevel';\n\nexport class CatI18nRegistry {\n private static instance: CatI18nRegistry;\n\n private _locale = 'en';\n private readonly _dicts: Map<string, Map<string, string>> = new Map();\n\n private constructor() {\n // hide constructor\n }\n\n static getInstance(): CatI18nRegistry {\n if (!CatI18nRegistry.instance) {\n CatI18nRegistry.instance = new CatI18nRegistry();\n }\n return CatI18nRegistry.instance;\n }\n\n locale(locale?: string): string {\n if (locale) {\n this._locale = locale;\n log.info(`[CatI18nRegistry] Locale set to ${locale}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-locale', { locale }));\n }\n return this._locale;\n }\n\n register(locale: string, i18n: { [key: string]: string }): void {\n const dict = this.getDict(locale);\n Object.entries(i18n).forEach(([key, message]) => dict.set(key, message));\n log.info(`[CatI18nRegistry] Registered messages for ${locale}`, i18n);\n window.dispatchEvent(this.buildEvent('cat-i18n-register', { i18n }));\n }\n\n clear(locale?: string): void {\n if (locale) {\n this.getDict(locale).clear();\n log.info(`[CatI18nRegistry] Cleared messages for ${locale}`);\n window.dispatchEvent(this.buildEvent('cat-i18n-clear', { locale }));\n } else {\n this._dicts.clear();\n log.info(`[CatI18nRegistry] Cleared messages`);\n window.dispatchEvent(this.buildEvent('cat-i18n-clear'));\n }\n }\n\n t(key: string, params?: { [key: string]: string | number }): string {\n const message = this._dicts.get(this._locale)?.get(key);\n if (message === undefined) {\n log.error(`[CatI18nRegistry] Unknown message for ${this._locale}: ${key}`);\n return '';\n }\n return message.replace(/{{\\s*([-a-zA-Z._]+)\\s*}}/g, (_match, key) => `${params?.[key] ?? ''}`);\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 private getDict(lang: string) {\n let dict = this._dicts.get(lang);\n if (!dict) {\n dict = new Map();\n this._dicts.set(lang, dict);\n }\n return dict;\n }\n}\n"]}
@@ -34,6 +34,10 @@ label {
34
34
  cursor: pointer;
35
35
  }
36
36
 
37
+ .label-left {
38
+ flex-direction: row-reverse;
39
+ }
40
+
37
41
  .radio {
38
42
  display: flex;
39
43
  position: relative;
@@ -71,6 +75,9 @@ input:focus-visible {
71
75
  outline-offset: 1px;
72
76
  }
73
77
 
78
+ .label {
79
+ flex: 1 1 auto;
80
+ }
74
81
  .is-hidden .label {
75
82
  position: absolute !important;
76
83
  width: 1px !important;
@@ -34,6 +34,10 @@ export class CatRadio {
34
34
  * Whether the radio is required.
35
35
  */
36
36
  this.required = false;
37
+ /**
38
+ * Whether the label should appear to the left of the radio component.
39
+ */
40
+ this.labelLeft = false;
37
41
  }
38
42
  componentWillRender() {
39
43
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
@@ -52,7 +56,7 @@ export class CatRadio {
52
56
  }
53
57
  render() {
54
58
  return (h(Host, null,
55
- h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
59
+ h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft }, role: "radio", "aria-checked": this.checked ? 'true' : 'false' },
56
60
  h("span", { class: "radio" },
57
61
  h("input", { ref: el => (this.input = el), id: this.id, type: "radio", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onChange.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
58
62
  h("span", { class: "circle" })),
@@ -64,6 +68,7 @@ export class CatRadio {
64
68
  return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
65
69
  }
66
70
  onChange(event) {
71
+ this.checked = true;
67
72
  this.value = this.input.value;
68
73
  this.catChange.emit(event);
69
74
  }
@@ -84,7 +89,7 @@ export class CatRadio {
84
89
  static get properties() { return {
85
90
  "checked": {
86
91
  "type": "boolean",
87
- "mutable": false,
92
+ "mutable": true,
88
93
  "complexType": {
89
94
  "original": "boolean",
90
95
  "resolved": "boolean",
@@ -222,6 +227,24 @@ export class CatRadio {
222
227
  },
223
228
  "attribute": "hint",
224
229
  "reflect": false
230
+ },
231
+ "labelLeft": {
232
+ "type": "boolean",
233
+ "mutable": false,
234
+ "complexType": {
235
+ "original": "boolean",
236
+ "resolved": "boolean",
237
+ "references": {}
238
+ },
239
+ "required": false,
240
+ "optional": false,
241
+ "docs": {
242
+ "tags": [],
243
+ "text": "Whether the label should appear to the left of the radio component."
244
+ },
245
+ "attribute": "label-left",
246
+ "reflect": false,
247
+ "defaultValue": "false"
225
248
  }
226
249
  }; }
227
250
  static get states() { return {
@@ -1 +1 @@
1
- {"version":3,"file":"cat-radio.js","sourceRoot":"","sources":["../../../src/components/cat-radio/cat-radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,C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,CAAC;EAC5B,CAAC;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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 */\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 input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Whether this radio is checked.\n */\n @Prop() checked = false;\n\n /**\n * Whether this radio is disabled.\n */\n @Prop() disabled = false;\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 @Prop({ mutable: true }) value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the radio.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Emitted when the radio is changed.\n */\n @Event() catChange!: EventEmitter;\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 if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on radio', this);\n }\n }\n\n /**\n * Sets focus on the radio. Use this method instead of `radio.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n render() {\n return (\n <Host>\n <label htmlFor={this.id} class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled }}>\n <span class=\"radio\">\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={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.onChange.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\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.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onChange(event: Event) {\n this.value = this.input.value;\n this.catChange.emit(event);\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"]}
1
+ {"version":3,"file":"cat-radio.js","sourceRoot":"","sources":["../../../src/components/cat-radio/cat-radio.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AAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CAC3F,CACF,CAAC;EACJ,CAAC;EAEO,QAAQ,CAAC,KAAY;IAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC7B,CAAC;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5B,CAAC;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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 */\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 input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = 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 * 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 @Prop({ mutable: true }) value?: string;\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 * Emitted when the radio is changed.\n */\n @Event() catChange!: EventEmitter;\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 if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on radio', this);\n }\n }\n\n /**\n * Sets focus on the radio. Use this method instead of `radio.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\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 ref={el => (this.input = el as HTMLInputElement)}\n id={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.onChange.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\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.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onChange(event: Event) {\n this.checked = true;\n this.value = this.input.value;\n this.catChange.emit(event);\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"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Auto-generated file. Do not edit directly.
3
+ */
4
+ /* stylelint-disable value-keyword-case */
5
+ /* stylelint-enable value-keyword-case */
6
+ :host {
7
+ display: block;
8
+ }
9
+
10
+ :host([hidden]) {
11
+ display: none;
12
+ }
@@ -0,0 +1,179 @@
1
+ import { Component, h, Prop, Element, Listen, Watch } from '@stencil/core';
2
+ export class CatRadioGroup {
3
+ constructor() {
4
+ this.catRadioGroup = [];
5
+ /**
6
+ * Whether this radio group is disabled.
7
+ */
8
+ this.disabled = false;
9
+ /**
10
+ * Whether the label of the radios should appear to the left of them.
11
+ */
12
+ this.labelLeft = false;
13
+ }
14
+ onNameChanged(newName) {
15
+ this.catRadioGroup.forEach(catRadio => {
16
+ catRadio.name = newName;
17
+ });
18
+ }
19
+ onDisabledChanged(disabled) {
20
+ this.catRadioGroup.forEach(catRadio => {
21
+ if (disabled) {
22
+ catRadio.disabled = disabled;
23
+ }
24
+ });
25
+ }
26
+ onLabelLeftChanged(labelLeft) {
27
+ this.catRadioGroup.forEach(catRadio => {
28
+ if (labelLeft) {
29
+ catRadio.labelLeft = labelLeft;
30
+ }
31
+ });
32
+ }
33
+ componentDidLoad() {
34
+ this.catRadioGroup = Array.from(this.hostElement.querySelectorAll(`cat-radio`));
35
+ this.onNameChanged(this.name);
36
+ this.onDisabledChanged(this.disabled);
37
+ this.onLabelLeftChanged(this.labelLeft);
38
+ this.updateTabIndex();
39
+ }
40
+ onKeydown(event) {
41
+ var _a, _b;
42
+ if (['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key) && this.catRadioGroup.length) {
43
+ const targetElements = this.catRadioGroup.filter(catRadio => !catRadio.disabled);
44
+ const activeElement = document.activeElement;
45
+ const activeIdx = this.catRadioGroup.findIndex(catRadio => catRadio === activeElement);
46
+ const activeOff = ['ArrowDown', 'ArrowRight'].includes(event.key) ? 1 : -1;
47
+ const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
48
+ targetElements[targetIdx].setFocus();
49
+ (_b = (_a = targetElements[targetIdx].shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === null || _b === void 0 ? void 0 : _b.click();
50
+ this.updateTabIndex();
51
+ event.preventDefault();
52
+ }
53
+ }
54
+ onInput(event) {
55
+ const catRadioElement = this.catRadioGroup.find(value => value === event.target);
56
+ if (catRadioElement && catRadioElement.checked) {
57
+ const catRadioElements = this.catRadioGroup.filter(value => value !== catRadioElement);
58
+ catRadioElements.forEach(value => (value.checked = false));
59
+ this.updateTabIndex();
60
+ }
61
+ }
62
+ render() {
63
+ return (h("div", { role: "radiogroup", "aria-label": this.a11yLabel },
64
+ h("slot", null)));
65
+ }
66
+ updateTabIndex() {
67
+ var _a, _b;
68
+ if (this.catRadioGroup.length) {
69
+ this.catRadioGroup.forEach(value => { var _a, _b; return (_b = (_a = value.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === null || _b === void 0 ? void 0 : _b.setAttribute('tabindex', '-1'); });
70
+ const checkedRadioIndex = this.catRadioGroup.findIndex(value => value.checked);
71
+ (_b = (_a = this.catRadioGroup[checkedRadioIndex >= 0 ? checkedRadioIndex : 0].shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === null || _b === void 0 ? void 0 : _b.setAttribute('tabindex', '0');
72
+ }
73
+ }
74
+ static get is() { return "cat-radio-group"; }
75
+ static get encapsulation() { return "shadow"; }
76
+ static get originalStyleUrls() { return {
77
+ "$": ["cat-radio-group.scss"]
78
+ }; }
79
+ static get styleUrls() { return {
80
+ "$": ["cat-radio-group.css"]
81
+ }; }
82
+ static get properties() { return {
83
+ "name": {
84
+ "type": "string",
85
+ "mutable": false,
86
+ "complexType": {
87
+ "original": "string",
88
+ "resolved": "string | undefined",
89
+ "references": {}
90
+ },
91
+ "required": false,
92
+ "optional": true,
93
+ "docs": {
94
+ "tags": [],
95
+ "text": "The name of the radio group component."
96
+ },
97
+ "attribute": "name",
98
+ "reflect": false
99
+ },
100
+ "disabled": {
101
+ "type": "boolean",
102
+ "mutable": false,
103
+ "complexType": {
104
+ "original": "boolean",
105
+ "resolved": "boolean",
106
+ "references": {}
107
+ },
108
+ "required": false,
109
+ "optional": false,
110
+ "docs": {
111
+ "tags": [],
112
+ "text": "Whether this radio group is disabled."
113
+ },
114
+ "attribute": "disabled",
115
+ "reflect": false,
116
+ "defaultValue": "false"
117
+ },
118
+ "a11yLabel": {
119
+ "type": "string",
120
+ "mutable": false,
121
+ "complexType": {
122
+ "original": "string",
123
+ "resolved": "string | undefined",
124
+ "references": {}
125
+ },
126
+ "required": false,
127
+ "optional": true,
128
+ "docs": {
129
+ "tags": [],
130
+ "text": "Adds an accessible label for the radio group that\nit is only shown in assistive technologies, like screen readers."
131
+ },
132
+ "attribute": "a11y-label",
133
+ "reflect": false
134
+ },
135
+ "labelLeft": {
136
+ "type": "boolean",
137
+ "mutable": false,
138
+ "complexType": {
139
+ "original": "boolean",
140
+ "resolved": "boolean",
141
+ "references": {}
142
+ },
143
+ "required": false,
144
+ "optional": false,
145
+ "docs": {
146
+ "tags": [],
147
+ "text": "Whether the label of the radios should appear to the left of them."
148
+ },
149
+ "attribute": "label-left",
150
+ "reflect": false,
151
+ "defaultValue": "false"
152
+ }
153
+ }; }
154
+ static get elementRef() { return "hostElement"; }
155
+ static get watchers() { return [{
156
+ "propName": "name",
157
+ "methodName": "onNameChanged"
158
+ }, {
159
+ "propName": "disabled",
160
+ "methodName": "onDisabledChanged"
161
+ }, {
162
+ "propName": "labelLeft",
163
+ "methodName": "onLabelLeftChanged"
164
+ }]; }
165
+ static get listeners() { return [{
166
+ "name": "keydown",
167
+ "method": "onKeydown",
168
+ "target": undefined,
169
+ "capture": false,
170
+ "passive": false
171
+ }, {
172
+ "name": "input",
173
+ "method": "onInput",
174
+ "target": undefined,
175
+ "capture": false,
176
+ "passive": false
177
+ }]; }
178
+ }
179
+ //# sourceMappingURL=cat-radio-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-radio-group.js","sourceRoot":"","sources":["../../../src/components/cat-radio-group/cat-radio-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAO3E,MAAM,OAAO,aAAa;EAL1B;IAMU,kBAAa,GAA0B,EAAE,CAAC;IASlD;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAQzB;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;GA6E3B;EA1EC,aAAa,CAAC,OAAgB;IAC5B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;MACpC,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC;IAC1B,CAAC,CAAC,CAAC;EACL,CAAC;EAGD,iBAAiB,CAAC,QAAiB;IACjC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;MACpC,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;OAC9B;IACH,CAAC,CAAC,CAAC;EACL,CAAC;EAGD,kBAAkB,CAAC,SAAkB;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BAAiB,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;MAC/E,MAAA,MAAA,IAAI,CAAC,aAAa,CAAC,iBAAiB,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,0CACzE,aAAa,CAAC,OAAO,CAAC,0CACtB,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;KACnC;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, Element, Listen, Watch } from '@stencil/core';\n\n@Component({\n tag: 'cat-radio-group',\n styleUrl: 'cat-radio-group.scss',\n shadow: true\n})\nexport class CatRadioGroup {\n private catRadioGroup: HTMLCatRadioElement[] = [];\n\n @Element() hostElement!: HTMLElement;\n\n /**\n * The name of the radio group component.\n */\n @Prop() name?: string;\n\n /**\n * Whether this radio group is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Adds an accessible label for the radio group that\n * it is only shown in assistive technologies, like screen readers.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n /**\n * Whether the label of the radios should appear to the left of them.\n */\n @Prop() labelLeft = false;\n\n @Watch('name')\n onNameChanged(newName?: string) {\n this.catRadioGroup.forEach(catRadio => {\n catRadio.name = newName;\n });\n }\n\n @Watch('disabled')\n onDisabledChanged(disabled: boolean) {\n this.catRadioGroup.forEach(catRadio => {\n if (disabled) {\n catRadio.disabled = disabled;\n }\n });\n }\n\n @Watch('labelLeft')\n onLabelLeftChanged(labelLeft: boolean) {\n this.catRadioGroup.forEach(catRadio => {\n if (labelLeft) {\n catRadio.labelLeft = labelLeft;\n }\n });\n }\n\n componentDidLoad(): void {\n this.catRadioGroup = Array.from(this.hostElement.querySelectorAll(`cat-radio`));\n this.onNameChanged(this.name);\n this.onDisabledChanged(this.disabled);\n this.onLabelLeftChanged(this.labelLeft);\n this.updateTabIndex();\n }\n\n @Listen('keydown')\n onKeydown(event: KeyboardEvent): void {\n if (['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key) && this.catRadioGroup.length) {\n const targetElements = this.catRadioGroup.filter(catRadio => !catRadio.disabled);\n const activeElement = document.activeElement as HTMLCatRadioElement;\n const activeIdx = this.catRadioGroup.findIndex(catRadio => catRadio === activeElement);\n const activeOff = ['ArrowDown', 'ArrowRight'].includes(event.key) ? 1 : -1;\n const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;\n targetElements[targetIdx].setFocus();\n targetElements[targetIdx].shadowRoot?.querySelector('input')?.click();\n this.updateTabIndex();\n event.preventDefault();\n }\n }\n\n @Listen('input')\n onInput(event: MouseEvent): void {\n const catRadioElement = this.catRadioGroup.find(value => value === event.target);\n if (catRadioElement && catRadioElement.checked) {\n const catRadioElements = this.catRadioGroup.filter(value => value !== catRadioElement);\n catRadioElements.forEach(value => (value.checked = false));\n this.updateTabIndex();\n }\n }\n\n render() {\n return (\n <div role=\"radiogroup\" aria-label={this.a11yLabel}>\n <slot></slot>\n </div>\n );\n }\n\n private updateTabIndex() {\n if (this.catRadioGroup.length) {\n this.catRadioGroup.forEach(value => value.shadowRoot?.querySelector('input')?.setAttribute('tabindex', '-1'));\n const checkedRadioIndex = this.catRadioGroup.findIndex(value => value.checked);\n this.catRadioGroup[checkedRadioIndex >= 0 ? checkedRadioIndex : 0].shadowRoot\n ?.querySelector('input')\n ?.setAttribute('tabindex', '0');\n }\n }\n}\n"]}
@@ -265,9 +265,6 @@ label.hidden {
265
265
  .choices[data-type*=select-one] {
266
266
  cursor: pointer;
267
267
  }
268
- .choices[data-type*=select-one] .choices__inner {
269
- padding-bottom: 7.5px;
270
- }
271
268
  .choices[data-type*=select-one] .choices__list--dropdown .choices__list {
272
269
  padding-top: 0.5rem;
273
270
  }
@@ -315,7 +312,7 @@ label.hidden {
315
312
  .choices[data-type*=select-one][dir=rtl] .choices__button {
316
313
  right: auto;
317
314
  left: 0;
318
- margin-left: 25px;
315
+ margin-left: 35px;
319
316
  margin-right: 0;
320
317
  }
321
318
 
@@ -323,9 +320,10 @@ label.hidden {
323
320
  .choices[data-type*=text] .choices__inner {
324
321
  cursor: text;
325
322
  display: flex;
326
- flex-direction: row;
323
+ flex-flow: row wrap;
327
324
  align-items: center;
328
- padding: 4px 60px 0 4px;
325
+ padding: 4px 60px 4px 4px;
326
+ gap: 4px;
329
327
  }
330
328
  .choices[data-type*=select-multiple] .choices__item cat-checkbox,
331
329
  .choices[data-type*=text] .choices__item cat-checkbox {
@@ -379,6 +377,18 @@ label.hidden {
379
377
  box-shadow: unset;
380
378
  background-color: transparent;
381
379
  }
380
+ .choices[data-type*=select-multiple][dir=rtl] .choices__inner,
381
+ .choices[data-type*=text][dir=rtl] .choices__inner {
382
+ padding-right: 4px;
383
+ padding-left: 60px;
384
+ }
385
+ .choices[data-type*=select-multiple][dir=rtl] cat-button,
386
+ .choices[data-type*=text][dir=rtl] cat-button {
387
+ right: auto;
388
+ left: 0;
389
+ margin-left: 25px;
390
+ margin-right: 0;
391
+ }
382
392
 
383
393
  .choices[data-type*=select-one]::after,
384
394
  .choices[data-type*=select-multiple]::after {
@@ -393,6 +403,11 @@ label.hidden {
393
403
  pointer-events: none;
394
404
  transition: transform 0.25s linear;
395
405
  }
406
+ .choices[data-type*=select-one][dir=rtl]::after,
407
+ .choices[data-type*=select-multiple][dir=rtl]::after {
408
+ left: 11.5px;
409
+ right: auto;
410
+ }
396
411
  .choices[data-type*=select-one].is-open::after,
397
412
  .choices[data-type*=select-multiple].is-open::after {
398
413
  transform: rotate(180deg);
@@ -404,7 +419,6 @@ label.hidden {
404
419
  vertical-align: top;
405
420
  width: 100%;
406
421
  background-color: #fff;
407
- padding: 7.5px 7.5px 3.75px;
408
422
  border: 1px solid #d7dbe0;
409
423
  border-radius: 4px;
410
424
  font-size: 15px;
@@ -424,21 +438,20 @@ label.hidden {
424
438
  list-style: none;
425
439
  }
426
440
  .choices__list--single {
427
- display: inline-block;
428
- padding: 4px 50px 4px 4px;
441
+ display: flex;
442
+ padding: 9px 50px 9px 12px;
429
443
  width: 100%;
430
444
  }
431
445
  [dir=rtl] .choices__list--single {
432
- padding-right: 4px;
433
- padding-left: 16px;
446
+ padding-right: 12px;
447
+ padding-left: 50px;
434
448
  }
435
449
  .choices__list--single .choices__item {
436
450
  width: 100%;
437
451
  }
438
452
 
439
453
  .choices__list--multiple {
440
- display: flex;
441
- flex-wrap: wrap;
454
+ display: contents;
442
455
  }
443
456
  .choices__list--multiple .choices__item {
444
457
  font-size: 0.9375rem;
@@ -448,9 +461,7 @@ label.hidden {
448
461
  align-items: center;
449
462
  justify-content: space-between;
450
463
  border-radius: 2px;
451
- padding: 5px 10px;
452
- margin-right: 4px;
453
- margin-bottom: 4px;
464
+ padding: 5px 8px 5px 4px;
454
465
  background-color: rgba(105, 118, 135, 0.1);
455
466
  color: #000;
456
467
  word-break: break-all;
@@ -483,7 +494,8 @@ label.hidden {
483
494
  word-break: break-all;
484
495
  will-change: visibility;
485
496
  box-shadow: 0 2px 4px 0 #101d3033;
486
- border-radius: 4px;
497
+ border-bottom-left-radius: 4px;
498
+ border-bottom-right-radius: 4px;
487
499
  }
488
500
  .is-active.choices__list--dropdown, .is-active.choices__list[aria-expanded] {
489
501
  visibility: visible;
@@ -515,9 +527,12 @@ label.hidden {
515
527
  text-align: right;
516
528
  }
517
529
  @media (min-width: 640px) {
518
- .choices__list--dropdown .choices__item--selectable, .choices__list[aria-expanded] .choices__item--selectable {
530
+ .choices__list--dropdown .choices__item--selectable[data-select-text]:not([data-select-text=""]), .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:not([data-select-text=""]) {
519
531
  padding-right: 100px;
520
532
  }
533
+ [dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:not([data-select-text=""]), [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:not([data-select-text=""]) {
534
+ padding-right: 10px;
535
+ }
521
536
  .choices__list--dropdown .choices__item--selectable::after, .choices__list[aria-expanded] .choices__item--selectable::after {
522
537
  content: attr(data-select-text);
523
538
  font-size: 12px;
@@ -530,7 +545,6 @@ label.hidden {
530
545
  [dir=rtl] .choices__list--dropdown .choices__item--selectable, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable {
531
546
  text-align: right;
532
547
  padding-left: 100px;
533
- padding-right: 10px;
534
548
  }
535
549
  [dir=rtl] .choices__list--dropdown .choices__item--selectable::after, [dir=rtl] .choices__list[aria-expanded] .choices__item--selectable::after {
536
550
  right: auto;
@@ -590,7 +604,7 @@ label.hidden {
590
604
  vertical-align: baseline;
591
605
  background-color: white;
592
606
  font-size: 15px;
593
- margin-bottom: 5px;
607
+ font-family: var(--cat-font-family-body, "Lato"), system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
594
608
  border: 0;
595
609
  border-radius: 0;
596
610
  max-width: 100%;
@@ -645,4 +659,5 @@ label.hidden {
645
659
  .choices-option-icon {
646
660
  width: 20px;
647
661
  aspect-ratio: 1;
662
+ border-radius: 0.125rem;
648
663
  }