@ni/nimble-components 11.8.5 → 11.9.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/dist/all-components-bundle.js +151 -41
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +219 -192
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/all-components.d.ts +1 -0
- package/dist/esm/all-components.js +1 -0
- package/dist/esm/all-components.js.map +1 -1
- package/dist/esm/dialog/index.d.ts +64 -0
- package/dist/esm/dialog/index.js +90 -0
- package/dist/esm/dialog/index.js.map +1 -0
- package/dist/esm/dialog/styles.d.ts +1 -0
- package/dist/esm/dialog/styles.js +14 -0
- package/dist/esm/dialog/styles.js.map +1 -0
- package/dist/esm/dialog/template.d.ts +2 -0
- package/dist/esm/dialog/template.js +15 -0
- package/dist/esm/dialog/template.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-components.js","sourceRoot":"","sources":["../../src/all-components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,CAAC;AAClB,OAAO,eAAe,CAAC;AACvB,OAAO,YAAY,CAAC;AACpB,OAAO,YAAY,CAAC;AACpB,OAAO,UAAU,CAAC;AAClB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,eAAe,CAAC;AACvB,OAAO,QAAQ,CAAC;AAChB,OAAO,eAAe,CAAC;AACvB,OAAO,aAAa,CAAC;AACrB,OAAO,gBAAgB,CAAC;AACxB,OAAO,UAAU,CAAC;AAClB,OAAO,UAAU,CAAC;AAClB,OAAO,OAAO,CAAC;AACf,OAAO,aAAa,CAAC;AACrB,OAAO,QAAQ,CAAC;AAChB,OAAO,gBAAgB,CAAC;AACxB,OAAO,aAAa,CAAC;AACrB,OAAO,cAAc,CAAC;AACtB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,iBAAiB,CAAC;AACzB,OAAO,WAAW,CAAC;AACnB,OAAO,WAAW,CAAC;AACnB,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"all-components.js","sourceRoot":"","sources":["../../src/all-components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,CAAC;AAClB,OAAO,eAAe,CAAC;AACvB,OAAO,YAAY,CAAC;AACpB,OAAO,YAAY,CAAC;AACpB,OAAO,UAAU,CAAC;AAClB,OAAO,UAAU,CAAC;AAClB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,eAAe,CAAC;AACvB,OAAO,QAAQ,CAAC;AAChB,OAAO,eAAe,CAAC;AACvB,OAAO,aAAa,CAAC;AACrB,OAAO,gBAAgB,CAAC;AACxB,OAAO,UAAU,CAAC;AAClB,OAAO,UAAU,CAAC;AAClB,OAAO,OAAO,CAAC;AACf,OAAO,aAAa,CAAC;AACrB,OAAO,QAAQ,CAAC;AAChB,OAAO,gBAAgB,CAAC;AACxB,OAAO,aAAa,CAAC;AACrB,OAAO,cAAc,CAAC;AACtB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,iBAAiB,CAAC;AACzB,OAAO,WAAW,CAAC;AACnB,OAAO,WAAW,CAAC;AACnB,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ARIAGlobalStatesAndProperties, FoundationElement } from '@microsoft/fast-foundation';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'nimble-dialog': Dialog;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Symbol that is returned as the dialog close reason (from the Promise returned by show()) when
|
|
9
|
+
* the dialog was closed by pressing the ESC key (vs. calling the close() function).
|
|
10
|
+
*/
|
|
11
|
+
export declare const USER_DISMISSED: unique symbol;
|
|
12
|
+
export declare type UserDismissed = typeof USER_DISMISSED;
|
|
13
|
+
/**
|
|
14
|
+
* This is a workaround for an incomplete definition of the native dialog element:
|
|
15
|
+
* https://github.com/microsoft/TypeScript/issues/48267
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export interface ExtendedDialog extends HTMLDialogElement {
|
|
19
|
+
showModal(): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A nimble-styled dialog.
|
|
24
|
+
*/
|
|
25
|
+
export declare class Dialog<CloseReason = void> extends FoundationElement {
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
* @description
|
|
29
|
+
* Prevents dismissing the dialog via the Escape key
|
|
30
|
+
*/
|
|
31
|
+
preventDismiss: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The ref to the internal dialog element.
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
readonly dialogElement: ExtendedDialog;
|
|
38
|
+
/**
|
|
39
|
+
* True if the dialog is open/showing, false otherwise
|
|
40
|
+
*/
|
|
41
|
+
get open(): boolean;
|
|
42
|
+
private resolveShow?;
|
|
43
|
+
private closeReason;
|
|
44
|
+
/**
|
|
45
|
+
* Opens the dialog
|
|
46
|
+
* @returns Promise that is resolved when the dialog is closed. The value of the resolved Promise is the reason value passed to the close() method, or USER_DISMISSED if the dialog was closed via the ESC key.
|
|
47
|
+
*/
|
|
48
|
+
show(): Promise<CloseReason | UserDismissed>;
|
|
49
|
+
/**
|
|
50
|
+
* Closes the dialog
|
|
51
|
+
* @param reason An optional value indicating how/why the dialog was closed.
|
|
52
|
+
*/
|
|
53
|
+
close(reason: CloseReason): void;
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
closeHandler(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
cancelHandler(event: Event): boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface Dialog extends ARIAGlobalStatesAndProperties {
|
|
64
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { attr } from '@microsoft/fast-element';
|
|
3
|
+
import { applyMixins, ARIAGlobalStatesAndProperties, DesignSystem, FoundationElement } from '@microsoft/fast-foundation';
|
|
4
|
+
import { styles } from './styles';
|
|
5
|
+
import { template } from './template';
|
|
6
|
+
/**
|
|
7
|
+
* Symbol that is returned as the dialog close reason (from the Promise returned by show()) when
|
|
8
|
+
* the dialog was closed by pressing the ESC key (vs. calling the close() function).
|
|
9
|
+
*/
|
|
10
|
+
export const USER_DISMISSED = Symbol('user dismissed');
|
|
11
|
+
/**
|
|
12
|
+
* A nimble-styled dialog.
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
15
|
+
export class Dialog extends FoundationElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
* @description
|
|
21
|
+
* Prevents dismissing the dialog via the Escape key
|
|
22
|
+
*/
|
|
23
|
+
this.preventDismiss = false;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* True if the dialog is open/showing, false otherwise
|
|
27
|
+
*/
|
|
28
|
+
get open() {
|
|
29
|
+
return this.resolveShow !== undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Opens the dialog
|
|
33
|
+
* @returns Promise that is resolved when the dialog is closed. The value of the resolved Promise is the reason value passed to the close() method, or USER_DISMISSED if the dialog was closed via the ESC key.
|
|
34
|
+
*/
|
|
35
|
+
async show() {
|
|
36
|
+
if (this.open) {
|
|
37
|
+
throw new Error('Dialog is already open');
|
|
38
|
+
}
|
|
39
|
+
this.dialogElement.showModal();
|
|
40
|
+
return new Promise((resolve, _reject) => {
|
|
41
|
+
this.resolveShow = resolve;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Closes the dialog
|
|
46
|
+
* @param reason An optional value indicating how/why the dialog was closed.
|
|
47
|
+
*/
|
|
48
|
+
close(reason) {
|
|
49
|
+
if (!this.open) {
|
|
50
|
+
throw new Error('Dialog is not open');
|
|
51
|
+
}
|
|
52
|
+
this.closeReason = reason;
|
|
53
|
+
this.dialogElement.close();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
closeHandler() {
|
|
59
|
+
this.resolveShow(this.closeReason);
|
|
60
|
+
this.resolveShow = undefined;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
cancelHandler(event) {
|
|
67
|
+
if (this.preventDismiss) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.closeReason = USER_DISMISSED;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
__decorate([
|
|
77
|
+
attr({ attribute: 'prevent-dismiss', mode: 'boolean' })
|
|
78
|
+
], Dialog.prototype, "preventDismiss", void 0);
|
|
79
|
+
applyMixins(Dialog, ARIAGlobalStatesAndProperties);
|
|
80
|
+
const nimbleDialog = Dialog.compose({
|
|
81
|
+
baseName: 'dialog',
|
|
82
|
+
template,
|
|
83
|
+
styles,
|
|
84
|
+
baseClass: Dialog,
|
|
85
|
+
shadowOptions: {
|
|
86
|
+
delegatesFocus: true
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleDialog());
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @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WAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,KAAY;QAC7B,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,KAAK,CAAC,cAAc,EAAE,CAAC;SAC1B;aAAM;YACH,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAjEG;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8CAC1B;AAqElC,WAAW,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;AAEnD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,QAAQ,EAAE,QAAQ;IAClB,QAAQ;IACR,MAAM;IACN,SAAS,EAAE,MAAM;IACjB,aAAa,EAAE;QACX,cAAc,EAAE,IAAI;KACvB;CACJ,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("@microsoft/fast-element").ElementStyles;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { css } from '@microsoft/fast-element';
|
|
2
|
+
import { display } from '@microsoft/fast-foundation';
|
|
3
|
+
import { applicationBackgroundColor, borderWidth, popupBoxShadowColor, popupBorderColor } from '../theme-provider/design-tokens';
|
|
4
|
+
export const styles = css `
|
|
5
|
+
${display('grid')}
|
|
6
|
+
|
|
7
|
+
dialog {
|
|
8
|
+
background-color: ${applicationBackgroundColor};
|
|
9
|
+
border: ${borderWidth} solid ${popupBorderColor};
|
|
10
|
+
box-shadow: 0px 2px 3px ${popupBoxShadowColor};
|
|
11
|
+
max-width: 50%;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/dialog/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EACH,0BAA0B,EAC1B,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,MAAM,CAAC;;;4BAGO,0BAA0B;kBACpC,WAAW,UAAU,gBAAgB;kCACrB,mBAAmB;;;CAGpD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { html, ref } from '@microsoft/fast-element';
|
|
2
|
+
export const template = html `
|
|
3
|
+
<template>
|
|
4
|
+
<dialog
|
|
5
|
+
${ref('dialogElement')}
|
|
6
|
+
role="alertdialog"
|
|
7
|
+
aria-label="${x => x.ariaLabel}"
|
|
8
|
+
@cancel="${(x, c) => x.cancelHandler(c.event)}"
|
|
9
|
+
@close="${x => x.closeHandler()}"
|
|
10
|
+
>
|
|
11
|
+
<slot></slot>
|
|
12
|
+
</dialog>
|
|
13
|
+
</template>
|
|
14
|
+
`;
|
|
15
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/dialog/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAGpD,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAQ;;;cAGtB,GAAG,CAAC,eAAe,CAAC;;0BAER,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;uBACnB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;sBACnC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE;;;;;CAK1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ni/nimble-components",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.9.0",
|
|
4
4
|
"description": "Styled web components for the NI Nimble Design System",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run generate-icons && npm run build-components && npm run bundle-components && npm run generate-scss && npm run build-storybook",
|