@eqtylab/equality 3.3.1 → 3.4.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.
@@ -49,103 +49,124 @@
49
49
  flex-direction: column;
50
50
  overflow: auto;
51
51
  min-width: calc(0.25rem * 0);
52
+ &:focus-visible {
53
+ --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
54
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
55
+ }
56
+ &:focus-visible {
57
+ --tw-ring-color: var(--color-focus-ring, color(display-p3 0.5242 0.2903 0.7705));
58
+ }
59
+ &:focus-visible {
60
+ --tw-ring-inset: inset;
61
+ }
62
+ font-family: var(--font-mono);
63
+ }
64
+ :global([data-equality-code-block]) {
52
65
  font-family: var(--font-mono);
53
- --syntax-comment: slategray;
54
- --syntax-punctuation: #999;
55
- --syntax-tag: #905;
56
- --syntax-number: #905;
57
- --syntax-string: #690;
58
- --syntax-operator: #9a6e3a;
59
- --syntax-variable: #e90;
60
- --syntax-atrule: #07a;
61
- --syntax-keyword: #07a;
62
- --syntax-function: #dd4a68;
63
- --syntax-class-name: #dd4a68;
64
- --syntax-regex: #e90;
66
+ --syntax-comment: #008000;
67
+ --syntax-punctuation: #000000;
68
+ --syntax-tag: #800000;
69
+ --syntax-property: #001080;
70
+ --syntax-constant: #098658;
71
+ --syntax-string: #a31515;
72
+ --syntax-selector: #800000;
73
+ --syntax-inserted: #795e26;
74
+ --syntax-deleted: #af00db;
75
+ --syntax-operator: #000000;
76
+ --syntax-variable: #001080;
77
+ --syntax-regexp: #811f3f;
78
+ --syntax-keyword: #af00db;
79
+ --syntax-function: #795e26;
80
+ --syntax-type: #267f99;
65
81
  &:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *) {
66
- --syntax-comment: #d4d0ab;
67
- --syntax-punctuation: #fefefe;
68
- --syntax-tag: #ffa07a;
69
- --syntax-number: #00e0e0;
70
- --syntax-string: #abe338;
71
- --syntax-operator: #00e0e0;
72
- --syntax-variable: #00e0e0;
73
- --syntax-atrule: #ffd700;
74
- --syntax-keyword: #00e0e0;
75
- --syntax-function: #ffd700;
76
- --syntax-class-name: #ffd700;
77
- --syntax-regex: #ffd700;
78
- }
79
- }
80
- .content :global(.token.comment),
81
- .content :global(.token.prolog),
82
- .content :global(.token.doctype),
83
- .content :global(.token.cdata) {
84
- color: var(--syntax-comment);
85
- }
86
- .content :global(.token.punctuation) {
87
- color: var(--syntax-punctuation);
88
- }
89
- .content :global(.token.property),
90
- .content :global(.token.tag),
91
- .content :global(.token.constant),
92
- .content :global(.token.symbol),
93
- .content :global(.token.deleted) {
94
- color: var(--syntax-tag);
95
- }
96
- .content :global(.token.boolean),
97
- .content :global(.token.number) {
98
- color: var(--syntax-number);
99
- }
100
- .content :global(.token.selector),
101
- .content :global(.token.attr-name),
102
- .content :global(.token.string),
103
- .content :global(.token.char),
104
- .content :global(.token.builtin),
105
- .content :global(.token.inserted) {
106
- color: var(--syntax-string);
107
- }
108
- .content :global(.token.operator),
109
- .content :global(.token.entity),
110
- .content :global(.token.url),
111
- .content :global(.language-css .token.string),
112
- .content :global(.style .token.string) {
113
- color: var(--syntax-operator);
114
- }
115
- .content :global(.token.entity) {
116
- cursor: help;
117
- }
118
- .content :global(.token.variable) {
119
- color: var(--syntax-variable);
120
- }
121
- .content :global(.token.atrule),
122
- .content :global(.token.attr-value) {
123
- color: var(--syntax-atrule);
124
- }
125
- .content :global(.token.keyword) {
126
- color: var(--syntax-keyword);
127
- }
128
- .content :global(.token.function) {
129
- color: var(--syntax-function);
130
- }
131
- .content :global(.token.class-name) {
132
- color: var(--syntax-class-name);
133
- }
134
- .content :global(.token.regex) {
135
- color: var(--syntax-regex);
136
- }
137
- .content :global(.token.important) {
138
- color: var(--syntax-regex);
139
- font-weight: bold;
140
- }
141
- .content :global(.token.bold) {
142
- font-weight: bold;
143
- }
144
- .content :global(.token.italic) {
145
- font-style: italic;
146
- }
147
- .content :global(.namespace) {
148
- opacity: 0.7;
82
+ --syntax-comment: #6a9955;
83
+ --syntax-punctuation: #d4d4d4;
84
+ --syntax-tag: #569cd6;
85
+ --syntax-property: #9cdcfe;
86
+ --syntax-constant: #b5cea8;
87
+ --syntax-string: #ce9178;
88
+ --syntax-selector: #d7ba7d;
89
+ --syntax-inserted: #dcdcaa;
90
+ --syntax-deleted: #c586c0;
91
+ --syntax-operator: #d4d4d4;
92
+ --syntax-variable: #9cdcfe;
93
+ --syntax-regexp: #d16969;
94
+ --syntax-keyword: #c586c0;
95
+ --syntax-function: #dcdcaa;
96
+ --syntax-type: #4ec9b0;
97
+ }
98
+ }
99
+ :global(pre[data-equality-code-block] > code) {
100
+ font: inherit;
101
+ color: inherit;
102
+ background: none;
103
+ text-shadow: none;
104
+ &::highlight(comment),
105
+ &::highlight(quote) {
106
+ color: var(--syntax-comment);
107
+ }
108
+ &::highlight(punctuation) {
109
+ color: var(--syntax-punctuation);
110
+ }
111
+ &::highlight(keyword),
112
+ &::highlight(storage),
113
+ &::highlight(at-rule),
114
+ &::highlight(doctype),
115
+ &::highlight(important),
116
+ &::highlight(section) {
117
+ color: var(--syntax-keyword);
118
+ }
119
+ &::highlight(operator) {
120
+ color: var(--syntax-operator);
121
+ }
122
+ &::highlight(string),
123
+ &::highlight(attribute-value),
124
+ &::highlight(link),
125
+ &::highlight(raw) {
126
+ color: var(--syntax-string);
127
+ }
128
+ &::highlight(regexp) {
129
+ color: var(--syntax-regexp);
130
+ }
131
+ &::highlight(numeric),
132
+ &::highlight(boolean),
133
+ &::highlight(constant),
134
+ &::highlight(symbol),
135
+ &::highlight(character-entity),
136
+ &::highlight(anchor),
137
+ &::highlight(entity) {
138
+ color: var(--syntax-constant);
139
+ }
140
+ &::highlight(function),
141
+ &::highlight(decorator),
142
+ &::highlight(animation) {
143
+ color: var(--syntax-function);
144
+ }
145
+ &::highlight(type),
146
+ &::highlight(support) {
147
+ color: var(--syntax-type);
148
+ }
149
+ &::highlight(variable),
150
+ &::highlight(interpolation) {
151
+ color: var(--syntax-variable);
152
+ }
153
+ &::highlight(property),
154
+ &::highlight(key),
155
+ &::highlight(attribute-name) {
156
+ color: var(--syntax-property);
157
+ }
158
+ &::highlight(tag) {
159
+ color: var(--syntax-tag);
160
+ }
161
+ &::highlight(selector) {
162
+ color: var(--syntax-selector);
163
+ }
164
+ &::highlight(inserted) {
165
+ color: var(--syntax-inserted);
166
+ }
167
+ &::highlight(deleted) {
168
+ color: var(--syntax-deleted);
169
+ }
149
170
  }
150
171
  .neutral {
151
172
  border-color: var(--color-border, color(display-p3 0.7432 0.7432 0.7432));
@@ -174,10 +195,37 @@
174
195
  line-height: var(--tw-leading, calc(1 / 0.75));
175
196
  font-family: var(--font-mono);
176
197
  }
198
+ .body {
199
+ display: flex;
200
+ min-width: calc(0.25rem * 0);
201
+ --code-line-height: 1.5;
202
+ }
203
+ .body.numbered {
204
+ width: max-content;
205
+ min-width: 100%;
206
+ }
207
+ .gutter {
208
+ border-right-color: var(--color-border, color(display-p3 0.7432 0.7432 0.7432));
209
+ background-color: var(--color-card-background, color(display-p3 1 1 1));
210
+ color: var(--color-text-tertiary, color(display-p3 0.5021 0.5021 0.5021));
211
+ position: sticky;
212
+ left: calc(0.25rem * 0);
213
+ margin-block: calc(0.25rem * 0);
214
+ flex-shrink: 0;
215
+ border-right-style: var(--tw-border-style);
216
+ border-right-width: 1px;
217
+ padding: calc(0.25rem * 3);
218
+ text-align: right;
219
+ -webkit-user-select: none;
220
+ user-select: none;
221
+ font-family: var(--font-mono);
222
+ line-height: var(--code-line-height);
223
+ }
177
224
  .pre {
178
225
  margin-block: calc(0.25rem * 0);
179
226
  padding: calc(0.25rem * 3);
180
- line-height: 1.5;
227
+ min-width: calc(0.25rem * 0);
228
+ line-height: var(--code-line-height);
181
229
  tab-size: 4;
182
230
  }
183
231
  .code.wrap {
@@ -192,3 +240,68 @@
192
240
  syntax: "*";
193
241
  inherits: false;
194
242
  }
243
+ @property --tw-shadow {
244
+ syntax: "*";
245
+ inherits: false;
246
+ initial-value: 0 0 #0000;
247
+ }
248
+ @property --tw-shadow-color {
249
+ syntax: "*";
250
+ inherits: false;
251
+ }
252
+ @property --tw-shadow-alpha {
253
+ syntax: "<percentage>";
254
+ inherits: false;
255
+ initial-value: 100%;
256
+ }
257
+ @property --tw-inset-shadow {
258
+ syntax: "*";
259
+ inherits: false;
260
+ initial-value: 0 0 #0000;
261
+ }
262
+ @property --tw-inset-shadow-color {
263
+ syntax: "*";
264
+ inherits: false;
265
+ }
266
+ @property --tw-inset-shadow-alpha {
267
+ syntax: "<percentage>";
268
+ inherits: false;
269
+ initial-value: 100%;
270
+ }
271
+ @property --tw-ring-color {
272
+ syntax: "*";
273
+ inherits: false;
274
+ }
275
+ @property --tw-ring-shadow {
276
+ syntax: "*";
277
+ inherits: false;
278
+ initial-value: 0 0 #0000;
279
+ }
280
+ @property --tw-inset-ring-color {
281
+ syntax: "*";
282
+ inherits: false;
283
+ }
284
+ @property --tw-inset-ring-shadow {
285
+ syntax: "*";
286
+ inherits: false;
287
+ initial-value: 0 0 #0000;
288
+ }
289
+ @property --tw-ring-inset {
290
+ syntax: "*";
291
+ inherits: false;
292
+ }
293
+ @property --tw-ring-offset-width {
294
+ syntax: "<length>";
295
+ inherits: false;
296
+ initial-value: 0px;
297
+ }
298
+ @property --tw-ring-offset-color {
299
+ syntax: "*";
300
+ inherits: false;
301
+ initial-value: #fff;
302
+ }
303
+ @property --tw-ring-offset-shadow {
304
+ syntax: "*";
305
+ inherits: false;
306
+ initial-value: 0 0 #0000;
307
+ }
package/dist/index.cjs CHANGED
@@ -24,9 +24,9 @@ var styles11 = require('./card-content-header.module.module.css.module.css');
24
24
  var styles12 = require('./card.module.module.css.module.css');
25
25
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
26
26
  var styles13 = require('./checkbox.module.module.css.module.css');
27
- var reactSyntaxHighlighter = require('react-syntax-highlighter');
28
27
  var styles15 = require('./code-block.module.module.css.module.css');
29
28
  var styles14 = require('./icon-button.module.module.css.module.css');
29
+ var microlighter = require('microlighter');
30
30
  var cmdk = require('cmdk');
31
31
  var styles17 = require('./command.module.module.css.module.css');
32
32
  var DialogPrimitive = require('@radix-ui/react-dialog');
@@ -1219,7 +1219,29 @@ function CopyButton({
1219
1219
  }
1220
1220
  );
1221
1221
  }
1222
- var WRAP = true;
1222
+ var CODE_BLOCK_ATTRIBUTE = "data-equality-code-block";
1223
+ var SELECTOR = `pre[${CODE_BLOCK_ATTRIBUTE}] > code`;
1224
+ var tail = Promise.resolve();
1225
+ var queued = null;
1226
+ var isSupported = () => typeof window !== "undefined" && typeof CSS !== "undefined" && Boolean(CSS.highlights);
1227
+ var scheduleHighlight = () => {
1228
+ if (!isSupported()) return Promise.resolve();
1229
+ if (queued) return queued;
1230
+ const pass = tail.then(
1231
+ () => new Promise((resolve) => {
1232
+ window.requestAnimationFrame(() => {
1233
+ queued = null;
1234
+ microlighter.highlightAll({ selector: SELECTOR }).then(
1235
+ () => resolve(),
1236
+ () => resolve()
1237
+ );
1238
+ });
1239
+ })
1240
+ );
1241
+ queued = pass;
1242
+ tail = pass;
1243
+ return pass;
1244
+ };
1223
1245
  var CodeBlock = ({
1224
1246
  className,
1225
1247
  title,
@@ -1227,28 +1249,45 @@ var CodeBlock = ({
1227
1249
  language = "text",
1228
1250
  variant = "neutral",
1229
1251
  codeLabel,
1230
- copy
1252
+ copy,
1253
+ lineNumbers = false
1231
1254
  }) => {
1255
+ React15.useEffect(() => {
1256
+ void scheduleHighlight();
1257
+ return () => void scheduleHighlight();
1258
+ }, [code, language]);
1259
+ const gutter = React15.useMemo(() => {
1260
+ if (!lineNumbers) return null;
1261
+ const lines = code.replace(/\n$/, "").split("\n").length;
1262
+ return Array.from({ length: lines }, (_, index) => index + 1).join("\n");
1263
+ }, [code, lineNumbers]);
1232
1264
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(styles15__default.default["code-block"], styles15__default.default[variant], className), children: [
1233
1265
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles15__default.default.header, children: [
1234
1266
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles15__default.default["header-left"], children: [
1235
1267
  title && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles15__default.default.title, children: title }),
1236
- /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "neutral", className: styles15__default.default["badge"], children: language })
1268
+ /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "neutral", className: styles15__default.default.badge, children: language })
1237
1269
  ] }),
1238
1270
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles15__default.default["header-right"], children: /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: copy || code, size: "sm" }) })
1239
1271
  ] }),
1240
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles15__default.default.content), children: /* @__PURE__ */ jsxRuntime.jsx(
1241
- reactSyntaxHighlighter.Prism,
1272
+ /* @__PURE__ */ jsxRuntime.jsx(
1273
+ "div",
1242
1274
  {
1243
- language,
1244
- useInlineStyles: false,
1245
- wrapLines: WRAP,
1246
- wrapLongLines: WRAP,
1247
- className: styles15__default.default.pre,
1248
- codeTagProps: { className: cn(styles15__default.default.code, { [styles15__default.default.wrap]: WRAP }) },
1249
- children: code
1275
+ className: styles15__default.default.content,
1276
+ tabIndex: 0,
1277
+ role: "group",
1278
+ "aria-label": title ? `${title}, code block` : "Code block",
1279
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(styles15__default.default.body, { [styles15__default.default.numbered]: lineNumbers }), children: [
1280
+ gutter && /* @__PURE__ */ jsxRuntime.jsx("pre", { "aria-hidden": "true", className: styles15__default.default.gutter, children: gutter }),
1281
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: styles15__default.default.pre, ...{ [CODE_BLOCK_ATTRIBUTE]: "" }, children: /* @__PURE__ */ jsxRuntime.jsx(
1282
+ "code",
1283
+ {
1284
+ className: cn(styles15__default.default.code, `language-${language}`, { [styles15__default.default.wrap]: !lineNumbers }),
1285
+ children: code
1286
+ }
1287
+ ) })
1288
+ ] })
1250
1289
  }
1251
- ) }),
1290
+ ),
1252
1291
  codeLabel && /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles15__default.default["code-label"], children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: styles15__default.default["code-label-text"], children: codeLabel }) })
1253
1292
  ] });
1254
1293
  };
@@ -4310,6 +4349,7 @@ exports.BarGraph = BarGraph;
4310
4349
  exports.BarGraphSegment = BarGraphSegment;
4311
4350
  exports.BgGradient = BgGradient;
4312
4351
  exports.Button = Button;
4352
+ exports.CODE_BLOCK_ATTRIBUTE = CODE_BLOCK_ATTRIBUTE;
4313
4353
  exports.Card = Card;
4314
4354
  exports.CardContent = CardContent;
4315
4355
  exports.CardContentHeader = CardContentHeader;
@@ -4476,6 +4516,7 @@ exports.TruncatedDescription = TruncatedDescription;
4476
4516
  exports.badgeVariants = badgeVariants;
4477
4517
  exports.buttonVariants = buttonVariants;
4478
4518
  exports.reducer = reducer;
4519
+ exports.scheduleHighlight = scheduleHighlight;
4479
4520
  exports.toast = toast;
4480
4521
  exports.useFormField = useFormField;
4481
4522
  exports.usePortalContainer = usePortalContainer;