@haiilo/catalyst 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.cdn.js +7 -3
- package/dist/catalyst/index.esm.js +9 -1
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-167f01e8.entry.js +2 -0
- package/dist/catalyst/p-167f01e8.entry.js.map +1 -0
- package/dist/catalyst/p-53a1db22.js +3 -0
- package/dist/catalyst/p-53a1db22.js.map +1 -0
- package/dist/catalyst/p-5865f232.js +2 -0
- package/dist/catalyst/p-5865f232.js.map +1 -0
- package/dist/catalyst/p-5bfc70e3.entry.js +2 -0
- package/dist/catalyst/{p-270fd91d.entry.js.map → p-5bfc70e3.entry.js.map} +1 -1
- package/dist/catalyst/scss/_variables.scss +1 -1
- package/dist/catalyst/scss/core/_form.scss +8 -0
- package/dist/catalyst/scss/core/_nav.scss +3 -3
- package/dist/catalyst/scss/core/_notification.scss +48 -0
- package/dist/catalyst/scss/index.scss +2 -1
- package/dist/catalyst/scss/utils/_typography.scss +4 -0
- package/dist/cjs/cat-alert_22.cjs.entry.js +358 -301
- package/dist/cjs/cat-alert_22.cjs.entry.js.map +1 -1
- package/dist/cjs/cat-icon-registry-2a54df3d.js +417 -0
- package/dist/cjs/cat-icon-registry-2a54df3d.js.map +1 -0
- package/dist/cjs/cat-modal.cjs.entry.js +2 -2
- package/dist/cjs/cat-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +2 -2
- package/dist/cjs/{index-b2134f1b.js → index-e540e911.js} +1 -4
- package/dist/cjs/index-e540e911.js.map +1 -0
- package/dist/cjs/index.cjs.js +528 -4
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/cat-button/cat-button.css +21 -63
- package/dist/collection/components/cat-button/cat-button.js +21 -4
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-card/cat-card.css +5 -4
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -4
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/{cat-menu/cat-menu.css → cat-dropdown/cat-dropdown.css} +23 -1
- package/dist/collection/components/{cat-menu/cat-menu.js → cat-dropdown/cat-dropdown.js} +122 -85
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -0
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +13 -38
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js +1 -0
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +1 -4
- package/dist/collection/components/cat-input/cat-input.js +4 -5
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-notification/cat-notification.js +61 -89
- package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.css +106 -0
- package/dist/collection/components/cat-pagination/cat-pagination.js +302 -0
- package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -0
- package/dist/collection/components/cat-radio/cat-radio.css +1 -4
- package/dist/collection/components/cat-radio/cat-radio.js +1 -1
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +3 -11
- package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.css +1 -4
- package/dist/collection/components/cat-select/cat-select.js +8 -9
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +4 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.css +2 -2
- package/dist/collection/components/cat-tabs/cat-tabs.js +2 -2
- package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +1 -4
- package/dist/collection/components/cat-textarea/cat-textarea.js +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.css +1 -4
- package/dist/collection/components/cat-toggle/cat-toggle.js +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/index.cdn.js +7 -3
- package/dist/collection/index.js +3 -3
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/scss/_variables.scss +1 -1
- package/dist/collection/scss/core/_form.scss +8 -0
- package/dist/collection/scss/core/_nav.scss +3 -3
- package/dist/collection/scss/core/_notification.scss +48 -0
- package/dist/collection/scss/index.scss +2 -1
- package/dist/collection/scss/utils/_typography.scss +4 -0
- package/dist/components/cat-button2.js +6 -5
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-card.js +1 -1
- package/dist/components/cat-card.js.map +1 -1
- package/dist/components/cat-checkbox2.js +2 -2
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/{cat-menu.d.ts → cat-dropdown.d.ts} +4 -4
- package/dist/components/cat-dropdown.js +8 -0
- package/dist/components/cat-dropdown.js.map +1 -0
- package/dist/components/cat-dropdown2.js +195 -0
- package/dist/components/cat-dropdown2.js.map +1 -0
- package/dist/components/cat-i18n-registry.js +14 -39
- package/dist/components/cat-i18n-registry.js.map +1 -1
- package/dist/components/cat-icon2.js +2 -1
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.js +5 -6
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/{cat-toast-demo.d.ts → cat-pagination.d.ts} +4 -4
- package/dist/components/cat-pagination.js +150 -0
- package/dist/components/cat-pagination.js.map +1 -0
- package/dist/components/cat-radio-group.js +3 -11
- package/dist/components/cat-radio-group.js.map +1 -1
- package/dist/components/cat-radio.js +2 -2
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-select-demo.js +13 -7
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +7 -8
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-tabs.js +3 -3
- package/dist/components/cat-tabs.js.map +1 -1
- package/dist/components/cat-textarea.js +2 -2
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +2 -2
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +531 -4
- package/dist/components/index.js.map +1 -1
- package/dist/esm/cat-alert_22.entry.js +355 -298
- package/dist/esm/cat-alert_22.entry.js.map +1 -1
- package/dist/esm/cat-icon-registry-d537b18b.js +409 -0
- package/dist/esm/cat-icon-registry-d537b18b.js.map +1 -0
- package/dist/esm/cat-modal.entry.js +2 -2
- package/dist/esm/cat-modal.entry.js.map +1 -1
- package/dist/esm/catalyst.js +2 -2
- package/dist/esm/{index-033048ed.js → index-c2a28ebb.js} +2 -4
- package/dist/esm/index-c2a28ebb.js.map +1 -0
- package/dist/esm/index.js +527 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/types/components/cat-button/cat-button.d.ts +4 -0
- package/dist/types/components/{cat-menu/cat-menu.d.ts → cat-dropdown/cat-dropdown.d.ts} +22 -11
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +4 -6
- package/dist/types/components/cat-icon/cat-icon-registry.d.ts +1 -0
- package/dist/types/components/cat-input/cat-input.d.ts +0 -1
- package/dist/types/components/cat-notification/cat-notification.d.ts +21 -48
- package/dist/types/components/cat-pagination/cat-pagination.d.ts +56 -0
- package/dist/types/components/cat-select/cat-select.d.ts +0 -1
- package/dist/types/components.d.ts +149 -53
- package/dist/types/index.d.ts +4 -4
- package/package.json +3 -3
- package/dist/catalyst/p-10b0d7a2.js +0 -10
- package/dist/catalyst/p-10b0d7a2.js.map +0 -1
- package/dist/catalyst/p-270fd91d.entry.js +0 -2
- package/dist/catalyst/p-3ad731e4.entry.js +0 -2
- package/dist/catalyst/p-3ad731e4.entry.js.map +0 -1
- package/dist/catalyst/p-692e49d6.js +0 -3
- package/dist/catalyst/p-692e49d6.js.map +0 -1
- package/dist/catalyst/scss/core/_toast.scss +0 -87
- package/dist/cjs/cat-notification-bcb9fb86.js +0 -990
- package/dist/cjs/cat-notification-bcb9fb86.js.map +0 -1
- package/dist/cjs/index-b2134f1b.js.map +0 -1
- package/dist/collection/components/cat-menu/cat-menu.js.map +0 -1
- package/dist/collection/components/cat-toast-demo/cat-toast-demo.css +0 -3
- package/dist/collection/components/cat-toast-demo/cat-toast-demo.js +0 -62
- package/dist/collection/components/cat-toast-demo/cat-toast-demo.js.map +0 -1
- package/dist/collection/scss/core/_toast.scss +0 -87
- package/dist/components/cat-menu.js +0 -174
- package/dist/components/cat-menu.js.map +0 -1
- package/dist/components/cat-toast-demo.js +0 -647
- package/dist/components/cat-toast-demo.js.map +0 -1
- package/dist/esm/cat-notification-8bcf6fa2.js +0 -985
- package/dist/esm/cat-notification-8bcf6fa2.js.map +0 -1
- package/dist/esm/index-033048ed.js.map +0 -1
- package/dist/types/components/cat-toast-demo/cat-toast-demo.d.ts +0 -9
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as catI18nRegistry } from './cat-i18n-registry.js';
|
|
3
|
+
import { d as defineCustomElement$4 } from './cat-button2.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './cat-icon2.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './cat-spinner2.js';
|
|
6
|
+
|
|
7
|
+
const catPaginationCss = ":host{display:inline-block}:host([hidden]){display:none}ol{display:flex;flex-wrap:wrap;list-style:none;margin:0;padding:0}li{display:inline-flex;justify-content:center}li.dots{-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([variant=outlined]) ol{gap:0.75rem}.cat-pagination-xs li.dots,.cat-pagination-xs li.text{height:1.5rem;line-height:1.5rem;font-size:0.875rem}.cat-pagination-xs li.dots{width:1.5rem}:host([variant=outlined]) .cat-pagination-xs{gap:0.375rem}.cat-pagination-s li.dots,.cat-pagination-s li.text{height:2rem;line-height:2rem;font-size:0.9375rem}.cat-pagination-s li.dots{width:2rem}:host([variant=outlined]) .cat-pagination-s{gap:0.5rem}.cat-pagination-m li.dots,.cat-pagination-m li.text{height:2.5rem;line-height:2.5rem;font-size:0.9375rem}.cat-pagination-m li.dots{width:2.5rem}:host([variant=outlined]) .cat-pagination-m{gap:0.625rem}.cat-pagination-l li.dots,.cat-pagination-l li.text{height:3rem;line-height:3rem;font-size:0.9375rem}.cat-pagination-l li.dots{width:3rem}:host([variant=outlined]) .cat-pagination-l{gap:0.75rem}.cat-pagination-xl li.dots,.cat-pagination-xl li.text{height:3.5rem;line-height:3.5rem;font-size:1.125rem}.cat-pagination-xl li.dots{width:3.5rem}:host([variant=outlined]) .cat-pagination-xl{gap:0.875rem}";
|
|
8
|
+
|
|
9
|
+
const CatPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.__registerHost();
|
|
13
|
+
this.__attachShadow();
|
|
14
|
+
/**
|
|
15
|
+
* The current page.
|
|
16
|
+
*/
|
|
17
|
+
this.page = 1;
|
|
18
|
+
/**
|
|
19
|
+
* The total number of pages.
|
|
20
|
+
*/
|
|
21
|
+
this.pageCount = 1;
|
|
22
|
+
/**
|
|
23
|
+
* The number of pages to be shown around the current page.
|
|
24
|
+
*/
|
|
25
|
+
this.activePadding = 1;
|
|
26
|
+
/**
|
|
27
|
+
* The number of pages to be shown at the edges.
|
|
28
|
+
*/
|
|
29
|
+
this.sidePadding = 1;
|
|
30
|
+
/**
|
|
31
|
+
* The size of the buttons.
|
|
32
|
+
*/
|
|
33
|
+
this.size = 'm';
|
|
34
|
+
/**
|
|
35
|
+
* The rendering style of the buttons.
|
|
36
|
+
*/
|
|
37
|
+
this.variant = 'text';
|
|
38
|
+
/**
|
|
39
|
+
* Use round button edges.
|
|
40
|
+
*/
|
|
41
|
+
this.round = false;
|
|
42
|
+
/**
|
|
43
|
+
* Use compact pagination mode.
|
|
44
|
+
*/
|
|
45
|
+
this.compact = false;
|
|
46
|
+
/**
|
|
47
|
+
* The icon of the "previous" button.
|
|
48
|
+
*/
|
|
49
|
+
this.iconPrev = 'chevron-left-outlined';
|
|
50
|
+
/**
|
|
51
|
+
* The icon of the "next" button.
|
|
52
|
+
*/
|
|
53
|
+
this.iconNext = 'chevron-right-outlined';
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
return (h("nav", { role: "navigation" }, h("ol", { class: {
|
|
57
|
+
[`cat-pagination-${this.size}`]: Boolean(this.size)
|
|
58
|
+
} }, h("li", null, h("cat-button", { variant: this.variant, size: this.size, round: this.round, disabled: this.isFirst, a11yLabel: catI18nRegistry.t('pagination.prev'), icon: this.iconPrev, iconOnly: true, onClick: () => (this.page = this.page - 1) })), this.content, h("li", null, h("cat-button", { variant: this.variant, size: this.size, round: this.round, disabled: this.isLast, a11yLabel: catI18nRegistry.t('pagination.next'), icon: this.iconNext, iconOnly: true, onClick: () => (this.page = this.page + 1) })))));
|
|
59
|
+
}
|
|
60
|
+
get isFirst() {
|
|
61
|
+
return this.page === 0;
|
|
62
|
+
}
|
|
63
|
+
get isLast() {
|
|
64
|
+
return this.page === this.pageCount - 1;
|
|
65
|
+
}
|
|
66
|
+
get pages() {
|
|
67
|
+
if (!this.sidePadding && !this.activePadding) {
|
|
68
|
+
return [this.page];
|
|
69
|
+
}
|
|
70
|
+
const result = new Set();
|
|
71
|
+
const minPage = this.page <= this.sidePadding + this.activePadding + 1;
|
|
72
|
+
const minActivepage = minPage ? this.sidePadding + 2 * this.activePadding + 2 : this.sidePadding;
|
|
73
|
+
const maxPage = this.page >= this.pageCount - this.sidePadding - this.activePadding - 2;
|
|
74
|
+
const maxActivepage = maxPage
|
|
75
|
+
? this.pageCount - this.sidePadding - 2 * this.activePadding - 2
|
|
76
|
+
: this.pageCount - this.sidePadding;
|
|
77
|
+
this.addSeq(result, 0, minActivepage);
|
|
78
|
+
if (!minPage && !maxPage) {
|
|
79
|
+
this.addSeq(result, this.page - this.activePadding, this.page + this.activePadding + 1);
|
|
80
|
+
}
|
|
81
|
+
this.addSeq(result, maxActivepage, this.pageCount);
|
|
82
|
+
return [...result];
|
|
83
|
+
}
|
|
84
|
+
addSeq(set, start, end) {
|
|
85
|
+
const _start = this.clamp(start, 0, this.pageCount);
|
|
86
|
+
const _end = this.clamp(end, 0, this.pageCount);
|
|
87
|
+
Array(_end - _start)
|
|
88
|
+
.fill(0)
|
|
89
|
+
.forEach((_, i) => set.add(_start + i));
|
|
90
|
+
}
|
|
91
|
+
clamp(num, min, max) {
|
|
92
|
+
return Math.min(Math.max(num, min), max);
|
|
93
|
+
}
|
|
94
|
+
get content() {
|
|
95
|
+
if (this.compact) {
|
|
96
|
+
return (h("li", { class: "text" }, this.page + 1, "/", this.pageCount));
|
|
97
|
+
}
|
|
98
|
+
return this.pages.map((page, i) => [
|
|
99
|
+
i > 0 && this.pages[i - 1] !== page - 1 ? h("li", { class: "dots" }, "\u2026") : null,
|
|
100
|
+
h("li", null, h("cat-button", { variant: this.variant, size: this.size, round: this.round, color: this.page === page ? 'primary' : undefined, active: this.page === page, a11yLabel: catI18nRegistry.t('pagination.page', { page: page + 1 }), a11yCurrent: this.page === page || undefined, onClick: () => (this.page = page) }, page + 1))
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
static get style() { return catPaginationCss; }
|
|
104
|
+
}, [1, "cat-pagination", {
|
|
105
|
+
"page": [1026],
|
|
106
|
+
"pageCount": [2, "page-count"],
|
|
107
|
+
"activePadding": [2, "active-padding"],
|
|
108
|
+
"sidePadding": [2, "side-padding"],
|
|
109
|
+
"size": [1],
|
|
110
|
+
"variant": [1],
|
|
111
|
+
"round": [4],
|
|
112
|
+
"compact": [4],
|
|
113
|
+
"iconPrev": [1, "icon-prev"],
|
|
114
|
+
"iconNext": [1, "icon-next"]
|
|
115
|
+
}]);
|
|
116
|
+
function defineCustomElement$1() {
|
|
117
|
+
if (typeof customElements === "undefined") {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const components = ["cat-pagination", "cat-button", "cat-icon", "cat-spinner"];
|
|
121
|
+
components.forEach(tagName => { switch (tagName) {
|
|
122
|
+
case "cat-pagination":
|
|
123
|
+
if (!customElements.get(tagName)) {
|
|
124
|
+
customElements.define(tagName, CatPagination$1);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case "cat-button":
|
|
128
|
+
if (!customElements.get(tagName)) {
|
|
129
|
+
defineCustomElement$4();
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
case "cat-icon":
|
|
133
|
+
if (!customElements.get(tagName)) {
|
|
134
|
+
defineCustomElement$3();
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case "cat-spinner":
|
|
138
|
+
if (!customElements.get(tagName)) {
|
|
139
|
+
defineCustomElement$2();
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
} });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const CatPagination = CatPagination$1;
|
|
146
|
+
const defineCustomElement = defineCustomElement$1;
|
|
147
|
+
|
|
148
|
+
export { CatPagination, defineCustomElement };
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=cat-pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"cat-pagination.js","mappings":";;;;;;AAAA,MAAM,gBAAgB,GAAG,+vCAA+vC;;MCe3wCA,eAAa;EAL1B;;;;;;;IAS2B,SAAI,GAAG,CAAC,CAAC;;;;IAK1B,cAA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AI,CAAC,IAAI,KAAK,IAAI,GAAG,SAAS,GAAG,SAAS,EACjD,MAAM,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI,EAC1B,SAAS,EAAEA,eAAI,CAAC,CAAC,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC,EACxD,WAAW,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,SAAS,EAC5C,OAAO,EAAE,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAEhC,IAAI,GAAG,CAAC,CACE,CACV;KACN,CAAC,CAAC;GACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatPagination","i18n"],"sources":["./src/components/cat-pagination/cat-pagination.scss?tag=cat-pagination&encapsulation=shadow","./src/components/cat-pagination/cat-pagination.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n@use 'sass:map';\n\n$button-sizes: (\n 'xl': 3.5rem,\n 'l': 3rem,\n 'm': 2.5rem,\n 's': 2rem,\n 'xs': 1.5rem\n);\n\n:host {\n display: inline-block;\n}\n\n:host([hidden]) {\n display: none;\n}\n\nol {\n display: flex;\n flex-wrap: wrap;\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\nli {\n display: inline-flex;\n justify-content: center;\n\n &.dots {\n @include cat-select(none);\n }\n}\n\n// ----- variant\n\n:host([variant='outlined']) {\n ol {\n gap: 0.75rem;\n }\n}\n\n// ----- size\n\n@mixin size($size, $fontSize) {\n .cat-pagination-#{$size} {\n li.dots,\n li.text {\n height: map.get($button-sizes, $size);\n line-height: map.get($button-sizes, $size);\n font-size: cat-body-font-size($fontSize);\n }\n\n li.dots {\n width: map.get($button-sizes, $size);\n }\n }\n\n :host([variant='outlined']) {\n .cat-pagination-#{$size} {\n gap: map.get($button-sizes, $size) * 0.25;\n }\n }\n}\n\n@include size('xs', 's');\n@include size('s', 'm');\n@include size('m', 'm');\n@include size('l', 'm');\n@include size('xl', 'l');\n","import { Component, h, Prop } from '@stencil/core';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n/**\n * A navigation component to switch between different pages of paged chunks of\n * data such as a table. Pagination is built with list HTML elements and a\n * wrapping `<nav>` element to identify it as a navigation section to screen\n * readers and other assistive technologies. Furthermore, the current page is\n * correctly highlighted using `aria-current`.\n */\n@Component({\n tag: 'cat-pagination',\n styleUrl: 'cat-pagination.scss',\n shadow: true\n})\nexport class CatPagination {\n /**\n * The current page.\n */\n @Prop({ mutable: true }) page = 1;\n\n /**\n * The total number of pages.\n */\n @Prop() pageCount = 1;\n\n /**\n * The number of pages to be shown around the current page.\n */\n @Prop() activePadding = 1;\n\n /**\n * The number of pages to be shown at the edges.\n */\n @Prop() sidePadding = 1;\n\n /**\n * The size of the buttons.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' = 'm';\n\n /**\n * The rendering style of the buttons.\n */\n @Prop() variant: 'filled' | 'outlined' | 'text' = 'text';\n\n /**\n * Use round button edges.\n */\n @Prop() round = false;\n\n /**\n * Use compact pagination mode.\n */\n @Prop() compact = false;\n\n /**\n * The icon of the \"previous\" button.\n */\n @Prop() iconPrev = 'chevron-left-outlined';\n\n /**\n * The icon of the \"next\" button.\n */\n @Prop() iconNext = 'chevron-right-outlined';\n\n render() {\n return (\n <nav role=\"navigation\">\n <ol\n class={{\n [`cat-pagination-${this.size}`]: Boolean(this.size)\n }}\n >\n <li>\n <cat-button\n variant={this.variant}\n size={this.size}\n round={this.round}\n disabled={this.isFirst}\n a11yLabel={i18n.t('pagination.prev')}\n icon={this.iconPrev}\n iconOnly\n onClick={() => (this.page = this.page - 1)}\n ></cat-button>\n </li>\n {this.content}\n <li>\n <cat-button\n variant={this.variant}\n size={this.size}\n round={this.round}\n disabled={this.isLast}\n a11yLabel={i18n.t('pagination.next')}\n icon={this.iconNext}\n iconOnly\n onClick={() => (this.page = this.page + 1)}\n ></cat-button>\n </li>\n </ol>\n </nav>\n );\n }\n\n get isFirst() {\n return this.page === 0;\n }\n\n get isLast() {\n return this.page === this.pageCount - 1;\n }\n\n get pages() {\n if (!this.sidePadding && !this.activePadding) {\n return [this.page];\n }\n\n const result = new Set<number>();\n const minPage = this.page <= this.sidePadding + this.activePadding + 1;\n const minActivepage = minPage ? this.sidePadding + 2 * this.activePadding + 2 : this.sidePadding;\n const maxPage = this.page >= this.pageCount - this.sidePadding - this.activePadding - 2;\n const maxActivepage = maxPage\n ? this.pageCount - this.sidePadding - 2 * this.activePadding - 2\n : this.pageCount - this.sidePadding;\n\n this.addSeq(result, 0, minActivepage);\n if (!minPage && !maxPage) {\n this.addSeq(result, this.page - this.activePadding, this.page + this.activePadding + 1);\n }\n this.addSeq(result, maxActivepage, this.pageCount);\n\n return [...result];\n }\n\n private addSeq(set: Set<number>, start: number, end: number) {\n const _start = this.clamp(start, 0, this.pageCount);\n const _end = this.clamp(end, 0, this.pageCount);\n Array(_end - _start)\n .fill(0)\n .forEach((_, i) => set.add(_start + i));\n }\n\n private clamp(num: number, min: number, max: number) {\n return Math.min(Math.max(num, min), max);\n }\n\n private get content() {\n if (this.compact) {\n return (\n <li class=\"text\">\n {this.page + 1}/{this.pageCount}\n </li>\n );\n }\n\n return this.pages.map((page, i) => [\n i > 0 && this.pages[i - 1] !== page - 1 ? <li class=\"dots\">…</li> : null,\n <li>\n <cat-button\n variant={this.variant}\n size={this.size}\n round={this.round}\n color={this.page === page ? 'primary' : undefined}\n active={this.page === page}\n a11yLabel={i18n.t('pagination.page', { page: page + 1 })}\n a11yCurrent={this.page === page || undefined}\n onClick={() => (this.page = page)}\n >\n {page + 1}\n </cat-button>\n </li>\n ]);\n }\n}\n"],"version":3}
|
|
@@ -20,22 +20,14 @@ const CatRadioGroup$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
20
20
|
this.labelLeft = false;
|
|
21
21
|
}
|
|
22
22
|
onNameChanged(newName) {
|
|
23
|
-
this.catRadioGroup.forEach(catRadio =>
|
|
24
|
-
catRadio.name = newName;
|
|
25
|
-
});
|
|
23
|
+
this.catRadioGroup.forEach(catRadio => (catRadio.name = newName));
|
|
26
24
|
}
|
|
27
25
|
onValueChanged(newValue) {
|
|
28
|
-
this.catRadioGroup.forEach(catRadio =>
|
|
29
|
-
catRadio.checked = catRadio.value === newValue;
|
|
30
|
-
});
|
|
26
|
+
this.catRadioGroup.forEach(catRadio => (catRadio.checked = catRadio.value === newValue));
|
|
31
27
|
this.updateTabIndex();
|
|
32
28
|
}
|
|
33
29
|
onDisabledChanged(disabled) {
|
|
34
|
-
this.catRadioGroup.forEach(catRadio =>
|
|
35
|
-
if (disabled) {
|
|
36
|
-
catRadio.disabled = disabled;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
30
|
+
this.catRadioGroup.forEach(catRadio => (catRadio.disabled = disabled));
|
|
39
31
|
}
|
|
40
32
|
onLabelLeftChanged(labelLeft) {
|
|
41
33
|
this.catRadioGroup.forEach(catRadio => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"cat-radio-group.js","mappings":";;AAAA,MAAM,gBAAgB,GAAG,mDAAmD;;MCU/DA,eAAa;EAL1B;;;;;;IAMU,kBAAa,GAA0B,EAAE,CAAC;;;;IAiB1C,aAAQ,GAAG,KAAK,CAAC;;;;IAWjB,cAAS,GAAG,KAAK,CAAC;
|
|
1
|
+
{"file":"cat-radio-group.js","mappings":";;AAAA,MAAM,gBAAgB,GAAG,mDAAmD;;MCU/DA,eAAa;EAL1B;;;;;;IAMU,kBAAa,GAA0B,EAAE,CAAC;;;;IAiB1C,aAAQ,GAAG,KAAK,CAAC;;;;IAWjB,cAAS,GAAG,KAAK,CAAC;GA2F3B;EA9EC,aAAa,CAAC,OAAgB;IAC5B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;GACnE;EAGD,cAAc,CAAC,QAAiB;I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AI,OAAA,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,aAAa,CAAC,OAAO,CAAC,0CAAE,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA,EAAA,CAAC,CAAC;MAC9G,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;MAC/E,MAAA,MAAA,IAAI,CAAC,aAAa,CAAC,iBAAiB,IAAI,CAAC,GAAG,iBAAiB,GAAG,CAAC,CAAC,CAAC,UAAU,0CACzE,aAAa,CAAC,OAAO,CAAC,0CACtB,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;KACnC;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CatRadioGroup"],"sources":["./src/components/cat-radio-group/cat-radio-group.scss?tag=cat-radio-group&encapsulation=shadow","./src/components/cat-radio-group/cat-radio-group.tsx"],"sourcesContent":["@use 'variables' as *;\n@use 'mixins' as *;\n\n:host {\n display: block;\n}\n\n:host([hidden]) {\n display: none;\n}\n","import { Component, Element, Event, EventEmitter, h, Listen, Prop, Watch } from '@stencil/core';\n\n/**\n * A group of radio buttons.\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 * The value of the radio group.\n */\n @Prop({ mutable: true }) value?: 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 /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the radio group loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('name')\n onNameChanged(newName?: string) {\n this.catRadioGroup.forEach(catRadio => (catRadio.name = newName));\n }\n\n @Watch('value')\n onValueChanged(newValue?: string) {\n this.catRadioGroup.forEach(catRadio => (catRadio.checked = catRadio.value === newValue));\n this.updateTabIndex();\n }\n\n @Watch('disabled')\n onDisabledChanged(disabled: boolean) {\n this.catRadioGroup.forEach(catRadio => (catRadio.disabled = disabled));\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.onValueChanged(this.value);\n this.onDisabledChanged(this.disabled);\n this.onLabelLeftChanged(this.labelLeft);\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 this.value = catRadioElement?.value;\n this.catChange.emit();\n }\n\n @Listen('blur', { capture: true })\n onBlur(event: FocusEvent): void {\n if (!event.relatedTarget) {\n this.catBlur.emit(event);\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"],"version":3}
|
|
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
|
|
|
2
2
|
import { l as loglevel } from './loglevel.js';
|
|
3
3
|
import { C as CatFormHint } from './cat-form-hint.js';
|
|
4
4
|
|
|
5
|
-
const catRadioCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host
|
|
5
|
+
const catRadioCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column;color:rgb(var(--cat-hint-color, inherit))}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);cursor:pointer}.label-left{flex-direction:row-reverse}.radio{display:flex;position:relative;align-self:flex-start}.circle{position:absolute;width:0.75rem;height:0.75rem;background-color:rgb(var(--cat-primary-bg, 0, 129, 148));border-radius:10rem;top:calc(50% - 0.375rem);left:calc(50% - 0.375rem);visibility:hidden;pointer-events:none}input{margin:0;width:1.25rem;height:1.25rem;appearance:none;background-color:white;border:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));border-radius:10rem;cursor:inherit}input:checked{border-color:rgb(var(--cat-primary-bg, 0, 129, 148))}input:checked+.circle{visibility:visible}input:focus-visible{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}:host(.cat-error) input{border-color:rgb(var(--cat-danger-bg, 217, 52, 13))}:host(.cat-error) .circle{background-color:rgb(var(--cat-danger-bg, 217, 52, 13))}.label{flex:1 1 auto}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.is-disabled input{background-color:#f2f4f7}.is-disabled input:checked{border-color:rgb(var(--cat-border-color-dark, 215, 219, 224))}.is-disabled .circle{background-color:rgb(var(--cat-border-color-dark, 215, 219, 224))}";
|
|
6
6
|
|
|
7
7
|
let nextUniqueId = 0;
|
|
8
8
|
const CatRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
@@ -43,7 +43,7 @@ const CatRadio$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
43
43
|
componentWillRender() {
|
|
44
44
|
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
45
45
|
if (!this.label && !this.hasSlottedLabel) {
|
|
46
|
-
loglevel.
|
|
46
|
+
loglevel.warn('[A11y] Missing ARIA label on radio', this);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"cat-radio.js","mappings":";;;;AAAA,MAAM,WAAW,GAAG,
|
|
1
|
+
{"file":"cat-radio.js","mappings":";;;;AAAA,MAAM,WAAW,GAAG,w5DAAw5D;;ACI56D,IAAI,YAAY,GAAG,CAAC,CAAC;MAeRA,UAAQ;EALrB;;;;;;;IAMmB,OAAE,GAAG,aAAa,EAAE,YAAY,EAAE,CAAC;IAK3C,oBAAe,GAAG,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AO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EACjC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAChC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAC9B,EACF,YAAM,KAAK,EAAC,QAAQ,GAAQ,CACvB,EACP,YAAM,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,OAAO,IAC7B,CAAC,IAAI,CAAC,eAAe,IAAI,YAAM,IAAI,EAAC,OAAO,GAAQ,KAAK,IAAI,CAAC,KAAK,CAC9D,CACD,EACP,IAAI,CAAC,WAAW,CACZ,EACP;GACH;EAED,IAAY,WAAW;IACrB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzE,QACE,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,MAC1B,EAAC,WAAW,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CAC3F,EACD;GACH;EAEO,QAAQ,CAAC,KAAY;IAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACpB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC5B;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC3B;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;GAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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:host {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n margin-bottom: $cat-body-margin-bottom;\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 {\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: 1.25rem;\n height: 1.25rem;\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.inputDisabled');\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 */\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() 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 /**\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.warn('[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.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"],"version":3}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import { d as defineCustomElement$
|
|
3
|
-
import { d as defineCustomElement$
|
|
4
|
-
import { d as defineCustomElement$
|
|
2
|
+
import { d as defineCustomElement$a } from './cat-avatar2.js';
|
|
3
|
+
import { d as defineCustomElement$9 } from './cat-button2.js';
|
|
4
|
+
import { d as defineCustomElement$8 } from './cat-checkbox2.js';
|
|
5
|
+
import { d as defineCustomElement$7 } from './cat-dropdown2.js';
|
|
5
6
|
import { d as defineCustomElement$6 } from './cat-icon2.js';
|
|
6
7
|
import { o as operate, c as createOperatorSubscriber, n as noop, m as map, a as mergeMap, d as defineCustomElement$5 } from './cat-scrollable2.js';
|
|
7
8
|
import { c as concat, t as take, a as asyncScheduler, b as timer, o as of, d as defineCustomElement$4 } from './cat-select2.js';
|
|
@@ -137,7 +138,7 @@ const CatSelectTest = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
137
138
|
(_f = this.singleSelectTagging) === null || _f === void 0 ? void 0 : _f.connect(this.countryConnector);
|
|
138
139
|
}
|
|
139
140
|
render() {
|
|
140
|
-
return (h(Host, { style: { display: 'flex', flexDirection: 'column' } }, h("cat-select", { label: "Multiple Select", hint: "This is a hint!", ref: el => (this.multipleSelect = el), value: ['1'], placeholder: "Hello World", onCatChange: () => { var _a; return console.log((_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.value); }, onCatBlur: e => console.log('Multiple blur', e), multiple: true, clearable: true }, h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), h("cat-select", { label: "Multiple with tagging support", hint: "This is a hint!", ref: el => (this.multipleSelectTagging = el), value: { ids: ['1'], tags: ['Test', 'Albania', 'Algeria'] }, placeholder: "Select country", onCatChange: () => { var _a; return console.log((_a = this.multipleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, multiple: true, tags: true, clearable: true }), h("cat-select", { label: "Single Select", hint: "This is a hint!", ref: el => (this.singleSelect = el), placeholder: "Search for a country or capital", onCatBlur: e => console.log('Single blur', e), clearable: true }), h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', onCatChange: () => { var _a; return console.log((_a = this.singleSelectAvatar) === null || _a === void 0 ? void 0 : _a.value); }, placeholder: "Search for a country or capital", clearable: true }), h("cat-select", { label: "Single with tagging support", ref: el => (this.singleSelectTagging = el), value: { id: '', tag: 'Albania' }, placeholder: "Search for a country or capital", onCatChange: () => { var _a; return console.log('Single', (_a = this.singleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, tagHint: "new country", tags: true, clearable: true })));
|
|
141
|
+
return (h(Host, { style: { display: 'flex', flexDirection: 'column' } }, h("cat-select", { label: "Multiple Select", hint: "This is a hint!", ref: el => (this.multipleSelect = el), value: ['1'], placeholder: "Hello World", onCatChange: () => { var _a; return console.log((_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.value); }, onCatBlur: e => console.log('Multiple blur', e), multiple: true, clearable: true }, h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), h("cat-select", { label: "Multiple with tagging support", hint: "This is a hint!", ref: el => (this.multipleSelectTagging = el), value: { ids: ['1'], tags: ['Test', 'Albania', 'Algeria'] }, placeholder: "Select country", onCatChange: () => { var _a; return console.log((_a = this.multipleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, multiple: true, tags: true, clearable: true }), h("cat-select", { label: "Single Select", hint: "This is a hint!", ref: el => (this.singleSelect = el), placeholder: "Search for a country or capital", onCatBlur: e => console.log('Single blur', e), clearable: true }), h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', onCatChange: () => { var _a; return console.log((_a = this.singleSelectAvatar) === null || _a === void 0 ? void 0 : _a.value); }, placeholder: "Search for a country or capital", clearable: true }), h("cat-dropdown", { overflow: true, noAutoClose: true }, h("cat-button", { slot: "trigger", style: { width: '50%' } }, "Open select"), h("div", { slot: "content", style: { width: '400px' } }, h("cat-select", { label: "Single with tagging support", ref: el => (this.singleSelectTagging = el), value: { id: '', tag: 'Albania' }, placeholder: "Search for a country or capital", onCatChange: () => { var _a; return console.log('Single', (_a = this.singleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, tagHint: "new country", tags: true, clearable: true, style: { width: '90%' } })))));
|
|
141
142
|
}
|
|
142
143
|
get countryConnector() {
|
|
143
144
|
return {
|
|
@@ -1389,7 +1390,7 @@ function defineCustomElement$1() {
|
|
|
1389
1390
|
if (typeof customElements === "undefined") {
|
|
1390
1391
|
return;
|
|
1391
1392
|
}
|
|
1392
|
-
const components = ["cat-select-demo", "cat-avatar", "cat-button", "cat-checkbox", "cat-icon", "cat-scrollable", "cat-select", "cat-skeleton", "cat-spinner"];
|
|
1393
|
+
const components = ["cat-select-demo", "cat-avatar", "cat-button", "cat-checkbox", "cat-dropdown", "cat-icon", "cat-scrollable", "cat-select", "cat-skeleton", "cat-spinner"];
|
|
1393
1394
|
components.forEach(tagName => { switch (tagName) {
|
|
1394
1395
|
case "cat-select-demo":
|
|
1395
1396
|
if (!customElements.get(tagName)) {
|
|
@@ -1398,15 +1399,20 @@ function defineCustomElement$1() {
|
|
|
1398
1399
|
break;
|
|
1399
1400
|
case "cat-avatar":
|
|
1400
1401
|
if (!customElements.get(tagName)) {
|
|
1401
|
-
defineCustomElement$
|
|
1402
|
+
defineCustomElement$a();
|
|
1402
1403
|
}
|
|
1403
1404
|
break;
|
|
1404
1405
|
case "cat-button":
|
|
1405
1406
|
if (!customElements.get(tagName)) {
|
|
1406
|
-
defineCustomElement$
|
|
1407
|
+
defineCustomElement$9();
|
|
1407
1408
|
}
|
|
1408
1409
|
break;
|
|
1409
1410
|
case "cat-checkbox":
|
|
1411
|
+
if (!customElements.get(tagName)) {
|
|
1412
|
+
defineCustomElement$8();
|
|
1413
|
+
}
|
|
1414
|
+
break;
|
|
1415
|
+
case "cat-dropdown":
|
|
1410
1416
|
if (!customElements.get(tagName)) {
|
|
1411
1417
|
defineCustomElement$7();
|
|
1412
1418
|
}
|