@redvars/peacock 3.2.8 → 3.2.9
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/{PeacockComponent-DMrFEGDh.js → PeacockComponent-CxJc63xj.js} +6 -13
- package/dist/PeacockComponent-CxJc63xj.js.map +1 -0
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/{button-BtpAXuLN.js → button-2MeDq0Yy.js} +11 -293
- package/dist/button-2MeDq0Yy.js.map +1 -0
- package/dist/button-group.js +3 -2
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +6 -4
- package/dist/button.js.map +1 -1
- package/dist/{class-map-CbncA34D.js → class-map-BvQRv7eW.js} +3 -2
- package/dist/class-map-BvQRv7eW.js.map +1 -0
- package/dist/clock.js +85 -0
- package/dist/clock.js.map +1 -0
- package/dist/code-editor.js +43877 -0
- package/dist/code-editor.js.map +1 -0
- package/dist/code-highlighter.js +5 -4
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +561 -0
- package/dist/custom-elements.json +777 -194
- package/dist/directive-Cuw6h7YA.js +9 -0
- package/dist/directive-Cuw6h7YA.js.map +1 -0
- package/dist/dispatch-event-utils-vbdiOSeC.js +290 -0
- package/dist/dispatch-event-utils-vbdiOSeC.js.map +1 -0
- package/dist/{breadcrumb-item-DkhwoMAH.js → image-DK6VQW7N.js} +255 -92
- package/dist/image-DK6VQW7N.js.map +1 -0
- package/dist/index.js +12 -87
- package/dist/index.js.map +1 -1
- package/dist/number-counter.js +3 -2
- package/dist/number-counter.js.map +1 -1
- package/dist/observe-theme-change-NneLARW8.js +51 -0
- package/dist/observe-theme-change-NneLARW8.js.map +1 -0
- package/dist/peacock-loader.js +22 -11
- package/dist/peacock-loader.js.map +1 -1
- package/dist/src/code-editor/code-editor.d.ts +45 -0
- package/dist/src/code-editor/index.d.ts +2 -0
- package/dist/src/image/image.d.ts +45 -0
- package/dist/src/image/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/dispatch-event-utils.d.ts +72 -0
- package/dist/src/utils/observe-theme-change.d.ts +3 -0
- package/dist/src/utils.d.ts +1 -72
- package/dist/{state-CEVpI7Vv.js → state-B09bP3XH.js} +2 -2
- package/dist/{state-CEVpI7Vv.js.map → state-B09bP3XH.js.map} +1 -1
- package/dist/{style-map-mOmZwsJT.js → style-map-B8xgVEc9.js} +3 -2
- package/dist/style-map-B8xgVEc9.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{unsafe-html-Ca00SXpn.js → unsafe-html-B-dV3Jps.js} +3 -2
- package/dist/unsafe-html-B-dV3Jps.js.map +1 -0
- package/package.json +5 -3
- package/scss/styles.scss +57 -1
- package/scss/tokens.css +1 -0
- package/src/accordion/accordion-item/accordion-item.scss +1 -1
- package/src/button/BaseButton.ts +1 -1
- package/src/clock/clock.ts +4 -1
- package/src/code-editor/code-editor.scss +52 -0
- package/src/code-editor/code-editor.ts +215 -0
- package/src/code-editor/demo/index.html +37 -0
- package/src/code-editor/index.ts +3 -0
- package/src/container/container.scss +1 -1
- package/src/date-picker/date-picker.ts +1 -1
- package/src/image/image.scss +49 -0
- package/src/image/image.ts +135 -0
- package/src/image/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/input/input.ts +1 -2
- package/src/menu/menu-item/menu-item.scss +5 -4
- package/src/menu/menu-list/menu-list.scss +1 -0
- package/src/number-field/number-field.ts +1 -1
- package/src/peacock-loader.ts +7 -0
- package/src/textarea/textarea.ts +1 -1
- package/src/time-picker/time-picker.ts +1 -1
- package/src/utils/dispatch-event-utils.ts +131 -0
- package/src/utils/observe-theme-change.ts +30 -0
- package/src/utils.ts +5 -131
- package/dist/PeacockComponent-DMrFEGDh.js.map +0 -1
- package/dist/breadcrumb-item-DkhwoMAH.js.map +0 -1
- package/dist/button-BtpAXuLN.js.map +0 -1
- package/dist/class-map-CbncA34D.js.map +0 -1
- package/dist/style-map-mOmZwsJT.js.map +0 -1
- package/dist/unsafe-html-Ca00SXpn.js.map +0 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { html, nothing } from 'lit';
|
|
2
|
+
import { property, state, query } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import {init} from 'modern-monaco';
|
|
5
|
+
import PeacockComponent from 'src/PeacockComponent.js';
|
|
6
|
+
import BaseInput from '../input/BaseInput.js';
|
|
7
|
+
import { observeThemeChange } from '../utils/observe-theme-change.js';
|
|
8
|
+
import { redispatchEvent } from '../utils/dispatch-event-utils.js';
|
|
9
|
+
import {
|
|
10
|
+
isDarkMode,
|
|
11
|
+
} from '../utils.js';
|
|
12
|
+
|
|
13
|
+
import styles from './code-editor.scss';
|
|
14
|
+
|
|
15
|
+
// At module level, outside the class
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
// At module level, outside the class
|
|
18
|
+
(self as any).MonacoEnvironment = {
|
|
19
|
+
getWorkerUrl(moduleId: string, label: string) {
|
|
20
|
+
const workersDir = new URL('monaco/workers/', import.meta.url);
|
|
21
|
+
switch (label) {
|
|
22
|
+
case 'json': return `${workersDir}json.worker.js`;
|
|
23
|
+
case 'css': return `${workersDir}css.worker.js`;
|
|
24
|
+
case 'html': return `${workersDir}html.worker.js`;
|
|
25
|
+
case 'typescript':
|
|
26
|
+
case 'javascript': return `${workersDir}ts.worker.js`;
|
|
27
|
+
default: return `${workersDir}editor.worker.js`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @label Code Editor
|
|
34
|
+
* @tag code-editor
|
|
35
|
+
* @rawTag code-editor
|
|
36
|
+
*
|
|
37
|
+
* @summary Code editor
|
|
38
|
+
* @overview
|
|
39
|
+
* - CodeHighlighter is a component that provides syntax highlighting for code snippets.
|
|
40
|
+
* - It supports various programming languages and can display line numbers for better readability.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```html
|
|
44
|
+
* <code-highlighter language="javascript" style="height: 9rem"><pre><code>
|
|
45
|
+
* function helloWorld() {
|
|
46
|
+
* console.log('Hello, world!');
|
|
47
|
+
* }</code></pre>
|
|
48
|
+
* </code-highlighter>
|
|
49
|
+
* ```
|
|
50
|
+
* @tags display
|
|
51
|
+
*/
|
|
52
|
+
@PeacockComponent
|
|
53
|
+
export default class CodeEditor extends BaseInput {
|
|
54
|
+
|
|
55
|
+
static styles = [styles];
|
|
56
|
+
|
|
57
|
+
@property({ type: String })
|
|
58
|
+
name = "";
|
|
59
|
+
|
|
60
|
+
@property({ type: String })
|
|
61
|
+
value = '';
|
|
62
|
+
|
|
63
|
+
@property({ type: String })
|
|
64
|
+
language: 'javascript' | 'json' | 'html' = 'javascript';
|
|
65
|
+
|
|
66
|
+
@property({ type: Object })
|
|
67
|
+
libSource: any;
|
|
68
|
+
|
|
69
|
+
@property({ type: String })
|
|
70
|
+
lineNumbers: 'off' | 'on' = 'on';
|
|
71
|
+
|
|
72
|
+
@property({ type: Boolean })
|
|
73
|
+
minimap = false;
|
|
74
|
+
|
|
75
|
+
@state() private _isDarkMode: boolean = isDarkMode();
|
|
76
|
+
|
|
77
|
+
@state() private hasFocus = false;
|
|
78
|
+
|
|
79
|
+
// Type the instance correctly using the npm package types
|
|
80
|
+
@state() private editorMonacoInstance?: any;
|
|
81
|
+
|
|
82
|
+
@query('.editor') private editorElement!: HTMLElement;
|
|
83
|
+
|
|
84
|
+
monaco: any;
|
|
85
|
+
|
|
86
|
+
connectedCallback() {
|
|
87
|
+
super.connectedCallback();
|
|
88
|
+
observeThemeChange(() => {
|
|
89
|
+
this._isDarkMode = isDarkMode();
|
|
90
|
+
this.monaco.editor.setTheme(this.getTheme());
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Cleanup to prevent memory leaks
|
|
95
|
+
disconnectedCallback() {
|
|
96
|
+
super.disconnectedCallback();
|
|
97
|
+
this.editorMonacoInstance?.dispose();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected firstUpdated() {
|
|
101
|
+
this.initializeMonaco();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
protected updated(changedProperties: any) {
|
|
105
|
+
if (changedProperties.has('libSource')) this.libSourceChanged();
|
|
106
|
+
|
|
107
|
+
if (changedProperties.has('disabled') || changedProperties.has('readonly')) {
|
|
108
|
+
this.editorMonacoInstance?.updateOptions({
|
|
109
|
+
readOnly: this.disabled || this.readonly,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (changedProperties.has('value')) {
|
|
114
|
+
if (this.editorMonacoInstance && this.editorMonacoInstance.getValue() !== this.value) {
|
|
115
|
+
this.editorMonacoInstance.setValue(this.value || '');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
private libSourceChanged() {
|
|
123
|
+
const libUri = 'java://peacock.redvars.com/lib.java';
|
|
124
|
+
const libModel = this.monaco.editor.getModel(this.monaco.Uri.parse(libUri));
|
|
125
|
+
|
|
126
|
+
if (libModel) libModel.dispose();
|
|
127
|
+
|
|
128
|
+
if (this.libSource) {
|
|
129
|
+
this.monaco.editor.createModel(
|
|
130
|
+
this.libSource,
|
|
131
|
+
this.language,
|
|
132
|
+
this.monaco.Uri.parse(libUri)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
private getTheme() {
|
|
139
|
+
return this._isDarkMode ? 'github-dark' : 'github-light';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async initializeMonaco() {
|
|
143
|
+
this.monaco = await init({
|
|
144
|
+
themes: [
|
|
145
|
+
"github-light",
|
|
146
|
+
"github-dark",
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
this.editorMonacoInstance = this.monaco.editor.create(this.editorElement, {
|
|
152
|
+
value: this.value,
|
|
153
|
+
lineNumbers: this.lineNumbers,
|
|
154
|
+
language: this.language,
|
|
155
|
+
minimap: { enabled: this.minimap },
|
|
156
|
+
theme: this.getTheme(),
|
|
157
|
+
readOnly: this.disabled || this.readonly
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if (this.libSource) {
|
|
163
|
+
this.libSourceChanged();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.editorMonacoInstance.onDidChangeModelContent((e: any) => {
|
|
167
|
+
if (!e.isFlush) {
|
|
168
|
+
const newValue = this.editorMonacoInstance!.getValue();
|
|
169
|
+
this.value = newValue;
|
|
170
|
+
redispatchEvent(this, new Event('change', { bubbles: true, composed: true }));
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
this.editorMonacoInstance.onDidFocusEditorText(() => {
|
|
175
|
+
this.hasFocus = true;
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
this.editorMonacoInstance.onDidBlurEditorText(() => {
|
|
179
|
+
this.hasFocus = false
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
async setFocus() { this.editorMonacoInstance?.focus(); }
|
|
185
|
+
|
|
186
|
+
async setBlur() { this.editorMonacoInstance?.trigger('keyboard', 'type', ''); /* Focus hack or use blur if available */ }
|
|
187
|
+
|
|
188
|
+
render() {
|
|
189
|
+
return html`
|
|
190
|
+
<base-field
|
|
191
|
+
?required=${this.required}
|
|
192
|
+
?disabled=${this.disabled}
|
|
193
|
+
?readonly=${this.readonly}
|
|
194
|
+
?skeleton=${this.skeleton}
|
|
195
|
+
?focused=${this.hasFocus}
|
|
196
|
+
.host=${this}
|
|
197
|
+
class="${classMap({
|
|
198
|
+
'code-editor-component': true,
|
|
199
|
+
'disabled': this.disabled,
|
|
200
|
+
})}"
|
|
201
|
+
>
|
|
202
|
+
${(this.disabled || this.readonly)
|
|
203
|
+
? html`<base-tag class="read-only-tag" color="red">Read Only</base-tag>`
|
|
204
|
+
: nothing
|
|
205
|
+
}
|
|
206
|
+
<div class="editor"></div>
|
|
207
|
+
${!this.editorMonacoInstance ? html`
|
|
208
|
+
<div class="code-editor-loader">
|
|
209
|
+
<base-spinner></base-spinner> Loading...
|
|
210
|
+
</div>
|
|
211
|
+
` : nothing}
|
|
212
|
+
</base-field>
|
|
213
|
+
`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang='en-GB' data-theme="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<meta name='viewport' content='width=device-width, initial-scale=1.0, viewport-fit=cover' />
|
|
6
|
+
<link rel='stylesheet' href='/dist/assets/styles.css' />
|
|
7
|
+
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
background: var(--color-surface);
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<code-editor style="height: 400px" id="business-rule-editor" language="javascript" ></code-editor>
|
|
20
|
+
|
|
21
|
+
<script type='module'>
|
|
22
|
+
import '/dist/peacock-loader.js';
|
|
23
|
+
|
|
24
|
+
document.getElementById("business-rule-editor").value = `/**
|
|
25
|
+
* Sample Code
|
|
26
|
+
*/
|
|
27
|
+
function myBusinessRuleFunction(){
|
|
28
|
+
const a = 1;
|
|
29
|
+
const b = 2;
|
|
30
|
+
let c = a + b;
|
|
31
|
+
console.log(c);
|
|
32
|
+
}`;
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { redispatchEvent } from 'src/utils/dispatch-event-utils.js';
|
|
3
4
|
import BaseInput from '../input/BaseInput.js';
|
|
4
5
|
import styles from './date-picker.scss';
|
|
5
6
|
import { spread } from '../spread.js';
|
|
6
|
-
import { redispatchEvent } from '../utils.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @label Date Picker
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.image-wrapper {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: inline-block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
img {
|
|
11
|
+
display: block;
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
img.clickable {
|
|
16
|
+
cursor: zoom-in;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.placeholder {
|
|
20
|
+
background: #e0e0e0;
|
|
21
|
+
min-width: 100px;
|
|
22
|
+
min-height: 100px;
|
|
23
|
+
display: block;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Preview overlay — rendered in light DOM via portal, but we keep
|
|
27
|
+
a host-level overlay as a fallback when shadow DOM is used. */
|
|
28
|
+
.preview-overlay {
|
|
29
|
+
display: none;
|
|
30
|
+
position: fixed;
|
|
31
|
+
inset: 0;
|
|
32
|
+
z-index: 9999;
|
|
33
|
+
background: rgba(0, 0, 0, 0.85);
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
cursor: zoom-out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.preview-overlay.open {
|
|
40
|
+
display: flex;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.preview-overlay img {
|
|
44
|
+
max-width: 90vw;
|
|
45
|
+
max-height: 90vh;
|
|
46
|
+
object-fit: contain;
|
|
47
|
+
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
|
|
48
|
+
border-radius: 4px;
|
|
49
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { LitElement, html } from 'lit';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
|
+
import { isDarkMode } from '../utils.js';
|
|
4
|
+
import { observeThemeChange } from '../utils/observe-theme-change.js';
|
|
5
|
+
|
|
6
|
+
import styles from './image.scss';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @label Image
|
|
10
|
+
* @tag base-image
|
|
11
|
+
* @rawTag image
|
|
12
|
+
*
|
|
13
|
+
* @summary Image
|
|
14
|
+
* @overview
|
|
15
|
+
* - CodeHighlighter is a component that provides syntax highlighting for code snippets.
|
|
16
|
+
* - It supports various programming languages and can display line numbers for better readability.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```html
|
|
20
|
+
* <code-highlighter language="javascript" style="height: 9rem"><pre><code>
|
|
21
|
+
* function helloWorld() {
|
|
22
|
+
* console.log('Hello, world!');
|
|
23
|
+
* }</code></pre>
|
|
24
|
+
* </code-highlighter>
|
|
25
|
+
* ```
|
|
26
|
+
* @tags display
|
|
27
|
+
*/
|
|
28
|
+
export class Image extends LitElement {
|
|
29
|
+
static styles = [styles];
|
|
30
|
+
|
|
31
|
+
/** Primary image source */
|
|
32
|
+
@property({ reflect: true }) src = '';
|
|
33
|
+
|
|
34
|
+
/** Optional dark-mode image source */
|
|
35
|
+
@property({ reflect: true, attribute: 'dark-src' }) darkSrc = '';
|
|
36
|
+
|
|
37
|
+
/** Alt text / title for the image */
|
|
38
|
+
@property({ attribute: 'image-title' }) imageTitle = '';
|
|
39
|
+
|
|
40
|
+
/** Enable click-to-preview lightbox */
|
|
41
|
+
@property({ type: Boolean, reflect: true }) preview = false;
|
|
42
|
+
|
|
43
|
+
@state() private _isDarkMode: boolean = isDarkMode();
|
|
44
|
+
|
|
45
|
+
@state() private _loaded = false;
|
|
46
|
+
|
|
47
|
+
@state() private _previewOpen = false;
|
|
48
|
+
|
|
49
|
+
private _intersectionObserver: IntersectionObserver | null = null;
|
|
50
|
+
|
|
51
|
+
private _themeCleanup: (() => void) | null = null;
|
|
52
|
+
|
|
53
|
+
connectedCallback() {
|
|
54
|
+
super.connectedCallback();
|
|
55
|
+
|
|
56
|
+
// Theme observation
|
|
57
|
+
this._themeCleanup = observeThemeChange(() => {
|
|
58
|
+
this._isDarkMode = isDarkMode();
|
|
59
|
+
// Reset lazy-load state so new src is loaded when visible
|
|
60
|
+
this._loaded = false;
|
|
61
|
+
this._setupIntersectionObserver();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
disconnectedCallback() {
|
|
66
|
+
super.disconnectedCallback();
|
|
67
|
+
this._intersectionObserver?.disconnect();
|
|
68
|
+
this._themeCleanup?.();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
firstUpdated() {
|
|
72
|
+
this._setupIntersectionObserver();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private _setupIntersectionObserver() {
|
|
76
|
+
this._intersectionObserver?.disconnect();
|
|
77
|
+
|
|
78
|
+
const wrapper = this.shadowRoot?.querySelector('.image-wrapper');
|
|
79
|
+
if (!wrapper) return;
|
|
80
|
+
|
|
81
|
+
this._intersectionObserver = new IntersectionObserver(
|
|
82
|
+
(entries) => {
|
|
83
|
+
if (entries[0].isIntersecting) {
|
|
84
|
+
this._loaded = true;
|
|
85
|
+
this._intersectionObserver?.disconnect();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{ rootMargin: '200px' } // start loading slightly before entering viewport
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
this._intersectionObserver.observe(wrapper);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private get _activeSrc(): string {
|
|
95
|
+
return this._isDarkMode && this.darkSrc ? this.darkSrc : this.src;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private _handleClick() {
|
|
99
|
+
if (this.preview) {
|
|
100
|
+
this._previewOpen = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private _closePreview(e: Event) {
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
this._previewOpen = false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
render() {
|
|
110
|
+
return html`
|
|
111
|
+
<div class="image-wrapper">
|
|
112
|
+
${this._loaded
|
|
113
|
+
? html`<img
|
|
114
|
+
src=${this._activeSrc}
|
|
115
|
+
alt=${this.imageTitle}
|
|
116
|
+
class=${this.preview ? 'clickable' : ''}
|
|
117
|
+
@click=${this._handleClick}
|
|
118
|
+
/>`
|
|
119
|
+
: html`<span class="placeholder" aria-hidden="true"></span>`}
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<!-- Lightbox preview overlay (inside shadow root) -->
|
|
123
|
+
<div
|
|
124
|
+
class="preview-overlay ${this._previewOpen ? 'open' : ''}"
|
|
125
|
+
role="dialog"
|
|
126
|
+
aria-modal="true"
|
|
127
|
+
aria-label="Image preview"
|
|
128
|
+
@click=${this._closePreview}
|
|
129
|
+
@keydown=${(e: KeyboardEvent) => e.key === 'Escape' && this._closePreview(e)}
|
|
130
|
+
>
|
|
131
|
+
<img src=${this._activeSrc} alt=${this.imageTitle} @click=${(e: Event) => e.stopPropagation()} />
|
|
132
|
+
</div>
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Image} from './image.js';
|
package/src/index.ts
CHANGED
|
@@ -31,3 +31,5 @@ export { Tooltip } from './popover/index.js';
|
|
|
31
31
|
export { Breadcrumb, BreadcrumbItem } from './breadcrumb/index.js';
|
|
32
32
|
|
|
33
33
|
export { CodeHighlighter } from './code-highlighter/index.js';
|
|
34
|
+
export { CodeEditor } from './code-editor/index.js';
|
|
35
|
+
export { Image } from './image/index.js';
|
package/src/input/input.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { html, nothing } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { redispatchEvent } from 'src/utils/dispatch-event-utils.js';
|
|
3
4
|
import BaseInput from './BaseInput.js';
|
|
4
5
|
import styles from './input.scss';
|
|
5
6
|
import { spread } from '../spread.js';
|
|
6
|
-
import { redispatchEvent } from '../utils.js';
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* @label Input
|
|
10
9
|
* @tag input-field
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
align-items: center;
|
|
14
14
|
padding-inline: 0.75rem;
|
|
15
15
|
outline: 0;
|
|
16
|
+
text-decoration: none;
|
|
16
17
|
|
|
17
18
|
@include mixin.get-typography(label-large);
|
|
18
19
|
|
|
@@ -93,10 +94,10 @@
|
|
|
93
94
|
&.selected {
|
|
94
95
|
--_container-color: var(--menu-item-container-selected-color);
|
|
95
96
|
--_label-text-color: var(--menu-item-label-selected-color);
|
|
96
|
-
--_container-shape-start-start: var(--
|
|
97
|
-
--_container-shape-start-end: var(--
|
|
98
|
-
--_container-shape-end-start: var(--
|
|
99
|
-
--_container-shape-end-end: var(--
|
|
97
|
+
--_container-shape-start-start: var(--shape-corner-large);
|
|
98
|
+
--_container-shape-start-end: var(--shape-corner-large);
|
|
99
|
+
--_container-shape-end-start: var(--shape-corner-large);
|
|
100
|
+
--_container-shape-end-end: var(--shape-corner-large);
|
|
100
101
|
--_container-corner-shape-variant: none;
|
|
101
102
|
}
|
|
102
103
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html, nothing } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { redispatchEvent } from 'src/utils/dispatch-event-utils.js';
|
|
4
5
|
import BaseInput from '../input/BaseInput.js';
|
|
5
6
|
import styles from './number-field.scss';
|
|
6
7
|
import { spread } from '../spread.js';
|
|
7
|
-
import { redispatchEvent } from '../utils.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @label Number Field
|
package/src/peacock-loader.ts
CHANGED
|
@@ -39,6 +39,7 @@ import { Spinner } from './spinner/spinner.js';
|
|
|
39
39
|
|
|
40
40
|
import { EmptyState } from './empty-state/empty-state.js';
|
|
41
41
|
import { Container } from './container/container.js';
|
|
42
|
+
import { Image } from './image/image.js';
|
|
42
43
|
|
|
43
44
|
import { LoaderConfig, LoaderUtils } from './LoaderUtils.js';
|
|
44
45
|
import { loadCSS } from './CssLoader.js';
|
|
@@ -151,6 +152,9 @@ const loaderConfig: LoaderConfig = {
|
|
|
151
152
|
'number-counter': {
|
|
152
153
|
importPath: `${distDirectory}/number-counter.js`,
|
|
153
154
|
},
|
|
155
|
+
'code-editor': {
|
|
156
|
+
importPath: `${distDirectory}/code-editor.js`,
|
|
157
|
+
},
|
|
154
158
|
'code-highlighter': {
|
|
155
159
|
importPath: `${distDirectory}/code-highlighter.js`,
|
|
156
160
|
},
|
|
@@ -183,6 +187,9 @@ const loaderConfig: LoaderConfig = {
|
|
|
183
187
|
},
|
|
184
188
|
'base-container': {
|
|
185
189
|
CustomElementClass: Container
|
|
190
|
+
},
|
|
191
|
+
'base-image': {
|
|
192
|
+
CustomElementClass: Image
|
|
186
193
|
}
|
|
187
194
|
},
|
|
188
195
|
};
|
package/src/textarea/textarea.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { redispatchEvent } from 'src/utils/dispatch-event-utils.js';
|
|
3
4
|
import BaseInput from '../input/BaseInput.js';
|
|
4
5
|
import styles from './textarea.scss';
|
|
5
6
|
import { spread } from '../spread.js';
|
|
6
|
-
import { redispatchEvent } from '../utils.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @label Textarea
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { redispatchEvent } from 'src/utils/dispatch-event-utils.js';
|
|
3
4
|
import BaseInput from '../input/BaseInput.js';
|
|
4
5
|
import styles from './time-picker.scss';
|
|
5
6
|
import { spread } from '../spread.js';
|
|
6
|
-
import { redispatchEvent } from '../utils.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @label Time Picker
|