@haiilo/catalyst 1.3.1 → 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-5865f232.js +2 -0
- package/dist/catalyst/p-5865f232.js.map +1 -0
- 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 +351 -290
- 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/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +528 -4
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- 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} +20 -0
- package/dist/collection/components/{cat-menu/cat-menu.js → cat-dropdown/cat-dropdown.js} +102 -87
- 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-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 +1 -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.js +2 -2
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-select-demo.js +6 -6
- 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 +348 -287
- 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/catalyst.js +1 -1
- package/dist/esm/index.js +527 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- 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} +19 -12
- 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 +145 -57
- 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-b561dcd4.entry.js +0 -2
- package/dist/catalyst/p-b561dcd4.entry.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/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 -8
- package/dist/components/cat-menu.js.map +0 -1
- package/dist/components/cat-menu2.js +0 -176
- package/dist/components/cat-menu2.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/types/components/cat-toast-demo/cat-toast-demo.d.ts +0 -9
|
@@ -1,105 +1,77 @@
|
|
|
1
1
|
import Toastify from 'toastify-js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
TypeIcons["info"] = "danger-filled";
|
|
7
|
-
TypeIcons["primary"] = "star-circle-filled";
|
|
8
|
-
TypeIcons["secondary"] = "info-circle-filled";
|
|
9
|
-
})(TypeIcons || (TypeIcons = {}));
|
|
10
|
-
export const ToastPositions = {
|
|
11
|
-
'top-left': {
|
|
12
|
-
gravity: 'top',
|
|
13
|
-
position: 'left'
|
|
14
|
-
},
|
|
15
|
-
'top-center': {
|
|
16
|
-
gravity: 'top',
|
|
17
|
-
position: 'center'
|
|
18
|
-
},
|
|
19
|
-
'top-right': {
|
|
20
|
-
gravity: 'top',
|
|
21
|
-
position: 'right'
|
|
22
|
-
},
|
|
23
|
-
'bottom-left': {
|
|
24
|
-
gravity: 'bottom',
|
|
25
|
-
position: 'left'
|
|
26
|
-
},
|
|
27
|
-
'bottom-center': {
|
|
28
|
-
gravity: 'bottom',
|
|
29
|
-
position: 'center'
|
|
30
|
-
},
|
|
31
|
-
'bottom-right': {
|
|
32
|
-
gravity: 'bottom',
|
|
33
|
-
position: 'right'
|
|
2
|
+
import { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';
|
|
3
|
+
export class CatNotificationService {
|
|
4
|
+
constructor() {
|
|
5
|
+
// hide constructor
|
|
34
6
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
success(title, message = ' ', options) {
|
|
42
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
43
|
-
Toastify(toastOptions).showToast();
|
|
44
|
-
}
|
|
45
|
-
info(title, message = ' ', options) {
|
|
46
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
47
|
-
Toastify(toastOptions).showToast();
|
|
48
|
-
}
|
|
49
|
-
primary(title, message = ' ', options) {
|
|
50
|
-
const toastOptions = this.extractOptions(title, message, options);
|
|
51
|
-
Toastify(toastOptions).showToast();
|
|
7
|
+
static getInstance() {
|
|
8
|
+
if (!CatNotificationService.instance) {
|
|
9
|
+
CatNotificationService.instance = new CatNotificationService();
|
|
10
|
+
}
|
|
11
|
+
return CatNotificationService.instance;
|
|
52
12
|
}
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
13
|
+
show(content, options) {
|
|
14
|
+
const ref = {};
|
|
15
|
+
const toastContent = this.getNode(content, ref, options);
|
|
16
|
+
const toastOptions = this.getOptions(toastContent, ref, options);
|
|
17
|
+
const toast = Toastify(toastOptions);
|
|
18
|
+
ref.toast = toast;
|
|
19
|
+
toast.showToast();
|
|
20
|
+
return () => toast.hideToast();
|
|
56
21
|
}
|
|
57
|
-
|
|
58
|
-
var _a;
|
|
22
|
+
getNode(content, ref, options) {
|
|
23
|
+
var _a, _b;
|
|
59
24
|
const template = document.createElement('template');
|
|
60
|
-
const typeIcon = (options === null || options === void 0 ? void 0 : options.type) ? TypeIcons[options.type] : TypeIcons.secondary;
|
|
61
|
-
title = title.trim();
|
|
62
|
-
message = message.trim();
|
|
63
|
-
const hasMessage = message && message !== '';
|
|
64
|
-
const hasMessageClass = hasMessage ? 'has-message' : '';
|
|
65
25
|
template.innerHTML = `<div class="cat-toastify-wrapper">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</div
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
26
|
+
${(options === null || options === void 0 ? void 0 : options.icon) ? `<cat-icon class="cat-toastify-icon" icon="${options.icon}" size="l"></cat-icon>` : ''}
|
|
27
|
+
<div class="cat-toastify-content">
|
|
28
|
+
<div class="cat-toastify-inner">${content}</div>
|
|
29
|
+
${(options === null || options === void 0 ? void 0 : options.action)
|
|
30
|
+
? `<cat-button class="cat-toastify-action cat-button-pull" size="s" variant="text" color="primary">${options.action}</cat-button>`
|
|
31
|
+
: ''}
|
|
32
|
+
</div>
|
|
33
|
+
${(options === null || options === void 0 ? void 0 : options.autoClose) === false
|
|
34
|
+
? `<cat-button class="cat-toastify-close cat-button-pull" size="s" icon="cross-outlined" variant="text" icon-only="true" class="close" a11y-label="${i18n.t('notification.dismiss')}"></cat-button>`
|
|
35
|
+
: ''}
|
|
36
|
+
</div>`;
|
|
37
|
+
const node = template.content.firstElementChild;
|
|
38
|
+
(_a = node.querySelector('.cat-toastify-close')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => { var _a; return (_a = ref.toast) === null || _a === void 0 ? void 0 : _a.hideToast(); });
|
|
39
|
+
(_b = node.querySelector('.cat-toastify-action')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', () => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.onAction) === null || _a === void 0 ? void 0 : _a.call(options, ref); });
|
|
40
|
+
const inner = node.querySelector('.cat-toastify-inner');
|
|
41
|
+
if (inner) {
|
|
42
|
+
if (typeof content !== 'string') {
|
|
43
|
+
inner.replaceChildren(content);
|
|
44
|
+
}
|
|
45
|
+
else if ((options === null || options === void 0 ? void 0 : options.escapeMarkup) === false) {
|
|
46
|
+
inner.innerHTML = content;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
inner.innerText = content;
|
|
50
|
+
}
|
|
83
51
|
}
|
|
84
|
-
return
|
|
52
|
+
return node;
|
|
85
53
|
}
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
getOptions(node, ref, options) {
|
|
55
|
+
var _a, _b, _c;
|
|
56
|
+
const [gravity, position] = ((_b = (_a = options === null || options === void 0 ? void 0 : options.position) === null || _a === void 0 ? void 0 : _a.split('-')) !== null && _b !== void 0 ? _b : ['bottom', 'left']);
|
|
57
|
+
const duration = (_c = options === null || options === void 0 ? void 0 : options.duration) !== null && _c !== void 0 ? _c : ((options === null || options === void 0 ? void 0 : options.autoClose) === false ? -1 : CatNotificationService.duration);
|
|
88
58
|
return {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
59
|
+
gravity,
|
|
60
|
+
position,
|
|
61
|
+
node,
|
|
62
|
+
duration,
|
|
63
|
+
close: false,
|
|
64
|
+
className: (options === null || options === void 0 ? void 0 : options.mode) === 'light' ? 'cat-toastify' : 'cat-toastify cat-toastify-dark',
|
|
95
65
|
stopOnFocus: true,
|
|
66
|
+
onClick: () => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.onClick) === null || _a === void 0 ? void 0 : _a.call(options, ref); },
|
|
67
|
+
callback: () => { var _a; return (_a = options === null || options === void 0 ? void 0 : options.onDismiss) === null || _a === void 0 ? void 0 : _a.call(options, ref); },
|
|
96
68
|
offset: {
|
|
97
|
-
x: '
|
|
98
|
-
y: '
|
|
69
|
+
x: '1rem',
|
|
70
|
+
y: '1rem'
|
|
99
71
|
}
|
|
100
72
|
};
|
|
101
73
|
}
|
|
102
74
|
}
|
|
103
|
-
CatNotificationService.
|
|
104
|
-
export const
|
|
75
|
+
CatNotificationService.duration = 3000;
|
|
76
|
+
export const catNotificationService = CatNotificationService.getInstance();
|
|
105
77
|
//# sourceMappingURL=cat-notification.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-notification.js","sourceRoot":"","sources":["../../../src/components/cat-notification/cat-notification.tsx"],"names":[],"mappings":"AAAA,OAAO,QAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"cat-notification.js","sourceRoot":"","sources":["../../../src/components/cat-notification/c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,QAAQ,0CAAE,KAAK,CAAC,GAAG,CAAC,mCAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAG/E,CAAC;IACF,MAAM,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,MAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAC5G,OAAO;MACL,OAAO;MACP,QAAQ;MACR,IAAI;MACJ,QAAQ;MACR,KAAK,EAAE,KAAK;MACZ,SAAS,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,gCAAgC;MACxF,WAAW,EAAE,IAAI;MACjB,OAAO,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,+CAAhB,OAAO,EAAY,GAAG,CAAC,CAAA,EAAA;MACtC,QAAQ,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,+CAAlB,OAAO,EAAc,GAAG,CAAC,CAAA,EAAA;MACzC,MAAM,EAAE;QACN,CAAC,EAAE,MAAM;QACT,CAAC,EAAE,MAAM;OACV;KACF,CAAC;EACJ,CAAC;;AAlFc,+BAAQ,GAAG,IAAI,CAAC;AAqFjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import Toastify, { Options } from 'toastify-js';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\ninterface ToastRef {\n toast?: {\n showToast: () => void;\n hideToast: () => void;\n };\n}\n\nexport interface ToastOptions {\n mode: 'dark' | 'light';\n icon: string;\n position: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';\n autoClose: boolean;\n duration: number;\n action: string;\n escapeMarkup: boolean;\n onAction: (toast: ToastRef) => void;\n onClick: (toast: ToastRef) => void;\n onDismiss: (toast: ToastRef) => void;\n}\n\nexport class CatNotificationService {\n private static instance: CatNotificationService;\n private static duration = 3000;\n\n private constructor() {\n // hide constructor\n }\n\n static getInstance(): CatNotificationService {\n if (!CatNotificationService.instance) {\n CatNotificationService.instance = new CatNotificationService();\n }\n return CatNotificationService.instance;\n }\n\n show(content: string | Node, options?: Partial<ToastOptions>): () => void {\n const ref: ToastRef = {};\n const toastContent = this.getNode(content, ref, options);\n const toastOptions = this.getOptions(toastContent, ref, options);\n const toast = Toastify(toastOptions);\n ref.toast = toast;\n toast.showToast();\n return () => toast.hideToast();\n }\n\n private getNode(content: string | Node, ref: ToastRef, options?: Partial<ToastOptions>): HTMLElement {\n const template = document.createElement('template');\n template.innerHTML = `<div class=\"cat-toastify-wrapper\">\n ${options?.icon ? `<cat-icon class=\"cat-toastify-icon\" icon=\"${options.icon}\" size=\"l\"></cat-icon>` : ''}\n <div class=\"cat-toastify-content\">\n <div class=\"cat-toastify-inner\">${content}</div>\n ${\n options?.action\n ? `<cat-button class=\"cat-toastify-action cat-button-pull\" size=\"s\" variant=\"text\" color=\"primary\">${options.action}</cat-button>`\n : ''\n }\n </div>\n ${\n options?.autoClose === false\n ? `<cat-button class=\"cat-toastify-close cat-button-pull\" size=\"s\" icon=\"cross-outlined\" variant=\"text\" icon-only=\"true\" class=\"close\" a11y-label=\"${i18n.t(\n 'notification.dismiss'\n )}\"></cat-button>`\n : ''\n }\n </div>`;\n\n const node = template.content.firstElementChild as HTMLElement;\n node.querySelector('.cat-toastify-close')?.addEventListener('click', () => ref.toast?.hideToast());\n node.querySelector('.cat-toastify-action')?.addEventListener('click', () => options?.onAction?.(ref));\n const inner = node.querySelector<HTMLDivElement>('.cat-toastify-inner');\n if (inner) {\n if (typeof content !== 'string') {\n inner.replaceChildren(content);\n } else if (options?.escapeMarkup === false) {\n inner.innerHTML = content;\n } else {\n inner.innerText = content;\n }\n }\n\n return node;\n }\n\n private getOptions(node: Node, ref: ToastRef, options?: Partial<ToastOptions>): Options {\n const [gravity, position] = (options?.position?.split('-') ?? ['bottom', 'left']) as [\n Options['gravity'],\n Options['position']\n ];\n const duration = options?.duration ?? (options?.autoClose === false ? -1 : CatNotificationService.duration);\n return {\n gravity,\n position,\n node,\n duration,\n close: false,\n className: options?.mode === 'light' ? 'cat-toastify' : 'cat-toastify cat-toastify-dark',\n stopOnFocus: true,\n onClick: () => options?.onClick?.(ref),\n callback: () => options?.onDismiss?.(ref),\n offset: {\n x: '1rem',\n y: '1rem'\n }\n };\n }\n}\n\nexport const catNotificationService = CatNotificationService.getInstance();\n"]}
|
|
@@ -0,0 +1,106 @@
|
|
|
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: inline-block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host([hidden]) {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
ol {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-wrap: wrap;
|
|
17
|
+
list-style: none;
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
li {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
li.dots {
|
|
27
|
+
/* stylelint-disable property-no-vendor-prefix */
|
|
28
|
+
-webkit-user-select: none;
|
|
29
|
+
-ms-user-select: none;
|
|
30
|
+
user-select: none;
|
|
31
|
+
/* stylelint-enable property-no-vendor-prefix */
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([variant=outlined]) ol {
|
|
35
|
+
gap: 0.75rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.cat-pagination-xs li.dots,
|
|
39
|
+
.cat-pagination-xs li.text {
|
|
40
|
+
height: 1.5rem;
|
|
41
|
+
line-height: 1.5rem;
|
|
42
|
+
font-size: 0.875rem;
|
|
43
|
+
}
|
|
44
|
+
.cat-pagination-xs li.dots {
|
|
45
|
+
width: 1.5rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host([variant=outlined]) .cat-pagination-xs {
|
|
49
|
+
gap: 0.375rem;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.cat-pagination-s li.dots,
|
|
53
|
+
.cat-pagination-s li.text {
|
|
54
|
+
height: 2rem;
|
|
55
|
+
line-height: 2rem;
|
|
56
|
+
font-size: 0.9375rem;
|
|
57
|
+
}
|
|
58
|
+
.cat-pagination-s li.dots {
|
|
59
|
+
width: 2rem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
:host([variant=outlined]) .cat-pagination-s {
|
|
63
|
+
gap: 0.5rem;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.cat-pagination-m li.dots,
|
|
67
|
+
.cat-pagination-m li.text {
|
|
68
|
+
height: 2.5rem;
|
|
69
|
+
line-height: 2.5rem;
|
|
70
|
+
font-size: 0.9375rem;
|
|
71
|
+
}
|
|
72
|
+
.cat-pagination-m li.dots {
|
|
73
|
+
width: 2.5rem;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([variant=outlined]) .cat-pagination-m {
|
|
77
|
+
gap: 0.625rem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.cat-pagination-l li.dots,
|
|
81
|
+
.cat-pagination-l li.text {
|
|
82
|
+
height: 3rem;
|
|
83
|
+
line-height: 3rem;
|
|
84
|
+
font-size: 0.9375rem;
|
|
85
|
+
}
|
|
86
|
+
.cat-pagination-l li.dots {
|
|
87
|
+
width: 3rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:host([variant=outlined]) .cat-pagination-l {
|
|
91
|
+
gap: 0.75rem;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.cat-pagination-xl li.dots,
|
|
95
|
+
.cat-pagination-xl li.text {
|
|
96
|
+
height: 3.5rem;
|
|
97
|
+
line-height: 3.5rem;
|
|
98
|
+
font-size: 1.125rem;
|
|
99
|
+
}
|
|
100
|
+
.cat-pagination-xl li.dots {
|
|
101
|
+
width: 3.5rem;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:host([variant=outlined]) .cat-pagination-xl {
|
|
105
|
+
gap: 0.875rem;
|
|
106
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { Component, h, Prop } from '@stencil/core';
|
|
2
|
+
import { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';
|
|
3
|
+
/**
|
|
4
|
+
* A navigation component to switch between different pages of paged chunks of
|
|
5
|
+
* data such as a table. Pagination is built with list HTML elements and a
|
|
6
|
+
* wrapping `<nav>` element to identify it as a navigation section to screen
|
|
7
|
+
* readers and other assistive technologies. Furthermore, the current page is
|
|
8
|
+
* correctly highlighted using `aria-current`.
|
|
9
|
+
*/
|
|
10
|
+
export class CatPagination {
|
|
11
|
+
constructor() {
|
|
12
|
+
/**
|
|
13
|
+
* The current page.
|
|
14
|
+
*/
|
|
15
|
+
this.page = 1;
|
|
16
|
+
/**
|
|
17
|
+
* The total number of pages.
|
|
18
|
+
*/
|
|
19
|
+
this.pageCount = 1;
|
|
20
|
+
/**
|
|
21
|
+
* The number of pages to be shown around the current page.
|
|
22
|
+
*/
|
|
23
|
+
this.activePadding = 1;
|
|
24
|
+
/**
|
|
25
|
+
* The number of pages to be shown at the edges.
|
|
26
|
+
*/
|
|
27
|
+
this.sidePadding = 1;
|
|
28
|
+
/**
|
|
29
|
+
* The size of the buttons.
|
|
30
|
+
*/
|
|
31
|
+
this.size = 'm';
|
|
32
|
+
/**
|
|
33
|
+
* The rendering style of the buttons.
|
|
34
|
+
*/
|
|
35
|
+
this.variant = 'text';
|
|
36
|
+
/**
|
|
37
|
+
* Use round button edges.
|
|
38
|
+
*/
|
|
39
|
+
this.round = false;
|
|
40
|
+
/**
|
|
41
|
+
* Use compact pagination mode.
|
|
42
|
+
*/
|
|
43
|
+
this.compact = false;
|
|
44
|
+
/**
|
|
45
|
+
* The icon of the "previous" button.
|
|
46
|
+
*/
|
|
47
|
+
this.iconPrev = 'chevron-left-outlined';
|
|
48
|
+
/**
|
|
49
|
+
* The icon of the "next" button.
|
|
50
|
+
*/
|
|
51
|
+
this.iconNext = 'chevron-right-outlined';
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
return (h("nav", { role: "navigation" },
|
|
55
|
+
h("ol", { class: {
|
|
56
|
+
[`cat-pagination-${this.size}`]: Boolean(this.size)
|
|
57
|
+
} },
|
|
58
|
+
h("li", null,
|
|
59
|
+
h("cat-button", { variant: this.variant, size: this.size, round: this.round, disabled: this.isFirst, a11yLabel: i18n.t('pagination.prev'), icon: this.iconPrev, iconOnly: true, onClick: () => (this.page = this.page - 1) })),
|
|
60
|
+
this.content,
|
|
61
|
+
h("li", null,
|
|
62
|
+
h("cat-button", { variant: this.variant, size: this.size, round: this.round, disabled: this.isLast, a11yLabel: i18n.t('pagination.next'), icon: this.iconNext, iconOnly: true, onClick: () => (this.page = this.page + 1) })))));
|
|
63
|
+
}
|
|
64
|
+
get isFirst() {
|
|
65
|
+
return this.page === 0;
|
|
66
|
+
}
|
|
67
|
+
get isLast() {
|
|
68
|
+
return this.page === this.pageCount - 1;
|
|
69
|
+
}
|
|
70
|
+
get pages() {
|
|
71
|
+
if (!this.sidePadding && !this.activePadding) {
|
|
72
|
+
return [this.page];
|
|
73
|
+
}
|
|
74
|
+
const result = new Set();
|
|
75
|
+
const minPage = this.page <= this.sidePadding + this.activePadding + 1;
|
|
76
|
+
const minActivepage = minPage ? this.sidePadding + 2 * this.activePadding + 2 : this.sidePadding;
|
|
77
|
+
const maxPage = this.page >= this.pageCount - this.sidePadding - this.activePadding - 2;
|
|
78
|
+
const maxActivepage = maxPage
|
|
79
|
+
? this.pageCount - this.sidePadding - 2 * this.activePadding - 2
|
|
80
|
+
: this.pageCount - this.sidePadding;
|
|
81
|
+
this.addSeq(result, 0, minActivepage);
|
|
82
|
+
if (!minPage && !maxPage) {
|
|
83
|
+
this.addSeq(result, this.page - this.activePadding, this.page + this.activePadding + 1);
|
|
84
|
+
}
|
|
85
|
+
this.addSeq(result, maxActivepage, this.pageCount);
|
|
86
|
+
return [...result];
|
|
87
|
+
}
|
|
88
|
+
addSeq(set, start, end) {
|
|
89
|
+
const _start = this.clamp(start, 0, this.pageCount);
|
|
90
|
+
const _end = this.clamp(end, 0, this.pageCount);
|
|
91
|
+
Array(_end - _start)
|
|
92
|
+
.fill(0)
|
|
93
|
+
.forEach((_, i) => set.add(_start + i));
|
|
94
|
+
}
|
|
95
|
+
clamp(num, min, max) {
|
|
96
|
+
return Math.min(Math.max(num, min), max);
|
|
97
|
+
}
|
|
98
|
+
get content() {
|
|
99
|
+
if (this.compact) {
|
|
100
|
+
return (h("li", { class: "text" },
|
|
101
|
+
this.page + 1,
|
|
102
|
+
"/",
|
|
103
|
+
this.pageCount));
|
|
104
|
+
}
|
|
105
|
+
return this.pages.map((page, i) => [
|
|
106
|
+
i > 0 && this.pages[i - 1] !== page - 1 ? h("li", { class: "dots" }, "\u2026") : null,
|
|
107
|
+
h("li", null,
|
|
108
|
+
h("cat-button", { variant: this.variant, size: this.size, round: this.round, color: this.page === page ? 'primary' : undefined, active: this.page === page, a11yLabel: i18n.t('pagination.page', { page: page + 1 }), a11yCurrent: this.page === page || undefined, onClick: () => (this.page = page) }, page + 1))
|
|
109
|
+
]);
|
|
110
|
+
}
|
|
111
|
+
static get is() { return "cat-pagination"; }
|
|
112
|
+
static get encapsulation() { return "shadow"; }
|
|
113
|
+
static get originalStyleUrls() { return {
|
|
114
|
+
"$": ["cat-pagination.scss"]
|
|
115
|
+
}; }
|
|
116
|
+
static get styleUrls() { return {
|
|
117
|
+
"$": ["cat-pagination.css"]
|
|
118
|
+
}; }
|
|
119
|
+
static get properties() { return {
|
|
120
|
+
"page": {
|
|
121
|
+
"type": "number",
|
|
122
|
+
"mutable": true,
|
|
123
|
+
"complexType": {
|
|
124
|
+
"original": "number",
|
|
125
|
+
"resolved": "number",
|
|
126
|
+
"references": {}
|
|
127
|
+
},
|
|
128
|
+
"required": false,
|
|
129
|
+
"optional": false,
|
|
130
|
+
"docs": {
|
|
131
|
+
"tags": [],
|
|
132
|
+
"text": "The current page."
|
|
133
|
+
},
|
|
134
|
+
"attribute": "page",
|
|
135
|
+
"reflect": false,
|
|
136
|
+
"defaultValue": "1"
|
|
137
|
+
},
|
|
138
|
+
"pageCount": {
|
|
139
|
+
"type": "number",
|
|
140
|
+
"mutable": false,
|
|
141
|
+
"complexType": {
|
|
142
|
+
"original": "number",
|
|
143
|
+
"resolved": "number",
|
|
144
|
+
"references": {}
|
|
145
|
+
},
|
|
146
|
+
"required": false,
|
|
147
|
+
"optional": false,
|
|
148
|
+
"docs": {
|
|
149
|
+
"tags": [],
|
|
150
|
+
"text": "The total number of pages."
|
|
151
|
+
},
|
|
152
|
+
"attribute": "page-count",
|
|
153
|
+
"reflect": false,
|
|
154
|
+
"defaultValue": "1"
|
|
155
|
+
},
|
|
156
|
+
"activePadding": {
|
|
157
|
+
"type": "number",
|
|
158
|
+
"mutable": false,
|
|
159
|
+
"complexType": {
|
|
160
|
+
"original": "number",
|
|
161
|
+
"resolved": "number",
|
|
162
|
+
"references": {}
|
|
163
|
+
},
|
|
164
|
+
"required": false,
|
|
165
|
+
"optional": false,
|
|
166
|
+
"docs": {
|
|
167
|
+
"tags": [],
|
|
168
|
+
"text": "The number of pages to be shown around the current page."
|
|
169
|
+
},
|
|
170
|
+
"attribute": "active-padding",
|
|
171
|
+
"reflect": false,
|
|
172
|
+
"defaultValue": "1"
|
|
173
|
+
},
|
|
174
|
+
"sidePadding": {
|
|
175
|
+
"type": "number",
|
|
176
|
+
"mutable": false,
|
|
177
|
+
"complexType": {
|
|
178
|
+
"original": "number",
|
|
179
|
+
"resolved": "number",
|
|
180
|
+
"references": {}
|
|
181
|
+
},
|
|
182
|
+
"required": false,
|
|
183
|
+
"optional": false,
|
|
184
|
+
"docs": {
|
|
185
|
+
"tags": [],
|
|
186
|
+
"text": "The number of pages to be shown at the edges."
|
|
187
|
+
},
|
|
188
|
+
"attribute": "side-padding",
|
|
189
|
+
"reflect": false,
|
|
190
|
+
"defaultValue": "1"
|
|
191
|
+
},
|
|
192
|
+
"size": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"mutable": false,
|
|
195
|
+
"complexType": {
|
|
196
|
+
"original": "'xs' | 's' | 'm' | 'l' | 'xl'",
|
|
197
|
+
"resolved": "\"l\" | \"m\" | \"s\" | \"xl\" | \"xs\"",
|
|
198
|
+
"references": {}
|
|
199
|
+
},
|
|
200
|
+
"required": false,
|
|
201
|
+
"optional": false,
|
|
202
|
+
"docs": {
|
|
203
|
+
"tags": [],
|
|
204
|
+
"text": "The size of the buttons."
|
|
205
|
+
},
|
|
206
|
+
"attribute": "size",
|
|
207
|
+
"reflect": false,
|
|
208
|
+
"defaultValue": "'m'"
|
|
209
|
+
},
|
|
210
|
+
"variant": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"mutable": false,
|
|
213
|
+
"complexType": {
|
|
214
|
+
"original": "'filled' | 'outlined' | 'text'",
|
|
215
|
+
"resolved": "\"filled\" | \"outlined\" | \"text\"",
|
|
216
|
+
"references": {}
|
|
217
|
+
},
|
|
218
|
+
"required": false,
|
|
219
|
+
"optional": false,
|
|
220
|
+
"docs": {
|
|
221
|
+
"tags": [],
|
|
222
|
+
"text": "The rendering style of the buttons."
|
|
223
|
+
},
|
|
224
|
+
"attribute": "variant",
|
|
225
|
+
"reflect": false,
|
|
226
|
+
"defaultValue": "'text'"
|
|
227
|
+
},
|
|
228
|
+
"round": {
|
|
229
|
+
"type": "boolean",
|
|
230
|
+
"mutable": false,
|
|
231
|
+
"complexType": {
|
|
232
|
+
"original": "boolean",
|
|
233
|
+
"resolved": "boolean",
|
|
234
|
+
"references": {}
|
|
235
|
+
},
|
|
236
|
+
"required": false,
|
|
237
|
+
"optional": false,
|
|
238
|
+
"docs": {
|
|
239
|
+
"tags": [],
|
|
240
|
+
"text": "Use round button edges."
|
|
241
|
+
},
|
|
242
|
+
"attribute": "round",
|
|
243
|
+
"reflect": false,
|
|
244
|
+
"defaultValue": "false"
|
|
245
|
+
},
|
|
246
|
+
"compact": {
|
|
247
|
+
"type": "boolean",
|
|
248
|
+
"mutable": false,
|
|
249
|
+
"complexType": {
|
|
250
|
+
"original": "boolean",
|
|
251
|
+
"resolved": "boolean",
|
|
252
|
+
"references": {}
|
|
253
|
+
},
|
|
254
|
+
"required": false,
|
|
255
|
+
"optional": false,
|
|
256
|
+
"docs": {
|
|
257
|
+
"tags": [],
|
|
258
|
+
"text": "Use compact pagination mode."
|
|
259
|
+
},
|
|
260
|
+
"attribute": "compact",
|
|
261
|
+
"reflect": false,
|
|
262
|
+
"defaultValue": "false"
|
|
263
|
+
},
|
|
264
|
+
"iconPrev": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"mutable": false,
|
|
267
|
+
"complexType": {
|
|
268
|
+
"original": "string",
|
|
269
|
+
"resolved": "string",
|
|
270
|
+
"references": {}
|
|
271
|
+
},
|
|
272
|
+
"required": false,
|
|
273
|
+
"optional": false,
|
|
274
|
+
"docs": {
|
|
275
|
+
"tags": [],
|
|
276
|
+
"text": "The icon of the \"previous\" button."
|
|
277
|
+
},
|
|
278
|
+
"attribute": "icon-prev",
|
|
279
|
+
"reflect": false,
|
|
280
|
+
"defaultValue": "'chevron-left-outlined'"
|
|
281
|
+
},
|
|
282
|
+
"iconNext": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"mutable": false,
|
|
285
|
+
"complexType": {
|
|
286
|
+
"original": "string",
|
|
287
|
+
"resolved": "string",
|
|
288
|
+
"references": {}
|
|
289
|
+
},
|
|
290
|
+
"required": false,
|
|
291
|
+
"optional": false,
|
|
292
|
+
"docs": {
|
|
293
|
+
"tags": [],
|
|
294
|
+
"text": "The icon of the \"next\" button."
|
|
295
|
+
},
|
|
296
|
+
"attribute": "icon-next",
|
|
297
|
+
"reflect": false,
|
|
298
|
+
"defaultValue": "'chevron-right-outlined'"
|
|
299
|
+
}
|
|
300
|
+
}; }
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=cat-pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-pagination.js","sourceRoot":"","sources":["../../../src/components/cat-pagination/cat-pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAExE;;;;;;GAMG;AAMH,MAAM,OAAO,aAAa;EAL1B;IAME;;OAEG;IACsB,SAAI,GAAG,CAAC,CAAC;IAElC;;OAEG;IACK,cAAS,GAAG,CAAC,CAAC;IAEtB;;OAEG;IACK,kBAAa,GAAG,CAAC,CAAC;IAE1B;;OAEG;IACK,gBAAW,GAAG,CAAC,CAAC;IAExB;;OAEG;IACK,SAAI,GAAkC,GAAG,CAAC;IAElD;;OAEG;IACK,YAAO,GAAmC,MAAM,CAAC;IAEzD;;OAEG;IACK,UAAK,GAAG,KAAK,CAAC;IAEtB;;OAEG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,aAAQ,GAAG,uBAAuB,CAAC;IAE3C;;OAEG;IACK,aAAQ,GAAG,wBAAwB,CAAC;GA6G7C;EA3GC,MAAM;IACJ,OAAO,CACL,WAAK,IAAI,EAAC,YAAY;MACpB,UACE,KAAK,EAAE;UACL,CAAC,kBAAkB,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,OA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,CAAC,IAAI,KAAK,IAAI,IAAI,SAAS,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAEhC,IAAI,GAAG,CAAC,CACE,CACV;KACN,CAAC,CAAC;EACL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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"]}
|