@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.
Files changed (35) hide show
  1. package/dist/index.cjs.js +1 -1
  2. package/dist/index.esm.js +1 -1
  3. package/dist/index.iife.js +173 -99
  4. package/dist/nile-input/index.cjs.js +1 -1
  5. package/dist/nile-input/index.esm.js +1 -1
  6. package/dist/nile-input/nile-input.cjs.js +1 -1
  7. package/dist/nile-input/nile-input.cjs.js.map +1 -1
  8. package/dist/nile-input/nile-input.css.cjs.js +1 -1
  9. package/dist/nile-input/nile-input.css.cjs.js.map +1 -1
  10. package/dist/nile-input/nile-input.css.esm.js +23 -6
  11. package/dist/nile-input/nile-input.esm.js +9 -3
  12. package/dist/nile-textarea/index.cjs.js +1 -1
  13. package/dist/nile-textarea/index.esm.js +1 -1
  14. package/dist/nile-textarea/nile-textarea.cjs.js +1 -1
  15. package/dist/nile-textarea/nile-textarea.cjs.js.map +1 -1
  16. package/dist/nile-textarea/nile-textarea.css.cjs.js +1 -1
  17. package/dist/nile-textarea/nile-textarea.css.cjs.js.map +1 -1
  18. package/dist/nile-textarea/nile-textarea.css.esm.js +41 -8
  19. package/dist/nile-textarea/nile-textarea.esm.js +58 -40
  20. package/dist/src/nile-input/nile-input.css.js +23 -6
  21. package/dist/src/nile-input/nile-input.css.js.map +1 -1
  22. package/dist/src/nile-input/nile-input.d.ts +2 -1
  23. package/dist/src/nile-input/nile-input.js +20 -6
  24. package/dist/src/nile-input/nile-input.js.map +1 -1
  25. package/dist/src/nile-textarea/nile-textarea.css.js +41 -8
  26. package/dist/src/nile-textarea/nile-textarea.css.js.map +1 -1
  27. package/dist/src/nile-textarea/nile-textarea.d.ts +7 -2
  28. package/dist/src/nile-textarea/nile-textarea.js +107 -45
  29. package/dist/src/nile-textarea/nile-textarea.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +1 -1
  32. package/src/nile-input/nile-input.css.ts +23 -6
  33. package/src/nile-input/nile-input.ts +23 -9
  34. package/src/nile-textarea/nile-textarea.css.ts +41 -8
  35. package/src/nile-textarea/nile-textarea.ts +127 -62
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent nile-elements following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "nile-elements",
6
- "version": "0.0.51",
6
+ "version": "0.0.53",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -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
- background-color: #ffffff;
484
- border: 1px solid grey;
485
- color: red;
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: #035da6;
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.findNonPrintableChar();
366
+ this.markNonPrintableCharacters();
364
367
  }
365
368
  }
366
369
 
367
-
368
370
  /** checks non printable characters in the value. */
369
- findNonPrintableChar() {
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
- this.emit('nile-value', { value: this.value , hasPrintableCharacters: true });
380
- break;
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.<span class="input__remove-non-printable" @click=${
666
+ Non-printable character detected.
667
+ <nile-badge variant="error" @click=${
661
668
  this.removeAllNonPrintableCharacters
662
- }> Remove All </span>
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
- <div part="form-control-input" class="form-control-input">
318
- <div
319
- part="base"
320
- class=${classMap({
321
- textarea: true,
322
- 'textarea--medium': this.size === 'medium',
323
- 'textarea--warning': this.warning,
324
- 'textarea--error': this.error,
325
- 'textarea--success': this.success,
326
- 'textarea--destructive': this.destructive,
327
- 'textarea--standard': !this.filled,
328
- 'textarea--disabled': this.disabled,
329
- 'textarea--focused': this.hasFocus,
330
- 'textarea--empty': !this.value,
331
- 'textarea--resize-none': this.resize === 'none',
332
- 'textarea--resize-vertical': this.resize === 'vertical',
333
- 'textarea--resize-auto': this.resize === 'auto'
334
- })}
335
- >
336
- <textarea
337
- part="textarea"
338
- id="input"
339
- class="textarea__control"
340
- title=${this.title /* An empty title prevents browser validation tooltips from appearing on hover */}
341
- name=${ifDefined(this.name)}
342
- .value=${live(this.value)}
343
- ?disabled=${this.disabled}
344
- ?readonly=${this.readonly}
345
- ?required=${this.required}
346
- placeholder=${ifDefined(this.placeholder)}
347
- rows=${ifDefined(this.rows)}
348
- minlength=${ifDefined(this.minlength)}
349
- maxlength=${ifDefined(this.maxlength)}
350
- autocapitalize=${ifDefined(this.autocapitalize)}
351
- autocorrect=${ifDefined(this.autocorrect)}
352
- ?autofocus=${this.autofocus}
353
- spellcheck=${ifDefined(this.spellcheck)}
354
- enterkeyhint=${ifDefined(this.enterkeyhint)}
355
- inputmode=${ifDefined(this.inputmode)}
356
- aria-describedby="help-text"
357
- @change=${this.handleChange}
358
- @input=${this.handleInput}
359
- @focus=${this.handleFocus}
360
- @blur=${this.handleBlur}
361
-
362
-
363
- ></textarea>
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
  }