@aquera/nile-elements 0.0.51 → 0.0.53
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/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +173 -99
- package/dist/nile-input/index.cjs.js +1 -1
- package/dist/nile-input/index.esm.js +1 -1
- package/dist/nile-input/nile-input.cjs.js +1 -1
- package/dist/nile-input/nile-input.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.css.cjs.js +1 -1
- package/dist/nile-input/nile-input.css.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.css.esm.js +23 -6
- package/dist/nile-input/nile-input.esm.js +9 -3
- package/dist/nile-textarea/index.cjs.js +1 -1
- package/dist/nile-textarea/index.esm.js +1 -1
- package/dist/nile-textarea/nile-textarea.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.css.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.css.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.css.esm.js +41 -8
- package/dist/nile-textarea/nile-textarea.esm.js +58 -40
- package/dist/src/nile-input/nile-input.css.js +23 -6
- package/dist/src/nile-input/nile-input.css.js.map +1 -1
- package/dist/src/nile-input/nile-input.d.ts +2 -1
- package/dist/src/nile-input/nile-input.js +20 -6
- package/dist/src/nile-input/nile-input.js.map +1 -1
- package/dist/src/nile-textarea/nile-textarea.css.js +41 -8
- package/dist/src/nile-textarea/nile-textarea.css.js.map +1 -1
- package/dist/src/nile-textarea/nile-textarea.d.ts +7 -2
- package/dist/src/nile-textarea/nile-textarea.js +107 -45
- package/dist/src/nile-textarea/nile-textarea.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-input/nile-input.css.ts +23 -6
- package/src/nile-input/nile-input.ts +23 -9
- package/src/nile-textarea/nile-textarea.css.ts +41 -8
- package/src/nile-textarea/nile-textarea.ts +127 -62
package/package.json
CHANGED
@@ -477,19 +477,36 @@ export const styles = css`
|
|
477
477
|
}
|
478
478
|
|
479
479
|
.input__non-printable {
|
480
|
-
width: 280px;
|
481
|
-
height: 12px;
|
482
480
|
border-radius: 4px;
|
483
|
-
|
484
|
-
|
485
|
-
|
481
|
+
max-width: 400px;
|
482
|
+
background-color: var(--nile-colors-white-base);
|
483
|
+
border: 1px solid var(--nile-colors-red-500);
|
484
|
+
color: var(--nile-colors-red-500);
|
486
485
|
padding: 10px;
|
487
486
|
font-size: 12px;
|
487
|
+
max-height: 300px;
|
488
|
+
overflow-y: scroll;
|
488
489
|
}
|
489
490
|
|
490
491
|
.input__remove-non-printable {
|
491
|
-
color:
|
492
|
+
color: var(--nile-colors-red-500);
|
492
493
|
margin-left: 10px;
|
494
|
+
font-size: 14px;
|
495
|
+
color: var(--nile-colors-dark-900);
|
496
|
+
}
|
497
|
+
|
498
|
+
.input__srtiked-text-container {
|
499
|
+
margin-top: 4px;
|
500
|
+
color: var(--nile-colors-dark-900);
|
501
|
+
word-wrap: break-all;
|
502
|
+
line-height: 16px;
|
503
|
+
}
|
504
|
+
|
505
|
+
.input__srtiked-text {
|
506
|
+
text-decoration: line-through;
|
507
|
+
text-decoration-color: var(--nile-colors-white-base);
|
508
|
+
color: var(--nile-colors-white-base);
|
509
|
+
background-color: var(--nile-colors-red-500);
|
493
510
|
}
|
494
511
|
`;
|
495
512
|
|
@@ -25,6 +25,7 @@ import { live } from 'lit/directives/live.js';
|
|
25
25
|
import { watch } from '../internal/watch';
|
26
26
|
import type { CSSResultGroup } from 'lit';
|
27
27
|
import NileElement, { NileFormControl } from '../internal/nile-element';
|
28
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
28
29
|
|
29
30
|
/**
|
30
31
|
* Nile icon component.
|
@@ -227,6 +228,8 @@ export class NileInput extends NileElement implements NileFormControl {
|
|
227
228
|
|
228
229
|
@state() hasPrintableCharacters: boolean = false;
|
229
230
|
|
231
|
+
@state() markedValue: string;
|
232
|
+
|
230
233
|
connectedCallback() {
|
231
234
|
super.connectedCallback();
|
232
235
|
this.emit('nile-init');
|
@@ -360,29 +363,32 @@ export class NileInput extends NileElement implements NileFormControl {
|
|
360
363
|
await this.updateComplete;
|
361
364
|
|
362
365
|
if(this.checkNonPrintableChar){
|
363
|
-
this.
|
366
|
+
this.markNonPrintableCharacters();
|
364
367
|
}
|
365
368
|
}
|
366
369
|
|
367
|
-
|
368
370
|
/** checks non printable characters in the value. */
|
369
|
-
|
371
|
+
markNonPrintableCharacters() {
|
372
|
+
let markedValue = '';
|
370
373
|
this.hasPrintableCharacters = false;
|
371
|
-
|
372
374
|
if (this.value) {
|
373
375
|
for (let i = 0, n = this.value.length; i < n; i++) {
|
374
376
|
const charCode = this.value.charCodeAt(i);
|
375
377
|
|
376
|
-
// Check if the character is non-printable
|
377
378
|
if ((charCode > 255 && charCode !== 9109) || [129, 143, 144, 157, 160].includes(charCode)) {
|
379
|
+
markedValue += `<span class="input__srtiked-text">${this.value.charAt(i)}</span>`;
|
378
380
|
this.hasPrintableCharacters = true;
|
379
|
-
|
380
|
-
|
381
|
+
} else {
|
382
|
+
markedValue += this.value.charAt(i);
|
381
383
|
}
|
382
384
|
}
|
383
385
|
}
|
386
|
+
|
387
|
+
this.markedValue = markedValue;
|
388
|
+
this.emit('nile-value-marked', { value: this.markedValue, hasNonPrintableCharacters: this.hasPrintableCharacters });
|
384
389
|
}
|
385
390
|
|
391
|
+
|
386
392
|
/** Removes all non printable characters from the value. */
|
387
393
|
removeAllNonPrintableCharacters() {
|
388
394
|
let cleanedValue = '';
|
@@ -657,9 +663,17 @@ export class NileInput extends NileElement implements NileFormControl {
|
|
657
663
|
</div>
|
658
664
|
|
659
665
|
<div class="input__non-printable">
|
660
|
-
Non-printable character detected
|
666
|
+
Non-printable character detected.
|
667
|
+
<nile-badge variant="error" @click=${
|
661
668
|
this.removeAllNonPrintableCharacters
|
662
|
-
}>
|
669
|
+
} class="input__remove-non-printable" >
|
670
|
+
Remove All
|
671
|
+
</nile-badge>
|
672
|
+
|
673
|
+
<div class="input__srtiked-text-container"> ${unsafeHTML(
|
674
|
+
this.markedValue
|
675
|
+
)} </div>
|
676
|
+
|
663
677
|
</div>
|
664
678
|
</nile-popup>
|
665
679
|
</div>
|
@@ -27,8 +27,8 @@ export const styles = css`
|
|
27
27
|
font-family: var(--nile-font-family-serif);
|
28
28
|
font-size: 14px;
|
29
29
|
font-style: normal;
|
30
|
-
font-weight: var(--nile-textarea-label-font-weight);
|
31
|
-
line-height: var(--nile-textarea-label-line-height);
|
30
|
+
font-weight: var(--nile-textarea-label-font-weight);
|
31
|
+
line-height: var(--nile-textarea-label-line-height);
|
32
32
|
letter-spacing: 0.2px;
|
33
33
|
}
|
34
34
|
|
@@ -87,13 +87,13 @@ export const styles = css`
|
|
87
87
|
/* Standard textareas */
|
88
88
|
.textarea--standard {
|
89
89
|
background-color: var(--nile-colors-white-base);
|
90
|
-
border: 1px solid var(--nile-textarea-standard-border-color);
|
91
|
-
box-shadow:var(--nile-textarea-standard-box-shadow);
|
90
|
+
border: 1px solid var(--nile-textarea-standard-border-color);
|
91
|
+
box-shadow:var(--nile-textarea-standard-box-shadow);
|
92
92
|
}
|
93
93
|
|
94
94
|
.textarea--standard:hover:not(.textarea--disabled) {
|
95
95
|
background-color: var(--nile-colors-white-base);
|
96
|
-
border-color: var(--nile-textarea-standard-hover-border-color);
|
96
|
+
border-color: var(--nile-textarea-standard-hover-border-color);
|
97
97
|
border-radius: var(--nile-radius-base-standard);
|
98
98
|
}
|
99
99
|
|
@@ -104,7 +104,7 @@ export const styles = css`
|
|
104
104
|
|
105
105
|
.textarea--standard.textarea--focused:not(.textarea--disabled) {
|
106
106
|
background-color: var(--nile-colors-white-base);
|
107
|
-
border-color: var(--nile-textarea-standard-focused-border-color);
|
107
|
+
border-color: var(--nile-textarea-standard-focused-border-color);
|
108
108
|
box-shadow:var(--nile-textarea-standard-focused-box-shadow);
|
109
109
|
}
|
110
110
|
|
@@ -114,11 +114,11 @@ export const styles = css`
|
|
114
114
|
}
|
115
115
|
|
116
116
|
.textarea--standard.textarea--disabled {
|
117
|
-
border-color: var(--nile-textarea-standard-disabled-border-color);
|
117
|
+
border-color: var(--nile-textarea-standard-disabled-border-color);
|
118
118
|
background: var(--nile-textarea-standard-disabled-background-color);
|
119
119
|
opacity: 0.5;
|
120
120
|
cursor: not-allowed;
|
121
|
-
box-shadow:var(--nile-textarea-standard-disabled-box-shadow);
|
121
|
+
box-shadow:var(--nile-textarea-standard-disabled-box-shadow);
|
122
122
|
}
|
123
123
|
|
124
124
|
.textarea--standard.textarea--disabled .textarea__control {
|
@@ -205,6 +205,39 @@ export const styles = css`
|
|
205
205
|
box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05),
|
206
206
|
0px 0px 0px 4px rgba(240, 68, 56, 0.24);
|
207
207
|
}
|
208
|
+
|
209
|
+
.input__non-printable {
|
210
|
+
border-radius: 4px;
|
211
|
+
max-width: 400px;
|
212
|
+
background-color: var(--nile-colors-white-base);
|
213
|
+
border: 1px solid var(--nile-colors-red-500);
|
214
|
+
color: var(--nile-colors-red-500);
|
215
|
+
padding: 10px;
|
216
|
+
font-size: 12px;
|
217
|
+
max-height: 300px;
|
218
|
+
overflow-y: scroll;
|
219
|
+
}
|
220
|
+
|
221
|
+
.input__remove-non-printable {
|
222
|
+
color: var(--nile-colors-red-500);
|
223
|
+
margin-left: 10px;
|
224
|
+
font-size: 14px;
|
225
|
+
color: var(--nile-colors-dark-900);
|
226
|
+
}
|
227
|
+
|
228
|
+
.input__srtiked-text-container {
|
229
|
+
margin-top: 4px;
|
230
|
+
color: var(--nile-colors-dark-900);
|
231
|
+
word-wrap: break-all;
|
232
|
+
line-height: 16px;
|
233
|
+
}
|
234
|
+
|
235
|
+
.input__srtiked-text {
|
236
|
+
text-decoration: line-through;
|
237
|
+
text-decoration-color: var(--nile-colors-white-base);
|
238
|
+
color: var(--nile-colors-white-base);
|
239
|
+
background-color: var(--nile-colors-red-500);
|
240
|
+
}
|
208
241
|
`;
|
209
242
|
|
210
243
|
export default [styles];
|
@@ -11,13 +11,13 @@ import {styles} from './nile-textarea.css';
|
|
11
11
|
import { classMap } from 'lit/directives/class-map.js';
|
12
12
|
import { query, state } from 'lit/decorators.js';
|
13
13
|
import { defaultValue } from '../internal/default-value';
|
14
|
-
import { FormControlController } from '../internal/form';
|
15
14
|
import { HasSlotController } from '../internal/slot';
|
16
15
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
17
16
|
import { live } from 'lit/directives/live.js';
|
18
17
|
import { watch } from '../internal/watch';
|
19
18
|
import NileElement from '../internal/nile-element';
|
20
19
|
import type { CSSResultGroup } from 'lit';
|
20
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
21
21
|
|
22
22
|
/**
|
23
23
|
* @summary Textareas collect data from the user and allow multiple lines of text.
|
@@ -111,9 +111,6 @@ export class NileTextarea extends NileElement {
|
|
111
111
|
/** Sets the input to a success state, changing its visual appearance. */
|
112
112
|
@property({ type: Boolean }) success = false;
|
113
113
|
|
114
|
-
/** Sets the input to a destructive state, changing its visual appearance. */
|
115
|
-
@property({ type: Boolean }) destructive = false;
|
116
|
-
|
117
114
|
/** Controls whether and how text input is automatically capitalized as it is entered by the user. */
|
118
115
|
@property() autocapitalize: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
|
119
116
|
|
@@ -154,6 +151,12 @@ export class NileTextarea extends NileElement {
|
|
154
151
|
|
155
152
|
@property({ type: Boolean, reflect: true }) fullHeight = false;
|
156
153
|
|
154
|
+
@property({type: Boolean}) checkNonPrintableChar: boolean = false;
|
155
|
+
|
156
|
+
@state() hasPrintableCharacters: boolean = false;
|
157
|
+
|
158
|
+
@state() markedValue: string;
|
159
|
+
|
157
160
|
connectedCallback() {
|
158
161
|
super.connectedCallback();
|
159
162
|
this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight());
|
@@ -227,6 +230,52 @@ export class NileTextarea extends NileElement {
|
|
227
230
|
async handleValueChange() {
|
228
231
|
await this.updateComplete;
|
229
232
|
this.setTextareaHeight();
|
233
|
+
|
234
|
+
if(this.checkNonPrintableChar){
|
235
|
+
this.markNonPrintableCharacters();
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
/** checks non printable characters in the value. */
|
240
|
+
markNonPrintableCharacters() {
|
241
|
+
let markedValue = '';
|
242
|
+
this.hasPrintableCharacters = false;
|
243
|
+
if (this.value) {
|
244
|
+
for (let i = 0, n = this.value.length; i < n; i++) {
|
245
|
+
const charCode = this.value.charCodeAt(i);
|
246
|
+
|
247
|
+
if ((charCode > 255 && charCode !== 9109) || [129, 143, 144, 157, 160].includes(charCode)) {
|
248
|
+
markedValue += `<span class="input__srtiked-text">${this.value.charAt(i)}</span>`;
|
249
|
+
this.hasPrintableCharacters = true;
|
250
|
+
} else {
|
251
|
+
markedValue += this.value.charAt(i);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
this.markedValue = markedValue;
|
257
|
+
this.emit('nile-value-marked', { value: this.markedValue, hasNonPrintableCharacters: this.hasPrintableCharacters });
|
258
|
+
}
|
259
|
+
|
260
|
+
|
261
|
+
/** Removes all non printable characters from the value. */
|
262
|
+
removeAllNonPrintableCharacters() {
|
263
|
+
let cleanedValue = '';
|
264
|
+
|
265
|
+
if (this.value) {
|
266
|
+
for (let i = 0, n = this.value.length; i < n; i++) {
|
267
|
+
const charCode = this.value.charCodeAt(i);
|
268
|
+
|
269
|
+
// Consider a character printable if it's not in the specified non-printable ranges
|
270
|
+
if (!(charCode > 255 && charCode !== 9109) && ![129, 143, 144, 157, 160].includes(charCode)) {
|
271
|
+
cleanedValue += this.value.charAt(i);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
this.value = cleanedValue;
|
277
|
+
this.emit('nile-npchar-removed', { value: this.value });
|
278
|
+
|
230
279
|
}
|
231
280
|
|
232
281
|
/** Sets focus on the textarea. */
|
@@ -302,7 +351,7 @@ export class NileTextarea extends NileElement {
|
|
302
351
|
'form-control': true,
|
303
352
|
'form-control--medium': this.size === 'medium',
|
304
353
|
'form-control--has-label': hasLabel,
|
305
|
-
'form-control--has-help-text': hasHelpText
|
354
|
+
'form-control--has-help-text': hasHelpText,
|
306
355
|
})}
|
307
356
|
>
|
308
357
|
<label
|
@@ -314,73 +363,89 @@ export class NileTextarea extends NileElement {
|
|
314
363
|
<slot name="label">${this.label}</slot>
|
315
364
|
</label>
|
316
365
|
|
317
|
-
<
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
366
|
+
<nile-popup
|
367
|
+
?active=${this.hasPrintableCharacters}
|
368
|
+
placement="bottom-start"
|
369
|
+
distance="5"
|
370
|
+
strategy="fixed"
|
371
|
+
>
|
372
|
+
<div part="form-control-input" class="form-control-input" slot="anchor">
|
373
|
+
<div
|
374
|
+
part="base"
|
375
|
+
class=${classMap({
|
376
|
+
textarea: true,
|
377
|
+
'textarea--medium': this.size === 'medium',
|
378
|
+
'textarea--warning': this.warning,
|
379
|
+
'textarea--error': this.error,
|
380
|
+
'textarea--success': this.success,
|
381
|
+
'textarea--standard': !this.filled,
|
382
|
+
'textarea--disabled': this.disabled,
|
383
|
+
'textarea--focused': this.hasFocus,
|
384
|
+
'textarea--empty': !this.value,
|
385
|
+
'textarea--resize-none': this.resize === 'none',
|
386
|
+
'textarea--resize-vertical': this.resize === 'vertical',
|
387
|
+
'textarea--resize-auto': this.resize === 'auto',
|
388
|
+
})}
|
389
|
+
>
|
390
|
+
<textarea
|
391
|
+
part="textarea"
|
392
|
+
id="input"
|
393
|
+
class="textarea__control"
|
394
|
+
title=${
|
395
|
+
this
|
396
|
+
.title /* An empty title prevents browser validation tooltips from appearing on hover */
|
397
|
+
}
|
398
|
+
name=${ifDefined(this.name)}
|
399
|
+
.value=${live(this.value)}
|
400
|
+
?disabled=${this.disabled}
|
401
|
+
?readonly=${this.readonly}
|
402
|
+
?required=${this.required}
|
403
|
+
placeholder=${ifDefined(this.placeholder)}
|
404
|
+
rows=${ifDefined(this.rows)}
|
405
|
+
minlength=${ifDefined(this.minlength)}
|
406
|
+
maxlength=${ifDefined(this.maxlength)}
|
407
|
+
autocapitalize=${ifDefined(this.autocapitalize)}
|
408
|
+
autocorrect=${ifDefined(this.autocorrect)}
|
409
|
+
?autofocus=${this.autofocus}
|
410
|
+
spellcheck=${ifDefined(this.spellcheck)}
|
411
|
+
enterkeyhint=${ifDefined(this.enterkeyhint)}
|
412
|
+
inputmode=${ifDefined(this.inputmode)}
|
413
|
+
aria-describedby="help-text"
|
414
|
+
@change=${this.handleChange}
|
415
|
+
@input=${this.handleInput}
|
416
|
+
@focus=${this.handleFocus}
|
417
|
+
@blur=${this.handleBlur}
|
418
|
+
></textarea>
|
419
|
+
</div>
|
364
420
|
</div>
|
365
|
-
</div>
|
366
421
|
|
367
|
-
|
368
|
-
hasHelpText
|
422
|
+
${hasHelpText
|
369
423
|
? html`
|
370
424
|
<nile-form-help-text>${this.helpText}</nile-form-help-text>
|
371
425
|
`
|
372
|
-
: ``
|
373
|
-
|
374
|
-
|
375
|
-
${
|
376
|
-
hasErrorMessage
|
426
|
+
: ``}
|
427
|
+
${hasErrorMessage
|
377
428
|
? html`
|
378
429
|
<nile-form-error-message
|
379
430
|
>${this.errorMessage}</nile-form-error-message
|
380
431
|
>
|
381
432
|
`
|
382
|
-
: ``
|
383
|
-
|
433
|
+
: ``}
|
434
|
+
<div class="input__non-printable">
|
435
|
+
Non-printable character detected.
|
436
|
+
<nile-badge
|
437
|
+
variant="error"
|
438
|
+
@click=${this.removeAllNonPrintableCharacters}
|
439
|
+
class="input__remove-non-printable"
|
440
|
+
>
|
441
|
+
Remove All
|
442
|
+
</nile-badge>
|
443
|
+
|
444
|
+
<div class="input__srtiked-text-container">
|
445
|
+
${unsafeHTML(this.markedValue)}
|
446
|
+
</div>
|
447
|
+
</div>
|
448
|
+
</nile-popup>
|
384
449
|
</div>
|
385
450
|
`;
|
386
451
|
}
|