@onerjs/shared-ui-components 8.38.5 → 8.38.6

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 (50) hide show
  1. package/fluent/hoc/buttonLine.d.ts +1 -0
  2. package/fluent/hoc/buttonLine.js +1 -1
  3. package/fluent/hoc/buttonLine.js.map +1 -1
  4. package/fluent/hoc/fileUploadLine.js +1 -1
  5. package/fluent/hoc/fileUploadLine.js.map +1 -1
  6. package/fluent/hoc/propertyLines/propertyLine.d.ts +9 -1
  7. package/fluent/hoc/propertyLines/propertyLine.js +5 -3
  8. package/fluent/hoc/propertyLines/propertyLine.js.map +1 -1
  9. package/fluent/hooks/keyboardHooks.d.ts +11 -0
  10. package/fluent/hooks/keyboardHooks.js +48 -0
  11. package/fluent/hooks/keyboardHooks.js.map +1 -0
  12. package/fluent/hooks/transientStateHooks.d.ts +7 -0
  13. package/fluent/hooks/transientStateHooks.js +20 -0
  14. package/fluent/hooks/transientStateHooks.js.map +1 -0
  15. package/fluent/icons.js +3 -3
  16. package/fluent/icons.js.map +1 -1
  17. package/fluent/primitives/accordion.contexts.d.ts +136 -0
  18. package/fluent/primitives/accordion.contexts.js +253 -0
  19. package/fluent/primitives/accordion.contexts.js.map +1 -0
  20. package/fluent/primitives/accordion.d.ts +51 -0
  21. package/fluent/primitives/accordion.js +173 -12
  22. package/fluent/primitives/accordion.js.map +1 -1
  23. package/fluent/primitives/collapse.js +3 -1
  24. package/fluent/primitives/collapse.js.map +1 -1
  25. package/fluent/primitives/comboBox.d.ts +23 -2
  26. package/fluent/primitives/comboBox.js +4 -4
  27. package/fluent/primitives/comboBox.js.map +1 -1
  28. package/fluent/primitives/entitySelector.js +20 -6
  29. package/fluent/primitives/entitySelector.js.map +1 -1
  30. package/fluent/primitives/infoLabel.js +4 -28
  31. package/fluent/primitives/infoLabel.js.map +1 -1
  32. package/fluent/primitives/messageBar.d.ts +1 -0
  33. package/fluent/primitives/messageBar.js +3 -2
  34. package/fluent/primitives/messageBar.js.map +1 -1
  35. package/fluent/primitives/spinButton.js +47 -4
  36. package/fluent/primitives/spinButton.js.map +1 -1
  37. package/fluent/primitives/toast.js +2 -2
  38. package/fluent/primitives/toast.js.map +1 -1
  39. package/fluent/primitives/utils.d.ts +1 -1
  40. package/nodeGraphSystem/graphCanvas.js +3 -0
  41. package/nodeGraphSystem/graphCanvas.js.map +1 -1
  42. package/nodeGraphSystem/graphNode.d.ts +1 -0
  43. package/nodeGraphSystem/graphNode.js +8 -0
  44. package/nodeGraphSystem/graphNode.js.map +1 -1
  45. package/nodeGraphSystem/interfaces/nodeData.d.ts +1 -0
  46. package/nodeGraphSystem/interfaces/nodeData.js.map +1 -1
  47. package/nodeGraphSystem/nodePort.d.ts +2 -0
  48. package/nodeGraphSystem/nodePort.js +11 -1
  49. package/nodeGraphSystem/nodePort.js.map +1 -1
  50. package/package.json +1 -1
@@ -2,6 +2,7 @@ import type { FunctionComponent } from "react";
2
2
  import type { ButtonProps } from "../primitives/button.js";
3
3
  type ButtonLineProps = Omit<ButtonProps, "label"> & {
4
4
  label: string;
5
+ uniqueId?: string;
5
6
  };
6
7
  /**
7
8
  * Wraps a button with a label in a line container
@@ -8,6 +8,6 @@ import { Button } from "../primitives/button.js";
8
8
  */
9
9
  export const ButtonLine = (props) => {
10
10
  ButtonLine.displayName = "ButtonLine";
11
- return (_jsx(LineContainer, { children: _jsx(Button, { ...props }) }));
11
+ return (_jsx(LineContainer, { uniqueId: props.uniqueId ?? props.label, children: _jsx(Button, { ...props }) }));
12
12
  };
13
13
  //# sourceMappingURL=buttonLine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"buttonLine.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/hoc/buttonLine.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAK9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAuC,CAAC,KAAK,EAAE,EAAE;IACpE,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;IAEtC,OAAO,CACH,KAAC,aAAa,cACV,KAAC,MAAM,OAAK,KAAK,GAAI,GACT,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { LineContainer } from \"./propertyLines/propertyLine\";\r\nimport type { FunctionComponent } from \"react\";\r\nimport { Button } from \"../primitives/button\";\r\nimport type { ButtonProps } from \"../primitives/button\";\r\n\r\ntype ButtonLineProps = Omit<ButtonProps, \"label\"> & { label: string }; // Require a label when button is the entire line (by default, label is optional on a button)\r\n\r\n/**\r\n * Wraps a button with a label in a line container\r\n * @param props Button props plus a label\r\n * @returns A button inside a line\r\n */\r\nexport const ButtonLine: FunctionComponent<ButtonLineProps> = (props) => {\r\n ButtonLine.displayName = \"ButtonLine\";\r\n\r\n return (\r\n <LineContainer>\r\n <Button {...props} />\r\n </LineContainer>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"file":"buttonLine.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/hoc/buttonLine.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAQ9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAuC,CAAC,KAAK,EAAE,EAAE;IACpE,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;IAEtC,OAAO,CACH,KAAC,aAAa,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,YAClD,KAAC,MAAM,OAAK,KAAK,GAAI,GACT,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { LineContainer } from \"./propertyLines/propertyLine\";\r\nimport type { FunctionComponent } from \"react\";\r\nimport { Button } from \"../primitives/button\";\r\nimport type { ButtonProps } from \"../primitives/button\";\r\n\r\ntype ButtonLineProps = Omit<ButtonProps, \"label\"> & {\r\n label: string; // Require a label when button is the entire line (by default, label is optional on a button)\r\n uniqueId?: string; // The ID of the property line to be used when the label cannot be used as a persistent ID.\r\n};\r\n\r\n/**\r\n * Wraps a button with a label in a line container\r\n * @param props Button props plus a label\r\n * @returns A button inside a line\r\n */\r\nexport const ButtonLine: FunctionComponent<ButtonLineProps> = (props) => {\r\n ButtonLine.displayName = \"ButtonLine\";\r\n\r\n return (\r\n <LineContainer uniqueId={props.uniqueId ?? props.label}>\r\n <Button {...props} />\r\n </LineContainer>\r\n );\r\n};\r\n"]}
@@ -8,6 +8,6 @@ import { UploadButton } from "../primitives/uploadButton.js";
8
8
  */
9
9
  export const FileUploadLine = ({ onClick, label, accept, ...buttonProps }) => {
10
10
  FileUploadLine.displayName = "FileUploadLine";
11
- return (_jsx(LineContainer, { children: _jsx(UploadButton, { onUpload: onClick, accept: accept, label: label, ...buttonProps }) }));
11
+ return (_jsx(LineContainer, { uniqueId: label, children: _jsx(UploadButton, { onUpload: onClick, accept: accept, label: label, ...buttonProps }) }));
12
12
  };
13
13
  //# sourceMappingURL=fileUploadLine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileUploadLine.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/hoc/fileUploadLine.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAS1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,EAAE,EAAE;IACjH,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC;IAE9C,OAAO,CACH,KAAC,aAAa,cACV,KAAC,YAAY,IAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAM,WAAW,GAAI,GACtE,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FunctionComponent } from \"react\";\r\nimport { LineContainer } from \"./propertyLines/propertyLine\";\r\nimport { UploadButton } from \"../primitives/uploadButton\";\r\nimport type { ButtonProps } from \"../primitives/button\";\r\n\r\ntype FileUploadLineProps = Omit<ButtonProps, \"onClick\" | \"label\"> & {\r\n onClick: (files: FileList) => void;\r\n label: string; // Require a label when button is the entire line (by default, label is optional on an UploadButton\r\n accept: string;\r\n};\r\n\r\n/**\r\n * A full-width line with an upload button.\r\n * For just the button without the line wrapper, use UploadButton directly.\r\n * @returns An UploadButton wrapped in a LineContainer\r\n */\r\nexport const FileUploadLine: FunctionComponent<FileUploadLineProps> = ({ onClick, label, accept, ...buttonProps }) => {\r\n FileUploadLine.displayName = \"FileUploadLine\";\r\n\r\n return (\r\n <LineContainer>\r\n <UploadButton onUpload={onClick} accept={accept} label={label} {...buttonProps} />\r\n </LineContainer>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"file":"fileUploadLine.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/hoc/fileUploadLine.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAS1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,EAAE,EAAE;IACjH,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC;IAE9C,OAAO,CACH,KAAC,aAAa,IAAC,QAAQ,EAAE,KAAK,YAC1B,KAAC,YAAY,IAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAM,WAAW,GAAI,GACtE,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FunctionComponent } from \"react\";\r\nimport { LineContainer } from \"./propertyLines/propertyLine\";\r\nimport { UploadButton } from \"../primitives/uploadButton\";\r\nimport type { ButtonProps } from \"../primitives/button\";\r\n\r\ntype FileUploadLineProps = Omit<ButtonProps, \"onClick\" | \"label\"> & {\r\n onClick: (files: FileList) => void;\r\n label: string; // Require a label when button is the entire line (by default, label is optional on an UploadButton\r\n accept: string;\r\n};\r\n\r\n/**\r\n * A full-width line with an upload button.\r\n * For just the button without the line wrapper, use UploadButton directly.\r\n * @returns An UploadButton wrapped in a LineContainer\r\n */\r\nexport const FileUploadLine: FunctionComponent<FileUploadLineProps> = ({ onClick, label, accept, ...buttonProps }) => {\r\n FileUploadLine.displayName = \"FileUploadLine\";\r\n\r\n return (\r\n <LineContainer uniqueId={label}>\r\n <UploadButton onUpload={onClick} accept={accept} label={label} {...buttonProps} />\r\n </LineContainer>\r\n );\r\n};\r\n"]}
@@ -1,10 +1,18 @@
1
1
  import type { FunctionComponent, HTMLProps, PropsWithChildren } from "react";
2
+ import type { AccordionSectionItemProps } from "../../primitives/accordion.js";
2
3
  import type { PrimitiveProps } from "../../primitives/primitive.js";
3
4
  type BasePropertyLineProps = {
4
5
  /**
5
6
  * The name of the property to display in the property line.
6
7
  */
7
8
  label: string;
9
+ /**
10
+ * The ID of the property line to be used when the label cannot be used as a persistent ID.
11
+ *
12
+ * Note that when a property line is used within an accordion section, this ID must be unique within that section in order
13
+ * for property pinning and filtering to work correctly. If not, error will be shown in console.
14
+ */
15
+ uniqueId?: string;
8
16
  /**
9
17
  * Optional description for the property, shown on hover of the info icon
10
18
  */
@@ -58,6 +66,6 @@ export type PropertyLineProps<ValueT> = BasePropertyLineProps & (NullablePropert
58
66
  *
59
67
  */
60
68
  export declare const PropertyLine: import("react").ForwardRefExoticComponent<PropsWithChildren<PropertyLineProps<any>> & import("react").RefAttributes<HTMLDivElement>>;
61
- export declare const LineContainer: import("react").ForwardRefExoticComponent<Omit<PropsWithChildren<HTMLProps<HTMLDivElement>>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
69
+ export declare const LineContainer: import("react").ForwardRefExoticComponent<Omit<PropsWithChildren<HTMLProps<HTMLDivElement> & AccordionSectionItemProps>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
62
70
  export declare const PlaceholderPropertyLine: FunctionComponent<PrimitiveProps<any> & PropertyLineProps<any>>;
63
71
  export {};
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Body1, Checkbox, makeStyles, tokens, mergeClasses } from "@fluentui/react-components";
3
3
  import { ChevronCircleDown20Regular, ChevronCircleDown16Regular, ChevronCircleRight16Regular, ChevronCircleRight20Regular, CopyRegular, Copy16Regular, } from "@fluentui/react-icons";
4
+ import { AccordionSectionItem } from "../../primitives/accordion.js";
4
5
  import { useContext, useState, forwardRef, cloneElement, isValidElement, useRef, useCallback } from "react";
5
6
  import { Collapse } from "../../primitives/collapse.js";
6
7
  import { copyCommandToClipboard } from "../../../copyCommandToClipboard.js";
@@ -72,7 +73,7 @@ export const PropertyLine = forwardRef((props, ref) => {
72
73
  PropertyLine.displayName = "PropertyLine";
73
74
  const { disableCopy, size } = useContext(ToolContext);
74
75
  const classes = usePropertyLineStyles();
75
- const { label, onCopy, expandedContent, children, nullable, ignoreNullable } = props;
76
+ const { label, uniqueId, onCopy, expandedContent, children, nullable, ignoreNullable } = props;
76
77
  const [expanded, setExpanded] = useState("expandByDefault" in props ? props.expandByDefault : false);
77
78
  const cachedVal = useRef(nullable ? props.value : null);
78
79
  const { showToast } = useToast();
@@ -96,7 +97,7 @@ export const PropertyLine = forwardRef((props, ref) => {
96
97
  defaultValue: undefined, // Don't pass defaultValue to children as there is no guarantee how this will be used and we can't mix controlled + uncontrolled state
97
98
  })
98
99
  : children;
99
- return (_jsxs(LineContainer, { ref: ref, children: [_jsxs("div", { className: classes.baseLine, children: [_jsx(InfoLabel, { className: classes.infoLabel, htmlFor: "property", info: description, label: label, flexLabel: true, onContextMenu: onCopy ? handleContextMenu : undefined }), _jsxs("div", { className: classes.rightContent, id: "property", children: [expandedContent && (_jsx(ToggleButton, { title: "Expand/Collapse property", appearance: "transparent", checkedIcon: size === "small" ? ChevronCircleDown16Regular : ChevronCircleDown20Regular, uncheckedIcon: size === "small" ? ChevronCircleRight16Regular : ChevronCircleRight20Regular, value: expanded === true, onChange: setExpanded })), nullable && !ignoreNullable && (
100
+ return (_jsxs(LineContainer, { ref: ref, uniqueId: uniqueId ?? label, label: label, children: [_jsxs("div", { className: classes.baseLine, children: [_jsx(InfoLabel, { className: classes.infoLabel, htmlFor: "property", info: description, label: label, flexLabel: true, onContextMenu: onCopy ? handleContextMenu : undefined }), _jsxs("div", { className: classes.rightContent, id: "property", children: [expandedContent && (_jsx(ToggleButton, { title: "Expand/Collapse property", appearance: "transparent", checkedIcon: size === "small" ? ChevronCircleDown16Regular : ChevronCircleDown20Regular, uncheckedIcon: size === "small" ? ChevronCircleRight16Regular : ChevronCircleRight20Regular, value: expanded === true, onChange: setExpanded })), nullable && !ignoreNullable && (
100
101
  // If this is a nullableProperty and ignoreNullable was not sent, display a checkbox used to toggle null ('checked' means 'non null')
101
102
  _jsx(Tooltip, { content: props.value == null ? "Enable property" : "Disable property (set to null)", children: _jsx(Checkbox, { className: classes.checkbox, indicator: { className: classes.checkboxIndicator }, checked: !(props.value == null), onChange: (_, data) => {
102
103
  if (data.checked) {
@@ -133,8 +134,9 @@ const useLineStyles = makeStyles({
133
134
  });
134
135
  export const LineContainer = forwardRef((props, ref) => {
135
136
  const { size } = useContext(ToolContext);
137
+ const { children, uniqueId, label, ...rest } = props;
136
138
  const classes = useLineStyles();
137
- return (_jsx("div", { ref: ref, className: mergeClasses(classes.container, size == "small" ? classes.containerSmall : undefined), ...props, children: props.children }));
139
+ return (_jsx(AccordionSectionItem, { uniqueId: uniqueId, label: label, children: _jsx("div", { ref: ref, className: mergeClasses(classes.container, size == "small" ? classes.containerSmall : undefined), ...rest, children: children }) }));
138
140
  });
139
141
  export const PlaceholderPropertyLine = (props) => {
140
142
  return (_jsx(PropertyLine, { ...props, children: _jsx(Body1, { children: props.value }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"propertyLine.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/fluent/hoc/propertyLines/propertyLine.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,EACH,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC3B,WAAW,EACX,aAAa,GAChB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,MAAM,qBAAqB,GAAG,UAAU,CAAC;IACrC,QAAQ,EAAE;QACN,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,YA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\nimport {\r\n ChevronCircleDown20Regular,\r\n ChevronCircleDown16Regular,\r\n ChevronCircleRight16Regular,\r\n ChevronCircleRight20Regular,\r\n CopyRegular,\r\n Copy16Regular,\r\n} from \"@fluentui/react-icons\";\r\nimport type { FunctionComponent, HTMLProps, PropsWithChildren, MouseEvent } from \"react\";\r\nimport { useContext, useState, forwardRef, cloneElement, isValidElement, useRef, useCallback } from \"react\";\r\nimport { Collapse } from \"../../primitives/collapse\";\r\nimport { copyCommandToClipboard } from \"../../../copyCommandToClipboard\";\r\nimport { ToolContext } from \"../fluentToolWrapper\";\r\nimport type { PrimitiveProps } from \"../../primitives/primitive\";\r\nimport { Link } from \"../../primitives/link\";\r\nimport { ToggleButton } from \"../../primitives/toggleButton\";\r\nimport { Button } from \"../../primitives/button\";\r\nimport { CustomTokens, TokenMap } from \"../../primitives/utils\";\r\nimport { InfoLabel } from \"../../primitives/infoLabel\";\r\nimport { Tooltip } from \"../../primitives/tooltip\";\r\nimport { useToast } from \"../../primitives/toast\";\r\n\r\nconst usePropertyLineStyles = makeStyles({\r\n baseLine: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"flex-start\",\r\n width: \"100%\",\r\n },\r\n infoLabel: {\r\n display: \"flex\",\r\n flex: \"1 1 0\", // grow=1, shrink =1, basis = 0 initial size before\r\n minWidth: CustomTokens.labelMinWidth,\r\n textAlign: \"left\",\r\n },\r\n rightContent: {\r\n flex: \"0 1 auto\",\r\n minWidth: 0,\r\n overflow: \"hidden\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"flex-end\",\r\n },\r\n childWrapper: {\r\n minWidth: 0,\r\n overflow: \"hidden\",\r\n textOverflow: \"ellipsis\",\r\n whiteSpace: \"nowrap\",\r\n },\r\n infoPopup: {\r\n whiteSpace: \"normal\",\r\n wordBreak: \"break-word\",\r\n },\r\n copy: {\r\n marginRight: CustomTokens.rightAlignOffset, // Accounts for the padding baked into fluent button / ensures propertyLine looks visually aligned at the right\r\n },\r\n expandedContentDiv: {\r\n overflow: \"hidden\",\r\n paddingLeft: tokens.spacingHorizontalM,\r\n },\r\n checkbox: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n marginRight: tokens.spacingHorizontalXS,\r\n },\r\n checkboxIndicator: {\r\n margin: TokenMap.px2,\r\n width: TokenMap.px12,\r\n height: TokenMap.px12,\r\n },\r\n});\r\n\r\ntype BasePropertyLineProps = {\r\n /**\r\n * The name of the property to display in the property line.\r\n */\r\n label: string;\r\n /**\r\n * Optional description for the property, shown on hover of the info icon\r\n */\r\n description?: string;\r\n /**\r\n * Optional function returning a string to copy to clipboard.\r\n */\r\n onCopy?: () => string;\r\n /**\r\n * Link to the documentation for this property, available from the info icon either linked from the description (if provided) or default 'docs' text\r\n */\r\n docLink?: string;\r\n};\r\n\r\n// Only require value/onChange/defaultValue props if nullable is true\r\ntype NullableProperty<ValueT> = {\r\n nullable: true;\r\n ignoreNullable: false;\r\n value: ValueT;\r\n onChange: (value: ValueT) => void;\r\n defaultValue?: ValueT;\r\n};\r\n\r\ntype IgnoreNullable<ValueT> = {\r\n ignoreNullable: true;\r\n nullable: false;\r\n value: ValueT;\r\n onChange: (value: ValueT) => void;\r\n defaultValue: ValueT;\r\n};\r\n\r\ntype NonNullableProperty = {\r\n nullable?: false;\r\n ignoreNullable?: false;\r\n};\r\n\r\n// Only expect optional expandByDefault prop if expandedContent is defined\r\ntype ExpandableProperty = {\r\n /**\r\n * If supplied, an 'expand' icon will be shown which, when clicked, renders this component within the property line.\r\n */\r\n expandedContent: JSX.Element;\r\n\r\n /**\r\n * If true, the expanded content will be shown by default.\r\n */\r\n expandByDefault?: boolean;\r\n};\r\n\r\n// If expanded content is undefined, don't expect expandByDefault prop\r\ntype NonExpandableProperty = {\r\n expandedContent?: undefined;\r\n};\r\n\r\nexport type PropertyLineProps<ValueT> = BasePropertyLineProps &\r\n (NullableProperty<ValueT> | NonNullableProperty | IgnoreNullable<ValueT>) &\r\n (ExpandableProperty | NonExpandableProperty);\r\n\r\n/**\r\n * A reusable component that renders a property line with a label and child content, and an optional description, copy button, and expandable section.\r\n *\r\n * @param props - The properties for the PropertyLine component.\r\n * @returns A React element representing the property line.\r\n *\r\n */\r\nexport const PropertyLine = forwardRef<HTMLDivElement, PropsWithChildren<PropertyLineProps<any>>>((props, ref) => {\r\n PropertyLine.displayName = \"PropertyLine\";\r\n const { disableCopy, size } = useContext(ToolContext);\r\n const classes = usePropertyLineStyles();\r\n const { label, onCopy, expandedContent, children, nullable, ignoreNullable } = props;\r\n\r\n const [expanded, setExpanded] = useState(\"expandByDefault\" in props ? props.expandByDefault : false);\r\n const cachedVal = useRef(nullable ? props.value : null);\r\n\r\n const { showToast } = useToast();\r\n\r\n const handleCopy = useCallback(() => {\r\n if (onCopy) {\r\n copyCommandToClipboard(onCopy());\r\n showToast(\"Copied property to clipboard\");\r\n }\r\n }, [onCopy, showToast]);\r\n\r\n const handleContextMenu = useCallback(\r\n (e: MouseEvent) => {\r\n e.preventDefault();\r\n handleCopy();\r\n },\r\n [handleCopy]\r\n );\r\n\r\n const description = props.docLink ? <Link url={props.docLink} value={props.description ?? \"Docs\"} /> : props.description ? <Body1>{props.description}</Body1> : undefined;\r\n\r\n // Process children to handle nullable state -- creating component in disabled state with default value in lieu of null value\r\n const processedChildren =\r\n (nullable || ignoreNullable) && isValidElement(children)\r\n ? cloneElement(children, {\r\n ...children.props,\r\n disabled: children.props.disabled || (nullable && props.value == null),\r\n value: props.value ?? props.defaultValue,\r\n defaultValue: undefined, // Don't pass defaultValue to children as there is no guarantee how this will be used and we can't mix controlled + uncontrolled state\r\n })\r\n : children;\r\n\r\n return (\r\n <LineContainer ref={ref}>\r\n <div className={classes.baseLine}>\r\n <InfoLabel className={classes.infoLabel} htmlFor=\"property\" info={description} label={label} flexLabel onContextMenu={onCopy ? handleContextMenu : undefined} />\r\n <div className={classes.rightContent} id=\"property\">\r\n {expandedContent && (\r\n <ToggleButton\r\n title=\"Expand/Collapse property\"\r\n appearance=\"transparent\"\r\n checkedIcon={size === \"small\" ? ChevronCircleDown16Regular : ChevronCircleDown20Regular}\r\n uncheckedIcon={size === \"small\" ? ChevronCircleRight16Regular : ChevronCircleRight20Regular}\r\n value={expanded === true}\r\n onChange={setExpanded}\r\n />\r\n )}\r\n\r\n {nullable && !ignoreNullable && (\r\n // If this is a nullableProperty and ignoreNullable was not sent, display a checkbox used to toggle null ('checked' means 'non null')\r\n <Tooltip content={props.value == null ? \"Enable property\" : \"Disable property (set to null)\"}>\r\n <Checkbox\r\n className={classes.checkbox}\r\n indicator={{ className: classes.checkboxIndicator }}\r\n checked={!(props.value == null)}\r\n onChange={(_, data) => {\r\n if (data.checked) {\r\n // if checked this means we are returning to non-null, use cached value if exists. If no cached value, use default value\r\n cachedVal.current != null ? props.onChange(cachedVal.current) : props.onChange(props.defaultValue);\r\n } else {\r\n // if moving to un-checked state, this means moving to null value. Cache the old value and tell props.onChange(null)\r\n cachedVal.current = props.value;\r\n props.onChange(null);\r\n }\r\n }}\r\n />\r\n </Tooltip>\r\n )}\r\n <div className={classes.childWrapper}>{processedChildren}</div>\r\n {onCopy && !disableCopy && (\r\n <Tooltip content=\"Copy to Clipboard\">\r\n <Button className={classes.copy} appearance=\"transparent\" icon={size === \"small\" ? Copy16Regular : CopyRegular} onClick={handleCopy} />\r\n </Tooltip>\r\n )}\r\n </div>\r\n </div>\r\n {expandedContent && (\r\n <Collapse visible={!!expanded}>\r\n <div className={classes.expandedContentDiv}>{expandedContent}</div>\r\n </Collapse>\r\n )}\r\n </LineContainer>\r\n );\r\n});\r\n\r\nconst useLineStyles = makeStyles({\r\n container: {\r\n width: \"100%\",\r\n display: \"flex\",\r\n flexDirection: \"column\", // Stack line + expanded content\r\n minHeight: CustomTokens.lineHeight,\r\n boxSizing: \"border-box\",\r\n justifyContent: \"center\",\r\n paddingTop: tokens.spacingVerticalXXS,\r\n paddingBottom: tokens.spacingVerticalXXS,\r\n borderTop: `1px solid transparent`,\r\n borderBottom: `1px solid transparent`,\r\n \":hover\": {\r\n borderTopColor: tokens.colorNeutralStroke2,\r\n borderBottomColor: tokens.colorNeutralStroke2,\r\n },\r\n },\r\n containerSmall: {\r\n minHeight: CustomTokens.lineHeightSmall,\r\n },\r\n});\r\n\r\nexport const LineContainer = forwardRef<HTMLDivElement, PropsWithChildren<HTMLProps<HTMLDivElement>>>((props, ref) => {\r\n const { size } = useContext(ToolContext);\r\n const classes = useLineStyles();\r\n\r\n return (\r\n <div ref={ref} className={mergeClasses(classes.container, size == \"small\" ? classes.containerSmall : undefined)} {...props}>\r\n {props.children}\r\n </div>\r\n );\r\n});\r\n\r\nexport const PlaceholderPropertyLine: FunctionComponent<PrimitiveProps<any> & PropertyLineProps<any>> = (props) => {\r\n return (\r\n <PropertyLine {...props}>\r\n <Body1>{props.value}</Body1>\r\n </PropertyLine>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"file":"propertyLine.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/fluent/hoc/propertyLines/propertyLine.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,EACH,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC3B,WAAW,EACX,aAAa,GAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,IA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AC;IACzC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAEhC,OAAO,CACH,KAAC,oBAAoB,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,YAClD,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,KAAM,IAAI,YACpH,QAAQ,GACP,GACa,CAC1B,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAoE,CAAC,KAAK,EAAE,EAAE;IAC9G,OAAO,CACH,KAAC,YAAY,OAAK,KAAK,YACnB,KAAC,KAAK,cAAE,KAAK,CAAC,KAAK,GAAS,GACjB,CAClB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Body1, Checkbox, makeStyles, tokens, mergeClasses } from \"@fluentui/react-components\";\r\nimport {\r\n ChevronCircleDown20Regular,\r\n ChevronCircleDown16Regular,\r\n ChevronCircleRight16Regular,\r\n ChevronCircleRight20Regular,\r\n CopyRegular,\r\n Copy16Regular,\r\n} from \"@fluentui/react-icons\";\r\nimport type { FunctionComponent, HTMLProps, PropsWithChildren, MouseEvent } from \"react\";\r\nimport type { AccordionSectionItemProps } from \"../../primitives/accordion\";\r\nimport { AccordionSectionItem } from \"../../primitives/accordion\";\r\nimport { useContext, useState, forwardRef, cloneElement, isValidElement, useRef, useCallback } from \"react\";\r\nimport { Collapse } from \"../../primitives/collapse\";\r\nimport { copyCommandToClipboard } from \"../../../copyCommandToClipboard\";\r\nimport { ToolContext } from \"../fluentToolWrapper\";\r\nimport type { PrimitiveProps } from \"../../primitives/primitive\";\r\nimport { Link } from \"../../primitives/link\";\r\nimport { ToggleButton } from \"../../primitives/toggleButton\";\r\nimport { Button } from \"../../primitives/button\";\r\nimport { CustomTokens, TokenMap } from \"../../primitives/utils\";\r\nimport { InfoLabel } from \"../../primitives/infoLabel\";\r\nimport { Tooltip } from \"../../primitives/tooltip\";\r\nimport { useToast } from \"../../primitives/toast\";\r\n\r\nconst usePropertyLineStyles = makeStyles({\r\n baseLine: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"flex-start\",\r\n width: \"100%\",\r\n },\r\n infoLabel: {\r\n display: \"flex\",\r\n flex: \"1 1 0\", // grow=1, shrink =1, basis = 0 initial size before\r\n minWidth: CustomTokens.labelMinWidth,\r\n textAlign: \"left\",\r\n },\r\n rightContent: {\r\n flex: \"0 1 auto\",\r\n minWidth: 0,\r\n overflow: \"hidden\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"flex-end\",\r\n },\r\n childWrapper: {\r\n minWidth: 0,\r\n overflow: \"hidden\",\r\n textOverflow: \"ellipsis\",\r\n whiteSpace: \"nowrap\",\r\n },\r\n infoPopup: {\r\n whiteSpace: \"normal\",\r\n wordBreak: \"break-word\",\r\n },\r\n copy: {\r\n marginRight: CustomTokens.rightAlignOffset, // Accounts for the padding baked into fluent button / ensures propertyLine looks visually aligned at the right\r\n },\r\n expandedContentDiv: {\r\n overflow: \"hidden\",\r\n paddingLeft: tokens.spacingHorizontalM,\r\n },\r\n checkbox: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n marginRight: tokens.spacingHorizontalXS,\r\n },\r\n checkboxIndicator: {\r\n margin: TokenMap.px2,\r\n width: TokenMap.px12,\r\n height: TokenMap.px12,\r\n },\r\n});\r\n\r\ntype BasePropertyLineProps = {\r\n /**\r\n * The name of the property to display in the property line.\r\n */\r\n label: string;\r\n /**\r\n * The ID of the property line to be used when the label cannot be used as a persistent ID.\r\n *\r\n * Note that when a property line is used within an accordion section, this ID must be unique within that section in order\r\n * for property pinning and filtering to work correctly. If not, error will be shown in console.\r\n */\r\n uniqueId?: string;\r\n /**\r\n * Optional description for the property, shown on hover of the info icon\r\n */\r\n description?: string;\r\n /**\r\n * Optional function returning a string to copy to clipboard.\r\n */\r\n onCopy?: () => string;\r\n /**\r\n * Link to the documentation for this property, available from the info icon either linked from the description (if provided) or default 'docs' text\r\n */\r\n docLink?: string;\r\n};\r\n\r\n// Only require value/onChange/defaultValue props if nullable is true\r\ntype NullableProperty<ValueT> = {\r\n nullable: true;\r\n ignoreNullable: false;\r\n value: ValueT;\r\n onChange: (value: ValueT) => void;\r\n defaultValue?: ValueT;\r\n};\r\n\r\ntype IgnoreNullable<ValueT> = {\r\n ignoreNullable: true;\r\n nullable: false;\r\n value: ValueT;\r\n onChange: (value: ValueT) => void;\r\n defaultValue: ValueT;\r\n};\r\n\r\ntype NonNullableProperty = {\r\n nullable?: false;\r\n ignoreNullable?: false;\r\n};\r\n\r\n// Only expect optional expandByDefault prop if expandedContent is defined\r\ntype ExpandableProperty = {\r\n /**\r\n * If supplied, an 'expand' icon will be shown which, when clicked, renders this component within the property line.\r\n */\r\n expandedContent: JSX.Element;\r\n\r\n /**\r\n * If true, the expanded content will be shown by default.\r\n */\r\n expandByDefault?: boolean;\r\n};\r\n\r\n// If expanded content is undefined, don't expect expandByDefault prop\r\ntype NonExpandableProperty = {\r\n expandedContent?: undefined;\r\n};\r\n\r\nexport type PropertyLineProps<ValueT> = BasePropertyLineProps &\r\n (NullableProperty<ValueT> | NonNullableProperty | IgnoreNullable<ValueT>) &\r\n (ExpandableProperty | NonExpandableProperty);\r\n\r\n/**\r\n * A reusable component that renders a property line with a label and child content, and an optional description, copy button, and expandable section.\r\n *\r\n * @param props - The properties for the PropertyLine component.\r\n * @returns A React element representing the property line.\r\n *\r\n */\r\nexport const PropertyLine = forwardRef<HTMLDivElement, PropsWithChildren<PropertyLineProps<any>>>((props, ref) => {\r\n PropertyLine.displayName = \"PropertyLine\";\r\n const { disableCopy, size } = useContext(ToolContext);\r\n const classes = usePropertyLineStyles();\r\n const { label, uniqueId, onCopy, expandedContent, children, nullable, ignoreNullable } = props;\r\n\r\n const [expanded, setExpanded] = useState(\"expandByDefault\" in props ? props.expandByDefault : false);\r\n const cachedVal = useRef(nullable ? props.value : null);\r\n\r\n const { showToast } = useToast();\r\n\r\n const handleCopy = useCallback(() => {\r\n if (onCopy) {\r\n copyCommandToClipboard(onCopy());\r\n showToast(\"Copied property to clipboard\");\r\n }\r\n }, [onCopy, showToast]);\r\n\r\n const handleContextMenu = useCallback(\r\n (e: MouseEvent) => {\r\n e.preventDefault();\r\n handleCopy();\r\n },\r\n [handleCopy]\r\n );\r\n\r\n const description = props.docLink ? <Link url={props.docLink} value={props.description ?? \"Docs\"} /> : props.description ? <Body1>{props.description}</Body1> : undefined;\r\n\r\n // Process children to handle nullable state -- creating component in disabled state with default value in lieu of null value\r\n const processedChildren =\r\n (nullable || ignoreNullable) && isValidElement(children)\r\n ? cloneElement(children, {\r\n ...children.props,\r\n disabled: children.props.disabled || (nullable && props.value == null),\r\n value: props.value ?? props.defaultValue,\r\n defaultValue: undefined, // Don't pass defaultValue to children as there is no guarantee how this will be used and we can't mix controlled + uncontrolled state\r\n })\r\n : children;\r\n\r\n return (\r\n <LineContainer ref={ref} uniqueId={uniqueId ?? label} label={label}>\r\n <div className={classes.baseLine}>\r\n <InfoLabel className={classes.infoLabel} htmlFor=\"property\" info={description} label={label} flexLabel onContextMenu={onCopy ? handleContextMenu : undefined} />\r\n <div className={classes.rightContent} id=\"property\">\r\n {expandedContent && (\r\n <ToggleButton\r\n title=\"Expand/Collapse property\"\r\n appearance=\"transparent\"\r\n checkedIcon={size === \"small\" ? ChevronCircleDown16Regular : ChevronCircleDown20Regular}\r\n uncheckedIcon={size === \"small\" ? ChevronCircleRight16Regular : ChevronCircleRight20Regular}\r\n value={expanded === true}\r\n onChange={setExpanded}\r\n />\r\n )}\r\n\r\n {nullable && !ignoreNullable && (\r\n // If this is a nullableProperty and ignoreNullable was not sent, display a checkbox used to toggle null ('checked' means 'non null')\r\n <Tooltip content={props.value == null ? \"Enable property\" : \"Disable property (set to null)\"}>\r\n <Checkbox\r\n className={classes.checkbox}\r\n indicator={{ className: classes.checkboxIndicator }}\r\n checked={!(props.value == null)}\r\n onChange={(_, data) => {\r\n if (data.checked) {\r\n // if checked this means we are returning to non-null, use cached value if exists. If no cached value, use default value\r\n cachedVal.current != null ? props.onChange(cachedVal.current) : props.onChange(props.defaultValue);\r\n } else {\r\n // if moving to un-checked state, this means moving to null value. Cache the old value and tell props.onChange(null)\r\n cachedVal.current = props.value;\r\n props.onChange(null);\r\n }\r\n }}\r\n />\r\n </Tooltip>\r\n )}\r\n <div className={classes.childWrapper}>{processedChildren}</div>\r\n {onCopy && !disableCopy && (\r\n <Tooltip content=\"Copy to Clipboard\">\r\n <Button className={classes.copy} appearance=\"transparent\" icon={size === \"small\" ? Copy16Regular : CopyRegular} onClick={handleCopy} />\r\n </Tooltip>\r\n )}\r\n </div>\r\n </div>\r\n {expandedContent && (\r\n <Collapse visible={!!expanded}>\r\n <div className={classes.expandedContentDiv}>{expandedContent}</div>\r\n </Collapse>\r\n )}\r\n </LineContainer>\r\n );\r\n});\r\n\r\nconst useLineStyles = makeStyles({\r\n container: {\r\n width: \"100%\",\r\n display: \"flex\",\r\n flexDirection: \"column\", // Stack line + expanded content\r\n minHeight: CustomTokens.lineHeight,\r\n boxSizing: \"border-box\",\r\n justifyContent: \"center\",\r\n paddingTop: tokens.spacingVerticalXXS,\r\n paddingBottom: tokens.spacingVerticalXXS,\r\n borderTop: `1px solid transparent`,\r\n borderBottom: `1px solid transparent`,\r\n \":hover\": {\r\n borderTopColor: tokens.colorNeutralStroke2,\r\n borderBottomColor: tokens.colorNeutralStroke2,\r\n },\r\n },\r\n containerSmall: {\r\n minHeight: CustomTokens.lineHeightSmall,\r\n },\r\n});\r\n\r\nexport const LineContainer = forwardRef<HTMLDivElement, PropsWithChildren<HTMLProps<HTMLDivElement> & AccordionSectionItemProps>>((props, ref) => {\r\n const { size } = useContext(ToolContext);\r\n const { children, uniqueId, label, ...rest } = props;\r\n const classes = useLineStyles();\r\n\r\n return (\r\n <AccordionSectionItem uniqueId={uniqueId} label={label}>\r\n <div ref={ref} className={mergeClasses(classes.container, size == \"small\" ? classes.containerSmall : undefined)} {...rest}>\r\n {children}\r\n </div>\r\n </AccordionSectionItem>\r\n );\r\n});\r\n\r\nexport const PlaceholderPropertyLine: FunctionComponent<PrimitiveProps<any> & PropertyLineProps<any>> = (props) => {\r\n return (\r\n <PropertyLine {...props}>\r\n <Body1>{props.value}</Body1>\r\n </PropertyLine>\r\n );\r\n};\r\n"]}
@@ -0,0 +1,11 @@
1
+ type KeyStateOptions = {
2
+ currentDocument?: boolean;
3
+ mainDocument?: boolean;
4
+ };
5
+ type KeyCallbacks = {
6
+ onKeyDown?: (e: KeyboardEvent) => void;
7
+ onKeyUp?: (e: KeyboardEvent) => void;
8
+ };
9
+ export declare function useKeyListener(callbacks: KeyCallbacks, options?: KeyStateOptions): void;
10
+ export declare function useKeyState(key: string, options?: KeyStateOptions): boolean;
11
+ export {};
@@ -0,0 +1,48 @@
1
+ import { useFluent } from "@fluentui/react-components";
2
+ import { useEffect, useState } from "react";
3
+ export function useKeyListener(callbacks, options) {
4
+ const watchCurrentDocument = options?.currentDocument ?? true;
5
+ const watchMainDocument = options?.mainDocument ?? true;
6
+ const { targetDocument: currentDocument } = useFluent();
7
+ const callbackMap = new Map([
8
+ ["keydown", callbacks.onKeyDown],
9
+ ["keyup", callbacks.onKeyUp],
10
+ ]);
11
+ for (const eventType of ["keydown", "keyup"]) {
12
+ for (const doc of [watchCurrentDocument ? currentDocument : null, watchMainDocument ? document : null]) {
13
+ const handler = callbackMap.get(eventType);
14
+ useEffect(() => {
15
+ if (doc && handler) {
16
+ // Ignore repeated events from holding down a key.
17
+ const guardedHandler = (e) => {
18
+ if (!e.repeat) {
19
+ handler(e);
20
+ }
21
+ };
22
+ doc.addEventListener(eventType, guardedHandler);
23
+ return () => {
24
+ doc.removeEventListener(eventType, guardedHandler);
25
+ };
26
+ }
27
+ return undefined;
28
+ }, [doc, handler]);
29
+ }
30
+ }
31
+ }
32
+ export function useKeyState(key, options) {
33
+ const [isPressed, setIsPressed] = useState(false);
34
+ useKeyListener({
35
+ onKeyDown: (e) => {
36
+ if (e.key === key) {
37
+ setIsPressed(true);
38
+ }
39
+ },
40
+ onKeyUp: (e) => {
41
+ if (e.key === key) {
42
+ setIsPressed(false);
43
+ }
44
+ },
45
+ }, options);
46
+ return isPressed;
47
+ }
48
+ //# sourceMappingURL=keyboardHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardHooks.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/hooks/keyboardHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAY5C,MAAM,UAAU,cAAc,CAAC,SAAuB,EAAE,OAAyB;IAC7E,MAAM,oBAAoB,GAAG,OAAO,EAAE,eAAe,IAAI,IAAI,CAAC;IAC9D,MAAM,iBAAiB,GAAG,OAAO,EAAE,YAAY,IAAI,IAAI,CAAC;IAExD,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,SAAS,EAAE,CAAC;IAExD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAgE;QACvF,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC;QAChC,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC;KAC/B,CAAC,CAAC;IAEH,KAAK,MAAM,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,CAAU,EAAE,CAAC;QACpD,KAAK,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;YACrG,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC3C,SAAS,CAAC,GAAG,EAAE;gBACX,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;oBACjB,kDAAkD;oBAClD,MAAM,cAAc,GAAG,CAAC,CAAgB,EAAE,EAAE;wBACxC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;4BACZ,OAAO,CAAC,CAAC,CAAC,CAAC;wBACf,CAAC;oBACL,CAAC,CAAC;oBAEF,GAAG,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;oBAChD,OAAO,GAAG,EAAE;wBACR,GAAG,CAAC,mBAAmB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;oBACvD,CAAC,CAAC;gBACN,CAAC;gBACD,OAAO,SAAS,CAAC;YACrB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAAyB;IAC9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,cAAc,CACV;QACI,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBAChB,YAAY,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACL,CAAC;QACD,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBAChB,YAAY,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACL,CAAC;KACJ,EACD,OAAO,CACV,CAAC;IAEF,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import { useFluent } from \"@fluentui/react-components\";\r\nimport { useEffect, useState } from \"react\";\r\n\r\ntype KeyStateOptions = {\r\n currentDocument?: boolean;\r\n mainDocument?: boolean;\r\n};\r\n\r\ntype KeyCallbacks = {\r\n onKeyDown?: (e: KeyboardEvent) => void;\r\n onKeyUp?: (e: KeyboardEvent) => void;\r\n};\r\n\r\nexport function useKeyListener(callbacks: KeyCallbacks, options?: KeyStateOptions) {\r\n const watchCurrentDocument = options?.currentDocument ?? true;\r\n const watchMainDocument = options?.mainDocument ?? true;\r\n\r\n const { targetDocument: currentDocument } = useFluent();\r\n\r\n const callbackMap = new Map<\"keydown\" | \"keyup\", ((e: KeyboardEvent) => void) | undefined>([\r\n [\"keydown\", callbacks.onKeyDown],\r\n [\"keyup\", callbacks.onKeyUp],\r\n ]);\r\n\r\n for (const eventType of [\"keydown\", \"keyup\"] as const) {\r\n for (const doc of [watchCurrentDocument ? currentDocument : null, watchMainDocument ? document : null]) {\r\n const handler = callbackMap.get(eventType);\r\n useEffect(() => {\r\n if (doc && handler) {\r\n // Ignore repeated events from holding down a key.\r\n const guardedHandler = (e: KeyboardEvent) => {\r\n if (!e.repeat) {\r\n handler(e);\r\n }\r\n };\r\n\r\n doc.addEventListener(eventType, guardedHandler);\r\n return () => {\r\n doc.removeEventListener(eventType, guardedHandler);\r\n };\r\n }\r\n return undefined;\r\n }, [doc, handler]);\r\n }\r\n }\r\n}\r\n\r\nexport function useKeyState(key: string, options?: KeyStateOptions): boolean {\r\n const [isPressed, setIsPressed] = useState(false);\r\n\r\n useKeyListener(\r\n {\r\n onKeyDown: (e) => {\r\n if (e.key === key) {\r\n setIsPressed(true);\r\n }\r\n },\r\n onKeyUp: (e) => {\r\n if (e.key === key) {\r\n setIsPressed(false);\r\n }\r\n },\r\n },\r\n options\r\n );\r\n\r\n return isPressed;\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A hook that provides a transient state value and a "pulse" function to set it.
3
+ * The transient value is meant to be consumed immediately after being set, and will be cleared on the next render.
4
+ * @typeParam T The type of the transient value.
5
+ * @returns A tuple containing the transient value and a function to "pulse" the state.
6
+ */
7
+ export declare function useImpulse<T>(): [T | undefined, (value: T) => void];
@@ -0,0 +1,20 @@
1
+ import { useCallback, useRef, useState } from "react";
2
+ /**
3
+ * A hook that provides a transient state value and a "pulse" function to set it.
4
+ * The transient value is meant to be consumed immediately after being set, and will be cleared on the next render.
5
+ * @typeParam T The type of the transient value.
6
+ * @returns A tuple containing the transient value and a function to "pulse" the state.
7
+ */
8
+ export function useImpulse() {
9
+ const impulseRef = useRef(undefined);
10
+ const [, setVersion] = useState(0);
11
+ const pulse = useCallback((value) => {
12
+ impulseRef.current = value;
13
+ setVersion((v) => v + 1);
14
+ }, []);
15
+ // Consume the impulse value and clear it
16
+ const value = impulseRef.current;
17
+ impulseRef.current = undefined;
18
+ return [value, pulse];
19
+ }
20
+ //# sourceMappingURL=transientStateHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transientStateHooks.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/hooks/transientStateHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,UAAU;IACtB,MAAM,UAAU,GAAG,MAAM,CAAgB,SAAS,CAAC,CAAC;IACpD,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEnC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,KAAQ,EAAE,EAAE;QACnC,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;QAC3B,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,yCAAyC;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC;IACjC,UAAU,CAAC,OAAO,GAAG,SAAS,CAAC;IAE/B,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { useCallback, useRef, useState } from \"react\";\r\n\r\n/**\r\n * A hook that provides a transient state value and a \"pulse\" function to set it.\r\n * The transient value is meant to be consumed immediately after being set, and will be cleared on the next render.\r\n * @typeParam T The type of the transient value.\r\n * @returns A tuple containing the transient value and a function to \"pulse\" the state.\r\n */\r\nexport function useImpulse<T>(): [T | undefined, (value: T) => void] {\r\n const impulseRef = useRef<T | undefined>(undefined);\r\n const [, setVersion] = useState(0);\r\n\r\n const pulse = useCallback((value: T) => {\r\n impulseRef.current = value;\r\n setVersion((v) => v + 1);\r\n }, []);\r\n\r\n // Consume the impulse value and clear it\r\n const value = impulseRef.current;\r\n impulseRef.current = undefined;\r\n\r\n return [value, pulse];\r\n}\r\n"]}
package/fluent/icons.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createFluentIcon } from "@fluentui/react-icons";
2
- export const MeshIcon = createFluentIcon("Mesh", "16", '<path d="M14.03,3.54l-5.11-2.07c-.61-.25-1.27-.25-1.88,0L1.93,3.54c-.57.23-.94.78-.94,1.39v6.15c0,.61.37,1.16.94,1.39l5.11,2.07c.3.12.62.18.94.18s.64-.06.94-.18l5.12-2.07c.57-.23.94-.78.94-1.39v-6.15c0-.61-.37-1.16-.94-1.39ZM13.97,7.71l-2.11.86v-2.71l2.11-.86v2.71ZM1.99,5l2.11.86v2.71l-2.11-.86v-2.71ZM11.35,4.98l-2.04-.83,1.78-.72,2.04.83-1.78.72ZM10.02,5.52l-2.04.83-2.04-.83,2.04-.83,2.04.83ZM4.6,4.98l-1.78-.72,2.04-.83,1.78.72-2.04.83ZM5.1,6.26l2.38.96v2.71l-2.38-.96v-2.71ZM8.48,7.22l2.38-.96v2.71l-2.38.96v-2.71ZM7.41,2.39c.18-.07.37-.11.56-.11s.38.04.56.11l1.22.49-1.78.72-1.79-.72,1.22-.49ZM1.99,11.07v-2.29l2.11.86v2.62l-1.8-.73c-.19-.08-.31-.26-.31-.46ZM5.1,12.67v-2.62l2.38.96v2.61s-.04,0-.06-.01l-2.31-.94ZM8.54,13.61s-.04,0-.06.01v-2.61l2.38-.96v2.62l-2.31.94ZM13.66,11.54l-1.8.73v-2.62l2.11-.86v2.29c0,.2-.12.39-.31.46Z"/>');
3
- export const TranslateIcon = createFluentIcon("Translate", "24", '<path d="M20.16,12.98l-2.75-2.75c-.29-.29-.77-.29-1.06,0-.29.29-.29.77,0,1.06l1.47,1.47h-6.69v-6.69l1.47,1.47c.29.29.77.29,1.06,0,.29-.29.29-.77,0-1.06l-2.75-2.75c-.14-.14-.33-.22-.53-.22s-.39.08-.53.22l-2.75,2.75c-.29.29-.29.77,0,1.06.29.29.77.29,1.06,0l1.47-1.47v7.13l-3.52,3.52v-2.08c0-.41-.34-.75-.75-.75s-.75.34-.75.75v3.89c0,.2.08.39.22.53.14.14.33.22.53.22h3.89c.41,0,.75-.34.75-.75s-.34-.75-.75-.75h-2.08s3.52-3.52,3.52-3.52h7.13l-1.47,1.47c-.29.29-.29.77,0,1.06s.77.29,1.06,0l2.75-2.75c.14-.14.22-.33.22-.53s-.08-.39-.22-.53Z" />');
4
- export const MaterialIcon = createFluentIcon("Material", "16", '<path d="M14.74,6.3c-.09-.36-.38-.64-.75-.72-.04-.09-.08-.18-.12-.27.1-.15.16-.32.16-.51,0-.18-.05-.34-.13-.48-1.23-1.97-3.41-3.28-5.9-3.28C4.16,1.04,1.04,4.16,1.04,7.99c0,.39.23.72.57.88.02.12.03.25.06.37-.18.18-.3.42-.3.7,0,.11.02.21.06.31.94,2.74,3.53,4.71,6.58,4.71,3.84,0,6.96-3.12,6.96-6.96,0-.59-.08-1.16-.22-1.7ZM2.07,8.58c-.02-.19-.03-.39-.03-.58,0-3.29,2.67-5.96,5.96-5.96,2.23,0,4.17,1.23,5.2,3.05.05.18-.07.45-.3.75-.57-.73-1.45-1.21-2.45-1.21-1.72,0-3.12,1.4-3.12,3.11,0,.33.07.65.16.95-3.05.82-5.17.52-5.42-.11ZM12.56,7.75c0,1.17-.95,2.11-2.11,2.11s-2.12-.95-2.12-2.11.95-2.11,2.12-2.11,2.11.95,2.11,2.11ZM8,13.96c-2.6,0-4.81-1.68-5.62-4.01.5.16,1.11.24,1.79.24,1.15,0,2.49-.22,3.79-.59.57.76,1.47,1.26,2.49,1.26,1.72,0,3.11-1.4,3.11-3.11,0-.34-.07-.65-.17-.96.13-.13.24-.26.34-.39.14.51.22,1.04.22,1.6,0,3.29-2.67,5.96-5.96,5.96Z"/>');
2
+ export const MeshIcon = createFluentIcon("Mesh", "1em", '<g transform="scale(1.25)"><path d="M14.03,3.54l-5.11-2.07c-.61-.25-1.27-.25-1.88,0L1.93,3.54c-.57.23-.94.78-.94,1.39v6.15c0,.61.37,1.16.94,1.39l5.11,2.07c.3.12.62.18.94.18s.64-.06.94-.18l5.12-2.07c.57-.23.94-.78.94-1.39v-6.15c0-.61-.37-1.16-.94-1.39ZM13.97,7.71l-2.11.86v-2.71l2.11-.86v2.71ZM1.99,5l2.11.86v2.71l-2.11-.86v-2.71ZM11.35,4.98l-2.04-.83,1.78-.72,2.04.83-1.78.72ZM10.02,5.52l-2.04.83-2.04-.83,2.04-.83,2.04.83ZM4.6,4.98l-1.78-.72,2.04-.83,1.78.72-2.04.83ZM5.1,6.26l2.38.96v2.71l-2.38-.96v-2.71ZM8.48,7.22l2.38-.96v2.71l-2.38.96v-2.71ZM7.41,2.39c.18-.07.37-.11.56-.11s.38.04.56.11l1.22.49-1.78.72-1.79-.72,1.22-.49ZM1.99,11.07v-2.29l2.11.86v2.62l-1.8-.73c-.19-.08-.31-.26-.31-.46ZM5.1,12.67v-2.62l2.38.96v2.61s-.04,0-.06-.01l-2.31-.94ZM8.54,13.61s-.04,0-.06.01v-2.61l2.38-.96v2.62l-2.31.94ZM13.66,11.54l-1.8.73v-2.62l2.11-.86v2.29c0,.2-.12.39-.31.46Z"/></g>');
3
+ export const TranslateIcon = createFluentIcon("Translate", "1em", '<g transform="scale(0.833)"><path d="M20.16,12.98l-2.75-2.75c-.29-.29-.77-.29-1.06,0-.29.29-.29.77,0,1.06l1.47,1.47h-6.69v-6.69l1.47,1.47c.29.29.77.29,1.06,0,.29-.29.29-.77,0-1.06l-2.75-2.75c-.14-.14-.33-.22-.53-.22s-.39.08-.53.22l-2.75,2.75c-.29.29-.29.77,0,1.06.29.29.77.29,1.06,0l1.47-1.47v7.13l-3.52,3.52v-2.08c0-.41-.34-.75-.75-.75s-.75.34-.75.75v3.89c0,.2.08.39.22.53.14.14.33.22.53.22h3.89c.41,0,.75-.34.75-.75s-.34-.75-.75-.75h-2.08s3.52-3.52,3.52-3.52h7.13l-1.47,1.47c-.29.29-.29.77,0,1.06s.77.29,1.06,0l2.75-2.75c.14-.14.22-.33.22-.53s-.08-.39-.22-.53Z" /></g>');
4
+ export const MaterialIcon = createFluentIcon("Material", "1em", '<g transform="scale(1.25)"><path d="M14.74,6.3c-.09-.36-.38-.64-.75-.72-.04-.09-.08-.18-.12-.27.1-.15.16-.32.16-.51,0-.18-.05-.34-.13-.48-1.23-1.97-3.41-3.28-5.9-3.28C4.16,1.04,1.04,4.16,1.04,7.99c0,.39.23.72.57.88.02.12.03.25.06.37-.18.18-.3.42-.3.7,0,.11.02.21.06.31.94,2.74,3.53,4.71,6.58,4.71,3.84,0,6.96-3.12,6.96-6.96,0-.59-.08-1.16-.22-1.7ZM2.07,8.58c-.02-.19-.03-.39-.03-.58,0-3.29,2.67-5.96,5.96-5.96,2.23,0,4.17,1.23,5.2,3.05.05.18-.07.45-.3.75-.57-.73-1.45-1.21-2.45-1.21-1.72,0-3.12,1.4-3.12,3.11,0,.33.07.65.16.95-3.05.82-5.17.52-5.42-.11ZM12.56,7.75c0,1.17-.95,2.11-2.11,2.11s-2.12-.95-2.12-2.11.95-2.11,2.12-2.11,2.11.95,2.11,2.11ZM8,13.96c-2.6,0-4.81-1.68-5.62-4.01.5.16,1.11.24,1.79.24,1.15,0,2.49-.22,3.79-.59.57.76,1.47,1.26,2.49,1.26,1.72,0,3.11-1.4,3.11-3.11,0-.34-.07-.65-.17-.96.13-.13.24-.26.34-.39.14.51.22,1.04.22,1.6,0,3.29-2.67,5.96-5.96,5.96Z"/></g>');
5
5
  export const FlatTangentIcon = createFluentIcon("FlatTangent", "20", '<g transform="scale(0.5)"><path d="M28,18.5a1.51,1.51,0,0,0-1.41,1H11.5v1H26.59a1.5,1.5,0,1,0,1.41-2Z"/></g>');
6
6
  export const LinearTangentIcon = createFluentIcon("LinearTangent", "20", '<g transform="scale(0.5)"><path d="M26,14a1.49,1.49,0,0,0-2.4,1.69l-10,10,.71.71,10-10A1.49,1.49,0,0,0,26,14Z"/></g>');
7
7
  export const BreakTangentIcon = createFluentIcon("BreakTangent", "20", '<g transform="scale(0.5)"><path d="M27.11,13.05a1.49,1.49,0,0,0-2.05.53,1.47,1.47,0,0,0,.14,1.72l-4.78,8L20,22.92l-.42.42-4.78-8a1.47,1.47,0,0,0,.14-1.72,1.49,1.49,0,0,0-2-.53,1.5,1.5,0,0,0,1,2.76l4.91,8.26-1,1L20,27.16,22.12,25l-1-1,4.91-8.26a1.5,1.5,0,0,0,1.05-2.76Z"/></g>');
@@ -1 +1 @@
1
- {"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/fluent/icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CACpC,MAAM,EACN,IAAI,EACJ,w0BAAw0B,CAC30B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CACzC,WAAW,EACX,IAAI,EACJ,4hBAA4hB,CAC/hB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CACxC,UAAU,EACV,IAAI,EACJ,i1BAAi1B,CACp1B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAC3C,aAAa,EACb,IAAI,EACJ,8GAA8G,CACjH,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAC7C,eAAe,EACf,IAAI,EACJ,sHAAsH,CACzH,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAC5C,cAAc,EACd,IAAI,EACJ,qRAAqR,CACxR,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAC5C,cAAc,EACd,IAAI,EACJ,0KAA0K,CAC7K,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAC3C,aAAa,EACb,IAAI,EACJ,uHAAuH,CAC1H,CAAC","sourcesContent":["import { createFluentIcon } from \"@fluentui/react-icons\";\r\n\r\nexport const MeshIcon = createFluentIcon(\r\n \"Mesh\",\r\n \"16\",\r\n '<path d=\"M14.03,3.54l-5.11-2.07c-.61-.25-1.27-.25-1.88,0L1.93,3.54c-.57.23-.94.78-.94,1.39v6.15c0,.61.37,1.16.94,1.39l5.11,2.07c.3.12.62.18.94.18s.64-.06.94-.18l5.12-2.07c.57-.23.94-.78.94-1.39v-6.15c0-.61-.37-1.16-.94-1.39ZM13.97,7.71l-2.11.86v-2.71l2.11-.86v2.71ZM1.99,5l2.11.86v2.71l-2.11-.86v-2.71ZM11.35,4.98l-2.04-.83,1.78-.72,2.04.83-1.78.72ZM10.02,5.52l-2.04.83-2.04-.83,2.04-.83,2.04.83ZM4.6,4.98l-1.78-.72,2.04-.83,1.78.72-2.04.83ZM5.1,6.26l2.38.96v2.71l-2.38-.96v-2.71ZM8.48,7.22l2.38-.96v2.71l-2.38.96v-2.71ZM7.41,2.39c.18-.07.37-.11.56-.11s.38.04.56.11l1.22.49-1.78.72-1.79-.72,1.22-.49ZM1.99,11.07v-2.29l2.11.86v2.62l-1.8-.73c-.19-.08-.31-.26-.31-.46ZM5.1,12.67v-2.62l2.38.96v2.61s-.04,0-.06-.01l-2.31-.94ZM8.54,13.61s-.04,0-.06.01v-2.61l2.38-.96v2.62l-2.31.94ZM13.66,11.54l-1.8.73v-2.62l2.11-.86v2.29c0,.2-.12.39-.31.46Z\"/>'\r\n);\r\n\r\nexport const TranslateIcon = createFluentIcon(\r\n \"Translate\",\r\n \"24\",\r\n '<path d=\"M20.16,12.98l-2.75-2.75c-.29-.29-.77-.29-1.06,0-.29.29-.29.77,0,1.06l1.47,1.47h-6.69v-6.69l1.47,1.47c.29.29.77.29,1.06,0,.29-.29.29-.77,0-1.06l-2.75-2.75c-.14-.14-.33-.22-.53-.22s-.39.08-.53.22l-2.75,2.75c-.29.29-.29.77,0,1.06.29.29.77.29,1.06,0l1.47-1.47v7.13l-3.52,3.52v-2.08c0-.41-.34-.75-.75-.75s-.75.34-.75.75v3.89c0,.2.08.39.22.53.14.14.33.22.53.22h3.89c.41,0,.75-.34.75-.75s-.34-.75-.75-.75h-2.08s3.52-3.52,3.52-3.52h7.13l-1.47,1.47c-.29.29-.29.77,0,1.06s.77.29,1.06,0l2.75-2.75c.14-.14.22-.33.22-.53s-.08-.39-.22-.53Z\" />'\r\n);\r\n\r\nexport const MaterialIcon = createFluentIcon(\r\n \"Material\",\r\n \"16\",\r\n '<path d=\"M14.74,6.3c-.09-.36-.38-.64-.75-.72-.04-.09-.08-.18-.12-.27.1-.15.16-.32.16-.51,0-.18-.05-.34-.13-.48-1.23-1.97-3.41-3.28-5.9-3.28C4.16,1.04,1.04,4.16,1.04,7.99c0,.39.23.72.57.88.02.12.03.25.06.37-.18.18-.3.42-.3.7,0,.11.02.21.06.31.94,2.74,3.53,4.71,6.58,4.71,3.84,0,6.96-3.12,6.96-6.96,0-.59-.08-1.16-.22-1.7ZM2.07,8.58c-.02-.19-.03-.39-.03-.58,0-3.29,2.67-5.96,5.96-5.96,2.23,0,4.17,1.23,5.2,3.05.05.18-.07.45-.3.75-.57-.73-1.45-1.21-2.45-1.21-1.72,0-3.12,1.4-3.12,3.11,0,.33.07.65.16.95-3.05.82-5.17.52-5.42-.11ZM12.56,7.75c0,1.17-.95,2.11-2.11,2.11s-2.12-.95-2.12-2.11.95-2.11,2.12-2.11,2.11.95,2.11,2.11ZM8,13.96c-2.6,0-4.81-1.68-5.62-4.01.5.16,1.11.24,1.79.24,1.15,0,2.49-.22,3.79-.59.57.76,1.47,1.26,2.49,1.26,1.72,0,3.11-1.4,3.11-3.11,0-.34-.07-.65-.17-.96.13-.13.24-.26.34-.39.14.51.22,1.04.22,1.6,0,3.29-2.67,5.96-5.96,5.96Z\"/>'\r\n);\r\n\r\nexport const FlatTangentIcon = createFluentIcon(\r\n \"FlatTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M28,18.5a1.51,1.51,0,0,0-1.41,1H11.5v1H26.59a1.5,1.5,0,1,0,1.41-2Z\"/></g>'\r\n);\r\n\r\nexport const LinearTangentIcon = createFluentIcon(\r\n \"LinearTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M26,14a1.49,1.49,0,0,0-2.4,1.69l-10,10,.71.71,10-10A1.49,1.49,0,0,0,26,14Z\"/></g>'\r\n);\r\n\r\nexport const BreakTangentIcon = createFluentIcon(\r\n \"BreakTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M27.11,13.05a1.49,1.49,0,0,0-2.05.53,1.47,1.47,0,0,0,.14,1.72l-4.78,8L20,22.92l-.42.42-4.78-8a1.47,1.47,0,0,0,.14-1.72,1.49,1.49,0,0,0-2-.53,1.5,1.5,0,0,0,1,2.76l4.91,8.26-1,1L20,27.16,22.12,25l-1-1,4.91-8.26a1.5,1.5,0,0,0,1.05-2.76Z\"/></g>'\r\n);\r\n\r\nexport const UnifyTangentIcon = createFluentIcon(\r\n \"UnifyTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M27.94,18.28a1.49,1.49,0,0,0-1.41,1h-5l-1.62-1.63-1.62,1.63h-5a1.5,1.5,0,1,0,0,1h5l1.62,1.62,1.62-1.62h5a1.5,1.5,0,1,0,1.41-2Z\"/></g>'\r\n);\r\n\r\nexport const StepTangentIcon = createFluentIcon(\r\n \"StepTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M29,16.71a1.5,1.5,0,1,0-2,1.41v5.67H11v1H28V18.12A1.51,1.51,0,0,0,29,16.71Z\"/></g>'\r\n);\r\n"]}
1
+ {"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/fluent/icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CACpC,MAAM,EACN,KAAK,EACL,u2BAAu2B,CAC12B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CACzC,WAAW,EACX,KAAK,EACL,4jBAA4jB,CAC/jB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CACxC,UAAU,EACV,KAAK,EACL,g3BAAg3B,CACn3B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAC3C,aAAa,EACb,IAAI,EACJ,8GAA8G,CACjH,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAC7C,eAAe,EACf,IAAI,EACJ,sHAAsH,CACzH,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAC5C,cAAc,EACd,IAAI,EACJ,qRAAqR,CACxR,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAC5C,cAAc,EACd,IAAI,EACJ,0KAA0K,CAC7K,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAC3C,aAAa,EACb,IAAI,EACJ,uHAAuH,CAC1H,CAAC","sourcesContent":["import { createFluentIcon } from \"@fluentui/react-icons\";\r\n\r\nexport const MeshIcon = createFluentIcon(\r\n \"Mesh\",\r\n \"1em\",\r\n '<g transform=\"scale(1.25)\"><path d=\"M14.03,3.54l-5.11-2.07c-.61-.25-1.27-.25-1.88,0L1.93,3.54c-.57.23-.94.78-.94,1.39v6.15c0,.61.37,1.16.94,1.39l5.11,2.07c.3.12.62.18.94.18s.64-.06.94-.18l5.12-2.07c.57-.23.94-.78.94-1.39v-6.15c0-.61-.37-1.16-.94-1.39ZM13.97,7.71l-2.11.86v-2.71l2.11-.86v2.71ZM1.99,5l2.11.86v2.71l-2.11-.86v-2.71ZM11.35,4.98l-2.04-.83,1.78-.72,2.04.83-1.78.72ZM10.02,5.52l-2.04.83-2.04-.83,2.04-.83,2.04.83ZM4.6,4.98l-1.78-.72,2.04-.83,1.78.72-2.04.83ZM5.1,6.26l2.38.96v2.71l-2.38-.96v-2.71ZM8.48,7.22l2.38-.96v2.71l-2.38.96v-2.71ZM7.41,2.39c.18-.07.37-.11.56-.11s.38.04.56.11l1.22.49-1.78.72-1.79-.72,1.22-.49ZM1.99,11.07v-2.29l2.11.86v2.62l-1.8-.73c-.19-.08-.31-.26-.31-.46ZM5.1,12.67v-2.62l2.38.96v2.61s-.04,0-.06-.01l-2.31-.94ZM8.54,13.61s-.04,0-.06.01v-2.61l2.38-.96v2.62l-2.31.94ZM13.66,11.54l-1.8.73v-2.62l2.11-.86v2.29c0,.2-.12.39-.31.46Z\"/></g>'\r\n);\r\n\r\nexport const TranslateIcon = createFluentIcon(\r\n \"Translate\",\r\n \"1em\",\r\n '<g transform=\"scale(0.833)\"><path d=\"M20.16,12.98l-2.75-2.75c-.29-.29-.77-.29-1.06,0-.29.29-.29.77,0,1.06l1.47,1.47h-6.69v-6.69l1.47,1.47c.29.29.77.29,1.06,0,.29-.29.29-.77,0-1.06l-2.75-2.75c-.14-.14-.33-.22-.53-.22s-.39.08-.53.22l-2.75,2.75c-.29.29-.29.77,0,1.06.29.29.77.29,1.06,0l1.47-1.47v7.13l-3.52,3.52v-2.08c0-.41-.34-.75-.75-.75s-.75.34-.75.75v3.89c0,.2.08.39.22.53.14.14.33.22.53.22h3.89c.41,0,.75-.34.75-.75s-.34-.75-.75-.75h-2.08s3.52-3.52,3.52-3.52h7.13l-1.47,1.47c-.29.29-.29.77,0,1.06s.77.29,1.06,0l2.75-2.75c.14-.14.22-.33.22-.53s-.08-.39-.22-.53Z\" /></g>'\r\n);\r\n\r\nexport const MaterialIcon = createFluentIcon(\r\n \"Material\",\r\n \"1em\",\r\n '<g transform=\"scale(1.25)\"><path d=\"M14.74,6.3c-.09-.36-.38-.64-.75-.72-.04-.09-.08-.18-.12-.27.1-.15.16-.32.16-.51,0-.18-.05-.34-.13-.48-1.23-1.97-3.41-3.28-5.9-3.28C4.16,1.04,1.04,4.16,1.04,7.99c0,.39.23.72.57.88.02.12.03.25.06.37-.18.18-.3.42-.3.7,0,.11.02.21.06.31.94,2.74,3.53,4.71,6.58,4.71,3.84,0,6.96-3.12,6.96-6.96,0-.59-.08-1.16-.22-1.7ZM2.07,8.58c-.02-.19-.03-.39-.03-.58,0-3.29,2.67-5.96,5.96-5.96,2.23,0,4.17,1.23,5.2,3.05.05.18-.07.45-.3.75-.57-.73-1.45-1.21-2.45-1.21-1.72,0-3.12,1.4-3.12,3.11,0,.33.07.65.16.95-3.05.82-5.17.52-5.42-.11ZM12.56,7.75c0,1.17-.95,2.11-2.11,2.11s-2.12-.95-2.12-2.11.95-2.11,2.12-2.11,2.11.95,2.11,2.11ZM8,13.96c-2.6,0-4.81-1.68-5.62-4.01.5.16,1.11.24,1.79.24,1.15,0,2.49-.22,3.79-.59.57.76,1.47,1.26,2.49,1.26,1.72,0,3.11-1.4,3.11-3.11,0-.34-.07-.65-.17-.96.13-.13.24-.26.34-.39.14.51.22,1.04.22,1.6,0,3.29-2.67,5.96-5.96,5.96Z\"/></g>'\r\n);\r\n\r\nexport const FlatTangentIcon = createFluentIcon(\r\n \"FlatTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M28,18.5a1.51,1.51,0,0,0-1.41,1H11.5v1H26.59a1.5,1.5,0,1,0,1.41-2Z\"/></g>'\r\n);\r\n\r\nexport const LinearTangentIcon = createFluentIcon(\r\n \"LinearTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M26,14a1.49,1.49,0,0,0-2.4,1.69l-10,10,.71.71,10-10A1.49,1.49,0,0,0,26,14Z\"/></g>'\r\n);\r\n\r\nexport const BreakTangentIcon = createFluentIcon(\r\n \"BreakTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M27.11,13.05a1.49,1.49,0,0,0-2.05.53,1.47,1.47,0,0,0,.14,1.72l-4.78,8L20,22.92l-.42.42-4.78-8a1.47,1.47,0,0,0,.14-1.72,1.49,1.49,0,0,0-2-.53,1.5,1.5,0,0,0,1,2.76l4.91,8.26-1,1L20,27.16,22.12,25l-1-1,4.91-8.26a1.5,1.5,0,0,0,1.05-2.76Z\"/></g>'\r\n);\r\n\r\nexport const UnifyTangentIcon = createFluentIcon(\r\n \"UnifyTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M27.94,18.28a1.49,1.49,0,0,0-1.41,1h-5l-1.62-1.63-1.62,1.63h-5a1.5,1.5,0,1,0,0,1h5l1.62,1.62,1.62-1.62h5a1.5,1.5,0,1,0,1.41-2Z\"/></g>'\r\n);\r\n\r\nexport const StepTangentIcon = createFluentIcon(\r\n \"StepTangent\",\r\n \"20\",\r\n '<g transform=\"scale(0.5)\"><path d=\"M29,16.71a1.5,1.5,0,1,0-2,1.41v5.67H11v1H28V18.12A1.51,1.51,0,0,0,29,16.71Z\"/></g>'\r\n);\r\n"]}
@@ -0,0 +1,136 @@
1
+ import type { RefObject } from "react";
2
+ import type { AccordionProps, AccordionSectionBlockProps, AccordionSectionItemProps } from "./accordion.js";
3
+ /**
4
+ * Immutable state for the Accordion.
5
+ */
6
+ export type AccordionState = {
7
+ /** IDs of pinned items (persisted to localStorage). */
8
+ pinnedIds: string[];
9
+ /** IDs of hidden items (persisted to localStorage). */
10
+ hiddenIds: string[];
11
+ /** Current search/filter term. */
12
+ searchTerm: string;
13
+ /** Whether edit mode is active (shows pin/hide controls). */
14
+ editMode: boolean;
15
+ };
16
+ /**
17
+ * Actions that can be dispatched to update accordion state.
18
+ */
19
+ export type AccordionAction = {
20
+ type: "SET_SEARCH_TERM";
21
+ term: string;
22
+ } | {
23
+ type: "SET_EDIT_MODE";
24
+ enabled: boolean;
25
+ } | {
26
+ type: "TOGGLE_PINNED";
27
+ itemId: string;
28
+ } | {
29
+ type: "TOGGLE_HIDDEN";
30
+ itemId: string;
31
+ } | {
32
+ type: "MOVE_PINNED_UP";
33
+ itemId: string;
34
+ } | {
35
+ type: "SHOW_ALL";
36
+ } | {
37
+ type: "HIDE_ALL_VISIBLE";
38
+ visibleItemIds: string[];
39
+ };
40
+ /**
41
+ * Feature flags for the Accordion (immutable after initialization).
42
+ */
43
+ export type AccordionFeatures = {
44
+ /** Whether pinning is enabled. */
45
+ pinning: boolean;
46
+ /** Whether hiding is enabled. */
47
+ hiding: boolean;
48
+ /** Whether search is enabled. */
49
+ search: boolean;
50
+ };
51
+ /**
52
+ * Context value for the Accordion component.
53
+ */
54
+ export type AccordionContextValue = {
55
+ /** The unique ID of the Accordion instance. */
56
+ accordionId: string;
57
+ /** State for the Accordion, managed via dispatch function. */
58
+ state: AccordionState;
59
+ /** Dispatch function to update state. */
60
+ dispatch: React.Dispatch<AccordionAction>;
61
+ /** Feature flags. */
62
+ features: AccordionFeatures;
63
+ /** Ref for the pinned items portal container. */
64
+ pinnedContainerRef: RefObject<HTMLDivElement>;
65
+ /** Set of registered item IDs (for duplicate detection). */
66
+ registeredItemIds: React.MutableRefObject<Set<string>>;
67
+ };
68
+ export declare const AccordionContext: import("react").Context<AccordionContextValue | undefined>;
69
+ /**
70
+ * Hook to create and manage the AccordionContext value.
71
+ *
72
+ * @param props - AccordionProps
73
+ * @returns AccordionContextValue, or undefined if no features are enabled or no uniqueId is provided.
74
+ */
75
+ export declare function useAccordionContext(props: AccordionProps): AccordionContextValue | undefined;
76
+ /**
77
+ * Context value for an AccordionSectionBlock.
78
+ */
79
+ export type AccordionSectionBlockContextValue = {
80
+ /** The section ID. */
81
+ sectionId: string;
82
+ };
83
+ export declare const AccordionSectionBlockContext: import("react").Context<AccordionSectionBlockContextValue | undefined>;
84
+ /**
85
+ * Hook to create the AccordionSectionBlockContext value.
86
+ *
87
+ * @param props - AccordionSectionBlockProps
88
+ * @returns AccordionSectionBlockContextValue
89
+ */
90
+ export declare function useAccordionSectionBlockContext(props: AccordionSectionBlockProps): AccordionSectionBlockContextValue;
91
+ /**
92
+ * Context to track whether we're inside an AccordionSectionItem.
93
+ * Used to prevent nested items from being individually manageable.
94
+ */
95
+ export declare const AccordionItemDepthContext: import("react").Context<boolean>;
96
+ /**
97
+ * Derived item state, computed from the accordion state during render.
98
+ */
99
+ export type AccordionItemState = {
100
+ /** The globally unique item ID. */
101
+ itemUniqueId: string;
102
+ /** Whether this item is nested inside another AccordionSectionItem. */
103
+ isNested: boolean;
104
+ /** Whether this item is pinned. */
105
+ isPinned: boolean;
106
+ /** Whether this item is hidden. */
107
+ isHidden: boolean;
108
+ /** Whether this item matches the current search term. */
109
+ isMatch: boolean;
110
+ /** The index of this item in the pinned list (for ordering). */
111
+ pinnedIndex: number;
112
+ /** Whether edit mode is active. */
113
+ inEditMode: boolean;
114
+ /** Callbacks to modify state. */
115
+ actions: {
116
+ togglePinned: () => void;
117
+ toggleHidden: () => void;
118
+ movePinnedUp: () => void;
119
+ };
120
+ };
121
+ /**
122
+ * Hook to compute item state from accordion context.
123
+ *
124
+ * @param props - AccordionSectionItemProps
125
+ * @returns AccordionItemState, or undefined if no accordion context or nested item.
126
+ */
127
+ export declare function useAccordionSectionItemState(props: AccordionSectionItemProps): AccordionItemState | undefined;
128
+ /**
129
+ * Hook to determine if a section should be hidden because it has no visible items.
130
+ * This is computed during render based on the current state.
131
+ *
132
+ * @param sectionId - The section ID to check.
133
+ * @param registeredItems - Map of item IDs to their labels in this section.
134
+ * @returns Whether the section is empty (has no visible items).
135
+ */
136
+ export declare function useIsSectionEmpty(sectionId: string, registeredItems: Map<string, string>): boolean;