@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.
Files changed (167) 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.cdn.js +7 -3
  5. package/dist/catalyst/index.esm.js +9 -1
  6. package/dist/catalyst/index.esm.js.map +1 -1
  7. package/dist/catalyst/p-167f01e8.entry.js +2 -0
  8. package/dist/catalyst/p-167f01e8.entry.js.map +1 -0
  9. package/dist/catalyst/p-53a1db22.js +3 -0
  10. package/dist/catalyst/p-53a1db22.js.map +1 -0
  11. package/dist/catalyst/p-5865f232.js +2 -0
  12. package/dist/catalyst/p-5865f232.js.map +1 -0
  13. package/dist/catalyst/p-5bfc70e3.entry.js +2 -0
  14. package/dist/catalyst/{p-270fd91d.entry.js.map → p-5bfc70e3.entry.js.map} +1 -1
  15. package/dist/catalyst/scss/_variables.scss +1 -1
  16. package/dist/catalyst/scss/core/_form.scss +8 -0
  17. package/dist/catalyst/scss/core/_nav.scss +3 -3
  18. package/dist/catalyst/scss/core/_notification.scss +48 -0
  19. package/dist/catalyst/scss/index.scss +2 -1
  20. package/dist/catalyst/scss/utils/_typography.scss +4 -0
  21. package/dist/cjs/cat-alert_22.cjs.entry.js +358 -301
  22. package/dist/cjs/cat-alert_22.cjs.entry.js.map +1 -1
  23. package/dist/cjs/cat-icon-registry-2a54df3d.js +417 -0
  24. package/dist/cjs/cat-icon-registry-2a54df3d.js.map +1 -0
  25. package/dist/cjs/cat-modal.cjs.entry.js +2 -2
  26. package/dist/cjs/cat-modal.cjs.entry.js.map +1 -1
  27. package/dist/cjs/catalyst.cjs.js +2 -2
  28. package/dist/cjs/{index-b2134f1b.js → index-e540e911.js} +1 -4
  29. package/dist/cjs/index-e540e911.js.map +1 -0
  30. package/dist/cjs/index.cjs.js +528 -4
  31. package/dist/cjs/index.cjs.js.map +1 -1
  32. package/dist/cjs/loader.cjs.js +2 -2
  33. package/dist/collection/collection-manifest.json +2 -2
  34. package/dist/collection/components/cat-button/cat-button.css +21 -63
  35. package/dist/collection/components/cat-button/cat-button.js +21 -4
  36. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  37. package/dist/collection/components/cat-card/cat-card.css +5 -4
  38. package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -4
  39. package/dist/collection/components/cat-checkbox/cat-checkbox.js +1 -1
  40. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  41. package/dist/collection/components/{cat-menu/cat-menu.css → cat-dropdown/cat-dropdown.css} +23 -1
  42. package/dist/collection/components/{cat-menu/cat-menu.js → cat-dropdown/cat-dropdown.js} +122 -85
  43. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -0
  44. package/dist/collection/components/cat-i18n/cat-i18n-registry.js +13 -38
  45. package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
  46. package/dist/collection/components/cat-icon/cat-icon-registry.js +1 -0
  47. package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
  48. package/dist/collection/components/cat-input/cat-input.css +1 -4
  49. package/dist/collection/components/cat-input/cat-input.js +4 -5
  50. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  51. package/dist/collection/components/cat-notification/cat-notification.js +61 -89
  52. package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
  53. package/dist/collection/components/cat-pagination/cat-pagination.css +106 -0
  54. package/dist/collection/components/cat-pagination/cat-pagination.js +302 -0
  55. package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -0
  56. package/dist/collection/components/cat-radio/cat-radio.css +1 -4
  57. package/dist/collection/components/cat-radio/cat-radio.js +1 -1
  58. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  59. package/dist/collection/components/cat-radio-group/cat-radio-group.js +3 -11
  60. package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
  61. package/dist/collection/components/cat-select/cat-select.css +1 -4
  62. package/dist/collection/components/cat-select/cat-select.js +8 -9
  63. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  64. package/dist/collection/components/cat-select-demo/cat-select-demo.js +4 -1
  65. package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
  66. package/dist/collection/components/cat-tabs/cat-tabs.css +2 -2
  67. package/dist/collection/components/cat-tabs/cat-tabs.js +2 -2
  68. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
  69. package/dist/collection/components/cat-textarea/cat-textarea.css +1 -4
  70. package/dist/collection/components/cat-textarea/cat-textarea.js +1 -1
  71. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  72. package/dist/collection/components/cat-toggle/cat-toggle.css +1 -4
  73. package/dist/collection/components/cat-toggle/cat-toggle.js +1 -1
  74. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  75. package/dist/collection/index.cdn.js +7 -3
  76. package/dist/collection/index.js +3 -3
  77. package/dist/collection/index.js.map +1 -1
  78. package/dist/collection/scss/_variables.scss +1 -1
  79. package/dist/collection/scss/core/_form.scss +8 -0
  80. package/dist/collection/scss/core/_nav.scss +3 -3
  81. package/dist/collection/scss/core/_notification.scss +48 -0
  82. package/dist/collection/scss/index.scss +2 -1
  83. package/dist/collection/scss/utils/_typography.scss +4 -0
  84. package/dist/components/cat-button2.js +6 -5
  85. package/dist/components/cat-button2.js.map +1 -1
  86. package/dist/components/cat-card.js +1 -1
  87. package/dist/components/cat-card.js.map +1 -1
  88. package/dist/components/cat-checkbox2.js +2 -2
  89. package/dist/components/cat-checkbox2.js.map +1 -1
  90. package/dist/components/{cat-menu.d.ts → cat-dropdown.d.ts} +4 -4
  91. package/dist/components/cat-dropdown.js +8 -0
  92. package/dist/components/cat-dropdown.js.map +1 -0
  93. package/dist/components/cat-dropdown2.js +195 -0
  94. package/dist/components/cat-dropdown2.js.map +1 -0
  95. package/dist/components/cat-i18n-registry.js +14 -39
  96. package/dist/components/cat-i18n-registry.js.map +1 -1
  97. package/dist/components/cat-icon2.js +2 -1
  98. package/dist/components/cat-icon2.js.map +1 -1
  99. package/dist/components/cat-input.js +5 -6
  100. package/dist/components/cat-input.js.map +1 -1
  101. package/dist/components/{cat-toast-demo.d.ts → cat-pagination.d.ts} +4 -4
  102. package/dist/components/cat-pagination.js +150 -0
  103. package/dist/components/cat-pagination.js.map +1 -0
  104. package/dist/components/cat-radio-group.js +3 -11
  105. package/dist/components/cat-radio-group.js.map +1 -1
  106. package/dist/components/cat-radio.js +2 -2
  107. package/dist/components/cat-radio.js.map +1 -1
  108. package/dist/components/cat-select-demo.js +13 -7
  109. package/dist/components/cat-select-demo.js.map +1 -1
  110. package/dist/components/cat-select2.js +7 -8
  111. package/dist/components/cat-select2.js.map +1 -1
  112. package/dist/components/cat-tabs.js +3 -3
  113. package/dist/components/cat-tabs.js.map +1 -1
  114. package/dist/components/cat-textarea.js +2 -2
  115. package/dist/components/cat-textarea.js.map +1 -1
  116. package/dist/components/cat-toggle.js +2 -2
  117. package/dist/components/cat-toggle.js.map +1 -1
  118. package/dist/components/index.d.ts +2 -2
  119. package/dist/components/index.js +531 -4
  120. package/dist/components/index.js.map +1 -1
  121. package/dist/esm/cat-alert_22.entry.js +355 -298
  122. package/dist/esm/cat-alert_22.entry.js.map +1 -1
  123. package/dist/esm/cat-icon-registry-d537b18b.js +409 -0
  124. package/dist/esm/cat-icon-registry-d537b18b.js.map +1 -0
  125. package/dist/esm/cat-modal.entry.js +2 -2
  126. package/dist/esm/cat-modal.entry.js.map +1 -1
  127. package/dist/esm/catalyst.js +2 -2
  128. package/dist/esm/{index-033048ed.js → index-c2a28ebb.js} +2 -4
  129. package/dist/esm/index-c2a28ebb.js.map +1 -0
  130. package/dist/esm/index.js +527 -1
  131. package/dist/esm/index.js.map +1 -1
  132. package/dist/esm/loader.js +2 -2
  133. package/dist/types/components/cat-button/cat-button.d.ts +4 -0
  134. package/dist/types/components/{cat-menu/cat-menu.d.ts → cat-dropdown/cat-dropdown.d.ts} +22 -11
  135. package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +4 -6
  136. package/dist/types/components/cat-icon/cat-icon-registry.d.ts +1 -0
  137. package/dist/types/components/cat-input/cat-input.d.ts +0 -1
  138. package/dist/types/components/cat-notification/cat-notification.d.ts +21 -48
  139. package/dist/types/components/cat-pagination/cat-pagination.d.ts +56 -0
  140. package/dist/types/components/cat-select/cat-select.d.ts +0 -1
  141. package/dist/types/components.d.ts +149 -53
  142. package/dist/types/index.d.ts +4 -4
  143. package/package.json +3 -3
  144. package/dist/catalyst/p-10b0d7a2.js +0 -10
  145. package/dist/catalyst/p-10b0d7a2.js.map +0 -1
  146. package/dist/catalyst/p-270fd91d.entry.js +0 -2
  147. package/dist/catalyst/p-3ad731e4.entry.js +0 -2
  148. package/dist/catalyst/p-3ad731e4.entry.js.map +0 -1
  149. package/dist/catalyst/p-692e49d6.js +0 -3
  150. package/dist/catalyst/p-692e49d6.js.map +0 -1
  151. package/dist/catalyst/scss/core/_toast.scss +0 -87
  152. package/dist/cjs/cat-notification-bcb9fb86.js +0 -990
  153. package/dist/cjs/cat-notification-bcb9fb86.js.map +0 -1
  154. package/dist/cjs/index-b2134f1b.js.map +0 -1
  155. package/dist/collection/components/cat-menu/cat-menu.js.map +0 -1
  156. package/dist/collection/components/cat-toast-demo/cat-toast-demo.css +0 -3
  157. package/dist/collection/components/cat-toast-demo/cat-toast-demo.js +0 -62
  158. package/dist/collection/components/cat-toast-demo/cat-toast-demo.js.map +0 -1
  159. package/dist/collection/scss/core/_toast.scss +0 -87
  160. package/dist/components/cat-menu.js +0 -174
  161. package/dist/components/cat-menu.js.map +0 -1
  162. package/dist/components/cat-toast-demo.js +0 -647
  163. package/dist/components/cat-toast-demo.js.map +0 -1
  164. package/dist/esm/cat-notification-8bcf6fa2.js +0 -985
  165. package/dist/esm/cat-notification-8bcf6fa2.js.map +0 -1
  166. package/dist/esm/index-033048ed.js.map +0 -1
  167. 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
- export var TypeIcons;
3
- (function (TypeIcons) {
4
- TypeIcons["success"] = "check-circle-filled";
5
- TypeIcons["error"] = "cross-circle-filled";
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
- class CatNotificationService {
37
- error(title, message = ' ', options) {
38
- const toastOptions = this.extractOptions(title, message, options);
39
- Toastify(toastOptions).showToast();
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
- secondary(title, message = ' ', options) {
54
- const toastOptions = this.extractOptions(title, message, options);
55
- Toastify(toastOptions).showToast();
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
- toastHTMLTemplate(title, message = ' ', options) {
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
- <div class="cat-toastify-icon-wrapper ${(_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : 'secondary'}">
67
- <cat-icon icon="${typeIcon}"></cat-icon>
68
- </div>
69
- <div class="cat-toastify-title-wrapper ${hasMessageClass}">
70
- <div class="cat-toastify-title">${title}</div></div>
71
- ${hasMessage ? `<div class="cat-toastify-message">${message}</div>` : ''}
72
- </div>`;
73
- return template.content.firstChild;
74
- }
75
- getPosition(options) {
76
- const position = {
77
- gravity: 'bottom',
78
- position: 'left'
79
- };
80
- if ((options === null || options === void 0 ? void 0 : options.position) && ToastPositions[options.position]) {
81
- position.position = ToastPositions[options.position].position;
82
- position.gravity = ToastPositions[options.position].gravity;
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 position;
52
+ return node;
85
53
  }
86
- extractOptions(title, message = ' ', options) {
87
- const position = this.getPosition(options);
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
- node: (options === null || options === void 0 ? void 0 : options.content) ? options.content : this.toastHTMLTemplate(title, message, options),
90
- duration: CatNotificationService.DURATION,
91
- close: true,
92
- className: 'cat-toastify',
93
- gravity: position.gravity,
94
- position: position.position,
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: '1.5rem',
98
- y: '1.5rem'
69
+ x: '1rem',
70
+ y: '1rem'
99
71
  }
100
72
  };
101
73
  }
102
74
  }
103
- CatNotificationService.DURATION = 80000;
104
- export const NotificationsService = new CatNotificationService();
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;AAEhD,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;EACnB,4CAAiC,CAAA;EACjC,0CAA+B,CAAA;EAC/B,mCAAwB,CAAA;EACxB,2CAAgC,CAAA;EAChC,6CAAkC,CAAA;AACpC,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB;AAED,MAAM,CAAC,MAAM,cAAc,GAA4F;EACrH,UAAU,EAAE;IACV,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,MAAM;GACjB;EACD,YAAY,EAAE;IACZ,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,QAAQ;GACnB;EACD,WAAW,EAAE;IACX,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,OAAO;GAClB;EACD,aAAa,EAAE;IACb,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,MAAM;GACjB;EACD,eAAe,EAAE;IACf,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,QAAQ;GACnB;EACD,cAAc,EAAE;IACd,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,O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GAAG,GAAG,EAAE,OAA+B;IAClF,MAAM,QAAQ,GAAkB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO;MACL,IAAI,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC;MAC1F,QAAQ,EAAE,sBAAsB,CAAC,QAAQ;MACzC,KAAK,EAAE,IAAI;MACX,SAAS,EAAE,cAAc;MACzB,OAAO,EAAE,QAAQ,CAAC,OAAO;MACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;MAC3B,WAAW,EAAE,IAAI;MACjB,MAAM,EAAE;QACN,CAAC,EAAE,QAAQ;QACX,CAAC,EAAE,QAAQ;OACZ;KACF,CAAC;EACJ,CAAC;;AAxEc,+BAAQ,GAAG,KAAK,CAAC;AA2ElC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,sBAAsB,EAAE,CAAC","sourcesContent":["import Toastify, { Options } from 'toastify-js';\n\nexport enum TypeIcons {\n 'success' = 'check-circle-filled',\n 'error' = 'cross-circle-filled',\n 'info' = 'danger-filled',\n 'primary' = 'star-circle-filled',\n 'secondary' = 'info-circle-filled'\n}\n\nexport const ToastPositions: { [key: string]: { gravity: 'top' | 'bottom'; position: 'left' | 'center' | 'right' } } = {\n 'top-left': {\n gravity: 'top',\n position: 'left'\n },\n 'top-center': {\n gravity: 'top',\n position: 'center'\n },\n 'top-right': {\n gravity: 'top',\n position: 'right'\n },\n 'bottom-left': {\n gravity: 'bottom',\n position: 'left'\n },\n 'bottom-center': {\n gravity: 'bottom',\n position: 'center'\n },\n 'bottom-right': {\n gravity: 'bottom',\n position: 'right'\n }\n};\n\nexport interface ToastPosition {\n gravity: 'top' | 'bottom';\n position: 'left' | 'center' | 'right';\n}\n\nexport interface ToastOptions {\n /**\n * HTML content of the toast\n */\n content: Node;\n /**\n * Show close button\n */\n close: boolean;\n /**\n * Toast position\n */\n position: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';\n /**\n * Type of toast\n */\n type: 'success' | 'info' | 'error' | 'primary' | 'secondary';\n /**\n * Invoked when the toast is clicked\n */\n onClick: () => void;\n /**\n * Toggle the default behavior of escaping HTML markup\n */\n escapeMarkup: boolean;\n}\n\nclass CatNotificationService {\n private static DURATION = 80000;\n\n error(title: string, message = ' ', options?: Partial<ToastOptions>): void {\n const toastOptions: Options = this.extractOptions(title, message, options);\n Toastify(toastOptions).showToast();\n }\n\n success(title: string, message = ' ', options?: Partial<ToastOptions>): void {\n const toastOptions: Options = this.extractOptions(title, message, options);\n Toastify(toastOptions).showToast();\n }\n\n info(title: string, message = ' ', options?: Partial<ToastOptions>): void {\n const toastOptions: Options = this.extractOptions(title, message, options);\n Toastify(toastOptions).showToast();\n }\n\n primary(title: string, message = ' ', options?: Partial<ToastOptions>): void {\n const toastOptions: Options = this.extractOptions(title, message, options);\n Toastify(toastOptions).showToast();\n }\n\n secondary(title: string, message = ' ', options?: Partial<ToastOptions>): void {\n const toastOptions: Options = this.extractOptions(title, message, options);\n Toastify(toastOptions).showToast();\n }\n\n private toastHTMLTemplate(title: string, message = ' ', options?: Partial<ToastOptions>): HTMLElement {\n const template = document.createElement('template');\n const typeIcon = options?.type ? TypeIcons[options.type] : TypeIcons.secondary;\n title = title.trim();\n message = message.trim();\n const hasMessage = message && message !== '';\n const hasMessageClass = hasMessage ? 'has-message' : '';\n template.innerHTML = `<div class=\"cat-toastify-wrapper\">\n <div class=\"cat-toastify-icon-wrapper ${options?.type ?? 'secondary'}\">\n <cat-icon icon=\"${typeIcon}\"></cat-icon>\n </div>\n <div class=\"cat-toastify-title-wrapper ${hasMessageClass}\">\n <div class=\"cat-toastify-title\">${title}</div></div>\n ${hasMessage ? `<div class=\"cat-toastify-message\">${message}</div>` : ''}\n </div>`;\n return template.content.firstChild as HTMLElement;\n }\n\n private getPosition(options?: Partial<ToastOptions>): ToastPosition {\n const position: ToastPosition = {\n gravity: 'bottom',\n position: 'left'\n };\n if (options?.position && ToastPositions[options.position]) {\n position.position = ToastPositions[options.position].position;\n position.gravity = ToastPositions[options.position].gravity;\n }\n return position;\n }\n\n private extractOptions(title: string, message = ' ', options?: Partial<ToastOptions>): Options {\n const position: ToastPosition = this.getPosition(options);\n return {\n node: options?.content ? options.content : this.toastHTMLTemplate(title, message, options),\n duration: CatNotificationService.DURATION,\n close: true,\n className: 'cat-toastify',\n gravity: position.gravity,\n position: position.position,\n stopOnFocus: true,\n offset: {\n x: '1.5rem',\n y: '1.5rem'\n }\n };\n }\n}\n\nexport const NotificationsService = new CatNotificationService();\n"]}
1
+ {"version":3,"file":"cat-notification.js","sourceRoot":"","sources":["../../../src/components/cat-notification/cat-notification.tsx"],"names":[],"mappings":"AAAA,OAAO,QAAqB,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAsBxE,MAAM,OAAO,sBAAsB;EAIjC;IACE,mBAAmB;EACrB,CAAC;EAED,MAAM,CAAC,WAAW;IAChB,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE;MACpC,sBAAsB,CAAC,QAAQ,GAAG,IAAI,sBAAsB,EAAE,CAAC;KAChE;IACD,OAAO,sBAAsB,CAAC,QAAQ,CAAC;EACzC,CAAC;EAED,IAAI,CAAC,OAAsB,EAAE,OAA+B;IAC1D,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACrC,GAAG,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;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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AAW,EAAE,IAAI,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"]}