@fluentui/web-components 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +54 -1
- package/CHANGELOG.md +11 -2
- package/dist/dts/number-field/number-field.stories.d.ts +1 -0
- package/dist/dts/text-area/text-area.stories.d.ts +1 -0
- package/dist/dts/text-field/text-field.stories.d.ts +1 -1
- package/dist/esm/anchor/anchor.stories.js +4 -3
- package/dist/esm/anchored-region/anchored-region.stories.js +3 -3
- package/dist/esm/badge/badge.stories.js +2 -2
- package/dist/esm/card/card.stories.js +1 -1
- package/dist/esm/checkbox/checkbox.stories.js +2 -2
- package/dist/esm/combobox/combobox.stories.js +5 -0
- package/dist/esm/data-grid/data-grid.stories.js +3 -3
- package/dist/esm/number-field/number-field.stories.js +2 -1
- package/dist/esm/radio-group/radio-group.stories.js +5 -3
- package/dist/esm/slider/slider.stories.js +8 -3
- package/dist/esm/switch/switch.stories.js +10 -2
- package/dist/esm/tabs/tabs.stories.js +2 -2
- package/dist/esm/text-area/text-area.stories.js +3 -2
- package/dist/esm/text-field/text-field.stories.js +3 -3
- package/dist/esm/tree-view/tree-view.stories.js +30 -8
- package/dist/web-components.js +582 -423
- package/dist/web-components.min.js +126 -126
- package/package.json +5 -4
- package/public/switches.ts +1 -1
package/dist/web-components.js
CHANGED
|
@@ -7038,7 +7038,9 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7038
7038
|
if (this.horizontalPositioningMode !== "uncontrolled") {
|
|
7039
7039
|
const horizontalOptions = this.getPositioningOptions(this.horizontalInset);
|
|
7040
7040
|
|
|
7041
|
-
if (this.horizontalDefaultPosition
|
|
7041
|
+
if (this.horizontalDefaultPosition === "center") {
|
|
7042
|
+
desiredHorizontalPosition = "center";
|
|
7043
|
+
} else if (this.horizontalDefaultPosition !== "unset") {
|
|
7042
7044
|
let dirCorrectedHorizontalDefaultPosition = this.horizontalDefaultPosition;
|
|
7043
7045
|
|
|
7044
7046
|
if (dirCorrectedHorizontalDefaultPosition === "start" || dirCorrectedHorizontalDefaultPosition === "end") {
|
|
@@ -7084,7 +7086,9 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7084
7086
|
if (this.verticalPositioningMode !== "uncontrolled") {
|
|
7085
7087
|
const verticalOptions = this.getPositioningOptions(this.verticalInset);
|
|
7086
7088
|
|
|
7087
|
-
if (this.verticalDefaultPosition
|
|
7089
|
+
if (this.verticalDefaultPosition === "center") {
|
|
7090
|
+
desiredVerticalPosition = "center";
|
|
7091
|
+
} else if (this.verticalDefaultPosition !== "unset") {
|
|
7088
7092
|
switch (this.verticalDefaultPosition) {
|
|
7089
7093
|
case "top":
|
|
7090
7094
|
desiredVerticalPosition = this.verticalInset ? "insetStart" : "start";
|
|
@@ -7160,10 +7164,12 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7160
7164
|
this.classList.toggle("bottom", this.verticalPosition === "end");
|
|
7161
7165
|
this.classList.toggle("inset-top", this.verticalPosition === "insetStart");
|
|
7162
7166
|
this.classList.toggle("inset-bottom", this.verticalPosition === "insetEnd");
|
|
7167
|
+
this.classList.toggle("vertical-center", this.verticalPosition === "center");
|
|
7163
7168
|
this.classList.toggle("left", this.horizontalPosition === "start");
|
|
7164
7169
|
this.classList.toggle("right", this.horizontalPosition === "end");
|
|
7165
7170
|
this.classList.toggle("inset-left", this.horizontalPosition === "insetStart");
|
|
7166
7171
|
this.classList.toggle("inset-right", this.horizontalPosition === "insetEnd");
|
|
7172
|
+
this.classList.toggle("horizontal-center", this.horizontalPosition === "center");
|
|
7167
7173
|
};
|
|
7168
7174
|
/**
|
|
7169
7175
|
* Get horizontal positioning state based on desired position
|
|
@@ -7190,6 +7196,8 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7190
7196
|
break;
|
|
7191
7197
|
}
|
|
7192
7198
|
|
|
7199
|
+
let sizeDelta = 0;
|
|
7200
|
+
|
|
7193
7201
|
switch (desiredHorizontalPosition) {
|
|
7194
7202
|
case "start":
|
|
7195
7203
|
this.translateX = this.baseHorizontalOffset - nextRegionWidth;
|
|
@@ -7225,6 +7233,23 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7225
7233
|
this.translateX = this.translateX - (this.anchorRect.right - this.viewportRect.left);
|
|
7226
7234
|
}
|
|
7227
7235
|
|
|
7236
|
+
break;
|
|
7237
|
+
|
|
7238
|
+
case "center":
|
|
7239
|
+
sizeDelta = (this.anchorRect.width - nextRegionWidth) / 2;
|
|
7240
|
+
this.translateX = this.baseHorizontalOffset + sizeDelta;
|
|
7241
|
+
|
|
7242
|
+
if (this.horizontalViewportLock) {
|
|
7243
|
+
const regionLeft = this.anchorRect.left + sizeDelta;
|
|
7244
|
+
const regionRight = this.anchorRect.right - sizeDelta;
|
|
7245
|
+
|
|
7246
|
+
if (regionLeft < this.viewportRect.left && !(regionRight > this.viewportRect.right)) {
|
|
7247
|
+
this.translateX = this.translateX - (regionLeft - this.viewportRect.left);
|
|
7248
|
+
} else if (regionRight > this.viewportRect.right && !(regionLeft < this.viewportRect.left)) {
|
|
7249
|
+
this.translateX = this.translateX - (regionRight - this.viewportRect.right);
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
|
|
7228
7253
|
break;
|
|
7229
7254
|
}
|
|
7230
7255
|
|
|
@@ -7255,6 +7280,8 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7255
7280
|
break;
|
|
7256
7281
|
}
|
|
7257
7282
|
|
|
7283
|
+
let sizeDelta = 0;
|
|
7284
|
+
|
|
7258
7285
|
switch (desiredVerticalPosition) {
|
|
7259
7286
|
case "start":
|
|
7260
7287
|
this.translateY = this.baseVerticalOffset - nextRegionHeight;
|
|
@@ -7291,6 +7318,22 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7291
7318
|
}
|
|
7292
7319
|
|
|
7293
7320
|
break;
|
|
7321
|
+
|
|
7322
|
+
case "center":
|
|
7323
|
+
sizeDelta = (this.anchorRect.height - nextRegionHeight) / 2;
|
|
7324
|
+
this.translateY = this.baseVerticalOffset + sizeDelta;
|
|
7325
|
+
|
|
7326
|
+
if (this.verticalViewportLock) {
|
|
7327
|
+
const regionTop = this.anchorRect.top + sizeDelta;
|
|
7328
|
+
const regionBottom = this.anchorRect.bottom - sizeDelta;
|
|
7329
|
+
|
|
7330
|
+
if (regionTop < this.viewportRect.top && !(regionBottom > this.viewportRect.bottom)) {
|
|
7331
|
+
this.translateY = this.translateY - (regionTop - this.viewportRect.top);
|
|
7332
|
+
} else if (regionBottom > this.viewportRect.bottom && !(regionTop < this.viewportRect.top)) {
|
|
7333
|
+
this.translateY = this.translateY - (regionBottom - this.viewportRect.bottom);
|
|
7334
|
+
}
|
|
7335
|
+
}
|
|
7336
|
+
|
|
7294
7337
|
}
|
|
7295
7338
|
|
|
7296
7339
|
this.verticalPosition = desiredVerticalPosition;
|
|
@@ -7328,6 +7371,9 @@ class AnchoredRegion extends FoundationElement {
|
|
|
7328
7371
|
|
|
7329
7372
|
case "end":
|
|
7330
7373
|
return spaceEnd;
|
|
7374
|
+
|
|
7375
|
+
case "center":
|
|
7376
|
+
return Math.min(spaceStart, spaceEnd) * 2 + anchorSpan;
|
|
7331
7377
|
}
|
|
7332
7378
|
};
|
|
7333
7379
|
/**
|
|
@@ -7977,9 +8023,14 @@ function FormAssociated(BaseCtor) {
|
|
|
7977
8023
|
this.proxy.value = this.value;
|
|
7978
8024
|
}
|
|
7979
8025
|
|
|
8026
|
+
this.currentValue = this.value;
|
|
7980
8027
|
this.setFormValue(this.value);
|
|
7981
8028
|
this.validate();
|
|
7982
8029
|
}
|
|
8030
|
+
|
|
8031
|
+
currentValueChanged() {
|
|
8032
|
+
this.value = this.currentValue;
|
|
8033
|
+
}
|
|
7983
8034
|
/**
|
|
7984
8035
|
* Invoked when the `initialValue` property changes
|
|
7985
8036
|
*
|
|
@@ -8249,6 +8300,9 @@ function FormAssociated(BaseCtor) {
|
|
|
8249
8300
|
mode: "fromView",
|
|
8250
8301
|
attribute: "value"
|
|
8251
8302
|
})(C.prototype, "initialValue");
|
|
8303
|
+
attr({
|
|
8304
|
+
attribute: "current-value"
|
|
8305
|
+
})(C.prototype, "currentValue");
|
|
8252
8306
|
attr(C.prototype, "name");
|
|
8253
8307
|
attr({
|
|
8254
8308
|
mode: "boolean"
|
|
@@ -10893,242 +10947,6 @@ const comboboxTemplate = (context, definition) => html`<template autocomplete="$
|
|
|
10893
10947
|
property: "slottedOptions"
|
|
10894
10948
|
})}></slot></div></template>`;
|
|
10895
10949
|
|
|
10896
|
-
/**
|
|
10897
|
-
* Indicates what to do with an ambiguous (duplicate) element.
|
|
10898
|
-
* @public
|
|
10899
|
-
*/
|
|
10900
|
-
|
|
10901
|
-
const ElementDisambiguation = Object.freeze({
|
|
10902
|
-
/**
|
|
10903
|
-
* Skip defining the element but still call the provided callback passed
|
|
10904
|
-
* to DesignSystemRegistrationContext.tryDefineElement
|
|
10905
|
-
*/
|
|
10906
|
-
definitionCallbackOnly: null,
|
|
10907
|
-
|
|
10908
|
-
/**
|
|
10909
|
-
* Ignore the duplicate element entirely.
|
|
10910
|
-
*/
|
|
10911
|
-
ignoreDuplicate: Symbol()
|
|
10912
|
-
});
|
|
10913
|
-
const elementTypesByTag = new Map();
|
|
10914
|
-
const elementTagsByType = new Map();
|
|
10915
|
-
let rootDesignSystem = null;
|
|
10916
|
-
const designSystemKey = DI.createInterface(x => x.cachedCallback(handler => {
|
|
10917
|
-
if (rootDesignSystem === null) {
|
|
10918
|
-
rootDesignSystem = new DefaultDesignSystem(null, handler);
|
|
10919
|
-
}
|
|
10920
|
-
|
|
10921
|
-
return rootDesignSystem;
|
|
10922
|
-
}));
|
|
10923
|
-
/**
|
|
10924
|
-
* An API gateway to design system features.
|
|
10925
|
-
* @public
|
|
10926
|
-
*/
|
|
10927
|
-
|
|
10928
|
-
const DesignSystem = Object.freeze({
|
|
10929
|
-
/**
|
|
10930
|
-
* Returns the HTML element name that the type is defined as.
|
|
10931
|
-
* @param type - The type to lookup.
|
|
10932
|
-
* @public
|
|
10933
|
-
*/
|
|
10934
|
-
tagFor(type) {
|
|
10935
|
-
return elementTagsByType.get(type);
|
|
10936
|
-
},
|
|
10937
|
-
|
|
10938
|
-
/**
|
|
10939
|
-
* Searches the DOM hierarchy for the design system that is responsible
|
|
10940
|
-
* for the provided element.
|
|
10941
|
-
* @param element - The element to locate the design system for.
|
|
10942
|
-
* @returns The located design system.
|
|
10943
|
-
* @public
|
|
10944
|
-
*/
|
|
10945
|
-
responsibleFor(element) {
|
|
10946
|
-
const owned = element.$$designSystem$$;
|
|
10947
|
-
|
|
10948
|
-
if (owned) {
|
|
10949
|
-
return owned;
|
|
10950
|
-
}
|
|
10951
|
-
|
|
10952
|
-
const container = DI.findResponsibleContainer(element);
|
|
10953
|
-
return container.get(designSystemKey);
|
|
10954
|
-
},
|
|
10955
|
-
|
|
10956
|
-
/**
|
|
10957
|
-
* Gets the DesignSystem if one is explicitly defined on the provided element;
|
|
10958
|
-
* otherwise creates a design system defined directly on the element.
|
|
10959
|
-
* @param element - The element to get or create a design system for.
|
|
10960
|
-
* @returns The design system.
|
|
10961
|
-
* @public
|
|
10962
|
-
*/
|
|
10963
|
-
getOrCreate(node) {
|
|
10964
|
-
if (!node) {
|
|
10965
|
-
if (rootDesignSystem === null) {
|
|
10966
|
-
rootDesignSystem = DI.getOrCreateDOMContainer().get(designSystemKey);
|
|
10967
|
-
}
|
|
10968
|
-
|
|
10969
|
-
return rootDesignSystem;
|
|
10970
|
-
}
|
|
10971
|
-
|
|
10972
|
-
const owned = node.$$designSystem$$;
|
|
10973
|
-
|
|
10974
|
-
if (owned) {
|
|
10975
|
-
return owned;
|
|
10976
|
-
}
|
|
10977
|
-
|
|
10978
|
-
const container = DI.getOrCreateDOMContainer(node);
|
|
10979
|
-
|
|
10980
|
-
if (container.has(designSystemKey, false)) {
|
|
10981
|
-
return container.get(designSystemKey);
|
|
10982
|
-
} else {
|
|
10983
|
-
const system = new DefaultDesignSystem(node, container);
|
|
10984
|
-
container.register(Registration.instance(designSystemKey, system));
|
|
10985
|
-
return system;
|
|
10986
|
-
}
|
|
10987
|
-
}
|
|
10988
|
-
|
|
10989
|
-
});
|
|
10990
|
-
|
|
10991
|
-
function extractTryDefineElementParams(params, elementDefinitionType, elementDefinitionCallback) {
|
|
10992
|
-
if (typeof params === "string") {
|
|
10993
|
-
return {
|
|
10994
|
-
name: params,
|
|
10995
|
-
type: elementDefinitionType,
|
|
10996
|
-
callback: elementDefinitionCallback
|
|
10997
|
-
};
|
|
10998
|
-
} else {
|
|
10999
|
-
return params;
|
|
11000
|
-
}
|
|
11001
|
-
}
|
|
11002
|
-
|
|
11003
|
-
class DefaultDesignSystem {
|
|
11004
|
-
constructor(owner, container) {
|
|
11005
|
-
this.owner = owner;
|
|
11006
|
-
this.container = container;
|
|
11007
|
-
this.prefix = "fast";
|
|
11008
|
-
this.shadowRootMode = undefined;
|
|
11009
|
-
|
|
11010
|
-
this.disambiguate = () => ElementDisambiguation.definitionCallbackOnly;
|
|
11011
|
-
|
|
11012
|
-
if (owner !== null) {
|
|
11013
|
-
owner.$$designSystem$$ = this;
|
|
11014
|
-
}
|
|
11015
|
-
}
|
|
11016
|
-
|
|
11017
|
-
withPrefix(prefix) {
|
|
11018
|
-
this.prefix = prefix;
|
|
11019
|
-
return this;
|
|
11020
|
-
}
|
|
11021
|
-
|
|
11022
|
-
withShadowRootMode(mode) {
|
|
11023
|
-
this.shadowRootMode = mode;
|
|
11024
|
-
return this;
|
|
11025
|
-
}
|
|
11026
|
-
|
|
11027
|
-
withElementDisambiguation(callback) {
|
|
11028
|
-
this.disambiguate = callback;
|
|
11029
|
-
return this;
|
|
11030
|
-
}
|
|
11031
|
-
|
|
11032
|
-
register(...registrations) {
|
|
11033
|
-
const container = this.container;
|
|
11034
|
-
const elementDefinitionEntries = [];
|
|
11035
|
-
const disambiguate = this.disambiguate;
|
|
11036
|
-
const shadowRootMode = this.shadowRootMode;
|
|
11037
|
-
const context = {
|
|
11038
|
-
elementPrefix: this.prefix,
|
|
11039
|
-
|
|
11040
|
-
tryDefineElement(params, elementDefinitionType, elementDefinitionCallback) {
|
|
11041
|
-
const extractedParams = extractTryDefineElementParams(params, elementDefinitionType, elementDefinitionCallback);
|
|
11042
|
-
const {
|
|
11043
|
-
name,
|
|
11044
|
-
callback,
|
|
11045
|
-
baseClass
|
|
11046
|
-
} = extractedParams;
|
|
11047
|
-
let {
|
|
11048
|
-
type
|
|
11049
|
-
} = extractedParams;
|
|
11050
|
-
let elementName = name;
|
|
11051
|
-
let typeFoundByName = elementTypesByTag.get(elementName);
|
|
11052
|
-
let needsDefine = true;
|
|
11053
|
-
|
|
11054
|
-
while (typeFoundByName) {
|
|
11055
|
-
const result = disambiguate(elementName, type, typeFoundByName);
|
|
11056
|
-
|
|
11057
|
-
switch (result) {
|
|
11058
|
-
case ElementDisambiguation.ignoreDuplicate:
|
|
11059
|
-
return;
|
|
11060
|
-
|
|
11061
|
-
case ElementDisambiguation.definitionCallbackOnly:
|
|
11062
|
-
needsDefine = false;
|
|
11063
|
-
typeFoundByName = void 0;
|
|
11064
|
-
break;
|
|
11065
|
-
|
|
11066
|
-
default:
|
|
11067
|
-
elementName = result;
|
|
11068
|
-
typeFoundByName = elementTypesByTag.get(elementName);
|
|
11069
|
-
break;
|
|
11070
|
-
}
|
|
11071
|
-
}
|
|
11072
|
-
|
|
11073
|
-
if (needsDefine) {
|
|
11074
|
-
if (elementTagsByType.has(type) || type === FoundationElement) {
|
|
11075
|
-
type = class extends type {};
|
|
11076
|
-
}
|
|
11077
|
-
|
|
11078
|
-
elementTypesByTag.set(elementName, type);
|
|
11079
|
-
elementTagsByType.set(type, elementName);
|
|
11080
|
-
|
|
11081
|
-
if (baseClass) {
|
|
11082
|
-
elementTagsByType.set(baseClass, elementName);
|
|
11083
|
-
}
|
|
11084
|
-
}
|
|
11085
|
-
|
|
11086
|
-
elementDefinitionEntries.push(new ElementDefinitionEntry(container, elementName, type, shadowRootMode, callback, needsDefine));
|
|
11087
|
-
}
|
|
11088
|
-
|
|
11089
|
-
};
|
|
11090
|
-
container.registerWithContext(context, ...registrations);
|
|
11091
|
-
|
|
11092
|
-
for (const entry of elementDefinitionEntries) {
|
|
11093
|
-
entry.callback(entry);
|
|
11094
|
-
|
|
11095
|
-
if (entry.willDefine && entry.definition !== null) {
|
|
11096
|
-
entry.definition.define();
|
|
11097
|
-
}
|
|
11098
|
-
}
|
|
11099
|
-
|
|
11100
|
-
return this;
|
|
11101
|
-
}
|
|
11102
|
-
|
|
11103
|
-
}
|
|
11104
|
-
|
|
11105
|
-
class ElementDefinitionEntry {
|
|
11106
|
-
constructor(container, name, type, shadowRootMode, callback, willDefine) {
|
|
11107
|
-
this.container = container;
|
|
11108
|
-
this.name = name;
|
|
11109
|
-
this.type = type;
|
|
11110
|
-
this.shadowRootMode = shadowRootMode;
|
|
11111
|
-
this.callback = callback;
|
|
11112
|
-
this.willDefine = willDefine;
|
|
11113
|
-
this.definition = null;
|
|
11114
|
-
}
|
|
11115
|
-
|
|
11116
|
-
definePresentation(presentation) {
|
|
11117
|
-
ComponentPresentation.define(this.name, presentation, this.container);
|
|
11118
|
-
}
|
|
11119
|
-
|
|
11120
|
-
defineElement(definition) {
|
|
11121
|
-
this.definition = new FASTElementDefinition(this.type, Object.assign(Object.assign({}, definition), {
|
|
11122
|
-
name: this.name
|
|
11123
|
-
}));
|
|
11124
|
-
}
|
|
11125
|
-
|
|
11126
|
-
tagFor(type) {
|
|
11127
|
-
return DesignSystem.tagFor(type);
|
|
11128
|
-
}
|
|
11129
|
-
|
|
11130
|
-
}
|
|
11131
|
-
|
|
11132
10950
|
/**
|
|
11133
10951
|
* Retrieves the "composed parent" element of a node, ignoring DOM tree boundaries.
|
|
11134
10952
|
* When the parent of a node is a shadow-root, it will return the host
|
|
@@ -11498,8 +11316,10 @@ class HeadStyleElementStyleSheetTarget extends QueuedStyleSheetTarget {
|
|
|
11498
11316
|
// but if-check it just in case.
|
|
11499
11317
|
|
|
11500
11318
|
if (sheet) {
|
|
11501
|
-
|
|
11502
|
-
|
|
11319
|
+
// https://github.com/jsdom/jsdom uses https://github.com/NV/CSSOM for it's CSSOM implementation,
|
|
11320
|
+
// which implements the DOM Level 2 spec for CSSStyleSheet where insertRule() requires an index argument.
|
|
11321
|
+
const index = sheet.insertRule(":root{}", sheet.cssRules.length);
|
|
11322
|
+
this.target = sheet.cssRules[index].style;
|
|
11503
11323
|
}
|
|
11504
11324
|
}
|
|
11505
11325
|
|
|
@@ -11560,8 +11380,10 @@ class StyleElementStyleSheetTarget {
|
|
|
11560
11380
|
if (sheet) {
|
|
11561
11381
|
// Safari will throw if we try to use the return result of insertRule()
|
|
11562
11382
|
// to index the rule inline, so store as a const prior to indexing.
|
|
11563
|
-
|
|
11564
|
-
|
|
11383
|
+
// https://github.com/jsdom/jsdom uses https://github.com/NV/CSSOM for it's CSSOM implementation,
|
|
11384
|
+
// which implements the DOM Level 2 spec for CSSStyleSheet where insertRule() requires an index argument.
|
|
11385
|
+
const index = sheet.insertRule(":root{}", sheet.cssRules.length);
|
|
11386
|
+
this.target = sheet.cssRules[index].style;
|
|
11565
11387
|
} else {
|
|
11566
11388
|
this.target = null;
|
|
11567
11389
|
}
|
|
@@ -11588,8 +11410,76 @@ class ElementStyleSheetTarget {
|
|
|
11588
11410
|
DOM.queueUpdate(() => this.target.removeProperty(name));
|
|
11589
11411
|
}
|
|
11590
11412
|
|
|
11591
|
-
}
|
|
11592
|
-
|
|
11413
|
+
}
|
|
11414
|
+
/**
|
|
11415
|
+
* Controls emission for default values. This control is capable
|
|
11416
|
+
* of emitting to multiple {@link PropertyTarget | PropertyTargets},
|
|
11417
|
+
* and only emits if it has at least one root.
|
|
11418
|
+
*
|
|
11419
|
+
* @internal
|
|
11420
|
+
*/
|
|
11421
|
+
|
|
11422
|
+
|
|
11423
|
+
class RootStyleSheetTarget {
|
|
11424
|
+
setProperty(name, value) {
|
|
11425
|
+
RootStyleSheetTarget.properties[name] = value;
|
|
11426
|
+
|
|
11427
|
+
for (const target of RootStyleSheetTarget.roots.values()) {
|
|
11428
|
+
PropertyTargetManager.getOrCreate(RootStyleSheetTarget.normalizeRoot(target)).setProperty(name, value);
|
|
11429
|
+
}
|
|
11430
|
+
}
|
|
11431
|
+
|
|
11432
|
+
removeProperty(name) {
|
|
11433
|
+
delete RootStyleSheetTarget.properties[name];
|
|
11434
|
+
|
|
11435
|
+
for (const target of RootStyleSheetTarget.roots.values()) {
|
|
11436
|
+
PropertyTargetManager.getOrCreate(RootStyleSheetTarget.normalizeRoot(target)).removeProperty(name);
|
|
11437
|
+
}
|
|
11438
|
+
}
|
|
11439
|
+
|
|
11440
|
+
static registerRoot(root) {
|
|
11441
|
+
const {
|
|
11442
|
+
roots
|
|
11443
|
+
} = RootStyleSheetTarget;
|
|
11444
|
+
|
|
11445
|
+
if (!roots.has(root)) {
|
|
11446
|
+
roots.add(root);
|
|
11447
|
+
const target = PropertyTargetManager.getOrCreate(this.normalizeRoot(root));
|
|
11448
|
+
|
|
11449
|
+
for (const key in RootStyleSheetTarget.properties) {
|
|
11450
|
+
target.setProperty(key, RootStyleSheetTarget.properties[key]);
|
|
11451
|
+
}
|
|
11452
|
+
}
|
|
11453
|
+
}
|
|
11454
|
+
|
|
11455
|
+
static unregisterRoot(root) {
|
|
11456
|
+
const {
|
|
11457
|
+
roots
|
|
11458
|
+
} = RootStyleSheetTarget;
|
|
11459
|
+
|
|
11460
|
+
if (roots.has(root)) {
|
|
11461
|
+
roots.delete(root);
|
|
11462
|
+
const target = PropertyTargetManager.getOrCreate(RootStyleSheetTarget.normalizeRoot(root));
|
|
11463
|
+
|
|
11464
|
+
for (const key in RootStyleSheetTarget.properties) {
|
|
11465
|
+
target.removeProperty(key);
|
|
11466
|
+
}
|
|
11467
|
+
}
|
|
11468
|
+
}
|
|
11469
|
+
/**
|
|
11470
|
+
* Returns the document when provided the default element,
|
|
11471
|
+
* otherwise is a no-op
|
|
11472
|
+
* @param root - the root to normalize
|
|
11473
|
+
*/
|
|
11474
|
+
|
|
11475
|
+
|
|
11476
|
+
static normalizeRoot(root) {
|
|
11477
|
+
return root === defaultElement ? document : root;
|
|
11478
|
+
}
|
|
11479
|
+
|
|
11480
|
+
}
|
|
11481
|
+
RootStyleSheetTarget.roots = new Set();
|
|
11482
|
+
RootStyleSheetTarget.properties = {}; // Caches PropertyTarget instances
|
|
11593
11483
|
|
|
11594
11484
|
const propertyTargetCache = new WeakMap(); // Use Constructable StyleSheets for FAST elements when supported, otherwise use
|
|
11595
11485
|
// HTMLStyleElement instances
|
|
@@ -11610,6 +11500,8 @@ const PropertyTargetManager = Object.freeze({
|
|
|
11610
11500
|
let target;
|
|
11611
11501
|
|
|
11612
11502
|
if (source === defaultElement) {
|
|
11503
|
+
target = new RootStyleSheetTarget();
|
|
11504
|
+
} else if (source instanceof Document) {
|
|
11613
11505
|
target = DOM.supportsAdoptedStyleSheets ? new DocumentStyleSheetTarget() : new HeadStyleElementStyleSheetTarget();
|
|
11614
11506
|
} else if (isFastElement(source)) {
|
|
11615
11507
|
target = new propertyTargetCtor(source);
|
|
@@ -12218,160 +12110,430 @@ class DesignTokenNode {
|
|
|
12218
12110
|
DesignTokenNode.cssCustomPropertyReflector.stopReflection(token, this.target);
|
|
12219
12111
|
}
|
|
12220
12112
|
}
|
|
12221
|
-
/**
|
|
12222
|
-
* Determines if a token is being reflected to CSS for a node.
|
|
12223
|
-
* @param token - The token to check for reflection
|
|
12224
|
-
* @returns
|
|
12225
|
-
*/
|
|
12113
|
+
/**
|
|
12114
|
+
* Determines if a token is being reflected to CSS for a node.
|
|
12115
|
+
* @param token - The token to check for reflection
|
|
12116
|
+
* @returns
|
|
12117
|
+
*/
|
|
12118
|
+
|
|
12119
|
+
|
|
12120
|
+
isReflecting(token) {
|
|
12121
|
+
return this.reflecting.has(token);
|
|
12122
|
+
}
|
|
12123
|
+
/**
|
|
12124
|
+
* Handle changes to upstream tokens
|
|
12125
|
+
* @param source - The parent DesignTokenNode
|
|
12126
|
+
* @param property - The token ID that changed
|
|
12127
|
+
*/
|
|
12128
|
+
|
|
12129
|
+
|
|
12130
|
+
handleChange(source, property) {
|
|
12131
|
+
const token = DesignTokenImpl.getTokenById(property);
|
|
12132
|
+
|
|
12133
|
+
if (!token) {
|
|
12134
|
+
return;
|
|
12135
|
+
}
|
|
12136
|
+
|
|
12137
|
+
this.hydrate(token, this.getRaw(token));
|
|
12138
|
+
}
|
|
12139
|
+
/**
|
|
12140
|
+
* Hydrates a token with a DesignTokenValue, making retrieval available.
|
|
12141
|
+
* @param token - The token to hydrate
|
|
12142
|
+
* @param value - The value to hydrate
|
|
12143
|
+
*/
|
|
12144
|
+
|
|
12145
|
+
|
|
12146
|
+
hydrate(token, value) {
|
|
12147
|
+
if (!this.has(token)) {
|
|
12148
|
+
const observer = this.bindingObservers.get(token);
|
|
12149
|
+
|
|
12150
|
+
if (DesignTokenImpl.isDerivedDesignTokenValue(value)) {
|
|
12151
|
+
if (observer) {
|
|
12152
|
+
// If the binding source doesn't match, we need
|
|
12153
|
+
// to update the binding
|
|
12154
|
+
if (observer.source !== value) {
|
|
12155
|
+
this.tearDownBindingObserver(token);
|
|
12156
|
+
this.setupBindingObserver(token, value);
|
|
12157
|
+
}
|
|
12158
|
+
} else {
|
|
12159
|
+
this.setupBindingObserver(token, value);
|
|
12160
|
+
}
|
|
12161
|
+
} else {
|
|
12162
|
+
if (observer) {
|
|
12163
|
+
this.tearDownBindingObserver(token);
|
|
12164
|
+
}
|
|
12165
|
+
|
|
12166
|
+
this.store.set(token, value);
|
|
12167
|
+
}
|
|
12168
|
+
}
|
|
12169
|
+
}
|
|
12170
|
+
/**
|
|
12171
|
+
* Sets up a binding observer for a derived token value that notifies token
|
|
12172
|
+
* subscribers on change.
|
|
12173
|
+
*
|
|
12174
|
+
* @param token - The token to notify when the binding updates
|
|
12175
|
+
* @param source - The binding source
|
|
12176
|
+
*/
|
|
12177
|
+
|
|
12178
|
+
|
|
12179
|
+
setupBindingObserver(token, source) {
|
|
12180
|
+
const binding = new DesignTokenBindingObserver(source, token, this);
|
|
12181
|
+
this.bindingObservers.set(token, binding);
|
|
12182
|
+
return binding;
|
|
12183
|
+
}
|
|
12184
|
+
/**
|
|
12185
|
+
* Tear down a binding observer for a token.
|
|
12186
|
+
*/
|
|
12187
|
+
|
|
12188
|
+
|
|
12189
|
+
tearDownBindingObserver(token) {
|
|
12190
|
+
if (this.bindingObservers.has(token)) {
|
|
12191
|
+
this.bindingObservers.get(token).disconnect();
|
|
12192
|
+
this.bindingObservers.delete(token);
|
|
12193
|
+
return true;
|
|
12194
|
+
}
|
|
12195
|
+
|
|
12196
|
+
return false;
|
|
12197
|
+
}
|
|
12198
|
+
|
|
12199
|
+
}
|
|
12200
|
+
/**
|
|
12201
|
+
* Responsible for reflecting tokens to CSS custom properties
|
|
12202
|
+
*/
|
|
12203
|
+
|
|
12204
|
+
|
|
12205
|
+
DesignTokenNode.cssCustomPropertyReflector = new CustomPropertyReflector();
|
|
12206
|
+
|
|
12207
|
+
__decorate$1([observable], DesignTokenNode.prototype, "children", void 0);
|
|
12208
|
+
|
|
12209
|
+
function create$1(nameOrConfig) {
|
|
12210
|
+
return DesignTokenImpl.from(nameOrConfig);
|
|
12211
|
+
}
|
|
12212
|
+
/**
|
|
12213
|
+
* Factory object for creating {@link (DesignToken:interface)} instances.
|
|
12214
|
+
* @public
|
|
12215
|
+
*/
|
|
12216
|
+
|
|
12217
|
+
|
|
12218
|
+
const DesignToken = Object.freeze({
|
|
12219
|
+
create: create$1,
|
|
12220
|
+
|
|
12221
|
+
/**
|
|
12222
|
+
* Informs DesignToken that an HTMLElement for which tokens have
|
|
12223
|
+
* been set has been connected to the document.
|
|
12224
|
+
*
|
|
12225
|
+
* The browser does not provide a reliable mechanism to observe an HTMLElement's connectedness
|
|
12226
|
+
* in all scenarios, so invoking this method manually is necessary when:
|
|
12227
|
+
*
|
|
12228
|
+
* 1. Token values are set for an HTMLElement.
|
|
12229
|
+
* 2. The HTMLElement does not inherit from FASTElement.
|
|
12230
|
+
* 3. The HTMLElement is not connected to the document when token values are set.
|
|
12231
|
+
*
|
|
12232
|
+
* @param element - The element to notify
|
|
12233
|
+
* @returns - true if notification was successful, otherwise false.
|
|
12234
|
+
*/
|
|
12235
|
+
notifyConnection(element) {
|
|
12236
|
+
if (!element.isConnected || !DesignTokenNode.existsFor(element)) {
|
|
12237
|
+
return false;
|
|
12238
|
+
}
|
|
12239
|
+
|
|
12240
|
+
DesignTokenNode.getOrCreate(element).bind();
|
|
12241
|
+
return true;
|
|
12242
|
+
},
|
|
12243
|
+
|
|
12244
|
+
/**
|
|
12245
|
+
* Informs DesignToken that an HTMLElement for which tokens have
|
|
12246
|
+
* been set has been disconnected to the document.
|
|
12247
|
+
*
|
|
12248
|
+
* The browser does not provide a reliable mechanism to observe an HTMLElement's connectedness
|
|
12249
|
+
* in all scenarios, so invoking this method manually is necessary when:
|
|
12250
|
+
*
|
|
12251
|
+
* 1. Token values are set for an HTMLElement.
|
|
12252
|
+
* 2. The HTMLElement does not inherit from FASTElement.
|
|
12253
|
+
*
|
|
12254
|
+
* @param element - The element to notify
|
|
12255
|
+
* @returns - true if notification was successful, otherwise false.
|
|
12256
|
+
*/
|
|
12257
|
+
notifyDisconnection(element) {
|
|
12258
|
+
if (element.isConnected || !DesignTokenNode.existsFor(element)) {
|
|
12259
|
+
return false;
|
|
12260
|
+
}
|
|
12261
|
+
|
|
12262
|
+
DesignTokenNode.getOrCreate(element).unbind();
|
|
12263
|
+
return true;
|
|
12264
|
+
},
|
|
12265
|
+
|
|
12266
|
+
/**
|
|
12267
|
+
* Registers and element or document as a DesignToken root.
|
|
12268
|
+
* {@link CSSDesignToken | CSSDesignTokens} with default values assigned via
|
|
12269
|
+
* {@link (DesignToken:interface).withDefault} will emit CSS custom properties to all
|
|
12270
|
+
* registered roots.
|
|
12271
|
+
* @param target - The root to register
|
|
12272
|
+
*/
|
|
12273
|
+
registerRoot(target = defaultElement) {
|
|
12274
|
+
RootStyleSheetTarget.registerRoot(target);
|
|
12275
|
+
},
|
|
12276
|
+
|
|
12277
|
+
/**
|
|
12278
|
+
* Unregister an element or document as a DesignToken root.
|
|
12279
|
+
* @param target - The root to deregister
|
|
12280
|
+
*/
|
|
12281
|
+
unregisterRoot(target = defaultElement) {
|
|
12282
|
+
RootStyleSheetTarget.unregisterRoot(target);
|
|
12283
|
+
}
|
|
12284
|
+
|
|
12285
|
+
});
|
|
12286
|
+
|
|
12287
|
+
/**
|
|
12288
|
+
* Indicates what to do with an ambiguous (duplicate) element.
|
|
12289
|
+
* @public
|
|
12290
|
+
*/
|
|
12291
|
+
|
|
12292
|
+
const ElementDisambiguation = Object.freeze({
|
|
12293
|
+
/**
|
|
12294
|
+
* Skip defining the element but still call the provided callback passed
|
|
12295
|
+
* to DesignSystemRegistrationContext.tryDefineElement
|
|
12296
|
+
*/
|
|
12297
|
+
definitionCallbackOnly: null,
|
|
12298
|
+
|
|
12299
|
+
/**
|
|
12300
|
+
* Ignore the duplicate element entirely.
|
|
12301
|
+
*/
|
|
12302
|
+
ignoreDuplicate: Symbol()
|
|
12303
|
+
});
|
|
12304
|
+
const elementTypesByTag = new Map();
|
|
12305
|
+
const elementTagsByType = new Map();
|
|
12306
|
+
let rootDesignSystem = null;
|
|
12307
|
+
const designSystemKey = DI.createInterface(x => x.cachedCallback(handler => {
|
|
12308
|
+
if (rootDesignSystem === null) {
|
|
12309
|
+
rootDesignSystem = new DefaultDesignSystem(null, handler);
|
|
12310
|
+
}
|
|
12311
|
+
|
|
12312
|
+
return rootDesignSystem;
|
|
12313
|
+
}));
|
|
12314
|
+
/**
|
|
12315
|
+
* An API gateway to design system features.
|
|
12316
|
+
* @public
|
|
12317
|
+
*/
|
|
12318
|
+
|
|
12319
|
+
const DesignSystem = Object.freeze({
|
|
12320
|
+
/**
|
|
12321
|
+
* Returns the HTML element name that the type is defined as.
|
|
12322
|
+
* @param type - The type to lookup.
|
|
12323
|
+
* @public
|
|
12324
|
+
*/
|
|
12325
|
+
tagFor(type) {
|
|
12326
|
+
return elementTagsByType.get(type);
|
|
12327
|
+
},
|
|
12328
|
+
|
|
12329
|
+
/**
|
|
12330
|
+
* Searches the DOM hierarchy for the design system that is responsible
|
|
12331
|
+
* for the provided element.
|
|
12332
|
+
* @param element - The element to locate the design system for.
|
|
12333
|
+
* @returns The located design system.
|
|
12334
|
+
* @public
|
|
12335
|
+
*/
|
|
12336
|
+
responsibleFor(element) {
|
|
12337
|
+
const owned = element.$$designSystem$$;
|
|
12338
|
+
|
|
12339
|
+
if (owned) {
|
|
12340
|
+
return owned;
|
|
12341
|
+
}
|
|
12342
|
+
|
|
12343
|
+
const container = DI.findResponsibleContainer(element);
|
|
12344
|
+
return container.get(designSystemKey);
|
|
12345
|
+
},
|
|
12346
|
+
|
|
12347
|
+
/**
|
|
12348
|
+
* Gets the DesignSystem if one is explicitly defined on the provided element;
|
|
12349
|
+
* otherwise creates a design system defined directly on the element.
|
|
12350
|
+
* @param element - The element to get or create a design system for.
|
|
12351
|
+
* @returns The design system.
|
|
12352
|
+
* @public
|
|
12353
|
+
*/
|
|
12354
|
+
getOrCreate(node) {
|
|
12355
|
+
if (!node) {
|
|
12356
|
+
if (rootDesignSystem === null) {
|
|
12357
|
+
rootDesignSystem = DI.getOrCreateDOMContainer().get(designSystemKey);
|
|
12358
|
+
}
|
|
12359
|
+
|
|
12360
|
+
return rootDesignSystem;
|
|
12361
|
+
}
|
|
12362
|
+
|
|
12363
|
+
const owned = node.$$designSystem$$;
|
|
12364
|
+
|
|
12365
|
+
if (owned) {
|
|
12366
|
+
return owned;
|
|
12367
|
+
}
|
|
12368
|
+
|
|
12369
|
+
const container = DI.getOrCreateDOMContainer(node);
|
|
12370
|
+
|
|
12371
|
+
if (container.has(designSystemKey, false)) {
|
|
12372
|
+
return container.get(designSystemKey);
|
|
12373
|
+
} else {
|
|
12374
|
+
const system = new DefaultDesignSystem(node, container);
|
|
12375
|
+
container.register(Registration.instance(designSystemKey, system));
|
|
12376
|
+
return system;
|
|
12377
|
+
}
|
|
12378
|
+
}
|
|
12379
|
+
|
|
12380
|
+
});
|
|
12381
|
+
|
|
12382
|
+
function extractTryDefineElementParams(params, elementDefinitionType, elementDefinitionCallback) {
|
|
12383
|
+
if (typeof params === "string") {
|
|
12384
|
+
return {
|
|
12385
|
+
name: params,
|
|
12386
|
+
type: elementDefinitionType,
|
|
12387
|
+
callback: elementDefinitionCallback
|
|
12388
|
+
};
|
|
12389
|
+
} else {
|
|
12390
|
+
return params;
|
|
12391
|
+
}
|
|
12392
|
+
}
|
|
12393
|
+
|
|
12394
|
+
class DefaultDesignSystem {
|
|
12395
|
+
constructor(owner, container) {
|
|
12396
|
+
this.owner = owner;
|
|
12397
|
+
this.container = container;
|
|
12398
|
+
this.designTokensInitialized = false;
|
|
12399
|
+
this.prefix = "fast";
|
|
12400
|
+
this.shadowRootMode = undefined;
|
|
12401
|
+
|
|
12402
|
+
this.disambiguate = () => ElementDisambiguation.definitionCallbackOnly;
|
|
12403
|
+
|
|
12404
|
+
if (owner !== null) {
|
|
12405
|
+
owner.$$designSystem$$ = this;
|
|
12406
|
+
}
|
|
12407
|
+
}
|
|
12226
12408
|
|
|
12409
|
+
withPrefix(prefix) {
|
|
12410
|
+
this.prefix = prefix;
|
|
12411
|
+
return this;
|
|
12412
|
+
}
|
|
12227
12413
|
|
|
12228
|
-
|
|
12229
|
-
|
|
12414
|
+
withShadowRootMode(mode) {
|
|
12415
|
+
this.shadowRootMode = mode;
|
|
12416
|
+
return this;
|
|
12230
12417
|
}
|
|
12231
|
-
/**
|
|
12232
|
-
* Handle changes to upstream tokens
|
|
12233
|
-
* @param source - The parent DesignTokenNode
|
|
12234
|
-
* @param property - The token ID that changed
|
|
12235
|
-
*/
|
|
12236
12418
|
|
|
12419
|
+
withElementDisambiguation(callback) {
|
|
12420
|
+
this.disambiguate = callback;
|
|
12421
|
+
return this;
|
|
12422
|
+
}
|
|
12237
12423
|
|
|
12238
|
-
|
|
12239
|
-
|
|
12424
|
+
withDesignTokenRoot(root) {
|
|
12425
|
+
this.designTokenRoot = root;
|
|
12426
|
+
return this;
|
|
12427
|
+
}
|
|
12240
12428
|
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12429
|
+
register(...registrations) {
|
|
12430
|
+
const container = this.container;
|
|
12431
|
+
const elementDefinitionEntries = [];
|
|
12432
|
+
const disambiguate = this.disambiguate;
|
|
12433
|
+
const shadowRootMode = this.shadowRootMode;
|
|
12434
|
+
const context = {
|
|
12435
|
+
elementPrefix: this.prefix,
|
|
12244
12436
|
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12437
|
+
tryDefineElement(params, elementDefinitionType, elementDefinitionCallback) {
|
|
12438
|
+
const extractedParams = extractTryDefineElementParams(params, elementDefinitionType, elementDefinitionCallback);
|
|
12439
|
+
const {
|
|
12440
|
+
name,
|
|
12441
|
+
callback,
|
|
12442
|
+
baseClass
|
|
12443
|
+
} = extractedParams;
|
|
12444
|
+
let {
|
|
12445
|
+
type
|
|
12446
|
+
} = extractedParams;
|
|
12447
|
+
let elementName = name;
|
|
12448
|
+
let typeFoundByName = elementTypesByTag.get(elementName);
|
|
12449
|
+
let needsDefine = true;
|
|
12252
12450
|
|
|
12451
|
+
while (typeFoundByName) {
|
|
12452
|
+
const result = disambiguate(elementName, type, typeFoundByName);
|
|
12253
12453
|
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
|
|
12454
|
+
switch (result) {
|
|
12455
|
+
case ElementDisambiguation.ignoreDuplicate:
|
|
12456
|
+
return;
|
|
12257
12457
|
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12458
|
+
case ElementDisambiguation.definitionCallbackOnly:
|
|
12459
|
+
needsDefine = false;
|
|
12460
|
+
typeFoundByName = void 0;
|
|
12461
|
+
break;
|
|
12462
|
+
|
|
12463
|
+
default:
|
|
12464
|
+
elementName = result;
|
|
12465
|
+
typeFoundByName = elementTypesByTag.get(elementName);
|
|
12466
|
+
break;
|
|
12265
12467
|
}
|
|
12266
|
-
} else {
|
|
12267
|
-
this.setupBindingObserver(token, value);
|
|
12268
12468
|
}
|
|
12269
|
-
|
|
12270
|
-
if (
|
|
12271
|
-
|
|
12469
|
+
|
|
12470
|
+
if (needsDefine) {
|
|
12471
|
+
if (elementTagsByType.has(type) || type === FoundationElement) {
|
|
12472
|
+
type = class extends type {};
|
|
12473
|
+
}
|
|
12474
|
+
|
|
12475
|
+
elementTypesByTag.set(elementName, type);
|
|
12476
|
+
elementTagsByType.set(type, elementName);
|
|
12477
|
+
|
|
12478
|
+
if (baseClass) {
|
|
12479
|
+
elementTagsByType.set(baseClass, elementName);
|
|
12480
|
+
}
|
|
12272
12481
|
}
|
|
12273
12482
|
|
|
12274
|
-
|
|
12483
|
+
elementDefinitionEntries.push(new ElementDefinitionEntry(container, elementName, type, shadowRootMode, callback, needsDefine));
|
|
12275
12484
|
}
|
|
12276
|
-
}
|
|
12277
|
-
}
|
|
12278
|
-
/**
|
|
12279
|
-
* Sets up a binding observer for a derived token value that notifies token
|
|
12280
|
-
* subscribers on change.
|
|
12281
|
-
*
|
|
12282
|
-
* @param token - The token to notify when the binding updates
|
|
12283
|
-
* @param source - The binding source
|
|
12284
|
-
*/
|
|
12285
|
-
|
|
12286
12485
|
|
|
12287
|
-
|
|
12288
|
-
const binding = new DesignTokenBindingObserver(source, token, this);
|
|
12289
|
-
this.bindingObservers.set(token, binding);
|
|
12290
|
-
return binding;
|
|
12291
|
-
}
|
|
12292
|
-
/**
|
|
12293
|
-
* Tear down a binding observer for a token.
|
|
12294
|
-
*/
|
|
12486
|
+
};
|
|
12295
12487
|
|
|
12488
|
+
if (!this.designTokensInitialized) {
|
|
12489
|
+
this.designTokensInitialized = true;
|
|
12296
12490
|
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
this.bindingObservers.delete(token);
|
|
12301
|
-
return true;
|
|
12491
|
+
if (this.designTokenRoot !== null) {
|
|
12492
|
+
DesignToken.registerRoot(this.designTokenRoot);
|
|
12493
|
+
}
|
|
12302
12494
|
}
|
|
12303
12495
|
|
|
12304
|
-
|
|
12305
|
-
}
|
|
12306
|
-
|
|
12307
|
-
}
|
|
12308
|
-
/**
|
|
12309
|
-
* Responsible for reflecting tokens to CSS custom properties
|
|
12310
|
-
*/
|
|
12496
|
+
container.registerWithContext(context, ...registrations);
|
|
12311
12497
|
|
|
12498
|
+
for (const entry of elementDefinitionEntries) {
|
|
12499
|
+
entry.callback(entry);
|
|
12312
12500
|
|
|
12313
|
-
|
|
12501
|
+
if (entry.willDefine && entry.definition !== null) {
|
|
12502
|
+
entry.definition.define();
|
|
12503
|
+
}
|
|
12504
|
+
}
|
|
12314
12505
|
|
|
12315
|
-
|
|
12506
|
+
return this;
|
|
12507
|
+
}
|
|
12316
12508
|
|
|
12317
|
-
function create$1(nameOrConfig) {
|
|
12318
|
-
return DesignTokenImpl.from(nameOrConfig);
|
|
12319
12509
|
}
|
|
12320
|
-
/**
|
|
12321
|
-
* Factory object for creating {@link (DesignToken:interface)} instances.
|
|
12322
|
-
* @public
|
|
12323
|
-
*/
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
const DesignToken = Object.freeze({
|
|
12327
|
-
create: create$1,
|
|
12328
12510
|
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
*
|
|
12340
|
-
* @param element - The element to notify
|
|
12341
|
-
* @returns - true if notification was successful, otherwise false.
|
|
12342
|
-
*/
|
|
12343
|
-
notifyConnection(element) {
|
|
12344
|
-
if (!element.isConnected || !DesignTokenNode.existsFor(element)) {
|
|
12345
|
-
return false;
|
|
12346
|
-
}
|
|
12511
|
+
class ElementDefinitionEntry {
|
|
12512
|
+
constructor(container, name, type, shadowRootMode, callback, willDefine) {
|
|
12513
|
+
this.container = container;
|
|
12514
|
+
this.name = name;
|
|
12515
|
+
this.type = type;
|
|
12516
|
+
this.shadowRootMode = shadowRootMode;
|
|
12517
|
+
this.callback = callback;
|
|
12518
|
+
this.willDefine = willDefine;
|
|
12519
|
+
this.definition = null;
|
|
12520
|
+
}
|
|
12347
12521
|
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
}
|
|
12522
|
+
definePresentation(presentation) {
|
|
12523
|
+
ComponentPresentation.define(this.name, presentation, this.container);
|
|
12524
|
+
}
|
|
12351
12525
|
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
* in all scenarios, so invoking this method manually is necessary when:
|
|
12358
|
-
*
|
|
12359
|
-
* 1. Token values are set for an HTMLElement.
|
|
12360
|
-
* 2. The HTMLElement does not inherit from FASTElement.
|
|
12361
|
-
*
|
|
12362
|
-
* @param element - The element to notify
|
|
12363
|
-
* @returns - true if notification was successful, otherwise false.
|
|
12364
|
-
*/
|
|
12365
|
-
notifyDisconnection(element) {
|
|
12366
|
-
if (element.isConnected || !DesignTokenNode.existsFor(element)) {
|
|
12367
|
-
return false;
|
|
12368
|
-
}
|
|
12526
|
+
defineElement(definition) {
|
|
12527
|
+
this.definition = new FASTElementDefinition(this.type, Object.assign(Object.assign({}, definition), {
|
|
12528
|
+
name: this.name
|
|
12529
|
+
}));
|
|
12530
|
+
}
|
|
12369
12531
|
|
|
12370
|
-
|
|
12371
|
-
return
|
|
12532
|
+
tagFor(type) {
|
|
12533
|
+
return DesignSystem.tagFor(type);
|
|
12372
12534
|
}
|
|
12373
12535
|
|
|
12374
|
-
}
|
|
12536
|
+
}
|
|
12375
12537
|
|
|
12376
12538
|
/**
|
|
12377
12539
|
* The template for the {@link @microsoft/fast-foundation#Dialog} component.
|
|
@@ -13663,7 +13825,7 @@ __decorate$1([observable], Menu.prototype, "items", void 0);
|
|
|
13663
13825
|
* @public
|
|
13664
13826
|
*/
|
|
13665
13827
|
|
|
13666
|
-
const numberFieldTemplate = (context, definition) => html`<template class="${x => x.readOnly ? "readonly" : ""}"><label part="label" for="control" class="${x => x.defaultSlottedNodes && x.defaultSlottedNodes.length ? "label" : "label label__hidden"}"><slot ${slotted("defaultSlottedNodes")}></slot></label><div class="root" part="root">${startSlotTemplate(context, definition)}<input class="control" part="control" id="control" @input="${x => x.handleTextInput()}" @change="${x => x.handleChange()}" @keydown="${(x, c) => x.handleKeyDown(c.event)}" ?autofocus="${x => x.autofocus}" ?disabled="${x => x.disabled}" list="${x => x.list}" maxlength="${x => x.maxlength}" minlength="${x => x.minlength}" placeholder="${x => x.placeholder}" ?readonly="${x => x.readOnly}" ?required="${x => x.required}" size="${x => x.size}"
|
|
13828
|
+
const numberFieldTemplate = (context, definition) => html`<template class="${x => x.readOnly ? "readonly" : ""}"><label part="label" for="control" class="${x => x.defaultSlottedNodes && x.defaultSlottedNodes.length ? "label" : "label label__hidden"}"><slot ${slotted("defaultSlottedNodes")}></slot></label><div class="root" part="root">${startSlotTemplate(context, definition)}<input class="control" part="control" id="control" @input="${x => x.handleTextInput()}" @change="${x => x.handleChange()}" @keydown="${(x, c) => x.handleKeyDown(c.event)}" @blur="${(x, c) => x.handleBlur()}" ?autofocus="${x => x.autofocus}" ?disabled="${x => x.disabled}" list="${x => x.list}" maxlength="${x => x.maxlength}" minlength="${x => x.minlength}" placeholder="${x => x.placeholder}" ?readonly="${x => x.readOnly}" ?required="${x => x.required}" size="${x => x.size}" type="text" inputmode="numeric" min="${x => x.min}" max="${x => x.max}" step="${x => x.step}" aria-atomic="${x => x.ariaAtomic}" aria-busy="${x => x.ariaBusy}" aria-controls="${x => x.ariaControls}" aria-current="${x => x.ariaCurrent}" aria-describedby="${x => x.ariaDescribedby}" aria-details="${x => x.ariaDetails}" aria-disabled="${x => x.ariaDisabled}" aria-errormessage="${x => x.ariaErrormessage}" aria-flowto="${x => x.ariaFlowto}" aria-haspopup="${x => x.ariaHaspopup}" aria-hidden="${x => x.ariaHidden}" aria-invalid="${x => x.ariaInvalid}" aria-keyshortcuts="${x => x.ariaKeyshortcuts}" aria-label="${x => x.ariaLabel}" aria-labelledby="${x => x.ariaLabelledby}" aria-live="${x => x.ariaLive}" aria-owns="${x => x.ariaOwns}" aria-relevant="${x => x.ariaRelevant}" aria-roledescription="${x => x.ariaRoledescription}" ${ref("control")} />${when(x => !x.hideStep && !x.readOnly && !x.disabled, html`<div class="controls" part="controls"><div class="step-up" part="step-up" @click="${x => x.stepUp()}"><slot name="step-up-glyph">${definition.stepUpGlyph || ""}</slot></div><div class="step-down" part="step-down" @click="${x => x.stepDown()}"><slot name="step-down-glyph">${definition.stepDownGlyph || ""}</slot></div></div>`)} ${endSlotTemplate(context, definition)}</div></template>`;
|
|
13667
13829
|
|
|
13668
13830
|
/**
|
|
13669
13831
|
* The template for the {@link @microsoft/fast-foundation#(TextField:class)} component.
|
|
@@ -13939,42 +14101,32 @@ class NumberField$1 extends FormAssociatedNumberField {
|
|
|
13939
14101
|
*/
|
|
13940
14102
|
|
|
13941
14103
|
this.step = 1;
|
|
13942
|
-
/**
|
|
13943
|
-
* Display text used in the input field
|
|
13944
|
-
* @public
|
|
13945
|
-
*/
|
|
13946
|
-
|
|
13947
|
-
this.displayText = "";
|
|
13948
14104
|
}
|
|
13949
14105
|
|
|
13950
14106
|
maxChanged(previousValue, nextValue) {
|
|
13951
|
-
|
|
14107
|
+
var _a;
|
|
13952
14108
|
|
|
13953
|
-
|
|
13954
|
-
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
this.max = numb;
|
|
13959
|
-
}
|
|
14109
|
+
this.max = Math.max(nextValue, (_a = this.min) !== null && _a !== void 0 ? _a : nextValue);
|
|
14110
|
+
const min = Math.min(this.min, this.max);
|
|
14111
|
+
|
|
14112
|
+
if (this.min !== undefined && this.min !== min) {
|
|
14113
|
+
this.min = min;
|
|
13960
14114
|
}
|
|
13961
14115
|
|
|
13962
|
-
this.
|
|
14116
|
+
this.valueChanged(this.value, this.value);
|
|
13963
14117
|
}
|
|
13964
14118
|
|
|
13965
14119
|
minChanged(previousValue, nextValue) {
|
|
13966
|
-
|
|
14120
|
+
var _a;
|
|
13967
14121
|
|
|
13968
|
-
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
13973
|
-
this.min = numb;
|
|
13974
|
-
}
|
|
14122
|
+
this.min = Math.min(nextValue, (_a = this.max) !== null && _a !== void 0 ? _a : nextValue);
|
|
14123
|
+
const max = Math.max(this.min, this.max);
|
|
14124
|
+
|
|
14125
|
+
if (this.max !== undefined && this.max !== max) {
|
|
14126
|
+
this.max = max;
|
|
13975
14127
|
}
|
|
13976
14128
|
|
|
13977
|
-
this.
|
|
14129
|
+
this.valueChanged(this.value, this.value);
|
|
13978
14130
|
}
|
|
13979
14131
|
/**
|
|
13980
14132
|
*
|
|
@@ -13984,39 +14136,24 @@ class NumberField$1 extends FormAssociatedNumberField {
|
|
|
13984
14136
|
|
|
13985
14137
|
|
|
13986
14138
|
valueChanged(previousValue, nextValue) {
|
|
13987
|
-
|
|
13988
|
-
this.updateValue(nextValue);
|
|
13989
|
-
}
|
|
13990
|
-
/**
|
|
13991
|
-
* Updates the value. Validates that it's a number, between the min
|
|
13992
|
-
* and max, updates the proxy and emits events.
|
|
13993
|
-
*
|
|
13994
|
-
* @param value - value to be validated
|
|
13995
|
-
* @internal
|
|
13996
|
-
*/
|
|
14139
|
+
var _a, _b;
|
|
13997
14140
|
|
|
14141
|
+
let value = parseFloat(nextValue);
|
|
13998
14142
|
|
|
13999
|
-
|
|
14000
|
-
if (value === "" || isNaN(parseFloat(value))) {
|
|
14143
|
+
if (isNaN(value)) {
|
|
14001
14144
|
value = "";
|
|
14002
14145
|
} else {
|
|
14003
|
-
value =
|
|
14004
|
-
|
|
14005
|
-
if (this.min !== undefined && value < this.min) {
|
|
14006
|
-
value = this.min;
|
|
14007
|
-
} else if (this.max !== undefined && value > this.max) {
|
|
14008
|
-
value = this.max;
|
|
14009
|
-
}
|
|
14010
|
-
|
|
14011
|
-
value = parseFloat(value.toPrecision(12));
|
|
14146
|
+
value = Math.min(value, (_a = this.max) !== null && _a !== void 0 ? _a : value);
|
|
14147
|
+
value = Math.max(value, (_b = this.min) !== null && _b !== void 0 ? _b : value);
|
|
14012
14148
|
}
|
|
14013
14149
|
|
|
14150
|
+
this.value = value.toString();
|
|
14151
|
+
|
|
14014
14152
|
if (this.proxy instanceof HTMLInputElement) {
|
|
14015
|
-
this.proxy.value = value;
|
|
14153
|
+
this.proxy.value = this.value;
|
|
14016
14154
|
}
|
|
14017
14155
|
|
|
14018
|
-
if (
|
|
14019
|
-
this.value = value.toString();
|
|
14156
|
+
if (previousValue !== undefined) {
|
|
14020
14157
|
this.$emit("input");
|
|
14021
14158
|
this.$emit("change");
|
|
14022
14159
|
}
|
|
@@ -14029,8 +14166,12 @@ class NumberField$1 extends FormAssociatedNumberField {
|
|
|
14029
14166
|
|
|
14030
14167
|
|
|
14031
14168
|
stepUp() {
|
|
14032
|
-
|
|
14033
|
-
|
|
14169
|
+
var _a;
|
|
14170
|
+
|
|
14171
|
+
const value = parseFloat(this.value);
|
|
14172
|
+
const stepUpValue = isNaN(value) ? (_a = this.min) !== null && _a !== void 0 ? _a : this.step : value + this.step;
|
|
14173
|
+
this.value = stepUpValue.toString();
|
|
14174
|
+
this.control.value = this.value;
|
|
14034
14175
|
}
|
|
14035
14176
|
/**
|
|
14036
14177
|
* Decrements the value using the step value
|
|
@@ -14040,8 +14181,12 @@ class NumberField$1 extends FormAssociatedNumberField {
|
|
|
14040
14181
|
|
|
14041
14182
|
|
|
14042
14183
|
stepDown() {
|
|
14043
|
-
|
|
14044
|
-
|
|
14184
|
+
var _a;
|
|
14185
|
+
|
|
14186
|
+
const value = parseFloat(this.value);
|
|
14187
|
+
const stepDownValue = isNaN(value) ? (_a = this.max) !== null && _a !== void 0 ? _a : 0 - this.step : value - this.step;
|
|
14188
|
+
this.value = stepDownValue.toString();
|
|
14189
|
+
this.control.value = this.value;
|
|
14045
14190
|
}
|
|
14046
14191
|
/**
|
|
14047
14192
|
* @internal
|
|
@@ -14050,9 +14195,9 @@ class NumberField$1 extends FormAssociatedNumberField {
|
|
|
14050
14195
|
|
|
14051
14196
|
connectedCallback() {
|
|
14052
14197
|
super.connectedCallback();
|
|
14053
|
-
this.displayText = this.value;
|
|
14054
14198
|
this.proxy.setAttribute("type", "number");
|
|
14055
14199
|
this.validate();
|
|
14200
|
+
this.control.value = this.value;
|
|
14056
14201
|
|
|
14057
14202
|
if (this.autofocus) {
|
|
14058
14203
|
DOM.queueUpdate(() => {
|
|
@@ -14067,6 +14212,7 @@ class NumberField$1 extends FormAssociatedNumberField {
|
|
|
14067
14212
|
|
|
14068
14213
|
|
|
14069
14214
|
handleTextInput() {
|
|
14215
|
+
this.control.value = this.control.value.replace(/[^0-9\-+e.]/g, "");
|
|
14070
14216
|
this.value = this.control.value;
|
|
14071
14217
|
}
|
|
14072
14218
|
/**
|
|
@@ -14104,6 +14250,16 @@ class NumberField$1 extends FormAssociatedNumberField {
|
|
|
14104
14250
|
|
|
14105
14251
|
return true;
|
|
14106
14252
|
}
|
|
14253
|
+
/**
|
|
14254
|
+
* Handles populating the input field with a validated value when
|
|
14255
|
+
* leaving the input field.
|
|
14256
|
+
* @internal
|
|
14257
|
+
*/
|
|
14258
|
+
|
|
14259
|
+
|
|
14260
|
+
handleBlur() {
|
|
14261
|
+
this.control.value = this.value;
|
|
14262
|
+
}
|
|
14107
14263
|
|
|
14108
14264
|
}
|
|
14109
14265
|
|
|
@@ -14149,8 +14305,6 @@ __decorate$1([attr({
|
|
|
14149
14305
|
converter: nullableNumberConverter
|
|
14150
14306
|
})], NumberField$1.prototype, "min", void 0);
|
|
14151
14307
|
|
|
14152
|
-
__decorate$1([observable], NumberField$1.prototype, "displayText", void 0);
|
|
14153
|
-
|
|
14154
14308
|
__decorate$1([observable], NumberField$1.prototype, "defaultSlottedNodes", void 0);
|
|
14155
14309
|
|
|
14156
14310
|
applyMixins(NumberField$1, StartEnd, DelegatesARIATextbox);
|
|
@@ -17716,6 +17870,11 @@ class Tooltip$1 extends FoundationElement {
|
|
|
17716
17870
|
this.showTooltip();
|
|
17717
17871
|
return;
|
|
17718
17872
|
} else {
|
|
17873
|
+
if (this.isAnchorHoveredFocused) {
|
|
17874
|
+
this.showTooltip();
|
|
17875
|
+
return;
|
|
17876
|
+
}
|
|
17877
|
+
|
|
17719
17878
|
this.hideTooltip();
|
|
17720
17879
|
}
|
|
17721
17880
|
};
|