@aquera/nile-elements 0.0.11 → 0.0.13
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/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.d.ts +3 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.js +3 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/internal/enum.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.d.ts +2 -2
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js +52 -15
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.css.js +3 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.d.ts +4 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.js +64 -17
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/document.d.ts +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/document.js +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-icon/icons/svg/document.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js +4 -3
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.iife.js +41 -27
- package/dist/internal/enum.cjs.js +1 -1
- package/dist/internal/enum.cjs.js.map +1 -1
- package/dist/internal/enum.esm.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.cjs.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.cjs.js.map +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.cjs.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.cjs.js.map +1 -1
- package/dist/nile-content-editor/nile-content-editor.css.esm.js +1 -1
- package/dist/nile-content-editor/nile-content-editor.esm.js +11 -11
- package/dist/nile-dialog/nile-dialog.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.css.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.css.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.css.esm.js +3 -0
- package/dist/nile-dialog/nile-dialog.esm.js +14 -4
- package/dist/nile-icon/icons/svg/document.cjs.js +1 -1
- package/dist/nile-icon/icons/svg/document.cjs.js.map +1 -1
- package/dist/nile-icon/icons/svg/document.esm.js +1 -1
- package/dist/nile-switcher/nile-switcher.cjs.js +1 -1
- package/dist/nile-switcher/nile-switcher.cjs.js.map +1 -1
- package/dist/nile-switcher/nile-switcher.esm.js +7 -6
- package/dist/src/internal/enum.d.ts +3 -0
- package/dist/src/internal/enum.js +3 -0
- package/dist/src/internal/enum.js.map +1 -1
- package/dist/src/nile-content-editor/nile-content-editor.css.js +1 -1
- package/dist/src/nile-content-editor/nile-content-editor.css.js.map +1 -1
- package/dist/src/nile-content-editor/nile-content-editor.d.ts +2 -2
- package/dist/src/nile-content-editor/nile-content-editor.js +52 -15
- package/dist/src/nile-content-editor/nile-content-editor.js.map +1 -1
- package/dist/src/nile-dialog/nile-dialog.css.js +3 -0
- package/dist/src/nile-dialog/nile-dialog.css.js.map +1 -1
- package/dist/src/nile-dialog/nile-dialog.d.ts +4 -0
- package/dist/src/nile-dialog/nile-dialog.js +64 -17
- package/dist/src/nile-dialog/nile-dialog.js.map +1 -1
- package/dist/src/nile-icon/icons/svg/document.d.ts +1 -1
- package/dist/src/nile-icon/icons/svg/document.js +1 -1
- package/dist/src/nile-icon/icons/svg/document.js.map +1 -1
- package/dist/src/nile-switcher/nile-switcher.js +4 -3
- package/dist/src/nile-switcher/nile-switcher.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/internal/enum.ts +3 -0
- package/src/nile-content-editor/nile-content-editor.css.ts +1 -1
- package/src/nile-content-editor/nile-content-editor.ts +56 -21
- package/src/nile-dialog/nile-dialog.css.ts +3 -0
- package/src/nile-dialog/nile-dialog.ts +82 -24
- package/src/nile-icon/icons/svg/document.ts +1 -1
- package/src/nile-switcher/nile-switcher.ts +4 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/internal/enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,SAAS,EAAE,WAAW;IACtB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,UAAU;IACrB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,WAAW;IACvB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/internal/enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,SAAS,EAAE,WAAW;IACtB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,UAAU;IACrB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,WAAW;IACvB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;IACvB,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACf,CAAC","sourcesContent":["export const KeyCode = {\n BACKSPACE: 'Backspace',\n TAB: 'Tab',\n ENTER: 'Enter',\n SHIFT: 'ShiftLeft', // or 'ShiftRight'\n CTRL: 'ControlLeft', // or 'ControlRight'\n ESCAPE: 'Escape',\n SPACE: 'Space',\n PAGE_UP: 'PageUp',\n PAGE_DOWN: 'PageDown',\n END: 'End',\n HOME: 'Home',\n ARROW_LEFT: 'ArrowLeft',\n ARROW_UP: 'ArrowUp',\n ARROW_RIGHT: 'ArrowRight',\n ARROW_DOWN: 'ArrowDown',\n CUT: 'KeyX',\n COPY: 'Copy',\n PASTE: 'Paste',\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-content-editor.css.js","sourceRoot":"","sources":["../../../src/nile-content-editor/nile-content-editor.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit-element';\n\n/**\n * AttributeExpression CSS\n */\nexport const styles = css`\n :host {\n width: 100%;\n box-sizing: border-box;\n font-size: 14px;\n }\n\n .content-editable-wrapper {\n position: relative;\n width: 100%;\n box-sizing: border-box;\n }\n\n .dropdown-position {\n position: relative;\n bottom:
|
1
|
+
{"version":3,"file":"nile-content-editor.css.js","sourceRoot":"","sources":["../../../src/nile-content-editor/nile-content-editor.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit-element';\n\n/**\n * AttributeExpression CSS\n */\nexport const styles = css`\n :host {\n width: 100%;\n box-sizing: border-box;\n font-size: 14px;\n }\n\n .content-editable-wrapper {\n position: relative;\n width: 100%;\n box-sizing: border-box;\n }\n\n .dropdown-position {\n position: relative;\n bottom: 20px;\n }\n .content-editable-input {\n box-sizing: border-box;\n width: 100%;\n padding: 9px;\n border: 1px solid #c7ced4;\n border-radius: 4px;\n overflow-x: auto;\n overflow-anchor: none;\n scrollbar-width: none;\n -ms-overflow-style: none;\n cursor: text;\n white-space: nowrap;\n background-color: #ffffff;\n height: 38px;\n }\n .content-editable-input:focus {\n outline: none;\n }\n\n .error {\n border-color: #e5434d;\n }\n\n .read-only {\n cursor: not-allowed;\n }\n\n .chips {\n display: inline;\n background: #e5e9eb;\n color: #000;\n border-radius: 4px;\n padding: 6px;\n height: 24px;\n line-height: 10px;\n margin-left: 3px;\n letter-spacing: 0.2px;\n }\n\n .text-area {\n height: 120px;\n overflow: scroll;\n line-height: 26px;\n }\n\n .text-area .chips {\n padding: 4px 8px;\n }\n\n .chip-error {\n background: #f3a5aa;\n }\n .nile-options-container {\n box-sizing: border-box;\n background-color: #ffffff;\n border: 1px solid #c7ced4;\n overflow: auto;\n max-height: 150px;\n }\n\n label {\n display: inline-block;\n margin-bottom: 6px;\n font-family: 'colfax-medium';\n }\n\n .asterik {\n color: #e5434d;\n }\n`;\n\nexport default [styles];\n"]}
|
@@ -42,17 +42,17 @@ export declare class NileContentEditor extends NileElement {
|
|
42
42
|
setInitialValues(): void;
|
43
43
|
addOpenListeners(): void;
|
44
44
|
removeOpenListeners(): void;
|
45
|
+
handleClipboardEvent(event: Event): Promise<void>;
|
45
46
|
toggleDropdown(value: boolean): void;
|
46
47
|
handleOutsideClick(event: Event): void;
|
47
48
|
handleTypeChange(): void;
|
48
49
|
disconnectedCallback(): void;
|
49
|
-
handlePaste(event: ClipboardEvent): void;
|
50
50
|
private handlekeyDown;
|
51
51
|
filterOptions(): void;
|
52
52
|
generateValuesFromHTMLTags(string: any): string;
|
53
53
|
generateHTMLTagsWithValues(string: any): string;
|
54
54
|
emitInputChange(): void;
|
55
|
-
insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag
|
55
|
+
insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag?: Node): void;
|
56
56
|
handleOptions(option: any): void;
|
57
57
|
renderAutoOptions(): TemplateResult;
|
58
58
|
render(): TemplateResult;
|
@@ -44,6 +44,7 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
44
44
|
}
|
45
45
|
connectedCallback() {
|
46
46
|
this.handleOutsideClick = this.handleOutsideClick.bind(this);
|
47
|
+
this.handleClipboardEvent = this.handleClipboardEvent.bind(this);
|
47
48
|
super.connectedCallback();
|
48
49
|
this.emit('nile-init');
|
49
50
|
this.addOpenListeners();
|
@@ -57,9 +58,36 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
57
58
|
}
|
58
59
|
addOpenListeners() {
|
59
60
|
window.addEventListener('click', this.handleOutsideClick);
|
61
|
+
window.addEventListener('cut', this.handleClipboardEvent);
|
62
|
+
window.addEventListener('copy', this.handleClipboardEvent);
|
63
|
+
window.addEventListener('paste', this.handleClipboardEvent);
|
60
64
|
}
|
61
65
|
removeOpenListeners() {
|
62
66
|
window.removeEventListener('click', this.handleOutsideClick);
|
67
|
+
window.removeEventListener('cut', this.handleClipboardEvent);
|
68
|
+
window.removeEventListener('copy', this.handleClipboardEvent);
|
69
|
+
window.removeEventListener('paste', this.handleClipboardEvent);
|
70
|
+
}
|
71
|
+
async handleClipboardEvent(event) {
|
72
|
+
const selectedText = window?.getSelection()?.toString();
|
73
|
+
if (!!selectedText) {
|
74
|
+
switch (event.type) {
|
75
|
+
case 'cut':
|
76
|
+
case 'copy':
|
77
|
+
await navigator.clipboard.writeText(selectedText);
|
78
|
+
document.execCommand(event.type);
|
79
|
+
break;
|
80
|
+
case 'paste':
|
81
|
+
const pastedText = await navigator.clipboard.readText();
|
82
|
+
document.execCommand('insertText', false, pastedText);
|
83
|
+
break;
|
84
|
+
default:
|
85
|
+
break;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
setTimeout(() => {
|
89
|
+
this.emitInputChange();
|
90
|
+
});
|
63
91
|
}
|
64
92
|
toggleDropdown(value) {
|
65
93
|
this.openDropdown = value;
|
@@ -77,19 +105,14 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
77
105
|
this.removeOpenListeners();
|
78
106
|
this.emit('nile-destroy');
|
79
107
|
}
|
80
|
-
handlePaste(event) {
|
81
|
-
event.preventDefault();
|
82
|
-
if (event.clipboardData) {
|
83
|
-
let text = event.clipboardData.getData('text/plain');
|
84
|
-
document.execCommand('insertText', false, text);
|
85
|
-
}
|
86
|
-
this.emitInputChange();
|
87
|
-
}
|
88
108
|
handlekeyDown(event) {
|
89
109
|
if (event.code === KeyCode.ENTER && this.type === 'text') {
|
90
110
|
event.preventDefault();
|
91
111
|
return;
|
92
112
|
}
|
113
|
+
if ([KeyCode.CUT, KeyCode.COPY, KeyCode.PASTE].includes(event.code)) {
|
114
|
+
return;
|
115
|
+
}
|
93
116
|
if (event.code === KeyCode.ESCAPE) {
|
94
117
|
event.preventDefault();
|
95
118
|
this.toggleDropdown(false);
|
@@ -99,8 +122,9 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
99
122
|
const value = this.contentEditor.innerText;
|
100
123
|
this.emitInputChange();
|
101
124
|
if (value.includes(this.tagIdentifier)) {
|
102
|
-
this.
|
125
|
+
this.insertNodes(this.contentEditor, this.contentEditor.childNodes);
|
103
126
|
this.filterOptions();
|
127
|
+
this.toggleDropdown(true);
|
104
128
|
}
|
105
129
|
else {
|
106
130
|
this.toggleDropdown(false);
|
@@ -148,14 +172,27 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
148
172
|
}
|
149
173
|
}
|
150
174
|
insertNodes(parentNode, childNodes, autoOptionsTag) {
|
151
|
-
|
175
|
+
[...childNodes].forEach((node, index) => {
|
152
176
|
if (node.hasChildNodes()) {
|
153
|
-
|
177
|
+
if (autoOptionsTag) {
|
178
|
+
this.insertNodes(node, node.childNodes, autoOptionsTag);
|
179
|
+
}
|
180
|
+
else {
|
181
|
+
this.insertNodes(node, node.childNodes);
|
182
|
+
}
|
154
183
|
}
|
155
184
|
else {
|
156
185
|
if (node.nodeValue?.includes(this.tagIdentifier)) {
|
157
|
-
|
158
|
-
|
186
|
+
if (autoOptionsTag) {
|
187
|
+
parentNode.childNodes[index].nodeValue = node.nodeValue?.replace(this.tagIdentifier + this.filteredValue, '');
|
188
|
+
parentNode.childNodes[index].after(autoOptionsTag);
|
189
|
+
}
|
190
|
+
this.filteredValue =
|
191
|
+
parentNode?.childNodes[index]?.nodeValue
|
192
|
+
?.split(this.tagIdentifier)
|
193
|
+
.slice(1)
|
194
|
+
.join() || '';
|
195
|
+
return;
|
159
196
|
}
|
160
197
|
}
|
161
198
|
});
|
@@ -200,6 +237,7 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
200
237
|
<nile-popup
|
201
238
|
.active="${live(this.openDropdown)}"
|
202
239
|
sync="width"
|
240
|
+
strategy="fixed"
|
203
241
|
placement="bottom"
|
204
242
|
class=${classMap({
|
205
243
|
dropdown: true,
|
@@ -211,7 +249,7 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
211
249
|
${this.showLabel && this.labelText
|
212
250
|
? html `<label class="ods-label">${this.labelText} </label> ${this
|
213
251
|
.required
|
214
|
-
? html `<
|
252
|
+
? html `<span class="asterik">*</span>`
|
215
253
|
: ''}`
|
216
254
|
: ''}
|
217
255
|
<div
|
@@ -223,7 +261,6 @@ let NileContentEditor = class NileContentEditor extends NileElement {
|
|
223
261
|
'text-area': type === 'text-area' ? true : false,
|
224
262
|
})}
|
225
263
|
@keydown=${this.handlekeyDown}
|
226
|
-
@paste=${this.handlePaste}
|
227
264
|
></div>
|
228
265
|
${hasHelpText
|
229
266
|
? html `
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-content-editor.js","sourceRoot":"","sources":["../../../src/nile-content-editor/nile-content-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CA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,CAAC,QAAQ;eACrC;YACH,CAAC,CAAC,EAAE;YACJ,eAAe;YACf,CAAC,CAAC,IAAI,CAAA;;qBAEG,IAAI,CAAC,YAAY;;eAEvB;YACH,CAAC,CAAC,EAAE;;;UAGN,IAAI,CAAC,iBAAiB,EAAE;;KAE7B,CAAC;IACJ,CAAC;;AAtOM,wBAAM,GAAmB,MAAM,CAAC;AA/B3B;IAAX,QAAQ,EAAE;gDAAoB;AAEnB;IAAX,QAAQ,EAAE;kDAAqB;AAEpB;IAAX,QAAQ,EAAE;0DAA6B;AAE5B;IAAX,QAAQ,EAAE;oDAA2B;AAE1B;IAAX,QAAQ,EAAE;oDAAgB;AAEf;IAAX,QAAQ,EAAE;+CAAyB;AAExB;IAAX,QAAQ,EAAE;mDAA0B;AAEH;IAAjC,KAAK,CAAC,yBAAyB,CAAC;wDAAiC;AAChC;IAAjC,KAAK,CAAC,yBAAyB,CAAC;sDAA+B;AAEvD;IAAR,KAAK,EAAE;uDAAsB;AAMQ;IAArC,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;mDAAe;AAEf;IAApC,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAAkB;AAEZ;IAAzC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;uDAAmB;AAE1B;IAAjC,QAAQ,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;gDAAe;AAwChD;IADC,KAAK,CAAC,MAAM,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;yDAG7C;AAhFU,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CA+Q7B;SA/QY,iBAAiB;AAiR9B,eAAe,iBAAiB,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, property, TemplateResult } from 'lit-element';\nimport { customElement, query, state } from 'lit/decorators.js';\nimport { styles } from './nile-content-editor.css';\nimport { CSSResultGroup } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport NileElement from '../internal/nile-element';\nimport { watch } from '../internal/watch';\nimport { KeyCode } from '../internal/enum';\nimport { live } from 'lit/directives/live.js';\n\n/**\n * Nile icon component.\n *\n * @tag nile-attribute-expression\n *\n */\n@customElement('nile-content-editor')\nexport class NileContentEditor extends NileElement {\n /**\n * @summary Allows you to handle both input and dropdown selection\n\n * @dependency nile-option\n \n * @event nile-change - Emitted when the control's value changes. \n */\n\n @property() value: string = '';\n\n @property() options: Array<any>;\n\n @property() filteredOptions: Array<any>;\n\n @property() showLabel: boolean = true;\n\n @property() labelText = '';\n\n @property() type = 'text|text-area';\n\n @property() required: boolean = true;\n\n @query('.content-editable-input') contentEditor: HTMLInputElement;\n @query('.nile-options-container') autoOptions: HTMLInputElement;\n\n @state() openDropdown = false;\n\n tagIdentifier = '$';\n\n filteredValue = '';\n\n @property({ attribute: 'help-text' }) helpText = '';\n\n @property({ attribute: 'readonly' }) readonly = false;\n\n @property({ attribute: 'error-message' }) errorMessage = '';\n\n @property({ attribute: 'error' }) error = false;\n\n static styles: CSSResultGroup = styles;\n\n connectedCallback() {\n this.handleOutsideClick = this.handleOutsideClick.bind(this);\n super.connectedCallback();\n this.emit('nile-init');\n this.addOpenListeners();\n this.setInitialValues();\n }\n\n setInitialValues() {\n this.updateComplete.then(res => {\n if (res && !!this.value)\n this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(\n this.value\n );\n });\n }\n\n addOpenListeners() {\n window.addEventListener('click', this.handleOutsideClick);\n }\n\n removeOpenListeners() {\n window.removeEventListener('click', this.handleOutsideClick);\n }\n\n toggleDropdown(value: boolean) {\n this.openDropdown = value;\n }\n\n handleOutsideClick(event: Event) {\n if (event && event.target) {\n this.toggleDropdown(false);\n }\n }\n\n @watch('type', { waitUntilFirstUpdate: true })\n handleTypeChange() {\n this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(this.value);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeOpenListeners();\n this.emit('nile-destroy');\n }\n\n handlePaste(event: ClipboardEvent) {\n event.preventDefault();\n if (event.clipboardData) {\n let text = event.clipboardData.getData('text/plain');\n document.execCommand('insertText', false, text);\n }\n this.emitInputChange();\n }\n\n private handlekeyDown(event: any) {\n if (event.code === KeyCode.ENTER && this.type === 'text') {\n event.preventDefault();\n return;\n }\n if (event.code === KeyCode.ESCAPE) {\n event.preventDefault();\n this.toggleDropdown(false);\n return;\n }\n setTimeout(() => {\n const value = this.contentEditor.innerText;\n this.emitInputChange();\n if (value.includes(this.tagIdentifier)) {\n this.toggleDropdown(true);\n this.filterOptions();\n } else {\n this.toggleDropdown(false);\n }\n });\n }\n\n filterOptions() {\n this.filteredOptions = this.options;\n if (!!this.options.length && !!this.filteredValue) {\n this.filteredOptions = this.options.filter(item =>\n item.startsWith(this.filteredValue)\n );\n } else {\n this.filteredOptions = this.options;\n }\n }\n\n generateValuesFromHTMLTags(string: any): string {\n var pattern =\n /<span class=\"chips(?: chip-error)?\" contenteditable=\"false\">(.*?)<\\/span>/g;\n var result = string.replace(pattern, (match: any, option: any) => {\n return '{{' + option + '}}';\n });\n return result;\n }\n\n generateHTMLTagsWithValues(string: any): string {\n var pattern = /{{(.*?)}}/g;\n var result = string.replace(pattern, (match: any, option: any) => {\n return this.options.includes(option)\n ? '<span class=\"chips\" contenteditable=\"false\">' + option + '</span>'\n : '<span class=\"chips chip-error\" contenteditable=\"false\">' +\n option +\n '</span>';\n });\n return result;\n }\n\n emitInputChange(): void {\n if (this.contentEditor) {\n let fieldValue = this.contentEditor.innerHTML;\n\n if (this.contentEditor.innerText !== '') {\n fieldValue = this.generateValuesFromHTMLTags(fieldValue);\n }\n fieldValue = fieldValue.replace(/ /g, ' ');\n fieldValue = fieldValue === '<br>' ? '' : fieldValue?.trim();\n this.emit('nile-change', {\n value: this.generateValuesFromHTMLTags(fieldValue),\n });\n }\n }\n\n insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag: Node) {\n Array.from(childNodes).map((node: Node, index: number) => {\n if (node.hasChildNodes()) {\n this.insertNodes(node, node.childNodes, autoOptionsTag);\n } else {\n if (node.nodeValue?.includes(this.tagIdentifier)) {\n parentNode.childNodes[index].nodeValue = node.nodeValue?.replace(\n this.tagIdentifier + this.filteredValue,\n ''\n );\n parentNode.childNodes[index].after(autoOptionsTag);\n }\n }\n });\n }\n\n handleOptions(option: any): void {\n this.toggleDropdown(false);\n let autoOptionsTag = document.createElement('span');\n autoOptionsTag.setAttribute('class', 'chips');\n autoOptionsTag.setAttribute('contentEditable', 'false');\n autoOptionsTag.innerText = option;\n this.insertNodes(\n this.contentEditor,\n this.contentEditor.childNodes,\n autoOptionsTag\n );\n this.filteredOptions = this.options;\n this.filteredValue = '';\n this.emitInputChange();\n }\n\n public renderAutoOptions(): TemplateResult {\n return html`<div\n class=\"${classMap({\n 'nile-options-container': true,\n 'dropdown-position': this.type === 'text-area',\n })}\"\n >\n ${this.filteredOptions &&\n this.filteredOptions.map((option: any) => {\n return html` <nile-option\n .value=\"${option}\"\n @click=\"${(event: Event) => {\n this.handleOptions(option);\n }}\"\n >${option}\n </nile-option>`;\n })}\n </div>`;\n }\n\n public render(): TemplateResult {\n const hasHelpText = this.helpText ? true : false;\n const hasError = !!this.error;\n const hasErrorMessage = !!this.errorMessage;\n const readonly = !!this.readonly;\n const type = this.type;\n return html`\n <nile-popup\n .active=\"${live(this.openDropdown)}\"\n sync=\"width\"\n placement=\"bottom\"\n class=${classMap({\n dropdown: true,\n 'dropdown--open': true,\n popup: true,\n })}\n >\n <div class=\"content-editable-wrapper\" slot=\"anchor\">\n ${this.showLabel && this.labelText\n ? html`<label class=\"ods-label\">${this.labelText} </label> ${this\n .required\n ? html`<sapn class=\"asterik\">*</span>`\n : ''}`\n : ''}\n <div\n contenteditable=\"${!readonly}\"\n class=${classMap({\n 'content-editable-input': true,\n error: hasError || hasErrorMessage,\n 'read-only': readonly,\n 'text-area': type === 'text-area' ? true : false,\n })}\n @keydown=${this.handlekeyDown}\n @paste=${this.handlePaste}\n ></div>\n ${hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``}\n ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}\n </div>\n\n ${this.renderAutoOptions()}\n </nile-popup>\n `;\n }\n}\n\nexport default NileContentEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-content-editor': NileContentEditor;\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"nile-content-editor.js","sourceRoot":"","sources":["../../../src/nile-content-editor/nile-content-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C;;;;;GAKG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,WAAW;IAA3C;QACL;;;;;;SAMC;;QAEW,UAAK,GAAW,EAAE,CAAC;QAMnB,cAAS,GAAY,IAAI,CAAC;QAE1B,cAAS,GAAG,EAAE,CAAC;QAEf,SAAI,GAAG,gBAAgB,CAAC;QAExB,aAAQ,GAAY,IAAI,CAAC;QAK5B,iBAAY,GAAG,KAAK,CAAC;QAE9B,kBAAa,GAAG,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AE;0DAA6B;AAE5B;IAAX,QAAQ,EAAE;oDAA2B;AAE1B;IAAX,QAAQ,EAAE;oDAAgB;AAEf;IAAX,QAAQ,EAAE;+CAAyB;AAExB;IAAX,QAAQ,EAAE;mDAA0B;AAEH;IAAjC,KAAK,CAAC,yBAAyB,CAAC;wDAAiC;AAChC;IAAjC,KAAK,CAAC,yBAAyB,CAAC;sDAA+B;AAEvD;IAAR,KAAK,EAAE;uDAAsB;AAMQ;IAArC,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;mDAAe;AAEf;IAApC,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAAkB;AAEZ;IAAzC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;uDAAmB;AAE1B;IAAjC,QAAQ,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;gDAAe;AAqEhD;IADC,KAAK,CAAC,MAAM,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;yDAG7C;AA7GU,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAkT7B;SAlTY,iBAAiB;AAoT9B,eAAe,iBAAiB,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, property, TemplateResult } from 'lit-element';\nimport { customElement, query, state } from 'lit/decorators.js';\nimport { styles } from './nile-content-editor.css';\nimport { CSSResultGroup } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport NileElement from '../internal/nile-element';\nimport { watch } from '../internal/watch';\nimport { KeyCode } from '../internal/enum';\nimport { live } from 'lit/directives/live.js';\n\n/**\n * Nile icon component.\n *\n * @tag nile-attribute-expression\n *\n */\n@customElement('nile-content-editor')\nexport class NileContentEditor extends NileElement {\n /**\n * @summary Allows you to handle both input and dropdown selection\n\n * @dependency nile-option\n \n * @event nile-change - Emitted when the control's value changes. \n */\n\n @property() value: string = '';\n\n @property() options: Array<any>;\n\n @property() filteredOptions: Array<any>;\n\n @property() showLabel: boolean = true;\n\n @property() labelText = '';\n\n @property() type = 'text|text-area';\n\n @property() required: boolean = true;\n\n @query('.content-editable-input') contentEditor: HTMLInputElement;\n @query('.nile-options-container') autoOptions: HTMLInputElement;\n\n @state() openDropdown = false;\n\n tagIdentifier = '$';\n\n filteredValue = '';\n\n @property({ attribute: 'help-text' }) helpText = '';\n\n @property({ attribute: 'readonly' }) readonly = false;\n\n @property({ attribute: 'error-message' }) errorMessage = '';\n\n @property({ attribute: 'error' }) error = false;\n\n static styles: CSSResultGroup = styles;\n\n connectedCallback() {\n this.handleOutsideClick = this.handleOutsideClick.bind(this);\n this.handleClipboardEvent = this.handleClipboardEvent.bind(this);\n super.connectedCallback();\n this.emit('nile-init');\n this.addOpenListeners();\n this.setInitialValues();\n }\n\n setInitialValues() {\n this.updateComplete.then(res => {\n if (res && !!this.value)\n this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(\n this.value\n );\n });\n }\n\n addOpenListeners() {\n window.addEventListener('click', this.handleOutsideClick);\n window.addEventListener('cut', this.handleClipboardEvent);\n window.addEventListener('copy', this.handleClipboardEvent);\n window.addEventListener('paste', this.handleClipboardEvent);\n }\n\n removeOpenListeners() {\n window.removeEventListener('click', this.handleOutsideClick);\n window.removeEventListener('cut', this.handleClipboardEvent);\n window.removeEventListener('copy', this.handleClipboardEvent);\n window.removeEventListener('paste', this.handleClipboardEvent);\n }\n\n async handleClipboardEvent(event: Event) {\n const selectedText = window?.getSelection()?.toString();\n if (!!selectedText) {\n switch (event.type) {\n case 'cut':\n case 'copy':\n await navigator.clipboard.writeText(selectedText);\n document.execCommand(event.type);\n break;\n case 'paste':\n const pastedText = await navigator.clipboard.readText();\n document.execCommand('insertText', false, pastedText);\n break;\n default:\n break;\n }\n }\n setTimeout(() => {\n this.emitInputChange();\n });\n }\n\n toggleDropdown(value: boolean) {\n this.openDropdown = value;\n }\n\n handleOutsideClick(event: Event) {\n if (event && event.target) {\n this.toggleDropdown(false);\n }\n }\n\n @watch('type', { waitUntilFirstUpdate: true })\n handleTypeChange() {\n this.contentEditor.innerHTML = this.generateHTMLTagsWithValues(this.value);\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeOpenListeners();\n this.emit('nile-destroy');\n }\n\n private handlekeyDown(event: any) {\n if (event.code === KeyCode.ENTER && this.type === 'text') {\n event.preventDefault();\n return;\n }\n if ([KeyCode.CUT, KeyCode.COPY, KeyCode.PASTE].includes(event.code)) {\n return;\n }\n if (event.code === KeyCode.ESCAPE) {\n event.preventDefault();\n this.toggleDropdown(false);\n return;\n }\n setTimeout(() => {\n const value = this.contentEditor.innerText;\n this.emitInputChange();\n if (value.includes(this.tagIdentifier)) {\n this.insertNodes(this.contentEditor, this.contentEditor.childNodes);\n this.filterOptions();\n this.toggleDropdown(true);\n } else {\n this.toggleDropdown(false);\n }\n });\n }\n\n filterOptions() {\n this.filteredOptions = this.options;\n if (!!this.options.length && !!this.filteredValue) {\n this.filteredOptions = this.options.filter(item =>\n item.startsWith(this.filteredValue)\n );\n } else {\n this.filteredOptions = this.options;\n }\n }\n\n generateValuesFromHTMLTags(string: any): string {\n var pattern =\n /<span class=\"chips(?: chip-error)?\" contenteditable=\"false\">(.*?)<\\/span>/g;\n var result = string.replace(pattern, (match: any, option: any) => {\n return '{{' + option + '}}';\n });\n return result;\n }\n\n generateHTMLTagsWithValues(string: any): string {\n var pattern = /{{(.*?)}}/g;\n var result = string.replace(pattern, (match: any, option: any) => {\n return this.options.includes(option)\n ? '<span class=\"chips\" contenteditable=\"false\">' + option + '</span>'\n : '<span class=\"chips chip-error\" contenteditable=\"false\">' +\n option +\n '</span>';\n });\n return result;\n }\n\n emitInputChange(): void {\n if (this.contentEditor) {\n let fieldValue = this.contentEditor.innerHTML;\n if (this.contentEditor.innerText !== '') {\n fieldValue = this.generateValuesFromHTMLTags(fieldValue);\n }\n fieldValue = fieldValue.replace(/ /g, ' ');\n fieldValue = fieldValue === '<br>' ? '' : fieldValue?.trim();\n this.emit('nile-change', {\n value: this.generateValuesFromHTMLTags(fieldValue),\n });\n }\n }\n\n insertNodes(parentNode: Node, childNodes: NodeList, autoOptionsTag?: Node) {\n [...childNodes].forEach((node: Node, index: number) => {\n if (node.hasChildNodes()) {\n if (autoOptionsTag) {\n this.insertNodes(node, node.childNodes, autoOptionsTag);\n } else {\n this.insertNodes(node, node.childNodes);\n }\n } else {\n if (node.nodeValue?.includes(this.tagIdentifier)) {\n if (autoOptionsTag) {\n parentNode.childNodes[index].nodeValue = node.nodeValue?.replace(\n this.tagIdentifier + this.filteredValue,\n ''\n );\n parentNode.childNodes[index].after(autoOptionsTag);\n }\n this.filteredValue =\n parentNode?.childNodes[index]?.nodeValue\n ?.split(this.tagIdentifier)\n .slice(1)\n .join() || '';\n return;\n }\n }\n });\n }\n\n handleOptions(option: any): void {\n this.toggleDropdown(false);\n let autoOptionsTag = document.createElement('span');\n autoOptionsTag.setAttribute('class', 'chips');\n autoOptionsTag.setAttribute('contentEditable', 'false');\n autoOptionsTag.innerText = option;\n this.insertNodes(\n this.contentEditor,\n this.contentEditor.childNodes,\n autoOptionsTag\n );\n this.filteredOptions = this.options;\n this.filteredValue = '';\n this.emitInputChange();\n }\n\n public renderAutoOptions(): TemplateResult {\n return html`<div\n class=\"${classMap({\n 'nile-options-container': true,\n 'dropdown-position': this.type === 'text-area',\n })}\"\n >\n ${this.filteredOptions &&\n this.filteredOptions.map((option: any) => {\n return html` <nile-option\n .value=\"${option}\"\n @click=\"${(event: Event) => {\n this.handleOptions(option);\n }}\"\n >${option}\n </nile-option>`;\n })}\n </div>`;\n }\n\n public render(): TemplateResult {\n const hasHelpText = this.helpText ? true : false;\n const hasError = !!this.error;\n const hasErrorMessage = !!this.errorMessage;\n const readonly = !!this.readonly;\n const type = this.type;\n return html`\n <nile-popup\n .active=\"${live(this.openDropdown)}\"\n sync=\"width\"\n strategy=\"fixed\"\n placement=\"bottom\"\n class=${classMap({\n dropdown: true,\n 'dropdown--open': true,\n popup: true,\n })}\n >\n <div class=\"content-editable-wrapper\" slot=\"anchor\">\n ${this.showLabel && this.labelText\n ? html`<label class=\"ods-label\">${this.labelText} </label> ${this\n .required\n ? html`<span class=\"asterik\">*</span>`\n : ''}`\n : ''}\n <div\n contenteditable=\"${!readonly}\"\n class=${classMap({\n 'content-editable-input': true,\n error: hasError || hasErrorMessage,\n 'read-only': readonly,\n 'text-area': type === 'text-area' ? true : false,\n })}\n @keydown=${this.handlekeyDown}\n ></div>\n ${hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``}\n ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}\n </div>\n\n ${this.renderAutoOptions()}\n </nile-popup>\n `;\n }\n}\n\nexport default NileContentEditor;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-content-editor': NileContentEditor;\n }\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-dialog.css.js","sourceRoot":"","sources":["../../../src/nile-dialog/nile-dialog.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
1
|
+
{"version":3,"file":"nile-dialog.css.js","sourceRoot":"","sources":["../../../src/nile-dialog/nile-dialog.css.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8IxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css } from 'lit-element';\n\n/**\n * Modal CSS\n */\nexport const styles = css`\n :host {\n --width: 31rem;\n --header-spacing: 1.25rem;\n --body-spacing: 1.25rem;\n --footer-spacing: 1.25rem;\n\n display: contents;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n [hidden] {\n display: none !important;\n }\n\n .dialog {\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 800;\n }\n\n .dialog__panel {\n display: flex;\n flex-direction: column;\n z-index: 2;\n width: var(--width);\n max-width: calc(100% - 2.25rem);\n max-height: calc(100% - 2.25rem);\n background-color: hsl(0, 0%, 100%);\n border-radius: 4px;\n box-shadow: 0 4px 16px rgb(0 0 0 / 24%);\n }\n\n .dialog__panel:focus {\n outline: none;\n }\n\n @media screen and (max-width: 420px) {\n .dialog__panel {\n max-height: 80vh;\n }\n }\n\n .dialog--open .dialog__panel {\n display: flex;\n opacity: 1;\n }\n\n .dialog__header {\n flex: 0 0 auto;\n display: flex;\n padding: 12px 24px;\n background-color: #fafafa;\n border-radius: 4px 4px 0 0;\n border: 1px solid #e5e9eb;\n }\n\n .dialog__title {\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n margin: 0;\n color: #000;\n font-family: Colfax-regular;\n font-size: 16px;\n font-style: normal;\n font-weight: 400;\n line-height: 16px;\n letter-spacing: 0.2px;\n }\n\n .dialog__header-actions {\n flex-shrink: 0;\n display: flex;\n flex-wrap: wrap;\n justify-content: end;\n gap: 24px;\n }\n\n .dialog__header-actions nile-icon-button,\n .dialog__header-actions ::slotted(nile-icon-button) {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n font-size: 1rem;\n }\n\n .dialog__body {\n flex: 1 1 auto;\n display: block;\n padding: 1.25rem;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n border: 1px solid #e5e9eb;\n }\n\n .dialog__body-noheader {\n border-radius: 4px 4px 0px 0px;\n }\n\n .dialog__footer {\n flex: 0 0 auto;\n text-align: right;\n padding: 12px 24px;\n background-color: #fafafa;\n border-radius: 0 0 4px 4px;\n border: 1px solid #e5e9eb;\n }\n\n .dialog__footer ::slotted(nile-button:not(:first-of-type)) {\n margin-inline-start: 0.5rem;\n }\n\n .dialog:not(.dialog--has-footer) .dialog__footer {\n display: none;\n }\n\n .dialog__overlay {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: hsl(0 0% 0% / 43%);\n }\n\n @media (forced-colors: active) {\n .dialog__panel {\n border: solid 1px hsl(240, 5.9%, 11%);\n }\n }\n`;\n\nexport default [styles];\n"]}
|
@@ -38,6 +38,10 @@ export declare class NileDialog extends NileElement {
|
|
38
38
|
*/
|
39
39
|
noHeader: boolean;
|
40
40
|
preventOverlayClose: boolean;
|
41
|
+
/**
|
42
|
+
* Added to resolve conflicts between Angular Material's mat-drawer components.
|
43
|
+
*/
|
44
|
+
private drawerStyle;
|
41
45
|
connectedCallback(): void;
|
42
46
|
firstUpdated(): void;
|
43
47
|
disconnectedCallback(): void;
|
@@ -45,6 +45,14 @@ let NileDialog = class NileDialog extends NileElement {
|
|
45
45
|
*/
|
46
46
|
this.noHeader = false;
|
47
47
|
this.preventOverlayClose = false;
|
48
|
+
/**
|
49
|
+
* Added to resolve conflicts between Angular Material's mat-drawer components.
|
50
|
+
*/
|
51
|
+
this.drawerStyle = `
|
52
|
+
<style id="drawer-style">
|
53
|
+
.mat-drawer.mat-drawer-side { z-index: 1; }
|
54
|
+
</style>
|
55
|
+
`;
|
48
56
|
}
|
49
57
|
connectedCallback() {
|
50
58
|
super.connectedCallback();
|
@@ -57,6 +65,7 @@ let NileDialog = class NileDialog extends NileElement {
|
|
57
65
|
this.addOpenListeners();
|
58
66
|
this.modal.activate();
|
59
67
|
lockBodyScrolling(this);
|
68
|
+
document.head.insertAdjacentHTML('beforeend', this.drawerStyle);
|
60
69
|
}
|
61
70
|
}
|
62
71
|
disconnectedCallback() {
|
@@ -66,14 +75,16 @@ let NileDialog = class NileDialog extends NileElement {
|
|
66
75
|
requestClose(source) {
|
67
76
|
const nileRequestClose = this.emit('nile-request-close', {
|
68
77
|
cancelable: true,
|
69
|
-
detail: { source }
|
78
|
+
detail: { source },
|
70
79
|
});
|
71
80
|
if (source === 'close-button') {
|
72
81
|
this.hide();
|
73
82
|
return;
|
74
83
|
}
|
75
84
|
if (nileRequestClose.defaultPrevented || this.preventOverlayClose) {
|
76
|
-
const animation = getAnimation(this, 'dialog.denyClose', {
|
85
|
+
const animation = getAnimation(this, 'dialog.denyClose', {
|
86
|
+
dir: 'right',
|
87
|
+
});
|
77
88
|
animateTo(this.panel, animation.keyframes, animation.options);
|
78
89
|
return;
|
79
90
|
}
|
@@ -93,11 +104,11 @@ let NileDialog = class NileDialog extends NileElement {
|
|
93
104
|
}
|
94
105
|
async handleOpenChange() {
|
95
106
|
if (this.open) {
|
96
|
-
// Show
|
97
107
|
this.emit('nile-show');
|
98
108
|
this.addOpenListeners();
|
99
109
|
this.originalTrigger = document.activeElement;
|
100
110
|
this.modal.activate();
|
111
|
+
document.head.insertAdjacentHTML('beforeend', this.drawerStyle);
|
101
112
|
lockBodyScrolling(this);
|
102
113
|
// When the dialog is shown, Safari will attempt to set focus on whatever element has autofocus. This can cause
|
103
114
|
// the dialogs's animation to jitter (if it starts offscreen), so we'll temporarily remove the attribute, call
|
@@ -109,15 +120,22 @@ let NileDialog = class NileDialog extends NileElement {
|
|
109
120
|
if (autoFocusTarget) {
|
110
121
|
autoFocusTarget.removeAttribute('autofocus');
|
111
122
|
}
|
112
|
-
await Promise.all([
|
123
|
+
await Promise.all([
|
124
|
+
stopAnimations(this.dialog),
|
125
|
+
stopAnimations(this.overlay),
|
126
|
+
]);
|
113
127
|
this.dialog.hidden = false;
|
114
128
|
// Set initial focus
|
115
129
|
requestAnimationFrame(() => {
|
116
|
-
const nileInitialFocus = this.emit('nile-initial-focus', {
|
130
|
+
const nileInitialFocus = this.emit('nile-initial-focus', {
|
131
|
+
cancelable: true,
|
132
|
+
});
|
117
133
|
if (!nileInitialFocus.defaultPrevented) {
|
118
134
|
// Set focus to the autofocus target and restore the attribute
|
119
135
|
if (autoFocusTarget) {
|
120
|
-
autoFocusTarget.focus({
|
136
|
+
autoFocusTarget.focus({
|
137
|
+
preventScroll: true,
|
138
|
+
});
|
121
139
|
}
|
122
140
|
else {
|
123
141
|
this.panel.focus({ preventScroll: true });
|
@@ -128,11 +146,15 @@ let NileDialog = class NileDialog extends NileElement {
|
|
128
146
|
autoFocusTarget.setAttribute('autofocus', '');
|
129
147
|
}
|
130
148
|
});
|
131
|
-
const panelAnimation = getAnimation(this, 'dialog.show', {
|
132
|
-
|
149
|
+
const panelAnimation = getAnimation(this, 'dialog.show', {
|
150
|
+
dir: 'right',
|
151
|
+
});
|
152
|
+
const overlayAnimation = getAnimation(this, 'dialog.overlay.show', {
|
153
|
+
dir: 'right',
|
154
|
+
});
|
133
155
|
await Promise.all([
|
134
156
|
animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),
|
135
|
-
animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)
|
157
|
+
animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options),
|
136
158
|
]);
|
137
159
|
this.emit('nile-after-show');
|
138
160
|
}
|
@@ -141,9 +163,20 @@ let NileDialog = class NileDialog extends NileElement {
|
|
141
163
|
this.emit('nile-hide');
|
142
164
|
this.removeOpenListeners();
|
143
165
|
this.modal.deactivate();
|
144
|
-
await Promise.all([
|
145
|
-
|
146
|
-
|
166
|
+
await Promise.all([
|
167
|
+
stopAnimations(this.dialog),
|
168
|
+
stopAnimations(this.overlay),
|
169
|
+
]);
|
170
|
+
const panelAnimation = getAnimation(this, 'dialog.hide', {
|
171
|
+
dir: 'right',
|
172
|
+
});
|
173
|
+
const overlayAnimation = getAnimation(this, 'dialog.overlay.hide', {
|
174
|
+
dir: 'right',
|
175
|
+
});
|
176
|
+
const styleTag = document.getElementById('drawer-style');
|
177
|
+
if (styleTag) {
|
178
|
+
document.head.removeChild(styleTag);
|
179
|
+
}
|
147
180
|
// Animate the overlay and the panel at the same time. Because animation durations might be different, we need to
|
148
181
|
// hide each one individually when the animation finishes, otherwise the first one that finishes will reappear
|
149
182
|
// unexpectedly. We'll unhide them after all animations have completed.
|
@@ -153,7 +186,7 @@ let NileDialog = class NileDialog extends NileElement {
|
|
153
186
|
}),
|
154
187
|
animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {
|
155
188
|
this.panel.hidden = true;
|
156
|
-
})
|
189
|
+
}),
|
157
190
|
]);
|
158
191
|
this.dialog.hidden = true;
|
159
192
|
// Now that the dialog is hidden, restore the overlay and panel for next time
|
@@ -191,10 +224,15 @@ let NileDialog = class NileDialog extends NileElement {
|
|
191
224
|
class=${classMap({
|
192
225
|
dialog: true,
|
193
226
|
'dialog--open': this.open,
|
194
|
-
'dialog--has-footer': this.hasSlotController.test('footer')
|
227
|
+
'dialog--has-footer': this.hasSlotController.test('footer'),
|
195
228
|
})}
|
196
229
|
>
|
197
|
-
<div
|
230
|
+
<div
|
231
|
+
part="overlay"
|
232
|
+
class="dialog__overlay"
|
233
|
+
@click=${() => this.requestClose('overlay')}
|
234
|
+
tabindex="-1"
|
235
|
+
></div>
|
198
236
|
|
199
237
|
<div
|
200
238
|
part="panel"
|
@@ -210,7 +248,11 @@ let NileDialog = class NileDialog extends NileElement {
|
|
210
248
|
? html `
|
211
249
|
<header part="header" class="dialog__header">
|
212
250
|
<h2 part="title" class="dialog__title" id="title">
|
213
|
-
<slot name="label">
|
251
|
+
<slot name="label">
|
252
|
+
${this.label.length > 0
|
253
|
+
? this.label
|
254
|
+
: String.fromCharCode(65279)}
|
255
|
+
</slot>
|
214
256
|
</h2>
|
215
257
|
<div part="header-actions" class="dialog__header-actions">
|
216
258
|
<slot name="header-actions"></slot>
|
@@ -228,7 +270,12 @@ let NileDialog = class NileDialog extends NileElement {
|
|
228
270
|
`
|
229
271
|
: ''}
|
230
272
|
|
231
|
-
<slot
|
273
|
+
<slot
|
274
|
+
part="body"
|
275
|
+
class="dialog__body ${this.noHeader
|
276
|
+
? 'dialog__body-noheader'
|
277
|
+
: ''}"
|
278
|
+
></slot>
|
232
279
|
|
233
280
|
<footer part="footer" class="dialog__footer">
|
234
281
|
<slot name="footer"></slot>
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"nile-dialog.js","sourceRoot":"","sources":["../../../src/nile-dialog/nile-dialog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAEzC,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAEtC,O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QAC1B,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KACzB;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;CAC3C,CAAC,CAAC;AAEH,mBAAmB,CAAC,aAAa,EAAE;IACjC,SAAS,EAAE;QACT,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QACxB,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;KAC3B;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;CAC3C,CAAC,CAAC;AAEH,mBAAmB,CAAC,kBAAkB,EAAE;IACtC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACxD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;CAC3B,CAAC,CAAC;AAEH,mBAAmB,CAAC,qBAAqB,EAAE;IACzC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;CAC3B,CAAC,CAAC;AAEH,mBAAmB,CAAC,qBAAqB,EAAE;IACzC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;CAC3B,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {LitElement, CSSResultArray, TemplateResult} from 'lit-element';\nimport {styles} from './nile-dialog.css';\n\nimport '../nile-icon-button/nile-icon-button';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { getAnimation, setDefaultAnimation } from '../utilities/animation-registry';\nimport { HasSlotController } from '../internal/slot';\nimport { html } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { lockBodyScrolling, unlockBodyScrolling } from '../internal/scroll';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport Modal from '../internal/modal';\nimport type { CSSResultGroup } from 'lit';\nimport NileElement from '../internal/nile-element';\n/**\n * Nile icon component.\n *\n * @tag nile-modal\n *\n */\n@customElement('nile-dialog')\nexport class NileDialog extends NileElement {\n\n static styles: CSSResultGroup = styles;\n\n private readonly hasSlotController = new HasSlotController(this, 'footer');\n private modal: Modal;\n private originalTrigger: HTMLElement | null;\n\n @query('.dialog') dialog: HTMLElement;\n @query('.dialog__panel') panel: HTMLElement;\n @query('.dialog__overlay') overlay: HTMLElement;\n\n /**\n * Indicates whether or not the dialog is open. You can toggle this attribute to show and hide the dialog, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the dialog's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The dialog's label as displayed in the header. You should always include a relevant label even when using\n * `no-header`, as it is required for proper accessibility. If you need to display HTML, use the `label` slot instead.\n */\n @property({ reflect: true }) label = '';\n\n /**\n * Disables the header. This will also remove the default close button, so please ensure you provide an easy,\n * accessible way for users to dismiss the dialog.\n */\n @property({ type: Boolean, reflect: true }) noHeader = false;\n\n @property({ type: Boolean, reflect: true }) preventOverlayClose = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.modal = new Modal(this);\n }\n\n firstUpdated() {\n this.dialog.hidden = !this.open;\n\n if (this.open) {\n this.addOpenListeners();\n this.modal.activate();\n lockBodyScrolling(this);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unlockBodyScrolling(this);\n }\n\n private requestClose(source: 'close-button' | 'keyboard' | 'overlay') {\n\n const nileRequestClose = this.emit('nile-request-close', {\n cancelable: true,\n detail: { source }\n });\n\n if(source === 'close-button'){\n this.hide();\n return;\n }\n\n if (nileRequestClose.defaultPrevented || this.preventOverlayClose ) {\n const animation = getAnimation(this, 'dialog.denyClose', { dir: 'right'});\n animateTo(this.panel, animation.keyframes, animation.options);\n return;\n }\n\n this.hide();\n }\n\n private addOpenListeners() {\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n private removeOpenListeners() {\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n private handleDocumentKeyDown(event: KeyboardEvent) {\n if (this.open && event.key === 'Escape') {\n event.stopPropagation();\n this.requestClose('keyboard');\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit('nile-show');\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n this.modal.activate();\n\n lockBodyScrolling(this);\n\n // When the dialog is shown, Safari will attempt to set focus on whatever element has autofocus. This can cause\n // the dialogs's animation to jitter (if it starts offscreen), so we'll temporarily remove the attribute, call\n // `focus({ preventScroll: true })` ourselves, and add the attribute back afterwards.\n //\n // Related: https://github.com/shoelace-style/shoelace/issues/693\n //\n const autoFocusTarget = this.querySelector('[autofocus]');\n if (autoFocusTarget) {\n autoFocusTarget.removeAttribute('autofocus');\n }\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n this.dialog.hidden = false;\n\n // Set initial focus\n requestAnimationFrame(() => {\n const nileInitialFocus = this.emit('nile-initial-focus', { cancelable: true });\n\n if (!nileInitialFocus.defaultPrevented) {\n // Set focus to the autofocus target and restore the attribute\n if (autoFocusTarget) {\n (autoFocusTarget as HTMLInputElement).focus({ preventScroll: true });\n } else {\n this.panel.focus({ preventScroll: true });\n }\n }\n\n // Restore the autofocus attribute\n if (autoFocusTarget) {\n autoFocusTarget.setAttribute('autofocus', '');\n }\n });\n\n const panelAnimation = getAnimation(this, 'dialog.show', { dir: 'right' });\n const overlayAnimation = getAnimation(this, 'dialog.overlay.show', { dir: 'right' });\n await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]);\n\n this.emit('nile-after-show');\n } else {\n // Hide\n this.emit('nile-hide');\n this.removeOpenListeners();\n this.modal.deactivate();\n\n await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, 'dialog.hide', { dir: 'right' });\n const overlayAnimation = getAnimation(this, 'dialog.overlay.hide', { dir: 'right' });\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]);\n\n this.dialog.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n unlockBodyScrolling(this);\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === 'function') {\n setTimeout(() => trigger.focus());\n }\n\n this.emit('nile-after-hide');\n }\n }\n\n /** Shows the dialog. */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'nile-after-show');\n }\n\n /** Hides the dialog */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'nile-after-hide');\n }\n\n render() {\n return html`\n <div\n part=\"base\"\n class=${classMap({\n dialog: true,\n 'dialog--open': this.open,\n 'dialog--has-footer': this.hasSlotController.test('footer')\n })}\n >\n <div part=\"overlay\" class=\"dialog__overlay\" @click=${() => this.requestClose('overlay')} tabindex=\"-1\"></div>\n\n <div\n part=\"panel\"\n class=\"dialog__panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden=${this.open ? 'false' : 'true'}\n aria-label=${ifDefined(this.noHeader ? this.label : undefined)}\n aria-labelledby=${ifDefined(!this.noHeader ? 'title' : undefined)}\n tabindex=\"0\"\n >\n ${!this.noHeader\n ? html`\n <header part=\"header\" class=\"dialog__header\">\n <h2 part=\"title\" class=\"dialog__title\" id=\"title\">\n <slot name=\"label\"> ${this.label.length > 0 ? this.label : String.fromCharCode(65279)} </slot>\n </h2>\n <div part=\"header-actions\" class=\"dialog__header-actions\">\n <slot name=\"header-actions\"></slot>\n <nile-icon-button\n part=\"close-button\"\n exportparts=\"base:close-button__base\"\n class=\"dialog__close\"\n name=\"close\"\n label=\"close\"\n library=\"system\"\n @click=\"${() => this.requestClose('close-button')}\"\n ></nile-icon-button>\n </div>\n </header>\n `\n : ''}\n\n <slot part=\"body\" class=\"dialog__body\"></slot>\n\n <footer part=\"footer\" class=\"dialog__footer\">\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation('dialog.show', {\n keyframes: [\n { opacity: 0, scale: 0.8 },\n { opacity: 1, scale: 1 }\n ],\n options: { duration: 250, easing: 'ease' }\n});\n\nsetDefaultAnimation('dialog.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.8 }\n ],\n options: { duration: 250, easing: 'ease' }\n});\n\nsetDefaultAnimation('dialog.denyClose', {\n keyframes: [{ scale: 1 }, { scale: 1.02 }, { scale: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation('dialog.overlay.show', {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation('dialog.overlay.hide', {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 250 }\n});\n\nexport default NileDialog;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-dialog': NileDialog;\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"nile-dialog.js","sourceRoot":"","sources":["../../../src/nile-dialog/nile-dialog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAEzC,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAEtC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD;;;;;GAKG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,WAAW;IAApC;;QAGY,sBAAiB,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAQ3E;;;WAGG;QACyC,SAAI,GAAG,KAAK,CAAC;QAEzD;;;WAGG;QAC0B,UAAK,GAAG,EAAE,CAAC;QAExC;;;WAGG;QACyC,aAAQ,GAAG,KAAK,C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","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {LitElement, CSSResultArray, TemplateResult} from 'lit-element';\nimport {styles} from './nile-dialog.css';\n\nimport '../nile-icon-button/nile-icon-button';\nimport { animateTo, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { getAnimation, setDefaultAnimation } from '../utilities/animation-registry';\nimport { HasSlotController } from '../internal/slot';\nimport { html } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { lockBodyScrolling, unlockBodyScrolling } from '../internal/scroll';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport Modal from '../internal/modal';\nimport type { CSSResultGroup } from 'lit';\nimport NileElement from '../internal/nile-element';\n/**\n * Nile icon component.\n *\n * @tag nile-modal\n *\n */\n@customElement('nile-dialog')\nexport class NileDialog extends NileElement {\n static styles: CSSResultGroup = styles;\n\n private readonly hasSlotController = new HasSlotController(this, 'footer');\n private modal: Modal;\n private originalTrigger: HTMLElement | null;\n\n @query('.dialog') dialog: HTMLElement;\n @query('.dialog__panel') panel: HTMLElement;\n @query('.dialog__overlay') overlay: HTMLElement;\n\n /**\n * Indicates whether or not the dialog is open. You can toggle this attribute to show and hide the dialog, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the dialog's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * The dialog's label as displayed in the header. You should always include a relevant label even when using\n * `no-header`, as it is required for proper accessibility. If you need to display HTML, use the `label` slot instead.\n */\n @property({ reflect: true }) label = '';\n\n /**\n * Disables the header. This will also remove the default close button, so please ensure you provide an easy,\n * accessible way for users to dismiss the dialog.\n */\n @property({ type: Boolean, reflect: true }) noHeader = false;\n\n @property({ type: Boolean, reflect: true }) preventOverlayClose = false;\n\n\n /**\n * Added to resolve conflicts between Angular Material's mat-drawer components.\n */\n private drawerStyle = `\n <style id=\"drawer-style\">\n .mat-drawer.mat-drawer-side { z-index: 1; }\n </style>\n `;\n\n connectedCallback() {\n super.connectedCallback();\n this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);\n this.modal = new Modal(this);\n }\n\n firstUpdated() {\n this.dialog.hidden = !this.open;\n\n if (this.open) {\n this.addOpenListeners();\n this.modal.activate();\n lockBodyScrolling(this);\n document.head.insertAdjacentHTML('beforeend', this.drawerStyle);\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n unlockBodyScrolling(this);\n }\n\n private requestClose(source: 'close-button' | 'keyboard' | 'overlay') {\n const nileRequestClose = this.emit('nile-request-close', {\n cancelable: true,\n detail: { source },\n });\n\n if (source === 'close-button') {\n this.hide();\n return;\n }\n\n if (nileRequestClose.defaultPrevented || this.preventOverlayClose) {\n const animation = getAnimation(this, 'dialog.denyClose', {\n dir: 'right',\n });\n animateTo(this.panel, animation.keyframes, animation.options);\n return;\n }\n\n this.hide();\n }\n\n private addOpenListeners() {\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n private removeOpenListeners() {\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n private handleDocumentKeyDown(event: KeyboardEvent) {\n if (this.open && event.key === 'Escape') {\n event.stopPropagation();\n this.requestClose('keyboard');\n }\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n this.emit('nile-show');\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n this.modal.activate();\n document.head.insertAdjacentHTML('beforeend', this.drawerStyle);\n lockBodyScrolling(this);\n\n // When the dialog is shown, Safari will attempt to set focus on whatever element has autofocus. This can cause\n // the dialogs's animation to jitter (if it starts offscreen), so we'll temporarily remove the attribute, call\n // `focus({ preventScroll: true })` ourselves, and add the attribute back afterwards.\n //\n // Related: https://github.com/shoelace-style/shoelace/issues/693\n //\n const autoFocusTarget = this.querySelector('[autofocus]');\n if (autoFocusTarget) {\n autoFocusTarget.removeAttribute('autofocus');\n }\n\n await Promise.all([\n stopAnimations(this.dialog),\n stopAnimations(this.overlay),\n ]);\n this.dialog.hidden = false;\n\n // Set initial focus\n requestAnimationFrame(() => {\n const nileInitialFocus = this.emit('nile-initial-focus', {\n cancelable: true,\n });\n\n if (!nileInitialFocus.defaultPrevented) {\n // Set focus to the autofocus target and restore the attribute\n if (autoFocusTarget) {\n (autoFocusTarget as HTMLInputElement).focus({\n preventScroll: true,\n });\n } else {\n this.panel.focus({ preventScroll: true });\n }\n }\n\n // Restore the autofocus attribute\n if (autoFocusTarget) {\n autoFocusTarget.setAttribute('autofocus', '');\n }\n });\n\n const panelAnimation = getAnimation(this, 'dialog.show', {\n dir: 'right',\n });\n const overlayAnimation = getAnimation(this, 'dialog.overlay.show', {\n dir: 'right',\n });\n await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(\n this.overlay,\n overlayAnimation.keyframes,\n overlayAnimation.options\n ),\n ]);\n\n this.emit('nile-after-show');\n } else {\n // Hide\n this.emit('nile-hide');\n this.removeOpenListeners();\n this.modal.deactivate();\n\n await Promise.all([\n stopAnimations(this.dialog),\n stopAnimations(this.overlay),\n ]);\n const panelAnimation = getAnimation(this, 'dialog.hide', {\n dir: 'right',\n });\n const overlayAnimation = getAnimation(this, 'dialog.overlay.hide', {\n dir: 'right',\n });\n\n const styleTag = document.getElementById('drawer-style');\n if (styleTag) {\n document.head.removeChild(styleTag);\n }\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n await Promise.all([\n animateTo(\n this.overlay,\n overlayAnimation.keyframes,\n overlayAnimation.options\n ).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(\n this.panel,\n panelAnimation.keyframes,\n panelAnimation.options\n ).then(() => {\n this.panel.hidden = true;\n }),\n ]);\n\n this.dialog.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n unlockBodyScrolling(this);\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === 'function') {\n setTimeout(() => trigger.focus());\n }\n\n this.emit('nile-after-hide');\n }\n }\n\n /** Shows the dialog. */\n async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'nile-after-show');\n }\n\n /** Hides the dialog */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'nile-after-hide');\n }\n\n render() {\n return html`\n <div\n part=\"base\"\n class=${classMap({\n dialog: true,\n 'dialog--open': this.open,\n 'dialog--has-footer': this.hasSlotController.test('footer'),\n })}\n >\n <div\n part=\"overlay\"\n class=\"dialog__overlay\"\n @click=${() => this.requestClose('overlay')}\n tabindex=\"-1\"\n ></div>\n\n <div\n part=\"panel\"\n class=\"dialog__panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-hidden=${this.open ? 'false' : 'true'}\n aria-label=${ifDefined(this.noHeader ? this.label : undefined)}\n aria-labelledby=${ifDefined(!this.noHeader ? 'title' : undefined)}\n tabindex=\"0\"\n >\n ${!this.noHeader\n ? html`\n <header part=\"header\" class=\"dialog__header\">\n <h2 part=\"title\" class=\"dialog__title\" id=\"title\">\n <slot name=\"label\">\n ${this.label.length > 0\n ? this.label\n : String.fromCharCode(65279)}\n </slot>\n </h2>\n <div part=\"header-actions\" class=\"dialog__header-actions\">\n <slot name=\"header-actions\"></slot>\n <nile-icon-button\n part=\"close-button\"\n exportparts=\"base:close-button__base\"\n class=\"dialog__close\"\n name=\"close\"\n label=\"close\"\n library=\"system\"\n @click=\"${() => this.requestClose('close-button')}\"\n ></nile-icon-button>\n </div>\n </header>\n `\n : ''}\n\n <slot\n part=\"body\"\n class=\"dialog__body ${this.noHeader\n ? 'dialog__body-noheader'\n : ''}\"\n ></slot>\n\n <footer part=\"footer\" class=\"dialog__footer\">\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n </div>\n `;\n }\n}\n\nsetDefaultAnimation('dialog.show', {\n keyframes: [\n { opacity: 0, scale: 0.8 },\n { opacity: 1, scale: 1 }\n ],\n options: { duration: 250, easing: 'ease' }\n});\n\nsetDefaultAnimation('dialog.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.8 }\n ],\n options: { duration: 250, easing: 'ease' }\n});\n\nsetDefaultAnimation('dialog.denyClose', {\n keyframes: [{ scale: 1 }, { scale: 1.02 }, { scale: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation('dialog.overlay.show', {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation('dialog.overlay.hide', {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 250 }\n});\n\nexport default NileDialog;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-dialog': NileDialog;\n }\n}\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
2
|
* Do not edit directly
|
3
3
|
*/
|
4
|
-
declare const _default: "
|
4
|
+
declare const _default: "PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjUiIHZpZXdCb3g9IjAgMCAyNCAyNSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMuNzUgNS43MzgyOEMzLjc1IDQuNDk1NjQgNC43NTczNiAzLjQ4ODI4IDYgMy40ODgyOEgxMy4zNzVWNS43MzgyOEMxMy4zNzUgNy44MDkzNSAxNS4wNTM5IDkuNDg4MjggMTcuMTI1IDkuNDg4MjhIMjAuMjVWMTkuNzM4M0MyMC4yNSAyMC45ODA5IDE5LjI0MjYgMjEuOTg4MyAxO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