@limetech/lime-elements 36.0.0-next.3 → 36.0.0-next.30

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 (121) hide show
  1. package/dist/cjs/{dateFormatter-05d80b12.js → dateFormatter-d7a8d40d.js} +1 -1
  2. package/dist/cjs/lime-elements.cjs.js +1 -1
  3. package/dist/cjs/limel-button.cjs.entry.js +32 -16
  4. package/dist/cjs/limel-chip-set.cjs.entry.js +19 -11
  5. package/dist/cjs/limel-code-editor.cjs.entry.js +1596 -2
  6. package/dist/cjs/limel-collapsible-section.cjs.entry.js +1 -1
  7. package/dist/cjs/{limel-color-picker-palette_2.cjs.entry.js → limel-color-picker-palette.cjs.entry.js} +0 -112
  8. package/dist/cjs/limel-date-picker.cjs.entry.js +3 -3
  9. package/dist/cjs/limel-dock-button.cjs.entry.js +105 -0
  10. package/dist/cjs/limel-dock.cjs.entry.js +104 -0
  11. package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +2 -2
  12. package/dist/cjs/limel-form.cjs.entry.js +1 -1
  13. package/dist/cjs/limel-input-field.cjs.entry.js +13 -6
  14. package/dist/cjs/{limel-list_3.cjs.entry.js → limel-list_2.cjs.entry.js} +0 -2018
  15. package/dist/cjs/limel-popover_4.cjs.entry.js +239 -0
  16. package/dist/cjs/limel-portal.cjs.entry.js +2024 -0
  17. package/dist/cjs/limel-progress-flow-item.cjs.entry.js +1 -1
  18. package/dist/cjs/limel-select.cjs.entry.js +4 -5
  19. package/dist/cjs/limel-table.cjs.entry.js +16 -4
  20. package/dist/cjs/loader.cjs.js +1 -1
  21. package/dist/cjs/{moment-5cfac5cd.js → moment-d1e35cdc.js} +2 -2
  22. package/dist/collection/collection-manifest.json +2 -0
  23. package/dist/collection/components/button/button.css +44 -4
  24. package/dist/collection/components/button/button.js +56 -20
  25. package/dist/collection/components/chip-set/chip-set.css +6 -2
  26. package/dist/collection/components/chip-set/chip-set.js +21 -13
  27. package/dist/collection/components/code-editor/code-editor.css +153 -1
  28. package/dist/collection/components/code-editor/code-editor.js +90 -2
  29. package/dist/collection/components/collapsible-section/collapsible-section.css +8 -7
  30. package/dist/collection/components/date-picker/date-picker.js +18 -1
  31. package/dist/collection/components/dock/dock-button/dock-button.css +77 -0
  32. package/dist/collection/components/dock/dock-button/dock-button.js +224 -0
  33. package/dist/collection/components/dock/dock.css +111 -0
  34. package/dist/collection/components/dock/dock.js +300 -0
  35. package/dist/collection/components/dock/dock.types.js +1 -0
  36. package/dist/collection/components/input-field/input-field.js +32 -7
  37. package/dist/collection/components/popover-surface/popover-surface.css +5 -4
  38. package/dist/collection/components/progress-flow/progress-flow-item/progress-flow-item.css +14 -5
  39. package/dist/collection/components/select/select.css +10 -11
  40. package/dist/collection/components/select/select.template.js +3 -4
  41. package/dist/collection/components/table/columns.js +1 -0
  42. package/dist/collection/components/table/layout.js +8 -0
  43. package/dist/collection/components/table/table.css +89 -61
  44. package/dist/collection/components/table/table.js +45 -14
  45. package/dist/collection/style/internal/codemirror-tooltip.scss +19 -0
  46. package/dist/collection/style/mixins.scss +11 -0
  47. package/dist/esm/{dateFormatter-2cad0292.js → dateFormatter-784c3334.js} +1 -1
  48. package/dist/esm/lime-elements.js +1 -1
  49. package/dist/esm/limel-button.entry.js +33 -17
  50. package/dist/esm/limel-chip-set.entry.js +19 -11
  51. package/dist/esm/limel-code-editor.entry.js +1596 -2
  52. package/dist/esm/limel-collapsible-section.entry.js +1 -1
  53. package/dist/esm/{limel-color-picker-palette_2.entry.js → limel-color-picker-palette.entry.js} +2 -113
  54. package/dist/esm/limel-date-picker.entry.js +3 -3
  55. package/dist/esm/limel-dock-button.entry.js +101 -0
  56. package/dist/esm/limel-dock.entry.js +100 -0
  57. package/dist/esm/limel-flatpickr-adapter.entry.js +2 -2
  58. package/dist/esm/limel-form.entry.js +1 -1
  59. package/dist/esm/limel-input-field.entry.js +13 -6
  60. package/dist/esm/{limel-list_3.entry.js → limel-list_2.entry.js} +1 -2018
  61. package/dist/esm/limel-popover_4.entry.js +232 -0
  62. package/dist/esm/limel-portal.entry.js +2020 -0
  63. package/dist/esm/limel-progress-flow-item.entry.js +1 -1
  64. package/dist/esm/limel-select.entry.js +4 -5
  65. package/dist/esm/limel-table.entry.js +17 -5
  66. package/dist/esm/loader.js +1 -1
  67. package/dist/esm/{moment-367e51c5.js → moment-faa8a4a8.js} +2 -2
  68. package/dist/lime-elements/lime-elements.css +1 -1
  69. package/dist/lime-elements/lime-elements.esm.js +1 -1
  70. package/dist/lime-elements/p-009de50e.entry.js +1 -0
  71. package/dist/lime-elements/{p-7e571ec6.entry.js → p-0ba0c38a.entry.js} +1 -1
  72. package/dist/lime-elements/p-0e87d44d.entry.js +1 -0
  73. package/dist/lime-elements/p-1390fdcb.entry.js +126 -0
  74. package/dist/lime-elements/{p-08251941.entry.js → p-19f72dab.entry.js} +1 -1
  75. package/dist/lime-elements/p-3cf4aae0.entry.js +1 -0
  76. package/dist/lime-elements/p-5ef52589.entry.js +1 -0
  77. package/dist/lime-elements/p-63a57d32.entry.js +1 -0
  78. package/dist/lime-elements/p-653faf47.entry.js +1 -0
  79. package/dist/lime-elements/{p-d76f896d.js → p-73df4d83.js} +1 -1
  80. package/dist/lime-elements/p-93cd2268.entry.js +1 -0
  81. package/dist/lime-elements/p-93f42a32.entry.js +1 -0
  82. package/dist/lime-elements/p-945afca2.js +3 -0
  83. package/dist/lime-elements/p-b0e54dc2.entry.js +1 -0
  84. package/dist/lime-elements/{p-af0ec482.entry.js → p-c544c05b.entry.js} +1 -1
  85. package/dist/lime-elements/p-c89f2b52.entry.js +1 -0
  86. package/dist/lime-elements/p-cb8db8c2.entry.js +37 -0
  87. package/dist/lime-elements/p-f41567a1.entry.js +1 -0
  88. package/dist/lime-elements/p-f5df4d4f.entry.js +1 -0
  89. package/dist/lime-elements/style/internal/codemirror-tooltip.scss +19 -0
  90. package/dist/lime-elements/style/mixins.scss +11 -0
  91. package/dist/types/components/button/button.d.ts +10 -3
  92. package/dist/types/components/chip-set/chip-set.d.ts +3 -2
  93. package/dist/types/components/code-editor/code-editor.d.ts +14 -0
  94. package/dist/types/components/date-picker/date-picker.d.ts +4 -0
  95. package/dist/types/components/dock/dock-button/dock-button.d.ts +52 -0
  96. package/dist/types/components/dock/dock.d.ts +83 -0
  97. package/dist/types/components/dock/dock.types.d.ts +53 -0
  98. package/dist/types/components/input-field/input-field.d.ts +6 -0
  99. package/dist/types/components/table/layout.d.ts +2 -0
  100. package/dist/types/components/table/table.d.ts +16 -1
  101. package/dist/types/components/table/table.types.d.ts +4 -0
  102. package/dist/types/components.d.ts +176 -0
  103. package/dist/types/interface.d.ts +1 -0
  104. package/package.json +5 -4
  105. package/dist/cjs/limel-popover-surface.cjs.entry.js +0 -32
  106. package/dist/cjs/limel-tooltip_2.cjs.entry.js +0 -102
  107. package/dist/esm/limel-popover-surface.entry.js +0 -28
  108. package/dist/esm/limel-tooltip_2.entry.js +0 -97
  109. package/dist/lime-elements/p-1e59114e.entry.js +0 -1
  110. package/dist/lime-elements/p-22569fb6.entry.js +0 -1
  111. package/dist/lime-elements/p-3af5f9ad.js +0 -3
  112. package/dist/lime-elements/p-404e1465.entry.js +0 -1
  113. package/dist/lime-elements/p-5ad60e14.entry.js +0 -126
  114. package/dist/lime-elements/p-6966b5df.entry.js +0 -1
  115. package/dist/lime-elements/p-705334c1.entry.js +0 -1
  116. package/dist/lime-elements/p-75152d89.entry.js +0 -1
  117. package/dist/lime-elements/p-7ee4b825.entry.js +0 -1
  118. package/dist/lime-elements/p-87453b45.entry.js +0 -1
  119. package/dist/lime-elements/p-97d6c4a6.entry.js +0 -1
  120. package/dist/lime-elements/p-b95e80c9.entry.js +0 -1
  121. package/dist/lime-elements/p-d1ee4501.entry.js +0 -37
@@ -15,6 +15,8 @@
15
15
  "./components/date-picker/date-picker.js",
16
16
  "./components/date-picker/flatpickr-adapter/flatpickr-adapter.js",
17
17
  "./components/dialog/dialog.js",
18
+ "./components/dock/dock.js",
19
+ "./components/dock/dock-button/dock-button.js",
18
20
  "./components/file/file.js",
19
21
  "./components/flex-container/flex-container.js",
20
22
  "./components/form/form.js",
@@ -798,6 +798,13 @@ button:active {
798
798
  box-shadow: var(--button-shadow-pressed);
799
799
  transform: translate3d(0, 0.08rem, 0);
800
800
  }
801
+ button:focus {
802
+ outline: none;
803
+ }
804
+ button:focus-visible {
805
+ outline: none;
806
+ box-shadow: var(--shadow-depth-8-focused);
807
+ }
801
808
  button.mdc-button {
802
809
  min-width: 2.25rem;
803
810
  padding: 0 0.75rem;
@@ -842,13 +849,16 @@ button limel-icon {
842
849
  vertical-align: top;
843
850
  }
844
851
  button svg {
845
- fill: currentColor;
846
852
  height: 1.875rem;
847
853
  opacity: 0;
848
854
  pointer-events: none;
849
855
  position: absolute;
850
856
  width: 1.875rem;
851
857
  }
858
+ button svg line {
859
+ stroke: rgb(var(--color-white));
860
+ stroke-width: 2;
861
+ }
852
862
  button limel-icon,
853
863
  button .label,
854
864
  button limel-spinner,
@@ -864,14 +874,20 @@ button.loading limel-spinner {
864
874
  display: block;
865
875
  }
866
876
  button.just-loaded limel-icon,
867
- button.just-loaded .label {
877
+ button.just-loaded .label, button.just-failed limel-icon,
878
+ button.just-failed .label {
868
879
  opacity: 0;
869
880
  }
870
- button.just-loaded svg {
881
+ button.just-loaded svg, button.just-failed svg {
871
882
  opacity: 1;
872
883
  }
873
- button.just-loaded limel-spinner {
884
+ button.just-loaded limel-spinner, button.just-failed limel-spinner {
874
885
  display: block;
886
+ animation: fade-out-spinner 0.3s ease;
887
+ }
888
+ button.just-failed {
889
+ background-color: var(--lime-error-text-color) !important;
890
+ animation: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
875
891
  }
876
892
 
877
893
  .mdc-button--outlined:not(:disabled) {
@@ -879,6 +895,30 @@ button.just-loaded limel-spinner {
879
895
  /* @alternate */
880
896
  border-color: var(--mdc-theme-primary, #26a69a);
881
897
  }
898
+ @keyframes fade-out-spinner {
899
+ 0% {
900
+ opacity: 1;
901
+ transform: scale(1);
902
+ }
903
+ 100% {
904
+ opacity: 0;
905
+ transform: scale(1.5);
906
+ }
907
+ }
908
+ @keyframes shake {
909
+ 10%, 90% {
910
+ transform: translate3d(-0.0625rem, 0, 0);
911
+ }
912
+ 20%, 80% {
913
+ transform: translate3d(0.125rem, 0, 0);
914
+ }
915
+ 30%, 50%, 70% {
916
+ transform: translate3d(-0.1875rem, 0, 0);
917
+ }
918
+ 40%, 60% {
919
+ transform: translate3d(0.1875rem, 0, 0);
920
+ }
921
+ }
882
922
  @keyframes reduced-presence {
883
923
  0% {
884
924
  opacity: 1;
@@ -1,4 +1,4 @@
1
- import { Component, Element, h, Prop, Watch } from '@stencil/core';
1
+ import { Component, h, Prop, State, Watch } from '@stencil/core';
2
2
  /**
3
3
  * @exampleComponent limel-example-button-basic
4
4
  * @exampleComponent limel-example-button-disabled
@@ -7,7 +7,8 @@ import { Component, Element, h, Prop, Watch } from '@stencil/core';
7
7
  * @exampleComponent limel-example-button-outlined
8
8
  * @exampleComponent limel-example-button-primary
9
9
  * @exampleComponent limel-example-button-composite
10
- * @exampleComponent limel-example-button-click
10
+ * @exampleComponent limel-example-button-click-success
11
+ * @exampleComponent limel-example-button-click-fail
11
12
  * @exampleComponent limel-example-button-reduce-presence
12
13
  * @exampleComponent limel-example-button-colors
13
14
  */
@@ -32,37 +33,52 @@ export class Button {
32
33
  * `disabled` property should be set to `true` as well.
33
34
  */
34
35
  this.loading = false;
36
+ /**
37
+ * Set to `true` to indicate failure instead of success when the button is
38
+ * no longer in the `loading` state.
39
+ */
40
+ this.loadingFailed = false;
41
+ this.justLoaded = false;
35
42
  }
36
43
  render() {
37
- return (h("button", { class: `
38
- mdc-button
39
- ${this.primary ? 'mdc-button--unelevated' : ''}
40
- ${this.loading ? 'loading' : ''}
41
- ${this.outlined ? 'mdc-button--outlined' : ''}
42
- `, disabled: this.disabled },
43
- h("div", { class: "mdc-button__ripple" }),
44
+ return (h("button", { class: {
45
+ 'mdc-button': true,
46
+ 'mdc-button--unelevated': this.primary,
47
+ loading: this.loading,
48
+ 'just-loaded': this.justLoaded && !this.loadingFailed,
49
+ 'just-failed': this.justLoaded && this.loadingFailed,
50
+ 'mdc-button--outlined': this.outlined,
51
+ }, disabled: this.disabled || this.loading },
44
52
  this.renderIcon(),
45
53
  h("span", { class: "label mdc-button__label" }, this.label),
46
54
  h("limel-spinner", { limeBranded: false }),
47
- h("svg", { viewBox: "0 0 30 30" },
48
- h("path", { d: "M20.659 10l-6.885 6.884-3.89-3.89-1.342 1.341 5.053 5.052.182.176L22 11.341z" }))));
55
+ h("svg", { viewBox: "0 0 30 30" }, this.renderLoadingIcons())));
49
56
  }
50
57
  loadingWatcher(newValue, oldValue) {
51
- const JUST_LOADED = 'just-loaded';
52
- const button = this.limelButton.shadowRoot.querySelector('button');
53
58
  if (oldValue && !newValue) {
54
- button.classList.remove('loading');
55
- button.classList.add(JUST_LOADED);
59
+ this.justLoaded = true;
56
60
  const TIMEOUT = 2000;
57
- this.justLoadedTimeout = setTimeout(() => {
58
- button.classList.remove(JUST_LOADED);
61
+ this.justLoadedTimeout = window.setTimeout(() => {
62
+ this.justLoaded = false;
59
63
  }, TIMEOUT);
60
64
  }
61
65
  else if (newValue) {
62
- button.classList.remove(JUST_LOADED);
63
- clearTimeout(this.justLoadedTimeout);
66
+ this.justLoaded = false;
67
+ window.clearTimeout(this.justLoadedTimeout);
64
68
  }
65
69
  }
70
+ renderLoadingIcons() {
71
+ if (this.loadingFailed) {
72
+ return [
73
+ h("line", { x1: "9", y1: "9", x2: "21", y2: "21" }),
74
+ h("line", { x1: "21", y1: "9", x2: "9", y2: "21" }),
75
+ ];
76
+ }
77
+ return [
78
+ h("line", { x1: "8", y1: "14", x2: "15", y2: "20" }),
79
+ h("line", { x1: "23", y1: "9", x2: "14", y2: "20" }),
80
+ ];
81
+ }
66
82
  renderIcon() {
67
83
  if (!this.icon) {
68
84
  return;
@@ -188,9 +204,29 @@ export class Button {
188
204
  "attribute": "loading",
189
205
  "reflect": true,
190
206
  "defaultValue": "false"
207
+ },
208
+ "loadingFailed": {
209
+ "type": "boolean",
210
+ "mutable": false,
211
+ "complexType": {
212
+ "original": "boolean",
213
+ "resolved": "boolean",
214
+ "references": {}
215
+ },
216
+ "required": false,
217
+ "optional": false,
218
+ "docs": {
219
+ "tags": [],
220
+ "text": "Set to `true` to indicate failure instead of success when the button is\nno longer in the `loading` state."
221
+ },
222
+ "attribute": "loading-failed",
223
+ "reflect": true,
224
+ "defaultValue": "false"
191
225
  }
192
226
  }; }
193
- static get elementRef() { return "limelButton"; }
227
+ static get states() { return {
228
+ "justLoaded": {}
229
+ }; }
194
230
  static get watchers() { return [{
195
231
  "propName": "loading",
196
232
  "methodName": "loadingWatcher"
@@ -2875,13 +2875,17 @@ limel-icon.mdc-chip__icon.mdc-chip__icon--leading {
2875
2875
  .clear-all-button:hover {
2876
2876
  background-color: #757580;
2877
2877
  }
2878
- .clear-all-button:focus, .has-chips:not(.mdc-text-field--disabled):hover .clear-all-button, .has-chips:not(.mdc-text-field--disabled).mdc-text-field--focused .clear-all-button {
2879
- opacity: 1;
2878
+ .clear-all-button:focus {
2880
2879
  outline: none;
2881
2880
  }
2882
2881
  .clear-all-button:focus-visible {
2882
+ outline: none;
2883
2883
  box-shadow: var(--shadow-depth-8-focused);
2884
2884
  }
2885
+ .clear-all-button:focus, .has-chips:not(.mdc-text-field--disabled):hover .clear-all-button, .has-chips:not(.mdc-text-field--disabled).mdc-text-field--focused .clear-all-button {
2886
+ opacity: 1;
2887
+ outline: none;
2888
+ }
2885
2889
  :not(.has-chips) .clear-all-button, .has-chips.mdc-text-field--disabled .clear-all-button {
2886
2890
  display: none;
2887
2891
  }
@@ -242,19 +242,27 @@ export class ChipSet {
242
242
  'lime-notched-outline--notched': !!(this.value.length || this.editMode),
243
243
  }, "dropzone-tip": this.dropZoneTip() },
244
244
  h("div", { class: "mdc-notched-outline__leading" }),
245
- h("div", { class: "mdc-notched-outline__notch" },
246
- h("label", { class: {
247
- 'mdc-floating-label': true,
248
- 'mdc-text-field--disabled': this.readonly || this.disabled,
249
- 'mdc-floating-label--required': this.required,
250
- 'lime-floating-label--float-above': !!(this.value.length || this.editMode),
251
- }, htmlFor: "input-element" }, this.label)),
245
+ this.renderLabel(),
252
246
  h("div", { class: "mdc-notched-outline__trailing" })),
253
247
  this.renderLeadingIcon(),
254
248
  this.renderClearAllChipsButton()),
255
249
  this.renderHelperLine(),
256
250
  ];
257
251
  }
252
+ renderLabel() {
253
+ const labelClassList = {
254
+ 'mdc-floating-label': true,
255
+ 'mdc-text-field--no-label': !this.label,
256
+ 'mdc-text-field--disabled': this.readonly || this.disabled,
257
+ 'mdc-floating-label--required': this.required,
258
+ 'lime-floating-label--float-above': !!(this.value.length || this.editMode),
259
+ };
260
+ if (!this.label) {
261
+ return;
262
+ }
263
+ return (h("div", { class: "mdc-notched-outline__notch" },
264
+ h("label", { class: labelClassList, htmlFor: "input-element" }, this.label)));
265
+ }
258
266
  isFull() {
259
267
  return !!this.maxItems && this.value.length >= this.maxItems;
260
268
  }
@@ -351,10 +359,10 @@ export class ChipSet {
351
359
  }
352
360
  renderDefaultChip(chip) {
353
361
  return (h("div", { class: `mdc-chip ${chip.selected ? SELECTED_CHIP_CLASS : ''}`, role: "row", id: `${chip.id}` },
354
- chip.icon ? this.renderIcon(chip) : null,
355
- chip.text ? this.renderLabel(chip) : null));
362
+ chip.icon ? this.renderChipIcon(chip) : null,
363
+ chip.text ? this.renderChipLabel(chip) : null));
356
364
  }
357
- renderLabel(chip) {
365
+ renderChipLabel(chip) {
358
366
  const attributes = {};
359
367
  if (chip.href) {
360
368
  attributes.href = getHref(chip.href);
@@ -379,8 +387,8 @@ export class ChipSet {
379
387
  'mdc-chip--selected': this.inputChipIndexSelected === index,
380
388
  disabled: this.disabled,
381
389
  }, role: "row", id: `${chip.id}`, onClick: this.catchInputChipClicks },
382
- chip.icon ? this.renderIcon(chip) : null,
383
- this.renderLabel(chip),
390
+ chip.icon ? this.renderChipIcon(chip) : null,
391
+ this.renderChipLabel(chip),
384
392
  this.renderChipRemoveButton(chip)),
385
393
  this.renderDelimiter(),
386
394
  ];
@@ -388,7 +396,7 @@ export class ChipSet {
388
396
  catchInputChipClicks(event) {
389
397
  event.stopPropagation();
390
398
  }
391
- renderIcon(chip) {
399
+ renderChipIcon(chip) {
392
400
  const style = {};
393
401
  if (chip.iconFillColor) {
394
402
  style['--icon-color'] = chip.iconFillColor;
@@ -343,15 +343,125 @@ div.CodeMirror-dragcursors {
343
343
  /* Help users use markselection to safely style text background */
344
344
  span.CodeMirror-selectedtext { background: none; }
345
345
 
346
+ /* The lint marker gutter */
347
+ .CodeMirror-lint-markers {
348
+ width: 16px;
349
+ }
350
+
351
+ .CodeMirror-lint-tooltip {
352
+ background-color: #ffd;
353
+ border: 1px solid black;
354
+ border-radius: 4px 4px 4px 4px;
355
+ color: black;
356
+ font-family: monospace;
357
+ font-size: 10pt;
358
+ overflow: hidden;
359
+ padding: 2px 5px;
360
+ position: fixed;
361
+ white-space: pre;
362
+ white-space: pre-wrap;
363
+ z-index: 100;
364
+ max-width: 600px;
365
+ opacity: 0;
366
+ transition: opacity .4s;
367
+ -moz-transition: opacity .4s;
368
+ -webkit-transition: opacity .4s;
369
+ -o-transition: opacity .4s;
370
+ -ms-transition: opacity .4s;
371
+ }
372
+
373
+ .CodeMirror-lint-mark {
374
+ background-position: left bottom;
375
+ background-repeat: repeat-x;
376
+ }
377
+
378
+ .CodeMirror-lint-mark-warning {
379
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
380
+ }
381
+
382
+ .CodeMirror-lint-mark-error {
383
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==");
384
+ }
385
+
386
+ .CodeMirror-lint-marker {
387
+ background-position: center center;
388
+ background-repeat: no-repeat;
389
+ cursor: pointer;
390
+ display: inline-block;
391
+ height: 16px;
392
+ width: 16px;
393
+ vertical-align: middle;
394
+ position: relative;
395
+ }
396
+
397
+ .CodeMirror-lint-message {
398
+ padding-left: 18px;
399
+ background-position: top left;
400
+ background-repeat: no-repeat;
401
+ }
402
+
403
+ .CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
404
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
405
+ }
406
+
407
+ .CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
408
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
409
+ }
410
+
411
+ .CodeMirror-lint-marker-multiple {
412
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
413
+ background-repeat: no-repeat;
414
+ background-position: right bottom;
415
+ width: 100%; height: 100%;
416
+ }
417
+
418
+ .CodeMirror-lint-line-error {
419
+ background-color: rgba(183, 76, 81, 0.08);
420
+ }
421
+
422
+ .CodeMirror-lint-line-warning {
423
+ background-color: rgba(255, 211, 0, 0.1);
424
+ }
425
+
426
+ .CodeMirror-foldmarker {
427
+ color: blue;
428
+ text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
429
+ font-family: arial;
430
+ line-height: .3;
431
+ cursor: pointer;
432
+ }
433
+ .CodeMirror-foldgutter {
434
+ width: .7em;
435
+ }
436
+ .CodeMirror-foldgutter-open,
437
+ .CodeMirror-foldgutter-folded {
438
+ cursor: pointer;
439
+ }
440
+ .CodeMirror-foldgutter-open:after {
441
+ content: "\25BE";
442
+ }
443
+ .CodeMirror-foldgutter-folded:after {
444
+ content: "\25B8";
445
+ }
446
+
447
+ /*
448
+ * This file is imported into every component!
449
+ *
450
+ * Nothing in this file may output any CSS
451
+ * without being explicitly called by outside code.
452
+ */
346
453
  /**
347
454
  * @prop --code-editor-max-height: Defines how tall the code editor can get before content becomes scrollable, defaults to `10rem`.
455
+ * @prop --code-editor-font-size: Defines the font size of the code, defaults to `0.875rem`.
348
456
  */
349
457
  :host {
350
458
  display: flex;
351
- font-size: 1rem;
459
+ font-size: var(--code-editor-font-size, 0.875rem);
352
460
  }
353
461
 
354
462
  .editor {
463
+ display: flex;
464
+ align-items: stretch;
355
465
  width: 100%;
356
466
  }
357
467
  .editor.is-light-mode {
@@ -477,6 +587,7 @@ span.CodeMirror-selectedtext { background: none; }
477
587
  background-color: rgb(var(--code-editor-background-color));
478
588
  border-radius: 0.25rem;
479
589
  height: auto;
590
+ width: 100%;
480
591
  }
481
592
  .cm-s-lime .CodeMirror-scroll {
482
593
  max-height: var(--code-editor-max-height, 10rem);
@@ -518,4 +629,45 @@ span.CodeMirror-selectedtext { background: none; }
518
629
  bottom: -0.4rem;
519
630
  left: 0;
520
631
  right: 0;
632
+ }
633
+ .cm-s-lime .CodeMirror-lint-marker-error,
634
+ .cm-s-lime .CodeMirror-lint-message-error {
635
+ background-image: url("data:image/svg+xml; utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><defs/><path fill='rgb(255,255,255)' d='M7.219 5.781L5.78 7.22 14.563 16 5.78 24.781 7.22 26.22 16 17.437l8.781 8.782 1.438-1.438L17.437 16l8.782-8.781L24.78 5.78 16 14.563z'/></svg>");
636
+ background-color: rgb(var(--color-red-default));
637
+ background-size: 0.75rem;
638
+ border-radius: 50%;
639
+ }
640
+ .cm-s-lime .CodeMirror-foldmarker {
641
+ position: relative;
642
+ transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease-out;
643
+ box-shadow: var(--button-shadow-normal);
644
+ color: transparent;
645
+ text-shadow: none;
646
+ padding: 0 0.5rem;
647
+ border-radius: 1rem;
648
+ background-image: url("data:image/svg+xml; utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' xml:space='preserve'><circle cx='16' cy='16' r='2'/><circle cx='26' cy='16' r='2'/><circle cx='6' cy='16' r='2'/></svg>");
649
+ background-size: contain;
650
+ background-repeat: no-repeat;
651
+ background-position: center;
652
+ }
653
+ .cm-s-lime .CodeMirror-foldmarker:hover {
654
+ box-shadow: var(--button-shadow-hovered);
655
+ }
656
+ .cm-s-lime .CodeMirror-foldmarker:active {
657
+ box-shadow: var(--button-shadow-pressed);
658
+ transform: translate3d(0, 0.08rem, 0);
659
+ }
660
+ .is-dark-mode .cm-s-lime .CodeMirror-foldmarker {
661
+ background-color: rgb(var(--contrast-1200));
662
+ }
663
+ .cm-s-lime [class^=CodeMirror-foldgutter] {
664
+ color: var(--code-editor-neutral-text-color);
665
+ transition: opacity 0.2s ease;
666
+ opacity: 0.4;
667
+ }
668
+ .cm-s-lime [class^=CodeMirror-foldgutter]:hover {
669
+ opacity: 1;
670
+ }
671
+ .cm-s-lime .CodeMirror-foldgutter-folded {
672
+ opacity: 0.7;
521
673
  }
@@ -1,14 +1,20 @@
1
- import { Component, h, Prop, Element, Event, State, } from '@stencil/core';
1
+ import { Component, h, Prop, Element, Event, State, Watch, } from '@stencil/core';
2
2
  import CodeMirror from 'codemirror';
3
3
  import 'codemirror/mode/javascript/javascript';
4
4
  import 'codemirror/addon/selection/active-line';
5
5
  import 'codemirror/addon/edit/matchbrackets';
6
+ import 'codemirror/addon/lint/lint';
7
+ import 'codemirror/addon/lint/json-lint';
8
+ import 'codemirror/addon/fold/foldgutter';
9
+ import 'codemirror/addon/fold/brace-fold';
10
+ import jslint from 'jsonlint-mod';
6
11
  /**
7
12
  * Currently this component support syntax highlighting for `javascript`,
8
13
  `json` and `typescript` formats.
9
14
  *
10
15
  * @exampleComponent limel-example-code-editor
11
16
  * @exampleComponent limel-example-code-editor-readonly-with-line-numbers
17
+ * @exampleComponent limel-example-code-editor-fold-lint
12
18
  */
13
19
  export class CodeEditor {
14
20
  constructor() {
@@ -24,6 +30,14 @@ export class CodeEditor {
24
30
  * Displays line numbers in the editor
25
31
  */
26
32
  this.lineNumbers = false;
33
+ /**
34
+ * Allows the user to fold code
35
+ */
36
+ this.fold = false;
37
+ /**
38
+ * Enables linting of JSON content
39
+ */
40
+ this.lint = false;
27
41
  /**
28
42
  * Select color scheme for the editor
29
43
  */
@@ -65,16 +79,37 @@ export class CodeEditor {
65
79
  }
66
80
  this.editor = this.createEditor();
67
81
  }
82
+ watchValue(newValue) {
83
+ if (!this.editor) {
84
+ return;
85
+ }
86
+ const currentValue = this.editor.getValue();
87
+ if (newValue === currentValue) {
88
+ // Circuit breaker for when the change comes from the editor itself
89
+ // The caret position will be reset without this
90
+ return;
91
+ }
92
+ this.editor.getDoc().setValue(newValue || '');
93
+ }
68
94
  createEditor() {
69
95
  const options = this.getOptions();
70
96
  const editor = CodeMirror(this.host.shadowRoot.querySelector('.editor'), options);
71
97
  editor.on('change', this.handleChange);
98
+ // Replace tab with spaces and use the actual indent setting for
99
+ // the space count
100
+ editor.setOption('extraKeys', {
101
+ Tab: (codeMirror) => {
102
+ const spaces = Array(codeMirror.getOption('indentUnit') + 1).join(' ');
103
+ codeMirror.replaceSelection(spaces);
104
+ },
105
+ });
72
106
  return editor;
73
107
  }
74
108
  getOptions() {
75
109
  let mode = this.language;
76
110
  const TAB_SIZE = 4;
77
111
  let theme = 'lime light';
112
+ const gutters = [];
78
113
  if (this.isDarkMode()) {
79
114
  theme = 'lime dark';
80
115
  }
@@ -83,6 +118,13 @@ export class CodeEditor {
83
118
  name: 'application/json',
84
119
  json: true,
85
120
  };
121
+ if (this.lint) {
122
+ gutters.push('CodeMirror-lint-markers');
123
+ if (!('jsonlint' in window)) {
124
+ // eslint-disable-next-line @typescript-eslint/dot-notation
125
+ window['jsonlint'] = jslint;
126
+ }
127
+ }
86
128
  }
87
129
  else if (this.language === 'typescript') {
88
130
  mode = {
@@ -90,9 +132,12 @@ export class CodeEditor {
90
132
  typescript: true,
91
133
  };
92
134
  }
135
+ if (this.fold) {
136
+ gutters.push('CodeMirror-foldgutter');
137
+ }
93
138
  return {
94
139
  mode: mode,
95
- value: this.value,
140
+ value: this.value || '',
96
141
  theme: theme,
97
142
  readOnly: this.readonly,
98
143
  tabSize: TAB_SIZE,
@@ -100,6 +145,9 @@ export class CodeEditor {
100
145
  lineNumbers: this.lineNumbers,
101
146
  styleActiveLine: true,
102
147
  matchBrackets: true,
148
+ lint: this.lint,
149
+ foldGutter: this.fold,
150
+ gutters: gutters,
103
151
  };
104
152
  }
105
153
  isDarkMode() {
@@ -208,6 +256,42 @@ export class CodeEditor {
208
256
  "reflect": false,
209
257
  "defaultValue": "false"
210
258
  },
259
+ "fold": {
260
+ "type": "boolean",
261
+ "mutable": false,
262
+ "complexType": {
263
+ "original": "boolean",
264
+ "resolved": "boolean",
265
+ "references": {}
266
+ },
267
+ "required": false,
268
+ "optional": false,
269
+ "docs": {
270
+ "tags": [],
271
+ "text": "Allows the user to fold code"
272
+ },
273
+ "attribute": "fold",
274
+ "reflect": false,
275
+ "defaultValue": "false"
276
+ },
277
+ "lint": {
278
+ "type": "boolean",
279
+ "mutable": false,
280
+ "complexType": {
281
+ "original": "boolean",
282
+ "resolved": "boolean",
283
+ "references": {}
284
+ },
285
+ "required": false,
286
+ "optional": false,
287
+ "docs": {
288
+ "tags": [],
289
+ "text": "Enables linting of JSON content"
290
+ },
291
+ "attribute": "lint",
292
+ "reflect": false,
293
+ "defaultValue": "false"
294
+ },
211
295
  "colorScheme": {
212
296
  "type": "string",
213
297
  "mutable": false,
@@ -252,4 +336,8 @@ export class CodeEditor {
252
336
  }
253
337
  }]; }
254
338
  static get elementRef() { return "host"; }
339
+ static get watchers() { return [{
340
+ "propName": "value",
341
+ "methodName": "watchValue"
342
+ }]; }
255
343
  }
@@ -63,7 +63,7 @@
63
63
  /**
64
64
  * @prop --closed-header-background-color: background color for header when closed
65
65
  * @prop --open-header-background-color: background color for header when open
66
- * @prop --header-stroke-color: color of the animated icons that visulize collapsed or normal states of the headers, as well as the divider line on headers
66
+ * @prop --header-stroke-color: color of the animated icons that visualize collapsed or normal states of the headers, as well as the divider line on headers
67
67
  * @prop --body-background-color: background color for body
68
68
  * @prop --body-padding: space around content of the body
69
69
  */
@@ -92,6 +92,13 @@
92
92
  background-color: var(--closed-header-background-color, rgb(var(--contrast-200)));
93
93
  border-radius: var(--border-radius-of-header);
94
94
  }
95
+ .section__header:focus {
96
+ outline: none;
97
+ }
98
+ .section__header:focus-visible {
99
+ outline: none;
100
+ box-shadow: var(--shadow-depth-8-focused);
101
+ }
95
102
  section.open .section__header {
96
103
  background-color: var(--open-header-background-color, rgb(var(--contrast-100)));
97
104
  border-radius: var(--border-radius-of-header) var(--border-radius-of-header) 0 0;
@@ -102,12 +109,6 @@ section.open .section__header:hover {
102
109
  .section__header:hover {
103
110
  background-color: var(--open-header-background-color, rgb(var(--contrast-300)));
104
111
  }
105
- .section__header:focus {
106
- outline: none;
107
- }
108
- .section__header:focus-visible {
109
- box-shadow: var(--shadow-depth-8-focused);
110
- }
111
112
 
112
113
  .section__header__title {
113
114
  -moz-osx-font-smoothing: grayscale;