@aquera/nile-elements 0.0.52 → 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/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.52",
6
+ "version": "0.0.53",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -499,6 +499,7 @@ export const styles = css`
499
499
  margin-top: 4px;
500
500
  color: var(--nile-colors-dark-900);
501
501
  word-wrap: break-all;
502
+ line-height: 16px;
502
503
  }
503
504
 
504
505
  .input__srtiked-text {
@@ -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
  }