@haiilo/catalyst 0.2.2 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/assets/fonts/AzeretMono-Regular.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Bold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Italic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Medium.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Regular.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Black.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Black.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Bold.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Bold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Hairline.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Hairline.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Heavy.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Heavy.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Italic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Italic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Light.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Light.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-LightItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-LightItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Medium.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Medium.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Regular.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Regular.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Semibold.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Semibold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Thin.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Thin.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff2 +0 -0
- package/dist/catalyst/catalyst.css +1 -1951
- package/dist/catalyst/catalyst.esm.js +2 -130
- package/dist/catalyst/catalyst.esm.js.map +1 -0
- package/dist/catalyst/index.esm.js +2 -1
- package/dist/catalyst/index.esm.js.map +1 -0
- package/dist/catalyst/p-31b500c7.entry.js +10 -0
- package/dist/catalyst/p-31b500c7.entry.js.map +1 -0
- package/dist/catalyst/p-ed826597.js +2 -0
- package/dist/catalyst/p-ed826597.js.map +1 -0
- package/dist/catalyst/p-ef0a8ae9.js +2 -0
- package/dist/catalyst/p-ef0a8ae9.js.map +1 -0
- package/dist/catalyst/p-f151cb13.js +2 -0
- package/dist/catalyst/p-f151cb13.js.map +1 -0
- package/dist/cjs/app-globals-7f2b1f8e.js +173 -0
- package/dist/cjs/app-globals-7f2b1f8e.js.map +1 -0
- package/dist/cjs/cat-alert_8.cjs.entry.js +4450 -0
- package/dist/cjs/cat-alert_8.cjs.entry.js.map +1 -0
- package/dist/cjs/cat-icon-registry-850c538c.js +47 -0
- package/dist/cjs/cat-icon-registry-850c538c.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +24 -0
- package/dist/cjs/catalyst.cjs.js.map +1 -0
- package/dist/cjs/index-c0881ae0.js +1348 -0
- package/dist/cjs/index-c0881ae0.js.map +1 -0
- package/dist/cjs/index.cjs.js +11 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +26 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/collection/assets/fonts/AzeretMono-Regular.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Bold.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Italic.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Medium.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Regular.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Black.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Black.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-BlackItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-BlackItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Bold.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Bold.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Hairline.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Hairline.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-HairlineItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Heavy.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Heavy.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-HeavyItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Italic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Italic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Light.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Light.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-LightItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-LightItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Medium.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Medium.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-MediumItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-MediumItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Regular.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Regular.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Semibold.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Semibold.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Thin.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Thin.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-ThinItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-ThinItalic.woff2 +0 -0
- package/dist/collection/collection-manifest.json +20 -0
- package/dist/collection/components/cat-alert/cat-alert.css +57 -0
- package/dist/collection/components/cat-alert/cat-alert.js +50 -0
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -0
- package/dist/collection/components/cat-badge/cat-badge.css +154 -0
- package/dist/collection/components/cat-badge/cat-badge.js +142 -0
- package/dist/collection/components/cat-badge/cat-badge.js.map +1 -0
- package/dist/collection/components/cat-button/cat-button.css +323 -0
- package/dist/collection/components/cat-button/cat-button.js +591 -0
- package/dist/collection/components/cat-button/cat-button.js.map +1 -0
- package/dist/collection/components/cat-icon/cat-icon-registry.js +42 -0
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -0
- package/dist/collection/components/cat-icon/cat-icon.css +50 -0
- package/dist/collection/components/cat-icon/cat-icon.js +90 -0
- package/dist/collection/components/cat-icon/cat-icon.js.map +1 -0
- package/dist/collection/components/cat-menu/cat-menu.css +33 -0
- package/dist/collection/components/cat-menu/cat-menu.js +186 -0
- package/dist/collection/components/cat-menu/cat-menu.js.map +1 -0
- package/dist/collection/components/cat-scrollable/cat-scrollable.css +69 -0
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +309 -0
- package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -0
- package/dist/collection/components/cat-skeleton/cat-skeleton.css +177 -0
- package/dist/collection/components/cat-skeleton/cat-skeleton.js +131 -0
- package/dist/collection/components/cat-skeleton/cat-skeleton.js.map +1 -0
- package/dist/collection/components/cat-spinner/cat-spinner.css +63 -0
- package/dist/collection/components/cat-spinner/cat-spinner.js +65 -0
- package/dist/collection/components/cat-spinner/cat-spinner.js.map +1 -0
- package/dist/collection/index.cdn.js +21 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/init.js +9 -0
- package/dist/collection/init.js.map +1 -0
- package/dist/collection/utils/breakpoints.js +12 -0
- package/dist/collection/utils/breakpoints.js.map +1 -0
- package/dist/collection/utils/media-matcher.js +55 -0
- package/dist/collection/utils/media-matcher.js.map +1 -0
- package/dist/collection/utils/platform.js +50 -0
- package/dist/collection/utils/platform.js.map +1 -0
- package/dist/collection/utils/utils.js +4 -0
- package/dist/collection/utils/utils.js.map +1 -0
- package/dist/{catalyst/cat-alert.entry.js → components/cat-alert.js} +29 -7
- package/dist/components/cat-alert.js.map +1 -0
- package/dist/{catalyst/cat-badge.entry.js → components/cat-badge.js} +34 -8
- package/dist/components/cat-badge.js.map +1 -0
- package/dist/{catalyst/cat-button.entry.js → components/cat-button.js} +62 -41
- package/dist/components/cat-button.js.map +1 -0
- package/dist/{catalyst/cat-icon-registry-59da2e37.js → components/cat-icon-registry.js} +2 -0
- package/dist/components/cat-icon-registry.js.map +1 -0
- package/dist/components/cat-icon.js +8 -0
- package/dist/components/cat-icon.js.map +1 -0
- package/dist/{catalyst/cat-icon.entry.js → components/cat-icon2.js} +29 -8
- package/dist/components/cat-icon2.js.map +1 -0
- package/dist/{catalyst/cat-menu.entry.js → components/cat-menu.js} +35 -641
- package/dist/components/cat-menu.js.map +1 -0
- package/dist/components/cat-scrollable.d.ts +11 -0
- package/dist/components/cat-scrollable.js +1363 -0
- package/dist/components/cat-scrollable.js.map +1 -0
- package/dist/{catalyst/cat-skeleton.entry.js → components/cat-skeleton.js} +32 -7
- package/dist/components/cat-skeleton.js.map +1 -0
- package/dist/components/cat-spinner.js +8 -0
- package/dist/components/cat-spinner.js.map +1 -0
- package/dist/{catalyst/cat-spinner.entry.js → components/cat-spinner2.js} +27 -7
- package/dist/components/cat-spinner2.js.map +1 -0
- package/dist/components/index.js +173 -0
- package/dist/components/index.js.map +1 -0
- package/dist/esm/app-globals-8af9b2cf.js +171 -0
- package/dist/esm/app-globals-8af9b2cf.js.map +1 -0
- package/dist/esm/cat-alert_8.entry.js +4439 -0
- package/dist/esm/cat-alert_8.entry.js.map +1 -0
- package/dist/esm/cat-icon-registry-59da2e37.js +45 -0
- package/dist/esm/cat-icon-registry-59da2e37.js.map +1 -0
- package/dist/esm/catalyst.js +22 -0
- package/dist/esm/catalyst.js.map +1 -0
- package/dist/esm/index-0ff35bca.js +1320 -0
- package/dist/esm/index-0ff35bca.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +22 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +50 -0
- package/dist/types/components.d.ts +85 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +12 -16
- package/dist/catalyst/app-globals-f83c9e4a.js +0 -722
- package/dist/catalyst/css-shim-e6dd2538.js +0 -4
- package/dist/catalyst/dom-7fc649b0.js +0 -73
- package/dist/catalyst/index-a0f41a84.js +0 -3057
- package/dist/catalyst/shadow-css-4d56fa31.js +0 -388
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import { Component, Event, h, Listen, Method, Prop, State, Watch } from '@stencil/core';
|
|
2
|
+
import log from 'loglevel';
|
|
3
|
+
import { Breakpoints, isBreakpoint } from '../../utils/breakpoints';
|
|
4
|
+
import { MediaMatcher } from '../../utils/media-matcher';
|
|
5
|
+
/**
|
|
6
|
+
* Buttons are used for interface actions.
|
|
7
|
+
*
|
|
8
|
+
* @part button - The native anchor or button element.
|
|
9
|
+
* @part content - The textual content of the button.
|
|
10
|
+
* @part prefix - The prefix icon.
|
|
11
|
+
* @part suffix - The suffix icon.
|
|
12
|
+
*/
|
|
13
|
+
export class CatButton {
|
|
14
|
+
constructor() {
|
|
15
|
+
this._iconOnly = true;
|
|
16
|
+
/**
|
|
17
|
+
* The rendering style of the button.
|
|
18
|
+
*/
|
|
19
|
+
this.variant = 'outlined';
|
|
20
|
+
/**
|
|
21
|
+
* The color palette of the button.
|
|
22
|
+
*/
|
|
23
|
+
this.color = 'secondary';
|
|
24
|
+
/**
|
|
25
|
+
* The size of the button.
|
|
26
|
+
*/
|
|
27
|
+
this.size = 'm';
|
|
28
|
+
/**
|
|
29
|
+
* Specifies that the button should be disabled. A disabled button is unusable
|
|
30
|
+
* and un-clickable. Corresponds with the native HTML disabled attribute.
|
|
31
|
+
*/
|
|
32
|
+
this.disabled = false;
|
|
33
|
+
/**
|
|
34
|
+
* Displays the button in a loading state with a spinner. Just like a disabled
|
|
35
|
+
* button, an inactive button is unusable and un-clickable. However, it
|
|
36
|
+
* retains the current focus state.
|
|
37
|
+
*/
|
|
38
|
+
this.loading = false;
|
|
39
|
+
/**
|
|
40
|
+
* Allows the button to submit a form.
|
|
41
|
+
*/
|
|
42
|
+
this.submit = false;
|
|
43
|
+
/**
|
|
44
|
+
* Ellipse overflowing button content.
|
|
45
|
+
*/
|
|
46
|
+
this.ellipsed = true;
|
|
47
|
+
/**
|
|
48
|
+
* Use round button edges.
|
|
49
|
+
*/
|
|
50
|
+
this.round = false;
|
|
51
|
+
/**
|
|
52
|
+
* Hide the actual button content and only display the icon.
|
|
53
|
+
*/
|
|
54
|
+
this.iconOnly = false;
|
|
55
|
+
/**
|
|
56
|
+
* Display the icon as a suffix.
|
|
57
|
+
*/
|
|
58
|
+
this.iconSuffix = false;
|
|
59
|
+
}
|
|
60
|
+
onIconOnlyChanged(value) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
// teardown
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
64
|
+
(_a = this.mediaQueryList) === null || _a === void 0 ? void 0 : _a.removeEventListener('change', this.mediaQueryListener);
|
|
65
|
+
this.mediaQueryList = undefined;
|
|
66
|
+
this.mediaQueryListener = undefined;
|
|
67
|
+
// setup
|
|
68
|
+
if (isBreakpoint(value)) {
|
|
69
|
+
(_b = this.mediaMatcher) !== null && _b !== void 0 ? _b : (this.mediaMatcher = new MediaMatcher());
|
|
70
|
+
this.mediaQueryList = this.mediaMatcher.matchMedia(Breakpoints[value]);
|
|
71
|
+
this.mediaQueryListener = (event) => (this._iconOnly = event.matches);
|
|
72
|
+
this.mediaQueryList.addEventListener('change', this.mediaQueryListener);
|
|
73
|
+
this._iconOnly = this.mediaQueryList.matches;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this._iconOnly = value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
componentWillLoad() {
|
|
80
|
+
this.onIconOnlyChanged(this.iconOnly);
|
|
81
|
+
}
|
|
82
|
+
componentWillRender() {
|
|
83
|
+
if (this.isIconButton && !this.a11yLabel) {
|
|
84
|
+
log.warn('[A11y] Missing ARIA label on icon button', this);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
haltDisabledEvents(event) {
|
|
88
|
+
if (this.disabled || this.loading) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
event.stopImmediatePropagation();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Sets focus on the button. Use this method instead of `button.focus()`.
|
|
95
|
+
*
|
|
96
|
+
* @param options An optional object providing options to control aspects of
|
|
97
|
+
* the focusing process.
|
|
98
|
+
*/
|
|
99
|
+
async setFocus(options) {
|
|
100
|
+
this.button.focus(options);
|
|
101
|
+
}
|
|
102
|
+
render() {
|
|
103
|
+
var _a;
|
|
104
|
+
if (this.url) {
|
|
105
|
+
return (h("a", { ref: el => (this.button = el), href: this.disabled ? undefined : this.url, target: this.urlTarget, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
|
|
106
|
+
'cat-button': true,
|
|
107
|
+
'cat-button-icon': this.isIconButton,
|
|
108
|
+
'cat-button-round': this.round,
|
|
109
|
+
'cat-button-loading': this.loading,
|
|
110
|
+
'cat-button-disabled': this.disabled,
|
|
111
|
+
'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
|
|
112
|
+
[`cat-button-${this.variant}`]: Boolean(this.variant),
|
|
113
|
+
[`cat-button-${this.color}`]: Boolean(this.color),
|
|
114
|
+
[`cat-button-${this.size}`]: Boolean(this.size)
|
|
115
|
+
}, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return (h("button", { ref: el => (this.button = el), type: this.submit ? 'submit' : 'button', name: this.name, value: this.value, disabled: this.disabled, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
|
|
119
|
+
'cat-button': true,
|
|
120
|
+
'cat-button-icon': this.isIconButton,
|
|
121
|
+
'cat-button-round': (_a = this.round) !== null && _a !== void 0 ? _a : this.isIconButton,
|
|
122
|
+
'cat-button-loading': this.loading,
|
|
123
|
+
'cat-button-disabled': this.disabled,
|
|
124
|
+
'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
|
|
125
|
+
[`cat-button-${this.variant}`]: Boolean(this.variant),
|
|
126
|
+
[`cat-button-${this.color}`]: Boolean(this.color),
|
|
127
|
+
[`cat-button-${this.size}`]: Boolean(this.size)
|
|
128
|
+
}, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
get iconSize() {
|
|
132
|
+
switch (this.size) {
|
|
133
|
+
case 'xs':
|
|
134
|
+
return 's';
|
|
135
|
+
default:
|
|
136
|
+
return 'l';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
get spinnerSize() {
|
|
140
|
+
switch (this.size) {
|
|
141
|
+
case 'xs':
|
|
142
|
+
return 'xs';
|
|
143
|
+
default:
|
|
144
|
+
return 'm';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
get isIconButton() {
|
|
148
|
+
return Boolean(this.icon) && this._iconOnly;
|
|
149
|
+
}
|
|
150
|
+
get hasPrefixIcon() {
|
|
151
|
+
return Boolean(this.icon) && !this._iconOnly && !this.iconSuffix;
|
|
152
|
+
}
|
|
153
|
+
get hasSuffixIcon() {
|
|
154
|
+
return Boolean(this.icon) && !this._iconOnly && this.iconSuffix;
|
|
155
|
+
}
|
|
156
|
+
get content() {
|
|
157
|
+
return [
|
|
158
|
+
this.hasPrefixIcon ? (h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-prefix", part: "prefix" })) : null,
|
|
159
|
+
this.isIconButton ? (h("cat-icon", { icon: this.icon, size: this.iconSize })) : (h("span", { class: "cat-button-content", part: "content" },
|
|
160
|
+
h("slot", null))),
|
|
161
|
+
this.hasSuffixIcon ? (h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-suffix", part: "suffix" })) : null,
|
|
162
|
+
this.loading ? h("cat-spinner", { size: this.spinnerSize }) : null
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
onClick(event) {
|
|
166
|
+
this.catClick.emit(event);
|
|
167
|
+
}
|
|
168
|
+
onFocus(event) {
|
|
169
|
+
this.catFocus.emit(event);
|
|
170
|
+
}
|
|
171
|
+
onBlur(event) {
|
|
172
|
+
this.catBlur.emit(event);
|
|
173
|
+
}
|
|
174
|
+
static get is() { return "cat-button"; }
|
|
175
|
+
static get encapsulation() { return "shadow"; }
|
|
176
|
+
static get originalStyleUrls() { return {
|
|
177
|
+
"$": ["cat-button.scss"]
|
|
178
|
+
}; }
|
|
179
|
+
static get styleUrls() { return {
|
|
180
|
+
"$": ["cat-button.css"]
|
|
181
|
+
}; }
|
|
182
|
+
static get properties() { return {
|
|
183
|
+
"variant": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"mutable": false,
|
|
186
|
+
"complexType": {
|
|
187
|
+
"original": "'filled' | 'outlined' | 'text'",
|
|
188
|
+
"resolved": "\"filled\" | \"outlined\" | \"text\"",
|
|
189
|
+
"references": {}
|
|
190
|
+
},
|
|
191
|
+
"required": false,
|
|
192
|
+
"optional": false,
|
|
193
|
+
"docs": {
|
|
194
|
+
"tags": [],
|
|
195
|
+
"text": "The rendering style of the button."
|
|
196
|
+
},
|
|
197
|
+
"attribute": "variant",
|
|
198
|
+
"reflect": false,
|
|
199
|
+
"defaultValue": "'outlined'"
|
|
200
|
+
},
|
|
201
|
+
"color": {
|
|
202
|
+
"type": "string",
|
|
203
|
+
"mutable": false,
|
|
204
|
+
"complexType": {
|
|
205
|
+
"original": "'primary' | 'secondary' | 'danger' | 'success' | 'warning'",
|
|
206
|
+
"resolved": "\"danger\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"",
|
|
207
|
+
"references": {}
|
|
208
|
+
},
|
|
209
|
+
"required": false,
|
|
210
|
+
"optional": false,
|
|
211
|
+
"docs": {
|
|
212
|
+
"tags": [],
|
|
213
|
+
"text": "The color palette of the button."
|
|
214
|
+
},
|
|
215
|
+
"attribute": "color",
|
|
216
|
+
"reflect": false,
|
|
217
|
+
"defaultValue": "'secondary'"
|
|
218
|
+
},
|
|
219
|
+
"size": {
|
|
220
|
+
"type": "string",
|
|
221
|
+
"mutable": false,
|
|
222
|
+
"complexType": {
|
|
223
|
+
"original": "'xs' | 's' | 'm' | 'l' | 'xl'",
|
|
224
|
+
"resolved": "\"l\" | \"m\" | \"s\" | \"xl\" | \"xs\"",
|
|
225
|
+
"references": {}
|
|
226
|
+
},
|
|
227
|
+
"required": false,
|
|
228
|
+
"optional": false,
|
|
229
|
+
"docs": {
|
|
230
|
+
"tags": [],
|
|
231
|
+
"text": "The size of the button."
|
|
232
|
+
},
|
|
233
|
+
"attribute": "size",
|
|
234
|
+
"reflect": false,
|
|
235
|
+
"defaultValue": "'m'"
|
|
236
|
+
},
|
|
237
|
+
"name": {
|
|
238
|
+
"type": "string",
|
|
239
|
+
"mutable": false,
|
|
240
|
+
"complexType": {
|
|
241
|
+
"original": "string",
|
|
242
|
+
"resolved": "string | undefined",
|
|
243
|
+
"references": {}
|
|
244
|
+
},
|
|
245
|
+
"required": false,
|
|
246
|
+
"optional": true,
|
|
247
|
+
"docs": {
|
|
248
|
+
"tags": [],
|
|
249
|
+
"text": "The name of the button, which gets paired with the button's value when\nsubmitted as part of a form. Corresponds with the native HTML name\nattribute."
|
|
250
|
+
},
|
|
251
|
+
"attribute": "name",
|
|
252
|
+
"reflect": false
|
|
253
|
+
},
|
|
254
|
+
"value": {
|
|
255
|
+
"type": "string",
|
|
256
|
+
"mutable": false,
|
|
257
|
+
"complexType": {
|
|
258
|
+
"original": "string",
|
|
259
|
+
"resolved": "string | undefined",
|
|
260
|
+
"references": {}
|
|
261
|
+
},
|
|
262
|
+
"required": false,
|
|
263
|
+
"optional": true,
|
|
264
|
+
"docs": {
|
|
265
|
+
"tags": [],
|
|
266
|
+
"text": "The value of the button, which gets paired with the button's name when\nsubmitted as part of a form. Corresponds with the native HTML value\nattribute."
|
|
267
|
+
},
|
|
268
|
+
"attribute": "value",
|
|
269
|
+
"reflect": false
|
|
270
|
+
},
|
|
271
|
+
"disabled": {
|
|
272
|
+
"type": "boolean",
|
|
273
|
+
"mutable": false,
|
|
274
|
+
"complexType": {
|
|
275
|
+
"original": "boolean",
|
|
276
|
+
"resolved": "boolean",
|
|
277
|
+
"references": {}
|
|
278
|
+
},
|
|
279
|
+
"required": false,
|
|
280
|
+
"optional": false,
|
|
281
|
+
"docs": {
|
|
282
|
+
"tags": [],
|
|
283
|
+
"text": "Specifies that the button should be disabled. A disabled button is unusable\nand un-clickable. Corresponds with the native HTML disabled attribute."
|
|
284
|
+
},
|
|
285
|
+
"attribute": "disabled",
|
|
286
|
+
"reflect": false,
|
|
287
|
+
"defaultValue": "false"
|
|
288
|
+
},
|
|
289
|
+
"loading": {
|
|
290
|
+
"type": "boolean",
|
|
291
|
+
"mutable": false,
|
|
292
|
+
"complexType": {
|
|
293
|
+
"original": "boolean",
|
|
294
|
+
"resolved": "boolean",
|
|
295
|
+
"references": {}
|
|
296
|
+
},
|
|
297
|
+
"required": false,
|
|
298
|
+
"optional": false,
|
|
299
|
+
"docs": {
|
|
300
|
+
"tags": [],
|
|
301
|
+
"text": "Displays the button in a loading state with a spinner. Just like a disabled\nbutton, an inactive button is unusable and un-clickable. However, it\nretains the current focus state."
|
|
302
|
+
},
|
|
303
|
+
"attribute": "loading",
|
|
304
|
+
"reflect": false,
|
|
305
|
+
"defaultValue": "false"
|
|
306
|
+
},
|
|
307
|
+
"submit": {
|
|
308
|
+
"type": "boolean",
|
|
309
|
+
"mutable": false,
|
|
310
|
+
"complexType": {
|
|
311
|
+
"original": "boolean",
|
|
312
|
+
"resolved": "boolean",
|
|
313
|
+
"references": {}
|
|
314
|
+
},
|
|
315
|
+
"required": false,
|
|
316
|
+
"optional": false,
|
|
317
|
+
"docs": {
|
|
318
|
+
"tags": [],
|
|
319
|
+
"text": "Allows the button to submit a form."
|
|
320
|
+
},
|
|
321
|
+
"attribute": "submit",
|
|
322
|
+
"reflect": false,
|
|
323
|
+
"defaultValue": "false"
|
|
324
|
+
},
|
|
325
|
+
"ellipsed": {
|
|
326
|
+
"type": "boolean",
|
|
327
|
+
"mutable": false,
|
|
328
|
+
"complexType": {
|
|
329
|
+
"original": "boolean",
|
|
330
|
+
"resolved": "boolean",
|
|
331
|
+
"references": {}
|
|
332
|
+
},
|
|
333
|
+
"required": false,
|
|
334
|
+
"optional": false,
|
|
335
|
+
"docs": {
|
|
336
|
+
"tags": [],
|
|
337
|
+
"text": "Ellipse overflowing button content."
|
|
338
|
+
},
|
|
339
|
+
"attribute": "ellipsed",
|
|
340
|
+
"reflect": false,
|
|
341
|
+
"defaultValue": "true"
|
|
342
|
+
},
|
|
343
|
+
"round": {
|
|
344
|
+
"type": "boolean",
|
|
345
|
+
"mutable": false,
|
|
346
|
+
"complexType": {
|
|
347
|
+
"original": "boolean",
|
|
348
|
+
"resolved": "boolean",
|
|
349
|
+
"references": {}
|
|
350
|
+
},
|
|
351
|
+
"required": false,
|
|
352
|
+
"optional": false,
|
|
353
|
+
"docs": {
|
|
354
|
+
"tags": [],
|
|
355
|
+
"text": "Use round button edges."
|
|
356
|
+
},
|
|
357
|
+
"attribute": "round",
|
|
358
|
+
"reflect": false,
|
|
359
|
+
"defaultValue": "false"
|
|
360
|
+
},
|
|
361
|
+
"url": {
|
|
362
|
+
"type": "string",
|
|
363
|
+
"mutable": false,
|
|
364
|
+
"complexType": {
|
|
365
|
+
"original": "string",
|
|
366
|
+
"resolved": "string | undefined",
|
|
367
|
+
"references": {}
|
|
368
|
+
},
|
|
369
|
+
"required": false,
|
|
370
|
+
"optional": true,
|
|
371
|
+
"docs": {
|
|
372
|
+
"tags": [],
|
|
373
|
+
"text": "A destination to link to, rendered in the href attribute of a link."
|
|
374
|
+
},
|
|
375
|
+
"attribute": "url",
|
|
376
|
+
"reflect": false
|
|
377
|
+
},
|
|
378
|
+
"urlTarget": {
|
|
379
|
+
"type": "string",
|
|
380
|
+
"mutable": false,
|
|
381
|
+
"complexType": {
|
|
382
|
+
"original": "'_blank' | '_self'",
|
|
383
|
+
"resolved": "\"_blank\" | \"_self\" | undefined",
|
|
384
|
+
"references": {}
|
|
385
|
+
},
|
|
386
|
+
"required": false,
|
|
387
|
+
"optional": true,
|
|
388
|
+
"docs": {
|
|
389
|
+
"tags": [],
|
|
390
|
+
"text": "Specifies where to open the linked document."
|
|
391
|
+
},
|
|
392
|
+
"attribute": "url-target",
|
|
393
|
+
"reflect": false
|
|
394
|
+
},
|
|
395
|
+
"icon": {
|
|
396
|
+
"type": "string",
|
|
397
|
+
"mutable": false,
|
|
398
|
+
"complexType": {
|
|
399
|
+
"original": "string",
|
|
400
|
+
"resolved": "string | undefined",
|
|
401
|
+
"references": {}
|
|
402
|
+
},
|
|
403
|
+
"required": false,
|
|
404
|
+
"optional": true,
|
|
405
|
+
"docs": {
|
|
406
|
+
"tags": [],
|
|
407
|
+
"text": "The name of an icon to be displayed in the button."
|
|
408
|
+
},
|
|
409
|
+
"attribute": "icon",
|
|
410
|
+
"reflect": false
|
|
411
|
+
},
|
|
412
|
+
"iconOnly": {
|
|
413
|
+
"type": "any",
|
|
414
|
+
"mutable": false,
|
|
415
|
+
"complexType": {
|
|
416
|
+
"original": "boolean | Breakpoint",
|
|
417
|
+
"resolved": "\"l\" | \"m\" | \"s\" | \"xl\" | \"xs\" | boolean",
|
|
418
|
+
"references": {
|
|
419
|
+
"Breakpoint": {
|
|
420
|
+
"location": "import",
|
|
421
|
+
"path": "../../utils/breakpoints"
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
"required": false,
|
|
426
|
+
"optional": false,
|
|
427
|
+
"docs": {
|
|
428
|
+
"tags": [],
|
|
429
|
+
"text": "Hide the actual button content and only display the icon."
|
|
430
|
+
},
|
|
431
|
+
"attribute": "icon-only",
|
|
432
|
+
"reflect": false,
|
|
433
|
+
"defaultValue": "false"
|
|
434
|
+
},
|
|
435
|
+
"iconSuffix": {
|
|
436
|
+
"type": "boolean",
|
|
437
|
+
"mutable": false,
|
|
438
|
+
"complexType": {
|
|
439
|
+
"original": "boolean",
|
|
440
|
+
"resolved": "boolean",
|
|
441
|
+
"references": {}
|
|
442
|
+
},
|
|
443
|
+
"required": false,
|
|
444
|
+
"optional": false,
|
|
445
|
+
"docs": {
|
|
446
|
+
"tags": [],
|
|
447
|
+
"text": "Display the icon as a suffix."
|
|
448
|
+
},
|
|
449
|
+
"attribute": "icon-suffix",
|
|
450
|
+
"reflect": false,
|
|
451
|
+
"defaultValue": "false"
|
|
452
|
+
},
|
|
453
|
+
"buttonId": {
|
|
454
|
+
"type": "string",
|
|
455
|
+
"mutable": false,
|
|
456
|
+
"complexType": {
|
|
457
|
+
"original": "string",
|
|
458
|
+
"resolved": "string | undefined",
|
|
459
|
+
"references": {}
|
|
460
|
+
},
|
|
461
|
+
"required": false,
|
|
462
|
+
"optional": true,
|
|
463
|
+
"docs": {
|
|
464
|
+
"tags": [],
|
|
465
|
+
"text": "Adds a unique identifier for the button. Please note that with this\nparticular component this ID is added inside the web component. If you need\nan ID on the HTML element, use the regular `id` attribute instead."
|
|
466
|
+
},
|
|
467
|
+
"attribute": "button-id",
|
|
468
|
+
"reflect": false
|
|
469
|
+
},
|
|
470
|
+
"a11yLabel": {
|
|
471
|
+
"type": "string",
|
|
472
|
+
"mutable": false,
|
|
473
|
+
"complexType": {
|
|
474
|
+
"original": "string",
|
|
475
|
+
"resolved": "string | undefined",
|
|
476
|
+
"references": {}
|
|
477
|
+
},
|
|
478
|
+
"required": false,
|
|
479
|
+
"optional": true,
|
|
480
|
+
"docs": {
|
|
481
|
+
"tags": [],
|
|
482
|
+
"text": "Adds accessible label for the button that is only shown for screen\nreaders. Typically, this label text replaces the visible text on the\nbutton for users who use assistive technology."
|
|
483
|
+
},
|
|
484
|
+
"attribute": "a11y-label",
|
|
485
|
+
"reflect": false
|
|
486
|
+
}
|
|
487
|
+
}; }
|
|
488
|
+
static get states() { return {
|
|
489
|
+
"_iconOnly": {}
|
|
490
|
+
}; }
|
|
491
|
+
static get events() { return [{
|
|
492
|
+
"method": "catClick",
|
|
493
|
+
"name": "catClick",
|
|
494
|
+
"bubbles": true,
|
|
495
|
+
"cancelable": true,
|
|
496
|
+
"composed": true,
|
|
497
|
+
"docs": {
|
|
498
|
+
"tags": [],
|
|
499
|
+
"text": "Emitted when the button is clicked."
|
|
500
|
+
},
|
|
501
|
+
"complexType": {
|
|
502
|
+
"original": "MouseEvent",
|
|
503
|
+
"resolved": "MouseEvent",
|
|
504
|
+
"references": {
|
|
505
|
+
"MouseEvent": {
|
|
506
|
+
"location": "global"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}, {
|
|
511
|
+
"method": "catFocus",
|
|
512
|
+
"name": "catFocus",
|
|
513
|
+
"bubbles": true,
|
|
514
|
+
"cancelable": true,
|
|
515
|
+
"composed": true,
|
|
516
|
+
"docs": {
|
|
517
|
+
"tags": [],
|
|
518
|
+
"text": "Emitted when the button received focus."
|
|
519
|
+
},
|
|
520
|
+
"complexType": {
|
|
521
|
+
"original": "FocusEvent",
|
|
522
|
+
"resolved": "FocusEvent",
|
|
523
|
+
"references": {
|
|
524
|
+
"FocusEvent": {
|
|
525
|
+
"location": "global"
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}, {
|
|
530
|
+
"method": "catBlur",
|
|
531
|
+
"name": "catBlur",
|
|
532
|
+
"bubbles": true,
|
|
533
|
+
"cancelable": true,
|
|
534
|
+
"composed": true,
|
|
535
|
+
"docs": {
|
|
536
|
+
"tags": [],
|
|
537
|
+
"text": "Emitted when the button loses focus."
|
|
538
|
+
},
|
|
539
|
+
"complexType": {
|
|
540
|
+
"original": "FocusEvent",
|
|
541
|
+
"resolved": "FocusEvent",
|
|
542
|
+
"references": {
|
|
543
|
+
"FocusEvent": {
|
|
544
|
+
"location": "global"
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}]; }
|
|
549
|
+
static get methods() { return {
|
|
550
|
+
"setFocus": {
|
|
551
|
+
"complexType": {
|
|
552
|
+
"signature": "(options?: FocusOptions | undefined) => Promise<void>",
|
|
553
|
+
"parameters": [{
|
|
554
|
+
"tags": [{
|
|
555
|
+
"name": "param",
|
|
556
|
+
"text": "options An optional object providing options to control aspects of\nthe focusing process."
|
|
557
|
+
}],
|
|
558
|
+
"text": "An optional object providing options to control aspects of\nthe focusing process."
|
|
559
|
+
}],
|
|
560
|
+
"references": {
|
|
561
|
+
"Promise": {
|
|
562
|
+
"location": "global"
|
|
563
|
+
},
|
|
564
|
+
"FocusOptions": {
|
|
565
|
+
"location": "global"
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
"return": "Promise<void>"
|
|
569
|
+
},
|
|
570
|
+
"docs": {
|
|
571
|
+
"text": "Sets focus on the button. Use this method instead of `button.focus()`.",
|
|
572
|
+
"tags": [{
|
|
573
|
+
"name": "param",
|
|
574
|
+
"text": "options An optional object providing options to control aspects of\nthe focusing process."
|
|
575
|
+
}]
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}; }
|
|
579
|
+
static get watchers() { return [{
|
|
580
|
+
"propName": "iconOnly",
|
|
581
|
+
"methodName": "onIconOnlyChanged"
|
|
582
|
+
}]; }
|
|
583
|
+
static get listeners() { return [{
|
|
584
|
+
"name": "click",
|
|
585
|
+
"method": "haltDisabledEvents",
|
|
586
|
+
"target": undefined,
|
|
587
|
+
"capture": false,
|
|
588
|
+
"passive": false
|
|
589
|
+
}]; }
|
|
590
|
+
}
|
|
591
|
+
//# sourceMappingURL=cat-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-button.js","sourceRoot":"","sources":["../../../src/components/cat-button/cat-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAc,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;GAOG;AAMH,MAAM,OAAO,SAAS;EALtB;IAWW,cAAS,GAAG,IAAI,CAAC;IAE1B;;OAEG;IACK,YAAO,GAAmC,UAAU,CAAC;IAE7D;;OAEG;IACK,UAAK,GAA+D,WAAW,CAAC;IAExF;;OAEG;IACK,SAAI,GAAkC,GAAG,CAAC;IAgBlD;;;OAGG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;;;OAIG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,WAAM,GAAG,KAAK,CAAC;IAEvB;;OAEG;IACK,aAAQ,GAAG,IAAI,CAAC;IAExB;;OAEG;IACK,UAAK,GAAG,KAAK,CAAC;IAiBtB;;OAEG;IACK,aAAQ,GAAyB,KAAK,CAAC;IAE/C;;OAEG;IACK,eAAU,GAAG,KAAK,CAAC;GAyM5B;EAxLC,iBAAiB,CAAC,KAA2B;;IAC3C,WAAW;IACX,oEAAoE;IACpE,MAAA,IAAI,CAAC,cAAc,0CAAE,mBAAmB,CAAC,QAAQ,EAAE,I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el';\nimport { Breakpoint, Breakpoints, isBreakpoint } from '../../utils/breakpoints';\nimport { MediaMatcher } from '../../utils/media-matcher';\n\n/**\n * Buttons are used for interface actions.\n *\n * @part button - The native anchor or button element.\n * @part content - The textual content of the button.\n * @part prefix - The prefix icon.\n * @part suffix - The suffix icon.\n */\n@Component({\n tag: 'cat-button',\n styleUrl: 'cat-button.scss',\n shadow: true\n})\nexport class CatButton {\n private button!: HTMLButtonElement | HTMLAnchorElement;\n private mediaMatcher?: MediaMatcher;\n private mediaQueryList?: MediaQueryList;\n private mediaQueryListener?: (event: MediaQueryListEvent) => void;\n\n @State() _iconOnly = true;\n\n /**\n * The rendering style of the button.\n */\n @Prop() variant: 'filled' | 'outlined' | 'text' = 'outlined';\n\n /**\n * The color palette of the button.\n */\n @Prop() color: 'primary' | 'secondary' | 'danger' | 'success' | 'warning' = 'secondary';\n\n /**\n * The size of the button.\n */\n @Prop() size: 'xs' | 's' | 'm' | 'l' | 'xl' = 'm';\n\n /**\n * The name of the button, which gets paired with the button's value when\n * submitted as part of a form. Corresponds with the native HTML name\n * attribute.\n */\n @Prop() name?: string;\n\n /**\n * The value of the button, which gets paired with the button's name when\n * submitted as part of a form. Corresponds with the native HTML value\n * attribute.\n */\n @Prop() value?: string;\n\n /**\n * Specifies that the button should be disabled. A disabled button is unusable\n * and un-clickable. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * Displays the button in a loading state with a spinner. Just like a disabled\n * button, an inactive button is unusable and un-clickable. However, it\n * retains the current focus state.\n */\n @Prop() loading = false;\n\n /**\n * Allows the button to submit a form.\n */\n @Prop() submit = false;\n\n /**\n * Ellipse overflowing button content.\n */\n @Prop() ellipsed = true;\n\n /**\n * Use round button edges.\n */\n @Prop() round = false;\n\n /**\n * A destination to link to, rendered in the href attribute of a link.\n */\n @Prop() url?: string;\n\n /**\n * Specifies where to open the linked document.\n */\n @Prop() urlTarget?: '_blank' | '_self';\n\n /**\n * The name of an icon to be displayed in the button.\n */\n @Prop() icon?: string;\n\n /**\n * Hide the actual button content and only display the icon.\n */\n @Prop() iconOnly: boolean | Breakpoint = false;\n\n /**\n * Display the icon as a suffix.\n */\n @Prop() iconSuffix = false;\n\n /**\n * Adds a unique identifier for the button. Please note that with this\n * particular component this ID is added inside the web component. If you need\n * an ID on the HTML element, use the regular `id` attribute instead.\n */\n @Prop() buttonId?: string;\n\n /**\n * Adds accessible label for the button that is only shown for screen\n * readers. Typically, this label text replaces the visible text on the\n * button for users who use assistive technology.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n @Watch('iconOnly')\n onIconOnlyChanged(value: boolean | Breakpoint): void {\n // teardown\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.mediaQueryList?.removeEventListener('change', this.mediaQueryListener!);\n this.mediaQueryList = undefined;\n this.mediaQueryListener = undefined;\n // setup\n if (isBreakpoint(value)) {\n this.mediaMatcher ??= new MediaMatcher();\n this.mediaQueryList = this.mediaMatcher.matchMedia(Breakpoints[value]);\n this.mediaQueryListener = (event: MediaQueryListEvent) => (this._iconOnly = event.matches);\n this.mediaQueryList.addEventListener('change', this.mediaQueryListener);\n this._iconOnly = this.mediaQueryList.matches;\n } else {\n this._iconOnly = value;\n }\n }\n\n /**\n * Emitted when the button is clicked.\n */\n @Event() catClick!: EventEmitter<MouseEvent>;\n\n /**\n * Emitted when the button received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the button loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillLoad(): void {\n this.onIconOnlyChanged(this.iconOnly);\n }\n\n componentWillRender(): void {\n if (this.isIconButton && !this.a11yLabel) {\n log.warn('[A11y] Missing ARIA label on icon button', this);\n }\n }\n\n @Listen('click')\n haltDisabledEvents(event: Event): void {\n if (this.disabled || this.loading) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n /**\n * Sets focus on the button. Use this method instead of `button.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.button.focus(options);\n }\n\n render() {\n if (this.url) {\n return (\n <a\n ref={el => (this.button = el as HTMLAnchorElement)}\n href={this.disabled ? undefined : this.url}\n target={this.urlTarget}\n aria-disabled={this.disabled ? 'true' : null}\n aria-label={this.a11yLabel}\n id={this.buttonId}\n part=\"button\"\n class={{\n 'cat-button': true,\n 'cat-button-icon': this.isIconButton,\n 'cat-button-round': this.round,\n 'cat-button-loading': this.loading,\n 'cat-button-disabled': this.disabled,\n 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,\n [`cat-button-${this.variant}`]: Boolean(this.variant),\n [`cat-button-${this.color}`]: Boolean(this.color),\n [`cat-button-${this.size}`]: Boolean(this.size)\n }}\n onClick={this.onClick.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n >\n {this.content}\n </a>\n );\n } else {\n return (\n <button\n ref={el => (this.button = el as HTMLButtonElement)}\n type={this.submit ? 'submit' : 'button'}\n name={this.name}\n value={this.value}\n disabled={this.disabled}\n aria-disabled={this.disabled ? 'true' : null}\n aria-label={this.a11yLabel}\n id={this.buttonId}\n part=\"button\"\n class={{\n 'cat-button': true,\n 'cat-button-icon': this.isIconButton,\n 'cat-button-round': this.round ?? this.isIconButton,\n 'cat-button-loading': this.loading,\n 'cat-button-disabled': this.disabled,\n 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,\n [`cat-button-${this.variant}`]: Boolean(this.variant),\n [`cat-button-${this.color}`]: Boolean(this.color),\n [`cat-button-${this.size}`]: Boolean(this.size)\n }}\n onClick={this.onClick.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n >\n {this.content}\n </button>\n );\n }\n }\n\n private get iconSize(): 'xs' | 's' | 'm' | 'l' | 'xl' {\n switch (this.size) {\n case 'xs':\n return 's';\n default:\n return 'l';\n }\n }\n\n private get spinnerSize(): 'xs' | 's' | 'm' | 'l' | 'xl' {\n switch (this.size) {\n case 'xs':\n return 'xs';\n default:\n return 'm';\n }\n }\n\n private get isIconButton() {\n return Boolean(this.icon) && this._iconOnly;\n }\n\n private get hasPrefixIcon() {\n return Boolean(this.icon) && !this._iconOnly && !this.iconSuffix;\n }\n\n private get hasSuffixIcon() {\n return Boolean(this.icon) && !this._iconOnly && this.iconSuffix;\n }\n\n private get content() {\n return [\n this.hasPrefixIcon ? (\n <cat-icon icon={this.icon} size={this.iconSize} class=\"cat-button-prefix\" part=\"prefix\"></cat-icon>\n ) : null,\n this.isIconButton ? (\n <cat-icon icon={this.icon} size={this.iconSize}></cat-icon>\n ) : (\n <span class=\"cat-button-content\" part=\"content\">\n <slot></slot>\n </span>\n ),\n this.hasSuffixIcon ? (\n <cat-icon icon={this.icon} size={this.iconSize} class=\"cat-button-suffix\" part=\"suffix\"></cat-icon>\n ) : null,\n this.loading ? <cat-spinner size={this.spinnerSize}></cat-spinner> : null\n ];\n }\n\n private onClick(event: MouseEvent) {\n this.catClick.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class CatIconRegistry {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.icons = new Map();
|
|
4
|
+
// hide constructor
|
|
5
|
+
}
|
|
6
|
+
static getInstance() {
|
|
7
|
+
if (!CatIconRegistry.instance) {
|
|
8
|
+
CatIconRegistry.instance = new CatIconRegistry();
|
|
9
|
+
}
|
|
10
|
+
return CatIconRegistry.instance;
|
|
11
|
+
}
|
|
12
|
+
getIcon(name, setName) {
|
|
13
|
+
return this.icons.get(this.buildName(name, setName));
|
|
14
|
+
}
|
|
15
|
+
addIcon(name, data, setName) {
|
|
16
|
+
this.icons.set(this.buildName(name, setName), data);
|
|
17
|
+
window.dispatchEvent(this.buildEvent('cat-icon-added', { name, setName }));
|
|
18
|
+
}
|
|
19
|
+
addIcons(icons, setName) {
|
|
20
|
+
Object.entries(icons).forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));
|
|
21
|
+
window.dispatchEvent(this.buildEvent('cat-icons-added', { names: Object.keys(icons), setName }));
|
|
22
|
+
}
|
|
23
|
+
removeIcon(name, setName) {
|
|
24
|
+
this.icons.delete(this.buildName(name, setName));
|
|
25
|
+
window.dispatchEvent(this.buildEvent('cat-icon-removed', { name, setName }));
|
|
26
|
+
}
|
|
27
|
+
removeIcons(names, setName) {
|
|
28
|
+
names.forEach(name => this.icons.delete(this.buildName(name, setName)));
|
|
29
|
+
window.dispatchEvent(this.buildEvent('cat-icons-removed', { names, setName }));
|
|
30
|
+
}
|
|
31
|
+
buildName(name, setName) {
|
|
32
|
+
return setName ? `${setName}:name` : name;
|
|
33
|
+
}
|
|
34
|
+
buildEvent(name, detail) {
|
|
35
|
+
return new CustomEvent(name, {
|
|
36
|
+
bubbles: true,
|
|
37
|
+
composed: true,
|
|
38
|
+
detail
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=cat-icon-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat-icon-registry.js","sourceRoot":"","sources":["../../../src/components/cat-icon/cat-icon-registry.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;EAK1B;IAFiB,UAAK,GAAwB,IAAI,GAAG,EAAE,CAAC;IAGtD,mBAAmB;EACrB,CAAC;EAED,MAAM,CAAC,WAAW;IAChB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;MAC7B,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;KAClD;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC;EAClC,CAAC;EAED,OAAO,CAAC,IAAY,EAAE,OAAgB;IACpC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CA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,CAAC,CAAC,CAAC,CAAC;IACxE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;EACjF,CAAC;EAEO,SAAS,CAAC,IAAY,EAAE,OAAgB;IAC9C,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;EAC5C,CAAC;EAEO,UAAU,CAAI,IAAY,EAAE,MAAU;IAC5C,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE;MAC3B,OAAO,EAAE,IAAI;MACb,QAAQ,EAAE,IAAI;MACd,MAAM;KACP,CAAC,CAAC;EACL,CAAC;CACF","sourcesContent":["export class CatIconRegistry {\n private static instance: CatIconRegistry;\n\n private readonly icons: Map<string, string> = new Map();\n\n private constructor() {\n // hide constructor\n }\n\n static getInstance(): CatIconRegistry {\n if (!CatIconRegistry.instance) {\n CatIconRegistry.instance = new CatIconRegistry();\n }\n return CatIconRegistry.instance;\n }\n\n getIcon(name: string, setName?: string): string | undefined {\n return this.icons.get(this.buildName(name, setName));\n }\n\n addIcon(name: string, data: string, setName?: string): void {\n this.icons.set(this.buildName(name, setName), data);\n window.dispatchEvent(this.buildEvent('cat-icon-added', { name, setName }));\n }\n\n addIcons(icons: { [name: string]: string }, setName?: string): void {\n Object.entries(icons).forEach(([name, data]) => this.icons.set(this.buildName(name, setName), data));\n window.dispatchEvent(this.buildEvent('cat-icons-added', { names: Object.keys(icons), setName }));\n }\n\n removeIcon(name: string, setName?: string): void {\n this.icons.delete(this.buildName(name, setName));\n window.dispatchEvent(this.buildEvent('cat-icon-removed', { name, setName }));\n }\n\n removeIcons(names: string[], setName?: string): void {\n names.forEach(name => this.icons.delete(this.buildName(name, setName)));\n window.dispatchEvent(this.buildEvent('cat-icons-removed', { names, setName }));\n }\n\n private buildName(name: string, setName?: string) {\n return setName ? `${setName}:name` : name;\n }\n\n private buildEvent<T>(name: string, detail?: T) {\n return new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail\n });\n }\n}\n"]}
|