@typespec/playground 0.7.0-dev.1 → 0.8.0-dev.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.
@@ -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, Checkbox, 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';
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":"AAWA,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACrE,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,CAwCzE,CAAC"}
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-dev.1",
3
+ "version": "0.8.0-dev.0",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec playground UI components.",
6
6
  "homepage": "https://typespec.io",
@@ -61,15 +61,15 @@
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",
64
+ "@typespec/bundler": "~0.1.11 || >=0.2.0-dev <0.2.0",
65
+ "@typespec/compiler": "~0.64.0 || >=0.65.0-dev <0.65.0",
66
+ "@typespec/html-program-viewer": "~0.64.0 || >=0.65.0-dev <0.65.0",
67
+ "@typespec/http": "~0.64.0 || >=0.65.0-dev <0.65.0",
68
+ "@typespec/openapi": "~0.64.0 || >=0.65.0-dev <0.65.0",
69
+ "@typespec/openapi3": "~0.64.0 || >=0.65.0-dev <0.65.0",
70
+ "@typespec/protobuf": "~0.64.0 || >=0.65.0-dev <0.65.0",
71
+ "@typespec/rest": "~0.64.0 || >=0.65.0-dev <0.65.0",
72
+ "@typespec/versioning": "~0.64.0 || >=0.65.0-dev <0.65.0",
73
73
  "clsx": "^2.1.1",
74
74
  "debounce": "~2.1.1",
75
75
  "lzutf8": "0.6.3",
@@ -95,7 +95,7 @@
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",
98
+ "@typespec/bundler": "~0.1.11 || >=0.2.0-dev <0.2.0",
99
99
  "@vitejs/plugin-react": "~4.3.2",
100
100
  "c8": "^10.1.2",
101
101
  "cross-env": "~7.0.3",