@vonage/vivid 3.32.0 → 3.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.js +5 -5
- package/accordion-item/index.js +4 -4
- package/action-group/index.js +1 -1
- package/alert/index.js +6 -6
- package/avatar/index.js +2 -2
- package/badge/index.js +2 -2
- package/banner/index.js +5 -5
- package/breadcrumb/index.js +1 -1
- package/breadcrumb-item/index.js +3 -3
- package/button/index.js +4 -4
- package/calendar/index.js +1 -1
- package/calendar-event/index.js +1 -1
- package/card/index.js +3 -3
- package/checkbox/index.js +5 -3
- package/combobox/index.js +8 -8
- package/custom-elements.json +256 -18
- package/data-grid/index.js +2 -2
- package/date-picker/index.js +9 -9
- package/dialog/index.js +6 -6
- package/divider/index.js +1 -1
- package/elevation/index.js +1 -1
- package/empty-state/index.js +2 -2
- package/fab/index.js +4 -4
- package/file-picker/index.js +5 -5
- package/focus/index.js +1 -1
- package/header/index.js +2 -2
- package/icon/index.js +1 -1
- package/index.js +59 -59
- package/layout/index.js +1 -1
- package/lib/avatar/avatar.d.ts +1 -1
- package/lib/calendar/calendar.d.ts +1 -1
- package/lib/date-picker/calendar/dateStr.d.ts +1 -0
- package/lib/date-picker/calendar/month.d.ts +1 -0
- package/lib/date-picker/calendar/year.d.ts +2 -0
- package/lib/date-picker/date-picker.d.ts +2 -0
- package/lib/icon/icon.d.ts +0 -1
- package/lib/listbox/listbox.d.ts +9 -1
- package/lib/progress-ring/progress-ring.d.ts +1 -1
- package/lib/text-field/text-field.d.ts +1 -0
- package/listbox/index.js +20 -16
- package/locales/en-GB.js +48 -14
- package/locales/en-US.js +48 -14
- package/locales/ja-JP.js +48 -14
- package/locales/zh-CN.js +48 -14
- package/menu/index.js +8 -8
- package/menu-item/index.js +4 -4
- package/nav/index.js +1 -1
- package/nav-disclosure/index.js +3 -3
- package/nav-item/index.js +3 -3
- package/note/index.js +2 -3
- package/number-field/index.js +6 -6
- package/option/index.js +3 -3
- package/package.json +2 -16
- package/pagination/index.js +5 -5
- package/popup/index.js +6 -6
- package/progress/index.js +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.js +2 -2
- package/radio-group/index.js +1 -1
- package/select/index.js +8 -8
- package/shared/affix.js +25 -9
- package/shared/apply-mixins.js +1 -1
- package/shared/breadcrumb-item.js +5 -5
- package/shared/button.js +13 -13
- package/shared/calendar-event.js +36 -16
- package/shared/definition.js +133 -194
- package/shared/definition10.js +225 -40
- package/shared/definition11.js +36 -32
- package/shared/definition12.js +763 -98
- package/shared/definition13.js +125 -89
- package/shared/definition14.js +207 -27
- package/shared/definition15.js +710 -731
- package/shared/definition16.js +1289 -47
- package/shared/definition17.js +6113 -93
- package/shared/definition18.js +242 -164
- package/shared/definition19.js +47 -692
- package/shared/definition2.js +199 -117
- package/shared/definition20.js +59 -1671
- package/shared/definition21.js +95 -255
- package/shared/definition22.js +2218 -1167
- package/shared/definition23.js +61 -5784
- package/shared/definition24.js +28 -117
- package/shared/definition25.js +52 -66
- package/shared/definition26.js +391 -214
- package/shared/definition27.js +441 -34
- package/shared/definition28.js +85 -73
- package/shared/definition29.js +21 -2283
- package/shared/definition3.js +61 -24
- package/shared/definition30.js +13 -49
- package/shared/definition31.js +54 -39
- package/shared/definition32.js +413 -375
- package/shared/definition33.js +223 -304
- package/shared/definition34.js +197 -13
- package/shared/definition35.js +88 -73
- package/shared/definition36.js +75 -25
- package/shared/definition37.js +434 -34
- package/shared/definition38.js +32 -432
- package/shared/definition39.js +677 -187
- package/shared/definition4.js +157 -12
- package/shared/definition40.js +95 -48
- package/shared/definition41.js +577 -31
- package/shared/definition42.js +126 -424
- package/shared/definition43.js +114 -618
- package/shared/definition44.js +24 -80
- package/shared/definition45.js +71 -543
- package/shared/definition46.js +499 -92
- package/shared/definition47.js +19 -133
- package/shared/definition48.js +129 -52
- package/shared/definition49.js +281 -17
- package/shared/definition5.js +71 -36
- package/shared/definition50.js +153 -484
- package/shared/definition51.js +131 -98
- package/shared/definition52.js +131 -16
- package/shared/definition53.js +80 -264
- package/shared/definition54.js +293 -118
- package/shared/definition55.js +12 -117
- package/shared/definition56.js +39 -68
- package/shared/definition57.js +166 -288
- package/shared/definition6.js +56 -111
- package/shared/definition7.js +120 -195
- package/shared/definition8.js +58 -23
- package/shared/definition9.js +92 -66
- package/shared/focus.js +2 -1
- package/shared/focus2.js +1 -1
- package/shared/form-associated.js +2 -2
- package/shared/icon.js +48 -27
- package/shared/index.js +7 -27
- package/shared/index2.js +108 -80
- package/shared/key-codes.js +1 -1
- package/shared/listbox.js +88 -11
- package/shared/patterns/form-elements/form-elements.d.ts +4 -4
- package/shared/radio.js +23 -7
- package/shared/repeat.js +1 -1
- package/shared/text-anchor.js +21 -4
- package/shared/text-anchor.template.js +37 -40
- package/shared/text-field.js +2 -2
- package/shared/text-field2.js +15 -15
- package/shared/tree-item.js +12 -12
- package/side-drawer/index.js +1 -1
- package/slider/index.js +2 -2
- package/split-button/index.js +3 -3
- package/style.css +6106 -0
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/switch/index.js +3 -3
- package/tab/index.js +3 -3
- package/tab-panel/index.js +1 -1
- package/tabs/index.js +5 -5
- package/tag/index.js +3 -3
- package/tag-group/index.js +1 -1
- package/text-anchor/index.js +1 -1
- package/text-area/index.js +3 -3
- package/text-field/index.js +3 -3
- package/toggletip/index.js +7 -7
- package/tooltip/index.js +7 -7
- package/tree-item/index.js +3 -3
- package/tree-view/index.js +1 -1
- package/vivid.api.json +10 -1
- package/lib/accordion/index.d.ts +0 -1
- package/lib/accordion-item/index.d.ts +0 -1
- package/lib/action-group/index.d.ts +0 -1
- package/lib/alert/index.d.ts +0 -1
- package/lib/avatar/index.d.ts +0 -1
- package/lib/badge/index.d.ts +0 -1
- package/lib/banner/index.d.ts +0 -1
- package/lib/breadcrumb/index.d.ts +0 -1
- package/lib/breadcrumb-item/index.d.ts +0 -1
- package/lib/button/index.d.ts +0 -1
- package/lib/calendar/index.d.ts +0 -1
- package/lib/calendar-event/index.d.ts +0 -1
- package/lib/card/index.d.ts +0 -1
- package/lib/checkbox/index.d.ts +0 -1
- package/lib/combobox/index.d.ts +0 -1
- package/lib/data-grid/index.d.ts +0 -1
- package/lib/date-picker/index.d.ts +0 -1
- package/lib/dialog/index.d.ts +0 -1
- package/lib/divider/index.d.ts +0 -1
- package/lib/elevation/index.d.ts +0 -1
- package/lib/empty-state/index.d.ts +0 -1
- package/lib/fab/index.d.ts +0 -1
- package/lib/file-picker/index.d.ts +0 -1
- package/lib/focus/index.d.ts +0 -1
- package/lib/header/index.d.ts +0 -1
- package/lib/icon/index.d.ts +0 -1
- package/lib/layout/index.d.ts +0 -1
- package/lib/listbox/index.d.ts +0 -1
- package/lib/menu/index.d.ts +0 -1
- package/lib/menu-item/index.d.ts +0 -1
- package/lib/nav/index.d.ts +0 -1
- package/lib/nav-disclosure/index.d.ts +0 -1
- package/lib/nav-item/index.d.ts +0 -1
- package/lib/note/index.d.ts +0 -1
- package/lib/number-field/index.d.ts +0 -1
- package/lib/option/index.d.ts +0 -1
- package/lib/pagination/index.d.ts +0 -1
- package/lib/popup/index.d.ts +0 -1
- package/lib/progress/index.d.ts +0 -1
- package/lib/progress-ring/index.d.ts +0 -1
- package/lib/radio/index.d.ts +0 -1
- package/lib/radio-group/index.d.ts +0 -1
- package/lib/select/index.d.ts +0 -1
- package/lib/side-drawer/index.d.ts +0 -1
- package/lib/slider/index.d.ts +0 -1
- package/lib/split-button/index.d.ts +0 -1
- package/lib/switch/index.d.ts +0 -1
- package/lib/tab/index.d.ts +0 -1
- package/lib/tab-panel/index.d.ts +0 -1
- package/lib/tabs/index.d.ts +0 -1
- package/lib/tag/index.d.ts +0 -1
- package/lib/tag-group/index.d.ts +0 -1
- package/lib/text-anchor/index.d.ts +0 -1
- package/lib/text-area/index.d.ts +0 -1
- package/lib/text-field/index.d.ts +0 -1
- package/lib/toggletip/index.d.ts +0 -1
- package/lib/tooltip/index.d.ts +0 -1
- package/lib/tree-item/index.d.ts +0 -1
- package/lib/tree-view/index.d.ts +0 -1
package/shared/definition32.js
CHANGED
|
@@ -1,434 +1,472 @@
|
|
|
1
|
-
import { F as FoundationElement, D as DOM, _ as __decorate,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { F as FoundationElement, D as DOM, _ as __decorate, a as attr, n as nullableNumberConverter, o as observable, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { B as Button, S as Shape, a as buttonRegistries } from './definition10.js';
|
|
3
|
+
import { D as Divider, a as dividerRegistries } from './definition19.js';
|
|
4
|
+
import { A as AffixIcon } from './affix.js';
|
|
5
|
+
import { f as formElements, F as FormElementSuccessText, a as FormElementHelperText, b as FormElementCharCount, g as getFeedbackTemplate } from './index2.js';
|
|
6
|
+
import { S as StartEnd } from './start-end.js';
|
|
7
|
+
import { a as applyMixins } from './apply-mixins.js';
|
|
8
|
+
import { D as DelegatesARIATextbox } from './text-field2.js';
|
|
9
|
+
import { F as FormAssociated } from './form-associated.js';
|
|
10
|
+
import { d as keyArrowDown, e as keyArrowUp } from './key-codes.js';
|
|
11
|
+
import { f as focusTemplateFactory } from './focus2.js';
|
|
12
|
+
import { w as when } from './when.js';
|
|
13
|
+
import { r as ref } from './ref.js';
|
|
7
14
|
import { c as classNames } from './class-names.js';
|
|
8
15
|
|
|
16
|
+
class _NumberField extends FoundationElement {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A form-associated base class for the {@link @microsoft/fast-foundation#(NumberField:class)} component.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
class FormAssociatedNumberField extends FormAssociated(_NumberField) {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.proxy = document.createElement("input");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
9
30
|
/**
|
|
10
|
-
* A
|
|
11
|
-
*
|
|
31
|
+
* A Number Field Custom HTML Element.
|
|
32
|
+
* Based largely on the {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number | <input type="number" /> element }.
|
|
12
33
|
*
|
|
13
|
-
* @slot -
|
|
34
|
+
* @slot start - Content which can be provided before the number field input
|
|
35
|
+
* @slot end - Content which can be provided after the number field input
|
|
36
|
+
* @slot - The default slot for the label
|
|
37
|
+
* @slot step-up-glyph - The glyph for the step up control
|
|
38
|
+
* @slot step-down-glyph - The glyph for the step down control
|
|
39
|
+
* @csspart label - The label
|
|
40
|
+
* @csspart root - The element wrapping the control, including start and end slots
|
|
41
|
+
* @csspart control - The element representing the input
|
|
42
|
+
* @csspart controls - The step up and step down controls
|
|
43
|
+
* @csspart step-up - The step up control
|
|
44
|
+
* @csspart step-down - The step down control
|
|
45
|
+
* @fires input - Fires a custom 'input' event when the value has changed
|
|
46
|
+
* @fires change - Fires a custom 'change' event when the value has changed
|
|
14
47
|
*
|
|
15
48
|
* @public
|
|
16
49
|
*/
|
|
17
|
-
|
|
50
|
+
let NumberField$1 = class NumberField extends FormAssociatedNumberField {
|
|
18
51
|
constructor() {
|
|
19
52
|
super(...arguments);
|
|
20
|
-
this.expandedItem = null;
|
|
21
53
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
54
|
+
* When true, spin buttons will not be rendered
|
|
55
|
+
* @public
|
|
56
|
+
* @remarks
|
|
57
|
+
* HTML Attribute: autofocus
|
|
24
58
|
*/
|
|
25
|
-
this.
|
|
59
|
+
this.hideStep = false;
|
|
26
60
|
/**
|
|
27
|
-
*
|
|
61
|
+
* Amount to increment or decrement the value by
|
|
62
|
+
* @public
|
|
63
|
+
* @remarks
|
|
64
|
+
* HTMLAttribute: step
|
|
28
65
|
*/
|
|
29
|
-
this.
|
|
30
|
-
return (this.parentElement !== null &&
|
|
31
|
-
isHTMLElement(this.parentElement) &&
|
|
32
|
-
this.parentElement.getAttribute("role") === "menuitem");
|
|
33
|
-
};
|
|
66
|
+
this.step = 1;
|
|
34
67
|
/**
|
|
35
|
-
*
|
|
68
|
+
* Flag to indicate that the value change is from the user input
|
|
36
69
|
* @internal
|
|
37
70
|
*/
|
|
38
|
-
this.
|
|
39
|
-
if (!this.contains(e.relatedTarget) && this.menuItems !== undefined) {
|
|
40
|
-
this.collapseExpandedItem();
|
|
41
|
-
// find our first focusable element
|
|
42
|
-
const focusIndex = this.menuItems.findIndex(this.isFocusableElement);
|
|
43
|
-
// set the current focus index's tabindex to -1
|
|
44
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
45
|
-
// set the first focusable element tabindex to 0
|
|
46
|
-
this.menuItems[focusIndex].setAttribute("tabindex", "0");
|
|
47
|
-
// set the focus index
|
|
48
|
-
this.focusIndex = focusIndex;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
this.handleItemFocus = (e) => {
|
|
52
|
-
const targetItem = e.target;
|
|
53
|
-
if (this.menuItems !== undefined &&
|
|
54
|
-
targetItem !== this.menuItems[this.focusIndex]) {
|
|
55
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
56
|
-
this.focusIndex = this.menuItems.indexOf(targetItem);
|
|
57
|
-
targetItem.setAttribute("tabindex", "0");
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
this.handleExpandedChanged = (e) => {
|
|
61
|
-
if (e.defaultPrevented ||
|
|
62
|
-
e.target === null ||
|
|
63
|
-
this.menuItems === undefined ||
|
|
64
|
-
this.menuItems.indexOf(e.target) < 0) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
e.preventDefault();
|
|
68
|
-
const changedItem = e.target;
|
|
69
|
-
// closing an expanded item without opening another
|
|
70
|
-
if (this.expandedItem !== null &&
|
|
71
|
-
changedItem === this.expandedItem &&
|
|
72
|
-
changedItem.expanded === false) {
|
|
73
|
-
this.expandedItem = null;
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (changedItem.expanded) {
|
|
77
|
-
if (this.expandedItem !== null && this.expandedItem !== changedItem) {
|
|
78
|
-
this.expandedItem.expanded = false;
|
|
79
|
-
}
|
|
80
|
-
this.menuItems[this.focusIndex].setAttribute("tabindex", "-1");
|
|
81
|
-
this.expandedItem = changedItem;
|
|
82
|
-
this.focusIndex = this.menuItems.indexOf(changedItem);
|
|
83
|
-
changedItem.setAttribute("tabindex", "0");
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
this.removeItemListeners = () => {
|
|
87
|
-
if (this.menuItems !== undefined) {
|
|
88
|
-
this.menuItems.forEach((item) => {
|
|
89
|
-
item.removeEventListener("expanded-change", this.handleExpandedChanged);
|
|
90
|
-
item.removeEventListener("focus", this.handleItemFocus);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
this.setItems = () => {
|
|
95
|
-
const newItems = this.domChildren();
|
|
96
|
-
this.removeItemListeners();
|
|
97
|
-
this.menuItems = newItems;
|
|
98
|
-
const menuItems = this.menuItems.filter(this.isMenuItemElement);
|
|
99
|
-
// if our focus index is not -1 we have items
|
|
100
|
-
if (menuItems.length) {
|
|
101
|
-
this.focusIndex = 0;
|
|
102
|
-
}
|
|
103
|
-
function elementIndent(el) {
|
|
104
|
-
const role = el.getAttribute("role");
|
|
105
|
-
const startSlot = el.querySelector("[slot=start]");
|
|
106
|
-
if (role !== MenuItemRole.menuitem && startSlot === null) {
|
|
107
|
-
return 1;
|
|
108
|
-
}
|
|
109
|
-
else if (role === MenuItemRole.menuitem && startSlot !== null) {
|
|
110
|
-
return 1;
|
|
111
|
-
}
|
|
112
|
-
else if (role !== MenuItemRole.menuitem && startSlot !== null) {
|
|
113
|
-
return 2;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
return 0;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const indent = menuItems.reduce((accum, current) => {
|
|
120
|
-
const elementValue = elementIndent(current);
|
|
121
|
-
return accum > elementValue ? accum : elementValue;
|
|
122
|
-
}, 0);
|
|
123
|
-
menuItems.forEach((item, index) => {
|
|
124
|
-
item.setAttribute("tabindex", index === 0 ? "0" : "-1");
|
|
125
|
-
item.addEventListener("expanded-change", this.handleExpandedChanged);
|
|
126
|
-
item.addEventListener("focus", this.handleItemFocus);
|
|
127
|
-
if (item instanceof MenuItem) {
|
|
128
|
-
item.startColumnCount = indent;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* handle change from child element
|
|
134
|
-
*/
|
|
135
|
-
this.changeHandler = (e) => {
|
|
136
|
-
if (this.menuItems === undefined) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const changedMenuItem = e.target;
|
|
140
|
-
const changeItemIndex = this.menuItems.indexOf(changedMenuItem);
|
|
141
|
-
if (changeItemIndex === -1) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (changedMenuItem.role === "menuitemradio" &&
|
|
145
|
-
changedMenuItem.checked === true) {
|
|
146
|
-
for (let i = changeItemIndex - 1; i >= 0; --i) {
|
|
147
|
-
const item = this.menuItems[i];
|
|
148
|
-
const role = item.getAttribute("role");
|
|
149
|
-
if (role === MenuItemRole.menuitemradio) {
|
|
150
|
-
item.checked = false;
|
|
151
|
-
}
|
|
152
|
-
if (role === "separator") {
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const maxIndex = this.menuItems.length - 1;
|
|
157
|
-
for (let i = changeItemIndex + 1; i <= maxIndex; ++i) {
|
|
158
|
-
const item = this.menuItems[i];
|
|
159
|
-
const role = item.getAttribute("role");
|
|
160
|
-
if (role === MenuItemRole.menuitemradio) {
|
|
161
|
-
item.checked = false;
|
|
162
|
-
}
|
|
163
|
-
if (role === "separator") {
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* check if the item is a menu item
|
|
171
|
-
*/
|
|
172
|
-
this.isMenuItemElement = (el) => {
|
|
173
|
-
return (isHTMLElement(el) &&
|
|
174
|
-
Menu$1.focusableElementRoles.hasOwnProperty(el.getAttribute("role")));
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* check if the item is focusable
|
|
178
|
-
*/
|
|
179
|
-
this.isFocusableElement = (el) => {
|
|
180
|
-
return this.isMenuItemElement(el);
|
|
181
|
-
};
|
|
71
|
+
this.isUserInput = false;
|
|
182
72
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Ensures that the max is greater than the min and that the value
|
|
75
|
+
* is less than the max
|
|
76
|
+
* @param previous - the previous max value
|
|
77
|
+
* @param next - updated max value
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
maxChanged(previous, next) {
|
|
82
|
+
var _a;
|
|
83
|
+
this.max = Math.max(next, (_a = this.min) !== null && _a !== void 0 ? _a : next);
|
|
84
|
+
const min = Math.min(this.min, this.max);
|
|
85
|
+
if (this.min !== undefined && this.min !== min) {
|
|
86
|
+
this.min = min;
|
|
189
87
|
}
|
|
88
|
+
this.value = this.getValidValue(this.value);
|
|
190
89
|
}
|
|
191
90
|
/**
|
|
91
|
+
* Ensures that the min is less than the max and that the value
|
|
92
|
+
* is greater than the min
|
|
93
|
+
* @param previous - previous min value
|
|
94
|
+
* @param next - updated min value
|
|
95
|
+
*
|
|
192
96
|
* @internal
|
|
193
97
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.
|
|
200
|
-
}
|
|
201
|
-
this.
|
|
98
|
+
minChanged(previous, next) {
|
|
99
|
+
var _a;
|
|
100
|
+
this.min = Math.min(next, (_a = this.max) !== null && _a !== void 0 ? _a : next);
|
|
101
|
+
const max = Math.max(this.min, this.max);
|
|
102
|
+
if (this.max !== undefined && this.max !== max) {
|
|
103
|
+
this.max = max;
|
|
104
|
+
}
|
|
105
|
+
this.value = this.getValidValue(this.value);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The value property, typed as a number.
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
get valueAsNumber() {
|
|
113
|
+
return parseFloat(super.value);
|
|
114
|
+
}
|
|
115
|
+
set valueAsNumber(next) {
|
|
116
|
+
this.value = next.toString();
|
|
202
117
|
}
|
|
203
118
|
/**
|
|
119
|
+
* Validates that the value is a number between the min and max
|
|
120
|
+
* @param previous - previous stored value
|
|
121
|
+
* @param next - value being updated
|
|
122
|
+
* @param updateControl - should the text field be updated with value, defaults to true
|
|
204
123
|
* @internal
|
|
205
124
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.
|
|
209
|
-
|
|
210
|
-
|
|
125
|
+
valueChanged(previous, next) {
|
|
126
|
+
this.value = this.getValidValue(next);
|
|
127
|
+
if (next !== this.value) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (this.control && !this.isUserInput) {
|
|
131
|
+
this.control.value = this.value;
|
|
132
|
+
}
|
|
133
|
+
super.valueChanged(previous, this.value);
|
|
134
|
+
if (previous !== undefined && !this.isUserInput) {
|
|
135
|
+
this.$emit("input");
|
|
136
|
+
this.$emit("change");
|
|
137
|
+
}
|
|
138
|
+
this.isUserInput = false;
|
|
139
|
+
}
|
|
140
|
+
/** {@inheritDoc (FormAssociated:interface).validate} */
|
|
141
|
+
validate() {
|
|
142
|
+
super.validate(this.control);
|
|
211
143
|
}
|
|
212
144
|
/**
|
|
213
|
-
*
|
|
145
|
+
* Sets the internal value to a valid number between the min and max properties
|
|
146
|
+
* @param value - user input
|
|
147
|
+
*
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
150
|
+
getValidValue(value) {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
let validValue = parseFloat(parseFloat(value).toPrecision(12));
|
|
153
|
+
if (isNaN(validValue)) {
|
|
154
|
+
validValue = "";
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
validValue = Math.min(validValue, (_a = this.max) !== null && _a !== void 0 ? _a : validValue);
|
|
158
|
+
validValue = Math.max(validValue, (_b = this.min) !== null && _b !== void 0 ? _b : validValue).toString();
|
|
159
|
+
}
|
|
160
|
+
return validValue;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Increments the value using the step value
|
|
214
164
|
*
|
|
215
165
|
* @public
|
|
216
166
|
*/
|
|
217
|
-
|
|
218
|
-
this.
|
|
167
|
+
stepUp() {
|
|
168
|
+
const value = parseFloat(this.value);
|
|
169
|
+
const stepUpValue = !isNaN(value)
|
|
170
|
+
? value + this.step
|
|
171
|
+
: this.min > 0
|
|
172
|
+
? this.min
|
|
173
|
+
: this.max < 0
|
|
174
|
+
? this.max
|
|
175
|
+
: !this.min
|
|
176
|
+
? this.step
|
|
177
|
+
: 0;
|
|
178
|
+
this.value = stepUpValue.toString();
|
|
219
179
|
}
|
|
220
180
|
/**
|
|
221
|
-
*
|
|
181
|
+
* Decrements the value using the step value
|
|
222
182
|
*
|
|
223
183
|
* @public
|
|
224
184
|
*/
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.
|
|
229
|
-
|
|
185
|
+
stepDown() {
|
|
186
|
+
const value = parseFloat(this.value);
|
|
187
|
+
const stepDownValue = !isNaN(value)
|
|
188
|
+
? value - this.step
|
|
189
|
+
: this.min > 0
|
|
190
|
+
? this.min
|
|
191
|
+
: this.max < 0
|
|
192
|
+
? this.max
|
|
193
|
+
: !this.min
|
|
194
|
+
? 0 - this.step
|
|
195
|
+
: 0;
|
|
196
|
+
this.value = stepDownValue.toString();
|
|
230
197
|
}
|
|
231
198
|
/**
|
|
199
|
+
* Sets up the initial state of the number field
|
|
232
200
|
* @internal
|
|
233
201
|
*/
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this.
|
|
242
|
-
|
|
243
|
-
case keyArrowUp:
|
|
244
|
-
// go back one index
|
|
245
|
-
this.setFocus(this.focusIndex - 1, -1);
|
|
246
|
-
return;
|
|
247
|
-
case keyEnd:
|
|
248
|
-
// set focus on last item
|
|
249
|
-
this.setFocus(this.menuItems.length - 1, -1);
|
|
250
|
-
return;
|
|
251
|
-
case keyHome:
|
|
252
|
-
// set focus on first item
|
|
253
|
-
this.setFocus(0, 1);
|
|
254
|
-
return;
|
|
255
|
-
default:
|
|
256
|
-
// if we are not handling the event, do not prevent default
|
|
257
|
-
return true;
|
|
202
|
+
connectedCallback() {
|
|
203
|
+
super.connectedCallback();
|
|
204
|
+
this.proxy.setAttribute("type", "number");
|
|
205
|
+
this.validate();
|
|
206
|
+
this.control.value = this.value;
|
|
207
|
+
if (this.autofocus) {
|
|
208
|
+
DOM.queueUpdate(() => {
|
|
209
|
+
this.focus();
|
|
210
|
+
});
|
|
258
211
|
}
|
|
259
212
|
}
|
|
260
213
|
/**
|
|
261
|
-
*
|
|
214
|
+
* Selects all the text in the number field
|
|
215
|
+
*
|
|
216
|
+
* @public
|
|
262
217
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
218
|
+
select() {
|
|
219
|
+
this.control.select();
|
|
220
|
+
/**
|
|
221
|
+
* The select event does not permeate the shadow DOM boundary.
|
|
222
|
+
* This fn effectively proxies the select event,
|
|
223
|
+
* emitting a `select` event whenever the internal
|
|
224
|
+
* control emits a `select` event
|
|
225
|
+
*/
|
|
226
|
+
this.$emit("select");
|
|
265
227
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Handles the internal control's `input` event
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
handleTextInput() {
|
|
233
|
+
this.control.value = this.control.value.replace(/[^0-9\-+e.]/g, "");
|
|
234
|
+
this.isUserInput = true;
|
|
235
|
+
this.value = this.control.value;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Change event handler for inner control.
|
|
239
|
+
* @remarks
|
|
240
|
+
* "Change" events are not `composable` so they will not
|
|
241
|
+
* permeate the shadow DOM boundary. This fn effectively proxies
|
|
242
|
+
* the change event, emitting a `change` event whenever the internal
|
|
243
|
+
* control emits a `change` event
|
|
244
|
+
* @internal
|
|
245
|
+
*/
|
|
246
|
+
handleChange() {
|
|
247
|
+
this.$emit("change");
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Handles the internal control's `keydown` event
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
handleKeyDown(e) {
|
|
254
|
+
const key = e.key;
|
|
255
|
+
switch (key) {
|
|
256
|
+
case keyArrowUp:
|
|
257
|
+
this.stepUp();
|
|
258
|
+
return false;
|
|
259
|
+
case keyArrowDown:
|
|
260
|
+
this.stepDown();
|
|
261
|
+
return false;
|
|
287
262
|
}
|
|
263
|
+
return true;
|
|
288
264
|
}
|
|
289
|
-
|
|
290
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Handles populating the input field with a validated value when
|
|
267
|
+
* leaving the input field.
|
|
268
|
+
* @internal
|
|
269
|
+
*/
|
|
270
|
+
handleBlur() {
|
|
271
|
+
this.control.value = this.value;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
__decorate([
|
|
275
|
+
attr({ attribute: "readonly", mode: "boolean" })
|
|
276
|
+
], NumberField$1.prototype, "readOnly", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
attr({ mode: "boolean" })
|
|
279
|
+
], NumberField$1.prototype, "autofocus", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
attr({ attribute: "hide-step", mode: "boolean" })
|
|
282
|
+
], NumberField$1.prototype, "hideStep", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
attr
|
|
285
|
+
], NumberField$1.prototype, "placeholder", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
attr
|
|
288
|
+
], NumberField$1.prototype, "list", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
attr({ converter: nullableNumberConverter })
|
|
291
|
+
], NumberField$1.prototype, "maxlength", void 0);
|
|
292
|
+
__decorate([
|
|
293
|
+
attr({ converter: nullableNumberConverter })
|
|
294
|
+
], NumberField$1.prototype, "minlength", void 0);
|
|
295
|
+
__decorate([
|
|
296
|
+
attr({ converter: nullableNumberConverter })
|
|
297
|
+
], NumberField$1.prototype, "size", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
attr({ converter: nullableNumberConverter })
|
|
300
|
+
], NumberField$1.prototype, "step", void 0);
|
|
301
|
+
__decorate([
|
|
302
|
+
attr({ converter: nullableNumberConverter })
|
|
303
|
+
], NumberField$1.prototype, "max", void 0);
|
|
304
|
+
__decorate([
|
|
305
|
+
attr({ converter: nullableNumberConverter })
|
|
306
|
+
], NumberField$1.prototype, "min", void 0);
|
|
291
307
|
__decorate([
|
|
292
308
|
observable
|
|
293
|
-
],
|
|
309
|
+
], NumberField$1.prototype, "defaultSlottedNodes", void 0);
|
|
310
|
+
applyMixins(NumberField$1, StartEnd, DelegatesARIATextbox);
|
|
294
311
|
|
|
295
|
-
|
|
312
|
+
const styles = "/**\n * Do not edit directly\n * Generated on Wed, 06 Sep 2023 09:40:36 GMT\n */\n:host {\n display: inline-block;\n}\n\n.base {\n --_text-field-gutter: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) / 2.5);\n --_text-field-icon-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2))) / 2);\n display: inline-grid;\n width: 100%;\n gap: 4px;\n grid-template-columns: min-content 1fr max-content;\n}\n.base {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-intermediate);\n}\n.base.appearance-ghost {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)).appearance-ghost {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: var(--vvd-color-neutral-100);\n --_appearance-color-outline: var(--vvd-color-neutral-300);\n}\n.base:where(:disabled, .disabled).appearance-ghost {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(.readonly):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--vvd-color-neutral-200);\n --_appearance-color-outline: var(--vvd-color-neutral-400);\n}\n.base:where(.readonly):where(:not(:disabled, .disabled)).appearance-ghost {\n --_appearance-color-text: var(--vvd-color-neutral-600);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base.connotation-success {\n /* @cssprop [--vvd-text-field-success-primary=var(--vvd-color-success-500)] */\n --_connotation-color-primary: var(--vvd-text-field-success-primary, var(--vvd-color-success-500));\n /* @cssprop [--vvd-text-field-success-backdrop=var(--vvd-color-success-50)] */\n --_connotation-color-backdrop: var(--vvd-text-field-success-backdrop, var(--vvd-color-success-50));\n /* @cssprop [--vvd-text-field-success-intermediate=var(--vvd-color-success-500)] */\n --_connotation-color-intermediate: var(--vvd-text-field-success-intermediate, var(--vvd-color-success-500));\n /* @cssprop [--vvd-text-field-success-firm=var(--vvd-color-success-600)] */\n --_connotation-color-firm: var(--vvd-text-field-success-firm, var(--vvd-color-success-600));\n /* @cssprop [--vvd-text-field-success-faint=var(--vvd-color-success-50)] */\n --_connotation-color-faint: var(--vvd-text-field-success-faint, var(--vvd-color-success-50));\n /* @cssprop [--vvd-text-field-success-soft=var(--vvd-color-success-100)] */\n --_connotation-color-soft: var(--vvd-text-field-success-soft, var(--vvd-color-success-100));\n}\n.base.connotation-alert {\n /* @cssprop [--vvd-text-field-alert-primary=var(--vvd-color-alert-500)] */\n --_connotation-color-primary: var(--vvd-text-field-alert-primary, var(--vvd-color-alert-500));\n /* @cssprop [--vvd-text-field-alert-backdrop=var(--vvd-color-alert-50)] */\n --_connotation-color-backdrop: var(--vvd-text-field-alert-backdrop, var(--vvd-color-alert-50));\n /* @cssprop [--vvd-text-field-alert-intermediate=var(--vvd-color-alert-500)] */\n --_connotation-color-intermediate: var(--vvd-text-field-alert-intermediate, var(--vvd-color-alert-500));\n /* @cssprop [--vvd-text-field-alert-firm=var(--vvd-color-alert-600)] */\n --_connotation-color-firm: var(--vvd-text-field-alert-firm, var(--vvd-color-alert-600));\n /* @cssprop [--vvd-text-field-alert-faint=var(--vvd-color-alert-50)] */\n --_connotation-color-faint: var(--vvd-text-field-alert-faint, var(--vvd-color-alert-50));\n /* @cssprop [--vvd-text-field-alert-soft=var(--vvd-color-alert-100)] */\n --_connotation-color-soft: var(--vvd-text-field-alert-soft, var(--vvd-color-alert-100));\n}\n.base:not(.connotation-success, .connotation-alert) {\n /* @cssprop [--vvd-text-field-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-text-field-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-text-field-accent-backdrop=var(--vvd-color-canvas)] */\n --_connotation-color-backdrop: var(--vvd-text-field-accent-backdrop, var(--vvd-color-canvas));\n /* @cssprop [--vvd-text-field-accent-intermediate=var(--vvd-color-neutral-500)] */\n --_connotation-color-intermediate: var(--vvd-text-field-accent-intermediate, var(--vvd-color-neutral-500));\n /* @cssprop [--vvd-text-field-accent-firm=var(--vvd-color-canvas-text)] */\n --_connotation-color-firm: var(--vvd-text-field-accent-firm, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-text-field-accent-faint=var(--vvd-color-neutral-50)] */\n --_connotation-color-faint: var(--vvd-text-field-accent-faint, var(--vvd-color-neutral-50));\n /* @cssprop [--vvd-text-field-accent-soft=var(--vvd-color-neutral-100)] */\n --_connotation-color-soft: var(--vvd-text-field-accent-soft, var(--vvd-color-neutral-100));\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base:not(.disabled) {\n --_low-ink-color: var(--vvd-color-neutral-600);\n}\n.base.disabled {\n --_low-ink-color: var(--_appearance-color-text);\n}\n\n.label {\n color: var(--vvd-color-canvas-text);\n contain: inline-size;\n font: var(--vvd-typography-base);\n grid-column: 1/4;\n grid-row: 1;\n}\n.char-count + .label {\n grid-column: 1/3;\n}\n\n.char-count {\n color: var(--_low-ink-color);\n font: var(--vvd-typography-base);\n grid-column: 3/4;\n}\n\n.fieldset {\n position: relative;\n display: flex;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n font: var(--vvd-typography-base);\n grid-column: 1/4;\n padding-block: 0;\n transition: color 0.2s, background-color 0.2s;\n /* Shape */\n}\n.fieldset::after {\n position: absolute;\n display: block;\n block-size: 100%;\n border-radius: inherit;\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n content: \"\";\n inline-size: 100%;\n pointer-events: none;\n transition: box-shadow 0.2s;\n}\n.fieldset:focus-visible {\n outline: none;\n}\n.base > .fieldset {\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2)));\n}\n.base:not(.shape-pill) .fieldset {\n border-radius: 6px;\n}\n.base.shape-pill .fieldset {\n border-radius: 24px;\n}\n\n.wrapper {\n block-size: 100%;\n border-radius: inherit;\n inline-size: 100%;\n}\n.wrapper:focus-visible {\n outline: none;\n}\n\n.control {\n width: 100%;\n box-sizing: border-box;\n border: 0 none;\n appearance: none; /* for box-shadow visibility on IOS */\n background-color: transparent;\n block-size: 100%;\n border-radius: inherit;\n color: inherit;\n font: inherit;\n padding-block: 0;\n padding-inline-end: var(--_text-field-gutter);\n padding-inline-start: var(--_text-field-gutter);\n}\n.control:disabled {\n cursor: not-allowed;\n opacity: 1; /* 2. correct opacity on iOS */\n -webkit-text-fill-color: var(--_appearance-color-text); /* 1. sets text fill to current `color` for safari */\n}\n.control::placeholder, .control:disabled::placeholder {\n opacity: 1; /* 2. correct opacity on iOS */\n -webkit-text-fill-color: var(--_low-ink-color); /* 1. sets text fill to current `color` for safari */\n}\n.control:focus-visible {\n outline: none;\n}\n.has-icon .control {\n padding-inline-start: calc(var(--_text-field-icon-size) + var(--_text-field-gutter) * 2);\n}\n\n.icon {\n position: absolute;\n z-index: 1;\n color: var(--_low-ink-color);\n font-size: var(--_text-field-icon-size);\n inset-block-start: 50%;\n inset-inline-start: calc(100% + var(--_text-field-gutter));\n line-height: 1;\n transform: translateY(-50%);\n}\n\n.leading-items-wrapper {\n position: relative;\n}\n.base.no-leading .leading-items-wrapper {\n display: none;\n}\n\n.action-items-wrapper {\n margin-inline-end: 4px;\n}\n.base:not(.action-items) .action-items-wrapper {\n display: none;\n}\n\n.focus-indicator {\n --focus-stroke-gap-color: transparent;\n pointer-events: none;\n}\n.wrapper:not(:focus-visible, :focus-within) > .focus-indicator, .fieldset:not(:focus-visible, :focus-within) > .focus-indicator {\n display: none;\n}\n\n.control {\n padding-inline-end: 70px;\n}\n.control::-webkit-outer-spin-button, .control::-webkit-inner-spin-button {\n appearance: none;\n}\n.control-buttons {\n position: absolute;\n z-index: 1;\n right: 3px;\n display: flex;\n}\n.readonly .control-buttons, .disabled .control-buttons {\n pointer-events: none;\n}\n.control-buttons .divider {\n margin-block: 8px;\n}\n.control-buttons > * {\n flex-shrink: 0;\n}\n\n.disabled .focus-indicator {\n display: none;\n pointer-events: none;\n}";
|
|
296
313
|
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
__classPrivateFieldGet(this, _Menu_instances, "m", _Menu_setupAnchor).call(this, __classPrivateFieldGet(this, _Menu_anchorEl, "f"));
|
|
310
|
-
__classPrivateFieldGet(this, _Menu_observer, "f").disconnect();
|
|
311
|
-
__classPrivateFieldSet(this, _Menu_observer, undefined, "f");
|
|
312
|
-
}
|
|
313
|
-
}), "f");
|
|
314
|
-
__classPrivateFieldGet(this, _Menu_observer, "f").observe(document.body, {
|
|
315
|
-
childList: true,
|
|
316
|
-
subtree: true
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
this.placement = 'bottom';
|
|
320
|
-
this.anchor = '';
|
|
321
|
-
this.autoDismiss = false;
|
|
322
|
-
this.open = false;
|
|
323
|
-
_Menu_openIfClosed.set(this, () => {
|
|
324
|
-
if (!this.open) DOM.queueUpdate(() => this.open = true);
|
|
325
|
-
});
|
|
326
|
-
_Menu_closeOnClickOutside.set(this, e => {
|
|
327
|
-
if (!this.contains(e.target)) this.open = false;
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
anchorChanged(_, newValue) {
|
|
331
|
-
var _a;
|
|
332
|
-
if (__classPrivateFieldGet(this, _Menu_anchorEl, "f")) __classPrivateFieldGet(this, _Menu_instances, "m", _Menu_cleanupAnchor).call(this, __classPrivateFieldGet(this, _Menu_anchorEl, "f"));
|
|
333
|
-
(_a = __classPrivateFieldGet(this, _Menu_observer, "f")) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
334
|
-
__classPrivateFieldSet(this, _Menu_anchorEl, newValue instanceof HTMLElement ? newValue : document.getElementById(newValue), "f");
|
|
335
|
-
if (__classPrivateFieldGet(this, _Menu_anchorEl, "f")) {
|
|
336
|
-
__classPrivateFieldGet(this, _Menu_instances, "m", _Menu_setupAnchor).call(this, __classPrivateFieldGet(this, _Menu_anchorEl, "f"));
|
|
337
|
-
} else {
|
|
338
|
-
__classPrivateFieldGet(this, _Menu_observeMissingAnchor, "f").call(this, newValue);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
autoDismissChanged(oldValue, newValue) {
|
|
342
|
-
if (oldValue === undefined) return;
|
|
343
|
-
if (newValue) {
|
|
344
|
-
document.addEventListener('click', __classPrivateFieldGet(this, _Menu_closeOnClickOutside, "f"));
|
|
345
|
-
} else {
|
|
346
|
-
document.removeEventListener('click', __classPrivateFieldGet(this, _Menu_closeOnClickOutside, "f"));
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
openChanged(_, newValue) {
|
|
350
|
-
newValue ? this.$emit('open', undefined, {
|
|
351
|
-
bubbles: false
|
|
352
|
-
}) : this.$emit('close', undefined, {
|
|
353
|
-
bubbles: false
|
|
354
|
-
});
|
|
355
|
-
if (__classPrivateFieldGet(this, _Menu_anchorEl, "f")) {
|
|
356
|
-
__classPrivateFieldGet(this, _Menu_anchorEl, "f").ariaExpanded = this.open.toString();
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
disconnectedCallback() {
|
|
360
|
-
var _a;
|
|
361
|
-
super.disconnectedCallback();
|
|
362
|
-
if (__classPrivateFieldGet(this, _Menu_anchorEl, "f")) __classPrivateFieldGet(this, _Menu_instances, "m", _Menu_cleanupAnchor).call(this, __classPrivateFieldGet(this, _Menu_anchorEl, "f"));
|
|
363
|
-
(_a = __classPrivateFieldGet(this, _Menu_observer, "f")) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
364
|
-
document.removeEventListener('click', __classPrivateFieldGet(this, _Menu_closeOnClickOutside, "f"));
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
_Menu_observer = new WeakMap(), _Menu_anchorEl = new WeakMap(), _Menu_observeMissingAnchor = new WeakMap(), _Menu_openIfClosed = new WeakMap(), _Menu_closeOnClickOutside = new WeakMap(), _Menu_instances = new WeakSet(), _Menu_setupAnchor = function _Menu_setupAnchor(a) {
|
|
368
|
-
a.addEventListener('click', __classPrivateFieldGet(this, _Menu_openIfClosed, "f"), true);
|
|
369
|
-
a.setAttribute('aria-haspopup', 'menu');
|
|
370
|
-
}, _Menu_cleanupAnchor = function _Menu_cleanupAnchor(a) {
|
|
371
|
-
a.removeEventListener('click', __classPrivateFieldGet(this, _Menu_openIfClosed, "f"), true);
|
|
372
|
-
a.removeAttribute('aria-hasPopup');
|
|
314
|
+
var __defProp = Object.defineProperty;
|
|
315
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
316
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
317
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
318
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
319
|
+
if (decorator = decorators[i])
|
|
320
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
321
|
+
if (kind && result)
|
|
322
|
+
__defProp(target, key, result);
|
|
323
|
+
return result;
|
|
324
|
+
};
|
|
325
|
+
let NumberField = class extends NumberField$1 {
|
|
373
326
|
};
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
__decorate([observable, __metadata("design:type", Array)], Menu.prototype, "headerSlottedContent", void 0);
|
|
388
|
-
__decorate([observable, __metadata("design:type", Array)], Menu.prototype, "actionItemsSlottedContent", void 0);
|
|
327
|
+
__decorateClass([
|
|
328
|
+
attr
|
|
329
|
+
], NumberField.prototype, "appearance", 2);
|
|
330
|
+
__decorateClass([
|
|
331
|
+
attr
|
|
332
|
+
], NumberField.prototype, "shape", 2);
|
|
333
|
+
__decorateClass([
|
|
334
|
+
attr
|
|
335
|
+
], NumberField.prototype, "autoComplete", 2);
|
|
336
|
+
NumberField = __decorateClass([
|
|
337
|
+
formElements
|
|
338
|
+
], NumberField);
|
|
339
|
+
applyMixins(NumberField, AffixIcon, FormElementCharCount, FormElementHelperText, FormElementSuccessText);
|
|
389
340
|
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
341
|
+
const ADD = 1;
|
|
342
|
+
const SUBTRACT = -1;
|
|
343
|
+
const getStateClasses = ({
|
|
344
|
+
errorValidationMessage,
|
|
345
|
+
disabled,
|
|
346
|
+
value,
|
|
347
|
+
readOnly,
|
|
348
|
+
placeholder,
|
|
349
|
+
appearance,
|
|
350
|
+
shape,
|
|
351
|
+
label,
|
|
352
|
+
successText
|
|
353
|
+
}) => classNames(
|
|
354
|
+
["error connotation-alert", Boolean(errorValidationMessage)],
|
|
355
|
+
["disabled", disabled],
|
|
356
|
+
["has-value", Boolean(value)],
|
|
357
|
+
["readonly", readOnly],
|
|
358
|
+
["placeholder", Boolean(placeholder)],
|
|
359
|
+
[`appearance-${appearance}`, Boolean(appearance)],
|
|
360
|
+
[`shape-${shape}`, Boolean(shape)],
|
|
361
|
+
["no-label", !label],
|
|
362
|
+
["success connotation-success", !!successText]
|
|
363
|
+
);
|
|
364
|
+
function renderLabel() {
|
|
399
365
|
return html`
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
366
|
+
<label for="control" class="label">
|
|
367
|
+
${(x) => x.label}
|
|
368
|
+
</label>`;
|
|
369
|
+
}
|
|
370
|
+
function adjustValueByStep(numberField, direction = ADD) {
|
|
371
|
+
numberField.value = (Number(numberField.value) + direction * (numberField.step ? numberField.step : 1)).toString();
|
|
372
|
+
}
|
|
373
|
+
function setControlButtonShape(numberField) {
|
|
374
|
+
return numberField.shape === Shape.Pill ? Shape.Pill : null;
|
|
375
|
+
}
|
|
376
|
+
function getTabIndex(numberField) {
|
|
377
|
+
return numberField.disabled || numberField.readOnly ? "-1" : null;
|
|
378
|
+
}
|
|
379
|
+
function numberControlButtons(context) {
|
|
380
|
+
const buttonTag = context.tagFor(Button);
|
|
381
|
+
const dividerTag = context.tagFor(Divider);
|
|
382
|
+
return html`
|
|
383
|
+
<div class="control-buttons"
|
|
384
|
+
?inert="${(x) => x.disabled || x.readOnly}">
|
|
385
|
+
<${buttonTag} id="subtract" icon="minus-line"
|
|
386
|
+
aria-controls="control"
|
|
387
|
+
shape="${setControlButtonShape}"
|
|
388
|
+
size="condensed"
|
|
389
|
+
tabindex="${getTabIndex}"
|
|
390
|
+
@click="${(x) => adjustValueByStep(x, SUBTRACT)}"></${buttonTag}>
|
|
391
|
+
<${dividerTag} class="divider" orientation="vertical"></${dividerTag}>
|
|
392
|
+
<${buttonTag} id="add" icon="plus-line"
|
|
393
|
+
aria-controls="control"
|
|
394
|
+
shape="${setControlButtonShape}"
|
|
395
|
+
size="condensed"
|
|
396
|
+
tabindex="${getTabIndex}"
|
|
397
|
+
@click="${(x) => adjustValueByStep(x)}"></${buttonTag}>
|
|
398
|
+
</div>
|
|
399
|
+
`;
|
|
400
|
+
}
|
|
401
|
+
const NumberFieldTemplate = (context) => {
|
|
402
|
+
const focusTemplate = focusTemplateFactory(context);
|
|
403
|
+
return html`
|
|
404
|
+
<div class="base ${getStateClasses}">
|
|
405
|
+
${when((x) => x.label, renderLabel())}
|
|
406
|
+
<div class="fieldset">
|
|
407
|
+
<div class="wrapper">
|
|
408
|
+
<input class="control"
|
|
409
|
+
id="control"
|
|
410
|
+
@input="${(x) => x.handleTextInput()}"
|
|
411
|
+
@change="${(x) => x.handleChange()}"
|
|
412
|
+
?autofocus="${(x) => x.autofocus}"
|
|
413
|
+
?disabled="${(x) => x.disabled}"
|
|
414
|
+
list="${(x) => x.list}"
|
|
415
|
+
step="${(x) => x.step ? x.step : null}"
|
|
416
|
+
max="${(x) => x.max}"
|
|
417
|
+
min="${(x) => x.min}"
|
|
418
|
+
maxlength="${(x) => x.maxlength}"
|
|
419
|
+
minlength="${(x) => x.minlength}"
|
|
420
|
+
placeholder="${(x) => x.placeholder}"
|
|
421
|
+
?readonly="${(x) => x.readOnly}"
|
|
422
|
+
?required="${(x) => x.required}"
|
|
423
|
+
size="${(x) => x.size}"
|
|
424
|
+
autocomplete="${(x) => x.autoComplete}"
|
|
425
|
+
name="${(x) => x.name}"
|
|
426
|
+
?spellcheck="${(x) => x.spellcheck}"
|
|
427
|
+
:value="${(x) => x.value}"
|
|
428
|
+
type="text"
|
|
429
|
+
aria-atomic="${(x) => x.ariaAtomic}"
|
|
430
|
+
aria-busy="${(x) => x.ariaBusy}"
|
|
431
|
+
aria-controls="${(x) => x.ariaControls}"
|
|
432
|
+
aria-current="${(x) => x.ariaCurrent}"
|
|
433
|
+
aria-describedby="${(x) => x.ariaDescribedby}"
|
|
434
|
+
aria-details="${(x) => x.ariaDetails}"
|
|
435
|
+
aria-disabled="${(x) => x.ariaDisabled}"
|
|
436
|
+
aria-errormessage="${(x) => x.ariaErrormessage}"
|
|
437
|
+
aria-flowto="${(x) => x.ariaFlowto}"
|
|
438
|
+
aria-haspopup="${(x) => x.ariaHaspopup}"
|
|
439
|
+
aria-hidden="${(x) => x.ariaHidden}"
|
|
440
|
+
aria-invalid="${(x) => x.ariaInvalid}"
|
|
441
|
+
aria-keyshortcuts="${(x) => x.ariaKeyshortcuts}"
|
|
442
|
+
aria-label="${(x) => x.ariaLabel}"
|
|
443
|
+
aria-labelledby="${(x) => x.ariaLabelledby}"
|
|
444
|
+
aria-live="${(x) => x.ariaLive}"
|
|
445
|
+
aria-owns="${(x) => x.ariaOwns}"
|
|
446
|
+
aria-relevant="${(x) => x.ariaRelevant}"
|
|
447
|
+
aria-roledescription="${(x) => x.ariaRoledescription}"
|
|
448
|
+
${ref("control")}
|
|
449
|
+
/>
|
|
450
|
+
${() => focusTemplate}
|
|
421
451
|
</div>
|
|
422
|
-
|
|
423
|
-
|
|
452
|
+
${() => numberControlButtons(context)}
|
|
453
|
+
</div>
|
|
454
|
+
${when((x) => !x.successText && !x.errorValidationMessage && x.helperText?.length, getFeedbackTemplate("helper", context))}
|
|
455
|
+
${when((x) => !x.successText && x.errorValidationMessage, getFeedbackTemplate("error", context))}
|
|
456
|
+
${when((x) => x.successText, getFeedbackTemplate("success", context))}
|
|
457
|
+
</div>
|
|
458
|
+
`;
|
|
424
459
|
};
|
|
425
460
|
|
|
426
|
-
const
|
|
427
|
-
baseName:
|
|
428
|
-
template:
|
|
429
|
-
styles
|
|
461
|
+
const numberFieldDefinition = NumberField.compose({
|
|
462
|
+
baseName: "number-field",
|
|
463
|
+
template: NumberFieldTemplate,
|
|
464
|
+
styles,
|
|
465
|
+
shadowOptions: {
|
|
466
|
+
delegatesFocus: true
|
|
467
|
+
}
|
|
430
468
|
});
|
|
431
|
-
const
|
|
432
|
-
const
|
|
469
|
+
const numberFieldRegistries = [numberFieldDefinition(), ...buttonRegistries, ...dividerRegistries];
|
|
470
|
+
const registerNumberField = registerFactory(numberFieldRegistries);
|
|
433
471
|
|
|
434
|
-
export {
|
|
472
|
+
export { numberFieldRegistries as a, numberFieldDefinition as n, registerNumberField as r };
|