@redvars/peacock 3.6.0 → 3.6.2

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 (105) hide show
  1. package/dist/assets/styles.css +1 -1
  2. package/dist/assets/styles.css.map +1 -1
  3. package/dist/assets/tokens.css +1 -1
  4. package/dist/assets/tokens.css.map +1 -1
  5. package/dist/{button-colors-Ccys3hvS.js → button-colors-AvGh22Zn.js} +18 -18
  6. package/dist/{button-colors-Ccys3hvS.js.map → button-colors-AvGh22Zn.js.map} +1 -1
  7. package/dist/button-group.js +2 -2
  8. package/dist/button.js +2 -3
  9. package/dist/button.js.map +1 -1
  10. package/dist/card.js +1 -1
  11. package/dist/card.js.map +1 -1
  12. package/dist/code-highlighter.js +34 -9
  13. package/dist/code-highlighter.js.map +1 -1
  14. package/dist/custom-elements-jsdocs.json +4973 -3553
  15. package/dist/custom-elements.json +7899 -6346
  16. package/dist/{flow-designer-node-XMe-jlKg.js → flow-designer-node-BWrPuxAR.js} +2 -2
  17. package/dist/flow-designer-node-BWrPuxAR.js.map +1 -0
  18. package/dist/flow-designer-node.js +1 -1
  19. package/dist/flow-designer.js +1402 -8
  20. package/dist/flow-designer.js.map +1 -1
  21. package/dist/html-editor.js +27245 -87
  22. package/dist/html-editor.js.map +1 -1
  23. package/dist/icon-CueRR7wx.js +260 -0
  24. package/dist/icon-CueRR7wx.js.map +1 -0
  25. package/dist/{icon-button-CK1ZuE-2.js → icon-button-ohxHhy4t.js} +2 -2
  26. package/dist/{icon-button-CK1ZuE-2.js.map → icon-button-ohxHhy4t.js.map} +1 -1
  27. package/dist/index.js +10 -9
  28. package/dist/index.js.map +1 -1
  29. package/dist/modal.js +12 -18
  30. package/dist/modal.js.map +1 -1
  31. package/dist/{navigation-rail-DyO0oAZU.js → navigation-rail-CD7IrqbN.js} +952 -279
  32. package/dist/navigation-rail-CD7IrqbN.js.map +1 -0
  33. package/dist/peacock-loader.js +39 -30
  34. package/dist/peacock-loader.js.map +1 -1
  35. package/dist/{popover-NC7b1lTq.js → popover-DUPmMVWS.js} +9 -4
  36. package/dist/{popover-NC7b1lTq.js.map → popover-DUPmMVWS.js.map} +1 -1
  37. package/dist/popover.js +1 -1
  38. package/dist/src/__controllers/floating-controller.d.ts +1 -0
  39. package/dist/src/avatar/avatar.d.ts +1 -1
  40. package/dist/src/breadcrumb/breadcrumb/breadcrumb.d.ts +0 -1
  41. package/dist/src/chip/chip/chip.d.ts +14 -11
  42. package/dist/src/chip/chip-set/chip-set.d.ts +20 -0
  43. package/dist/src/chip/chip-set/index.d.ts +1 -0
  44. package/dist/src/code-highlighter/code-highlighter.d.ts +4 -0
  45. package/dist/src/html-editor/html-editor.d.ts +44 -11
  46. package/dist/src/index.d.ts +3 -0
  47. package/dist/src/list/index.d.ts +2 -0
  48. package/dist/src/list/list-item.d.ts +35 -0
  49. package/dist/src/list/list.d.ts +28 -0
  50. package/dist/src/menu/menu/menu.d.ts +1 -0
  51. package/dist/src/modal/modal.d.ts +2 -8
  52. package/dist/src/navigation-rail/navigation-rail.d.ts +3 -7
  53. package/dist/src/number-field/number-field.d.ts +2 -2
  54. package/dist/src/svg/index.d.ts +1 -0
  55. package/dist/src/svg/svg.d.ts +38 -0
  56. package/dist/src/toolbar/toolbar.d.ts +3 -3
  57. package/dist/test/chip.test.d.ts +1 -0
  58. package/dist/toolbar.js +3 -3
  59. package/dist/toolbar.js.map +1 -1
  60. package/dist/tsconfig.tsbuildinfo +1 -1
  61. package/package.json +7 -1
  62. package/readme.md +3 -3
  63. package/scss/styles.scss +3 -3
  64. package/scss/tokens.css +1 -1
  65. package/src/__controllers/floating-controller.ts +9 -3
  66. package/src/avatar/avatar.scss +4 -4
  67. package/src/avatar/avatar.ts +1 -1
  68. package/src/breadcrumb/breadcrumb/breadcrumb.ts +0 -1
  69. package/src/button/button/button.scss +17 -17
  70. package/src/button/button/button.ts +1 -2
  71. package/src/card/card.ts +1 -1
  72. package/src/chip/chip/chip.scss +119 -45
  73. package/src/chip/chip/chip.ts +97 -38
  74. package/src/chip/chip-set/chip-set.scss +13 -0
  75. package/src/chip/chip-set/chip-set.ts +25 -0
  76. package/src/chip/chip-set/index.ts +1 -0
  77. package/src/code-highlighter/code-highlighter.ts +33 -6
  78. package/src/field/field.scss +1 -1
  79. package/src/flow-designer/flow-designer-node.ts +1 -1
  80. package/src/html-editor/html-editor.scss +44 -2
  81. package/src/html-editor/html-editor.ts +309 -94
  82. package/src/index.ts +3 -1
  83. package/src/list/index.ts +2 -0
  84. package/src/list/list-item.scss +111 -0
  85. package/src/list/list-item.ts +175 -0
  86. package/src/list/list.scss +24 -0
  87. package/src/list/list.ts +51 -0
  88. package/src/menu/menu/menu.ts +11 -0
  89. package/src/modal/modal.scss +10 -10
  90. package/src/modal/modal.ts +2 -8
  91. package/src/navigation-rail/navigation-rail-item.scss +7 -38
  92. package/src/navigation-rail/navigation-rail-item.ts +1 -2
  93. package/src/navigation-rail/navigation-rail.scss +17 -21
  94. package/src/navigation-rail/navigation-rail.ts +6 -9
  95. package/src/number-field/number-field.ts +2 -2
  96. package/src/peacock-loader.ts +36 -22
  97. package/src/svg/index.ts +1 -0
  98. package/src/svg/svg.scss +91 -0
  99. package/src/svg/svg.ts +160 -0
  100. package/src/toolbar/toolbar.ts +3 -3
  101. package/dist/flow-designer-dZnLJOQT.js +0 -1656
  102. package/dist/flow-designer-dZnLJOQT.js.map +0 -1
  103. package/dist/flow-designer-node-XMe-jlKg.js.map +0 -1
  104. package/dist/navigation-rail-DyO0oAZU.js.map +0 -1
  105. package/src/chip/chip/chip-colors.scss +0 -31
@@ -0,0 +1,91 @@
1
+ @use '../../scss/mixin';
2
+
3
+ @include mixin.base-styles;
4
+
5
+ :host {
6
+ display: inline-flex;
7
+ vertical-align: middle;
8
+ --svg-size: inherit;
9
+ --svg-color: inherit;
10
+ }
11
+
12
+ .svg-wrapper {
13
+ height: var(--svg-size, 1rem);
14
+ width: var(--svg-size, 1rem);
15
+ display: inline-flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ }
19
+
20
+ .svg-content {
21
+ height: 100%;
22
+ width: 100%;
23
+ display: inline-flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+
27
+ svg {
28
+ fill: var(--svg-color);
29
+ height: 100%;
30
+ width: 100%;
31
+ }
32
+ }
33
+
34
+ .svg-content.clickable {
35
+ cursor: zoom-in;
36
+ }
37
+
38
+ .placeholder {
39
+ display: block;
40
+ height: 100%;
41
+ width: 100%;
42
+ }
43
+
44
+ .preview-overlay {
45
+ display: none;
46
+ position: fixed;
47
+ inset: 0;
48
+ z-index: 9999;
49
+ background: rgba(0, 0, 0, 0.85);
50
+ align-items: center;
51
+ justify-content: center;
52
+ cursor: zoom-out;
53
+ }
54
+
55
+ .preview-overlay.open {
56
+ display: flex;
57
+ }
58
+
59
+ .preview-close {
60
+ position: absolute;
61
+ top: 1rem;
62
+ right: 1rem;
63
+ background: transparent;
64
+ border: none;
65
+ color: #fff;
66
+ font-size: 1.5rem;
67
+ cursor: pointer;
68
+ line-height: 1;
69
+ padding: 0.25rem 0.5rem;
70
+
71
+ &:focus-visible {
72
+ outline: 2px solid #fff;
73
+ outline-offset: 2px;
74
+ }
75
+ }
76
+
77
+ .preview-content {
78
+ max-width: 90vw;
79
+ max-height: 90vh;
80
+ display: flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ cursor: default;
84
+
85
+ svg {
86
+ max-width: 90vw;
87
+ max-height: 90vh;
88
+ box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
89
+ border-radius: 4px;
90
+ }
91
+ }
package/src/svg/svg.ts ADDED
@@ -0,0 +1,160 @@
1
+ import { html, LitElement } from 'lit';
2
+ import { property, state } from 'lit/decorators.js';
3
+ import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
4
+
5
+ import { sanitizeSvg } from '@/__utils/sanitize-svg.js';
6
+ import { fetchSVG } from '../icon/datasource.js';
7
+
8
+ import styles from './svg.scss';
9
+
10
+ /**
11
+ * @label SVG
12
+ * @tag wc-svg
13
+ * @rawTag svg
14
+ * @summary An SVG component with lazy loading and optional preview support.
15
+ * @overview Renders an inline SVG fetched from a URL, with lazy loading via IntersectionObserver and an optional click-to-preview lightbox.
16
+ *
17
+ * @cssprop --svg-color - Controls the fill color of the SVG.
18
+ * @cssprop [--svg-size=1rem] - Controls the size of the SVG. Defaults to "1rem"
19
+ *
20
+ * @example
21
+ * ```html
22
+ * <wc-svg src="/icons/my-icon.svg" image-title="My icon"></wc-svg>
23
+ * ```
24
+ */
25
+ export class Svg extends LitElement {
26
+ static styles = [styles];
27
+
28
+ /** URL of the SVG asset to fetch and render inline. */
29
+ @property({ type: String, reflect: true }) src = '';
30
+
31
+ /** Accessible title / alt text for the SVG. */
32
+ @property({ attribute: 'image-title' }) imageTitle = '';
33
+
34
+ /** Enable click-to-preview lightbox. */
35
+ @property({ type: Boolean, reflect: true }) preview = false;
36
+
37
+ @state() private _loaded = false;
38
+
39
+ @state() private _previewOpen = false;
40
+
41
+ @state() private _svgContent: string = '';
42
+
43
+ // token to avoid stale fetch results
44
+ private _fetchId = 0;
45
+
46
+ private _intersectionObserver: IntersectionObserver | null = null;
47
+
48
+ disconnectedCallback() {
49
+ super.disconnectedCallback();
50
+ this._intersectionObserver?.disconnect();
51
+ }
52
+
53
+ firstUpdated() {
54
+ this._setupIntersectionObserver();
55
+ }
56
+
57
+ updated(changedProperties: Map<string, unknown>) {
58
+ if (changedProperties.has('src')) {
59
+ // Reset lazy-load state so the new src is fetched when visible
60
+ this._loaded = false;
61
+ this._svgContent = '';
62
+ this._setupIntersectionObserver();
63
+ }
64
+ }
65
+
66
+ private _setupIntersectionObserver() {
67
+ this._intersectionObserver?.disconnect();
68
+
69
+ const wrapper = this.shadowRoot?.querySelector('.svg-wrapper');
70
+ if (!wrapper) return;
71
+
72
+ this._intersectionObserver = new IntersectionObserver(
73
+ (entries) => {
74
+ if (entries[0].isIntersecting) {
75
+ this._loaded = true;
76
+ this._intersectionObserver?.disconnect();
77
+ this._fetchSvg();
78
+ }
79
+ },
80
+ { rootMargin: '200px' },
81
+ );
82
+
83
+ this._intersectionObserver.observe(wrapper);
84
+ }
85
+
86
+ private async _fetchSvg() {
87
+ if (!this.src) return;
88
+
89
+ this._fetchId += 1;
90
+ const currentId = this._fetchId;
91
+
92
+ try {
93
+ const raw = await fetchSVG(this.src);
94
+ if (currentId !== this._fetchId) return;
95
+
96
+ this._svgContent = raw ? sanitizeSvg(raw) : '';
97
+ } catch {
98
+ if (currentId === this._fetchId) {
99
+ this._svgContent = '';
100
+ }
101
+ }
102
+ }
103
+
104
+ private _handleClick() {
105
+ if (this.preview) {
106
+ this._previewOpen = true;
107
+ // Move focus into the dialog after render
108
+ this.updateComplete.then(() => {
109
+ const closeBtn = this.shadowRoot?.querySelector<HTMLElement>('.preview-close');
110
+ closeBtn?.focus();
111
+ });
112
+ }
113
+ }
114
+
115
+ private _closePreview(e: Event) {
116
+ e.stopPropagation();
117
+ const wasOpen = this._previewOpen;
118
+ this._previewOpen = false;
119
+ if (wasOpen) {
120
+ // Return focus to the trigger
121
+ const trigger = this.shadowRoot?.querySelector<HTMLElement>('.svg-content');
122
+ trigger?.focus();
123
+ }
124
+ }
125
+
126
+ render() {
127
+ return html`
128
+ <div class="svg-wrapper">
129
+ ${this._loaded && this._svgContent
130
+ ? html`<div
131
+ class="svg-content ${this.preview ? 'clickable' : ''}"
132
+ role=${this.imageTitle ? 'img' : 'presentation'}
133
+ aria-label=${this.imageTitle || ''}
134
+ @click=${this._handleClick}
135
+ >
136
+ ${unsafeSVG(this._svgContent)}
137
+ </div>`
138
+ : html`<span class="placeholder" aria-hidden="true"></span>`}
139
+ </div>
140
+
141
+ <div
142
+ class="preview-overlay ${this._previewOpen ? 'open' : ''}"
143
+ role="dialog"
144
+ aria-modal="true"
145
+ aria-label=${this.imageTitle ? `Preview: ${this.imageTitle}` : 'SVG preview'}
146
+ @click=${this._closePreview}
147
+ @keydown=${(e: KeyboardEvent) => e.key === 'Escape' && this._closePreview(e)}
148
+ >
149
+ <button
150
+ class="preview-close"
151
+ aria-label="Close preview"
152
+ @click=${this._closePreview}
153
+ >&#x2715;</button>
154
+ <div class="preview-content" @click=${(e: Event) => e.stopPropagation()}>
155
+ ${unsafeSVG(this._svgContent)}
156
+ </div>
157
+ </div>
158
+ `;
159
+ }
160
+ }
@@ -33,10 +33,10 @@ import colorStyles from './toolbar-colors.scss';
33
33
  * ```html
34
34
  * <!-- Docked toolbar -->
35
35
  * <wc-toolbar>
36
- * <wc-icon-button variant="text"><wc-icon name="home"></wc-icon></wc-icon-button>
36
+ * <wc-icon-button variant="text" color="surface"><wc-icon name="home"></wc-icon></wc-icon-button>
37
37
  * <wc-icon-button variant="tonal"><wc-icon name="search"></wc-icon></wc-icon-button>
38
- * <wc-icon-button variant="text"><wc-icon name="favorite"></wc-icon></wc-icon-button>
39
- * <wc-icon-button variant="text"><wc-icon name="account_circle"></wc-icon></wc-icon-button>
38
+ * <wc-icon-button variant="text" color="surface"><wc-icon name="favorite"></wc-icon></wc-icon-button>
39
+ * <wc-icon-button variant="text" color="surface"><wc-icon name="account_circle"></wc-icon></wc-icon-button>
40
40
  * </wc-toolbar>
41
41
  * ```
42
42
  *