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

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 +28 -0
  21. package/dist/components/checkbox/checkbox.d.ts.map +1 -0
  22. package/dist/components/checkbox/checkbox.js +247 -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 +13 -0
  42. package/dist/components/form/form-step.d.ts.map +1 -0
  43. package/dist/components/form/form-step.js +41 -0
  44. package/dist/components/form/form.d.ts +25 -0
  45. package/dist/components/form/form.d.ts.map +1 -0
  46. package/dist/components/form/form.js +358 -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 +16 -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 +24 -0
  69. package/dist/components/modal/modal.d.ts.map +1 -0
  70. package/dist/components/modal/modal.js +163 -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 +7 -0
  81. package/dist/components/router/router.d.ts.map +1 -0
  82. package/dist/components/router/router.js +37 -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 +17 -0
  87. package/dist/components/skeleton/skeleton.d.ts.map +1 -0
  88. package/dist/components/skeleton/skeleton.js +78 -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 +10 -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 +9 -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 +238 -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 +32 -32
  138. package/src/components/form/form.ts +376 -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 +82 -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 +158 -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 +46 -46
  151. package/src/components/select/select.ts +161 -161
  152. package/src/components/skeleton/skeleton.ts +67 -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 +109 -96
  162. package/src/components/vertical-nav/vertical-nav-item.ts +66 -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,247 @@
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
+ // Checkboxes default to 'on' natively if no value is provided
16
+ this.value = "on";
17
+ this.checked = false;
18
+ this.indeterminate = false;
19
+ this.disabled = false;
20
+ this.invalid = false;
21
+ this.required = false;
22
+ this.ariaLabel = "";
23
+ this._internals = this.attachInternals();
24
+ // 1. Trigger error state if the user clicks away and the field is invalid
25
+ this.addEventListener('focusout', () => {
26
+ this.invalid = !this._inputEl.validity.valid;
27
+ });
28
+ // 2. Trigger error state if the st-form tries to submit and fails
29
+ this.addEventListener('invalid', () => {
30
+ this.invalid = true;
31
+ });
32
+ }
33
+ updated(changedProperties) {
34
+ super.updated(changedProperties);
35
+ if (changedProperties.has("checked") || changedProperties.has("value")) {
36
+ // Form API: If checked, submit the value. If unchecked, submit null to remove it from FormData.
37
+ this._internals.setFormValue(this.checked ? this.value : null);
38
+ this._syncValidity();
39
+ }
40
+ if (changedProperties.has("required")) {
41
+ this._syncValidity();
42
+ }
43
+ }
44
+ _syncValidity() {
45
+ if (!this._inputEl)
46
+ return;
47
+ this._internals.setValidity(this._inputEl.validity, this._inputEl.validationMessage, this._inputEl);
48
+ }
49
+ formResetCallback() {
50
+ this.checked = false;
51
+ this.indeterminate = false;
52
+ this._internals.setFormValue(null);
53
+ this.updateComplete.then(() => this._syncValidity());
54
+ }
55
+ _handleChange(e) {
56
+ e.stopPropagation();
57
+ if (this.disabled)
58
+ return;
59
+ // Standard native behavior: clicking an indeterminate checkbox unsets the indeterminate state
60
+ if (this.indeterminate) {
61
+ this.indeterminate = false;
62
+ }
63
+ this.checked = this._inputEl.checked;
64
+ this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
65
+ }
66
+ render() {
67
+ return html `
68
+ <label>
69
+ <input
70
+ type="checkbox"
71
+ aria-label=${this.ariaLabel || ""}
72
+ .name=${this.name}
73
+ .value=${this.value}
74
+ .checked=${this.checked}
75
+ .indeterminate=${this.indeterminate}
76
+ ?disabled=${this.disabled}
77
+ ?required=${this.required}
78
+ @change=${this._handleChange}
79
+ />
80
+ <div class="control">
81
+ <!-- Render both SVGs and use CSS to conditionally reveal them based on host attributes -->
82
+ ${this.indeterminate
83
+ ? html `<svg class="icon-minus" viewBox="0 0 24 24"><path d="M5 12h14"></path></svg>`
84
+ : html `<svg class="icon-check" viewBox="0 0 24 24">
85
+ <path d="M20 6L9 17l-5-5"></path>
86
+ </svg>`}
87
+ </div>
88
+ <span class="label"><slot></slot></span>
89
+ </label>
90
+ `;
91
+ }
92
+ };
93
+ StCheckbox.formAssociated = true;
94
+ StCheckbox.styles = [
95
+ resetStyles,
96
+ css `
97
+ :host {
98
+ display: inline-block;
99
+ outline: none;
100
+ user-select: none;
101
+ --checkbox-size: 1.25rem;
102
+ --checkbox-icon-size: 0.875rem;
103
+ }
104
+
105
+ :host([size="sm"]) {
106
+ --checkbox-size: 1rem;
107
+ --checkbox-icon-size: 0.75rem;
108
+ }
109
+ :host([size="lg"]) {
110
+ --checkbox-size: 1.5rem;
111
+ --checkbox-icon-size: 1rem;
112
+ }
113
+
114
+ label {
115
+ display: inline-flex;
116
+ align-items: flex-start;
117
+ gap: var(--st-spacing-sm);
118
+ cursor: pointer;
119
+ color: var(--st-color-text);
120
+ font-size: var(--st-font-size-base);
121
+ }
122
+
123
+ /* Visually hide the native input but keep it in the DOM for focus/screen readers */
124
+ input {
125
+ position: absolute;
126
+ width: var(--checkbox-size);
127
+ height: var(--checkbox-size);
128
+ padding: 0;
129
+ margin: -1px;
130
+ overflow: hidden;
131
+ clip: rect(0, 0, 0, 0);
132
+ white-space: nowrap;
133
+ border-width: 0;
134
+ }
135
+
136
+ /* Custom Checkbox Box */
137
+ .control {
138
+ display: flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ width: var(--checkbox-size);
142
+ height: var(--checkbox-size);
143
+ border: 1px solid var(--st-color-border);
144
+ border-radius: 4px;
145
+ background-color: var(--st-color-bg);
146
+ transition: all 0.2s ease;
147
+ flex-shrink: 0;
148
+ /* Aligns the box nicely with standard text line-height */
149
+ margin-top: 0.125rem;
150
+ }
151
+
152
+ /* Hover State */
153
+ label:hover .control {
154
+ border-color: var(--st-color-primary-hover);
155
+ }
156
+
157
+ /* Focus State */
158
+ input:focus-visible + .control {
159
+ box-shadow:
160
+ 0 0 0 2px var(--st-color-bg),
161
+ 0 0 0 4px var(--st-color-primary);
162
+ }
163
+
164
+ /* Checked & Indeterminate States */
165
+ :host([checked]) .control,
166
+ :host([indeterminate]) .control {
167
+ border-color: var(--st-color-primary);
168
+ background-color: var(--st-color-primary);
169
+ }
170
+
171
+ /* SVG Icons */
172
+ svg {
173
+ width: var(--checkbox-icon-size);
174
+ height: var(--checkbox-icon-size);
175
+ stroke: var(--st-white);
176
+ stroke-width: 3;
177
+ stroke-linecap: round;
178
+ stroke-linejoin: round;
179
+ fill: none;
180
+ opacity: 0;
181
+ transform: scale(0.5);
182
+ transition:
183
+ transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
184
+ opacity 0.2s ease;
185
+ }
186
+
187
+ /* Reveal Icons */
188
+ :host([checked]) svg.icon-check,
189
+ :host([indeterminate]) svg.icon-minus {
190
+ opacity: 1;
191
+ transform: scale(1);
192
+ }
193
+
194
+ /* Disabled State */
195
+ :host([disabled]) {
196
+ pointer-events: none;
197
+ }
198
+ :host([disabled]) label {
199
+ opacity: 0.5;
200
+ cursor: not-allowed;
201
+ }
202
+
203
+ /* Invalid State */
204
+ :host([invalid]) .control {
205
+ border-color: var(--st-color-error);
206
+ }
207
+ :host([invalid]) input:focus-visible + .control {
208
+ box-shadow:
209
+ 0 0 0 2px var(--st-color-bg),
210
+ 0 0 0 4px var(--st-color-error);
211
+ }
212
+ `,
213
+ ];
214
+ __decorate([
215
+ query("input")
216
+ ], StCheckbox.prototype, "_inputEl", void 0);
217
+ __decorate([
218
+ property({ type: String, reflect: true })
219
+ ], StCheckbox.prototype, "size", void 0);
220
+ __decorate([
221
+ property({ type: String, reflect: true })
222
+ ], StCheckbox.prototype, "name", void 0);
223
+ __decorate([
224
+ property({ type: String })
225
+ ], StCheckbox.prototype, "value", void 0);
226
+ __decorate([
227
+ property({ type: Boolean, reflect: true })
228
+ ], StCheckbox.prototype, "checked", void 0);
229
+ __decorate([
230
+ property({ type: Boolean, reflect: true })
231
+ ], StCheckbox.prototype, "indeterminate", void 0);
232
+ __decorate([
233
+ property({ type: Boolean, reflect: true })
234
+ ], StCheckbox.prototype, "disabled", void 0);
235
+ __decorate([
236
+ property({ type: Boolean, reflect: true })
237
+ ], StCheckbox.prototype, "invalid", void 0);
238
+ __decorate([
239
+ property({ type: Boolean, reflect: true })
240
+ ], StCheckbox.prototype, "required", void 0);
241
+ __decorate([
242
+ property({ attribute: "aria-label" })
243
+ ], StCheckbox.prototype, "ariaLabel", void 0);
244
+ StCheckbox = __decorate([
245
+ customElement("st-checkbox")
246
+ ], StCheckbox);
247
+ 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"}
@@ -0,0 +1,140 @@
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 } from 'lit/decorators.js';
9
+ import { resetStyles } from '../../styles/reset.js';
10
+ let StContentCard = class StContentCard extends LitElement {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.target = '_self';
14
+ }
15
+ render() {
16
+ // 1. Define the inner content once to avoid duplication
17
+ const innerContent = html `
18
+ <div class="media">
19
+ <slot name="media"></slot>
20
+ </div>
21
+ <div class="content">
22
+ <div class="title">
23
+ <slot name="title"></slot>
24
+ </div>
25
+ <div class="body">
26
+ <slot></slot>
27
+ </div>
28
+ </div>
29
+ `;
30
+ // 2. Conditionally wrap it in an anchor or a div
31
+ return this.href
32
+ ? html `<a href="${this.href}" target="${this.target}" class="card">${innerContent}</a>`
33
+ : html `<div class="card">${innerContent}</div>`;
34
+ }
35
+ };
36
+ StContentCard.styles = [
37
+ resetStyles,
38
+ css `
39
+ :host {
40
+ display: block;
41
+ /* Ensures cards stretch to equal heights if placed in a flex/grid container */
42
+ height: 100%;
43
+ }
44
+
45
+ .card {
46
+ display: flex;
47
+ flex-direction: column;
48
+ height: 100%;
49
+ background-color: var(--st-color-surface);
50
+ border: 1px solid var(--st-color-border);
51
+ border-radius: var(--st-radius-md, 0.5rem);
52
+ overflow: hidden;
53
+ text-decoration: none;
54
+ color: inherit;
55
+
56
+ /* Smooth transitions for the hover effects */
57
+ transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
58
+ }
59
+
60
+ /* ==========================================================
61
+ Hover Effects (Only applied if it is a link)
62
+ ========================================================== */
63
+ a.card {
64
+ cursor: pointer;
65
+ }
66
+
67
+ a.card:hover,
68
+ a.card:focus-visible {
69
+ outline: none;
70
+ border-color: var(--st-color-primary);
71
+ transform: translateY(-2px);
72
+ /* Subtle shadow to lift the card off the background */
73
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
74
+ }
75
+
76
+ /* Dark mode specific shadow adjustment */
77
+ :host-context([data-theme="dark"]) a.card:hover {
78
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
79
+ }
80
+
81
+ /* ==========================================================
82
+ Internal Layout
83
+ ========================================================== */
84
+ .media {
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: center;
88
+ aspect-ratio: 16 / 9;
89
+ background-color: var(--st-color-bg);
90
+ border-bottom: 1px solid var(--st-color-border);
91
+ overflow: hidden;
92
+ }
93
+
94
+ /* Image formatting */
95
+ ::slotted(img[slot="media"]) {
96
+ width: 100%;
97
+ height: 100%;
98
+ object-fit: cover;
99
+ }
100
+
101
+ /* SVG formatting (for the icons we just created) */
102
+ ::slotted(svg[slot="media"]) {
103
+ width: 3rem;
104
+ height: 3rem;
105
+ color: var(--st-color-primary);
106
+ }
107
+
108
+ .content {
109
+ display: flex;
110
+ flex-direction: column;
111
+ padding: var(--st-spacing-md, 1.25rem);
112
+ gap: var(--st-spacing-sm, 0.5rem);
113
+ flex: 1;
114
+ }
115
+
116
+ .title {
117
+ font-weight: 600;
118
+ font-size: 1.125rem;
119
+ color: var(--st-color-text);
120
+ margin: 0;
121
+ }
122
+
123
+ .body {
124
+ color: var(--st-color-text-muted);
125
+ font-size: 0.875rem;
126
+ margin: 0;
127
+ line-height: 1.5;
128
+ }
129
+ `
130
+ ];
131
+ __decorate([
132
+ property({ type: String })
133
+ ], StContentCard.prototype, "href", void 0);
134
+ __decorate([
135
+ property({ type: String })
136
+ ], StContentCard.prototype, "target", void 0);
137
+ StContentCard = __decorate([
138
+ customElement('st-content-card')
139
+ ], StContentCard);
140
+ export { StContentCard };