@typespec/playground 0.12.0-dev.6 → 0.12.0-dev.8

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,10 +1,10 @@
1
1
  import require$$0, { createContext, useContext, memo, useCallback, useRef, useEffect, useMemo, useState, useId as useId$1 } from 'react';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, TableHeader, TableRow, TableHeaderCell, TableBody, TableCell, Select, useId, Label, Checkbox, RadioGroup, Radio, Input, Switch, Divider, Dialog, DialogTrigger, ToolbarButton, DialogSurface, DialogBody, DialogTitle, DialogContent, Toolbar, Tooltip, Link, TabList, Tab, Button, useToastController, Toast, ToastTitle, ToastBody, Toaster, FluentProvider, webLightTheme } from '@fluentui/react-components';
3
+ import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, TableHeader, TableRow, TableHeaderCell, TableBody, TableCell, Select, tokens, Card, Text, Tooltip, ToolbarButton, OverlayDrawer, DrawerHeader, DrawerHeaderTitle, Button, DrawerBody, useId, Label, Checkbox, RadioGroup, Radio, Input, Switch, Divider, Dialog, DialogTrigger, DialogSurface, DialogBody, DialogTitle, DialogContent, Toolbar, Link, TabList, Tab, useToastController, Toast, ToastTitle, ToastBody, Toaster, FluentProvider, webLightTheme } from '@fluentui/react-components';
4
4
  import { getSourceLocation } from '@typespec/compiler';
5
5
  import { editor, Uri, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
6
6
  import { $ } from '@typespec/compiler/typekit';
7
- import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
7
+ import { DocumentBulletList24Regular, Dismiss24Regular, Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
8
8
  import debounce from 'debounce';
9
9
  import { CompletionItemTag } from 'vscode-languageserver';
10
10
  import { a as resolveVirtualPath, p as printDebugInfo, d as debugGlobals, g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage } from '../services-BTSPLy3C.js';
@@ -26,7 +26,7 @@ function usePlaygroundContext() {
26
26
 
27
27
  const list = "_list_wrnwm_1";
28
28
  const item$1 = "_item_wrnwm_4";
29
- const style$a = {
29
+ const style$b = {
30
30
  list: list,
31
31
  item: item$1,
32
32
  "item--error": "_item--error_wrnwm_15",
@@ -46,9 +46,9 @@ const DiagnosticList = ({
46
46
  [onDiagnosticSelected]
47
47
  );
48
48
  if (diagnostics.length === 0) {
49
- return /* @__PURE__ */ jsx("div", { className: style$a["list"], children: "No errors" });
49
+ return /* @__PURE__ */ jsx("div", { className: style$b["list"], children: "No errors" });
50
50
  }
51
- return /* @__PURE__ */ jsx("div", { className: style$a["list"], children: diagnostics.map((x, i) => {
51
+ return /* @__PURE__ */ jsx("div", { className: style$b["list"], children: diagnostics.map((x, i) => {
52
52
  return /* @__PURE__ */ jsx(DiagnosticItem, { diagnostic: x, onItemSelected: handleItemSelected }, i);
53
53
  }) });
54
54
  };
@@ -56,19 +56,19 @@ const DiagnosticItem = ({ diagnostic, onItemSelected }) => {
56
56
  const handleClick = useCallback(() => {
57
57
  onItemSelected(diagnostic);
58
58
  }, [diagnostic, onItemSelected]);
59
- return /* @__PURE__ */ jsxs("div", { tabIndex: 0, className: style$a["item"], onClick: handleClick, children: [
59
+ return /* @__PURE__ */ jsxs("div", { tabIndex: 0, className: style$b["item"], onClick: handleClick, children: [
60
60
  /* @__PURE__ */ jsx(
61
61
  "div",
62
62
  {
63
63
  className: mergeClasses(
64
- (style$a[diagnostic.severity === "error" ? "item--error" : "item--warning"])
64
+ (style$b[diagnostic.severity === "error" ? "item--error" : "item--warning"])
65
65
  ),
66
66
  children: diagnostic.severity
67
67
  }
68
68
  ),
69
- /* @__PURE__ */ jsx("div", { className: style$a["item-code"], children: diagnostic.code }),
70
- /* @__PURE__ */ jsx("div", { className: style$a["item-message"], children: diagnostic.message }),
71
- /* @__PURE__ */ jsx("div", { className: style$a["item-loc"], children: /* @__PURE__ */ jsx(DiagnosticTargetLink, { target: diagnostic.target }) })
69
+ /* @__PURE__ */ jsx("div", { className: style$b["item-code"], children: diagnostic.code }),
70
+ /* @__PURE__ */ jsx("div", { className: style$b["item-message"], children: diagnostic.message }),
71
+ /* @__PURE__ */ jsx("div", { className: style$b["item-loc"], children: /* @__PURE__ */ jsx(DiagnosticTargetLink, { target: diagnostic.target }) })
72
72
  ] });
73
73
  };
74
74
  const DiagnosticTargetLink = memo(({ target }) => {
@@ -133,18 +133,18 @@ function useMonacoModel(uri, language) {
133
133
  }
134
134
 
135
135
  const footer = "_footer_e6dic_1";
136
- const style$9 = {
136
+ const style$a = {
137
137
  footer: footer,
138
138
  "footer-item": "_footer-item_e6dic_9"
139
139
  };
140
140
 
141
141
  const FooterItem = ({ children, link, className }) => {
142
- const resolvedClassName = mergeClasses(style$9["footer-item"], className);
142
+ const resolvedClassName = mergeClasses(style$a["footer-item"], className);
143
143
  return link ? /* @__PURE__ */ jsx("a", { className: resolvedClassName, href: link, target: "_blank", rel: "noopener noreferrer", children }) : /* @__PURE__ */ jsx("div", { className: resolvedClassName, children });
144
144
  };
145
145
 
146
146
  const button = "_button_1c15n_4";
147
- const style$8 = {
147
+ const style$9 = {
148
148
  "version-item": "_version-item_1c15n_1",
149
149
  button: button
150
150
  };
@@ -153,8 +153,8 @@ const FooterVersionItem = memo(({ versionSelector }) => {
153
153
  const { host } = usePlaygroundContext();
154
154
  const latest = versionSelector?.latest;
155
155
  const selected = versionSelector?.selected ?? host.compiler.MANIFEST.version;
156
- return /* @__PURE__ */ jsx(FooterItem, { className: style$8["version-item"], children: /* @__PURE__ */ jsxs(Popover, { children: [
157
- /* @__PURE__ */ jsx(PopoverTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsxs("div", { className: style$8["button"], children: [
156
+ return /* @__PURE__ */ jsx(FooterItem, { className: style$9["version-item"], children: /* @__PURE__ */ jsxs(Popover, { children: [
157
+ /* @__PURE__ */ jsx(PopoverTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsxs("div", { className: style$9["button"], children: [
158
158
  /* @__PURE__ */ jsx("span", { children: "Version " }),
159
159
  /* @__PURE__ */ jsx("span", { children: selected }),
160
160
  /* @__PURE__ */ jsx("span", { children: latest ? latest === selected ? " (latest)" : " (old)" : "" })
@@ -200,7 +200,7 @@ const VersionSelector = memo(({ versions, selected, latest, onChange }) => {
200
200
  });
201
201
 
202
202
  const Footer = ({ className, children }) => {
203
- return /* @__PURE__ */ jsx("div", { className: mergeClasses(style$9.footer, className), children });
203
+ return /* @__PURE__ */ jsx("div", { className: mergeClasses(style$a.footer, className), children });
204
204
  };
205
205
 
206
206
  function useControllableValue(controlledValue, defaultUncontrolledValue, onChange) {
@@ -988,35 +988,174 @@ const EmitterDropdown = ({
988
988
  );
989
989
  };
990
990
 
991
- const SamplesDropdown = ({
991
+ const style$8 = {
992
+ "samples-grid": "_samples-grid_1dkte_1",
993
+ "sample-card": "_sample-card_1dkte_8",
994
+ "sample-card-content": "_sample-card-content_1dkte_26",
995
+ "sample-card-text": "_sample-card-text_1dkte_32",
996
+ "sample-icon": "_sample-icon_1dkte_40",
997
+ "sample-icon-pattern": "_sample-icon-pattern_1dkte_53",
998
+ "sample-icon-initials": "_sample-icon-initials_1dkte_59",
999
+ "sample-title": "_sample-title_1dkte_66",
1000
+ "sample-description": "_sample-description_1dkte_71"
1001
+ };
1002
+
1003
+ function hashString(str) {
1004
+ let hash = 0;
1005
+ for (let i = 0; i < str.length; i++) {
1006
+ const char = str.charCodeAt(i);
1007
+ hash = (hash << 5) - hash + char;
1008
+ hash = hash & hash;
1009
+ }
1010
+ return Math.abs(hash);
1011
+ }
1012
+ const iconColors = [
1013
+ { bg: tokens.colorPaletteBlueBackground2, fg: tokens.colorPaletteBlueForeground2 },
1014
+ { bg: tokens.colorPaletteGrapeBackground2, fg: tokens.colorPaletteGrapeForeground2 },
1015
+ { bg: tokens.colorPaletteForestBackground2, fg: tokens.colorPaletteForestForeground2 },
1016
+ { bg: tokens.colorPalettePumpkinBackground2, fg: tokens.colorPalettePumpkinForeground2 },
1017
+ { bg: tokens.colorPaletteMagentaBackground2, fg: tokens.colorPaletteMagentaForeground2 },
1018
+ { bg: tokens.colorPaletteTealBackground2, fg: tokens.colorPaletteTealForeground2 },
1019
+ { bg: tokens.colorPaletteGoldBackground2, fg: tokens.colorPaletteGoldForeground2 },
1020
+ { bg: tokens.colorPalettePlumBackground2, fg: tokens.colorPalettePlumForeground2 },
1021
+ { bg: tokens.colorPaletteLavenderBackground2, fg: tokens.colorPaletteLavenderForeground2 },
1022
+ { bg: tokens.colorPaletteSteelBackground2, fg: tokens.colorPaletteSteelForeground2 }
1023
+ ];
1024
+ const patterns = ["circle", "squares", "triangle", "hexagon", "diamond"];
1025
+ const SampleIcon = ({ name }) => {
1026
+ const { colors, pattern, initials } = useMemo(() => {
1027
+ const hash = hashString(name);
1028
+ const colorIndex = hash % iconColors.length;
1029
+ const patternIndex = (hash >> 4) % patterns.length;
1030
+ const words = name.split(/\s+/);
1031
+ const init = words.length >= 2 ? (words[0][0] + words[1][0]).toUpperCase() : name.slice(0, 2).toUpperCase();
1032
+ return {
1033
+ colors: iconColors[colorIndex],
1034
+ pattern: patterns[patternIndex],
1035
+ initials: init
1036
+ };
1037
+ }, [name]);
1038
+ const renderPattern = () => {
1039
+ const size = 48;
1040
+ const half = size / 2;
1041
+ switch (pattern) {
1042
+ case "circle":
1043
+ return /* @__PURE__ */ jsx("circle", { cx: half, cy: half, r: half - 4, fill: colors.fg, opacity: 0.15 });
1044
+ case "squares":
1045
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1046
+ /* @__PURE__ */ jsx("rect", { x: 4, y: 4, width: 16, height: 16, fill: colors.fg, opacity: 0.1 }),
1047
+ /* @__PURE__ */ jsx("rect", { x: 28, y: 28, width: 16, height: 16, fill: colors.fg, opacity: 0.15 })
1048
+ ] });
1049
+ case "triangle":
1050
+ return /* @__PURE__ */ jsx(
1051
+ "polygon",
1052
+ {
1053
+ points: `${half},8 ${size - 8},${size - 8} 8,${size - 8}`,
1054
+ fill: colors.fg,
1055
+ opacity: 0.12
1056
+ }
1057
+ );
1058
+ case "hexagon":
1059
+ return /* @__PURE__ */ jsx(
1060
+ "polygon",
1061
+ {
1062
+ points: `${half},4 ${size - 6},${half / 2 + 4} ${size - 6},${size - half / 2 - 4} ${half},${size - 4} 6,${size - half / 2 - 4} 6,${half / 2 + 4}`,
1063
+ fill: colors.fg,
1064
+ opacity: 0.12
1065
+ }
1066
+ );
1067
+ case "diamond":
1068
+ return /* @__PURE__ */ jsx(
1069
+ "polygon",
1070
+ {
1071
+ points: `${half},6 ${size - 6},${half} ${half},${size - 6} 6,${half}`,
1072
+ fill: colors.fg,
1073
+ opacity: 0.12
1074
+ }
1075
+ );
1076
+ }
1077
+ };
1078
+ return /* @__PURE__ */ jsxs("div", { className: style$8["sample-icon"], style: { backgroundColor: colors.bg }, "aria-hidden": "true", children: [
1079
+ /* @__PURE__ */ jsx("svg", { width: "48", height: "48", viewBox: "0 0 48 48", className: style$8["sample-icon-pattern"], children: renderPattern() }),
1080
+ /* @__PURE__ */ jsx("span", { className: style$8["sample-icon-initials"], style: { color: colors.fg }, children: initials })
1081
+ ] });
1082
+ };
1083
+
1084
+ const SampleCard = ({ name, sample, onSelect }) => {
1085
+ return /* @__PURE__ */ jsx(
1086
+ Card,
1087
+ {
1088
+ className: style$8["sample-card"],
1089
+ onClick: () => onSelect(name),
1090
+ role: "button",
1091
+ tabIndex: 0,
1092
+ onKeyDown: (e) => {
1093
+ if (e.key === "Enter" || e.key === " ") {
1094
+ e.preventDefault();
1095
+ onSelect(name);
1096
+ }
1097
+ },
1098
+ children: /* @__PURE__ */ jsxs("div", { className: style$8["sample-card-content"], children: [
1099
+ /* @__PURE__ */ jsx(SampleIcon, { name }),
1100
+ /* @__PURE__ */ jsxs("div", { className: style$8["sample-card-text"], children: [
1101
+ /* @__PURE__ */ jsx(Text, { as: "h3", weight: "semibold", className: style$8["sample-title"], children: name }),
1102
+ sample.description && /* @__PURE__ */ jsx(Text, { as: "p", className: style$8["sample-description"], children: sample.description })
1103
+ ] })
1104
+ ] })
1105
+ }
1106
+ );
1107
+ };
1108
+
1109
+ const SamplesDrawerTrigger = ({
992
1110
  samples,
993
- selectedSampleName,
994
1111
  onSelectedSampleNameChange
995
1112
  }) => {
996
- const options = Object.keys(samples).map((sample) => {
997
- return /* @__PURE__ */ jsx("option", { children: sample }, sample);
998
- });
999
- const handleSelected = useCallback(
1000
- (evt) => {
1001
- if (samples[evt.target.value]) {
1002
- onSelectedSampleNameChange(evt.target.value);
1003
- }
1113
+ const [isOpen, setIsOpen] = useState(false);
1114
+ const handleSampleSelect = useCallback(
1115
+ (sampleName) => {
1116
+ onSelectedSampleNameChange(sampleName);
1117
+ setIsOpen(false);
1004
1118
  },
1005
- [onSelectedSampleNameChange, samples]
1006
- );
1007
- return /* @__PURE__ */ jsxs(
1008
- Select,
1009
- {
1010
- className: "sample-dropdown",
1011
- onChange: handleSelected,
1012
- value: selectedSampleName ?? "",
1013
- "aria-label": "Select a sample",
1014
- children: [
1015
- /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select sample..." }),
1016
- options
1017
- ]
1018
- }
1119
+ [onSelectedSampleNameChange]
1019
1120
  );
1121
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1122
+ /* @__PURE__ */ jsx(Tooltip, { content: "Browse samples", relationship: "description", withArrow: true, children: /* @__PURE__ */ jsx(
1123
+ ToolbarButton,
1124
+ {
1125
+ "aria-label": "Browse samples",
1126
+ icon: /* @__PURE__ */ jsx(DocumentBulletList24Regular, {}),
1127
+ onClick: () => setIsOpen(true),
1128
+ children: "Samples"
1129
+ }
1130
+ ) }),
1131
+ /* @__PURE__ */ jsxs(
1132
+ OverlayDrawer,
1133
+ {
1134
+ open: isOpen,
1135
+ onOpenChange: (_, data) => setIsOpen(data.open),
1136
+ position: "end",
1137
+ size: "large",
1138
+ children: [
1139
+ /* @__PURE__ */ jsx(DrawerHeader, { children: /* @__PURE__ */ jsx(
1140
+ DrawerHeaderTitle,
1141
+ {
1142
+ action: /* @__PURE__ */ jsx(
1143
+ Button,
1144
+ {
1145
+ appearance: "subtle",
1146
+ "aria-label": "Close",
1147
+ icon: /* @__PURE__ */ jsx(Dismiss24Regular, {}),
1148
+ onClick: () => setIsOpen(false)
1149
+ }
1150
+ ),
1151
+ children: "Sample Gallery"
1152
+ }
1153
+ ) }),
1154
+ /* @__PURE__ */ jsx(DrawerBody, { children: /* @__PURE__ */ jsx("div", { className: style$8["samples-grid"], children: Object.entries(samples).map(([name, sample]) => /* @__PURE__ */ jsx(SampleCard, { name, sample, onSelect: handleSampleSelect }, name)) }) })
1155
+ ]
1156
+ }
1157
+ )
1158
+ ] });
1020
1159
  };
1021
1160
 
1022
1161
  const form = "_form_sqeas_1";
@@ -1305,10 +1444,9 @@ const EditorCommandBar = ({
1305
1444
  /* @__PURE__ */ jsx(Tooltip, { content: "Format", relationship: "description", withArrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { "aria-label": "Format", icon: /* @__PURE__ */ jsx(Broom16Filled, {}), onClick: formatCode }) }),
1306
1445
  samples && /* @__PURE__ */ jsxs(Fragment, { children: [
1307
1446
  /* @__PURE__ */ jsx(
1308
- SamplesDropdown,
1447
+ SamplesDrawerTrigger,
1309
1448
  {
1310
1449
  samples,
1311
- selectedSampleName,
1312
1450
  onSelectedSampleNameChange
1313
1451
  }
1314
1452
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"editor-command-bar.d.ts","sourceRoot":"","sources":["../../../src/editor-command-bar/editor-command-bar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,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C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,eAAe,EAAE,eAAe,CAAC;IACjC,uBAAuB,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAE5D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AACD,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CA0ErE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { SamplesDrawerTrigger, type SamplesDrawerProps } from './samples-drawer-trigger.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { PlaygroundSample } from '../../types.js';
3
+ export interface SampleCardProps {
4
+ name: string;
5
+ sample: PlaygroundSample;
6
+ onSelect: (name: string) => void;
7
+ }
8
+ export declare const SampleCard: FunctionComponent<SampleCardProps>;
9
+ //# sourceMappingURL=sample-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample-card.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/sample-card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CA6BzD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { FunctionComponent } from 'react';
2
+ export interface SampleIconProps {
3
+ name: string;
4
+ }
5
+ export declare const SampleIcon: FunctionComponent<SampleIconProps>;
6
+ //# sourceMappingURL=sample-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample-icon.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/sample-icon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAgCxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAqEzD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { PlaygroundSample } from '../../types.js';
3
+ export interface SamplesDrawerProps {
4
+ samples: Record<string, PlaygroundSample>;
5
+ onSelectedSampleNameChange: (sampleName: string) => void;
6
+ }
7
+ export declare const SamplesDrawerTrigger: FunctionComponent<SamplesDrawerProps>;
8
+ //# sourceMappingURL=samples-drawer-trigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"samples-drawer-trigger.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/samples-drawer-trigger.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,kBAAkB,CAwDtE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tooling/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,iBAyBhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tooling/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,iBA0BhD"}
@@ -3,6 +3,10 @@ export interface PlaygroundSample {
3
3
  filename: string;
4
4
  preferredEmitter?: string;
5
5
  content: string;
6
+ /**
7
+ * A short description of what this sample demonstrates.
8
+ */
9
+ description?: string;
6
10
  /**
7
11
  * Compiler options for the sample.
8
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAC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,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,QAAQ,EAAE,cAAc,oBAAoB,CAAC,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CACjD"}
package/dist/style.css CHANGED
@@ -175,6 +175,82 @@
175
175
  ._tree-row_16t0l_4 ._column_16t0l_44:last-child {
176
176
  margin-right: 5px;
177
177
  }
178
+ ._samples-grid_1dkte_1 {
179
+ display: grid;
180
+ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
181
+ gap: 16px;
182
+ padding: 8px 0;
183
+ }
184
+
185
+ ._sample-card_1dkte_8 {
186
+ cursor: pointer;
187
+ padding: 16px;
188
+ transition:
189
+ box-shadow 0.2s ease,
190
+ border-color 0.2s ease;
191
+ min-height: 100px;
192
+ }
193
+
194
+ ._sample-card_1dkte_8:hover {
195
+ box-shadow: var(--shadow8);
196
+ }
197
+
198
+ ._sample-card_1dkte_8:focus-visible {
199
+ outline: 2px solid var(--colorBrandStroke1);
200
+ outline-offset: 2px;
201
+ }
202
+
203
+ ._sample-card-content_1dkte_26 {
204
+ display: flex;
205
+ gap: 16px;
206
+ align-items: flex-start;
207
+ }
208
+
209
+ ._sample-card-text_1dkte_32 {
210
+ display: flex;
211
+ flex-direction: column;
212
+ gap: 4px;
213
+ flex: 1;
214
+ min-width: 0;
215
+ }
216
+
217
+ ._sample-icon_1dkte_40 {
218
+ width: 48px;
219
+ height: 48px;
220
+ border-radius: 8px;
221
+ flex-shrink: 0;
222
+ position: relative;
223
+ display: flex;
224
+ align-items: center;
225
+ justify-content: center;
226
+ overflow: hidden;
227
+ user-select: none;
228
+ }
229
+
230
+ ._sample-icon-pattern_1dkte_53 {
231
+ position: absolute;
232
+ top: 0;
233
+ left: 0;
234
+ }
235
+
236
+ ._sample-icon-initials_1dkte_59 {
237
+ position: relative;
238
+ font-size: 16px;
239
+ font-weight: 600;
240
+ z-index: 1;
241
+ }
242
+
243
+ ._sample-title_1dkte_66 {
244
+ font-size: var(--fontSizeBase400);
245
+ margin: 0;
246
+ }
247
+
248
+ ._sample-description_1dkte_71 {
249
+ font-size: var(--fontSizeBase200);
250
+ color: var(--colorNeutralForeground2);
251
+ margin: 0;
252
+ line-height: 1.4;
253
+ }
178
254
  ._form_sqeas_1 {
179
255
  display: flex;
180
256
  flex-direction: column;
@@ -9,6 +9,7 @@ async function buildSamples_experimental(rootDir, output, samples) {
9
9
  filename: config.filename,
10
10
  content,
11
11
  preferredEmitter: config.preferredEmitter,
12
+ description: config.description,
12
13
  compilerOptions: config.compilerOptions
13
14
  };
14
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/playground",
3
- "version": "0.12.0-dev.6",
3
+ "version": "0.12.0-dev.8",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec playground UI components.",
6
6
  "homepage": "https://typespec.io",
@@ -1,9 +0,0 @@
1
- import { FunctionComponent } from 'react';
2
- import { PlaygroundSample } from '../types.js';
3
- export interface SamplesDropdownProps {
4
- samples: Record<string, PlaygroundSample>;
5
- selectedSampleName: string;
6
- onSelectedSampleNameChange: (sampleName: string) => void;
7
- }
8
- export declare const SamplesDropdown: FunctionComponent<SamplesDropdownProps>;
9
- //# sourceMappingURL=samples-dropdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"samples-dropdown.d.ts","sourceRoot":"","sources":["../../../src/react/samples-dropdown.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,CA8BnE,CAAC"}