@telesign/boreal-web-components 0.1.0-alpha.1 → 0.1.0-alpha.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/components-build/bds-banner.js +1 -1
- package/components-build/bds-button.d.ts +11 -0
- package/components-build/bds-button.js +1 -0
- package/components-build/bds-typography.js +1 -1
- package/components-build/index.js +1 -1
- package/components-build/p-Ba6iHqJA.js +1 -0
- package/components-build/p-DQR-jjOl.js +1 -0
- package/custom-elements.json +352 -2
- package/dist/boreal-web-components/boreal-web-components.esm.js +1 -1
- package/dist/boreal-web-components/boreal-web-components.js +1 -1
- package/dist/boreal-web-components/p-08bd6bed.system.entry.js +1 -0
- package/dist/boreal-web-components/p-1575fe61.system.entry.js +1 -0
- package/dist/boreal-web-components/p-657c12a3.system.entry.js +1 -0
- package/dist/boreal-web-components/p-66bb3c44.entry.js +1 -0
- package/dist/boreal-web-components/p-742f39ef.entry.js +1 -0
- package/dist/boreal-web-components/p-BG1kmb4c.system.js +1 -0
- package/dist/boreal-web-components/p-B_tL_RWF.system.js +2 -0
- package/dist/boreal-web-components/p-Ba6iHqJA.js +1 -0
- package/dist/boreal-web-components/p-DIvR9Mw7.system.js +1 -0
- package/dist/boreal-web-components/p-DKPZ4_C0.system.js +1 -0
- package/dist/boreal-web-components/p-DQR-jjOl.js +1 -0
- package/dist/boreal-web-components/p-DQvmq159.js +2 -0
- package/dist/boreal-web-components/p-e4a075ba.entry.js +1 -0
- package/dist/cjs/{attributes-RPVEtBdj.js → attributes-D0WPida0.js} +0 -9
- package/dist/cjs/bds-banner.cjs.entry.js +4 -3
- package/dist/cjs/bds-button.cjs.entry.js +185 -0
- package/dist/cjs/bds-typography.cjs.entry.js +10 -9
- package/dist/cjs/boreal-web-components.cjs.js +2 -2
- package/dist/cjs/{index-Cdb66Tqj.js → index-C9JKWXwa.js} +41 -4
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/states-C03fKOhs.js +12 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/actions/bds-button/bds-button.css +479 -0
- package/dist/collection/components/actions/bds-button/bds-button.js +459 -0
- package/dist/collection/components/actions/bds-button/types/IButton.js +1 -0
- package/dist/collection/components/actions/bds-button/types/enum.js +15 -0
- package/dist/collection/components/actions/bds-button/types/types.js +1 -0
- package/dist/collection/components/titles-text/bds-typography/bds-typography.js +5 -5
- package/dist/collection/components/titles-text/bds-typography/utils/bds-typography-utils.js +5 -5
- package/dist/collection/types/coreColors.js +6 -0
- package/dist/collection/types/states.js +1 -1
- package/dist/collection/utils/helpers/validateProps.js +16 -0
- package/dist/esm/{attributes-B9wshZ_4.js → attributes-Ba6iHqJA.js} +1 -8
- package/dist/esm/bds-banner.entry.js +3 -2
- package/dist/esm/bds-button.entry.js +183 -0
- package/dist/esm/bds-typography.entry.js +10 -9
- package/dist/esm/boreal-web-components.js +3 -3
- package/dist/esm/{index-DgFiTd6X.js → index-DQvmq159.js} +41 -4
- package/dist/esm/loader.js +3 -3
- package/dist/esm/states-DQR-jjOl.js +9 -0
- package/{components-build/p-B9wshZ_4.js → dist/esm-es5/attributes-Ba6iHqJA.js} +1 -1
- package/dist/esm-es5/bds-banner.entry.js +1 -1
- package/dist/esm-es5/bds-button.entry.js +1 -0
- package/dist/esm-es5/bds-typography.entry.js +1 -1
- package/dist/esm-es5/boreal-web-components.js +1 -1
- package/dist/esm-es5/index-DQvmq159.js +2 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/states-DQR-jjOl.js +1 -0
- package/dist/types/components/actions/bds-button/bds-button.d.ts +90 -0
- package/dist/types/components/actions/bds-button/types/IButton.d.ts +14 -0
- package/dist/types/components/actions/bds-button/types/enum.d.ts +16 -0
- package/dist/types/components/actions/bds-button/types/types.d.ts +5 -0
- package/dist/types/components/titles-text/bds-typography/types/ITypography.d.ts +2 -2
- package/dist/types/components/titles-text/bds-typography/utils/bds-typography-utils.d.ts +2 -2
- package/dist/types/components.d.ts +269 -2
- package/dist/types/types/coreColors.d.ts +8 -0
- package/dist/types/types/states.d.ts +2 -2
- package/dist/types/utils/helpers/validateProps.d.ts +11 -0
- package/package.json +4 -3
- package/dist/boreal-web-components/p-69d89caa.entry.js +0 -1
- package/dist/boreal-web-components/p-B9wshZ_4.js +0 -1
- package/dist/boreal-web-components/p-BQdH0ijK.system.js +0 -2
- package/dist/boreal-web-components/p-CMd-Mv-5.system.js +0 -1
- package/dist/boreal-web-components/p-CaVEtaG3.system.js +0 -1
- package/dist/boreal-web-components/p-DgFiTd6X.js +0 -2
- package/dist/boreal-web-components/p-c3c558d2.system.entry.js +0 -1
- package/dist/boreal-web-components/p-d596406b.entry.js +0 -1
- package/dist/boreal-web-components/p-e37e7dba.system.entry.js +0 -1
- package/dist/esm-es5/attributes-B9wshZ_4.js +0 -1
- package/dist/esm-es5/index-DgFiTd6X.js +0 -2
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { COMPONENT_STATES } from "../../../types/index";
|
|
3
|
+
import { BUTTON_SIZES, BUTTON_TYPES, BUTTON_VARIANTS } from "./types/enum";
|
|
4
|
+
import { CORE_COLORS } from "../../../types/coreColors";
|
|
5
|
+
//import { emitEvent } from '@/utils/helpers/eventEmitter';
|
|
6
|
+
import { validatePropValue } from "../../../utils/helpers/validateProps";
|
|
7
|
+
/**
|
|
8
|
+
* Button component for user interactions, form submissions, supporting various styles, sizes, and states.
|
|
9
|
+
*
|
|
10
|
+
* @summary A versatile button component that can be customized with different colors, sizes, variants and states to fit various use cases in the application.
|
|
11
|
+
* @slot - The content of the button, typically text or an icon.
|
|
12
|
+
* @slot icon - Content to show an icon at the begining of the button
|
|
13
|
+
* @slot badge - Slot to place a badge component
|
|
14
|
+
*
|
|
15
|
+
* @attr {string} label - The accessible name for the button, used for screen readers. It should be provided by the user for accessibility purposes.
|
|
16
|
+
* @attr {boolean} disabled - Disables the button when true, preventing user interaction and applying disabled styles.
|
|
17
|
+
* @attr {string} name - The name attribute for the button, useful for form submissions.
|
|
18
|
+
* @attr {string} type - The type of the button, which can be 'button', 'submit', or 'reset'. Default is 'button'.
|
|
19
|
+
* @attr {string} color - The color theme of the button, which can be 'default', 'primary', 'success', or 'error'. Default is 'default'.
|
|
20
|
+
* @attr {string} variant - The visual style of the button, which can be 'default', 'outline', or 'plain'. Default is 'default'.
|
|
21
|
+
* @attr {string} size - The size of the button, which can be 'small', 'medium', or 'large'. Default is 'medium'.
|
|
22
|
+
* @attr {boolean} loading - Indicates whether the button is in a loading state, which can be used to show a loading spinner and disable the button. Default is false.
|
|
23
|
+
* @attr {boolean} disclosure - Indicates if the button should show a chevron down at the end of the content.
|
|
24
|
+
*
|
|
25
|
+
* @property {string} label - The accessible name for the button, used for screen readers. It should be provided by the user for accessibility purposes.
|
|
26
|
+
* @property {boolean} disabled - Disables the button when true, preventing user interaction and applying disabled styles.
|
|
27
|
+
* @property {string} name - The name attribute for the button, useful for form submissions.
|
|
28
|
+
* @property {string} type - The type of the button, which can be 'button', 'submit', or 'reset'. Default is 'button'.
|
|
29
|
+
* @property {string} color - The color theme of the button, which can be 'default', 'primary', 'success', or 'error'. Default is 'default'.
|
|
30
|
+
* @property {string} variant - The visual style of the button, which can be 'default', 'outline', or 'plain'. Default is 'default'.
|
|
31
|
+
* @property {string} size - The size of the button, which can be 'small', 'medium', or 'large'. Default is 'medium'.
|
|
32
|
+
* @property {boolean} loading - Indicates whether the button is in a loading state, which can be used to show a loading spinner and disable the button. Default is false.
|
|
33
|
+
* @property {boolean} disclosure - Indicates if the button should show a chevron down at the end of the content.
|
|
34
|
+
*
|
|
35
|
+
* @default 'button' - Default type value
|
|
36
|
+
* @default 'default' - Default color value
|
|
37
|
+
* @default 'default' - Default variant value
|
|
38
|
+
* @default 'medium' - Default size value
|
|
39
|
+
* @default 'default' - Default status value
|
|
40
|
+
* @default false - Default disabled value
|
|
41
|
+
* @default '' - Default label value
|
|
42
|
+
* @default '' - Default name value
|
|
43
|
+
* @default false - Default loading value
|
|
44
|
+
* @default false - Default disclosure value
|
|
45
|
+
*/
|
|
46
|
+
export class BdsButton {
|
|
47
|
+
constructor() {
|
|
48
|
+
/** State to manage states */
|
|
49
|
+
this.currentState = COMPONENT_STATES.DEFAULT;
|
|
50
|
+
/* Props to manage the button attributes */
|
|
51
|
+
/** The accessible name for the button, used for screen readers. It should be provided by the user for accessibility purposes. */
|
|
52
|
+
this.label = '';
|
|
53
|
+
/** disabled is a boolean attribute. Disables the button when true, preventing user interaction and applying disabled styles. */
|
|
54
|
+
this.disabled = false;
|
|
55
|
+
/** name is a string attribute. The name attribute for the button, useful for form submissions. */
|
|
56
|
+
this.name = '';
|
|
57
|
+
/** type is a string attribute. The type of the button, which can be 'button', 'submit', or 'reset'. Default is 'button'. */
|
|
58
|
+
this.type = BUTTON_TYPES.BUTTON;
|
|
59
|
+
/** color is a string attribute. The color theme of the button, which can be 'default', 'primary', 'success', or 'error'. Default is 'default'. */
|
|
60
|
+
this.color = CORE_COLORS.DEFAULT;
|
|
61
|
+
/** variant is a string attribute. The visual style of the button, which can be 'default', 'outline', or 'plain'. Default is 'default'.*/
|
|
62
|
+
this.variant = BUTTON_VARIANTS.DEFAULT;
|
|
63
|
+
/** size is a string attribute. The size of the button, which can be 'small', 'medium', or 'large'. Default is 'medium'. */
|
|
64
|
+
this.size = BUTTON_SIZES.MEDIUM;
|
|
65
|
+
/** loading is a boolean attribute. Indicates whether the button is in a loading state, which can be used to show a loading spinner and disable the button. Default is false. */
|
|
66
|
+
this.loading = false;
|
|
67
|
+
/** disclosure is a boolean attribute. Used to show a chevron down at the of the content */
|
|
68
|
+
this.disclosure = false;
|
|
69
|
+
/** Event for listen keydown from button, make navigation easier */
|
|
70
|
+
this.handleKeyDown = (event) => {
|
|
71
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
72
|
+
this.currentState = COMPONENT_STATES.ACTIVE;
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
this.bdsClick.emit(event);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/** reset status on keyup */
|
|
78
|
+
this.handleKeyUp = () => {
|
|
79
|
+
this.currentState = COMPONENT_STATES.DEFAULT;
|
|
80
|
+
};
|
|
81
|
+
/** Method to handle custom click events */
|
|
82
|
+
this.handleClick = (event) => {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
event.stopPropagation();
|
|
85
|
+
if (this.disabled || this.loading)
|
|
86
|
+
return;
|
|
87
|
+
if (this.type === BUTTON_TYPES.SUBMIT || this.type === BUTTON_TYPES.RESET) {
|
|
88
|
+
this.processFormClick();
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.bdsClick.emit(event);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Validate props */
|
|
96
|
+
checkPropValues() {
|
|
97
|
+
validatePropValue(Object.values(BUTTON_TYPES), BUTTON_TYPES.BUTTON, this.el, 'type');
|
|
98
|
+
validatePropValue(Object.values(CORE_COLORS), CORE_COLORS.DEFAULT, this.el, 'color');
|
|
99
|
+
validatePropValue(Object.values(BUTTON_VARIANTS), BUTTON_VARIANTS.DEFAULT, this.el, 'variant');
|
|
100
|
+
validatePropValue(Object.values(BUTTON_SIZES), BUTTON_SIZES.MEDIUM, this.el, 'size');
|
|
101
|
+
}
|
|
102
|
+
/** */
|
|
103
|
+
componentWillLoad() {
|
|
104
|
+
this.checkPropValues();
|
|
105
|
+
}
|
|
106
|
+
/** After component rendered */
|
|
107
|
+
componentDidLoad() {
|
|
108
|
+
this.setupFormAssociation();
|
|
109
|
+
}
|
|
110
|
+
/** Select closest form or internal form from ElementInternals */
|
|
111
|
+
setupFormAssociation() {
|
|
112
|
+
const closestForm = this.el.closest('form');
|
|
113
|
+
const intForm = this.internals && 'form' in this.internals ? this.internals.form : null;
|
|
114
|
+
this.internalForm = intForm || closestForm || undefined;
|
|
115
|
+
}
|
|
116
|
+
/** Decide which form action to perform based on button type */
|
|
117
|
+
processFormClick() {
|
|
118
|
+
if (this.internalForm === undefined) {
|
|
119
|
+
console.warn('[BorealDS Button] No form found for submit/reset action. Please ensure the button is within a form or that the form is properly associated.');
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const events = {
|
|
123
|
+
[BUTTON_TYPES.SUBMIT]: () => {
|
|
124
|
+
if (typeof this.internalForm?.requestSubmit === 'function') {
|
|
125
|
+
this.internalForm.requestSubmit();
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this.internalForm?.submit();
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
[BUTTON_TYPES.RESET]: () => this.internalForm?.reset(),
|
|
132
|
+
};
|
|
133
|
+
const action = events[this.type];
|
|
134
|
+
if (typeof action === 'function') {
|
|
135
|
+
action();
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
/* Method to get the class map for the button based on the props */
|
|
140
|
+
get getClassMap() {
|
|
141
|
+
return {
|
|
142
|
+
'bds-button': true,
|
|
143
|
+
'bds-button--is-disabled': this.disabled,
|
|
144
|
+
'bds-button--is-loading': this.loading,
|
|
145
|
+
[`bds-button--state-${this.currentState}`]: true,
|
|
146
|
+
[`bds-button--${this.color}`]: true,
|
|
147
|
+
[`bds-button--var-${this.variant}`]: true,
|
|
148
|
+
[`bds-button--size-${this.size}`]: true,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/* render button depends on variant */
|
|
152
|
+
render() {
|
|
153
|
+
return (h("button", { key: '937ea6972ca39ef41aec1d8c6459a224c84b8390', name: this.name, class: this.getClassMap, type: this.type, disabled: this.disabled || this.loading, "aria-label": this.label || undefined, "aria-disabled": this.disabled || this.loading, onClick: this.handleClick, onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp }, h("div", { key: 'f9adeb219026e966ce85db7127696e9bc60adb57', class: "bds-button__content" }, h("span", { key: 'e4dbb94477218eb831f534ffdd7b816532718b22', class: "bds-button__content-icon bds-button__content-icon--start" }, h("slot", { key: 'a04168309cfd6bba4eb47d4aa8c2e43f44df4d12', name: "icon" })), h("slot", { key: '47094f3e68f8b98fa16c6ab6e75fa2fcaeb0a8cd' }), h("span", { key: 'fb548f03228e22abdb1deaf56b60fcc7ed53a9e9', class: "bds-button__content-badge" }, h("slot", { key: '7e2d30d8c750f1472825618be9730ddedc974bd1', name: "badge" })), this.disclosure && (h("span", { key: 'eb4ba3930fc8a936d6825ce35961a9a9b2866be6', class: "bds-button__content-icon" }, h("i", { key: '8bafff19aedeacc4dfae9fd9a5b9006ffb185d85', class: "bds-icon-chevron-down" }))))));
|
|
154
|
+
}
|
|
155
|
+
static get is() { return "bds-button"; }
|
|
156
|
+
static get formAssociated() { return true; }
|
|
157
|
+
static get originalStyleUrls() {
|
|
158
|
+
return {
|
|
159
|
+
"$": ["bds-button.scss"]
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
static get styleUrls() {
|
|
163
|
+
return {
|
|
164
|
+
"$": ["bds-button.css"]
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
static get properties() {
|
|
168
|
+
return {
|
|
169
|
+
"label": {
|
|
170
|
+
"type": "string",
|
|
171
|
+
"mutable": false,
|
|
172
|
+
"complexType": {
|
|
173
|
+
"original": "IButton['label']",
|
|
174
|
+
"resolved": "string",
|
|
175
|
+
"references": {
|
|
176
|
+
"IButton": {
|
|
177
|
+
"location": "import",
|
|
178
|
+
"path": "./types/IButton",
|
|
179
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
180
|
+
"referenceLocation": "IButton"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "The accessible name for the button, used for screen readers. It should be provided by the user for accessibility purposes."
|
|
189
|
+
},
|
|
190
|
+
"getter": false,
|
|
191
|
+
"setter": false,
|
|
192
|
+
"reflect": false,
|
|
193
|
+
"attribute": "label",
|
|
194
|
+
"defaultValue": "''"
|
|
195
|
+
},
|
|
196
|
+
"disabled": {
|
|
197
|
+
"type": "boolean",
|
|
198
|
+
"mutable": false,
|
|
199
|
+
"complexType": {
|
|
200
|
+
"original": "IButton['disabled']",
|
|
201
|
+
"resolved": "boolean",
|
|
202
|
+
"references": {
|
|
203
|
+
"IButton": {
|
|
204
|
+
"location": "import",
|
|
205
|
+
"path": "./types/IButton",
|
|
206
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
207
|
+
"referenceLocation": "IButton"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"required": false,
|
|
212
|
+
"optional": false,
|
|
213
|
+
"docs": {
|
|
214
|
+
"tags": [],
|
|
215
|
+
"text": "disabled is a boolean attribute. Disables the button when true, preventing user interaction and applying disabled styles."
|
|
216
|
+
},
|
|
217
|
+
"getter": false,
|
|
218
|
+
"setter": false,
|
|
219
|
+
"reflect": false,
|
|
220
|
+
"attribute": "disabled",
|
|
221
|
+
"defaultValue": "false"
|
|
222
|
+
},
|
|
223
|
+
"name": {
|
|
224
|
+
"type": "string",
|
|
225
|
+
"mutable": false,
|
|
226
|
+
"complexType": {
|
|
227
|
+
"original": "IButton['name']",
|
|
228
|
+
"resolved": "string",
|
|
229
|
+
"references": {
|
|
230
|
+
"IButton": {
|
|
231
|
+
"location": "import",
|
|
232
|
+
"path": "./types/IButton",
|
|
233
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
234
|
+
"referenceLocation": "IButton"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"required": false,
|
|
239
|
+
"optional": false,
|
|
240
|
+
"docs": {
|
|
241
|
+
"tags": [],
|
|
242
|
+
"text": "name is a string attribute. The name attribute for the button, useful for form submissions."
|
|
243
|
+
},
|
|
244
|
+
"getter": false,
|
|
245
|
+
"setter": false,
|
|
246
|
+
"reflect": false,
|
|
247
|
+
"attribute": "name",
|
|
248
|
+
"defaultValue": "''"
|
|
249
|
+
},
|
|
250
|
+
"type": {
|
|
251
|
+
"type": "string",
|
|
252
|
+
"mutable": false,
|
|
253
|
+
"complexType": {
|
|
254
|
+
"original": "IButton['type']",
|
|
255
|
+
"resolved": "\"button\" | \"reset\" | \"submit\"",
|
|
256
|
+
"references": {
|
|
257
|
+
"IButton": {
|
|
258
|
+
"location": "import",
|
|
259
|
+
"path": "./types/IButton",
|
|
260
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
261
|
+
"referenceLocation": "IButton"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"required": false,
|
|
266
|
+
"optional": false,
|
|
267
|
+
"docs": {
|
|
268
|
+
"tags": [],
|
|
269
|
+
"text": "type is a string attribute. The type of the button, which can be 'button', 'submit', or 'reset'. Default is 'button'."
|
|
270
|
+
},
|
|
271
|
+
"getter": false,
|
|
272
|
+
"setter": false,
|
|
273
|
+
"reflect": false,
|
|
274
|
+
"attribute": "type",
|
|
275
|
+
"defaultValue": "BUTTON_TYPES.BUTTON"
|
|
276
|
+
},
|
|
277
|
+
"color": {
|
|
278
|
+
"type": "string",
|
|
279
|
+
"mutable": false,
|
|
280
|
+
"complexType": {
|
|
281
|
+
"original": "IButton['color']",
|
|
282
|
+
"resolved": "\"default\" | \"error\" | \"primary\" | \"success\"",
|
|
283
|
+
"references": {
|
|
284
|
+
"IButton": {
|
|
285
|
+
"location": "import",
|
|
286
|
+
"path": "./types/IButton",
|
|
287
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
288
|
+
"referenceLocation": "IButton"
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"required": false,
|
|
293
|
+
"optional": false,
|
|
294
|
+
"docs": {
|
|
295
|
+
"tags": [],
|
|
296
|
+
"text": "color is a string attribute. The color theme of the button, which can be 'default', 'primary', 'success', or 'error'. Default is 'default'."
|
|
297
|
+
},
|
|
298
|
+
"getter": false,
|
|
299
|
+
"setter": false,
|
|
300
|
+
"reflect": false,
|
|
301
|
+
"attribute": "color",
|
|
302
|
+
"defaultValue": "CORE_COLORS.DEFAULT"
|
|
303
|
+
},
|
|
304
|
+
"variant": {
|
|
305
|
+
"type": "string",
|
|
306
|
+
"mutable": false,
|
|
307
|
+
"complexType": {
|
|
308
|
+
"original": "IButton['variant']",
|
|
309
|
+
"resolved": "\"default\" | \"outline\" | \"plain\"",
|
|
310
|
+
"references": {
|
|
311
|
+
"IButton": {
|
|
312
|
+
"location": "import",
|
|
313
|
+
"path": "./types/IButton",
|
|
314
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
315
|
+
"referenceLocation": "IButton"
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
"required": false,
|
|
320
|
+
"optional": false,
|
|
321
|
+
"docs": {
|
|
322
|
+
"tags": [],
|
|
323
|
+
"text": "variant is a string attribute. The visual style of the button, which can be 'default', 'outline', or 'plain'. Default is 'default'."
|
|
324
|
+
},
|
|
325
|
+
"getter": false,
|
|
326
|
+
"setter": false,
|
|
327
|
+
"reflect": false,
|
|
328
|
+
"attribute": "variant",
|
|
329
|
+
"defaultValue": "BUTTON_VARIANTS.DEFAULT"
|
|
330
|
+
},
|
|
331
|
+
"size": {
|
|
332
|
+
"type": "string",
|
|
333
|
+
"mutable": false,
|
|
334
|
+
"complexType": {
|
|
335
|
+
"original": "IButton['size']",
|
|
336
|
+
"resolved": "\"large\" | \"medium\" | \"small\"",
|
|
337
|
+
"references": {
|
|
338
|
+
"IButton": {
|
|
339
|
+
"location": "import",
|
|
340
|
+
"path": "./types/IButton",
|
|
341
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
342
|
+
"referenceLocation": "IButton"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
"required": false,
|
|
347
|
+
"optional": false,
|
|
348
|
+
"docs": {
|
|
349
|
+
"tags": [],
|
|
350
|
+
"text": "size is a string attribute. The size of the button, which can be 'small', 'medium', or 'large'. Default is 'medium'."
|
|
351
|
+
},
|
|
352
|
+
"getter": false,
|
|
353
|
+
"setter": false,
|
|
354
|
+
"reflect": false,
|
|
355
|
+
"attribute": "size",
|
|
356
|
+
"defaultValue": "BUTTON_SIZES.MEDIUM"
|
|
357
|
+
},
|
|
358
|
+
"loading": {
|
|
359
|
+
"type": "boolean",
|
|
360
|
+
"mutable": false,
|
|
361
|
+
"complexType": {
|
|
362
|
+
"original": "IButton['loading']",
|
|
363
|
+
"resolved": "boolean",
|
|
364
|
+
"references": {
|
|
365
|
+
"IButton": {
|
|
366
|
+
"location": "import",
|
|
367
|
+
"path": "./types/IButton",
|
|
368
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
369
|
+
"referenceLocation": "IButton"
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
"required": false,
|
|
374
|
+
"optional": false,
|
|
375
|
+
"docs": {
|
|
376
|
+
"tags": [],
|
|
377
|
+
"text": "loading is a boolean attribute. Indicates whether the button is in a loading state, which can be used to show a loading spinner and disable the button. Default is false."
|
|
378
|
+
},
|
|
379
|
+
"getter": false,
|
|
380
|
+
"setter": false,
|
|
381
|
+
"reflect": false,
|
|
382
|
+
"attribute": "loading",
|
|
383
|
+
"defaultValue": "false"
|
|
384
|
+
},
|
|
385
|
+
"disclosure": {
|
|
386
|
+
"type": "boolean",
|
|
387
|
+
"mutable": false,
|
|
388
|
+
"complexType": {
|
|
389
|
+
"original": "IButton['disclosure']",
|
|
390
|
+
"resolved": "boolean",
|
|
391
|
+
"references": {
|
|
392
|
+
"IButton": {
|
|
393
|
+
"location": "import",
|
|
394
|
+
"path": "./types/IButton",
|
|
395
|
+
"id": "src/components/actions/bds-button/types/IButton.ts::IButton",
|
|
396
|
+
"referenceLocation": "IButton"
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
"required": false,
|
|
401
|
+
"optional": false,
|
|
402
|
+
"docs": {
|
|
403
|
+
"tags": [],
|
|
404
|
+
"text": "disclosure is a boolean attribute. Used to show a chevron down at the of the content"
|
|
405
|
+
},
|
|
406
|
+
"getter": false,
|
|
407
|
+
"setter": false,
|
|
408
|
+
"reflect": false,
|
|
409
|
+
"attribute": "disclosure",
|
|
410
|
+
"defaultValue": "false"
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
static get states() {
|
|
415
|
+
return {
|
|
416
|
+
"currentState": {}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
static get events() {
|
|
420
|
+
return [{
|
|
421
|
+
"method": "bdsClick",
|
|
422
|
+
"name": "bdsClick",
|
|
423
|
+
"bubbles": true,
|
|
424
|
+
"cancelable": true,
|
|
425
|
+
"composed": true,
|
|
426
|
+
"docs": {
|
|
427
|
+
"tags": [],
|
|
428
|
+
"text": "emit event to click"
|
|
429
|
+
},
|
|
430
|
+
"complexType": {
|
|
431
|
+
"original": "UIEvent",
|
|
432
|
+
"resolved": "UIEvent",
|
|
433
|
+
"references": {
|
|
434
|
+
"UIEvent": {
|
|
435
|
+
"location": "global",
|
|
436
|
+
"id": "global::UIEvent"
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}];
|
|
441
|
+
}
|
|
442
|
+
static get elementRef() { return "el"; }
|
|
443
|
+
static get watchers() {
|
|
444
|
+
return [{
|
|
445
|
+
"propName": "type",
|
|
446
|
+
"methodName": "checkPropValues"
|
|
447
|
+
}, {
|
|
448
|
+
"propName": "color",
|
|
449
|
+
"methodName": "checkPropValues"
|
|
450
|
+
}, {
|
|
451
|
+
"propName": "variant",
|
|
452
|
+
"methodName": "checkPropValues"
|
|
453
|
+
}, {
|
|
454
|
+
"propName": "size",
|
|
455
|
+
"methodName": "checkPropValues"
|
|
456
|
+
}];
|
|
457
|
+
}
|
|
458
|
+
static get attachInternalsMemberName() { return "internals"; }
|
|
459
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const BUTTON_VARIANTS = {
|
|
2
|
+
DEFAULT: 'default',
|
|
3
|
+
OUTLINE: 'outline',
|
|
4
|
+
PLAIN: 'plain',
|
|
5
|
+
};
|
|
6
|
+
export const BUTTON_SIZES = {
|
|
7
|
+
SMALL: 'small',
|
|
8
|
+
MEDIUM: 'medium',
|
|
9
|
+
LARGE: 'large',
|
|
10
|
+
};
|
|
11
|
+
export const BUTTON_TYPES = {
|
|
12
|
+
BUTTON: 'button',
|
|
13
|
+
SUBMIT: 'submit',
|
|
14
|
+
RESET: 'reset',
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { ALIGNMENT } from "../../../types/alignment";
|
|
3
3
|
import { SIZES } from "../../../types/size";
|
|
4
|
-
import {
|
|
4
|
+
import { COMPONENT_STATES } from "../../../types/states";
|
|
5
5
|
import { inheritAriaAttributes } from "../../../utils/a11y/index";
|
|
6
6
|
import { TAG_ELEMENT, VARIANT_TYPOGRAPHY } from "./types/enum";
|
|
7
7
|
import { FILENAME, getAttributesByTag, VARIANT_CONFIG } from "./utils/bds-typography-utils";
|
|
@@ -66,7 +66,7 @@ export class BdsTypography {
|
|
|
66
66
|
/** Typography size token. */
|
|
67
67
|
this.size = SIZES.M;
|
|
68
68
|
/** Visual state (if supported by variant). */
|
|
69
|
-
this.state =
|
|
69
|
+
this.state = COMPONENT_STATES.DEFAULT;
|
|
70
70
|
/** Additional custom CSS class. */
|
|
71
71
|
this.customClass = '';
|
|
72
72
|
/** HTML tag used for rendering. */
|
|
@@ -122,7 +122,7 @@ export class BdsTypography {
|
|
|
122
122
|
const isInteractiveTag = ['a', 'label'].includes(this.getTagName);
|
|
123
123
|
return {
|
|
124
124
|
'aria-required': this.isRequired && isRequired,
|
|
125
|
-
'aria-disabled': this.state ===
|
|
125
|
+
'aria-disabled': this.state === COMPONENT_STATES.DISABLED && isInteractiveTag,
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
getVariantStateStyles() {
|
|
@@ -147,7 +147,7 @@ export class BdsTypography {
|
|
|
147
147
|
};
|
|
148
148
|
const classes = this.getVariantStateStyles();
|
|
149
149
|
const { canUseTooltip = null, isRequired = null } = this.getVariantConfig();
|
|
150
|
-
return (h(Host, { key: '
|
|
150
|
+
return (h(Host, { key: '80c41f5a33f3089005b9cdf2c7db51e07272b5df', class: "bds-typography" }, h(TagName, { key: '623e0a57bf2341ecaeba7e670d01a06f891f4423', class: classes, style: { webkitLineClamp: this.maxLines }, ...attributes }, h("slot", { key: 'fa7fa6e7f6cbe6133a1c52bf2f219b2927847a88' }), this.isRequired && isRequired && (h("em", { key: 'aa339d8fbf758491db17ac9c471327a0466bf3dc', class: "bds-typography__required-indicator", "aria-hidden": "true" }, "*")), this.tooltipText && canUseTooltip && h("em", { key: '98a6c58192b585fbbe01a93c031e9ae3c20cf3ca', class: "bds-typography__info-icon bds-icon-info-circle" }))));
|
|
151
151
|
}
|
|
152
152
|
static get is() { return "bds-typography"; }
|
|
153
153
|
static get originalStyleUrls() {
|
|
@@ -241,7 +241,7 @@ export class BdsTypography {
|
|
|
241
241
|
"setter": false,
|
|
242
242
|
"reflect": true,
|
|
243
243
|
"attribute": "state",
|
|
244
|
-
"defaultValue": "
|
|
244
|
+
"defaultValue": "COMPONENT_STATES.DEFAULT"
|
|
245
245
|
},
|
|
246
246
|
"customClass": {
|
|
247
247
|
"type": "string",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { COMPONENT_STATES } from "../../../../types/states";
|
|
2
2
|
import { SIZES } from "../../../../types/size";
|
|
3
3
|
/*
|
|
4
4
|
* LINK consts
|
|
@@ -9,17 +9,17 @@ export const FILENAME = 'download';
|
|
|
9
9
|
*/
|
|
10
10
|
export const VARIANT_CONFIG = {
|
|
11
11
|
link: {
|
|
12
|
-
states: [
|
|
12
|
+
states: [COMPONENT_STATES.DISABLED /* STATES.VISITED, STATES.HOVER, STATES.ACTIVE, STATES.FOCUS */],
|
|
13
13
|
size: [SIZES.S, SIZES.M],
|
|
14
14
|
},
|
|
15
15
|
label: {
|
|
16
|
-
states: [
|
|
16
|
+
states: [COMPONENT_STATES.DISABLED],
|
|
17
17
|
isRequired: true,
|
|
18
18
|
canUseTooltip: true,
|
|
19
19
|
},
|
|
20
20
|
heading: { canUseTooltip: true },
|
|
21
21
|
subheading: { canUseTooltip: true },
|
|
22
|
-
helper: { states: [
|
|
22
|
+
helper: { states: [COMPONENT_STATES.ERROR] },
|
|
23
23
|
display: { size: [SIZES.XS, SIZES.S, SIZES.M, SIZES.L, SIZES.XL] },
|
|
24
24
|
};
|
|
25
25
|
/*
|
|
@@ -28,7 +28,7 @@ export const VARIANT_CONFIG = {
|
|
|
28
28
|
export const getAttributesByTag = (comp, tagName) => {
|
|
29
29
|
const ATTR_MAP = {
|
|
30
30
|
a: {
|
|
31
|
-
href: comp.state !==
|
|
31
|
+
href: comp.state !== COMPONENT_STATES.DISABLED ? comp.sanitizedHref : null,
|
|
32
32
|
target: comp.target,
|
|
33
33
|
download: comp.isDownloadable ? comp.filename : null,
|
|
34
34
|
rel: comp.target === '_blank' ? 'noopener noreferrer' : undefined,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a component prop against a list of accepted values.
|
|
3
|
+
* If the current value is invalid, the prop is reset to the fallback and a warning is issued.
|
|
4
|
+
*
|
|
5
|
+
* @param acceptedValues - The list of valid values for the prop.
|
|
6
|
+
* @param fallbackValue - The value to apply when the current value is invalid.
|
|
7
|
+
* @param element - The host element whose property will be corrected.
|
|
8
|
+
* @param propertyName - The name of the prop to validate.
|
|
9
|
+
*/
|
|
10
|
+
export function validatePropValue(acceptedValues, fallbackValue, element, propertyName) {
|
|
11
|
+
const currentValue = element[propertyName];
|
|
12
|
+
if (acceptedValues.includes(currentValue))
|
|
13
|
+
return;
|
|
14
|
+
element[propertyName] = fallbackValue;
|
|
15
|
+
console.warn(`[BorealDS] Invalid value "${currentValue}" for prop "${propertyName}" on <${element.tagName.toLowerCase()}>. Expected one of: ${acceptedValues.join(', ')}.`);
|
|
16
|
+
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
const STATES = {
|
|
2
|
-
DEFAULT: 'default',
|
|
3
|
-
ERROR: 'error',
|
|
4
|
-
DISABLED: 'disabled'};
|
|
5
|
-
const STATUS_VARIANT = {
|
|
6
|
-
INFO: 'info'};
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* Taken from StencilJS Ionic team
|
|
10
3
|
* This helper pass the attributes passed to components directly to the inner element
|
|
@@ -83,4 +76,4 @@ const inheritAriaAttributes = (el, ignoreList) => {
|
|
|
83
76
|
return inheritAttributes(el, attributesToInherit);
|
|
84
77
|
};
|
|
85
78
|
|
|
86
|
-
export {
|
|
79
|
+
export { inheritAriaAttributes as i };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, a as Host, g as getElement } from './index-
|
|
2
|
-
import { S as STATUS_VARIANT
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, a as Host, g as getElement } from './index-DQvmq159.js';
|
|
2
|
+
import { S as STATUS_VARIANT } from './states-DQR-jjOl.js';
|
|
3
|
+
import { i as inheritAriaAttributes } from './attributes-Ba6iHqJA.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Ensure the given component instance has an auto-generated id if one wasn't provided.
|