@ni/fast-foundation 10.1.3 → 10.1.5
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 +3 -2
- package/dist/esm/accordion/accordion.js +1 -2
- package/dist/esm/anchor/anchor.js +2 -4
- package/dist/esm/anchored-region/anchored-region-config.js +32 -6
- package/dist/esm/anchored-region/anchored-region.js +1 -1
- package/dist/esm/breadcrumb/breadcrumb.js +2 -3
- package/dist/esm/button/button.js +5 -10
- package/dist/esm/calendar/calendar.template.js +1 -2
- package/dist/esm/calendar/date-formatter.js +4 -1
- package/dist/esm/combobox/combobox.js +7 -11
- package/dist/esm/data-grid/data-grid-cell.js +1 -2
- package/dist/esm/data-grid/data-grid.js +11 -11
- package/dist/esm/design-system/design-system.js +4 -1
- package/dist/esm/design-token/custom-property-manager.js +2 -2
- package/dist/esm/design-token/design-token.js +16 -17
- package/dist/esm/di/di.js +2 -3
- package/dist/esm/dialog/dialog.js +2 -4
- package/dist/esm/directives/reflect-attributes.js +1 -1
- package/dist/esm/form-associated/form-associated.js +3 -5
- package/dist/esm/foundation-element/foundation-element.js +4 -1
- package/dist/esm/horizontal-scroll/horizontal-scroll.js +6 -9
- package/dist/esm/horizontal-scroll/horizontal-scroll.template.js +8 -11
- package/dist/esm/listbox/listbox.element.js +5 -10
- package/dist/esm/listbox/listbox.js +21 -28
- package/dist/esm/listbox-option/listbox-option.js +4 -7
- package/dist/esm/menu/menu.js +1 -1
- package/dist/esm/number-field/number-field.js +2 -4
- package/dist/esm/picker/picker-list-item.js +3 -4
- package/dist/esm/picker/picker-menu-option.js +3 -4
- package/dist/esm/picker/picker.js +12 -9
- package/dist/esm/radio/radio.js +3 -5
- package/dist/esm/radio-group/radio-group.js +4 -8
- package/dist/esm/select/select.js +12 -20
- package/dist/esm/tabs/tabs.js +2 -4
- package/dist/esm/test-utilities/fixture.js +57 -60
- package/dist/esm/test-utilities/timeout.js +5 -8
- package/dist/esm/toolbar/toolbar.js +7 -9
- package/dist/esm/utilities/intersection-service.js +2 -4
- package/dist/fast-foundation.js +243 -262
- package/dist/fast-foundation.min.js +88 -88
- package/package.json +3 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
1
|
import { defaultExecutionContext, ViewTemplate, } from "@ni/fast-element";
|
|
3
2
|
import { DesignSystem } from "../design-system/index.js";
|
|
4
3
|
function findElement(view) {
|
|
@@ -26,65 +25,63 @@ function isElementRegistry(obj) {
|
|
|
26
25
|
* Yields control to the caller one Microtask later, in order to
|
|
27
26
|
* ensure that the DOM has settled.
|
|
28
27
|
*/
|
|
29
|
-
export function fixture(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
export async function fixture(templateNameOrRegistry, options = {}) {
|
|
29
|
+
const document = options.document || globalThis.document;
|
|
30
|
+
const parent = options.parent || document.createElement("div");
|
|
31
|
+
const source = options.source || {};
|
|
32
|
+
const context = options.context || defaultExecutionContext;
|
|
33
|
+
if (typeof templateNameOrRegistry === "string") {
|
|
34
|
+
const html = `<${templateNameOrRegistry}></${templateNameOrRegistry}>`;
|
|
35
|
+
templateNameOrRegistry = new ViewTemplate(html, []);
|
|
36
|
+
}
|
|
37
|
+
else if (isElementRegistry(templateNameOrRegistry)) {
|
|
38
|
+
templateNameOrRegistry = [templateNameOrRegistry];
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(templateNameOrRegistry)) {
|
|
41
|
+
const first = templateNameOrRegistry[0];
|
|
42
|
+
const ds = options.designSystem || DesignSystem.getOrCreate(parent);
|
|
43
|
+
let prefix = "";
|
|
44
|
+
ds.register(templateNameOrRegistry, {
|
|
45
|
+
register(container, context) {
|
|
46
|
+
prefix = context.elementPrefix;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
const elementName = `${prefix}-${first.definition.baseName}`;
|
|
50
|
+
const html = `<${elementName}></${elementName}>`;
|
|
51
|
+
templateNameOrRegistry = new ViewTemplate(html, []);
|
|
52
|
+
}
|
|
53
|
+
const view = templateNameOrRegistry.create();
|
|
54
|
+
const element = findElement(view);
|
|
55
|
+
let isConnected = false;
|
|
56
|
+
view.bind(source, context);
|
|
57
|
+
view.appendTo(parent);
|
|
58
|
+
customElements.upgrade(parent);
|
|
59
|
+
// Hook into the Microtask Queue to ensure the DOM is settled
|
|
60
|
+
// before yielding control to the caller.
|
|
61
|
+
await Promise.resolve();
|
|
62
|
+
const connect = async () => {
|
|
63
|
+
if (isConnected) {
|
|
64
|
+
return;
|
|
41
65
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
const elementName = `${prefix}-${first.definition.baseName}`;
|
|
52
|
-
const html = `<${elementName}></${elementName}>`;
|
|
53
|
-
templateNameOrRegistry = new ViewTemplate(html, []);
|
|
66
|
+
isConnected = true;
|
|
67
|
+
document.body.appendChild(parent);
|
|
68
|
+
await Promise.resolve();
|
|
69
|
+
};
|
|
70
|
+
const disconnect = async () => {
|
|
71
|
+
if (!isConnected) {
|
|
72
|
+
return;
|
|
54
73
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
isConnected = true;
|
|
69
|
-
document.body.appendChild(parent);
|
|
70
|
-
yield Promise.resolve();
|
|
71
|
-
});
|
|
72
|
-
const disconnect = () => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
if (!isConnected) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
isConnected = false;
|
|
77
|
-
document.body.removeChild(parent);
|
|
78
|
-
yield Promise.resolve();
|
|
79
|
-
});
|
|
80
|
-
return {
|
|
81
|
-
document,
|
|
82
|
-
template: templateNameOrRegistry,
|
|
83
|
-
view,
|
|
84
|
-
parent,
|
|
85
|
-
element,
|
|
86
|
-
connect,
|
|
87
|
-
disconnect,
|
|
88
|
-
};
|
|
89
|
-
});
|
|
74
|
+
isConnected = false;
|
|
75
|
+
document.body.removeChild(parent);
|
|
76
|
+
await Promise.resolve();
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
document,
|
|
80
|
+
template: templateNameOrRegistry,
|
|
81
|
+
view,
|
|
82
|
+
parent,
|
|
83
|
+
element,
|
|
84
|
+
connect,
|
|
85
|
+
disconnect,
|
|
86
|
+
};
|
|
90
87
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
1
|
/**
|
|
3
2
|
* Timeout for use in async tets.
|
|
4
3
|
*/
|
|
5
|
-
export function timeout() {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, timeout);
|
|
11
|
-
});
|
|
4
|
+
export async function timeout(timeout = 0) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
window.setTimeout(() => {
|
|
7
|
+
resolve(void 0);
|
|
8
|
+
}, timeout);
|
|
12
9
|
});
|
|
13
10
|
}
|
|
@@ -96,8 +96,7 @@ export class Toolbar extends FoundationElement {
|
|
|
96
96
|
* @internal
|
|
97
97
|
*/
|
|
98
98
|
mouseDownHandler(e) {
|
|
99
|
-
|
|
100
|
-
const activeIndex = (_a = this.focusableElements) === null || _a === void 0 ? void 0 : _a.findIndex(x => x.contains(e.target));
|
|
99
|
+
const activeIndex = this.focusableElements?.findIndex(x => x.contains(e.target));
|
|
101
100
|
if (activeIndex > -1 && this.activeIndex !== activeIndex) {
|
|
102
101
|
this.setFocusedElement(activeIndex);
|
|
103
102
|
}
|
|
@@ -135,8 +134,9 @@ export class Toolbar extends FoundationElement {
|
|
|
135
134
|
* @internal
|
|
136
135
|
*/
|
|
137
136
|
getDirectionalIncrementer(key) {
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
return (ToolbarArrowKeyMap[key]?.[this.orientation]?.[this.direction] ??
|
|
138
|
+
ToolbarArrowKeyMap[key]?.[this.orientation] ??
|
|
139
|
+
0);
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Handle keyboard events for the toolbar.
|
|
@@ -176,8 +176,7 @@ export class Toolbar extends FoundationElement {
|
|
|
176
176
|
* @internal
|
|
177
177
|
*/
|
|
178
178
|
reduceFocusableElements() {
|
|
179
|
-
|
|
180
|
-
const previousFocusedElement = (_a = this.focusableElements) === null || _a === void 0 ? void 0 : _a[this.activeIndex];
|
|
179
|
+
const previousFocusedElement = this.focusableElements?.[this.activeIndex];
|
|
181
180
|
this.focusableElements = this.allSlottedItems.reduce(Toolbar.reduceFocusableItems, []);
|
|
182
181
|
// If the previously active item is still focusable, adjust the active index to the
|
|
183
182
|
// index of that item.
|
|
@@ -210,10 +209,9 @@ export class Toolbar extends FoundationElement {
|
|
|
210
209
|
* @internal
|
|
211
210
|
*/
|
|
212
211
|
static reduceFocusableItems(elements, element) {
|
|
213
|
-
var _a, _b, _c, _d;
|
|
214
212
|
const isRoleRadio = element.getAttribute("role") === "radio";
|
|
215
|
-
const isFocusableFastElement =
|
|
216
|
-
const hasFocusableShadow = Array.from(
|
|
213
|
+
const isFocusableFastElement = element.$fastController?.definition.shadowOptions?.delegatesFocus;
|
|
214
|
+
const hasFocusableShadow = Array.from(element.shadowRoot?.querySelectorAll("*") ?? []).some(x => isFocusable(x));
|
|
217
215
|
if (!element.hasAttribute("disabled") &&
|
|
218
216
|
!element.hasAttribute("hidden") &&
|
|
219
217
|
(isFocusable(element) ||
|
|
@@ -14,12 +14,11 @@ export class IntersectionService {
|
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
16
|
this.requestPosition = (target, callback) => {
|
|
17
|
-
var _a;
|
|
18
17
|
if (this.intersectionDetector === null) {
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
if (this.observedElements.has(target)) {
|
|
22
|
-
|
|
21
|
+
this.observedElements.get(target)?.push(callback);
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
24
|
this.observedElements.set(target, [callback]);
|
|
@@ -64,9 +63,8 @@ export class IntersectionService {
|
|
|
64
63
|
const pendingCallbackParams = [];
|
|
65
64
|
// go through the entries to build a list of callbacks and params for each
|
|
66
65
|
entries.forEach((entry) => {
|
|
67
|
-
var _a;
|
|
68
66
|
// stop watching this element until we get new update requests for it
|
|
69
|
-
|
|
67
|
+
this.intersectionDetector?.unobserve(entry.target);
|
|
70
68
|
const thisElementCallbacks = this.observedElements.get(entry.target);
|
|
71
69
|
if (thisElementCallbacks !== undefined) {
|
|
72
70
|
thisElementCallbacks.forEach((callback) => {
|