@hraness/design-kit 0.35.0 → 0.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SyntaxCode,
3
3
  platformInstallClassName
4
- } from "./chunk-fjf81bww.js";
4
+ } from "./chunk-6ts4955n.js";
5
5
  import {
6
6
  detectPlatform,
7
7
  isKnownPlatformId,
@@ -13,7 +13,102 @@ import {
13
13
 
14
14
  // src/react/platform-install.tsx
15
15
  import { useCallback, useEffect, useId, useRef, useState } from "react";
16
+
17
+ // src/react/setup-copy-button.stylex.ts
18
+ import * as stylex from "@stylexjs/stylex";
19
+ var setupCopyButtonStyles = {
20
+ button: {
21
+ kGNEyG: "x6s0dn4",
22
+ kysU6D: "xjyslct",
23
+ kWkggS: "x17tv4j5 x1lf5oka xnwy5bs",
24
+ kVAM5u: "x3ugid2 x1ylmb6m",
25
+ kaIpWk: "x116uinm",
26
+ ksu8eU: "x1y0btm7",
27
+ kMzoRj: "xmkeg23",
28
+ kB7OPa: "x9f619",
29
+ kMwMTN: "xm06a53 x1ggml12",
30
+ kkrTdU: "x1ypdohk",
31
+ k1xSpc: "x3nfvp2 x1cfwndu",
32
+ kmuXW: "x2lah0s",
33
+ kMv6JI: "xtls1wf",
34
+ kGuDYH: "x1dcheo9",
35
+ k63SB2: "xk50ysn",
36
+ kOIVth: "x1neeqzj",
37
+ kjj79g: "xl56j7k",
38
+ kLWn49: "xo5v014",
39
+ kogj98: "x1ghz6dp",
40
+ kAzted: "xgbkey0",
41
+ kI3sdo: "x1a2a7pz xr5lfjo",
42
+ kInvED: "x1hl8ikr",
43
+ kmVPX3: "x1i4hug3",
44
+ $$css: true
45
+ },
46
+ icon: {
47
+ kZKoxP: "x1l36t39",
48
+ kmuXW: "x2lah0s",
49
+ kzqmXN: "xcdlrvm",
50
+ $$css: true
51
+ }
52
+ };
53
+ function setupCopyButtonClassName(part, caller) {
54
+ return [`hraness-setup-copy__${part}`, stylex.props(setupCopyButtonStyles[part]).className, caller].filter(Boolean).join(" ");
55
+ }
56
+
57
+ // src/react/setup-copy-button.tsx
16
58
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
59
+ function SetupCopyButton({
60
+ className,
61
+ iconClassName,
62
+ onCopy,
63
+ state,
64
+ subject,
65
+ failedLabel = "Copy failed"
66
+ }) {
67
+ return /* @__PURE__ */ jsxs("button", {
68
+ "aria-busy": state === "copying" || undefined,
69
+ "aria-label": `${state === "copied" ? "Copied" : "Copy"} ${subject}`,
70
+ className: setupCopyButtonClassName("button", className),
71
+ "data-copy-state": state,
72
+ disabled: state === "copying",
73
+ onClick: onCopy,
74
+ type: "button",
75
+ children: [
76
+ /* @__PURE__ */ jsx("svg", {
77
+ "aria-hidden": "true",
78
+ className: setupCopyButtonClassName("icon", iconClassName),
79
+ fill: "none",
80
+ focusable: "false",
81
+ stroke: "currentColor",
82
+ strokeLinecap: "round",
83
+ strokeLinejoin: "round",
84
+ strokeWidth: 2,
85
+ viewBox: "0 0 24 24",
86
+ children: state === "copied" ? /* @__PURE__ */ jsx("path", {
87
+ d: "M5 12.5l4.5 4.5L19 7.5"
88
+ }) : /* @__PURE__ */ jsxs(Fragment, {
89
+ children: [
90
+ /* @__PURE__ */ jsx("rect", {
91
+ height: "12",
92
+ rx: "2",
93
+ width: "12",
94
+ x: "8",
95
+ y: "8"
96
+ }),
97
+ /* @__PURE__ */ jsx("path", {
98
+ d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"
99
+ })
100
+ ]
101
+ })
102
+ }),
103
+ /* @__PURE__ */ jsx("span", {
104
+ children: state === "copied" ? "Copied" : state === "copying" ? "Copying" : state === "failed" ? failedLabel : "Copy"
105
+ })
106
+ ]
107
+ });
108
+ }
109
+
110
+ // src/react/platform-install.tsx
111
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
17
112
  var copyResetMilliseconds = 2000;
18
113
  function assertTargets(platforms, defaultPlatform) {
19
114
  if (platforms.length === 0)
@@ -82,17 +177,17 @@ function PlatformMarkSymbols({
82
177
  ids,
83
178
  symbolId
84
179
  }) {
85
- return /* @__PURE__ */ jsx("svg", {
180
+ return /* @__PURE__ */ jsx2("svg", {
86
181
  "aria-hidden": "true",
87
182
  className: platformInstallClassName(["markSymbols"]),
88
183
  focusable: "false",
89
184
  xmlns: "http://www.w3.org/2000/svg",
90
185
  children: ids.map((id) => {
91
186
  const mark = platformMark(id);
92
- return /* @__PURE__ */ jsx("symbol", {
187
+ return /* @__PURE__ */ jsx2("symbol", {
93
188
  id: symbolId(id),
94
189
  viewBox: mark.viewBox,
95
- children: /* @__PURE__ */ jsx("path", {
190
+ children: /* @__PURE__ */ jsx2("path", {
96
191
  d: mark.path
97
192
  })
98
193
  }, id);
@@ -103,7 +198,7 @@ function PlatformMarkUse({
103
198
  platform,
104
199
  symbolId
105
200
  }) {
106
- return /* @__PURE__ */ jsx("svg", {
201
+ return /* @__PURE__ */ jsx2("svg", {
107
202
  "aria-hidden": "true",
108
203
  className: platformInstallClassName(["icon"]),
109
204
  "data-platform": platform,
@@ -111,97 +206,58 @@ function PlatformMarkUse({
111
206
  focusable: "false",
112
207
  viewBox: platformMark(platform).viewBox,
113
208
  xmlns: "http://www.w3.org/2000/svg",
114
- children: /* @__PURE__ */ jsx("use", {
209
+ children: /* @__PURE__ */ jsx2("use", {
115
210
  href: `#${symbolId}`
116
211
  })
117
212
  });
118
213
  }
119
- function CopyGlyph({
120
- copied
121
- }) {
122
- return /* @__PURE__ */ jsx("svg", {
123
- "aria-hidden": "true",
124
- className: platformInstallClassName(["copyIcon"]),
125
- fill: "none",
126
- focusable: "false",
127
- stroke: "currentColor",
128
- strokeLinecap: "round",
129
- strokeLinejoin: "round",
130
- strokeWidth: 2,
131
- viewBox: "0 0 24 24",
132
- children: copied ? /* @__PURE__ */ jsx("path", {
133
- d: "M5 12.5l4.5 4.5L19 7.5"
134
- }) : /* @__PURE__ */ jsxs(Fragment, {
135
- children: [
136
- /* @__PURE__ */ jsx("rect", {
137
- height: "12",
138
- rx: "2",
139
- width: "12",
140
- x: "8",
141
- y: "8"
142
- }),
143
- /* @__PURE__ */ jsx("path", {
144
- d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"
145
- })
146
- ]
147
- })
148
- });
149
- }
150
214
  function CommandBlock({
151
215
  caption,
152
216
  command,
153
217
  copyKey,
154
218
  onCopy,
219
+ note,
155
220
  status,
156
221
  subject
157
222
  }) {
158
223
  const preRef = useRef(null);
159
224
  const state = status?.key === copyKey ? status.ok ? "copied" : "failed" : "idle";
160
- return /* @__PURE__ */ jsxs("div", {
225
+ return /* @__PURE__ */ jsxs2("div", {
161
226
  className: platformInstallClassName(["command"]),
162
227
  "data-copy-state": state,
163
228
  children: [
164
- /* @__PURE__ */ jsxs("div", {
229
+ /* @__PURE__ */ jsxs2("div", {
165
230
  className: platformInstallClassName(["commandBar", (caption === undefined || caption === "") && "commandBarEmpty"]),
166
231
  children: [
167
- /* @__PURE__ */ jsx("span", {
232
+ /* @__PURE__ */ jsx2("span", {
168
233
  className: platformInstallClassName(["shell"]),
169
234
  children: caption
170
235
  }),
171
- /* @__PURE__ */ jsxs("button", {
172
- className: platformInstallClassName(["copy"]),
173
- "data-copy-state": state,
174
- onClick: () => onCopy(copyKey, command, subject, preRef.current),
175
- type: "button",
176
- children: [
177
- /* @__PURE__ */ jsx(CopyGlyph, {
178
- copied: state === "copied"
179
- }),
180
- /* @__PURE__ */ jsx("span", {
181
- children: state === "copied" ? "Copied" : state === "failed" ? "Select to copy" : "Copy"
182
- }),
183
- /* @__PURE__ */ jsxs("span", {
184
- className: platformInstallClassName(["status"]),
185
- children: [
186
- " ",
187
- subject
188
- ]
189
- })
190
- ]
236
+ /* @__PURE__ */ jsx2(SetupCopyButton, {
237
+ className: "hraness-platform-install__copy",
238
+ iconClassName: "hraness-platform-install__copy-icon",
239
+ failedLabel: "Select to copy",
240
+ onCopy: () => onCopy(copyKey, command, subject, preRef.current),
241
+ state,
242
+ subject
191
243
  })
192
244
  ]
193
245
  }),
194
- /* @__PURE__ */ jsx("pre", {
246
+ /* @__PURE__ */ jsx2("pre", {
195
247
  "aria-label": subject,
196
248
  className: platformInstallClassName(["pre"]),
197
249
  ref: preRef,
198
250
  tabIndex: 0,
199
- children: /* @__PURE__ */ jsx(SyntaxCode, {
251
+ children: /* @__PURE__ */ jsx2(SyntaxCode, {
200
252
  className: platformInstallClassName(["code"]),
201
253
  code: command,
202
254
  language: "shell",
203
255
  styles: "classes"
204
256
  })
257
+ }),
258
+ note === undefined ? null : /* @__PURE__ */ jsx2("div", {
259
+ className: platformInstallClassName(["note", "commandNote"]),
260
+ children: note
205
261
  })
206
262
  ]
207
263
  });
@@ -286,25 +342,25 @@ function PlatformInstall({
286
342
  event.preventDefault();
287
343
  choose(target, true);
288
344
  };
289
- return /* @__PURE__ */ jsxs("div", {
345
+ return /* @__PURE__ */ jsxs2("div", {
290
346
  className: platformInstallClassName(["root"], className),
291
347
  "data-hraness-platform-install": "",
292
348
  "data-selected-platform": current,
293
349
  "data-selection-source": source,
294
350
  id,
295
351
  children: [
296
- /* @__PURE__ */ jsx(PlatformMarkSymbols, {
352
+ /* @__PURE__ */ jsx2(PlatformMarkSymbols, {
297
353
  ids,
298
354
  symbolId
299
355
  }),
300
- /* @__PURE__ */ jsx("div", {
356
+ /* @__PURE__ */ jsx2("div", {
301
357
  "aria-label": label,
302
358
  className: platformInstallClassName(["tablist"]),
303
359
  onKeyDown,
304
360
  role: "tablist",
305
361
  children: platforms.map((target) => {
306
362
  const isSelected = target.id === current;
307
- return /* @__PURE__ */ jsxs("button", {
363
+ return /* @__PURE__ */ jsxs2("button", {
308
364
  "aria-controls": `${baseId}-panel-${target.id}`,
309
365
  "aria-selected": isSelected,
310
366
  className: platformInstallClassName(["tab", isSelected && "tabSelected"]),
@@ -322,11 +378,11 @@ function PlatformInstall({
322
378
  tabIndex: isSelected ? 0 : -1,
323
379
  type: "button",
324
380
  children: [
325
- /* @__PURE__ */ jsx(PlatformMarkUse, {
381
+ /* @__PURE__ */ jsx2(PlatformMarkUse, {
326
382
  platform: target.id,
327
383
  symbolId: symbolId(target.id)
328
384
  }),
329
- /* @__PURE__ */ jsx("span", {
385
+ /* @__PURE__ */ jsx2("span", {
330
386
  className: platformInstallClassName(["tabLabel"]),
331
387
  children: labelOf(target)
332
388
  })
@@ -337,7 +393,7 @@ function PlatformInstall({
337
393
  platforms.map((target) => {
338
394
  const name = labelOf(target);
339
395
  const alternatives = target.alternatives ?? [];
340
- return /* @__PURE__ */ jsx("div", {
396
+ return /* @__PURE__ */ jsx2("div", {
341
397
  "aria-labelledby": `${baseId}-tab-${target.id}`,
342
398
  className: platformInstallClassName(["panel"]),
343
399
  "data-availability": target.unavailable === true ? "unavailable" : "available",
@@ -345,38 +401,39 @@ function PlatformInstall({
345
401
  hidden: target.id !== current,
346
402
  id: `${baseId}-panel-${target.id}`,
347
403
  role: "tabpanel",
348
- children: /* @__PURE__ */ jsxs("div", {
404
+ children: /* @__PURE__ */ jsxs2("div", {
349
405
  className: platformInstallClassName(["panelBody"]),
350
406
  children: [
351
- /* @__PURE__ */ jsxs("p", {
407
+ /* @__PURE__ */ jsxs2("p", {
352
408
  className: platformInstallClassName(["panelLabel"]),
353
409
  children: [
354
- /* @__PURE__ */ jsx(PlatformMarkUse, {
410
+ /* @__PURE__ */ jsx2(PlatformMarkUse, {
355
411
  platform: target.id,
356
412
  symbolId: symbolId(target.id)
357
413
  }),
358
- /* @__PURE__ */ jsx("span", {
414
+ /* @__PURE__ */ jsx2("span", {
359
415
  children: name
360
416
  })
361
417
  ]
362
418
  }),
363
- target.unavailable === true ? /* @__PURE__ */ jsx("div", {
419
+ target.unavailable === true ? /* @__PURE__ */ jsx2("div", {
364
420
  className: platformInstallClassName(["unavailable"]),
365
421
  children: target.unavailableNote
366
422
  }) : null,
367
- target.command === undefined ? null : /* @__PURE__ */ jsx(CommandBlock, {
423
+ target.command === undefined ? null : /* @__PURE__ */ jsx2(CommandBlock, {
368
424
  caption: target.shell,
369
425
  command: target.command,
370
426
  copyKey: `${target.id}:primary`,
371
427
  onCopy: copy,
428
+ note: target.note,
372
429
  status,
373
430
  subject: `${name} install command`
374
431
  }),
375
- alternatives.length === 0 ? null : /* @__PURE__ */ jsx("ul", {
432
+ alternatives.length === 0 ? null : /* @__PURE__ */ jsx2("ul", {
376
433
  "aria-label": `Other ways to install on ${name}`,
377
434
  className: platformInstallClassName(["alternatives"]),
378
- children: alternatives.map((alternative, index) => /* @__PURE__ */ jsx("li", {
379
- children: /* @__PURE__ */ jsx(CommandBlock, {
435
+ children: alternatives.map((alternative, index) => /* @__PURE__ */ jsx2("li", {
436
+ children: /* @__PURE__ */ jsx2(CommandBlock, {
380
437
  caption: [alternative.label, alternative.shell].filter(Boolean).join(" · "),
381
438
  command: alternative.command,
382
439
  copyKey: `${target.id}:${index}`,
@@ -386,7 +443,7 @@ function PlatformInstall({
386
443
  })
387
444
  }, `${alternative.label}-${index}`))
388
445
  }),
389
- target.note === undefined ? null : /* @__PURE__ */ jsx("div", {
446
+ target.command !== undefined || target.note === undefined ? null : /* @__PURE__ */ jsx2("div", {
390
447
  className: platformInstallClassName(["note"]),
391
448
  children: target.note
392
449
  })
@@ -394,7 +451,7 @@ function PlatformInstall({
394
451
  })
395
452
  }, target.id);
396
453
  }),
397
- /* @__PURE__ */ jsx("p", {
454
+ /* @__PURE__ */ jsx2("p", {
398
455
  "aria-live": "polite",
399
456
  className: platformInstallClassName(["status"]),
400
457
  role: "status",
@@ -404,4 +461,4 @@ function PlatformInstall({
404
461
  });
405
462
  }
406
463
 
407
- export { PlatformInstall };
464
+ export { SetupCopyButton, PlatformInstall };
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ import {
64
64
  themeFor,
65
65
  typeScale,
66
66
  typography
67
- } from "./chunk-c80g58j1.js";
67
+ } from "./chunk-fmeg5cxf.js";
68
68
  import {
69
69
  diagramMetrics
70
70
  } from "./chunk-gmea6p0d.js";