@sondor-technology/sondor-components 1.0.0 → 1.0.1-develop.11

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 (168) hide show
  1. package/README.md +8 -0
  2. package/dist/components/alert/alert.d.ts +13 -0
  3. package/dist/components/alert/alert.d.ts.map +1 -0
  4. package/dist/components/alert/alert.js +105 -0
  5. package/dist/components/badge/badge.d.ts +13 -0
  6. package/dist/components/badge/badge.d.ts.map +1 -0
  7. package/dist/components/badge/badge.js +101 -0
  8. package/dist/components/breadcrumb/breadcrumb.d.ts +19 -0
  9. package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -0
  10. package/dist/components/breadcrumb/breadcrumb.js +99 -0
  11. package/dist/components/button/button.d.ts +23 -0
  12. package/dist/components/button/button.d.ts.map +1 -0
  13. package/dist/components/button/button.js +304 -0
  14. package/dist/components/button-group/button-group.d.ts +6 -0
  15. package/dist/components/button-group/button-group.d.ts.map +1 -0
  16. package/dist/components/button-group/button-group.js +74 -0
  17. package/dist/components/card/card.d.ts +11 -0
  18. package/dist/components/card/card.d.ts.map +1 -0
  19. package/dist/components/card/card.js +54 -0
  20. package/dist/components/checkbox/checkbox.d.ts +31 -0
  21. package/dist/components/checkbox/checkbox.d.ts.map +1 -0
  22. package/dist/components/checkbox/checkbox.js +265 -0
  23. package/dist/components/code-block/code-block.d.ts +20 -0
  24. package/dist/components/code-block/code-block.d.ts.map +1 -0
  25. package/dist/components/code-block/code-block.js +260 -0
  26. package/dist/components/content-card/content-card.d.ts +13 -0
  27. package/dist/components/content-card/content-card.d.ts.map +1 -0
  28. package/dist/components/content-card/content-card.js +140 -0
  29. package/dist/components/divider/divider.d.ts +16 -0
  30. package/dist/components/divider/divider.d.ts.map +1 -0
  31. package/dist/components/divider/divider.js +82 -0
  32. package/dist/components/drawer/drawer.d.ts +22 -0
  33. package/dist/components/drawer/drawer.d.ts.map +1 -0
  34. package/dist/components/drawer/drawer.js +226 -0
  35. package/dist/components/field/field.d.ts +11 -0
  36. package/dist/components/field/field.d.ts.map +1 -0
  37. package/dist/components/field/field.js +32 -0
  38. package/dist/components/footer/footer.d.ts +6 -0
  39. package/dist/components/footer/footer.d.ts.map +1 -0
  40. package/dist/components/footer/footer.js +65 -0
  41. package/dist/components/form/form-step.d.ts +14 -0
  42. package/dist/components/form/form-step.d.ts.map +1 -0
  43. package/dist/components/form/form-step.js +44 -0
  44. package/dist/components/form/form.d.ts +30 -0
  45. package/dist/components/form/form.d.ts.map +1 -0
  46. package/dist/components/form/form.js +456 -0
  47. package/dist/components/grid/grid-row.d.ts +17 -0
  48. package/dist/components/grid/grid-row.d.ts.map +1 -0
  49. package/dist/components/grid/grid-row.js +92 -0
  50. package/dist/components/grid/grid.d.ts +13 -0
  51. package/dist/components/grid/grid.d.ts.map +1 -0
  52. package/dist/components/grid/grid.js +42 -0
  53. package/dist/components/icon/icon-paths.d.ts +132 -0
  54. package/dist/components/icon/icon-paths.d.ts.map +1 -0
  55. package/dist/components/icon/icon-paths.js +137 -0
  56. package/dist/components/icon/icon.d.ts +17 -0
  57. package/dist/components/icon/icon.d.ts.map +1 -0
  58. package/dist/components/icon/icon.js +95 -0
  59. package/dist/components/input/input.d.ts +31 -0
  60. package/dist/components/input/input.d.ts.map +1 -0
  61. package/dist/components/input/input.js +268 -0
  62. package/dist/components/link/link.d.ts +16 -0
  63. package/dist/components/link/link.d.ts.map +1 -0
  64. package/dist/components/link/link.js +116 -0
  65. package/dist/components/metadata/metadata.d.ts +18 -0
  66. package/dist/components/metadata/metadata.d.ts.map +1 -0
  67. package/dist/components/metadata/metadata.js +71 -0
  68. package/dist/components/modal/modal.d.ts +35 -0
  69. package/dist/components/modal/modal.d.ts.map +1 -0
  70. package/dist/components/modal/modal.js +251 -0
  71. package/dist/components/page-layout/page-layout.d.ts +46 -0
  72. package/dist/components/page-layout/page-layout.d.ts.map +1 -0
  73. package/dist/components/page-layout/page-layout.js +697 -0
  74. package/dist/components/radio/radio.d.ts +16 -0
  75. package/dist/components/radio/radio.d.ts.map +1 -0
  76. package/dist/components/radio/radio.js +152 -0
  77. package/dist/components/radio-group/radio-group.d.ts +27 -0
  78. package/dist/components/radio-group/radio-group.d.ts.map +1 -0
  79. package/dist/components/radio-group/radio-group.js +161 -0
  80. package/dist/components/router/router.d.ts +31 -0
  81. package/dist/components/router/router.d.ts.map +1 -0
  82. package/dist/components/router/router.js +97 -0
  83. package/dist/components/select/select.d.ts +16 -0
  84. package/dist/components/select/select.d.ts.map +1 -0
  85. package/dist/components/select/select.js +172 -0
  86. package/dist/components/skeleton/skeleton.d.ts +16 -0
  87. package/dist/components/skeleton/skeleton.d.ts.map +1 -0
  88. package/dist/components/skeleton/skeleton.js +149 -0
  89. package/dist/components/switch/switch.d.ts +25 -0
  90. package/dist/components/switch/switch.d.ts.map +1 -0
  91. package/dist/components/switch/switch.js +185 -0
  92. package/dist/components/table/data-table.d.ts +72 -0
  93. package/dist/components/table/data-table.d.ts.map +1 -0
  94. package/dist/components/table/data-table.js +551 -0
  95. package/dist/components/table/table.d.ts +22 -0
  96. package/dist/components/table/table.d.ts.map +1 -0
  97. package/dist/components/table/table.js +167 -0
  98. package/dist/components/tabs/tab-panel.d.ts +8 -0
  99. package/dist/components/tabs/tab-panel.d.ts.map +1 -0
  100. package/dist/components/tabs/tab-panel.js +46 -0
  101. package/dist/components/tabs/tab.d.ts +9 -0
  102. package/dist/components/tabs/tab.d.ts.map +1 -0
  103. package/dist/components/tabs/tab.js +91 -0
  104. package/dist/components/tabs/tabs.d.ts +14 -0
  105. package/dist/components/tabs/tabs.d.ts.map +1 -0
  106. package/dist/components/tabs/tabs.js +85 -0
  107. package/dist/components/textarea/textarea.d.ts +36 -0
  108. package/dist/components/textarea/textarea.d.ts.map +1 -0
  109. package/dist/components/textarea/textarea.js +231 -0
  110. package/dist/components/theme-toggle/theme-toggle.d.ts +15 -0
  111. package/dist/components/theme-toggle/theme-toggle.d.ts.map +1 -0
  112. package/dist/components/theme-toggle/theme-toggle.js +130 -0
  113. package/dist/components/vertical-nav/vertical-nav-group.d.ts +15 -0
  114. package/dist/components/vertical-nav/vertical-nav-group.d.ts.map +1 -0
  115. package/dist/components/vertical-nav/vertical-nav-group.js +127 -0
  116. package/dist/components/vertical-nav/vertical-nav-item.d.ts +14 -0
  117. package/dist/components/vertical-nav/vertical-nav-item.d.ts.map +1 -0
  118. package/dist/components/vertical-nav/vertical-nav-item.js +85 -0
  119. package/dist/styles/index.css +171 -0
  120. package/dist/styles/reset.d.ts +2 -0
  121. package/dist/styles/reset.d.ts.map +1 -0
  122. package/dist/styles/reset.js +50 -0
  123. package/package.json +7 -2
  124. package/src/components/alert/alert.ts +100 -100
  125. package/src/components/badge/badge.ts +96 -96
  126. package/src/components/breadcrumb/breadcrumb.ts +98 -98
  127. package/src/components/button/button.ts +281 -281
  128. package/src/components/button-group/button-group.ts +67 -67
  129. package/src/components/card/card.ts +52 -52
  130. package/src/components/checkbox/checkbox.ts +266 -238
  131. package/src/components/code-block/code-block.ts +256 -256
  132. package/src/components/content-card/content-card.ts +133 -133
  133. package/src/components/divider/divider.ts +68 -68
  134. package/src/components/drawer/drawer.ts +217 -217
  135. package/src/components/field/field.ts +30 -30
  136. package/src/components/footer/footer.ts +58 -58
  137. package/src/components/form/form-step.ts +36 -32
  138. package/src/components/form/form.ts +492 -376
  139. package/src/components/grid/grid-row.ts +75 -75
  140. package/src/components/grid/grid.ts +36 -36
  141. package/src/components/icon/icon-paths.ts +140 -124
  142. package/src/components/icon/icon.ts +84 -82
  143. package/src/components/input/input.ts +248 -248
  144. package/src/components/link/link.ts +97 -97
  145. package/src/components/metadata/metadata.ts +66 -66
  146. package/src/components/modal/modal.ts +246 -158
  147. package/src/components/page-layout/page-layout.ts +704 -704
  148. package/src/components/radio/radio.ts +142 -142
  149. package/src/components/radio-group/radio-group.ts +157 -157
  150. package/src/components/router/router.ts +133 -46
  151. package/src/components/select/select.ts +161 -161
  152. package/src/components/skeleton/skeleton.ts +134 -67
  153. package/src/components/switch/switch.ts +181 -181
  154. package/src/components/table/data-table.ts +556 -556
  155. package/src/components/table/table.ts +153 -153
  156. package/src/components/tabs/tab-panel.ts +30 -30
  157. package/src/components/tabs/tab.ts +76 -76
  158. package/src/components/tabs/tabs.ts +88 -88
  159. package/src/components/textarea/textarea.ts +215 -215
  160. package/src/components/theme-toggle/theme-toggle.ts +131 -131
  161. package/src/components/vertical-nav/vertical-nav-group.ts +115 -96
  162. package/src/components/vertical-nav/vertical-nav-item.ts +72 -49
  163. package/src/styles/globals.css +58 -58
  164. package/src/styles/index.css +80 -80
  165. package/src/styles/reset.ts +50 -50
  166. package/src/styles/theme.css +58 -58
  167. package/src/styles/typography.css +25 -25
  168. package/tsconfig.json +15 -15
@@ -0,0 +1,265 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, html, css } from "lit";
8
+ import { customElement, property, query } from "lit/decorators.js";
9
+ import { resetStyles } from "../../styles/reset.js";
10
+ let StCheckbox = class StCheckbox extends LitElement {
11
+ constructor() {
12
+ super();
13
+ this.size = "md";
14
+ this.name = "";
15
+ this.value = "on";
16
+ this.checked = false;
17
+ this.indeterminate = false;
18
+ this.disabled = false;
19
+ this.invalid = false;
20
+ this.required = false;
21
+ this.errorMessage = "";
22
+ this.ariaLabel = "";
23
+ this._internals = this.attachInternals();
24
+ this.addEventListener('focusout', () => {
25
+ this.invalid = !this.checkValidity();
26
+ });
27
+ this.addEventListener('invalid', () => {
28
+ this.invalid = !this.checkValidity();
29
+ });
30
+ }
31
+ updated(changedProperties) {
32
+ super.updated(changedProperties);
33
+ if (changedProperties.has("checked") || changedProperties.has("value") || changedProperties.has("errorMessage")) {
34
+ this._internals.setFormValue(this.checked ? this.value : null);
35
+ this._syncValidity();
36
+ }
37
+ if (changedProperties.has("required")) {
38
+ this._syncValidity();
39
+ }
40
+ }
41
+ _syncValidity() {
42
+ if (!this._inputEl)
43
+ return;
44
+ if (this.required && !this.checked) {
45
+ const message = this.errorMessage || this._inputEl.validationMessage || "Please check this box if you want to proceed.";
46
+ this._internals.setValidity({ valueMissing: true }, message, this._inputEl);
47
+ }
48
+ else {
49
+ this._internals.setValidity(this._inputEl.validity, this._inputEl.validationMessage, this._inputEl);
50
+ }
51
+ }
52
+ checkValidity() {
53
+ if (!this._inputEl)
54
+ return true;
55
+ if (this.required && !this.checked) {
56
+ const message = this.errorMessage || this._inputEl.validationMessage || "Please check this box if you want to proceed.";
57
+ this._internals.setValidity({ valueMissing: true }, message, this._inputEl);
58
+ this.invalid = true;
59
+ return false;
60
+ }
61
+ const isValid = this._inputEl.checkValidity();
62
+ this._syncValidity();
63
+ this.invalid = !isValid;
64
+ return isValid;
65
+ }
66
+ reportValidity() {
67
+ this._syncValidity();
68
+ const isValid = this._internals.reportValidity();
69
+ this.invalid = !isValid;
70
+ return isValid;
71
+ }
72
+ formResetCallback() {
73
+ this.checked = false;
74
+ this.indeterminate = false;
75
+ this.invalid = false;
76
+ this._internals.setFormValue(null);
77
+ this.updateComplete.then(() => this._syncValidity());
78
+ }
79
+ _handleChange(e) {
80
+ e.stopPropagation();
81
+ if (this.disabled)
82
+ return;
83
+ if (this.indeterminate) {
84
+ this.indeterminate = false;
85
+ }
86
+ this.checked = this._inputEl.checked;
87
+ if (this.checkValidity()) {
88
+ this.invalid = false;
89
+ }
90
+ this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
91
+ }
92
+ render() {
93
+ return html `
94
+ <label>
95
+ <input
96
+ type="checkbox"
97
+ aria-label=${this.ariaLabel || ""}
98
+ .name=${this.name}
99
+ .value=${this.value}
100
+ .checked=${this.checked}
101
+ .indeterminate=${this.indeterminate}
102
+ ?disabled=${this.disabled}
103
+ ?required=${this.required}
104
+ @change=${this._handleChange}
105
+ />
106
+ <div class="control">
107
+ ${this.indeterminate
108
+ ? html `<svg class="icon-minus" viewBox="0 0 24 24"><path d="M5 12h14"></path></svg>`
109
+ : html `<svg class="icon-check" viewBox="0 0 24 24">
110
+ <path d="M20 6L9 17l-5-5"></path>
111
+ </svg>`}
112
+ </div>
113
+ <span class="label"><slot></slot></span>
114
+ </label>
115
+ `;
116
+ }
117
+ };
118
+ StCheckbox.formAssociated = true;
119
+ StCheckbox.styles = [
120
+ resetStyles,
121
+ css `
122
+ :host {
123
+ display: inline-block;
124
+ outline: none;
125
+ user-select: none;
126
+ --checkbox-size: 1.25rem;
127
+ --checkbox-icon-size: 0.875rem;
128
+ }
129
+
130
+ :host([size="sm"]) {
131
+ --checkbox-size: 1rem;
132
+ --checkbox-icon-size: 0.75rem;
133
+ }
134
+ :host([size="lg"]) {
135
+ --checkbox-size: 1.5rem;
136
+ --checkbox-icon-size: 1rem;
137
+ }
138
+
139
+ label {
140
+ display: inline-flex;
141
+ align-items: flex-start;
142
+ gap: var(--st-spacing-sm);
143
+ cursor: pointer;
144
+ color: var(--st-color-text);
145
+ font-size: var(--st-font-size-base);
146
+ }
147
+
148
+ input {
149
+ position: absolute;
150
+ width: var(--checkbox-size);
151
+ height: var(--checkbox-size);
152
+ padding: 0;
153
+ margin: -1px;
154
+ overflow: hidden;
155
+ clip: rect(0, 0, 0, 0);
156
+ white-space: nowrap;
157
+ border-width: 0;
158
+ }
159
+
160
+ .control {
161
+ display: flex;
162
+ align-items: center;
163
+ justify-content: center;
164
+ width: var(--checkbox-size);
165
+ height: var(--checkbox-size);
166
+ border: 1px solid var(--st-color-border);
167
+ border-radius: 4px;
168
+ background-color: var(--st-color-bg);
169
+ transition: all 0.2s ease;
170
+ flex-shrink: 0;
171
+ margin-top: 0.125rem;
172
+ }
173
+
174
+ label:hover .control {
175
+ border-color: var(--st-color-primary-hover);
176
+ }
177
+
178
+ input:focus-visible + .control {
179
+ box-shadow:
180
+ 0 0 0 2px var(--st-color-bg),
181
+ 0 0 0 4px var(--st-color-primary);
182
+ }
183
+
184
+ :host([checked]) .control,
185
+ :host([indeterminate]) .control {
186
+ border-color: var(--st-color-primary);
187
+ background-color: var(--st-color-primary);
188
+ }
189
+
190
+ svg {
191
+ width: var(--checkbox-icon-size);
192
+ height: var(--checkbox-icon-size);
193
+ stroke: var(--st-white);
194
+ stroke-width: 3;
195
+ stroke-linecap: round;
196
+ stroke-linejoin: round;
197
+ fill: none;
198
+ opacity: 0;
199
+ transform: scale(0.5);
200
+ transition:
201
+ transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
202
+ opacity 0.2s ease;
203
+ }
204
+
205
+ :host([checked]) svg.icon-check,
206
+ :host([indeterminate]) svg.icon-minus {
207
+ opacity: 1;
208
+ transform: scale(1);
209
+ }
210
+
211
+ :host([disabled]) {
212
+ pointer-events: none;
213
+ }
214
+ :host([disabled]) label {
215
+ opacity: 0.5;
216
+ cursor: not-allowed;
217
+ }
218
+
219
+ :host([invalid]) .control {
220
+ border-color: var(--st-color-error);
221
+ }
222
+ :host([invalid]) input:focus-visible + .control {
223
+ box-shadow:
224
+ 0 0 0 2px var(--st-color-bg),
225
+ 0 0 0 4px var(--st-color-error);
226
+ }
227
+ `,
228
+ ];
229
+ __decorate([
230
+ query("input")
231
+ ], StCheckbox.prototype, "_inputEl", void 0);
232
+ __decorate([
233
+ property({ type: String, reflect: true })
234
+ ], StCheckbox.prototype, "size", void 0);
235
+ __decorate([
236
+ property({ type: String, reflect: true })
237
+ ], StCheckbox.prototype, "name", void 0);
238
+ __decorate([
239
+ property({ type: String })
240
+ ], StCheckbox.prototype, "value", void 0);
241
+ __decorate([
242
+ property({ type: Boolean, reflect: true })
243
+ ], StCheckbox.prototype, "checked", void 0);
244
+ __decorate([
245
+ property({ type: Boolean, reflect: true })
246
+ ], StCheckbox.prototype, "indeterminate", void 0);
247
+ __decorate([
248
+ property({ type: Boolean, reflect: true })
249
+ ], StCheckbox.prototype, "disabled", void 0);
250
+ __decorate([
251
+ property({ type: Boolean, reflect: true })
252
+ ], StCheckbox.prototype, "invalid", void 0);
253
+ __decorate([
254
+ property({ type: Boolean, reflect: true })
255
+ ], StCheckbox.prototype, "required", void 0);
256
+ __decorate([
257
+ property({ type: String })
258
+ ], StCheckbox.prototype, "errorMessage", void 0);
259
+ __decorate([
260
+ property({ attribute: "aria-label" })
261
+ ], StCheckbox.prototype, "ariaLabel", void 0);
262
+ StCheckbox = __decorate([
263
+ customElement("st-checkbox")
264
+ ], StCheckbox);
265
+ export { StCheckbox };
@@ -0,0 +1,20 @@
1
+ import { LitElement } from 'lit';
2
+ import 'prismjs/components/prism-typescript.js';
3
+ import 'prismjs/components/prism-javascript.js';
4
+ import 'prismjs/components/prism-css.js';
5
+ import 'prismjs/components/prism-json.js';
6
+ import 'prismjs/components/prism-bash.js';
7
+ import 'prismjs/components/prism-csharp.js';
8
+ export declare class StCodeBlock extends LitElement {
9
+ language: string;
10
+ private _snippets;
11
+ private _activeIndex;
12
+ private _copied;
13
+ private _slot;
14
+ static styles: import("lit").CSSResult[];
15
+ private _handleSlotChange;
16
+ private _dedent;
17
+ private _copyToClipboard;
18
+ render(): import("lit-html").TemplateResult<1>;
19
+ }
20
+ //# sourceMappingURL=code-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../src/components/code-block/code-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAM5C,OAAO,wCAAwC,CAAC;AAChD,OAAO,wCAAwC,CAAC;AAChD,OAAO,iCAAiC,CAAC;AACzC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,oCAAoC,CAAC;AAS5C,qBACa,WAAY,SAAQ,UAAU;IAEb,QAAQ,SAAgB;IAE3C,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,OAAO,CAAS;IAEN,OAAO,CAAC,KAAK,CAAmB;IAE3D,MAAM,CAAC,MAAM,4BAyHX;IAEF,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,OAAO;YAaD,gBAAgB;IAc9B,MAAM,yCAwCL;CACF"}
@@ -0,0 +1,260 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, html, css } from 'lit';
8
+ import { customElement, property, state, query } from 'lit/decorators.js';
9
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
10
+ import { resetStyles } from '../../styles/reset.js';
11
+ import Prism from 'prismjs';
12
+ import 'prismjs/components/prism-typescript.js';
13
+ import 'prismjs/components/prism-javascript.js';
14
+ import 'prismjs/components/prism-css.js';
15
+ import 'prismjs/components/prism-json.js';
16
+ import 'prismjs/components/prism-bash.js';
17
+ import 'prismjs/components/prism-csharp.js';
18
+ let StCodeBlock = class StCodeBlock extends LitElement {
19
+ constructor() {
20
+ super(...arguments);
21
+ // Fallback language if a template doesn't provide one
22
+ this.language = 'typescript';
23
+ this._snippets = [];
24
+ this._activeIndex = 0;
25
+ this._copied = false;
26
+ }
27
+ _handleSlotChange() {
28
+ const nodes = this._slot.assignedNodes({ flatten: true });
29
+ // Find ALL template tags passed into the slot
30
+ const templates = nodes.filter(n => n instanceof HTMLTemplateElement);
31
+ if (templates.length > 0) {
32
+ // Map over every template and parse its code and attributes
33
+ this._snippets = templates.map(template => {
34
+ const lang = template.getAttribute('data-lang') || this.language;
35
+ const label = template.getAttribute('data-label') || lang; // Fallback to lang if no label provided
36
+ const rawCode = this._dedent(template.innerHTML);
37
+ const grammar = Prism.languages[lang] || Prism.languages.javascript;
38
+ const highlightedCode = Prism.highlight(rawCode, grammar, lang);
39
+ return { lang, label, rawCode, highlightedCode };
40
+ });
41
+ }
42
+ else {
43
+ // Fallback: If no template is used, process raw text just like before
44
+ const rawText = nodes.map(n => n.textContent).join('');
45
+ const rawCode = this._dedent(rawText);
46
+ if (rawCode) {
47
+ const grammar = Prism.languages[this.language] || Prism.languages.javascript;
48
+ const highlightedCode = Prism.highlight(rawCode, grammar, this.language);
49
+ this._snippets = [{ lang: this.language, label: this.language, rawCode, highlightedCode }];
50
+ }
51
+ }
52
+ // Reset to the first tab whenever new code is injected
53
+ this._activeIndex = 0;
54
+ }
55
+ _dedent(text) {
56
+ const lines = text.split('\n');
57
+ const minIndent = lines
58
+ .filter(line => line.trim().length > 0)
59
+ .reduce((min, line) => {
60
+ const indent = line.match(/^\s*/)?.[0].length || 0;
61
+ return Math.min(min, indent);
62
+ }, Infinity);
63
+ if (minIndent === Infinity || minIndent === 0)
64
+ return text.trim();
65
+ return lines.map(line => line.slice(minIndent)).join('\n').trim();
66
+ }
67
+ async _copyToClipboard() {
68
+ // Copy the code from the currently active tab
69
+ const activeSnippet = this._snippets[this._activeIndex];
70
+ if (!activeSnippet)
71
+ return;
72
+ try {
73
+ await navigator.clipboard.writeText(activeSnippet.rawCode);
74
+ this._copied = true;
75
+ setTimeout(() => { this._copied = false; }, 2000);
76
+ }
77
+ catch (err) {
78
+ console.error('Failed to copy text: ', err);
79
+ }
80
+ }
81
+ render() {
82
+ const activeSnippet = this._snippets[this._activeIndex];
83
+ return html `
84
+ <div class="header">
85
+ ${this._snippets.length > 1
86
+ ? html `
87
+ <div class="tabs">
88
+ ${this._snippets.map((snippet, index) => html `
89
+ <button
90
+ class="tab ${index === this._activeIndex ? 'active' : ''}"
91
+ @click=${() => this._activeIndex = index}
92
+ >
93
+ ${snippet.label}
94
+ </button>
95
+ `)}
96
+ </div>
97
+ `
98
+ : html `
99
+ <span class="language-label">${activeSnippet?.label || this.language}</span>
100
+ `}
101
+
102
+ <button class="copy-button ${this._copied ? 'copied' : ''}" @click=${this._copyToClipboard}>
103
+ ${this._copied
104
+ ? html `<svg viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"></polyline></svg> Copied!`
105
+ : html `<svg viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg> Copy`}
106
+ </button>
107
+ </div>
108
+
109
+ <!-- Render the currently active snippet -->
110
+ ${activeSnippet ? html `
111
+ <pre><code class="language-${activeSnippet.lang}">${unsafeHTML(activeSnippet.highlightedCode)}</code></pre>
112
+ ` : ''}
113
+
114
+ <div class="raw-content">
115
+ <slot name="raw" @slotchange=${this._handleSlotChange}></slot>
116
+ </div>
117
+ `;
118
+ }
119
+ };
120
+ StCodeBlock.styles = [
121
+ resetStyles,
122
+ css `
123
+ :host {
124
+ display: block;
125
+ margin: var(--st-spacing-md) 0;
126
+ border-radius: 8px;
127
+ background-color: var(--st-color-surface);
128
+ border: 1px solid var(--st-color-border);
129
+ overflow: hidden;
130
+ }
131
+
132
+ .header {
133
+ display: flex;
134
+ justify-content: space-between;
135
+ align-items: center;
136
+ background-color: rgba(0, 0, 0, 0.2);
137
+ border-bottom: 1px solid var(--st-color-border);
138
+ padding: 0 var(--st-spacing-md);
139
+ min-height: 2.5rem; /* 40px */
140
+ }
141
+
142
+ /* Single language label */
143
+ .language-label {
144
+ font-size: var(--st-font-size-xs);
145
+ color: var(--st-color-text-muted);
146
+ text-transform: uppercase;
147
+ letter-spacing: 0.05em;
148
+ font-weight: var(--st-font-weight-bold);
149
+ }
150
+
151
+ /* Multi-language Tabs */
152
+ .tabs {
153
+ display: flex;
154
+ gap: var(--st-spacing-md);
155
+ height: 100%;
156
+ }
157
+
158
+ .tab {
159
+ background: transparent;
160
+ border: none;
161
+ border-bottom: 2px solid transparent;
162
+ color: var(--st-color-text-muted);
163
+ font-size: var(--st-font-size-xs);
164
+ font-weight: var(--st-font-weight-medium);
165
+ padding: var(--st-spacing-xs) 0;
166
+ cursor: pointer;
167
+ transition: all 0.2s ease;
168
+ }
169
+
170
+ .tab:hover {
171
+ color: var(--st-color-text);
172
+ }
173
+
174
+ .tab.active {
175
+ color: var(--st-color-primary);
176
+ border-bottom-color: var(--st-color-primary);
177
+ }
178
+
179
+ /* Copy Button */
180
+ .copy-button {
181
+ background: transparent;
182
+ border: 1px solid transparent;
183
+ color: var(--st-color-text-muted);
184
+ cursor: pointer;
185
+ display: flex;
186
+ align-items: center;
187
+ gap: var(--st-spacing-xs);
188
+ padding: 4px 8px;
189
+ border-radius: 4px;
190
+ font-size: var(--st-font-size-xs);
191
+ transition: all 0.2s ease;
192
+ margin-left: auto; /* Pushes it to the right */
193
+ }
194
+
195
+ .copy-button:hover {
196
+ color: var(--st-color-text);
197
+ background-color: rgba(255, 255, 255, 0.05);
198
+ }
199
+
200
+ .copy-button svg {
201
+ width: 14px;
202
+ height: 14px;
203
+ fill: none;
204
+ stroke: currentColor;
205
+ stroke-width: 2;
206
+ stroke-linecap: round;
207
+ stroke-linejoin: round;
208
+ }
209
+
210
+ .copy-button.copied {
211
+ color: var(--st-color-success);
212
+ }
213
+
214
+ pre {
215
+ margin: 0;
216
+ padding: var(--st-spacing-md);
217
+ overflow-x: auto;
218
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
219
+ font-size: 0.875rem;
220
+ line-height: 1.5;
221
+ color: var(--st-color-text);
222
+ }
223
+
224
+ .raw-content {
225
+ display: none;
226
+ }
227
+
228
+ /* ==========================================================
229
+ Prism.js Theme Mapping (Space Grey / Purple Aesthetic)
230
+ ========================================================== */
231
+ .token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--st-color-text-muted); font-style: italic; }
232
+ .token.punctuation { color: #8b949e; }
233
+ .token.namespace { opacity: .7; }
234
+ .token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #79c0ff; }
235
+ .token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #a5d6ff; }
236
+ .token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: var(--st-color-text); }
237
+ .token.atrule, .token.attr-value, .token.keyword { color: var(--st-color-primary); }
238
+ .token.function, .token.class-name { color: #d2a8ff; }
239
+ .token.regex, .token.important, .token.variable { color: #ffa657; }
240
+ `
241
+ ];
242
+ __decorate([
243
+ property({ type: String })
244
+ ], StCodeBlock.prototype, "language", void 0);
245
+ __decorate([
246
+ state()
247
+ ], StCodeBlock.prototype, "_snippets", void 0);
248
+ __decorate([
249
+ state()
250
+ ], StCodeBlock.prototype, "_activeIndex", void 0);
251
+ __decorate([
252
+ state()
253
+ ], StCodeBlock.prototype, "_copied", void 0);
254
+ __decorate([
255
+ query('slot[name="raw"]')
256
+ ], StCodeBlock.prototype, "_slot", void 0);
257
+ StCodeBlock = __decorate([
258
+ customElement('st-code-block')
259
+ ], StCodeBlock);
260
+ export { StCodeBlock };
@@ -0,0 +1,13 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class StContentCard extends LitElement {
3
+ href?: string;
4
+ target: '_blank' | '_self';
5
+ static styles: import("lit").CSSResult[];
6
+ render(): import("lit-html").TemplateResult<1>;
7
+ }
8
+ declare global {
9
+ interface HTMLElementTagNameMap {
10
+ 'st-content-card': StContentCard;
11
+ }
12
+ }
13
+ //# sourceMappingURL=content-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-card.d.ts","sourceRoot":"","sources":["../../../src/components/content-card/content-card.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,qBACa,aAAc,SAAQ,UAAU;IAEf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAW;IAEjE,MAAM,CAAC,MAAM,4BA8FX;IAEF,MAAM,yCAoBL;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}