@mantine/code-highlight 7.0.0-alpha.8 → 7.0.0-beta.0

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 (54) hide show
  1. package/cjs/CodeHighlight.js +1 -21
  2. package/cjs/CodeHighlight.js.map +1 -1
  3. package/cjs/CodeHighlight.module.css.js +1 -2
  4. package/cjs/CodeHighlight.module.css.js.map +1 -1
  5. package/cjs/CodeHighlight.theme.module.css.js +1 -2
  6. package/cjs/CodeHighlight.theme.module.css.js.map +1 -1
  7. package/cjs/CodeHighlightTabs.js +40 -50
  8. package/cjs/CodeHighlightTabs.js.map +1 -1
  9. package/cjs/CopyIcon.js +14 -25
  10. package/cjs/CopyIcon.js.map +1 -1
  11. package/cjs/ExpandIcon.js +14 -39
  12. package/cjs/ExpandIcon.js.map +1 -1
  13. package/cjs/FileIcon.js +3 -4
  14. package/cjs/FileIcon.js.map +1 -1
  15. package/cjs/InlineCodeHighlight.js +9 -7
  16. package/cjs/InlineCodeHighlight.js.map +1 -1
  17. package/cjs/index.css +81 -118
  18. package/cjs/use-highlight.js +3 -2
  19. package/cjs/use-highlight.js.map +1 -1
  20. package/esm/CodeHighlight.js +1 -21
  21. package/esm/CodeHighlight.js.map +1 -1
  22. package/esm/CodeHighlight.module.css.js +1 -2
  23. package/esm/CodeHighlight.module.css.js.map +1 -1
  24. package/esm/CodeHighlight.theme.module.css.js +1 -2
  25. package/esm/CodeHighlight.theme.module.css.js.map +1 -1
  26. package/esm/CodeHighlightTabs.js +40 -50
  27. package/esm/CodeHighlightTabs.js.map +1 -1
  28. package/esm/CopyIcon.js +14 -25
  29. package/esm/CopyIcon.js.map +1 -1
  30. package/esm/ExpandIcon.js +14 -39
  31. package/esm/ExpandIcon.js.map +1 -1
  32. package/esm/FileIcon.js +3 -4
  33. package/esm/FileIcon.js.map +1 -1
  34. package/esm/InlineCodeHighlight.js +9 -7
  35. package/esm/InlineCodeHighlight.js.map +1 -1
  36. package/esm/index.css +81 -118
  37. package/esm/use-highlight.js +3 -2
  38. package/esm/use-highlight.js.map +1 -1
  39. package/lib/CodeHighlight.d.ts +0 -3
  40. package/lib/CodeHighlightTabs.d.ts +1 -2
  41. package/lib/CopyIcon.d.ts +1 -1
  42. package/lib/ExpandIcon.d.ts +1 -1
  43. package/lib/FileIcon.d.ts +3 -1
  44. package/lib/InlineCodeHighlight.d.ts +0 -1
  45. package/lib/index.d.ts +3 -3
  46. package/package.json +7 -6
  47. package/src/CodeHighlight.module.css +14 -1
  48. package/src/CodeHighlight.story.tsx +6 -0
  49. package/src/CodeHighlight.tsx +1 -3
  50. package/src/CodeHighlightTabs.tsx +9 -4
  51. package/src/FileIcon.tsx +13 -3
  52. package/src/InlineCodeHighlight.tsx +0 -1
  53. package/src/index.ts +0 -3
  54. package/tsconfig.build.tsbuildinfo +1 -1
package/esm/index.css CHANGED
@@ -1,4 +1,4 @@
1
- .mantine-XIBJZDt {
1
+ .m-5caae6d3 {
2
2
  display: inline-block;
3
3
  padding: calc(0.0625rem * var(--mantine-scale)) calc(0.1875rem * var(--mantine-scale));
4
4
  font-size: calc(0.8125rem * var(--mantine-scale));
@@ -7,28 +7,27 @@
7
7
  font-family: var(--mantine-font-family-monospace);
8
8
  }
9
9
 
10
- .mantine-RDvBcjB {
10
+ .m-2c47c4fd {
11
11
  display: block;
12
12
  padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);
13
13
  margin: 0;
14
- font-size: 16px; /* Required for Safari to be set in px */
15
14
  --_code-line-height: 1.7;
16
15
  }
17
16
 
18
- .mantine-cmEtjrV {
17
+ .m-e58679f3 {
19
18
  display: flex;
20
19
  align-items: flex-start;
21
20
  justify-content: space-between;
22
21
  }
23
22
 
24
- .mantine-059sM-t {
23
+ .m-be7e9c9c {
25
24
  display: flex;
26
25
  margin-top: calc(0.4375rem * var(--mantine-scale));
27
26
  margin-right: calc(0.4375rem * var(--mantine-scale));
28
27
  }
29
28
 
30
- .mantine-tB-P5PD,
31
- .mantine-NTm-nGn {
29
+ .m-5caae85b,
30
+ .m-d498bab7 {
32
31
  background-color: transparent;
33
32
  opacity: 0.8;
34
33
  margin: 0;
@@ -36,34 +35,34 @@
36
35
 
37
36
  @media (hover: hover) {
38
37
 
39
- .mantine-tB-P5PD:hover, .mantine-NTm-nGn:hover {
38
+ .m-5caae85b:hover, .m-d498bab7:hover {
40
39
  opacity: 1;
41
40
  }
42
41
  }
43
42
 
44
43
  @media (hover: none) {
45
44
 
46
- .mantine-tB-P5PD:active, .mantine-NTm-nGn:active {
45
+ .m-5caae85b:active, .m-d498bab7:active {
47
46
  opacity: 1;
48
47
  }
49
48
  }
50
49
 
51
50
  @media (max-width: 40em) {
52
51
 
53
- .mantine-tB-P5PD,
54
- .mantine-NTm-nGn {
52
+ .m-5caae85b,
53
+ .m-d498bab7 {
55
54
  display: none
56
55
  }
57
56
  }
58
57
 
59
- .mantine-tB-P5PD {
58
+ .m-5caae85b {
60
59
  position: absolute;
61
60
  top: calc(0.3125rem * var(--mantine-scale));
62
61
  right: calc(0.3125rem * var(--mantine-scale));
63
62
  z-index: 1;
64
63
  }
65
64
 
66
- .mantine-PBrPXnu {
65
+ .m-5cac2e62 {
67
66
  display: flex;
68
67
  align-items: center;
69
68
  justify-content: center;
@@ -81,88 +80,70 @@
81
80
  color: var(--_file-color);
82
81
  opacity: var(--_file-opacity);
83
82
  background-color: var(--_file-bg);
83
+ white-space: nowrap;
84
84
  }
85
85
 
86
86
  @media (hover: hover) {
87
87
 
88
- .mantine-PBrPXnu:hover {
88
+ .m-5cac2e62:hover {
89
89
  --_file-opacity: 1;
90
90
  }
91
91
  }
92
92
 
93
93
  @media (hover: none) {
94
94
 
95
- .mantine-PBrPXnu:active {
95
+ .m-5cac2e62:active {
96
96
  --_file-opacity: 1;
97
97
  }
98
98
  }
99
99
 
100
- .mantine-PBrPXnu:last-of-type {
100
+ .m-5cac2e62:last-of-type {
101
101
  border-bottom-right-radius: var(--mantine-radius-sm);
102
102
  }
103
103
 
104
- .mantine-PBrPXnu:only-child {
104
+ .m-5cac2e62:only-child {
105
105
  --_file-cursor: default;
106
106
  }
107
107
 
108
- .mantine-PBrPXnu[data-active] {
108
+ .m-5cac2e62[data-active] {
109
109
  --_file-opacity: 1;
110
110
  --_file-color: var(--_file-active-color) !important;
111
111
  --_file-bg: var(--_file-active-bg);
112
112
  }
113
113
 
114
- .mantine-PBrPXnu {
114
+ .m-5cac2e62 {
115
115
 
116
116
  --_file-opacity: 0.8;
117
117
  --_file-cursor: pointer;
118
118
  }
119
119
 
120
- [data-mantine-color-scheme='light'] .mantine-PBrPXnu {
120
+ [data-mantine-color-scheme='light'] .m-5cac2e62 {
121
121
  --_file-color: var(--mantine-color-gray-8);
122
122
  --_file-bd: var(--mantine-color-gray-2);
123
123
  --_file-active-bg: var(--mantine-color-white);
124
124
  --_file-active-color: var(--mantine-color-black);
125
125
  }
126
126
 
127
- @media (prefers-color-scheme: light) {
128
-
129
- .mantine-PBrPXnu {
130
- --_file-color: var(--mantine-color-gray-8);
131
- --_file-bd: var(--mantine-color-gray-2);
132
- --_file-active-bg: var(--mantine-color-white);
133
- --_file-active-color: var(--mantine-color-black);
134
- }
135
- }
136
-
137
- [data-mantine-color-scheme='dark'] .mantine-PBrPXnu {
127
+ [data-mantine-color-scheme='dark'] .m-5cac2e62 {
138
128
  --_file-color: var(--mantine-color-dark-0);
139
129
  --_file-bd: var(--mantine-color-dark-4);
140
130
  --_file-active-bg: var(--mantine-color-dark-6);
141
131
  --_file-active-color: var(--mantine-color-white);
142
132
  }
143
133
 
144
- @media (prefers-color-scheme: dark) {
145
-
146
- .mantine-PBrPXnu {
147
- --_file-color: var(--mantine-color-dark-0);
148
- --_file-bd: var(--mantine-color-dark-4);
149
- --_file-active-bg: var(--mantine-color-dark-6);
150
- --_file-active-color: var(--mantine-color-white);
151
- }
152
- }
153
-
154
- .mantine-IvOddiX {
134
+ .m-38d99e51 {
155
135
  display: flex;
156
136
  }
157
137
 
158
- .mantine-YfYyOiA {
138
+ .m-9f507240 {
159
139
  max-height: var(--ch-max-collapsed-height);
160
140
  overflow: hidden;
161
141
  position: relative;
162
142
  }
163
143
 
164
- .mantine-YfYyOiA::before {
144
+ .m-9f507240::before {
165
145
  content: '';
146
+ z-index: 100;
166
147
  position: absolute;
167
148
  inset: 0;
168
149
  pointer-events: none;
@@ -170,15 +151,15 @@
170
151
  border-radius: calc(var(--mantine-radius-md) - calc(0.0625rem * var(--mantine-scale)));
171
152
  }
172
153
 
173
- .mantine-YfYyOiA[data-expanded] {
154
+ .m-9f507240[data-expanded] {
174
155
  max-height: none;
175
156
  }
176
157
 
177
- .mantine-YfYyOiA[data-expanded]::before {
158
+ .m-9f507240[data-expanded]::before {
178
159
  display: none;
179
160
  }
180
161
 
181
- .mantine-haNyFRC {
162
+ .m-c9378bc2 {
182
163
  position: absolute;
183
164
  bottom: 0;
184
165
  left: 50%;
@@ -187,39 +168,37 @@
187
168
  color: var(--mantine-color-anchor);
188
169
  width: 100%;
189
170
  text-align: center;
171
+ z-index: 101;
190
172
  padding-top: var(--mantine-spacing-xs);
191
173
  padding-bottom: var(--mantine-spacing-xs);
192
174
  }
193
175
 
194
- .mantine-haNyFRC[data-hidden] {
176
+ .m-c9378bc2[data-hidden] {
195
177
  display: none;
196
178
  }
197
179
 
198
- .mantine-k6OJW8l {
180
+ .m-5cb1b9c8 {
199
181
  margin-top: 0;
200
182
  position: relative;
201
183
  }
202
184
 
203
- .mantine-h-DP-Yw {
204
- color: var(--_color);
205
- background: var(--_background);
185
+ .m-b46cddfb {
186
+ display: flex;
187
+ align-items: center;
188
+ justify-content: center;
189
+ flex: 0 1;
206
190
  }
207
191
 
208
- [data-mantine-color-scheme='light'] .mantine-h-DP-Yw {
209
- --_color: var(--mantine-color-gray-7);
210
- --_background: var(--mantine-color-gray-0);
211
- --code-comment-color: var(--mantine-color-gray-6);
212
- --code-keyword-color: var(--mantine-color-violet-8);
213
- --code-tag-color: var(--mantine-color-red-9);
214
- --code-literal-color: var(--mantine-color-blue-6);
215
- --code-string-color: var(--mantine-color-blue-9);
216
- --code-variable-color: var(--mantine-color-lime-9);
217
- --code-class-color: var(--mantine-color-orange-9);
218
- }
192
+ .m-b46cddfb > svg {
193
+ display: block;
194
+ }
219
195
 
220
- @media (prefers-color-scheme: light) {
196
+ .m-1f5e827e {
197
+ color: var(--_color);
198
+ background: var(--_background);
199
+ }
221
200
 
222
- .mantine-h-DP-Yw {
201
+ [data-mantine-color-scheme='light'] .m-1f5e827e {
223
202
  --_color: var(--mantine-color-gray-7);
224
203
  --_background: var(--mantine-color-gray-0);
225
204
  --code-comment-color: var(--mantine-color-gray-6);
@@ -229,24 +208,9 @@
229
208
  --code-string-color: var(--mantine-color-blue-9);
230
209
  --code-variable-color: var(--mantine-color-lime-9);
231
210
  --code-class-color: var(--mantine-color-orange-9);
232
- }
233
- }
234
-
235
- [data-mantine-color-scheme='dark'] .mantine-h-DP-Yw {
236
- --_color: var(--mantine-color-dark-1);
237
- --_background: var(--mantine-color-dark-8);
238
- --code-comment-color: var(--mantine-color-dark-3);
239
- --code-keyword-color: var(--mantine-color-violet-3);
240
- --code-tag-color: var(--mantine-color-yellow-4);
241
- --code-literal-color: var(--mantine-color-blue-4);
242
- --code-string-color: var(--mantine-color-green-6);
243
- --code-variable-color: var(--mantine-color-blue-2);
244
- --code-class-color: var(--mantine-color-orange-5);
245
211
  }
246
212
 
247
- @media (prefers-color-scheme: dark) {
248
-
249
- .mantine-h-DP-Yw {
213
+ [data-mantine-color-scheme='dark'] .m-1f5e827e {
250
214
  --_color: var(--mantine-color-dark-1);
251
215
  --_background: var(--mantine-color-dark-8);
252
216
  --code-comment-color: var(--mantine-color-dark-3);
@@ -256,72 +220,71 @@
256
220
  --code-string-color: var(--mantine-color-green-6);
257
221
  --code-variable-color: var(--mantine-color-blue-2);
258
222
  --code-class-color: var(--mantine-color-orange-5);
259
- }
260
223
  }
261
224
 
262
- .mantine-h-DP-Yw .hljs-comment,
263
- .mantine-h-DP-Yw .hljs-quote {
225
+ .m-1f5e827e .hljs-comment,
226
+ .m-1f5e827e .hljs-quote {
264
227
  font-style: italic;
265
228
  color: var(--code-comment-color);
266
229
  }
267
230
 
268
- .mantine-h-DP-Yw .hljs-doctag,
269
- .mantine-h-DP-Yw .hljs-formula,
270
- .mantine-h-DP-Yw .hljs-keyword {
231
+ .m-1f5e827e .hljs-doctag,
232
+ .m-1f5e827e .hljs-formula,
233
+ .m-1f5e827e .hljs-keyword {
271
234
  color: var(--code-keyword-color);
272
235
  }
273
236
 
274
- .mantine-h-DP-Yw .hljs-deletion,
275
- .mantine-h-DP-Yw .hljs-name,
276
- .mantine-h-DP-Yw .hljs-section,
277
- .mantine-h-DP-Yw .hljs-selector-tag,
278
- .mantine-h-DP-Yw .hljs-subst {
237
+ .m-1f5e827e .hljs-deletion,
238
+ .m-1f5e827e .hljs-name,
239
+ .m-1f5e827e .hljs-section,
240
+ .m-1f5e827e .hljs-selector-tag,
241
+ .m-1f5e827e .hljs-subst {
279
242
  color: var(--code-tag-color);
280
243
  }
281
244
 
282
- .mantine-h-DP-Yw .hljs-literal {
245
+ .m-1f5e827e .hljs-literal {
283
246
  color: var(--code-literal-color);
284
247
  }
285
248
 
286
- .mantine-h-DP-Yw .hljs-addition,
287
- .mantine-h-DP-Yw .hljs-attribute,
288
- .mantine-h-DP-Yw .hljs-meta .hljs-string,
289
- .mantine-h-DP-Yw .hljs-regexp,
290
- .mantine-h-DP-Yw .hljs-string {
249
+ .m-1f5e827e .hljs-addition,
250
+ .m-1f5e827e .hljs-attribute,
251
+ .m-1f5e827e .hljs-meta .hljs-string,
252
+ .m-1f5e827e .hljs-regexp,
253
+ .m-1f5e827e .hljs-string {
291
254
  color: var(--code-string-color);
292
255
  }
293
256
 
294
- .mantine-h-DP-Yw .hljs-attr,
295
- .mantine-h-DP-Yw .hljs-number,
296
- .mantine-h-DP-Yw .hljs-selector-attr,
297
- .mantine-h-DP-Yw .hljs-selector-class,
298
- .mantine-h-DP-Yw .hljs-selector-pseudo,
299
- .mantine-h-DP-Yw .hljs-template-variable,
300
- .mantine-h-DP-Yw .hljs-type,
301
- .mantine-h-DP-Yw .hljs-variable {
257
+ .m-1f5e827e .hljs-attr,
258
+ .m-1f5e827e .hljs-number,
259
+ .m-1f5e827e .hljs-selector-attr,
260
+ .m-1f5e827e .hljs-selector-class,
261
+ .m-1f5e827e .hljs-selector-pseudo,
262
+ .m-1f5e827e .hljs-template-variable,
263
+ .m-1f5e827e .hljs-type,
264
+ .m-1f5e827e .hljs-variable {
302
265
  color: var(--code-variable-color);
303
266
  }
304
267
 
305
- .mantine-h-DP-Yw .hljs-bullet,
306
- .mantine-h-DP-Yw .hljs-link,
307
- .mantine-h-DP-Yw .hljs-meta,
308
- .mantine-h-DP-Yw .hljs-selector-id,
309
- .mantine-h-DP-Yw .hljs-symbol,
310
- .mantine-h-DP-Yw .hljs-title,
311
- .mantine-h-DP-Yw .hljs-built_in,
312
- .mantine-h-DP-Yw .hljs-class .hljs-title,
313
- .mantine-h-DP-Yw .hljs-title.class_ {
268
+ .m-1f5e827e .hljs-bullet,
269
+ .m-1f5e827e .hljs-link,
270
+ .m-1f5e827e .hljs-meta,
271
+ .m-1f5e827e .hljs-selector-id,
272
+ .m-1f5e827e .hljs-symbol,
273
+ .m-1f5e827e .hljs-title,
274
+ .m-1f5e827e .hljs-built_in,
275
+ .m-1f5e827e .hljs-class .hljs-title,
276
+ .m-1f5e827e .hljs-title.class_ {
314
277
  color: var(--code-class-color);
315
278
  }
316
279
 
317
- .mantine-h-DP-Yw .hljs-emphasis {
280
+ .m-1f5e827e .hljs-emphasis {
318
281
  font-style: italic;
319
282
  }
320
283
 
321
- .mantine-h-DP-Yw .hljs-strong {
284
+ .m-1f5e827e .hljs-strong {
322
285
  font-weight: 700;
323
286
  }
324
287
 
325
- .mantine-h-DP-Yw .hljs-link {
288
+ .m-1f5e827e .hljs-link {
326
289
  text-decoration: underline;
327
290
  }
@@ -1,11 +1,12 @@
1
- 'use client';
2
1
  import { useState, useEffect } from 'react';
3
2
  import hljs from 'highlight.js';
4
3
 
5
4
  function useHighlight({ code, language, highlightOnClient }) {
6
5
  const getHighlightedCode = () => hljs.highlight(code.trim(), { language }).value;
7
6
  const [highlighted, setHighlighted] = useState(!highlightOnClient);
8
- const [highlightedCode, setHighlightedCode] = useState(highlightOnClient ? code : getHighlightedCode());
7
+ const [highlightedCode, setHighlightedCode] = useState(
8
+ highlightOnClient ? code : getHighlightedCode()
9
+ );
9
10
  const getCodeProps = () => highlighted ? { dangerouslySetInnerHTML: { __html: highlightedCode } } : { children: code.trim() };
10
11
  useEffect(() => {
11
12
  if (highlightOnClient) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-highlight.js","sources":["../src/use-highlight.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport hljs from 'highlight.js';\n\ninterface UseHighlightInput {\n code: string;\n language: string;\n highlightOnClient: boolean | undefined;\n}\n\nexport function useHighlight({ code, language, highlightOnClient }: UseHighlightInput) {\n const getHighlightedCode = () => hljs.highlight(code.trim(), { language: language! }).value;\n const [highlighted, setHighlighted] = useState(!highlightOnClient);\n const [highlightedCode, setHighlightedCode] = useState(\n highlightOnClient ? code : getHighlightedCode()\n );\n\n const getCodeProps = () =>\n highlighted\n ? { dangerouslySetInnerHTML: { __html: highlightedCode } }\n : { children: code.trim() };\n\n useEffect(() => {\n if (highlightOnClient) {\n setHighlightedCode(getHighlightedCode());\n setHighlighted(true);\n }\n }, []);\n\n return getCodeProps;\n}\n"],"names":[],"mappings":";;;;AAEO,SAAS,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE;AACpE,EAAE,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC;AACnF,EAAE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC;AACrE,EAAE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,iBAAiB,GAAG,IAAI,GAAG,kBAAkB,EAAE,CAAC,CAAC;AAC1G,EAAE,MAAM,YAAY,GAAG,MAAM,WAAW,GAAG,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAChI,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,kBAAkB,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAC/C,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;AAC3B,KAAK;AACL,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,YAAY,CAAC;AACtB;;"}
1
+ {"version":3,"file":"use-highlight.js","sources":["../src/use-highlight.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport hljs from 'highlight.js';\n\ninterface UseHighlightInput {\n code: string;\n language: string;\n highlightOnClient: boolean | undefined;\n}\n\nexport function useHighlight({ code, language, highlightOnClient }: UseHighlightInput) {\n const getHighlightedCode = () => hljs.highlight(code.trim(), { language: language! }).value;\n const [highlighted, setHighlighted] = useState(!highlightOnClient);\n const [highlightedCode, setHighlightedCode] = useState(\n highlightOnClient ? code : getHighlightedCode()\n );\n\n const getCodeProps = () =>\n highlighted\n ? { dangerouslySetInnerHTML: { __html: highlightedCode } }\n : { children: code.trim() };\n\n useEffect(() => {\n if (highlightOnClient) {\n setHighlightedCode(getHighlightedCode());\n setHighlighted(true);\n }\n }, []);\n\n return getCodeProps;\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE;AACpE,EAAE,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC;AACnF,EAAE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC;AACrE,EAAE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ;AACxD,IAAI,iBAAiB,GAAG,IAAI,GAAG,kBAAkB,EAAE;AACnD,GAAG,CAAC;AACJ,EAAE,MAAM,YAAY,GAAG,MAAM,WAAW,GAAG,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAChI,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,kBAAkB,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAC/C,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;AAC3B,KAAK;AACL,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,YAAY,CAAC;AACtB;;;;"}
@@ -1,6 +1,5 @@
1
1
  import { BoxProps, StylesApiProps, ElementProps, Factory } from '@mantine/core';
2
2
  export type CodeHighlightStylesNames = 'root' | 'code' | 'pre' | 'copy';
3
- export type CodeHighlightVariant = string;
4
3
  export interface CodeHighlightProps extends BoxProps, StylesApiProps<CodeHighlightFactory>, ElementProps<'div'> {
5
4
  /** Code to highlight */
6
5
  code: string;
@@ -19,11 +18,9 @@ export type CodeHighlightFactory = Factory<{
19
18
  props: CodeHighlightProps;
20
19
  ref: HTMLDivElement;
21
20
  stylesNames: CodeHighlightStylesNames;
22
- variant: CodeHighlightVariant;
23
21
  }>;
24
22
  export declare const CodeHighlight: import("@mantine/core").MantineComponent<{
25
23
  props: CodeHighlightProps;
26
24
  ref: HTMLDivElement;
27
25
  stylesNames: CodeHighlightStylesNames;
28
- variant: CodeHighlightVariant;
29
26
  }>;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { BoxProps, StylesApiProps, ElementProps, Factory } from '@mantine/core';
3
- export type CodeHighlightTabsStylesNames = 'root' | 'code' | 'codeWrapper' | 'showCodeButton' | 'pre' | 'controls' | 'control' | 'header' | 'file' | 'files';
4
- export type CodeHighlightTabsVariant = string;
3
+ export type CodeHighlightTabsStylesNames = 'root' | 'code' | 'codeWrapper' | 'showCodeButton' | 'pre' | 'controls' | 'control' | 'header' | 'file' | 'files' | 'fileIcon';
5
4
  export type CodeHighlightTabsCssVariables = {
6
5
  root: '--ch-max-collapsed-height';
7
6
  };
package/lib/CopyIcon.d.ts CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  interface CopyIconProps extends React.ComponentPropsWithoutRef<'svg'> {
3
3
  copied: boolean;
4
4
  }
5
- export declare function CopyIcon({ copied, style, ...others }: CopyIconProps): JSX.Element;
5
+ export declare function CopyIcon({ copied, style, ...others }: CopyIconProps): React.JSX.Element;
6
6
  export declare namespace CopyIcon {
7
7
  var displayName: string;
8
8
  }
@@ -2,5 +2,5 @@ import React from 'react';
2
2
  interface ExpandIconProps extends React.ComponentPropsWithoutRef<'svg'> {
3
3
  expanded: boolean;
4
4
  }
5
- export declare function ExpandIcon({ expanded, style, ...others }: ExpandIconProps): JSX.Element;
5
+ export declare function ExpandIcon({ expanded, style, ...others }: ExpandIconProps): React.JSX.Element;
6
6
  export {};
package/lib/FileIcon.d.ts CHANGED
@@ -3,6 +3,8 @@ interface FileIconProps {
3
3
  fileName: string | undefined;
4
4
  getFileIcon?: ((fileName: string) => React.ReactNode) | undefined;
5
5
  fileIcon: React.ReactNode | undefined;
6
+ className?: string;
7
+ style?: React.CSSProperties;
6
8
  }
7
- export declare function FileIcon({ fileIcon, fileName, getFileIcon }: FileIconProps): JSX.Element | null;
9
+ export declare function FileIcon({ fileIcon, fileName, getFileIcon, className, style }: FileIconProps): React.JSX.Element | null;
8
10
  export {};
@@ -1,6 +1,5 @@
1
1
  import { BoxProps, StylesApiProps, ElementProps, Factory } from '@mantine/core';
2
2
  export type InlineCodeHighlightStylesNames = 'code';
3
- export type InlineCodeHighlightVariant = string;
4
3
  export interface InlineCodeHighlightProps extends BoxProps, StylesApiProps<InlineCodeHighlightFactory>, ElementProps<'div'> {
5
4
  /** Code to highlight */
6
5
  code: string;
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { CodeHighlightTabs } from './CodeHighlightTabs';
2
2
  export { CodeHighlight } from './CodeHighlight';
3
3
  export { InlineCodeHighlight } from './InlineCodeHighlight';
4
- export type { CodeHighlightTabsFactory, CodeHighlightTabsStylesNames, CodeHighlightTabsProps, CodeHighlightTabsCode, CodeHighlightTabsVariant, CodeHighlightTabsCssVariables, } from './CodeHighlightTabs';
5
- export type { CodeHighlightFactory, CodeHighlightProps, CodeHighlightStylesNames, CodeHighlightVariant, } from './CodeHighlight';
6
- export type { InlineCodeHighlightFactory, InlineCodeHighlightProps, InlineCodeHighlightStylesNames, InlineCodeHighlightVariant, } from './InlineCodeHighlight';
4
+ export type { CodeHighlightTabsFactory, CodeHighlightTabsStylesNames, CodeHighlightTabsProps, CodeHighlightTabsCode, CodeHighlightTabsCssVariables, } from './CodeHighlightTabs';
5
+ export type { CodeHighlightFactory, CodeHighlightProps, CodeHighlightStylesNames, } from './CodeHighlight';
6
+ export type { InlineCodeHighlightFactory, InlineCodeHighlightProps, InlineCodeHighlightStylesNames, } from './InlineCodeHighlight';
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@mantine/code-highlight",
3
3
  "description": "Code highlight with Mantine theme",
4
- "version": "7.0.0-alpha.8",
4
+ "version": "7.0.0-beta.0",
5
+ "types": "./lib/index.d.ts",
5
6
  "exports": {
6
7
  ".": {
7
8
  "import": "./esm/index.js",
@@ -36,14 +37,14 @@
36
37
  "syntax-highlight"
37
38
  ],
38
39
  "peerDependencies": {
39
- "@mantine/core": "7.0.0-alpha.8",
40
- "@mantine/hooks": "7.0.0-alpha.8",
41
- "react": ">=16.8.0",
42
- "react-dom": ">=16.8.0"
40
+ "@mantine/core": "7.0.0-beta.0",
41
+ "@mantine/hooks": "7.0.0-beta.0",
42
+ "react": "^18.2.0",
43
+ "react-dom": "^18.2.0"
43
44
  },
44
45
  "dependencies": {
45
46
  "highlight.js": "^11.7.0",
46
- "clsx": "1.1.1"
47
+ "clsx": "2.0.0"
47
48
  },
48
49
  "devDependencies": {}
49
50
  }
@@ -11,7 +11,6 @@
11
11
  display: block;
12
12
  padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);
13
13
  margin: 0;
14
- font-size: 16px; /* Required for Safari to be set in px */
15
14
  --_code-line-height: 1.7;
16
15
  }
17
16
 
@@ -67,6 +66,7 @@
67
66
  color: var(--_file-color);
68
67
  opacity: var(--_file-opacity);
69
68
  background-color: var(--_file-bg);
69
+ white-space: nowrap;
70
70
 
71
71
  @mixin hover {
72
72
  --_file-opacity: 1;
@@ -115,6 +115,7 @@
115
115
 
116
116
  &::before {
117
117
  content: '';
118
+ z-index: 100;
118
119
  position: absolute;
119
120
  inset: 0;
120
121
  pointer-events: none;
@@ -140,6 +141,7 @@
140
141
  color: var(--mantine-color-anchor);
141
142
  width: 100%;
142
143
  text-align: center;
144
+ z-index: 101;
143
145
  padding-top: var(--mantine-spacing-xs);
144
146
  padding-bottom: var(--mantine-spacing-xs);
145
147
 
@@ -152,3 +154,14 @@
152
154
  margin-top: 0;
153
155
  position: relative;
154
156
  }
157
+
158
+ .fileIcon {
159
+ display: flex;
160
+ align-items: center;
161
+ justify-content: center;
162
+ flex: 0;
163
+
164
+ & > svg {
165
+ display: block;
166
+ }
167
+ }
@@ -194,6 +194,12 @@ export function Tabs() {
194
194
  code={[
195
195
  { code: tsxCode, language: 'tsx', icon: <TsIcon />, fileName: 'Component.tsx' },
196
196
  { code: cssCode, language: 'css', icon: <CSSIcon />, fileName: 'Component.module.css' },
197
+ {
198
+ code: cssCode,
199
+ language: 'css',
200
+ icon: <CSSIcon />,
201
+ fileName: 'Long-file-name-that-will-break-to-another-line.css',
202
+ },
197
203
  ]}
198
204
  defaultExpanded={false}
199
205
  >
@@ -22,7 +22,6 @@ import themeClasses from './CodeHighlight.theme.module.css';
22
22
  const classes = { ..._classes, root: cx(_classes.root, themeClasses.theme) };
23
23
 
24
24
  export type CodeHighlightStylesNames = 'root' | 'code' | 'pre' | 'copy';
25
- export type CodeHighlightVariant = string;
26
25
 
27
26
  export interface CodeHighlightProps
28
27
  extends BoxProps,
@@ -51,7 +50,6 @@ export type CodeHighlightFactory = Factory<{
51
50
  props: CodeHighlightProps;
52
51
  ref: HTMLDivElement;
53
52
  stylesNames: CodeHighlightStylesNames;
54
- variant: CodeHighlightVariant;
55
53
  }>;
56
54
 
57
55
  const defaultProps: Partial<CodeHighlightProps> = {
@@ -111,7 +109,7 @@ export const CodeHighlight = factory<CodeHighlightFactory>((_props, ref) => {
111
109
  </CopyButton>
112
110
  )}
113
111
 
114
- <ScrollArea type="auto" dir="ltr" offsetScrollbars={false}>
112
+ <ScrollArea type="hover" dir="ltr" offsetScrollbars={false}>
115
113
  <pre {...getStyles('pre')}>
116
114
  <code {...getStyles('code')} {...getCodeProps()} />
117
115
  </pre>
@@ -37,9 +37,9 @@ export type CodeHighlightTabsStylesNames =
37
37
  | 'control'
38
38
  | 'header'
39
39
  | 'file'
40
- | 'files';
40
+ | 'files'
41
+ | 'fileIcon';
41
42
 
42
- export type CodeHighlightTabsVariant = string;
43
43
  export type CodeHighlightTabsCssVariables = {
44
44
  root: '--ch-max-collapsed-height';
45
45
  };
@@ -189,7 +189,12 @@ export const CodeHighlightTabs = factory<CodeHighlightTabsFactory>((_props, ref)
189
189
  mod={{ active: index === value }}
190
190
  onClick={() => setValue(index)}
191
191
  >
192
- <FileIcon fileIcon={node.icon} getFileIcon={getFileIcon} fileName={node.fileName} />
192
+ <FileIcon
193
+ fileIcon={node.icon}
194
+ getFileIcon={getFileIcon}
195
+ fileName={node.fileName}
196
+ {...getStyles('fileIcon')}
197
+ />
193
198
  <span>{node.fileName}</span>
194
199
  </UnstyledButton>
195
200
  ));
@@ -243,7 +248,7 @@ export const CodeHighlightTabs = factory<CodeHighlightTabsFactory>((_props, ref)
243
248
  mod={{ hidden: _expanded }}
244
249
  onClick={() => setExpanded(true)}
245
250
  >
246
- Expand code
251
+ {expandCodeLabel}
247
252
  </UnstyledButton>
248
253
  </Box>
249
254
  );