@babylonjs/shared-ui-components 8.41.2 → 8.43.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.
Files changed (43) hide show
  1. package/fluent/hoc/childWindow.d.ts +61 -0
  2. package/fluent/hoc/childWindow.js +174 -0
  3. package/fluent/hoc/childWindow.js.map +1 -0
  4. package/fluent/hoc/fileUploadLine.d.ts +5 -0
  5. package/fluent/hoc/fileUploadLine.js +10 -17
  6. package/fluent/hoc/fileUploadLine.js.map +1 -1
  7. package/fluent/hoc/propertyLines/comboBoxPropertyLine.d.ts +11 -0
  8. package/fluent/hoc/propertyLines/comboBoxPropertyLine.js +13 -0
  9. package/fluent/hoc/propertyLines/comboBoxPropertyLine.js.map +1 -0
  10. package/fluent/hoc/propertyLines/entitySelectorPropertyLine.d.ts +15 -0
  11. package/fluent/hoc/propertyLines/entitySelectorPropertyLine.js +9 -0
  12. package/fluent/hoc/propertyLines/entitySelectorPropertyLine.js.map +1 -0
  13. package/fluent/hoc/textureUpload.d.ts +40 -0
  14. package/fluent/hoc/textureUpload.js +64 -0
  15. package/fluent/hoc/textureUpload.js.map +1 -0
  16. package/fluent/primitives/button.d.ts +7 -3
  17. package/fluent/primitives/button.js +5 -5
  18. package/fluent/primitives/button.js.map +1 -1
  19. package/fluent/primitives/colorPicker.d.ts +8 -1
  20. package/fluent/primitives/colorPicker.js +25 -28
  21. package/fluent/primitives/colorPicker.js.map +1 -1
  22. package/fluent/primitives/comboBox.d.ts +23 -4
  23. package/fluent/primitives/comboBox.js +28 -8
  24. package/fluent/primitives/comboBox.js.map +1 -1
  25. package/fluent/primitives/entitySelector.d.ts +33 -0
  26. package/fluent/primitives/entitySelector.js +31 -0
  27. package/fluent/primitives/entitySelector.js.map +1 -0
  28. package/fluent/primitives/materialSelector.d.ts +21 -0
  29. package/fluent/primitives/materialSelector.js +16 -0
  30. package/fluent/primitives/materialSelector.js.map +1 -0
  31. package/fluent/primitives/nodeSelector.d.ts +21 -0
  32. package/fluent/primitives/nodeSelector.js +16 -0
  33. package/fluent/primitives/nodeSelector.js.map +1 -0
  34. package/fluent/primitives/popover.d.ts +13 -0
  35. package/fluent/primitives/popover.js +27 -0
  36. package/fluent/primitives/popover.js.map +1 -0
  37. package/fluent/primitives/textureSelector.d.ts +26 -0
  38. package/fluent/primitives/textureSelector.js +29 -0
  39. package/fluent/primitives/textureSelector.js.map +1 -0
  40. package/fluent/primitives/uploadButton.d.ts +24 -0
  41. package/fluent/primitives/uploadButton.js +27 -0
  42. package/fluent/primitives/uploadButton.js.map +1 -0
  43. package/package.json +1 -1
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { makeStyles, tokens } from "@fluentui/react-components";
3
+ import { useCallback } from "react";
4
+ import { TextureUpload } from "../hoc/textureUpload.js";
5
+ import { EntitySelector } from "./entitySelector.js";
6
+ const useStyles = makeStyles({
7
+ container: {
8
+ display: "flex",
9
+ flexDirection: "row",
10
+ alignItems: "center",
11
+ gap: tokens.spacingHorizontalS,
12
+ },
13
+ });
14
+ /**
15
+ * A primitive component with a ComboBox for selecting from existing scene textures
16
+ * and a button for uploading new texture files.
17
+ * @param props TextureSelectorProps
18
+ * @returns TextureSelector component
19
+ */
20
+ export const TextureSelector = (props) => {
21
+ TextureSelector.displayName = "TextureSelector";
22
+ const { scene, cubeOnly, value, onChange } = props;
23
+ const classes = useStyles();
24
+ const getTextures = useCallback(() => scene.textures, [scene.textures]);
25
+ const getName = useCallback((texture) => texture.displayName || texture.name, []);
26
+ const filter = useCallback((texture) => !cubeOnly || texture.isCube, [cubeOnly]);
27
+ return (_jsxs("div", { className: classes.container, children: [_jsx(EntitySelector, { value: value, onChange: onChange, getEntities: getTextures, getName: getName, filter: filter }), _jsx(TextureUpload, { scene: scene, onChange: onChange, cubeOnly: cubeOnly })] }));
28
+ };
29
+ //# sourceMappingURL=textureSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3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E,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAI,EAChH,KAAC,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAI,IACrE,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { FunctionComponent } from \"react\";\r\nimport type { PrimitiveProps } from \"./primitive\";\r\n\r\nimport { makeStyles, tokens } from \"@fluentui/react-components\";\r\nimport { useCallback } from \"react\";\r\nimport { TextureUpload } from \"../hoc/textureUpload\";\r\nimport { EntitySelector } from \"./entitySelector\";\r\n\r\nconst useStyles = makeStyles({\r\n container: {\r\n display: \"flex\",\r\n flexDirection: \"row\",\r\n alignItems: \"center\",\r\n gap: tokens.spacingHorizontalS,\r\n },\r\n});\r\n\r\nexport type TextureSelectorProps = PrimitiveProps<Nullable<BaseTexture>> & {\r\n /**\r\n * The scene to get textures from\r\n */\r\n scene: Scene;\r\n /**\r\n * File types to accept for upload\r\n */\r\n accept?: string;\r\n /**\r\n * Whether to only allow cube textures\r\n */\r\n cubeOnly?: boolean;\r\n};\r\n\r\n/**\r\n * A primitive component with a ComboBox for selecting from existing scene textures\r\n * and a button for uploading new texture files.\r\n * @param props TextureSelectorProps\r\n * @returns TextureSelector component\r\n */\r\nexport const TextureSelector: FunctionComponent<TextureSelectorProps> = (props) => {\r\n TextureSelector.displayName = \"TextureSelector\";\r\n const { scene, cubeOnly, value, onChange } = props;\r\n const classes = useStyles();\r\n\r\n const getTextures = useCallback(() => scene.textures, [scene.textures]);\r\n const getName = useCallback((texture: BaseTexture) => texture.displayName || texture.name, []);\r\n const filter = useCallback((texture: BaseTexture) => !cubeOnly || texture.isCube, [cubeOnly]);\r\n\r\n return (\r\n <div className={classes.container}>\r\n <EntitySelector value={value} onChange={onChange} getEntities={getTextures} getName={getName} filter={filter} />\r\n <TextureUpload scene={scene} onChange={onChange} cubeOnly={cubeOnly} />\r\n </div>\r\n );\r\n};\r\n"]}
@@ -0,0 +1,24 @@
1
+ import type { FunctionComponent } from "react";
2
+ import type { ButtonProps } from "./button.js";
3
+ type UploadButtonProps = Omit<ButtonProps, "onClick" | "icon"> & {
4
+ /**
5
+ * Callback when files are selected
6
+ */
7
+ onUpload: (files: FileList) => void;
8
+ /**
9
+ * File types to accept (e.g., ".jpg, .png, .dds")
10
+ */
11
+ accept?: string;
12
+ /**
13
+ * Text label to display on the button (optional)
14
+ */
15
+ label?: string;
16
+ };
17
+ /**
18
+ * A button that triggers a file upload dialog.
19
+ * Combines a Button with a hidden file input.
20
+ * @param props UploadButtonProps
21
+ * @returns UploadButton component
22
+ */
23
+ export declare const UploadButton: FunctionComponent<UploadButtonProps>;
24
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef } from "react";
3
+ import { ArrowUploadRegular } from "@fluentui/react-icons";
4
+ import { Button } from "./button.js";
5
+ /**
6
+ * A button that triggers a file upload dialog.
7
+ * Combines a Button with a hidden file input.
8
+ * @param props UploadButtonProps
9
+ * @returns UploadButton component
10
+ */
11
+ export const UploadButton = (props) => {
12
+ const { onUpload, accept, label, ...buttonProps } = props;
13
+ UploadButton.displayName = "UploadButton";
14
+ const inputRef = useRef(null);
15
+ const handleClick = () => {
16
+ inputRef.current?.click();
17
+ };
18
+ const handleChange = (evt) => {
19
+ const files = evt.target.files;
20
+ if (files && files.length) {
21
+ onUpload(files);
22
+ }
23
+ evt.target.value = "";
24
+ };
25
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { icon: ArrowUploadRegular, title: label ?? "Upload", label: label, onClick: handleClick, ...buttonProps }), _jsx("input", { ref: inputRef, type: "file", accept: accept, style: { display: "none" }, onChange: handleChange })] }));
26
+ };
27
+ //# sourceMappingURL=uploadButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadButton.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/uploadButton.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAkBlC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAyC,CAAC,KAAK,EAAE,EAAE;IACxE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,GAAG,KAAK,CAAC;IAC1D,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;IAC1C,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEhD,MAAM,WAAW,GAAG,GAAG,EAAE;QACrB,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,CAAC,GAAwC,EAAE,EAAE;QAC9D,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/B,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACxB,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;QACD,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,CACH,8BACI,KAAC,MAAM,IAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,KAAM,WAAW,GAAI,EACnH,gBAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,GAAI,IACzG,CACN,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FunctionComponent } from \"react\";\r\nimport { useRef } from \"react\";\r\nimport { ArrowUploadRegular } from \"@fluentui/react-icons\";\r\nimport { Button } from \"./button\";\r\nimport type { ButtonProps } from \"./button\";\r\n\r\ntype UploadButtonProps = Omit<ButtonProps, \"onClick\" | \"icon\"> & {\r\n /**\r\n * Callback when files are selected\r\n */\r\n onUpload: (files: FileList) => void;\r\n /**\r\n * File types to accept (e.g., \".jpg, .png, .dds\")\r\n */\r\n accept?: string;\r\n /**\r\n * Text label to display on the button (optional)\r\n */\r\n label?: string;\r\n};\r\n\r\n/**\r\n * A button that triggers a file upload dialog.\r\n * Combines a Button with a hidden file input.\r\n * @param props UploadButtonProps\r\n * @returns UploadButton component\r\n */\r\nexport const UploadButton: FunctionComponent<UploadButtonProps> = (props) => {\r\n const { onUpload, accept, label, ...buttonProps } = props;\r\n UploadButton.displayName = \"UploadButton\";\r\n const inputRef = useRef<HTMLInputElement>(null);\r\n\r\n const handleClick = () => {\r\n inputRef.current?.click();\r\n };\r\n\r\n const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {\r\n const files = evt.target.files;\r\n if (files && files.length) {\r\n onUpload(files);\r\n }\r\n evt.target.value = \"\";\r\n };\r\n\r\n return (\r\n <>\r\n <Button icon={ArrowUploadRegular} title={label ?? \"Upload\"} label={label} onClick={handleClick} {...buttonProps} />\r\n <input ref={inputRef} type=\"file\" accept={accept} style={{ display: \"none\" }} onChange={handleChange} />\r\n </>\r\n );\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/shared-ui-components",
3
- "version": "8.41.2",
3
+ "version": "8.43.0",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",