@fluentui/web-components 3.0.0-beta.83 → 3.0.0-beta.85
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/CHANGELOG.md +20 -2
- package/dist/dts/accordion-item/accordion-item.base.d.ts +71 -0
- package/dist/dts/accordion-item/accordion-item.d.ts +1 -71
- package/dist/dts/accordion-item/index.d.ts +2 -1
- package/dist/dts/anchor-button/anchor-button.base.d.ts +144 -0
- package/dist/dts/anchor-button/anchor-button.d.ts +2 -144
- package/dist/dts/anchor-button/index.d.ts +3 -1
- package/dist/dts/avatar/avatar.base.d.ts +42 -0
- package/dist/dts/avatar/avatar.d.ts +2 -42
- package/dist/dts/avatar/index.d.ts +2 -1
- package/dist/dts/button/button.base.d.ts +242 -0
- package/dist/dts/button/button.d.ts +2 -242
- package/dist/dts/button/index.d.ts +2 -1
- package/dist/dts/checkbox/checkbox.base.d.ts +288 -0
- package/dist/dts/checkbox/checkbox.d.ts +1 -288
- package/dist/dts/checkbox/index.d.ts +2 -1
- package/dist/dts/divider/divider.base.d.ts +49 -0
- package/dist/dts/divider/divider.d.ts +2 -49
- package/dist/dts/divider/index.d.ts +2 -1
- package/dist/dts/dropdown/dropdown.base.d.ts +418 -0
- package/dist/dts/dropdown/dropdown.d.ts +2 -418
- package/dist/dts/dropdown/dropdown.options.d.ts +1 -1
- package/dist/dts/dropdown/dropdown.template.d.ts +1 -1
- package/dist/dts/dropdown/index.d.ts +2 -1
- package/dist/dts/field/field.base.d.ts +120 -0
- package/dist/dts/field/field.d.ts +2 -120
- package/dist/dts/field/index.d.ts +2 -1
- package/dist/dts/index-rollup.d.ts +2 -0
- package/dist/dts/index.d.ts +7 -8
- package/dist/dts/link/link.d.ts +1 -1
- package/dist/dts/listbox/listbox.d.ts +1 -1
- package/dist/dts/progress-bar/index.d.ts +2 -1
- package/dist/dts/progress-bar/progress-bar.base.d.ts +73 -0
- package/dist/dts/progress-bar/progress-bar.d.ts +2 -73
- package/dist/dts/radio/radio.d.ts +1 -1
- package/dist/dts/rating-display/index.d.ts +2 -1
- package/dist/dts/rating-display/rating-display.base.d.ts +89 -0
- package/dist/dts/rating-display/rating-display.d.ts +1 -89
- package/dist/dts/spinner/index.d.ts +2 -1
- package/dist/dts/spinner/spinner.base.d.ts +14 -0
- package/dist/dts/spinner/spinner.d.ts +1 -14
- package/dist/dts/switch/switch.d.ts +1 -1
- package/dist/dts/tablist/index.d.ts +2 -1
- package/dist/dts/tablist/tablist.base.d.ts +95 -0
- package/dist/dts/tablist/tablist.d.ts +2 -95
- package/dist/dts/tabs/tabs.base.d.ts +90 -0
- package/dist/dts/tabs/tabs.d.ts +2 -90
- package/dist/dts/text-input/index.d.ts +2 -1
- package/dist/dts/text-input/text-input.base.d.ts +393 -0
- package/dist/dts/text-input/text-input.d.ts +2 -393
- package/dist/dts/textarea/index.d.ts +2 -1
- package/dist/dts/textarea/textarea.base.d.ts +347 -0
- package/dist/dts/textarea/textarea.d.ts +2 -347
- package/dist/dts/tree/define.d.ts +1 -0
- package/dist/dts/tree/index.d.ts +4 -0
- package/dist/dts/tree/tree.bench.d.ts +3 -0
- package/dist/dts/tree/tree.d.ts +88 -0
- package/dist/dts/tree/tree.definition.d.ts +8 -0
- package/dist/dts/tree/tree.styles.d.ts +1 -0
- package/dist/dts/tree/tree.template.d.ts +2 -0
- package/dist/dts/tree-item/define.d.ts +1 -0
- package/dist/dts/tree-item/index.d.ts +5 -0
- package/dist/dts/tree-item/tree-item.bench.d.ts +3 -0
- package/dist/dts/tree-item/tree-item.d.ts +121 -0
- package/dist/dts/tree-item/tree-item.definition.d.ts +8 -0
- package/dist/dts/tree-item/tree-item.options.d.ts +22 -0
- package/dist/dts/tree-item/tree-item.styles.d.ts +1 -0
- package/dist/dts/tree-item/tree-item.template.d.ts +2 -0
- package/dist/esm/accordion/accordion.js +1 -1
- package/dist/esm/accordion/accordion.js.map +1 -1
- package/dist/esm/accordion-item/accordion-item.base.js +94 -0
- package/dist/esm/accordion-item/accordion-item.base.js.map +1 -0
- package/dist/esm/accordion-item/accordion-item.js +2 -91
- package/dist/esm/accordion-item/accordion-item.js.map +1 -1
- package/dist/esm/accordion-item/index.js +2 -1
- package/dist/esm/accordion-item/index.js.map +1 -1
- package/dist/esm/anchor-button/anchor-button.base.js +147 -0
- package/dist/esm/anchor-button/anchor-button.base.js.map +1 -0
- package/dist/esm/anchor-button/anchor-button.js +3 -145
- package/dist/esm/anchor-button/anchor-button.js.map +1 -1
- package/dist/esm/anchor-button/index.js +3 -1
- package/dist/esm/anchor-button/index.js.map +1 -1
- package/dist/esm/avatar/avatar.base.js +28 -0
- package/dist/esm/avatar/avatar.base.js.map +1 -0
- package/dist/esm/avatar/avatar.js +2 -26
- package/dist/esm/avatar/avatar.js.map +1 -1
- package/dist/esm/avatar/index.js +2 -1
- package/dist/esm/avatar/index.js.map +1 -1
- package/dist/esm/button/button.base.js +283 -0
- package/dist/esm/button/button.base.js.map +1 -0
- package/dist/esm/button/button.js +3 -281
- package/dist/esm/button/button.js.map +1 -1
- package/dist/esm/button/button.styles.js +2 -1
- package/dist/esm/button/button.styles.js.map +1 -1
- package/dist/esm/button/index.js +2 -1
- package/dist/esm/button/index.js.map +1 -1
- package/dist/esm/checkbox/checkbox.base.js +366 -0
- package/dist/esm/checkbox/checkbox.base.js.map +1 -0
- package/dist/esm/checkbox/checkbox.js +2 -363
- package/dist/esm/checkbox/checkbox.js.map +1 -1
- package/dist/esm/checkbox/index.js +2 -1
- package/dist/esm/checkbox/index.js.map +1 -1
- package/dist/esm/divider/divider.base.js +61 -0
- package/dist/esm/divider/divider.base.js.map +1 -0
- package/dist/esm/divider/divider.js +3 -58
- package/dist/esm/divider/divider.js.map +1 -1
- package/dist/esm/divider/index.js +2 -1
- package/dist/esm/divider/index.js.map +1 -1
- package/dist/esm/dropdown/dropdown.base.js +677 -0
- package/dist/esm/dropdown/dropdown.base.js.map +1 -0
- package/dist/esm/dropdown/dropdown.js +3 -674
- package/dist/esm/dropdown/dropdown.js.map +1 -1
- package/dist/esm/dropdown/index.js +2 -1
- package/dist/esm/dropdown/index.js.map +1 -1
- package/dist/esm/field/field.base.js +189 -0
- package/dist/esm/field/field.base.js.map +1 -0
- package/dist/esm/field/field.js +3 -187
- package/dist/esm/field/field.js.map +1 -1
- package/dist/esm/field/index.js +2 -1
- package/dist/esm/field/index.js.map +1 -1
- package/dist/esm/index-rollup.js +2 -0
- package/dist/esm/index-rollup.js.map +1 -1
- package/dist/esm/index.js +6 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/link/link.js +1 -1
- package/dist/esm/link/link.js.map +1 -1
- package/dist/esm/progress-bar/index.js +2 -1
- package/dist/esm/progress-bar/index.js.map +1 -1
- package/dist/esm/progress-bar/progress-bar.base.js +90 -0
- package/dist/esm/progress-bar/progress-bar.base.js.map +1 -0
- package/dist/esm/progress-bar/progress-bar.js +3 -87
- package/dist/esm/progress-bar/progress-bar.js.map +1 -1
- package/dist/esm/radio/radio.js +1 -1
- package/dist/esm/radio/radio.js.map +1 -1
- package/dist/esm/rating-display/index.js +2 -1
- package/dist/esm/rating-display/index.js.map +1 -1
- package/dist/esm/rating-display/rating-display.base.js +94 -0
- package/dist/esm/rating-display/rating-display.base.js.map +1 -0
- package/dist/esm/rating-display/rating-display.js +2 -92
- package/dist/esm/rating-display/rating-display.js.map +1 -1
- package/dist/esm/spinner/index.js +2 -1
- package/dist/esm/spinner/index.js.map +1 -1
- package/dist/esm/spinner/spinner.base.js +18 -0
- package/dist/esm/spinner/spinner.base.js.map +1 -0
- package/dist/esm/spinner/spinner.js +2 -17
- package/dist/esm/spinner/spinner.js.map +1 -1
- package/dist/esm/switch/switch.js +1 -1
- package/dist/esm/switch/switch.js.map +1 -1
- package/dist/esm/tablist/index.js +2 -1
- package/dist/esm/tablist/index.js.map +1 -1
- package/dist/esm/tablist/tablist.base.js +248 -0
- package/dist/esm/tablist/tablist.base.js.map +1 -0
- package/dist/esm/tablist/tablist.js +3 -245
- package/dist/esm/tablist/tablist.js.map +1 -1
- package/dist/esm/tabs/tabs.base.js +279 -0
- package/dist/esm/tabs/tabs.base.js.map +1 -0
- package/dist/esm/tabs/tabs.js +2 -276
- package/dist/esm/tabs/tabs.js.map +1 -1
- package/dist/esm/text-input/index.js +2 -1
- package/dist/esm/text-input/index.js.map +1 -1
- package/dist/esm/text-input/text-input.base.js +409 -0
- package/dist/esm/text-input/text-input.base.js.map +1 -0
- package/dist/esm/text-input/text-input.js +3 -407
- package/dist/esm/text-input/text-input.js.map +1 -1
- package/dist/esm/textarea/index.js +2 -1
- package/dist/esm/textarea/index.js.map +1 -1
- package/dist/esm/textarea/textarea.base.js +494 -0
- package/dist/esm/textarea/textarea.base.js.map +1 -0
- package/dist/esm/textarea/textarea.js +3 -491
- package/dist/esm/textarea/textarea.js.map +1 -1
- package/dist/esm/tree/define.js +4 -0
- package/dist/esm/tree/define.js.map +1 -0
- package/dist/esm/tree/index.js +5 -0
- package/dist/esm/tree/index.js.map +1 -0
- package/dist/esm/tree/tree.bench.js +10 -0
- package/dist/esm/tree/tree.bench.js.map +1 -0
- package/dist/esm/tree/tree.definition.js +16 -0
- package/dist/esm/tree/tree.definition.js.map +1 -0
- package/dist/esm/tree/tree.js +274 -0
- package/dist/esm/tree/tree.js.map +1 -0
- package/dist/esm/tree/tree.styles.js +9 -0
- package/dist/esm/tree/tree.styles.js.map +1 -0
- package/dist/esm/tree/tree.template.js +18 -0
- package/dist/esm/tree/tree.template.js.map +1 -0
- package/dist/esm/tree-item/define.js +4 -0
- package/dist/esm/tree-item/define.js.map +1 -0
- package/dist/esm/tree-item/index.js +5 -0
- package/dist/esm/tree-item/index.js.map +1 -0
- package/dist/esm/tree-item/tree-item.bench.js +10 -0
- package/dist/esm/tree-item/tree-item.bench.js.map +1 -0
- package/dist/esm/tree-item/tree-item.definition.js +16 -0
- package/dist/esm/tree-item/tree-item.definition.js.map +1 -0
- package/dist/esm/tree-item/tree-item.js +201 -0
- package/dist/esm/tree-item/tree-item.js.map +1 -0
- package/dist/esm/tree-item/tree-item.options.js +24 -0
- package/dist/esm/tree-item/tree-item.options.js.map +1 -0
- package/dist/esm/tree-item/tree-item.styles.js +170 -0
- package/dist/esm/tree-item/tree-item.styles.js.map +1 -0
- package/dist/esm/tree-item/tree-item.template.js +41 -0
- package/dist/esm/tree-item/tree-item.template.js.map +1 -0
- package/dist/web-components.d.ts +157 -0
- package/dist/web-components.js +1445 -842
- package/dist/web-components.min.js +310 -303
- package/package.json +5 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { attr, FASTElement, nullableNumberConverter, observable } from '@microsoft/fast-element';
|
|
3
|
+
import { keyEnter, keySpace } from '@microsoft/fast-web-utilities';
|
|
4
|
+
import { ButtonType } from './button.options.js';
|
|
5
|
+
/**
|
|
6
|
+
* A Button Custom HTML Element.
|
|
7
|
+
* Based largely on the {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button | `<button>`} element.
|
|
8
|
+
*
|
|
9
|
+
* @slot start - Content which can be provided before the button content
|
|
10
|
+
* @slot end - Content which can be provided after the button content
|
|
11
|
+
* @slot - The default slot for button content
|
|
12
|
+
* @csspart content - The button content container
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export class BaseButton extends FASTElement {
|
|
17
|
+
/**
|
|
18
|
+
* Sets the element's internal disabled state when the element is focusable while disabled.
|
|
19
|
+
*
|
|
20
|
+
* @param previous - the previous disabledFocusable value
|
|
21
|
+
* @param next - the current disabledFocusable value
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
disabledFocusableChanged(previous, next) {
|
|
25
|
+
if (this.$fastController.isConnected) {
|
|
26
|
+
this.elementInternals.ariaDisabled = `${!!next}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The associated form element.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
get form() {
|
|
35
|
+
return this.elementInternals.form;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The form-associated flag.
|
|
39
|
+
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example | Form-associated custom elements}
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
static { this.formAssociated = true; }
|
|
44
|
+
/**
|
|
45
|
+
* A reference to all associated label elements.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
get labels() {
|
|
50
|
+
return Object.freeze(Array.from(this.elementInternals.labels));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Removes the form submission fallback control when the type changes.
|
|
54
|
+
*
|
|
55
|
+
* @param previous - the previous type value
|
|
56
|
+
* @param next - the new type value
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
typeChanged(previous, next) {
|
|
60
|
+
if (next !== ButtonType.submit) {
|
|
61
|
+
this.formSubmissionFallbackControl?.remove();
|
|
62
|
+
this.shadowRoot?.querySelector('slot[name="internal"]')?.remove();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Handles the button click event.
|
|
67
|
+
*
|
|
68
|
+
* @param e - The event object
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
clickHandler(e) {
|
|
72
|
+
if (e && this.disabledFocusable) {
|
|
73
|
+
e.stopImmediatePropagation();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.press();
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
connectedCallback() {
|
|
80
|
+
super.connectedCallback();
|
|
81
|
+
this.elementInternals.ariaDisabled = `${!!this.disabledFocusable}`;
|
|
82
|
+
}
|
|
83
|
+
constructor() {
|
|
84
|
+
super();
|
|
85
|
+
/**
|
|
86
|
+
* Indicates that the button is focusable while disabled.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
* @remarks
|
|
90
|
+
* HTML Attribute: `disabled-focusable`
|
|
91
|
+
*/
|
|
92
|
+
this.disabledFocusable = false;
|
|
93
|
+
/**
|
|
94
|
+
* Sets that the button tabindex attribute
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
* @remarks
|
|
98
|
+
* HTML Attribute: `tabindex`
|
|
99
|
+
*/
|
|
100
|
+
this.tabIndex = 0;
|
|
101
|
+
/**
|
|
102
|
+
* The internal {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
this.elementInternals = this.attachInternals();
|
|
107
|
+
this.elementInternals.role = 'button';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* This fallback creates a new slot, then creates a submit button to mirror the custom element's
|
|
111
|
+
* properties. The submit button is then appended to the slot and the form is submitted.
|
|
112
|
+
*
|
|
113
|
+
* @internal
|
|
114
|
+
* @privateRemarks
|
|
115
|
+
* This is a workaround until {@link https://github.com/WICG/webcomponents/issues/814 | WICG/webcomponents/issues/814} is resolved.
|
|
116
|
+
*/
|
|
117
|
+
createAndInsertFormSubmissionFallbackControl() {
|
|
118
|
+
const internalSlot = this.formSubmissionFallbackControlSlot ?? document.createElement('slot');
|
|
119
|
+
internalSlot.setAttribute('name', 'internal');
|
|
120
|
+
this.shadowRoot?.appendChild(internalSlot);
|
|
121
|
+
this.formSubmissionFallbackControlSlot = internalSlot;
|
|
122
|
+
const fallbackControl = this.formSubmissionFallbackControl ?? document.createElement('button');
|
|
123
|
+
fallbackControl.style.display = 'none';
|
|
124
|
+
fallbackControl.setAttribute('type', 'submit');
|
|
125
|
+
fallbackControl.setAttribute('slot', 'internal');
|
|
126
|
+
if (this.formNoValidate) {
|
|
127
|
+
fallbackControl.toggleAttribute('formnovalidate', true);
|
|
128
|
+
}
|
|
129
|
+
if (this.elementInternals.form?.id) {
|
|
130
|
+
fallbackControl.setAttribute('form', this.elementInternals.form.id);
|
|
131
|
+
}
|
|
132
|
+
if (this.name) {
|
|
133
|
+
fallbackControl.setAttribute('name', this.name);
|
|
134
|
+
}
|
|
135
|
+
if (this.value) {
|
|
136
|
+
fallbackControl.setAttribute('value', this.value);
|
|
137
|
+
}
|
|
138
|
+
if (this.formAction) {
|
|
139
|
+
fallbackControl.setAttribute('formaction', this.formAction ?? '');
|
|
140
|
+
}
|
|
141
|
+
if (this.formEnctype) {
|
|
142
|
+
fallbackControl.setAttribute('formenctype', this.formEnctype ?? '');
|
|
143
|
+
}
|
|
144
|
+
if (this.formMethod) {
|
|
145
|
+
fallbackControl.setAttribute('formmethod', this.formMethod ?? '');
|
|
146
|
+
}
|
|
147
|
+
if (this.formTarget) {
|
|
148
|
+
fallbackControl.setAttribute('formtarget', this.formTarget ?? '');
|
|
149
|
+
}
|
|
150
|
+
this.append(fallbackControl);
|
|
151
|
+
this.formSubmissionFallbackControl = fallbackControl;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Invoked when a connected component's form or fieldset has its disabled state changed.
|
|
155
|
+
*
|
|
156
|
+
* @param disabled - the disabled value of the form / fieldset
|
|
157
|
+
*
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
formDisabledCallback(disabled) {
|
|
161
|
+
this.disabled = disabled;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Handles keypress events for the button.
|
|
165
|
+
*
|
|
166
|
+
* @param e - the keyboard event
|
|
167
|
+
* @returns - the return value of the click handler
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
keypressHandler(e) {
|
|
171
|
+
if (e && this.disabledFocusable) {
|
|
172
|
+
e.stopImmediatePropagation();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (e.key === keyEnter || e.key === keySpace) {
|
|
176
|
+
this.click();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Presses the button.
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
press() {
|
|
187
|
+
switch (this.type) {
|
|
188
|
+
case ButtonType.reset: {
|
|
189
|
+
this.resetForm();
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case ButtonType.submit: {
|
|
193
|
+
this.submitForm();
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Resets the associated form.
|
|
200
|
+
*
|
|
201
|
+
* @public
|
|
202
|
+
*/
|
|
203
|
+
resetForm() {
|
|
204
|
+
this.elementInternals.form?.reset();
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Submits the associated form.
|
|
208
|
+
*
|
|
209
|
+
* @internal
|
|
210
|
+
*/
|
|
211
|
+
submitForm() {
|
|
212
|
+
if (!this.elementInternals.form || this.disabled || this.type !== ButtonType.submit) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
// workaround: if the button doesn't have any form overrides, the form can be submitted directly.
|
|
216
|
+
if (!this.name &&
|
|
217
|
+
!this.formAction &&
|
|
218
|
+
!this.formEnctype &&
|
|
219
|
+
!this.form &&
|
|
220
|
+
!this.formMethod &&
|
|
221
|
+
!this.formNoValidate &&
|
|
222
|
+
!this.formTarget) {
|
|
223
|
+
this.elementInternals.form.requestSubmit();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
this.elementInternals.setFormValue(this.value ?? '');
|
|
228
|
+
this.elementInternals.form.requestSubmit(this);
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
// `requestSubmit` throws an error since custom elements may not be able to submit the form.
|
|
232
|
+
// This fallback creates a new slot, then creates a submit button to mirror the custom element's
|
|
233
|
+
// properties. The submit button is then appended to the slot and the form is submitted.
|
|
234
|
+
this.createAndInsertFormSubmissionFallbackControl();
|
|
235
|
+
// workaround: the form value is reset since the fallback control will handle the form submission.
|
|
236
|
+
this.elementInternals.setFormValue(null);
|
|
237
|
+
this.elementInternals.form.requestSubmit(this.formSubmissionFallbackControl);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
__decorate([
|
|
242
|
+
attr({ mode: 'boolean' })
|
|
243
|
+
], BaseButton.prototype, "autofocus", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
observable
|
|
246
|
+
], BaseButton.prototype, "defaultSlottedContent", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
attr({ mode: 'boolean' })
|
|
249
|
+
], BaseButton.prototype, "disabled", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
attr({ attribute: 'disabled-focusable', mode: 'boolean' })
|
|
252
|
+
], BaseButton.prototype, "disabledFocusable", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
attr({ attribute: 'tabindex', mode: 'fromView', converter: nullableNumberConverter })
|
|
255
|
+
], BaseButton.prototype, "tabIndex", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
attr({ attribute: 'formaction' })
|
|
258
|
+
], BaseButton.prototype, "formAction", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
attr({ attribute: 'form' })
|
|
261
|
+
], BaseButton.prototype, "formAttribute", void 0);
|
|
262
|
+
__decorate([
|
|
263
|
+
attr({ attribute: 'formenctype' })
|
|
264
|
+
], BaseButton.prototype, "formEnctype", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
attr({ attribute: 'formmethod' })
|
|
267
|
+
], BaseButton.prototype, "formMethod", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
attr({ attribute: 'formnovalidate', mode: 'boolean' })
|
|
270
|
+
], BaseButton.prototype, "formNoValidate", void 0);
|
|
271
|
+
__decorate([
|
|
272
|
+
attr({ attribute: 'formtarget' })
|
|
273
|
+
], BaseButton.prototype, "formTarget", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
attr
|
|
276
|
+
], BaseButton.prototype, "name", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
attr
|
|
279
|
+
], BaseButton.prototype, "type", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
attr
|
|
282
|
+
], BaseButton.prototype, "value", void 0);
|
|
283
|
+
//# sourceMappingURL=button.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.base.js","sourceRoot":"","sources":["../../../src/button/button.base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAoB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IAmDzC;;;;;;OAMG;IACI,wBAAwB,CAAC,QAAiB,EAAE,IAAa;QAC9D,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;YACrC,IAAI,CAAC,gBAAgB,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACnD,CAAC;IACH,CAAC;IASD;;;;OAIG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;IACpC,CAAC;IAaD;;;;;OAKG;aACa,mBAAc,GAAG,IAAI,AAAP,CAAQ;IAuEtC;;;;OAIG;IACH,IAAW,MAAM;QACf,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC;IAwBD;;;;;;OAMG;IACI,WAAW,CAAC,QAAoB,EAAE,IAAgB;QACvD,IAAI,IAAI,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;YAC/B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E;AAWvB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;+CACP;AAWrB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;8CACP;AAWpB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;kDACvB;AAyBzB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;8CACG;AAoB9B;IADN,IAAI;wCACgB;AAWd;IADN,IAAI;wCACoB;AA0BlB;IADN,IAAI;yCACiB"}
|
|
@@ -1,288 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { attr
|
|
3
|
-
import { keyEnter, keySpace } from '@microsoft/fast-web-utilities';
|
|
2
|
+
import { attr } from '@microsoft/fast-element';
|
|
4
3
|
import { StartEnd } from '../patterns/index.js';
|
|
5
4
|
import { applyMixins } from '../utils/apply-mixins.js';
|
|
6
5
|
import { swapStates, toggleState } from '../utils/element-internals.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
* A Button Custom HTML Element.
|
|
10
|
-
* Based largely on the {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button | `<button>`} element.
|
|
11
|
-
*
|
|
12
|
-
* @slot start - Content which can be provided before the button content
|
|
13
|
-
* @slot end - Content which can be provided after the button content
|
|
14
|
-
* @slot - The default slot for button content
|
|
15
|
-
* @csspart content - The button content container
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export class BaseButton extends FASTElement {
|
|
20
|
-
/**
|
|
21
|
-
* Sets the element's internal disabled state when the element is focusable while disabled.
|
|
22
|
-
*
|
|
23
|
-
* @param previous - the previous disabledFocusable value
|
|
24
|
-
* @param next - the current disabledFocusable value
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
disabledFocusableChanged(previous, next) {
|
|
28
|
-
if (this.$fastController.isConnected) {
|
|
29
|
-
this.elementInternals.ariaDisabled = `${!!next}`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The associated form element.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
get form() {
|
|
38
|
-
return this.elementInternals.form;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The form-associated flag.
|
|
42
|
-
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example | Form-associated custom elements}
|
|
43
|
-
*
|
|
44
|
-
* @public
|
|
45
|
-
*/
|
|
46
|
-
static { this.formAssociated = true; }
|
|
47
|
-
/**
|
|
48
|
-
* A reference to all associated label elements.
|
|
49
|
-
*
|
|
50
|
-
* @public
|
|
51
|
-
*/
|
|
52
|
-
get labels() {
|
|
53
|
-
return Object.freeze(Array.from(this.elementInternals.labels));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Removes the form submission fallback control when the type changes.
|
|
57
|
-
*
|
|
58
|
-
* @param previous - the previous type value
|
|
59
|
-
* @param next - the new type value
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
typeChanged(previous, next) {
|
|
63
|
-
if (next !== ButtonType.submit) {
|
|
64
|
-
this.formSubmissionFallbackControl?.remove();
|
|
65
|
-
this.shadowRoot?.querySelector('slot[name="internal"]')?.remove();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Handles the button click event.
|
|
70
|
-
*
|
|
71
|
-
* @param e - The event object
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
74
|
-
clickHandler(e) {
|
|
75
|
-
if (e && this.disabledFocusable) {
|
|
76
|
-
e.stopImmediatePropagation();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
this.press();
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
connectedCallback() {
|
|
83
|
-
super.connectedCallback();
|
|
84
|
-
this.elementInternals.ariaDisabled = `${!!this.disabledFocusable}`;
|
|
85
|
-
}
|
|
86
|
-
constructor() {
|
|
87
|
-
super();
|
|
88
|
-
/**
|
|
89
|
-
* Indicates that the button is focusable while disabled.
|
|
90
|
-
*
|
|
91
|
-
* @public
|
|
92
|
-
* @remarks
|
|
93
|
-
* HTML Attribute: `disabled-focusable`
|
|
94
|
-
*/
|
|
95
|
-
this.disabledFocusable = false;
|
|
96
|
-
/**
|
|
97
|
-
* Sets that the button tabindex attribute
|
|
98
|
-
*
|
|
99
|
-
* @public
|
|
100
|
-
* @remarks
|
|
101
|
-
* HTML Attribute: `tabindex`
|
|
102
|
-
*/
|
|
103
|
-
this.tabIndex = 0;
|
|
104
|
-
/**
|
|
105
|
-
* The internal {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
|
|
106
|
-
*
|
|
107
|
-
* @internal
|
|
108
|
-
*/
|
|
109
|
-
this.elementInternals = this.attachInternals();
|
|
110
|
-
this.elementInternals.role = 'button';
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* This fallback creates a new slot, then creates a submit button to mirror the custom element's
|
|
114
|
-
* properties. The submit button is then appended to the slot and the form is submitted.
|
|
115
|
-
*
|
|
116
|
-
* @internal
|
|
117
|
-
* @privateRemarks
|
|
118
|
-
* This is a workaround until {@link https://github.com/WICG/webcomponents/issues/814 | WICG/webcomponents/issues/814} is resolved.
|
|
119
|
-
*/
|
|
120
|
-
createAndInsertFormSubmissionFallbackControl() {
|
|
121
|
-
const internalSlot = this.formSubmissionFallbackControlSlot ?? document.createElement('slot');
|
|
122
|
-
internalSlot.setAttribute('name', 'internal');
|
|
123
|
-
this.shadowRoot?.appendChild(internalSlot);
|
|
124
|
-
this.formSubmissionFallbackControlSlot = internalSlot;
|
|
125
|
-
const fallbackControl = this.formSubmissionFallbackControl ?? document.createElement('button');
|
|
126
|
-
fallbackControl.style.display = 'none';
|
|
127
|
-
fallbackControl.setAttribute('type', 'submit');
|
|
128
|
-
fallbackControl.setAttribute('slot', 'internal');
|
|
129
|
-
if (this.formNoValidate) {
|
|
130
|
-
fallbackControl.toggleAttribute('formnovalidate', true);
|
|
131
|
-
}
|
|
132
|
-
if (this.elementInternals.form?.id) {
|
|
133
|
-
fallbackControl.setAttribute('form', this.elementInternals.form.id);
|
|
134
|
-
}
|
|
135
|
-
if (this.name) {
|
|
136
|
-
fallbackControl.setAttribute('name', this.name);
|
|
137
|
-
}
|
|
138
|
-
if (this.value) {
|
|
139
|
-
fallbackControl.setAttribute('value', this.value);
|
|
140
|
-
}
|
|
141
|
-
if (this.formAction) {
|
|
142
|
-
fallbackControl.setAttribute('formaction', this.formAction ?? '');
|
|
143
|
-
}
|
|
144
|
-
if (this.formEnctype) {
|
|
145
|
-
fallbackControl.setAttribute('formenctype', this.formEnctype ?? '');
|
|
146
|
-
}
|
|
147
|
-
if (this.formMethod) {
|
|
148
|
-
fallbackControl.setAttribute('formmethod', this.formMethod ?? '');
|
|
149
|
-
}
|
|
150
|
-
if (this.formTarget) {
|
|
151
|
-
fallbackControl.setAttribute('formtarget', this.formTarget ?? '');
|
|
152
|
-
}
|
|
153
|
-
this.append(fallbackControl);
|
|
154
|
-
this.formSubmissionFallbackControl = fallbackControl;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Invoked when a connected component's form or fieldset has its disabled state changed.
|
|
158
|
-
*
|
|
159
|
-
* @param disabled - the disabled value of the form / fieldset
|
|
160
|
-
*
|
|
161
|
-
* @internal
|
|
162
|
-
*/
|
|
163
|
-
formDisabledCallback(disabled) {
|
|
164
|
-
this.disabled = disabled;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Handles keypress events for the button.
|
|
168
|
-
*
|
|
169
|
-
* @param e - the keyboard event
|
|
170
|
-
* @returns - the return value of the click handler
|
|
171
|
-
* @public
|
|
172
|
-
*/
|
|
173
|
-
keypressHandler(e) {
|
|
174
|
-
if (e && this.disabledFocusable) {
|
|
175
|
-
e.stopImmediatePropagation();
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (e.key === keyEnter || e.key === keySpace) {
|
|
179
|
-
this.click();
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Presses the button.
|
|
186
|
-
*
|
|
187
|
-
* @public
|
|
188
|
-
*/
|
|
189
|
-
press() {
|
|
190
|
-
switch (this.type) {
|
|
191
|
-
case ButtonType.reset: {
|
|
192
|
-
this.resetForm();
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
case ButtonType.submit: {
|
|
196
|
-
this.submitForm();
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Resets the associated form.
|
|
203
|
-
*
|
|
204
|
-
* @public
|
|
205
|
-
*/
|
|
206
|
-
resetForm() {
|
|
207
|
-
this.elementInternals.form?.reset();
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Submits the associated form.
|
|
211
|
-
*
|
|
212
|
-
* @internal
|
|
213
|
-
*/
|
|
214
|
-
submitForm() {
|
|
215
|
-
if (!this.elementInternals.form || this.disabled || this.type !== ButtonType.submit) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
// workaround: if the button doesn't have any form overrides, the form can be submitted directly.
|
|
219
|
-
if (!this.name &&
|
|
220
|
-
!this.formAction &&
|
|
221
|
-
!this.formEnctype &&
|
|
222
|
-
!this.form &&
|
|
223
|
-
!this.formMethod &&
|
|
224
|
-
!this.formNoValidate &&
|
|
225
|
-
!this.formTarget) {
|
|
226
|
-
this.elementInternals.form.requestSubmit();
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
try {
|
|
230
|
-
this.elementInternals.setFormValue(this.value ?? '');
|
|
231
|
-
this.elementInternals.form.requestSubmit(this);
|
|
232
|
-
}
|
|
233
|
-
catch (e) {
|
|
234
|
-
// `requestSubmit` throws an error since custom elements may not be able to submit the form.
|
|
235
|
-
// This fallback creates a new slot, then creates a submit button to mirror the custom element's
|
|
236
|
-
// properties. The submit button is then appended to the slot and the form is submitted.
|
|
237
|
-
this.createAndInsertFormSubmissionFallbackControl();
|
|
238
|
-
// workaround: the form value is reset since the fallback control will handle the form submission.
|
|
239
|
-
this.elementInternals.setFormValue(null);
|
|
240
|
-
this.elementInternals.form.requestSubmit(this.formSubmissionFallbackControl);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
__decorate([
|
|
245
|
-
attr({ mode: 'boolean' })
|
|
246
|
-
], BaseButton.prototype, "autofocus", void 0);
|
|
247
|
-
__decorate([
|
|
248
|
-
observable
|
|
249
|
-
], BaseButton.prototype, "defaultSlottedContent", void 0);
|
|
250
|
-
__decorate([
|
|
251
|
-
attr({ mode: 'boolean' })
|
|
252
|
-
], BaseButton.prototype, "disabled", void 0);
|
|
253
|
-
__decorate([
|
|
254
|
-
attr({ attribute: 'disabled-focusable', mode: 'boolean' })
|
|
255
|
-
], BaseButton.prototype, "disabledFocusable", void 0);
|
|
256
|
-
__decorate([
|
|
257
|
-
attr({ attribute: 'tabindex', mode: 'fromView', converter: nullableNumberConverter })
|
|
258
|
-
], BaseButton.prototype, "tabIndex", void 0);
|
|
259
|
-
__decorate([
|
|
260
|
-
attr({ attribute: 'formaction' })
|
|
261
|
-
], BaseButton.prototype, "formAction", void 0);
|
|
262
|
-
__decorate([
|
|
263
|
-
attr({ attribute: 'form' })
|
|
264
|
-
], BaseButton.prototype, "formAttribute", void 0);
|
|
265
|
-
__decorate([
|
|
266
|
-
attr({ attribute: 'formenctype' })
|
|
267
|
-
], BaseButton.prototype, "formEnctype", void 0);
|
|
268
|
-
__decorate([
|
|
269
|
-
attr({ attribute: 'formmethod' })
|
|
270
|
-
], BaseButton.prototype, "formMethod", void 0);
|
|
271
|
-
__decorate([
|
|
272
|
-
attr({ attribute: 'formnovalidate', mode: 'boolean' })
|
|
273
|
-
], BaseButton.prototype, "formNoValidate", void 0);
|
|
274
|
-
__decorate([
|
|
275
|
-
attr({ attribute: 'formtarget' })
|
|
276
|
-
], BaseButton.prototype, "formTarget", void 0);
|
|
277
|
-
__decorate([
|
|
278
|
-
attr
|
|
279
|
-
], BaseButton.prototype, "name", void 0);
|
|
280
|
-
__decorate([
|
|
281
|
-
attr
|
|
282
|
-
], BaseButton.prototype, "type", void 0);
|
|
283
|
-
__decorate([
|
|
284
|
-
attr
|
|
285
|
-
], BaseButton.prototype, "value", void 0);
|
|
6
|
+
import { BaseButton } from './button.base.js';
|
|
7
|
+
import { ButtonAppearance, ButtonShape, ButtonSize } from './button.options.js';
|
|
286
8
|
/**
|
|
287
9
|
* A Button Custom HTML Element.
|
|
288
10
|
* Based on BaseButton and includes style and layout specific attributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/button/button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/button/button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,OAAO,MAAO,SAAQ,UAAU;IAAtC;;QA0DE;;;;;;WAMG;QAEI,aAAQ,GAAY,KAAK,CAAC;IAUnC,CAAC;IAjEC;;;;OAIG;IACI,iBAAiB,CAAC,I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{"version":3,"file":"button.styles.js","sourceRoot":"","sources":["../../../src/button/button.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,uBAAuB,EACvB,iCAAiC,EACjC,mCAAmC,EACnC,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC9B,6BAA6B,EAC7B,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,+BAA+B,EAC/B,iCAAiC,EACjC,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;IAC/B,OAAO,CAAC,aAAa,CAAC;;;sB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C;;;UAGnC,WAAW;YACT,mCAAmC;;;UAGrC,gBAAgB;wBACF,0BAA0B;aACrC,uBAAuB;;;UAG1B,gBAAgB;wBACF,+BAA+B;aAC1C,iCAAiC;;;UAGpC,gBAAgB;wBACF,iCAAiC;aAC5C,mCAAmC;;;cAGlC,gBAAgB,KAAK,gBAAgB;;;CAGlD,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;IACrB,gBAAgB;;;;;wBAKI,8BAA8B;oBAClC,0BAA0B;aACjC,8BAA8B;;;;UAIjC,YAAY;UACZ,YAAY;;;;UAIZ,YAAY;UACZ,YAAY;wBACE,0BAA0B;;;UAGxC,WAAW;UACX,WAAW;wBACG,0BAA0B;;;;UAIxC,gBAAgB;UAChB,gBAAgB;;wBAEF,0BAA0B;;CAEjD,CAAC,aAAa,CACb,8BAA8B,CAAC,GAAG,CAAA;;;;;;;;;;YAUxB,YAAY;;;;;;;;;;;GAWrB,CAAC,CACH,CAAC"}
|
package/dist/esm/button/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { definition as ButtonDefinition } from './button.definition.js';
|
|
2
|
-
export { BaseButton
|
|
2
|
+
export { BaseButton } from './button.base.js';
|
|
3
|
+
export { Button } from './button.js';
|
|
3
4
|
export { ButtonAppearance, ButtonFormTarget, ButtonShape, ButtonSize, ButtonType } from './button.options.js';
|
|
4
5
|
export { styles as ButtonStyles } from './button.styles.js';
|
|
5
6
|
export { template as ButtonTemplate } from './button.template.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE9G,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|