@ncino/web-components 13.1.0 → 13.1.2
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{NjcModal as
|
|
1
|
+
import{NjcModal as g}from"../modal.js";import"../../card/gator/base/card.gator.js";import"../../card/gator/header/card-header.gator.js";import"../../card/gator/content/card-content.gator.js";import"../../card/gator/footer/card-footer.gator.js";import"../../button/slds/button.slds.js";import"../../button/gator/button.gator.js";import"../../icon-button/gator/icon-button.gator.js";import"../../input/gator/input-currency/input-currency.gator.js";import"../../input/gator/input-date/input-date.gator.js";import"../../input/gator/input-label/input-label.gator.js";import"../../input/gator/help-text/help-text.gator.js";import"../../input/gator/input-text/input-text.gator.js";import"../../input/gator/input-textarea/input-textarea.gator.js";import"../../input/gator/input-masked/input-masked.gator.js";import"../../input/gator/input-percent/input-percent.gator.js";import"../../input/gator/input-phone/input-phone.gator.js";import"../../input/gator/dropdown/input-dropdown.gator.js";import"../../input/gator/input-file/input-file.gator.js";import"../../input/gator/input-file/file-uploaded-preview/file-upload-preview.gator.js";import"../../input/gator/input-search/input-search.gator.js";import"../../input/gator/input-time/input-time.gator.js";import"../../input/gator/input-group/input-group.gator.js";import"../../text-detail/gator/text-detail.gator.js";import"../../skeleton-loader/gator/skeleton-loader.gator.js";import"../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";import{html as l}from"../../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.js";import"../../../node_modules/.pnpm/lit-element@4.2.2/node_modules/lit-element/lit-element.js";import{customElement as f}from"../../../utils/decorators/custom-element-decorator.js";import v from"../../../packages/web-components/src/components/modal/gator/modal.gator.scss.js";import b from"../../../packages/styles/dist/tokens/primitive.tokens.css.js";import E from"../../../packages/styles/dist/tokens/semantic.tokens.css.js";import{createRef as u,ref as m}from"../../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/ref.js";import{getFirstFocusableElement as y}from"../../../utils/accessibility-utils.js";import{ifDefined as C}from"../../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/if-defined.js";import{classMap as k}from"../../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/class-map.js";import{unsafeCSS as h}from"../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";var w=Object.getOwnPropertyDescriptor,D=(t,e,o,i)=>{for(var s=i>1?void 0:i?w(e,o):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(s=c(s)||s);return s};let p=class extends g{constructor(){super(...arguments),this._destructiveMessageRef=u(),this._primaryActionButtonRef=u(),this._dialogRef=u(),this._previouslyFocusedElement=null,this._suppressNextDialogClose=!1,this.onHostKeyDown=t=>{if(!this.open)return;const e=t.key;(e==="Escape"||e==="Esc")&&(t.preventDefault(),t.stopPropagation(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0})))}}render(){return this.open?l`
|
|
2
2
|
<dialog
|
|
3
|
-
${
|
|
4
|
-
class="${
|
|
3
|
+
${m(this._dialogRef)}
|
|
4
|
+
class="${k(this.dialogClassMap)}"
|
|
5
5
|
role="${this.dialogRole}"
|
|
6
6
|
aria-modal="true"
|
|
7
7
|
aria-labelledby="gator-modal-title"
|
|
@@ -19,7 +19,7 @@ import{NjcModal as m}from"../modal.js";import"../../card/gator/base/card.gator.j
|
|
|
19
19
|
<ngc-card-header>
|
|
20
20
|
<ngc-text-detail
|
|
21
21
|
id="gator-modal-title"
|
|
22
|
-
title="${
|
|
22
|
+
title="${C(this.dataset.title)}"
|
|
23
23
|
subtitle="${this.subtitle}"
|
|
24
24
|
size="large"
|
|
25
25
|
?skeleton="${this.skeleton}"
|
|
@@ -40,17 +40,17 @@ import{NjcModal as m}from"../modal.js";import"../../card/gator/base/card.gator.j
|
|
|
40
40
|
</div>
|
|
41
41
|
|
|
42
42
|
<div class="gator-modal-content">
|
|
43
|
-
${this.skeleton?this.gatorModalContentLoadingMarkup:
|
|
43
|
+
${this.skeleton?this.gatorModalContentLoadingMarkup:l`<slot></slot>`}
|
|
44
44
|
</div>
|
|
45
45
|
|
|
46
46
|
${this.gatorModalFooterMarkup}
|
|
47
47
|
</div>
|
|
48
48
|
</ngc-card>
|
|
49
49
|
</dialog>
|
|
50
|
-
`:null}get dialogClassMap(){return{"gator-modal-dialog":!0,"gator-dialog--fullscreen":this.size==="fullscreen"}}get gatorModalContentLoadingMarkup(){return
|
|
50
|
+
`:null}get dialogClassMap(){return{"gator-modal-dialog":!0,"gator-dialog--fullscreen":this.size==="fullscreen"}}get gatorModalContentLoadingMarkup(){return l`
|
|
51
51
|
<ngc-skeleton-loader full-width height="16" rounded></ngc-skeleton-loader>
|
|
52
52
|
<ngc-skeleton-loader full-width height="18" rounded></ngc-skeleton-loader>
|
|
53
|
-
`}get gatorModalFooterMarkup(){return["decide","destructive","confirmation"].includes(this.variant)?
|
|
53
|
+
`}get gatorModalFooterMarkup(){return["decide","destructive","confirmation"].includes(this.variant)?l`
|
|
54
54
|
<div class="gator-modal-footer">
|
|
55
55
|
<slot name="footer">
|
|
56
56
|
${this.footerWarningMessageMarkup}
|
|
@@ -61,16 +61,16 @@ import{NjcModal as m}from"../modal.js";import"../../card/gator/base/card.gator.j
|
|
|
61
61
|
</div>
|
|
62
62
|
</slot>
|
|
63
63
|
</div>
|
|
64
|
-
`:null}get footerWarningMessageMarkup(){return!["destructive"].includes(this.variant)||this.skeleton||!this.destructiveMessageText?null:(requestAnimationFrame(()=>{const e=
|
|
64
|
+
`:null}get footerWarningMessageMarkup(){return!["destructive"].includes(this.variant)||this.skeleton||!this.destructiveMessageText?null:(requestAnimationFrame(()=>{const e=y(this._primaryActionButtonRef.value);this._destructiveMessageRef.value&&e&&(e.ariaDescribedByElements=[this._destructiveMessageRef.value])}),l`
|
|
65
65
|
<div class="gator-modal-warning">
|
|
66
66
|
<ngc-icon name="warning"></ngc-icon>
|
|
67
|
-
<ngc-input-label ${
|
|
67
|
+
<ngc-input-label ${m(this._destructiveMessageRef)}>
|
|
68
68
|
${this.destructiveMessageText}
|
|
69
69
|
</ngc-input-label>
|
|
70
70
|
</div>
|
|
71
|
-
`)}get footerPrimaryActionButtonMarkup(){return["decide","destructive","confirmation"].includes(this.variant)?
|
|
71
|
+
`)}get footerPrimaryActionButtonMarkup(){return["decide","destructive","confirmation"].includes(this.variant)?l`
|
|
72
72
|
<ngc-button
|
|
73
|
-
${
|
|
73
|
+
${m(this._primaryActionButtonRef)}
|
|
74
74
|
class="gator-modal-primary-button"
|
|
75
75
|
variant="${this.variant==="destructive"?"destructive":"primary"}"
|
|
76
76
|
size="${this.buttonSize}"
|
|
@@ -80,7 +80,7 @@ import{NjcModal as m}from"../modal.js";import"../../card/gator/base/card.gator.j
|
|
|
80
80
|
>
|
|
81
81
|
${this.primaryActionText}
|
|
82
82
|
</ngc-button>
|
|
83
|
-
`:null}get footerSecondaryActionButtonMarkup(){return["decide","destructive"].includes(this.variant)?
|
|
83
|
+
`:null}get footerSecondaryActionButtonMarkup(){return["decide","destructive"].includes(this.variant)?l`
|
|
84
84
|
<ngc-button
|
|
85
85
|
class="gator-modal-secondary-button"
|
|
86
86
|
variant="secondary"
|
|
@@ -91,4 +91,4 @@ import{NjcModal as m}from"../modal.js";import"../../card/gator/base/card.gator.j
|
|
|
91
91
|
>
|
|
92
92
|
Cancel
|
|
93
93
|
</ngc-button>
|
|
94
|
-
`:null}get buttonSize(){switch(this.size){case"small":return"xlarge";case"standard":return"medium";case"fullscreen":return"large";default:return"medium"}}onDialogCancel(t){t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))}onDialogClose(t){const e=this._dialogRef.value;this._suppressNextDialogClose?this._suppressNextDialogClose=!1:this.dispatchEvent(new CustomEvent("close",{bubbles:!0})),this._previouslyFocusedElement instanceof HTMLElement&&requestAnimationFrame(()=>this._previouslyFocusedElement?.focus()),e&&e.close()}onDialogBackdropClick(t){t.target===this._dialogRef.value&&this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))}handleCloseClick(t){t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))}handleCloseKeydown(t){(t.code==="Enter"||t.code==="Space")&&this.handleCloseClick(t)}handlePrimaryActionClick(t){t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("primary-action-click",{bubbles:!0}))}handleSecondaryActionClick(t){t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("secondary-action-click",{bubbles:!0}))}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.onHostKeyDown)}disconnectedCallback(){this.removeEventListener("keydown",this.onHostKeyDown),super.disconnectedCallback()}willUpdate(t){if(super.willUpdate?.(t),t.has("open")&&t.get("open")&&!this.open){const
|
|
94
|
+
`:null}get buttonSize(){switch(this.size){case"small":return"xlarge";case"standard":return"medium";case"fullscreen":return"large";default:return"medium"}}onDialogCancel(t){t.preventDefault(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))}onDialogClose(t){const e=this._dialogRef.value;this._suppressNextDialogClose?this._suppressNextDialogClose=!1:this.dispatchEvent(new CustomEvent("close",{bubbles:!0})),this._previouslyFocusedElement instanceof HTMLElement&&requestAnimationFrame(()=>this._previouslyFocusedElement?.focus()),e&&e.close()}onDialogBackdropClick(t){t.target===this._dialogRef.value&&this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))}handleCloseClick(t){t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))}handleCloseKeydown(t){(t.code==="Enter"||t.code==="Space")&&this.handleCloseClick(t)}handlePrimaryActionClick(t){t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("primary-action-click",{bubbles:!0}))}handleSecondaryActionClick(t){t.preventDefault(),t.stopImmediatePropagation(),this.dispatchEvent(new CustomEvent("secondary-action-click",{bubbles:!0}))}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.onHostKeyDown)}disconnectedCallback(){this.removeEventListener("keydown",this.onHostKeyDown),super.disconnectedCallback()}willUpdate(t){if(super.willUpdate?.(t),t.has("open")&&t.get("open")&&!this.open){const i=this._dialogRef.value;if(i&&i.open){this._suppressNextDialogClose=!0;try{i.close()}catch{}}}}updated(t){if(super.updated(t),t.has("open")){const e=this._dialogRef.value;if(this.open){if(document.activeElement instanceof HTMLElement&&(this._previouslyFocusedElement=document.activeElement),e&&!e.open)try{e.showModal()}catch{}this.focusFirstElement()}}t.has("title")&&this.title&&(this.dataset.title=this.title,this.removeAttribute("title"),this.requestUpdate())}onDialogKeyDown(t){if(t.key!=="Tab")return;const e=this.getKeyboardFocusableElements();if(e.length===0)return;const o=this.getDeepActiveElement(),i=e[0],s=e[e.length-1],a=this.findFocusedIndex(o,e);a!==-1&&(t.shiftKey?a===0&&(t.preventDefault(),s.focus()):a===e.length-1&&(t.preventDefault(),i.focus()))}getDeepActiveElement(){let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}findFocusedIndex(t,e){return t?e.findIndex(o=>o===t||o.contains(t)||o.shadowRoot?.contains(t)):-1}getKeyboardFocusableElements(){const t='a[href],button,ngc-button,ngc-icon-button,input,textarea,select,details,[tabindex]:not([tabindex="-1"])',e=Array.from(this.shadowRoot?.querySelectorAll(t)??[]),o=[],i=this.shadowRoot?.querySelectorAll("slot")??[];for(const r of i){const d=r.assignedElements({flatten:!0});for(const n of d)n.matches?.(t)&&o.push(n),o.push(...Array.from(n.querySelectorAll(t)))}const s=[...e,...o];return(this._dialogRef.value?s.sort((r,d)=>{const n=r.compareDocumentPosition(d);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}):s).filter(r=>!r.hasAttribute("disabled")&&!r.hasAttribute("aria-hidden"))}focusFirstElement(){if(!this.open)return;const t=this.getKeyboardFocusableElements();if(t.length>0){const e=t[0];requestAnimationFrame(()=>{e.focus()})}}};p.styles=[h(v),h(b),h(E)];p=D([f("ngc-modal")],p);export{p as NgcModal};
|
|
@@ -37,7 +37,8 @@ export declare class NgcModal extends NjcModal {
|
|
|
37
37
|
willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
38
38
|
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
39
39
|
onDialogKeyDown(event: KeyboardEvent): void;
|
|
40
|
-
private
|
|
40
|
+
private getDeepActiveElement;
|
|
41
|
+
private findFocusedIndex;
|
|
41
42
|
getKeyboardFocusableElements(): HTMLElement[];
|
|
42
43
|
focusFirstElement(): void;
|
|
43
44
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ncino/web-components",
|
|
3
3
|
"author": "nCino",
|
|
4
|
-
"version": "13.1.
|
|
4
|
+
"version": "13.1.2",
|
|
5
5
|
"license": "(c) Copyright 2023 nCino, Inc., all rights reserved",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"vite-plugin-static-copy": "^3.3.0",
|
|
101
101
|
"vitest": "^4.1.0",
|
|
102
102
|
"yaml-eslint-parser": "^2.0.0",
|
|
103
|
-
"@ncino/styles": "13.1.
|
|
103
|
+
"@ncino/styles": "13.1.2"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@ncino/styles": "13.1.
|
|
106
|
+
"@ncino/styles": "13.1.2"
|
|
107
107
|
},
|
|
108
108
|
"bugs": {
|
|
109
109
|
"url": "https://github.com/ncino/force-sdk-web-components/issues"
|
package/web-types.json
CHANGED