@vonage/vivid 3.0.0-next.11 → 3.0.0-next.110
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/README.md +165 -4
- package/accordion/index.js +5 -14
- package/accordion-item/index.js +34 -41
- package/action-group/index.js +37 -0
- package/avatar/index.js +61 -0
- package/badge/index.js +23 -35
- package/banner/index.js +20 -115
- package/breadcrumb/index.js +22 -19
- package/breadcrumb-item/index.js +28 -25
- package/button/index.js +29 -690
- package/calendar/index.js +70 -69
- package/calendar-event/index.js +109 -0
- package/card/index.js +112 -0
- package/checkbox/index.js +178 -0
- package/custom-elements.json +3941 -0
- package/dialog/index.js +214 -0
- package/divider/index.js +27 -0
- package/elevation/index.js +10 -16
- package/fab/index.js +98 -0
- package/focus/index.js +18 -3
- package/header/index.js +63 -0
- package/icon/index.js +9 -12
- package/index.js +68 -22
- package/layout/index.js +6 -16
- package/lib/accordion-item/accordion-item.d.ts +2 -2
- package/lib/accordion-item/index.d.ts +0 -1
- package/lib/action-group/action-group.d.ts +10 -0
- package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
- package/lib/{sidenav-item → action-group}/index.d.ts +1 -2
- package/lib/avatar/avatar.d.ts +15 -0
- package/lib/avatar/avatar.template.d.ts +4 -0
- package/lib/avatar/index.d.ts +2 -0
- package/lib/badge/badge.d.ts +3 -5
- package/lib/badge/index.d.ts +1 -2
- package/lib/banner/banner.d.ts +1 -1
- package/lib/banner/banner.template.d.ts +0 -2
- package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
- package/lib/breadcrumb-item/index.d.ts +0 -1
- package/lib/button/button.d.ts +4 -3
- package/lib/button/index.d.ts +1 -21
- package/lib/calendar/calendar.d.ts +3 -1
- package/lib/calendar/index.d.ts +0 -1
- package/lib/calendar-event/calendar-event.d.ts +14 -0
- package/lib/calendar-event/calendar-event.template.d.ts +4 -0
- package/lib/calendar-event/index.d.ts +2 -0
- package/lib/card/card.d.ts +10 -0
- package/lib/{text/text.template.d.ts → card/card.template.d.ts} +2 -2
- package/lib/{text → card}/index.d.ts +1 -1
- package/lib/checkbox/checkbox.d.ts +5 -0
- package/lib/checkbox/checkbox.template.d.ts +4 -0
- package/lib/checkbox/index.d.ts +2 -0
- package/lib/components.d.ts +32 -10
- package/lib/dialog/dialog.d.ts +20 -0
- package/lib/dialog/dialog.template.d.ts +4 -0
- package/lib/dialog/index.d.ts +2 -0
- package/lib/divider/divider.d.ts +3 -0
- package/lib/divider/divider.template.d.ts +4 -0
- package/lib/divider/index.d.ts +2 -0
- package/lib/elevation/elevation.d.ts +1 -0
- package/lib/elevation/index.d.ts +1 -1
- package/lib/enums.d.ts +19 -6
- package/lib/fab/fab.d.ts +13 -0
- package/lib/fab/fab.template.d.ts +4 -0
- package/lib/fab/index.d.ts +2 -0
- package/lib/focus/index.d.ts +1 -1
- package/lib/header/header.d.ts +5 -0
- package/lib/header/header.template.d.ts +4 -0
- package/lib/header/index.d.ts +2 -0
- package/lib/icon/icon.d.ts +5 -6
- package/lib/layout/index.d.ts +1 -1
- package/lib/layout/layout.d.ts +4 -4
- package/lib/listbox/index.d.ts +1 -0
- package/lib/listbox/listbox.d.ts +9 -0
- package/lib/listbox/listbox.template.d.ts +4 -0
- package/lib/menu/index.d.ts +10 -0
- package/lib/menu/menu.d.ts +10 -0
- package/lib/menu/menu.template.d.ts +3 -0
- package/lib/menu-item/index.d.ts +2 -0
- package/lib/menu-item/menu-item.d.ts +7 -0
- package/lib/menu-item/menu-item.template.d.ts +5 -0
- package/lib/nav/index.d.ts +2 -0
- package/lib/nav/nav.d.ts +3 -0
- package/lib/nav/nav.template.d.ts +4 -0
- package/lib/nav-disclosure/index.d.ts +2 -0
- package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
- package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
- package/lib/nav-item/index.d.ts +2 -0
- package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
- package/lib/nav-item/nav-item.template.d.ts +4 -0
- package/lib/note/index.d.ts +2 -0
- package/lib/note/note.d.ts +10 -0
- package/lib/note/note.template.d.ts +4 -0
- package/lib/number-field/index.d.ts +2 -0
- package/lib/number-field/number-field.d.ts +14 -0
- package/lib/number-field/number-field.template.d.ts +4 -0
- package/lib/option/index.d.ts +2 -0
- package/lib/option/option.d.ts +9 -0
- package/lib/option/option.template.d.ts +4 -0
- package/lib/popup/index.d.ts +1 -3
- package/lib/popup/popup.d.ts +3 -2
- package/lib/progress/progress.d.ts +1 -1
- package/lib/progress-ring/progress-ring.d.ts +2 -1
- package/lib/radio/index.d.ts +2 -0
- package/lib/radio/radio.d.ts +4 -0
- package/lib/radio/radio.template.d.ts +4 -0
- package/lib/radio-group/index.d.ts +10 -0
- package/lib/radio-group/radio-group.d.ts +4 -0
- package/lib/radio-group/radio-group.template.d.ts +4 -0
- package/lib/side-drawer/index.d.ts +1 -1
- package/lib/side-drawer/side-drawer.d.ts +3 -2
- package/lib/slider/index.d.ts +2 -0
- package/lib/slider/slider.d.ts +4 -0
- package/lib/slider/slider.template.d.ts +4 -0
- package/lib/switch/index.d.ts +2 -0
- package/lib/switch/switch.d.ts +7 -0
- package/lib/switch/switch.template.d.ts +4 -0
- package/lib/text-anchor/text-anchor.d.ts +1 -1
- package/lib/text-area/index.d.ts +2 -0
- package/lib/text-area/text-area.d.ts +9 -0
- package/lib/text-area/text-area.template.d.ts +4 -0
- package/lib/text-field/index.d.ts +2 -0
- package/lib/text-field/text-field.d.ts +14 -0
- package/lib/text-field/text-field.template.d.ts +4 -0
- package/lib/tooltip/index.d.ts +0 -1
- package/lib/tooltip/tooltip.d.ts +7 -7
- package/listbox/index.js +1086 -0
- package/menu/index.js +357 -0
- package/menu-item/index.js +90 -0
- package/nav/index.js +17 -0
- package/nav-disclosure/index.js +80 -0
- package/nav-item/index.js +44 -0
- package/note/index.js +59 -0
- package/number-field/index.js +460 -0
- package/option/index.js +75 -0
- package/package.json +62 -10
- package/popup/index.js +35 -2036
- package/progress/index.js +33 -38
- package/progress-ring/index.js +13 -13
- package/radio/index.js +52 -0
- package/radio-group/index.js +435 -0
- package/shared/affix.js +2 -8
- package/shared/anchor.js +11 -3
- package/shared/apply-mixins.js +5 -4
- package/shared/aria-global.js +2 -86
- package/shared/aria.js +9 -0
- package/shared/base-progress.js +6 -1
- package/shared/breadcrumb-item.js +2 -2
- package/shared/button.js +23 -0
- package/shared/button2.js +200 -0
- package/shared/calendar-event.js +19 -0
- package/shared/design-system/index.d.ts +1 -1
- package/shared/dialog-polyfill.esm.js +858 -0
- package/shared/direction.js +20 -0
- package/shared/divider.js +55 -0
- package/shared/dom.js +8 -0
- package/shared/elevation.js +10 -0
- package/shared/enums.js +70 -0
- package/shared/es.object.assign.js +2 -59
- package/shared/es.promise.resolve.js +944 -0
- package/shared/es.regexp.to-string.js +58 -0
- package/shared/focus.js +11 -0
- package/shared/focus2.js +5 -0
- package/shared/form-associated.js +466 -0
- package/shared/form-elements.js +343 -0
- package/shared/icon.js +32 -1153
- package/shared/index.js +3780 -83
- package/shared/index2.js +7 -19
- package/shared/key-codes.js +97 -0
- package/shared/listbox-option.js +201 -0
- package/shared/menu-item.js +277 -0
- package/shared/numbers.js +25 -0
- package/shared/patterns/focus.d.ts +3 -0
- package/shared/patterns/form-elements/form-elements.d.ts +31 -0
- package/shared/patterns/form-elements/index.d.ts +1 -0
- package/shared/patterns/index.d.ts +2 -0
- package/shared/popup.js +1484 -0
- package/shared/radio.js +127 -0
- package/shared/ref.js +41 -0
- package/shared/slotted.js +1 -1
- package/shared/start-end.js +50 -0
- package/shared/string-trim.js +39 -0
- package/shared/text-anchor.js +2 -13
- package/shared/text-anchor.template.js +6 -5
- package/shared/utils/index.d.ts +1 -0
- package/side-drawer/index.js +38 -34
- package/slider/index.js +596 -0
- package/styles/core/all.css +86 -0
- package/styles/core/theme.css +11 -0
- package/styles/core/typography.css +80 -0
- package/styles/fonts/SpeziaCompleteVariableItalicWeb.woff2 +0 -0
- package/styles/fonts/SpeziaCompleteVariableUprightWeb.woff2 +0 -0
- package/styles/fonts/SpeziaMonoCompleteVariableWeb.woff2 +0 -0
- package/styles/fonts/spezia.css +9 -12
- package/styles/tokens/theme-dark.css +230 -0
- package/styles/tokens/theme-light.css +230 -0
- package/switch/index.js +153 -0
- package/text-anchor/index.js +8 -3
- package/text-area/index.js +288 -0
- package/text-field/index.js +129 -0
- package/tooltip/index.js +59 -43
- package/vivid.api.json +2979 -0
- package/lib/text/text.d.ts +0 -10
- package/shared/style-inject.es.js +0 -28
- package/shared/web.dom-collections.iterator.js +0 -1479
- package/sidenav-item/index.js +0 -38
- package/styles/themes/dark.css +0 -205
- package/styles/themes/light.css +0 -205
- package/text/index.js +0 -45
package/shared/index2.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import './es.promise.resolve.js';
|
|
2
|
+
import './index.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const loadComponentsModules = (components, prefix) => {
|
|
5
|
+
components.forEach(component => import(`../${component}/index.js?prefix=${prefix}`));
|
|
6
|
+
return Promise.all(components.map(component => customElements.whenDefined(`${prefix}-${component}`)));
|
|
7
|
+
};
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
styleInject(css_248z);
|
|
8
|
-
|
|
9
|
-
let _ = t => t,
|
|
10
|
-
_t;
|
|
11
|
-
const focusTemplate = () => html(_t || (_t = _`
|
|
12
|
-
<span class="control"></span>`));
|
|
13
|
-
|
|
14
|
-
const VIVIDFocus = Focus.compose({
|
|
15
|
-
baseName: 'focus',
|
|
16
|
-
template: focusTemplate,
|
|
17
|
-
styles: css_248z
|
|
18
|
-
});
|
|
19
|
-
designSystem.register(VIVIDFocus());
|
|
20
|
-
|
|
21
|
-
export { Focus as F, VIVIDFocus as V };
|
|
9
|
+
export { loadComponentsModules as l };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key Code values
|
|
3
|
+
* @deprecated - KeyCodes are deprecated, use individual string key exports
|
|
4
|
+
*/
|
|
5
|
+
var KeyCodes;
|
|
6
|
+
(function (KeyCodes) {
|
|
7
|
+
KeyCodes[KeyCodes["alt"] = 18] = "alt";
|
|
8
|
+
KeyCodes[KeyCodes["arrowDown"] = 40] = "arrowDown";
|
|
9
|
+
KeyCodes[KeyCodes["arrowLeft"] = 37] = "arrowLeft";
|
|
10
|
+
KeyCodes[KeyCodes["arrowRight"] = 39] = "arrowRight";
|
|
11
|
+
KeyCodes[KeyCodes["arrowUp"] = 38] = "arrowUp";
|
|
12
|
+
KeyCodes[KeyCodes["back"] = 8] = "back";
|
|
13
|
+
KeyCodes[KeyCodes["backSlash"] = 220] = "backSlash";
|
|
14
|
+
KeyCodes[KeyCodes["break"] = 19] = "break";
|
|
15
|
+
KeyCodes[KeyCodes["capsLock"] = 20] = "capsLock";
|
|
16
|
+
KeyCodes[KeyCodes["closeBracket"] = 221] = "closeBracket";
|
|
17
|
+
KeyCodes[KeyCodes["colon"] = 186] = "colon";
|
|
18
|
+
KeyCodes[KeyCodes["colon2"] = 59] = "colon2";
|
|
19
|
+
KeyCodes[KeyCodes["comma"] = 188] = "comma";
|
|
20
|
+
KeyCodes[KeyCodes["ctrl"] = 17] = "ctrl";
|
|
21
|
+
KeyCodes[KeyCodes["delete"] = 46] = "delete";
|
|
22
|
+
KeyCodes[KeyCodes["end"] = 35] = "end";
|
|
23
|
+
KeyCodes[KeyCodes["enter"] = 13] = "enter";
|
|
24
|
+
KeyCodes[KeyCodes["equals"] = 187] = "equals";
|
|
25
|
+
KeyCodes[KeyCodes["equals2"] = 61] = "equals2";
|
|
26
|
+
KeyCodes[KeyCodes["equals3"] = 107] = "equals3";
|
|
27
|
+
KeyCodes[KeyCodes["escape"] = 27] = "escape";
|
|
28
|
+
KeyCodes[KeyCodes["forwardSlash"] = 191] = "forwardSlash";
|
|
29
|
+
KeyCodes[KeyCodes["function1"] = 112] = "function1";
|
|
30
|
+
KeyCodes[KeyCodes["function10"] = 121] = "function10";
|
|
31
|
+
KeyCodes[KeyCodes["function11"] = 122] = "function11";
|
|
32
|
+
KeyCodes[KeyCodes["function12"] = 123] = "function12";
|
|
33
|
+
KeyCodes[KeyCodes["function2"] = 113] = "function2";
|
|
34
|
+
KeyCodes[KeyCodes["function3"] = 114] = "function3";
|
|
35
|
+
KeyCodes[KeyCodes["function4"] = 115] = "function4";
|
|
36
|
+
KeyCodes[KeyCodes["function5"] = 116] = "function5";
|
|
37
|
+
KeyCodes[KeyCodes["function6"] = 117] = "function6";
|
|
38
|
+
KeyCodes[KeyCodes["function7"] = 118] = "function7";
|
|
39
|
+
KeyCodes[KeyCodes["function8"] = 119] = "function8";
|
|
40
|
+
KeyCodes[KeyCodes["function9"] = 120] = "function9";
|
|
41
|
+
KeyCodes[KeyCodes["home"] = 36] = "home";
|
|
42
|
+
KeyCodes[KeyCodes["insert"] = 45] = "insert";
|
|
43
|
+
KeyCodes[KeyCodes["menu"] = 93] = "menu";
|
|
44
|
+
KeyCodes[KeyCodes["minus"] = 189] = "minus";
|
|
45
|
+
KeyCodes[KeyCodes["minus2"] = 109] = "minus2";
|
|
46
|
+
KeyCodes[KeyCodes["numLock"] = 144] = "numLock";
|
|
47
|
+
KeyCodes[KeyCodes["numPad0"] = 96] = "numPad0";
|
|
48
|
+
KeyCodes[KeyCodes["numPad1"] = 97] = "numPad1";
|
|
49
|
+
KeyCodes[KeyCodes["numPad2"] = 98] = "numPad2";
|
|
50
|
+
KeyCodes[KeyCodes["numPad3"] = 99] = "numPad3";
|
|
51
|
+
KeyCodes[KeyCodes["numPad4"] = 100] = "numPad4";
|
|
52
|
+
KeyCodes[KeyCodes["numPad5"] = 101] = "numPad5";
|
|
53
|
+
KeyCodes[KeyCodes["numPad6"] = 102] = "numPad6";
|
|
54
|
+
KeyCodes[KeyCodes["numPad7"] = 103] = "numPad7";
|
|
55
|
+
KeyCodes[KeyCodes["numPad8"] = 104] = "numPad8";
|
|
56
|
+
KeyCodes[KeyCodes["numPad9"] = 105] = "numPad9";
|
|
57
|
+
KeyCodes[KeyCodes["numPadDivide"] = 111] = "numPadDivide";
|
|
58
|
+
KeyCodes[KeyCodes["numPadDot"] = 110] = "numPadDot";
|
|
59
|
+
KeyCodes[KeyCodes["numPadMinus"] = 109] = "numPadMinus";
|
|
60
|
+
KeyCodes[KeyCodes["numPadMultiply"] = 106] = "numPadMultiply";
|
|
61
|
+
KeyCodes[KeyCodes["numPadPlus"] = 107] = "numPadPlus";
|
|
62
|
+
KeyCodes[KeyCodes["openBracket"] = 219] = "openBracket";
|
|
63
|
+
KeyCodes[KeyCodes["pageDown"] = 34] = "pageDown";
|
|
64
|
+
KeyCodes[KeyCodes["pageUp"] = 33] = "pageUp";
|
|
65
|
+
KeyCodes[KeyCodes["period"] = 190] = "period";
|
|
66
|
+
KeyCodes[KeyCodes["print"] = 44] = "print";
|
|
67
|
+
KeyCodes[KeyCodes["quote"] = 222] = "quote";
|
|
68
|
+
KeyCodes[KeyCodes["scrollLock"] = 145] = "scrollLock";
|
|
69
|
+
KeyCodes[KeyCodes["shift"] = 16] = "shift";
|
|
70
|
+
KeyCodes[KeyCodes["space"] = 32] = "space";
|
|
71
|
+
KeyCodes[KeyCodes["tab"] = 9] = "tab";
|
|
72
|
+
KeyCodes[KeyCodes["tilde"] = 192] = "tilde";
|
|
73
|
+
KeyCodes[KeyCodes["windowsLeft"] = 91] = "windowsLeft";
|
|
74
|
+
KeyCodes[KeyCodes["windowsOpera"] = 219] = "windowsOpera";
|
|
75
|
+
KeyCodes[KeyCodes["windowsRight"] = 92] = "windowsRight";
|
|
76
|
+
})(KeyCodes || (KeyCodes = {}));
|
|
77
|
+
/**
|
|
78
|
+
* String values for use with KeyboardEvent.key
|
|
79
|
+
*/
|
|
80
|
+
const keyArrowDown = "ArrowDown";
|
|
81
|
+
const keyArrowLeft = "ArrowLeft";
|
|
82
|
+
const keyArrowRight = "ArrowRight";
|
|
83
|
+
const keyArrowUp = "ArrowUp";
|
|
84
|
+
const keyEnter = "Enter";
|
|
85
|
+
const keyEscape = "Escape";
|
|
86
|
+
const keyHome = "Home";
|
|
87
|
+
const keyEnd = "End";
|
|
88
|
+
const keySpace = " ";
|
|
89
|
+
const keyTab = "Tab";
|
|
90
|
+
const ArrowKeys = {
|
|
91
|
+
ArrowDown: keyArrowDown,
|
|
92
|
+
ArrowLeft: keyArrowLeft,
|
|
93
|
+
ArrowRight: keyArrowRight,
|
|
94
|
+
ArrowUp: keyArrowUp,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export { ArrowKeys as A, keySpace as a, keyEscape as b, keyTab as c, keyEnd as d, keyArrowUp as e, keyArrowDown as f, keyHome as g, keyArrowLeft as h, keyArrowRight as i, keyEnter as k };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { F as FoundationElement, Z as Observable, _ as __decorate, V as observable, a as attr } from './index.js';
|
|
2
|
+
import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
|
|
3
|
+
import { S as StartEnd } from './start-end.js';
|
|
4
|
+
import { a as applyMixins } from './apply-mixins.js';
|
|
5
|
+
import { i as isHTMLElement } from './dom.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Determines if the element is a {@link (ListboxOption:class)}
|
|
9
|
+
*
|
|
10
|
+
* @param element - the element to test.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
function isListboxOption(el) {
|
|
14
|
+
return (isHTMLElement(el) &&
|
|
15
|
+
(el.getAttribute("role") === "option" ||
|
|
16
|
+
el instanceof HTMLOptionElement));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* An Option Custom HTML Element.
|
|
20
|
+
* Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
|
|
21
|
+
*
|
|
22
|
+
* @slot start - Content which can be provided before the listbox option content
|
|
23
|
+
* @slot end - Content which can be provided after the listbox option content
|
|
24
|
+
* @slot - The default slot for listbox option content
|
|
25
|
+
* @csspart content - Wraps the listbox option content
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
class ListboxOption extends FoundationElement {
|
|
30
|
+
constructor(text, value, defaultSelected, selected) {
|
|
31
|
+
super();
|
|
32
|
+
/**
|
|
33
|
+
* The defaultSelected state of the option.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
this.defaultSelected = false;
|
|
37
|
+
/**
|
|
38
|
+
* Tracks whether the "selected" property has been changed.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
this.dirtySelected = false;
|
|
42
|
+
/**
|
|
43
|
+
* The checked state of the control.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
this.selected = this.defaultSelected;
|
|
48
|
+
/**
|
|
49
|
+
* Track whether the value has been changed from the initial value
|
|
50
|
+
*/
|
|
51
|
+
this.dirtyValue = false;
|
|
52
|
+
if (text) {
|
|
53
|
+
this.textContent = text;
|
|
54
|
+
}
|
|
55
|
+
if (value) {
|
|
56
|
+
this.initialValue = value;
|
|
57
|
+
}
|
|
58
|
+
if (defaultSelected) {
|
|
59
|
+
this.defaultSelected = defaultSelected;
|
|
60
|
+
}
|
|
61
|
+
if (selected) {
|
|
62
|
+
this.selected = selected;
|
|
63
|
+
}
|
|
64
|
+
this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
|
|
65
|
+
this.proxy.disabled = this.disabled;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Updates the ariaChecked property when the checked property changes.
|
|
69
|
+
*
|
|
70
|
+
* @param prev - the previous checked value
|
|
71
|
+
* @param next - the current checked value
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
checkedChanged(prev, next) {
|
|
76
|
+
if (typeof next === "boolean") {
|
|
77
|
+
this.ariaChecked = next ? "true" : "false";
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.ariaChecked = null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Updates the proxy's text content when the default slot changes.
|
|
84
|
+
* @param prev - the previous content value
|
|
85
|
+
* @param next - the current content value
|
|
86
|
+
*
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
contentChanged(prev, next) {
|
|
90
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
91
|
+
this.proxy.textContent = this.textContent;
|
|
92
|
+
}
|
|
93
|
+
this.$emit("contentchange", null, { bubbles: true });
|
|
94
|
+
}
|
|
95
|
+
defaultSelectedChanged() {
|
|
96
|
+
if (!this.dirtySelected) {
|
|
97
|
+
this.selected = this.defaultSelected;
|
|
98
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
99
|
+
this.proxy.selected = this.defaultSelected;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
disabledChanged(prev, next) {
|
|
104
|
+
this.ariaDisabled = this.disabled ? "true" : "false";
|
|
105
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
106
|
+
this.proxy.disabled = this.disabled;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
selectedAttributeChanged() {
|
|
110
|
+
this.defaultSelected = this.selectedAttribute;
|
|
111
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
112
|
+
this.proxy.defaultSelected = this.defaultSelected;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
selectedChanged() {
|
|
116
|
+
this.ariaSelected = this.selected ? "true" : "false";
|
|
117
|
+
if (!this.dirtySelected) {
|
|
118
|
+
this.dirtySelected = true;
|
|
119
|
+
}
|
|
120
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
121
|
+
this.proxy.selected = this.selected;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
initialValueChanged(previous, next) {
|
|
125
|
+
// If the value is clean and the component is connected to the DOM
|
|
126
|
+
// then set value equal to the attribute value.
|
|
127
|
+
if (!this.dirtyValue) {
|
|
128
|
+
this.value = this.initialValue;
|
|
129
|
+
this.dirtyValue = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
get label() {
|
|
133
|
+
var _a;
|
|
134
|
+
return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
|
|
135
|
+
}
|
|
136
|
+
get text() {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
|
|
139
|
+
}
|
|
140
|
+
set value(next) {
|
|
141
|
+
const newValue = `${next !== null && next !== void 0 ? next : ""}`;
|
|
142
|
+
this._value = newValue;
|
|
143
|
+
this.dirtyValue = true;
|
|
144
|
+
if (this.proxy instanceof HTMLOptionElement) {
|
|
145
|
+
this.proxy.value = newValue;
|
|
146
|
+
}
|
|
147
|
+
Observable.notify(this, "value");
|
|
148
|
+
}
|
|
149
|
+
get value() {
|
|
150
|
+
var _a;
|
|
151
|
+
Observable.track(this, "value");
|
|
152
|
+
return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
|
|
153
|
+
}
|
|
154
|
+
get form() {
|
|
155
|
+
return this.proxy ? this.proxy.form : null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
__decorate([
|
|
159
|
+
observable
|
|
160
|
+
], ListboxOption.prototype, "checked", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
observable
|
|
163
|
+
], ListboxOption.prototype, "content", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
observable
|
|
166
|
+
], ListboxOption.prototype, "defaultSelected", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
attr({ mode: "boolean" })
|
|
169
|
+
], ListboxOption.prototype, "disabled", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
attr({ attribute: "selected", mode: "boolean" })
|
|
172
|
+
], ListboxOption.prototype, "selectedAttribute", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
observable
|
|
175
|
+
], ListboxOption.prototype, "selected", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
attr({ attribute: "value", mode: "fromView" })
|
|
178
|
+
], ListboxOption.prototype, "initialValue", void 0);
|
|
179
|
+
/**
|
|
180
|
+
* States and properties relating to the ARIA `option` role.
|
|
181
|
+
*
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
class DelegatesARIAListboxOption {
|
|
185
|
+
}
|
|
186
|
+
__decorate([
|
|
187
|
+
observable
|
|
188
|
+
], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
observable
|
|
191
|
+
], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
observable
|
|
194
|
+
], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
observable
|
|
197
|
+
], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
|
|
198
|
+
applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
|
|
199
|
+
applyMixins(ListboxOption, StartEnd, DelegatesARIAListboxOption);
|
|
200
|
+
|
|
201
|
+
export { ListboxOption as L, isListboxOption as i };
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { F as FoundationElement, a2 as DOM, _ as __decorate, a as attr, V as observable } from './index.js';
|
|
2
|
+
import { S as StartEnd } from './start-end.js';
|
|
3
|
+
import { D as Direction, g as getDirection } from './direction.js';
|
|
4
|
+
import { a as applyMixins } from './apply-mixins.js';
|
|
5
|
+
import { h as keyArrowLeft, i as keyArrowRight, a as keySpace, k as keyEnter } from './key-codes.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Menu items roles.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
const MenuItemRole = {
|
|
12
|
+
/**
|
|
13
|
+
* The menu item has a "menuitem" role
|
|
14
|
+
*/
|
|
15
|
+
menuitem: "menuitem",
|
|
16
|
+
/**
|
|
17
|
+
* The menu item has a "menuitemcheckbox" role
|
|
18
|
+
*/
|
|
19
|
+
menuitemcheckbox: "menuitemcheckbox",
|
|
20
|
+
/**
|
|
21
|
+
* The menu item has a "menuitemradio" role
|
|
22
|
+
*/
|
|
23
|
+
menuitemradio: "menuitemradio",
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
const roleForMenuItem = {
|
|
29
|
+
[MenuItemRole.menuitem]: "menuitem",
|
|
30
|
+
[MenuItemRole.menuitemcheckbox]: "menuitemcheckbox",
|
|
31
|
+
[MenuItemRole.menuitemradio]: "menuitemradio",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A Switch Custom HTML Element.
|
|
36
|
+
* Implements {@link https://www.w3.org/TR/wai-aria-1.1/#menuitem | ARIA menuitem }, {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemcheckbox | ARIA menuitemcheckbox}, or {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemradio | ARIA menuitemradio }.
|
|
37
|
+
*
|
|
38
|
+
* @slot checked-indicator - The checked indicator
|
|
39
|
+
* @slot radio-indicator - The radio indicator
|
|
40
|
+
* @slot start - Content which can be provided before the menu item content
|
|
41
|
+
* @slot end - Content which can be provided after the menu item content
|
|
42
|
+
* @slot - The default slot for menu item content
|
|
43
|
+
* @slot expand-collapse-indicator - The expand/collapse indicator
|
|
44
|
+
* @slot submenu - Used to nest menu's within menu items
|
|
45
|
+
* @csspart input-container - The element representing the visual checked or radio indicator
|
|
46
|
+
* @csspart checkbox - The element wrapping the `menuitemcheckbox` indicator
|
|
47
|
+
* @csspart radio - The element wrapping the `menuitemradio` indicator
|
|
48
|
+
* @csspart content - The element wrapping the menu item content
|
|
49
|
+
* @csspart expand-collapse-glyph-container - The element wrapping the expand collapse element
|
|
50
|
+
* @csspart expand-collapse - The expand/collapse element
|
|
51
|
+
* @csspart submenu-region - The container for the submenu, used for positioning
|
|
52
|
+
* @fires expanded-change - Fires a custom 'expanded-change' event when the expanded state changes
|
|
53
|
+
* @fires change - Fires a custom 'change' event when a non-submenu item with a role of `menuitemcheckbox`, `menuitemradio`, or `menuitem` is invoked
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
class MenuItem extends FoundationElement {
|
|
58
|
+
constructor() {
|
|
59
|
+
super(...arguments);
|
|
60
|
+
/**
|
|
61
|
+
* The role of the element.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
* @remarks
|
|
65
|
+
* HTML Attribute: role
|
|
66
|
+
*/
|
|
67
|
+
this.role = MenuItemRole.menuitem;
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
this.hasSubmenu = false;
|
|
72
|
+
/**
|
|
73
|
+
* Track current direction to pass to the anchored region
|
|
74
|
+
*
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
this.currentDirection = Direction.ltr;
|
|
78
|
+
this.focusSubmenuOnLoad = false;
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
this.handleMenuItemKeyDown = (e) => {
|
|
83
|
+
if (e.defaultPrevented) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
switch (e.key) {
|
|
87
|
+
case keyEnter:
|
|
88
|
+
case keySpace:
|
|
89
|
+
this.invoke();
|
|
90
|
+
return false;
|
|
91
|
+
case keyArrowRight:
|
|
92
|
+
//open/focus on submenu
|
|
93
|
+
this.expandAndFocus();
|
|
94
|
+
return false;
|
|
95
|
+
case keyArrowLeft:
|
|
96
|
+
//close submenu
|
|
97
|
+
if (this.expanded) {
|
|
98
|
+
this.expanded = false;
|
|
99
|
+
this.focus();
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
this.handleMenuItemClick = (e) => {
|
|
109
|
+
if (e.defaultPrevented || this.disabled) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
this.invoke();
|
|
113
|
+
return false;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
this.submenuLoaded = () => {
|
|
119
|
+
if (!this.focusSubmenuOnLoad) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this.focusSubmenuOnLoad = false;
|
|
123
|
+
if (this.hasSubmenu) {
|
|
124
|
+
this.submenu.focus();
|
|
125
|
+
this.setAttribute("tabindex", "-1");
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
this.handleMouseOver = (e) => {
|
|
132
|
+
if (this.disabled || !this.hasSubmenu || this.expanded) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
this.expanded = true;
|
|
136
|
+
return false;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
this.handleMouseOut = (e) => {
|
|
142
|
+
if (!this.expanded || this.contains(document.activeElement)) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
this.expanded = false;
|
|
146
|
+
return false;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
this.expandAndFocus = () => {
|
|
152
|
+
if (!this.hasSubmenu) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.focusSubmenuOnLoad = true;
|
|
156
|
+
this.expanded = true;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
this.invoke = () => {
|
|
162
|
+
if (this.disabled) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
switch (this.role) {
|
|
166
|
+
case MenuItemRole.menuitemcheckbox:
|
|
167
|
+
this.checked = !this.checked;
|
|
168
|
+
break;
|
|
169
|
+
case MenuItemRole.menuitem:
|
|
170
|
+
// update submenu
|
|
171
|
+
this.updateSubmenu();
|
|
172
|
+
if (this.hasSubmenu) {
|
|
173
|
+
this.expandAndFocus();
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.$emit("change");
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
case MenuItemRole.menuitemradio:
|
|
180
|
+
if (!this.checked) {
|
|
181
|
+
this.checked = true;
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Gets the submenu element if any
|
|
188
|
+
*
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
this.updateSubmenu = () => {
|
|
192
|
+
this.submenu = this.domChildren().find((element) => {
|
|
193
|
+
return element.getAttribute("role") === "menu";
|
|
194
|
+
});
|
|
195
|
+
this.hasSubmenu = this.submenu === undefined ? false : true;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
expandedChanged(oldValue) {
|
|
199
|
+
if (this.$fastController.isConnected) {
|
|
200
|
+
if (this.submenu === undefined) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (this.expanded === false) {
|
|
204
|
+
this.submenu.collapseExpandedItem();
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
this.currentDirection = getDirection(this);
|
|
208
|
+
}
|
|
209
|
+
this.$emit("expanded-change", this, { bubbles: false });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
checkedChanged(oldValue, newValue) {
|
|
213
|
+
if (this.$fastController.isConnected) {
|
|
214
|
+
this.$emit("change");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
connectedCallback() {
|
|
221
|
+
super.connectedCallback();
|
|
222
|
+
DOM.queueUpdate(() => {
|
|
223
|
+
this.updateSubmenu();
|
|
224
|
+
});
|
|
225
|
+
if (!this.startColumnCount) {
|
|
226
|
+
this.startColumnCount = 1;
|
|
227
|
+
}
|
|
228
|
+
this.observer = new MutationObserver(this.updateSubmenu);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
233
|
+
disconnectedCallback() {
|
|
234
|
+
super.disconnectedCallback();
|
|
235
|
+
this.submenu = undefined;
|
|
236
|
+
if (this.observer !== undefined) {
|
|
237
|
+
this.observer.disconnect();
|
|
238
|
+
this.observer = undefined;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* get an array of valid DOM children
|
|
243
|
+
*/
|
|
244
|
+
domChildren() {
|
|
245
|
+
return Array.from(this.children).filter(child => !child.hasAttribute("hidden"));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
__decorate([
|
|
249
|
+
attr({ mode: "boolean" })
|
|
250
|
+
], MenuItem.prototype, "disabled", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
attr({ mode: "boolean" })
|
|
253
|
+
], MenuItem.prototype, "expanded", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
observable
|
|
256
|
+
], MenuItem.prototype, "startColumnCount", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
attr
|
|
259
|
+
], MenuItem.prototype, "role", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
attr({ mode: "boolean" })
|
|
262
|
+
], MenuItem.prototype, "checked", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
observable
|
|
265
|
+
], MenuItem.prototype, "submenuRegion", void 0);
|
|
266
|
+
__decorate([
|
|
267
|
+
observable
|
|
268
|
+
], MenuItem.prototype, "hasSubmenu", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
observable
|
|
271
|
+
], MenuItem.prototype, "currentDirection", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
observable
|
|
274
|
+
], MenuItem.prototype, "submenu", void 0);
|
|
275
|
+
applyMixins(MenuItem, StartEnd);
|
|
276
|
+
|
|
277
|
+
export { MenuItem as M, MenuItemRole as a, roleForMenuItem as r };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This method keeps a given value within the bounds of a min and max value. If the value
|
|
3
|
+
* is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
|
|
4
|
+
* the maximum will be returned. Otherwise, the value is returned un-changed.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
|
|
8
|
+
* If value is greater than max, max will be returned.
|
|
9
|
+
*/
|
|
10
|
+
function limit(min, max, value) {
|
|
11
|
+
return Math.min(Math.max(value, min), max);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Determines if a number value is within a specified range.
|
|
15
|
+
*
|
|
16
|
+
* @param value - the value to check
|
|
17
|
+
* @param min - the range start
|
|
18
|
+
* @param max - the range end
|
|
19
|
+
*/
|
|
20
|
+
function inRange(value, min, max = 0) {
|
|
21
|
+
[min, max] = [min, max].sort((a, b) => a - b);
|
|
22
|
+
return min <= value && value < max;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { inRange as i, limit as l };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ElementDefinitionContext } from '@microsoft/fast-foundation';
|
|
2
|
+
export interface FormElement {
|
|
3
|
+
charCount: boolean;
|
|
4
|
+
errorValidationMessage: boolean;
|
|
5
|
+
helperText: string;
|
|
6
|
+
successText: string;
|
|
7
|
+
label: string;
|
|
8
|
+
userValid: boolean;
|
|
9
|
+
dirtyValue: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function formElements<T extends {
|
|
12
|
+
new (...args: any[]): Record<string, any>;
|
|
13
|
+
}>(constructor: T): {
|
|
14
|
+
new (...args: any[]): {
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
label?: string | undefined;
|
|
17
|
+
helperText?: string | undefined;
|
|
18
|
+
successText?: string | undefined;
|
|
19
|
+
charCount: boolean;
|
|
20
|
+
userValid: boolean;
|
|
21
|
+
"__#7248@#blurred": boolean;
|
|
22
|
+
readonly errorValidationMessage: any;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
"__#7248@#handleInvalidEvent": () => void;
|
|
25
|
+
disconnectedCallback(): void;
|
|
26
|
+
validate: () => void;
|
|
27
|
+
};
|
|
28
|
+
} & T;
|
|
29
|
+
declare type FeedbackType = 'error' | 'helper' | 'success';
|
|
30
|
+
export declare function getFeedbackTemplate(messageType: FeedbackType, context: ElementDefinitionContext): import("@microsoft/fast-element").ViewTemplate<FormElement, any>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './form-elements';
|