@typespec/playground 0.7.0-dev.1 → 0.7.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.
package/dist/react/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import require$$0, { createContext, useContext, useRef, useEffect, useMemo, memo, useCallback, useState, useId as useId$1 } from 'react';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { editor, Uri, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
|
|
4
|
-
import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, TableHeader, TableRow, TableHeaderCell, TableBody, TableCell, Select, useId, Label, RadioGroup, Radio, Input, Switch,
|
|
4
|
+
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';
|
|
5
5
|
import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
|
|
6
6
|
import debounce from 'debounce';
|
|
7
7
|
import { CompletionItemTag } from 'vscode-languageserver';
|
|
@@ -1931,7 +1931,15 @@ const EmitterOptionsForm = ({
|
|
|
1931
1931
|
}
|
|
1932
1932
|
const entries = Object.entries(emitterOptionsSchema);
|
|
1933
1933
|
return /* @__PURE__ */ jsx("div", { className: style$8["form"], children: entries.map(([key, value]) => {
|
|
1934
|
-
return /* @__PURE__ */ jsx("div", { className: style$8["form-item"], children: /* @__PURE__ */ jsx(
|
|
1934
|
+
return /* @__PURE__ */ jsx("div", { className: style$8["form-item"], children: value.type === "array" ? /* @__PURE__ */ jsx(
|
|
1935
|
+
JsonSchemaArrayPropertyInput,
|
|
1936
|
+
{
|
|
1937
|
+
emitterOptions: options[library.name] ?? {},
|
|
1938
|
+
name: key,
|
|
1939
|
+
prop: value,
|
|
1940
|
+
onChange: handleChange
|
|
1941
|
+
}
|
|
1942
|
+
) : /* @__PURE__ */ jsx(
|
|
1935
1943
|
JsonSchemaPropertyInput,
|
|
1936
1944
|
{
|
|
1937
1945
|
emitterOptions: options[library.name] ?? {},
|
|
@@ -1942,6 +1950,52 @@ const EmitterOptionsForm = ({
|
|
|
1942
1950
|
) }, key);
|
|
1943
1951
|
}) });
|
|
1944
1952
|
};
|
|
1953
|
+
const JsonSchemaArrayPropertyInput = ({
|
|
1954
|
+
emitterOptions,
|
|
1955
|
+
name,
|
|
1956
|
+
prop,
|
|
1957
|
+
onChange
|
|
1958
|
+
}) => {
|
|
1959
|
+
const itemsSchema = prop.items;
|
|
1960
|
+
const value = emitterOptions[name] ?? itemsSchema.default;
|
|
1961
|
+
const prettyName = useMemo(
|
|
1962
|
+
() => name[0].toUpperCase() + name.slice(1).replace(/-/g, " "),
|
|
1963
|
+
[name]
|
|
1964
|
+
);
|
|
1965
|
+
const inputId = useId("input");
|
|
1966
|
+
const [selectedValues, setSelectedValues] = useState(new Set(value));
|
|
1967
|
+
const handleChange = useCallback(
|
|
1968
|
+
(_, data, value2) => {
|
|
1969
|
+
const modifiedSelectedValues = new Set(selectedValues);
|
|
1970
|
+
if ("checked" in data) {
|
|
1971
|
+
data.checked ? modifiedSelectedValues.add(value2) : modifiedSelectedValues.delete(value2);
|
|
1972
|
+
} else {
|
|
1973
|
+
modifiedSelectedValues.clear();
|
|
1974
|
+
modifiedSelectedValues.add(data.value);
|
|
1975
|
+
}
|
|
1976
|
+
setSelectedValues(modifiedSelectedValues);
|
|
1977
|
+
onChange({ name, value: Array.from(modifiedSelectedValues) });
|
|
1978
|
+
},
|
|
1979
|
+
[name, onChange, selectedValues]
|
|
1980
|
+
);
|
|
1981
|
+
if (!itemsSchema.enum) {
|
|
1982
|
+
return JsonSchemaPropertyInput({ emitterOptions, name, prop: itemsSchema, onChange });
|
|
1983
|
+
}
|
|
1984
|
+
const itemsEnum = itemsSchema.enum;
|
|
1985
|
+
return /* @__PURE__ */ jsxs("div", { className: style$8["item"], children: [
|
|
1986
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: inputId, title: name, children: prettyName }),
|
|
1987
|
+
itemsEnum.map((x) => /* @__PURE__ */ jsx(
|
|
1988
|
+
Checkbox,
|
|
1989
|
+
{
|
|
1990
|
+
value: x,
|
|
1991
|
+
label: x,
|
|
1992
|
+
checked: selectedValues.has(x),
|
|
1993
|
+
onChange: (...args) => handleChange(...args, x)
|
|
1994
|
+
},
|
|
1995
|
+
x
|
|
1996
|
+
))
|
|
1997
|
+
] });
|
|
1998
|
+
};
|
|
1945
1999
|
const JsonSchemaPropertyInput = ({
|
|
1946
2000
|
emitterOptions,
|
|
1947
2001
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter-options-form.d.ts","sourceRoot":"","sources":["../../../../src/react/settings/emitter-options-form.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"emitter-options-form.d.ts","sourceRoot":"","sources":["../../../../src/react/settings/emitter-options-form.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAkC,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;CAC5D;AAED,eAAO,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,CAiDzE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/playground",
|
|
3
|
-
"version": "0.7.0
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec playground UI components.",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -61,15 +61,6 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@fluentui/react-components": "~9.55.0",
|
|
63
63
|
"@fluentui/react-icons": "^2.0.260",
|
|
64
|
-
"@typespec/bundler": "~0.1.9 || >=0.2.0-dev <0.2.0",
|
|
65
|
-
"@typespec/compiler": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
66
|
-
"@typespec/html-program-viewer": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
67
|
-
"@typespec/http": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
68
|
-
"@typespec/openapi": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
69
|
-
"@typespec/openapi3": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
70
|
-
"@typespec/protobuf": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
71
|
-
"@typespec/rest": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
72
|
-
"@typespec/versioning": "~0.62.0 || >=0.63.0-dev <0.63.0",
|
|
73
64
|
"clsx": "^2.1.1",
|
|
74
65
|
"debounce": "~2.1.1",
|
|
75
66
|
"lzutf8": "0.6.3",
|
|
@@ -79,7 +70,16 @@
|
|
|
79
70
|
"react-error-boundary": "^4.0.13",
|
|
80
71
|
"swagger-ui-dist": "^5.17.14",
|
|
81
72
|
"vscode-languageserver": "~9.0.1",
|
|
82
|
-
"vscode-languageserver-textdocument": "~1.0.12"
|
|
73
|
+
"vscode-languageserver-textdocument": "~1.0.12",
|
|
74
|
+
"@typespec/bundler": "~0.1.11",
|
|
75
|
+
"@typespec/compiler": "~0.64.0",
|
|
76
|
+
"@typespec/http": "~0.64.0",
|
|
77
|
+
"@typespec/html-program-viewer": "~0.64.0",
|
|
78
|
+
"@typespec/openapi": "~0.64.0",
|
|
79
|
+
"@typespec/openapi3": "~0.64.0",
|
|
80
|
+
"@typespec/protobuf": "~0.64.0",
|
|
81
|
+
"@typespec/rest": "~0.64.0",
|
|
82
|
+
"@typespec/versioning": "~0.64.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@babel/core": "^7.25.2",
|
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
"@types/react": "~18.3.11",
|
|
96
96
|
"@types/react-dom": "~18.3.0",
|
|
97
97
|
"@types/swagger-ui-dist": "~3.30.5",
|
|
98
|
-
"@typespec/bundler": "~0.1.9 || >=0.2.0-dev <0.2.0",
|
|
99
98
|
"@vitejs/plugin-react": "~4.3.2",
|
|
100
99
|
"c8": "^10.1.2",
|
|
101
100
|
"cross-env": "~7.0.3",
|
|
@@ -105,9 +104,9 @@
|
|
|
105
104
|
"vite": "^5.4.8",
|
|
106
105
|
"vite-plugin-checker": "^0.8.0",
|
|
107
106
|
"vite-plugin-dts": "4.2.3",
|
|
107
|
+
"@typespec/bundler": "~0.1.11",
|
|
108
108
|
"@typespec/react-components": "~0.57.0"
|
|
109
109
|
},
|
|
110
|
-
"peerDependencies": {},
|
|
111
110
|
"scripts": {
|
|
112
111
|
"clean": "rimraf ./dist ./dist-dev ./temp ./typespecContents.json",
|
|
113
112
|
"build": "vite build",
|