@sankhyalabs/ezui 6.1.0-dev.4 → 6.1.0-dev.5

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 (90) hide show
  1. package/dist/cjs/RichToolbarHelper-438916fa.js +46 -0
  2. package/dist/cjs/{ez-combo-box-list_3.cjs.entry.js → ez-combo-box-list_4.cjs.entry.js} +269 -0
  3. package/dist/cjs/ez-filter-input.cjs.entry.js +129 -0
  4. package/dist/cjs/ez-form-view.cjs.entry.js +6 -0
  5. package/dist/cjs/ez-grid.cjs.entry.js +3 -1348
  6. package/dist/cjs/ez-icon.cjs.entry.js +1 -1
  7. package/dist/cjs/ez-link-builder_6.cjs.entry.js +295 -0
  8. package/dist/cjs/ez-modal-container.cjs.entry.js +1 -1
  9. package/dist/cjs/ez-rich-toolbar-item.cjs.entry.js +27 -0
  10. package/dist/cjs/{ez-filter-input_2.cjs.entry.js → ez-tooltip.cjs.entry.js} +1 -123
  11. package/dist/cjs/ezui.cjs.js +1 -1
  12. package/dist/cjs/index-a7b0c73d.js +20 -8
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/purify-6de957d4.js +1351 -0
  15. package/dist/collection/collection-manifest.json +8 -0
  16. package/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder.js +2 -0
  17. package/dist/collection/components/ez-form-view/fieldbuilder/templates/RichText.tpl.js +4 -0
  18. package/dist/collection/components/ez-icon/ez-icon.css +147 -140
  19. package/dist/collection/components/ez-modal-container/ez-modal-container.css +2 -0
  20. package/dist/collection/components/ez-rich-text/ez-link-builder/ez-link-builder.css +22 -0
  21. package/dist/collection/components/ez-rich-text/ez-link-builder/ez-link-builder.js +131 -0
  22. package/dist/collection/components/ez-rich-text/ez-rich-text.css +35 -0
  23. package/dist/collection/components/ez-rich-text/ez-rich-text.js +544 -0
  24. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/RichToolbarHelper.js +39 -0
  25. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-arrows/ez-rich-toolbar-arrows.css +4 -0
  26. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-arrows/ez-rich-toolbar-arrows.js +19 -0
  27. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-configs/ez-rich-toolbar-configs.css +4 -0
  28. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-configs/ez-rich-toolbar-configs.js +19 -0
  29. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-item/ez-rich-toolbar-item.css +20 -0
  30. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-item/ez-rich-toolbar-item.js +122 -0
  31. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-letters/ez-rich-toolbar-letters.css +4 -0
  32. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-letters/ez-rich-toolbar-letters.js +19 -0
  33. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar.css +42 -0
  34. package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar.js +183 -0
  35. package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/ez-simple-image-uploader.css +70 -0
  36. package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/ez-simple-image-uploader.js +216 -0
  37. package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/test/resource/imageBase64.js +1 -0
  38. package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/utils/fileToBase64.js +14 -0
  39. package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/utils/formatBytes.js +10 -0
  40. package/dist/collection/components/ez-tooltip/ez-tooltip.js +1 -1
  41. package/dist/custom-elements/index.d.ts +48 -0
  42. package/dist/custom-elements/index.js +641 -4
  43. package/dist/esm/RichToolbarHelper-fd6427df.js +41 -0
  44. package/dist/esm/{ez-combo-box-list_3.entry.js → ez-combo-box-list_4.entry.js} +270 -2
  45. package/dist/esm/ez-filter-input.entry.js +125 -0
  46. package/dist/esm/ez-form-view.entry.js +6 -0
  47. package/dist/esm/ez-grid.entry.js +2 -1347
  48. package/dist/esm/ez-icon.entry.js +1 -1
  49. package/dist/esm/ez-link-builder_6.entry.js +286 -0
  50. package/dist/esm/ez-modal-container.entry.js +1 -1
  51. package/dist/esm/ez-rich-toolbar-item.entry.js +23 -0
  52. package/dist/esm/{ez-filter-input_2.entry.js → ez-tooltip.entry.js} +3 -124
  53. package/dist/esm/ezui.js +1 -1
  54. package/dist/esm/index-baa5e267.js +20 -8
  55. package/dist/esm/loader.js +1 -1
  56. package/dist/esm/purify-aa3062c4.js +1349 -0
  57. package/dist/ezui/ezui.esm.js +1 -1
  58. package/dist/ezui/p-098594de.entry.js +1 -0
  59. package/dist/ezui/p-1cebdc92.js +1 -0
  60. package/dist/ezui/p-20c024f7.entry.js +1 -0
  61. package/dist/ezui/{p-26685c50.entry.js → p-454bba13.entry.js} +1 -1
  62. package/dist/ezui/p-566c809b.entry.js +1 -0
  63. package/dist/ezui/{p-38581954.entry.js → p-5f1e98da.entry.js} +45 -47
  64. package/dist/ezui/p-79044c3e.entry.js +1 -0
  65. package/dist/ezui/p-80461324.entry.js +1 -0
  66. package/dist/ezui/p-91c9d50e.entry.js +1 -0
  67. package/dist/ezui/p-bcae530a.js +3 -0
  68. package/dist/ezui/p-ec0d8122.entry.js +1 -0
  69. package/dist/types/components/ez-form-view/fieldbuilder/templates/RichText.tpl.d.ts +2 -0
  70. package/dist/types/components/ez-rich-text/ez-link-builder/ez-link-builder.d.ts +17 -0
  71. package/dist/types/components/ez-rich-text/ez-rich-text.d.ts +98 -0
  72. package/dist/types/components/ez-rich-text/ez-rich-toolbar/RichToolbarHelper.d.ts +43 -0
  73. package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-arrows/ez-rich-toolbar-arrows.d.ts +3 -0
  74. package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-configs/ez-rich-toolbar-configs.d.ts +3 -0
  75. package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-item/ez-rich-toolbar-item.d.ts +11 -0
  76. package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-letters/ez-rich-toolbar-letters.d.ts +3 -0
  77. package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar.d.ts +33 -0
  78. package/dist/types/components/ez-rich-text/ez-simple-image-uploader/ez-simple-image-uploader.d.ts +37 -0
  79. package/dist/types/components/ez-rich-text/ez-simple-image-uploader/test/resource/imageBase64.d.ts +1 -0
  80. package/dist/types/components/ez-rich-text/ez-simple-image-uploader/utils/fileToBase64.d.ts +1 -0
  81. package/dist/types/components/ez-rich-text/ez-simple-image-uploader/utils/formatBytes.d.ts +1 -0
  82. package/dist/types/components.d.ts +291 -0
  83. package/package.json +1 -1
  84. package/react/components.d.ts +8 -0
  85. package/react/components.js +8 -0
  86. package/react/components.js.map +1 -1
  87. package/dist/ezui/p-2b42abbb.entry.js +0 -1
  88. package/dist/ezui/p-63cb493e.entry.js +0 -1
  89. package/dist/ezui/p-7ab19270.entry.js +0 -1
  90. package/dist/ezui/p-9567b31a.entry.js +0 -1
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ const RICH_TOOLBAR_COMMANDS = {
4
+ PREVIEW: 'preview',
5
+ UNDO: 'undo',
6
+ REDO: 'redo',
7
+ FORMAT: 'format',
8
+ LINK: 'link',
9
+ IMAGE: 'image',
10
+ FOCUS: 'focus',
11
+ };
12
+ const RICH_TOOLBAR_FORMAT_TAGS = {
13
+ BOLD: '<strong>$selection</strong>',
14
+ ITALIC: '<em>$selection</em>',
15
+ UNDERLINE: '<u>$selection</u>',
16
+ LIST: '<ul><li>$selection</li></ul>',
17
+ BREAK_LINE: '\n<br/>\n',
18
+ };
19
+ const RICH_TOOLBAR_COMMAND_TITLE = {
20
+ PREVIEW: 'Ctrl + P',
21
+ EDIT: 'Ir para modo edição',
22
+ UNDO: 'Desfazer (Ctrl + Z)',
23
+ REDO: 'Refazer (Ctrl + X)',
24
+ LINK: 'Inserir link (Ctrl + K)',
25
+ IMAGE: 'Inserir imagem (Ctrl + O)',
26
+ LIST: 'Lista (Ctrl + L)',
27
+ UNDERLINE: 'Sublinhado (Ctrl + U)',
28
+ ITALIC: 'Itálico (Ctrl + I)',
29
+ BOLD: 'Negrito (Ctrl + B)',
30
+ };
31
+ const RICH_TOOLBAR_COMMAND_ICON = {
32
+ PREVIEW: 'Ctrl + P',
33
+ UNDO: 'undo',
34
+ REDO: 'redo',
35
+ LINK: 'link',
36
+ IMAGE: 'image-plus',
37
+ LIST: 'list',
38
+ UNDERLINE: 'underline',
39
+ ITALIC: 'italic',
40
+ BOLD: 'bold',
41
+ };
42
+
43
+ exports.RICH_TOOLBAR_COMMANDS = RICH_TOOLBAR_COMMANDS;
44
+ exports.RICH_TOOLBAR_COMMAND_ICON = RICH_TOOLBAR_COMMAND_ICON;
45
+ exports.RICH_TOOLBAR_COMMAND_TITLE = RICH_TOOLBAR_COMMAND_TITLE;
46
+ exports.RICH_TOOLBAR_FORMAT_TAGS = RICH_TOOLBAR_FORMAT_TAGS;
@@ -5,9 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-a7b0c73d.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const FormLayout = require('./FormLayout-18853e70.js');
8
+ const RichToolbarHelper = require('./RichToolbarHelper-438916fa.js');
9
+ const purify = require('./purify-6de957d4.js');
8
10
  const ApplicationUtils = require('./ApplicationUtils-c9d1205c.js');
9
11
  require('./DialogType-2114c337.js');
10
12
  require('./CheckMode-ecb90b87.js');
13
+ require('./_commonjsHelpers-537d719a.js');
11
14
 
12
15
  const ezComboBoxListCss = ":host{--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box--line-height:calc(var(--text--medium, 14px) + 4px);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium) + 4px);--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__scrollbar--color-default:var(--scrollbar--default, #626e82);--ez-combo-box__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--ez-combo-box__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--ez-combo-box__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--ez-combo-box__scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__scrollbar--width:var(--space--medium, 12px);--ez-combo-box__list-container--padding:var(--space--extra-small, 3px)}.list-container{padding-top:var(--ez-combo-box__list-container--padding)}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:0;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small) + 9px);background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow--medium, 0 8px 24px 0 rgba(43, 58, 84, 0.10));padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;padding:0;margin:0;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;gap:3px;scrollbar-color:var(--ez-combo-box__scrollbar--color-clicked) var(--ez-combo-box__scrollbar--color-background)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__scrollbar--color-background);width:var(--ez-combo-box__scrollbar--width);max-width:var(--ez-combo-box__scrollbar--width);min-width:var(--ez-combo-box__scrollbar--width)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__scrollbar--color-background);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__scrollbar--color-default);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb:vertical:hover,.list-options::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--ez-combo-box__scrollbar--color-hover)}.list-options::-webkit-scrollbar-thumb:vertical:active,.list-options::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--ez-combo-box__scrollbar--color-clicked)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size);line-height:var(--ez-combo-box--line-height)}.item__label{font-weight:var(--ez-combo-box--font-weight--medium)}.item__label--bold{font-weight:var(--ez-combo-box--font-weight--large)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large)}.item__value--hidden{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:14px;height:14px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
13
16
 
@@ -286,6 +289,271 @@ const EzCustomFormInput = class {
286
289
  }; }
287
290
  };
288
291
 
292
+ const ezRichTextCss = ".sc-ez-rich-text-h{display:block;width:100%;font-family:Roboto;--ez-rich-text--box-shadow:0 0 3px 0 #DCE0E8;--ez-rich-text--shadow--outline:var(--shadow--outline) var(--color--strokes)}.editor-container.bordered.sc-ez-rich-text{border-radius:12px;border:1px solid #DCE0E8}.editor-container.sc-ez-rich-text{width:100%;border-radius:12px;overflow:hidden;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}ez-text-area.sc-ez-rich-text{--text-area__input--border:1px solid}.preview.sc-ez-rich-text{min-height:20px;padding:12px;resize:both;overflow:auto;max-width:100%}";
293
+
294
+ const EzRichText = class {
295
+ constructor(hostRef) {
296
+ index.registerInstance(this, hostRef);
297
+ this.ezChange = index.createEvent(this, "ezChange", 7);
298
+ this.historyStack = [];
299
+ this.historyIndex = -1;
300
+ this.previewMode = false;
301
+ this.showPreview = true;
302
+ this.showBorder = false;
303
+ this.value = '';
304
+ this.label = undefined;
305
+ this.enabled = true;
306
+ this.rows = 6;
307
+ this.errorMessage = undefined;
308
+ this.showConfigs = true;
309
+ this.showTextFormat = true;
310
+ this.showUndoRedo = true;
311
+ }
312
+ observeValue(newValue, oldValue) {
313
+ if (core.ObjectUtils.equals(newValue, oldValue))
314
+ return;
315
+ this.ezChange.emit(newValue);
316
+ }
317
+ async handleExecuteToolbarCommand(event) {
318
+ const { command, value } = event.detail;
319
+ await this.executeCommand(command, value);
320
+ }
321
+ /**
322
+ * Aplica o foco no campo.
323
+ */
324
+ async setFocus() {
325
+ this.handleFocus();
326
+ }
327
+ /**
328
+ * Remove o foco do campo.
329
+ */
330
+ async setBlur() {
331
+ var _a;
332
+ await ((_a = this.textAreaRef) === null || _a === void 0 ? void 0 : _a.setBlur());
333
+ }
334
+ /**
335
+ * Retorna se o conteúdo é inválido.
336
+ */
337
+ async isInvalid() {
338
+ return typeof this.errorMessage === 'string' && this.errorMessage.trim() !== '';
339
+ }
340
+ bindPreview() {
341
+ if (!this._keyboardManager || !this.showPreview)
342
+ return;
343
+ this._keyboardManager
344
+ .bind('ctrl + p', async () => {
345
+ await this.togglePreview();
346
+ }, { description: 'Entra em modo de pré visualização.', element: this.element });
347
+ }
348
+ bindConfigs() {
349
+ if (!this._keyboardManager || !this.showConfigs)
350
+ return;
351
+ this._keyboardManager
352
+ .bind('ctrl + l', async () => {
353
+ await this.handleFormatSelection(RichToolbarHelper.RICH_TOOLBAR_FORMAT_TAGS.LIST);
354
+ }, { description: 'Aplica estilo de lista ao texto selecionado.', element: this.element })
355
+ .bind('ctrl + k', async () => {
356
+ await this.handleLink();
357
+ }, { description: 'Abre popup de link.', element: this.element })
358
+ .bind('ctrl + o', async () => {
359
+ await this.handleImage();
360
+ }, { description: 'Abre popup de imagem.', element: this.element });
361
+ }
362
+ bindTextFormat() {
363
+ if (!this._keyboardManager || !this.showTextFormat)
364
+ return;
365
+ this._keyboardManager
366
+ .bind('ctrl + b', async () => {
367
+ await this.handleFormatSelection(RichToolbarHelper.RICH_TOOLBAR_FORMAT_TAGS.BOLD);
368
+ }, { description: 'Aplica estilo negrito ao texto selecionado.', element: this.element })
369
+ .bind('ctrl + i', async () => {
370
+ await this.handleFormatSelection(RichToolbarHelper.RICH_TOOLBAR_FORMAT_TAGS.ITALIC);
371
+ }, { description: 'Aplica estilo itálico ao texto selecionado.', element: this.element })
372
+ .bind('ctrl + u', async () => {
373
+ await this.handleFormatSelection(RichToolbarHelper.RICH_TOOLBAR_FORMAT_TAGS.UNDERLINE);
374
+ }, { description: 'Aplica estilo underline ao texto selecionado.', element: this.element });
375
+ }
376
+ initKeyboardManager() {
377
+ this._keyboardManager = new core.KeyboardManager({ propagate: false, element: this.element });
378
+ this._keyboardManager
379
+ .bind('ctrl + Enter', async () => {
380
+ await this.handleFormatSelection(RichToolbarHelper.RICH_TOOLBAR_FORMAT_TAGS.BREAK_LINE);
381
+ }, { description: 'Aplica quebra de linha.', element: this.element })
382
+ .bind('ctrl + z', async () => {
383
+ await this.handleUndo();
384
+ }, { description: 'Desfaz a ultima alteração de texto.', element: this.element })
385
+ .bind('ctrl + x', async () => {
386
+ await this.handleRedo();
387
+ }, { description: 'Refaz a ultima alteração de texto.', element: this.element });
388
+ this.bindPreview();
389
+ this.bindConfigs();
390
+ this.bindTextFormat();
391
+ }
392
+ async executeCommand(command, value) {
393
+ switch (command) {
394
+ case RichToolbarHelper.RICH_TOOLBAR_COMMANDS.FOCUS:
395
+ this.handleFocus();
396
+ break;
397
+ case RichToolbarHelper.RICH_TOOLBAR_COMMANDS.PREVIEW:
398
+ await this.togglePreview();
399
+ break;
400
+ case RichToolbarHelper.RICH_TOOLBAR_COMMANDS.FORMAT:
401
+ await this.handleFormatSelection(value);
402
+ break;
403
+ case RichToolbarHelper.RICH_TOOLBAR_COMMANDS.UNDO:
404
+ await this.handleUndo();
405
+ break;
406
+ case RichToolbarHelper.RICH_TOOLBAR_COMMANDS.REDO:
407
+ await this.handleRedo();
408
+ break;
409
+ case RichToolbarHelper.RICH_TOOLBAR_COMMANDS.LINK:
410
+ await this.handleLink();
411
+ break;
412
+ case RichToolbarHelper.RICH_TOOLBAR_COMMANDS.IMAGE:
413
+ await this.handleImage();
414
+ break;
415
+ }
416
+ }
417
+ handleFocus() {
418
+ this.previewMode = false;
419
+ requestAnimationFrame(async () => {
420
+ await this.textAreaRef.setFocus();
421
+ });
422
+ }
423
+ async handleLink() {
424
+ this.previewMode = false;
425
+ requestAnimationFrame(async () => {
426
+ await this.linkBuilderRef.show(this.getSelectedText());
427
+ });
428
+ }
429
+ async handleImage() {
430
+ this.previewMode = false;
431
+ await this.imageUploaderRef.show();
432
+ }
433
+ async handleRedo() {
434
+ this.previewMode = false;
435
+ requestAnimationFrame(async () => {
436
+ this.redo();
437
+ await this.textAreaRef.setFocus();
438
+ });
439
+ }
440
+ async handleUndo() {
441
+ this.previewMode = false;
442
+ requestAnimationFrame(async () => {
443
+ this.undo();
444
+ await this.textAreaRef.setFocus();
445
+ });
446
+ }
447
+ async handleFormatSelection(value) {
448
+ if (!value)
449
+ return;
450
+ this.previewMode = false;
451
+ requestAnimationFrame(async () => {
452
+ await this.formatSelection(value);
453
+ await this.textAreaRef.setFocus();
454
+ });
455
+ }
456
+ async togglePreview() {
457
+ this.previewMode = !this.previewMode;
458
+ if (this.previewMode) {
459
+ await this.textAreaRef.setFocus();
460
+ }
461
+ }
462
+ getSelectedText() {
463
+ const textarea = this.getTextAreaElement();
464
+ if (!textarea)
465
+ return undefined;
466
+ const selectionStart = textarea.selectionStart;
467
+ const selectionEnd = textarea.selectionEnd;
468
+ const currentValue = this.textAreaRef.value || '';
469
+ return currentValue.substring(selectionStart, selectionEnd);
470
+ }
471
+ getTextAreaElement() {
472
+ const textAreaElement = this.element.querySelector('ez-text-area');
473
+ return textAreaElement.shadowRoot.querySelector('textarea');
474
+ }
475
+ async formatSelection(htmlTag) {
476
+ if (!this.textAreaRef)
477
+ return;
478
+ const formattedHtml = htmlTag.replace('$selection', this.getSelectedText() || '');
479
+ await this.textAreaRef.appendTextToSelection(formattedHtml);
480
+ this.value = this.textAreaRef.value;
481
+ this.addToHistory(this.value);
482
+ }
483
+ addToHistory(content) {
484
+ // Só adiciona ao histórico se for diferente do estado atual
485
+ if (this.historyIndex >= 0 && content === this.historyStack[this.historyIndex]) {
486
+ return;
487
+ }
488
+ //se o tamanho do histórico chegou ao máximo, faz um splice mantendo os últimos 49 elementos
489
+ if (this.historyStack.length >= 50) {
490
+ this.historyStack.splice(0, this.historyStack.length - 49);
491
+ }
492
+ //Adiciona novo estado ao histórico
493
+ this.historyStack.push(content);
494
+ this.historyIndex = this.historyStack.length - 1;
495
+ }
496
+ undo() {
497
+ if (!this.canExecuteUndo())
498
+ return;
499
+ this.historyIndex--;
500
+ const content = this.historyStack[this.historyIndex];
501
+ this.value = content;
502
+ this.textAreaRef.value = content;
503
+ }
504
+ canExecuteUndo() {
505
+ return this.historyIndex > 0;
506
+ }
507
+ redo() {
508
+ if (!this.canExecuteRedo())
509
+ return;
510
+ this.historyIndex++;
511
+ this.getValueFromHistory();
512
+ }
513
+ canExecuteRedo() {
514
+ return this.historyIndex < this.historyStack.length - 1;
515
+ }
516
+ getValueFromHistory() {
517
+ const content = this.historyStack[this.historyIndex];
518
+ this.value = content;
519
+ this.textAreaRef.value = content;
520
+ }
521
+ handleTextAreaChanged(event) {
522
+ this.value = event.detail;
523
+ this.addToHistory(this.value);
524
+ }
525
+ async removeShortcuts() {
526
+ var _a;
527
+ (_a = this._keyboardManager) === null || _a === void 0 ? void 0 : _a.unbindAllShortcutKeys();
528
+ }
529
+ componentDidLoad() {
530
+ this.initKeyboardManager();
531
+ this.addToHistory(this.value);
532
+ }
533
+ async disconnectedCallback() {
534
+ await this.removeShortcuts();
535
+ }
536
+ getSanitizedValue() {
537
+ return purify.purify.sanitize(this.value, {
538
+ ADD_ATTR: ['target', 'rel']
539
+ });
540
+ }
541
+ renderContent() {
542
+ if (this.previewMode) {
543
+ return (index.h("div", { id: 'rich-text-preview-container', class: "preview", innerHTML: this.getSanitizedValue() }));
544
+ }
545
+ return index.h("ez-text-area", { ref: (el) => this.textAreaRef = el, label: this.label, value: this.value, enabled: this.enabled, rows: this.rows, mode: 'slim', errorMessage: this.errorMessage, onEzChange: this.handleTextAreaChanged.bind(this) });
546
+ }
547
+ render() {
548
+ return (index.h(index.Host, null, index.h("div", { class: `editor-container ${this.showBorder ? 'bordered' : ''}` }, index.h("ez-rich-toolbar", { isPreviewMode: this.previewMode, showPreview: this.showPreview, showConfigs: this.showConfigs && this.enabled, showTextFormat: this.showTextFormat && this.enabled, showUndoRedo: this.showUndoRedo && this.enabled }), this.renderContent()), index.h("ez-link-builder", { ref: (el) => this.linkBuilderRef = el }), index.h("ez-simple-image-uploader", { ref: (el) => this.imageUploaderRef = el })));
549
+ }
550
+ get element() { return index.getElement(this); }
551
+ static get watchers() { return {
552
+ "value": ["observeValue"]
553
+ }; }
554
+ };
555
+ EzRichText.style = ezRichTextCss;
556
+
289
557
  const ezTextEditCss = ":host{display:flex;align-items:center;gap:5px}.text-edit__form-input{width:auto;--ez-text-input__input--padding:0px}.text-edit__hidden-value{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}";
290
558
 
291
559
  const EzTextEdit = class {
@@ -384,4 +652,5 @@ EzTextEdit.style = ezTextEditCss;
384
652
 
385
653
  exports.ez_combo_box_list = EzComboBoxList;
386
654
  exports.ez_custom_form_input = EzCustomFormInput;
655
+ exports.ez_rich_text = EzRichText;
387
656
  exports.ez_text_edit = EzTextEdit;
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-a7b0c73d.js');
6
+ const core = require('@sankhyalabs/core');
7
+ const CSSVarsUtils = require('./CSSVarsUtils-f20973d1.js');
8
+
9
+ const ezFilterInputCss = ":host{display:block;width:100%}";
10
+
11
+ const EzFilterInput = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ this.ezChange = index.createEvent(this, "ezChange", 7);
15
+ this.ezSearching = index.createEvent(this, "ezSearching", 7);
16
+ this.ezFocusIn = index.createEvent(this, "ezFocusIn", 7);
17
+ this._searchingText = "";
18
+ this.handleFocus = () => {
19
+ if (this._searchingText === "") {
20
+ this._textInput.value = "";
21
+ }
22
+ else {
23
+ this._textInput.value = this._searchingText;
24
+ }
25
+ this.ezFocusIn.emit();
26
+ };
27
+ this.label = undefined;
28
+ this.value = undefined;
29
+ this.enabled = true;
30
+ this.errorMessage = undefined;
31
+ this.restrict = undefined;
32
+ this.mode = "regular";
33
+ this.asyncSearch = false;
34
+ this.canShowError = true;
35
+ this.autoFocus = false;
36
+ }
37
+ observeLabel() {
38
+ if (this._textInput) {
39
+ this._textInput.label = this.label;
40
+ }
41
+ }
42
+ observeErrorMessage() {
43
+ if (this._textInput) {
44
+ this._textInput.errorMessage = this.errorMessage;
45
+ }
46
+ }
47
+ observeValue(newValue, oldValue) {
48
+ if (this._textInput && newValue != oldValue) {
49
+ this._textInput.value = newValue;
50
+ this.ezChange.emit(newValue);
51
+ }
52
+ }
53
+ /**
54
+ * Aplica o foco no campo.
55
+ */
56
+ async setFocus(options) {
57
+ this._textInput.setFocus(options);
58
+ }
59
+ /**
60
+ * Remove o foco do campo.
61
+ */
62
+ async setBlur() {
63
+ this._textInput.setBlur();
64
+ }
65
+ /**
66
+ * Retorna se o conteúdo é inválido.
67
+ */
68
+ async isInvalid() {
69
+ return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
70
+ }
71
+ /**
72
+ * Método responsável por setar um novo valor ao campo.
73
+ */
74
+ async setValue(newValue) {
75
+ if (!this.asyncSearch || this._textInput == undefined) {
76
+ return;
77
+ }
78
+ if (newValue !== this.value) {
79
+ this.value = newValue;
80
+ this._searchingText = "";
81
+ }
82
+ else {
83
+ this._textInput.value = newValue;
84
+ }
85
+ }
86
+ /**
87
+ * Método responsável por resetar o valor do campo para o ultimo valor inputado.
88
+ */
89
+ async endSearch() {
90
+ if (!this.asyncSearch || this._textInput == undefined) {
91
+ return;
92
+ }
93
+ if (this._textInput.value !== this.value) {
94
+ this._textInput.value = this.value;
95
+ }
96
+ }
97
+ handleChange(evt) {
98
+ const newValue = evt.detail;
99
+ this.errorMessage = "";
100
+ if (this.asyncSearch) {
101
+ this._searchingText = newValue;
102
+ this.ezSearching.emit(newValue);
103
+ }
104
+ else if (newValue !== this.value) {
105
+ this.value = newValue;
106
+ }
107
+ }
108
+ componentDidLoad() {
109
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
110
+ if (this.autoFocus) {
111
+ requestAnimationFrame(() => {
112
+ this.setFocus({ selectText: true });
113
+ });
114
+ }
115
+ }
116
+ render() {
117
+ core.ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
118
+ return (index.h("ez-text-input", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, label: this.label, onEzChange: evt => this.handleChange(evt), value: this.value, enabled: this.enabled, errorMessage: this.errorMessage, restrict: this.restrict, mode: this.mode, onFocusin: this.handleFocus, canShowError: this.canShowError }, index.h("ez-icon", { slot: "leftIcon", iconName: "search" })));
119
+ }
120
+ get _elem() { return index.getElement(this); }
121
+ static get watchers() { return {
122
+ "label": ["observeLabel"],
123
+ "errorMessage": ["observeErrorMessage"],
124
+ "value": ["observeValue"]
125
+ }; }
126
+ };
127
+ EzFilterInput.style = ezFilterInputCss;
128
+
129
+ exports.ez_filter_input = EzFilterInput;
@@ -99,6 +99,11 @@ const buildSearch = ({ name, label, readOnly, required, contextName, canShowErro
99
99
  index.h("ez-search", { class: "ez-input__no-margin", enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, "data-context-name": contextName, key: name, canShowError: canShowError, optionLoader: optionLoader, ignoreLimitCharsToSearch: (_a = props === null || props === void 0 ? void 0 : props.ignoreLimitCharsToSearch) !== null && _a !== void 0 ? _a : false })));
100
100
  };
101
101
 
102
+ const buildRichText = ({ name, label, readOnly, contextName, rows, canShowError }) => {
103
+ return (index.h("div", { class: "ez-col ez-col--sd-12", key: name },
104
+ index.h("ez-rich-text", null)));
105
+ };
106
+
102
107
  const uiBuilders = new Map();
103
108
  uiBuilders.set(core.UserInterface.CHECKBOX, buildCheckBox);
104
109
  uiBuilders.set(core.UserInterface.SWITCH, buildSwitch);
@@ -113,6 +118,7 @@ uiBuilders.set(core.UserInterface.INTEGERNUMBER, buildInteger);
113
118
  uiBuilders.set(core.UserInterface.SEARCH, buildSearch);
114
119
  uiBuilders.set(core.UserInterface.SEARCHPLUS, buildSearchPlus);
115
120
  uiBuilders.set(core.UserInterface.LONGTEXT, buildTextArea);
121
+ uiBuilders.set(core.UserInterface.HTML, buildRichText);
116
122
  const fieldBuilder = (field) => {
117
123
  const builder = uiBuilders.get(field.userInterface) || buildTextInput;
118
124
  const label = field.required ? `${field.label}${constants.REQUIRED_INFO}` : field.label;