@genesislcap/web-core 14.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/cjs/FAST/fast-colors.js +7 -0
- package/dist/cjs/FAST/fast-components.js +4 -0
- package/dist/cjs/FAST/fast-element.js +30 -0
- package/dist/cjs/FAST/fast-foundation.js +64 -0
- package/dist/cjs/FAST/fast-router.js +11 -0
- package/dist/cjs/FAST/fast-web-utilities.js +11 -0
- package/dist/cjs/FAST/index.js +9 -0
- package/dist/cjs/directives/index.js +5 -0
- package/dist/cjs/directives/sync.js +101 -0
- package/dist/cjs/directives/when-else.js +18 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/patterns/define.js +41 -0
- package/dist/cjs/patterns/index.js +5 -0
- package/dist/cjs/patterns/tag-for.js +24 -0
- package/dist/dts/FAST/fast-colors.d.ts +2 -0
- package/dist/dts/FAST/fast-colors.d.ts.map +1 -0
- package/dist/dts/FAST/fast-components.d.ts +2 -0
- package/dist/dts/FAST/fast-components.d.ts.map +1 -0
- package/dist/dts/FAST/fast-element.d.ts +2 -0
- package/dist/dts/FAST/fast-element.d.ts.map +1 -0
- package/dist/dts/FAST/fast-foundation.d.ts +2 -0
- package/dist/dts/FAST/fast-foundation.d.ts.map +1 -0
- package/dist/dts/FAST/fast-router.d.ts +2 -0
- package/dist/dts/FAST/fast-router.d.ts.map +1 -0
- package/dist/dts/FAST/fast-web-utilities.d.ts +2 -0
- package/dist/dts/FAST/fast-web-utilities.d.ts.map +1 -0
- package/dist/dts/FAST/index.d.ts +7 -0
- package/dist/dts/FAST/index.d.ts.map +1 -0
- package/dist/dts/directives/index.d.ts +3 -0
- package/dist/dts/directives/index.d.ts.map +1 -0
- package/dist/dts/directives/sync.d.ts +22 -0
- package/dist/dts/directives/sync.d.ts.map +1 -0
- package/dist/dts/directives/when-else.d.ts +13 -0
- package/dist/dts/directives/when-else.d.ts.map +1 -0
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/patterns/define.d.ts +39 -0
- package/dist/dts/patterns/define.d.ts.map +1 -0
- package/dist/dts/patterns/index.d.ts +3 -0
- package/dist/dts/patterns/index.d.ts.map +1 -0
- package/dist/dts/patterns/tag-for.d.ts +21 -0
- package/dist/dts/patterns/tag-for.d.ts.map +1 -0
- package/dist/dts/tsdoc-metadata.json +11 -0
- package/dist/esm/FAST/fast-colors.js +1 -0
- package/dist/esm/FAST/fast-components.js +1 -0
- package/dist/esm/FAST/fast-element.js +1 -0
- package/dist/esm/FAST/fast-foundation.js +1 -0
- package/dist/esm/FAST/fast-router.js +1 -0
- package/dist/esm/FAST/fast-web-utilities.js +1 -0
- package/dist/esm/FAST/index.js +6 -0
- package/dist/esm/directives/index.js +2 -0
- package/dist/esm/directives/sync.js +97 -0
- package/dist/esm/directives/when-else.js +14 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/patterns/define.js +37 -0
- package/dist/esm/patterns/index.js +2 -0
- package/dist/esm/patterns/tag-for.js +20 -0
- package/dist/web-core.api.json +863 -0
- package/dist/web-core.d.ts +526 -0
- package/docs/.gitattributes +2 -0
- package/docs/api/index.md +12 -0
- package/docs/api/web-core.conversiontype.md +13 -0
- package/docs/api/web-core.defaulteventmap.md +13 -0
- package/docs/api/web-core.definefactory.md +41 -0
- package/docs/api/web-core.definefunction.md +15 -0
- package/docs/api/web-core.definitionoverrider.md +15 -0
- package/docs/api/web-core.eventname.md +13 -0
- package/docs/api/web-core.md +32 -0
- package/docs/api/web-core.sync.md +27 -0
- package/docs/api/web-core.tagfor.md +29 -0
- package/docs/api/web-core.templateelementdependency.md +16 -0
- package/docs/api/web-core.templateelements.md +20 -0
- package/docs/api/web-core.whenelse.md +26 -0
- package/docs/api-report.md +473 -0
- package/license.txt +46 -0
- package/package.json +39 -0
- package/tsconfig.cjs.json +10 -0
- package/tsdoc.json +20 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Constructable, FASTElement, FASTElementDefinition } from '@microsoft/fast-element';
|
|
2
|
+
/**
|
|
3
|
+
* Used to designate a template's dependency on another custom element.
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
export type TemplateElementDependency = string | FASTElementDefinition | Constructable<FASTElement>;
|
|
7
|
+
/**
|
|
8
|
+
* Used to help map components / elements for tagFor usage
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export type TemplateElements = {
|
|
12
|
+
[key: string]: TemplateElementDependency;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Determines what HTML tag name to use for the dependency.
|
|
16
|
+
* @param dependency - The dependency the template is dependent on.
|
|
17
|
+
* @returns The tag name to use in markup.
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export declare function tagFor(dependency: TemplateElementDependency): string;
|
|
21
|
+
//# sourceMappingURL=tag-for.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-for.d.ts","sourceRoot":"","sources":["../../../src/patterns/tag-for.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAE5F;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,qBAAqB,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAEpG;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAA;CAAE,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,yBAAyB,GAAG,MAAM,CAcpE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.34.9"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorRGBA64, ComponentStateColorPalette, parseColorHexRGB } from '@microsoft/fast-colors';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@microsoft/fast-components';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { attr, BindingBehavior, children, css, CSSDirective, cssPartial, customElement, defaultExecutionContext, DOM, elements, ElementStyles, ExecutionContext, FASTElement, FASTElementDefinition, html, HTMLBindingDirective, HTMLView, nullableNumberConverter, Observable, observable, ref, repeat, slotted, ViewTemplate, volatile, when, } from '@microsoft/fast-element';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { accordionItemTemplate, accordionTemplate, anchorTemplate, anchoredRegionTemplate, avatarTemplate, badgeTemplate, breadcrumbItemTemplate, breadcrumbTemplate, buttonTemplate, calendarTemplate, cardTemplate, checkboxTemplate, composedParent, ComboboxAutocomplete, Container, dataGridTemplate, dataGridCellTemplate, dataGridRowTemplate, DesignSystem, DesignToken, DI, disclosureTemplate, display, dividerTemplate, endSlotTemplate, flipperTemplate, FoundationElement, FoundationElementRegistry, forcedColorsStylesheetBehavior, FormAssociated, horizontalScrollTemplate, inject, listboxTemplate, listboxOptionTemplate, menuTemplate, menuItemTemplate, optional, progressTemplate, progressRingTemplate, PropertyStyleSheetBehavior, Registration, radioTemplate, radioGroupTemplate, selectTemplate, skeletonTemplate, sliderLabelTemplate, startSlotTemplate, switchTemplate, tabTemplate, tabPanelTemplate, tabsTemplate, TabsOrientation, textAreaTemplate, toolbarTemplate, TooltipPosition, tooltipTemplate, treeItemTemplate, treeViewTemplate, whitespaceFilter, } from '@microsoft/fast-foundation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DefaultRouteRecognizer, FASTElementLayout, FASTRouter, Route, RouteCollection, Router, RouterConfiguration, } from '@microsoft/fast-router';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { classNames, Direction, limit, Orientation, pascalCase, SystemColors, uniqueId, } from '@microsoft/fast-web-utilities';
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { HTMLBindingDirective, } from '@microsoft/fast-element';
|
|
2
|
+
/**
|
|
3
|
+
* A map that associates specific HTML element tags with their corresponding default event names.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export const defaultEventMap = new Map([
|
|
7
|
+
['FAST-TEXT-AREA', 'input'],
|
|
8
|
+
['FAST-TEXT-FIELD', 'input'],
|
|
9
|
+
['FOUNDATION-TEXT-AREA', 'input'],
|
|
10
|
+
['FOUNDATION-TEXT-FIELD', 'input'],
|
|
11
|
+
['INPUT', 'input'],
|
|
12
|
+
['ZERO-TEXT-FIELD', 'input'],
|
|
13
|
+
]);
|
|
14
|
+
function customUpdateTarget(value) {
|
|
15
|
+
if (this['keyAttr']) {
|
|
16
|
+
// FUI-389: set initial state based on keyAttr
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.target[this.targetName] = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function bind(source, context) {
|
|
23
|
+
if (this['keyAttr']) {
|
|
24
|
+
// overwrite internal update method called by originalBind
|
|
25
|
+
this.updateTarget = customUpdateTarget;
|
|
26
|
+
}
|
|
27
|
+
this.originalBind.call(this, source, context);
|
|
28
|
+
this.target.addEventListener(this.changeEvent, this.changeHandler);
|
|
29
|
+
}
|
|
30
|
+
function unbind() {
|
|
31
|
+
this.originalUnbind.call(this);
|
|
32
|
+
this.target.removeEventListener(this.changeEvent, this.changeHandler);
|
|
33
|
+
}
|
|
34
|
+
function determineChangeEvent(target, eventName) {
|
|
35
|
+
var _a;
|
|
36
|
+
const tag = target.tagName;
|
|
37
|
+
if (eventName === 'default') {
|
|
38
|
+
return (_a = defaultEventMap.get(tag)) !== null && _a !== void 0 ? _a : 'change';
|
|
39
|
+
}
|
|
40
|
+
return eventName;
|
|
41
|
+
}
|
|
42
|
+
class SyncDirective extends HTMLBindingDirective {
|
|
43
|
+
constructor(binding, convert, eventName, keyAttr) {
|
|
44
|
+
super(binding);
|
|
45
|
+
this.keyAttr = keyAttr;
|
|
46
|
+
this.conversionType = convert;
|
|
47
|
+
this.eventName = eventName;
|
|
48
|
+
}
|
|
49
|
+
createBehavior(target) {
|
|
50
|
+
const behavior = super.createBehavior(target);
|
|
51
|
+
behavior.originalBind = behavior.bind;
|
|
52
|
+
behavior.originalUnbind = behavior.unbind;
|
|
53
|
+
behavior.keyAttr = this.keyAttr;
|
|
54
|
+
behavior.bind = bind;
|
|
55
|
+
behavior.unbind = unbind;
|
|
56
|
+
behavior.changeEvent = determineChangeEvent(target, this.eventName);
|
|
57
|
+
behavior.changeHandler = () => {
|
|
58
|
+
// for checkbox, which is currently the only component converting to boolean, will have to change if boolean conversion is used anywhere else
|
|
59
|
+
const value = this.conversionType === 'boolean' ? behavior.target.checked : behavior.target.value;
|
|
60
|
+
if (this.keyAttr) {
|
|
61
|
+
const last = behavior.bindingObserver.last;
|
|
62
|
+
const key = behavior.target[this.keyAttr];
|
|
63
|
+
last.propertySource[last.propertyName][key] = this.convert(value);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Wait for an official setValue API
|
|
67
|
+
const last = behavior.bindingObserver.last;
|
|
68
|
+
last.propertySource[last.propertyName] = this.convert(value);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return behavior;
|
|
72
|
+
}
|
|
73
|
+
convert(value) {
|
|
74
|
+
if (value === undefined || value === null)
|
|
75
|
+
return value;
|
|
76
|
+
switch (this.conversionType) {
|
|
77
|
+
case 'time':
|
|
78
|
+
const msSinceEpoch = new Date(value).getTime();
|
|
79
|
+
return isNaN(msSinceEpoch) ? undefined : msSinceEpoch;
|
|
80
|
+
case 'number':
|
|
81
|
+
return value.length ? Number(value) : undefined; // Number('') returns 0
|
|
82
|
+
case 'string':
|
|
83
|
+
return String(value);
|
|
84
|
+
case 'boolean':
|
|
85
|
+
return Boolean(value);
|
|
86
|
+
default:
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates a synchronization directive that binds a data source to an HTML element,
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export function sync(binding, conversionType = 'string', eventName = 'default', keyAttr) {
|
|
96
|
+
return new SyncDirective(binding, conversionType, eventName, keyAttr);
|
|
97
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directive that allows supplying an "else" template to the traditional {@link https://www.fast.design/docs/api/fast-element.when/#when-function} directive
|
|
3
|
+
*
|
|
4
|
+
* @param binding - The condition to test for rendering.
|
|
5
|
+
* @param trueTemplateOrTemplateBinding - The template or a binding that gets the template to render when the condition is true.
|
|
6
|
+
* @param falseTemplateOrTemplateBinding - The template or a binding that gets the template to render when the condition is false.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export function whenElse(binding, trueTemplateOrTemplateBinding, falseTemplateOrTemplateBinding) {
|
|
10
|
+
const getTemplate = (template) => typeof template === 'function' ? template : () => template;
|
|
11
|
+
const trueTemplate = getTemplate(trueTemplateOrTemplateBinding);
|
|
12
|
+
const falseTemplate = getTemplate(falseTemplateOrTemplateBinding);
|
|
13
|
+
return (source, context) => binding(source, context) ? trueTemplate(source, context) : falseTemplate(source, context);
|
|
14
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FASTElement } from '@microsoft/fast-element';
|
|
2
|
+
const defaultDefinitionOverrider = (base) => (override) => (Object.assign(Object.assign({}, base), override));
|
|
3
|
+
/**
|
|
4
|
+
* Defines a platform custom element based on the provided type and definition.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* An example using custom definition merge logic, useful if you need to impose hard restrictions.
|
|
8
|
+
* ```ts
|
|
9
|
+
* const definitionOverrider = (definition) => ({
|
|
10
|
+
* ...baseDefinition,
|
|
11
|
+
* ...definition,
|
|
12
|
+
* styles: baseDefinition.styles,
|
|
13
|
+
* shadowOptions: {
|
|
14
|
+
* mode: 'closed,
|
|
15
|
+
* },
|
|
16
|
+
* });
|
|
17
|
+
* export const define = defineFactory(LoginForm, definitionOverrider);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* You can provide the base definition if you're happy with the default spread operator merge logic.
|
|
22
|
+
* ```ts
|
|
23
|
+
* export const define = defineFactory(LoginForm, baseDefinition);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param Type - The custom element Type / Class to define.
|
|
27
|
+
* @param overriderOrBase - A function that merges definitions, or the base definition if custom merging is not needed.
|
|
28
|
+
* @returns The type class.
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
export const defineFactory = (Type, overriderOrBase) => (definition) => {
|
|
32
|
+
const overrider = typeof overriderOrBase === 'function'
|
|
33
|
+
? overriderOrBase
|
|
34
|
+
: defaultDefinitionOverrider(overriderOrBase);
|
|
35
|
+
return FASTElement.define(class extends Type {
|
|
36
|
+
}, overrider(definition));
|
|
37
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FASTElementDefinition } from '@microsoft/fast-element';
|
|
2
|
+
/**
|
|
3
|
+
* Determines what HTML tag name to use for the dependency.
|
|
4
|
+
* @param dependency - The dependency the template is dependent on.
|
|
5
|
+
* @returns The tag name to use in markup.
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export function tagFor(dependency) {
|
|
9
|
+
if (typeof dependency === 'string') {
|
|
10
|
+
return dependency;
|
|
11
|
+
}
|
|
12
|
+
if (typeof dependency === 'function') {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
14
|
+
dependency = FASTElementDefinition.forType(dependency); // < using forType instead of getByType for now...
|
|
15
|
+
if (!dependency) {
|
|
16
|
+
throw new Error('Missing FASTElement definition.');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return dependency.name;
|
|
20
|
+
}
|