@typespec/playground 0.14.0-dev.7 → 0.14.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.
package/dist/react/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getSourceLocation } from "@typespec/compiler";
|
|
|
4
4
|
import { KeyCode, KeyMod, MarkerSeverity, Uri, editor } from "monaco-editor";
|
|
5
5
|
import { CompletionItemTag } from "vscode-languageserver";
|
|
6
6
|
import { Fragment, createContext, memo, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
7
|
-
import { Button, Card, Checkbox, DrawerBody, DrawerHeader, DrawerHeaderTitle, FluentProvider, Input, Label, Menu, MenuDivider, MenuItem, MenuList, MenuPopover, MenuTrigger, OverlayDrawer, Popover, PopoverSurface, PopoverTrigger, Radio, RadioGroup, Select, Subtitle2, Switch, Tab, TabList, Table, TableBody, TableCell, TableHeader, TableHeaderCell, TableRow, Text, Title3, Toast, ToastBody, ToastTitle, Toaster, Toolbar, ToolbarButton, Tooltip, mergeClasses, tokens, useId as useId$1, useToastController, webLightTheme } from "@fluentui/react-components";
|
|
7
|
+
import { Button, Card, Checkbox, DrawerBody, DrawerHeader, DrawerHeaderTitle, FluentProvider, Input, Label, Menu, MenuDivider, MenuItem, MenuList, MenuPopover, MenuTrigger, OverlayDrawer, Popover, PopoverSurface, PopoverTrigger, Radio, RadioGroup, SearchBox, Select, Subtitle2, Switch, Tab, TabList, Table, TableBody, TableCell, TableHeader, TableHeaderCell, TableRow, Text, Title3, Toast, ToastBody, ToastTitle, Toaster, Toolbar, ToolbarButton, Tooltip, mergeClasses, tokens, useId as useId$1, useToastController, webLightTheme } from "@fluentui/react-components";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { $ } from "@typespec/compiler/typekit";
|
|
10
10
|
import { Broom16Filled, Bug16Regular, Checkmark16Regular, ChevronDown16Regular, ChevronDownRegular, ChevronRightRegular, DataLineRegular, Dismiss24Regular, DocumentBulletList24Regular, DocumentRegular, ErrorCircle16Filled, FolderListRegular, FolderRegular, MoreHorizontal24Filled, Save16Regular, SettingsRegular, Warning16Filled } from "@fluentui/react-icons";
|
|
@@ -850,15 +850,20 @@ var MenuItemRenderer = ({ item }) => {
|
|
|
850
850
|
//#endregion
|
|
851
851
|
//#region src/react/samples-drawer/samples-drawer.module.css
|
|
852
852
|
var samples_drawer_module_default = {
|
|
853
|
-
"samples-
|
|
854
|
-
"
|
|
855
|
-
"
|
|
856
|
-
"
|
|
857
|
-
"
|
|
858
|
-
"
|
|
859
|
-
"sample-
|
|
860
|
-
"sample-
|
|
861
|
-
"sample-
|
|
853
|
+
"samples-search": "_samples-search_103tj_1",
|
|
854
|
+
"search-input": "_search-input_103tj_9",
|
|
855
|
+
"samples-category": "_samples-category_103tj_13",
|
|
856
|
+
"category-title": "_category-title_103tj_17",
|
|
857
|
+
"samples-empty": "_samples-empty_103tj_23",
|
|
858
|
+
"samples-grid": "_samples-grid_103tj_30",
|
|
859
|
+
"sample-card": "_sample-card_103tj_37",
|
|
860
|
+
"sample-card-content": "_sample-card-content_103tj_55",
|
|
861
|
+
"sample-card-text": "_sample-card-text_103tj_61",
|
|
862
|
+
"sample-icon": "_sample-icon_103tj_69",
|
|
863
|
+
"sample-icon-pattern": "_sample-icon-pattern_103tj_82",
|
|
864
|
+
"sample-icon-initials": "_sample-icon-initials_103tj_88",
|
|
865
|
+
"sample-title": "_sample-title_103tj_95",
|
|
866
|
+
"sample-description": "_sample-description_103tj_100"
|
|
862
867
|
};
|
|
863
868
|
//#endregion
|
|
864
869
|
//#region src/react/samples-drawer/sample-icon.tsx
|
|
@@ -1029,15 +1034,45 @@ var SampleCard = ({ name, sample, onSelect }) => {
|
|
|
1029
1034
|
};
|
|
1030
1035
|
//#endregion
|
|
1031
1036
|
//#region src/react/samples-drawer/samples-drawer-trigger.tsx
|
|
1037
|
+
function groupAndFilterSamples(samples, searchQuery) {
|
|
1038
|
+
const query = searchQuery.toLowerCase().trim();
|
|
1039
|
+
const categoryMap = /* @__PURE__ */ new Map();
|
|
1040
|
+
for (const [name, sample] of Object.entries(samples)) {
|
|
1041
|
+
if (query) {
|
|
1042
|
+
const matchesName = name.toLowerCase().includes(query);
|
|
1043
|
+
const matchesDescription = sample.description?.toLowerCase().includes(query);
|
|
1044
|
+
const matchesCategory = sample.category?.toLowerCase().includes(query);
|
|
1045
|
+
if (!matchesName && !matchesDescription && !matchesCategory) continue;
|
|
1046
|
+
}
|
|
1047
|
+
const category = sample.category ?? "Other";
|
|
1048
|
+
let entries = categoryMap.get(category);
|
|
1049
|
+
if (!entries) {
|
|
1050
|
+
entries = [];
|
|
1051
|
+
categoryMap.set(category, entries);
|
|
1052
|
+
}
|
|
1053
|
+
entries.push([name, sample]);
|
|
1054
|
+
}
|
|
1055
|
+
return Array.from(categoryMap.entries()).map(([name, entries]) => ({
|
|
1056
|
+
name,
|
|
1057
|
+
entries
|
|
1058
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
1059
|
+
}
|
|
1032
1060
|
/** The overlay drawer showing the sample gallery. Controlled via open/onOpenChange. */
|
|
1033
1061
|
var SamplesDrawerOverlay = ({ samples, onSelectedSampleNameChange, open, onOpenChange }) => {
|
|
1062
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
1034
1063
|
const handleSampleSelect = useCallback((sampleName) => {
|
|
1035
1064
|
onSelectedSampleNameChange(sampleName);
|
|
1036
1065
|
onOpenChange(false);
|
|
1037
1066
|
}, [onSelectedSampleNameChange, onOpenChange]);
|
|
1067
|
+
const categories = useMemo(() => groupAndFilterSamples(samples, searchQuery), [samples, searchQuery]);
|
|
1068
|
+
const hasCategories = useMemo(() => Object.values(samples).some((s) => s.category), [samples]);
|
|
1069
|
+
const totalFiltered = useMemo(() => categories.reduce((sum, c) => sum + c.entries.length, 0), [categories]);
|
|
1038
1070
|
return /* @__PURE__ */ jsxs(OverlayDrawer, {
|
|
1039
1071
|
open,
|
|
1040
|
-
onOpenChange: (_, data) =>
|
|
1072
|
+
onOpenChange: (_, data) => {
|
|
1073
|
+
onOpenChange(data.open);
|
|
1074
|
+
if (!data.open) setSearchQuery("");
|
|
1075
|
+
},
|
|
1041
1076
|
position: "end",
|
|
1042
1077
|
size: "large",
|
|
1043
1078
|
children: [/* @__PURE__ */ jsx(DrawerHeader, { children: /* @__PURE__ */ jsx(DrawerHeaderTitle, {
|
|
@@ -1048,14 +1083,40 @@ var SamplesDrawerOverlay = ({ samples, onSelectedSampleNameChange, open, onOpenC
|
|
|
1048
1083
|
onClick: () => onOpenChange(false)
|
|
1049
1084
|
}),
|
|
1050
1085
|
children: "Sample Gallery"
|
|
1051
|
-
}) }), /* @__PURE__ */
|
|
1086
|
+
}) }), /* @__PURE__ */ jsxs(DrawerBody, { children: [/* @__PURE__ */ jsx("div", {
|
|
1087
|
+
className: samples_drawer_module_default["samples-search"],
|
|
1088
|
+
children: /* @__PURE__ */ jsx(SearchBox, {
|
|
1089
|
+
placeholder: "Search samples...",
|
|
1090
|
+
value: searchQuery,
|
|
1091
|
+
onChange: (_, data) => setSearchQuery(data.value),
|
|
1092
|
+
className: samples_drawer_module_default["search-input"]
|
|
1093
|
+
})
|
|
1094
|
+
}), totalFiltered === 0 ? /* @__PURE__ */ jsx("div", {
|
|
1095
|
+
className: samples_drawer_module_default["samples-empty"],
|
|
1096
|
+
children: /* @__PURE__ */ jsx(Text, { children: "No samples match your search." })
|
|
1097
|
+
}) : hasCategories ? categories.map((category) => /* @__PURE__ */ jsxs("div", {
|
|
1098
|
+
className: samples_drawer_module_default["samples-category"],
|
|
1099
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
1100
|
+
as: "h3",
|
|
1101
|
+
weight: "semibold",
|
|
1102
|
+
className: samples_drawer_module_default["category-title"],
|
|
1103
|
+
children: category.name
|
|
1104
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1105
|
+
className: samples_drawer_module_default["samples-grid"],
|
|
1106
|
+
children: category.entries.map(([name, sample]) => /* @__PURE__ */ jsx(SampleCard, {
|
|
1107
|
+
name,
|
|
1108
|
+
sample,
|
|
1109
|
+
onSelect: handleSampleSelect
|
|
1110
|
+
}, name))
|
|
1111
|
+
})]
|
|
1112
|
+
}, category.name)) : /* @__PURE__ */ jsx("div", {
|
|
1052
1113
|
className: samples_drawer_module_default["samples-grid"],
|
|
1053
|
-
children:
|
|
1114
|
+
children: categories.flatMap((c) => c.entries.map(([name, sample]) => /* @__PURE__ */ jsx(SampleCard, {
|
|
1054
1115
|
name,
|
|
1055
1116
|
sample,
|
|
1056
1117
|
onSelect: handleSampleSelect
|
|
1057
|
-
}, name))
|
|
1058
|
-
}) })]
|
|
1118
|
+
}, name)))
|
|
1119
|
+
})] })]
|
|
1059
1120
|
});
|
|
1060
1121
|
};
|
|
1061
1122
|
/** Toolbar button trigger + overlay drawer for samples. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"samples-drawer-trigger.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/samples-drawer-trigger.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"samples-drawer-trigger.d.ts","sourceRoot":"","sources":["../../../../src/react/samples-drawer/samples-drawer-trigger.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAkC,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/E,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,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAoCD,uFAAuF;AACvF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,yBAAyB,CA8F7E,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,kBAAkB,CA0BtE,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export interface PlaygroundSample {
|
|
|
7
7
|
* A short description of what this sample demonstrates.
|
|
8
8
|
*/
|
|
9
9
|
description?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Category for grouping samples in the sample gallery.
|
|
12
|
+
*/
|
|
13
|
+
category?: string;
|
|
10
14
|
/**
|
|
11
15
|
* Compiler options for the sample.
|
|
12
16
|
*/
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,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"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,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
|
@@ -182,14 +182,43 @@
|
|
|
182
182
|
._divider_1gurd_5 {
|
|
183
183
|
flex: 1;
|
|
184
184
|
}
|
|
185
|
-
._samples-
|
|
185
|
+
._samples-search_103tj_1 {
|
|
186
|
+
padding: 0 0 16px 0;
|
|
187
|
+
position: sticky;
|
|
188
|
+
top: 0;
|
|
189
|
+
z-index: 1;
|
|
190
|
+
background: var(--colorNeutralBackground1);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
._search-input_103tj_9 {
|
|
194
|
+
width: 100%;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
._samples-category_103tj_13 {
|
|
198
|
+
margin-bottom: 24px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
._category-title_103tj_17 {
|
|
202
|
+
font-size: var(--fontSizeBase400);
|
|
203
|
+
margin: 0 0 12px 0;
|
|
204
|
+
color: var(--colorNeutralForeground1);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
._samples-empty_103tj_23 {
|
|
208
|
+
display: flex;
|
|
209
|
+
justify-content: center;
|
|
210
|
+
padding: 48px 16px;
|
|
211
|
+
color: var(--colorNeutralForeground3);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
._samples-grid_103tj_30 {
|
|
186
215
|
display: grid;
|
|
187
216
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
188
217
|
gap: 16px;
|
|
189
218
|
padding: 8px 0;
|
|
190
219
|
}
|
|
191
220
|
|
|
192
|
-
._sample-
|
|
221
|
+
._sample-card_103tj_37 {
|
|
193
222
|
cursor: pointer;
|
|
194
223
|
padding: 16px;
|
|
195
224
|
transition:
|
|
@@ -198,22 +227,22 @@
|
|
|
198
227
|
min-height: 100px;
|
|
199
228
|
}
|
|
200
229
|
|
|
201
|
-
._sample-
|
|
230
|
+
._sample-card_103tj_37:hover {
|
|
202
231
|
box-shadow: var(--shadow8);
|
|
203
232
|
}
|
|
204
233
|
|
|
205
|
-
._sample-
|
|
234
|
+
._sample-card_103tj_37:focus-visible {
|
|
206
235
|
outline: 2px solid var(--colorBrandStroke1);
|
|
207
236
|
outline-offset: 2px;
|
|
208
237
|
}
|
|
209
238
|
|
|
210
|
-
._sample-card-
|
|
239
|
+
._sample-card-content_103tj_55 {
|
|
211
240
|
display: flex;
|
|
212
241
|
gap: 16px;
|
|
213
242
|
align-items: flex-start;
|
|
214
243
|
}
|
|
215
244
|
|
|
216
|
-
._sample-card-
|
|
245
|
+
._sample-card-text_103tj_61 {
|
|
217
246
|
display: flex;
|
|
218
247
|
flex-direction: column;
|
|
219
248
|
gap: 4px;
|
|
@@ -221,7 +250,7 @@
|
|
|
221
250
|
min-width: 0;
|
|
222
251
|
}
|
|
223
252
|
|
|
224
|
-
._sample-
|
|
253
|
+
._sample-icon_103tj_69 {
|
|
225
254
|
width: 48px;
|
|
226
255
|
height: 48px;
|
|
227
256
|
border-radius: 8px;
|
|
@@ -234,25 +263,25 @@
|
|
|
234
263
|
user-select: none;
|
|
235
264
|
}
|
|
236
265
|
|
|
237
|
-
._sample-icon-
|
|
266
|
+
._sample-icon-pattern_103tj_82 {
|
|
238
267
|
position: absolute;
|
|
239
268
|
top: 0;
|
|
240
269
|
left: 0;
|
|
241
270
|
}
|
|
242
271
|
|
|
243
|
-
._sample-icon-
|
|
272
|
+
._sample-icon-initials_103tj_88 {
|
|
244
273
|
position: relative;
|
|
245
274
|
font-size: 16px;
|
|
246
275
|
font-weight: 600;
|
|
247
276
|
z-index: 1;
|
|
248
277
|
}
|
|
249
278
|
|
|
250
|
-
._sample-
|
|
279
|
+
._sample-title_103tj_95 {
|
|
251
280
|
font-size: var(--fontSizeBase400);
|
|
252
281
|
margin: 0;
|
|
253
282
|
}
|
|
254
283
|
|
|
255
|
-
._sample-
|
|
284
|
+
._sample-description_103tj_100 {
|
|
256
285
|
font-size: var(--fontSizeBase200);
|
|
257
286
|
color: var(--colorNeutralForeground2);
|
|
258
287
|
margin: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/playground",
|
|
3
|
-
"version": "0.14.0-dev.
|
|
3
|
+
"version": "0.14.0-dev.8",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec playground UI components.",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@fluentui/react-components": "~9.73.3",
|
|
63
63
|
"@fluentui/react-icons": "^2.0.323",
|
|
64
|
-
"@typespec/bundler": "^0.5.1 || >= 0.5.2-dev.
|
|
65
|
-
"@typespec/compiler": "^1.10.0 || >= 1.11.0-dev.
|
|
64
|
+
"@typespec/bundler": "^0.5.1 || >= 0.5.2-dev.6",
|
|
65
|
+
"@typespec/compiler": "^1.10.0 || >= 1.11.0-dev.9",
|
|
66
66
|
"@typespec/html-program-viewer": "^0.80.0 || >= 0.81.0-dev.3",
|
|
67
67
|
"@typespec/http": "^1.10.0 || >= 1.11.0-dev.3",
|
|
68
68
|
"@typespec/openapi": "^1.10.0 || >= 1.11.0-dev.2",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@types/react": "~19.2.14",
|
|
96
96
|
"@types/react-dom": "~19.2.3",
|
|
97
97
|
"@types/swagger-ui-dist": "~3.30.6",
|
|
98
|
-
"@typespec/bundler": "^0.5.1 || >= 0.5.2-dev.
|
|
98
|
+
"@typespec/bundler": "^0.5.1 || >= 0.5.2-dev.6",
|
|
99
99
|
"@vitejs/plugin-react": "~6.0.1",
|
|
100
100
|
"c8": "^11.0.0",
|
|
101
101
|
"cross-env": "~10.1.0",
|