@hitachivantara/uikit-react-core 5.83.1 → 5.84.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/cjs/FileUploader/DropZone/DropZone.cjs +29 -14
- package/dist/cjs/FileUploader/DropZone/DropZone.styles.cjs +14 -26
- package/dist/cjs/FileUploader/FileUploader.cjs +12 -12
- package/dist/cjs/FileUploader/FileUploader.styles.cjs +8 -0
- package/dist/cjs/FileUploader/utils.cjs +0 -1
- package/dist/cjs/FormElement/Suggestions/Suggestions.cjs +1 -1
- package/dist/cjs/FormElement/Suggestions/Suggestions.styles.cjs +1 -0
- package/dist/cjs/Select/Select.cjs +5 -3
- package/dist/cjs/Select/Select.styles.cjs +7 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/esm/FileUploader/DropZone/DropZone.js +30 -15
- package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
- package/dist/esm/FileUploader/DropZone/DropZone.styles.js +14 -26
- package/dist/esm/FileUploader/DropZone/DropZone.styles.js.map +1 -1
- package/dist/esm/FileUploader/FileUploader.js +14 -13
- package/dist/esm/FileUploader/FileUploader.js.map +1 -1
- package/dist/esm/FileUploader/FileUploader.styles.js +8 -0
- package/dist/esm/FileUploader/FileUploader.styles.js.map +1 -0
- package/dist/esm/FileUploader/utils.js +1 -2
- package/dist/esm/FileUploader/utils.js.map +1 -1
- package/dist/esm/FormElement/Suggestions/Suggestions.js +2 -2
- package/dist/esm/FormElement/Suggestions/Suggestions.js.map +1 -1
- package/dist/esm/FormElement/Suggestions/Suggestions.styles.js +1 -0
- package/dist/esm/FormElement/Suggestions/Suggestions.styles.js.map +1 -1
- package/dist/esm/ListContainer/ListItem/ListItem.js.map +1 -1
- package/dist/esm/Select/Select.js +5 -3
- package/dist/esm/Select/Select.js.map +1 -1
- package/dist/esm/Select/Select.styles.js +7 -1
- package/dist/esm/Select/Select.styles.js.map +1 -1
- package/dist/esm/index.js +128 -126
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +311 -252
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploader.js","sources":["../../../src/FileUploader/FileUploader.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"FileUploader.js","sources":["../../../src/FileUploader/FileUploader.tsx"],"sourcesContent":["import {\n ExtractNames,\n useDefaultProps,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvFormElement, HvFormElementProps } from \"../FormElement\";\nimport { useLabels } from \"../hooks/useLabels\";\nimport { setId } from \"../utils/setId\";\nimport { HvDropZone, HvDropZoneLabels, HvDropZoneProps } from \"./DropZone\";\nimport { HvFileData, HvFileRemovedEvent, HvFilesAddedEvent } from \"./File\";\nimport { HvFileList } from \"./FileList\";\nimport { staticClasses, useClasses } from \"./FileUploader.styles\";\n\nexport { staticClasses as fileUploaderClasses };\n\nexport type HvFileUploaderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFileUploaderLabels extends HvDropZoneLabels {\n /** Value of aria-label to apply to remove file button in FileList */\n removeFileButtonLabel?: string;\n}\n\nexport interface HvFileUploaderProps extends HvFormElementProps {\n /**\n * An object containing all the labels.\n */\n labels?: HvFileUploaderLabels;\n /**\n * An object used to override or extend the styles applied to the component.\n */\n classes?: HvFileUploaderClasses;\n /**\n * The files to upload.\n */\n fileList?: HvFileData[];\n /**\n * Whether the Dropzone should accept multiple files at once.\n */\n multiple?: boolean;\n /**\n * If the input is disabled or not\n */\n disabled?: boolean;\n /**\n * Max upload size\n * */\n maxFileSize?: number;\n /** File types accepted for uploading. @see [HTML input file accept](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) */\n accept?: HvDropZoneProps[\"accept\"];\n /** Files extensions accepted for upload. @deprecated use `accept` instead */\n acceptedFiles?: string[];\n /**\n * Callback fired when files are added.\n */\n onFilesAdded?: HvFilesAddedEvent;\n /**\n * Callback fired when file is removed from list.\n */\n onFileRemoved?: HvFileRemovedEvent;\n /**\n * Whether the DropZone should hide labels or not.\n */\n hideLabels?: boolean;\n /**\n * Attributes applied to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n}\n\n// TODO: This component needs to adopt the Form element shape and deprecate its way of composing labels\n\nconst DEFAULT_LABELS = {\n removeFileButtonLabel: \"Remove File\",\n};\n\n/**\n * Lets the user choose one or more files from their device storage. Once chosen,\n * the files can be uploaded to a server or manipulated on the client side.\n *\n * Accepted file types follow the format of the html [input accept attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file).\n */\nexport const HvFileUploader = (props: HvFileUploaderProps) => {\n const {\n id,\n className,\n classes: classesProp,\n labels: labelsProp,\n fileList,\n multiple = true,\n label,\n hideLabels,\n maxFileSize = Infinity,\n inputProps = {},\n accept,\n acceptedFiles = [],\n // TODO: consider adding/replacing with onFilesChange\n onFilesAdded,\n onFileRemoved,\n ...others\n } = useDefaultProps(\"HvFileUploader\", props);\n const { classes, cx } = useClasses(classesProp);\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n return (\n <HvFormElement id={id} className={cx(classes.root, className)} {...others}>\n <HvDropZone\n id={setId(id, \"dropzone\")}\n label={label}\n labels={labels}\n multiple={multiple}\n accept={accept ?? acceptedFiles.join(\",\")}\n maxFileSize={maxFileSize}\n onFilesAdded={onFilesAdded}\n inputProps={inputProps}\n hideLabels={hideLabels}\n />\n <HvFileList\n id={setId(id, \"filelist\")}\n list={fileList}\n onFileRemoved={onFileRemoved}\n removeFileButtonLabel={labels?.removeFileButtonLabel}\n />\n </HvFormElement>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAuEA,MAAM,iBAAiB;AAAA,EACrB,uBAAuB;AACzB;AAQa,MAAA,iBAAiB,CAAC,UAA+B;AACtD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,QAAQ;AAAA,IACR;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,aAAa,CAAC;AAAA,IACd;AAAA,IACA,gBAAgB,CAAC;AAAA;AAAA,IAEjB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,kBAAkB,KAAK;AAC3C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AACxC,QAAA,SAAS,UAAU,gBAAgB,UAAU;AAGjD,SAAA,qBAAC,eAAc,EAAA,IAAQ,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,QACjE,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,MAAM,IAAI,UAAU;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,QACA,QAAQ,UAAU,cAAc,KAAK,GAAG;AAAA,QACxC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,MAAM,IAAI,UAAU;AAAA,QACxB,MAAM;AAAA,QACN;AAAA,QACA,uBAAuB,QAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,EACjC,GACF;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploader.styles.js","sources":["../../../src/FileUploader/FileUploader.styles.ts"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvFileUploader\", {\n root: {},\n});\n"],"names":[],"mappings":";AAEO,MAAM,EAAE,eAAe,eAAe,cAAc,kBAAkB;AAAA,EAC3E,MAAM,CAAA;AACR,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/FileUploader/utils.ts"],"sourcesContent":["const units = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/FileUploader/utils.ts"],"sourcesContent":["const units = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\nconst findBestUnit = (bytes: number, base = 1000) => {\n const i = bytes > 0 ? Math.floor(Math.log(bytes) / Math.log(base)) : 0;\n const si = Math.min(i, units.length - 1); // safe index\n\n return { unit: units[si], value: bytes / base ** si };\n};\n\nexport const convertUnits = (bytes: number, base = 1000) => {\n const { unit, value } = findBestUnit(bytes, base);\n\n return value.toFixed(2) + unit;\n};\n"],"names":[],"mappings":"AAAA,MAAM,QAAQ,CAAC,KAAK,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI;AAElE,MAAM,eAAe,CAAC,OAAe,OAAO,QAAS;AACnD,QAAM,IAAI,QAAQ,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI;AACrE,QAAM,KAAK,KAAK,IAAI,GAAG,MAAM,SAAS,CAAC;AAEhC,SAAA,EAAE,MAAM,MAAM,EAAE,GAAG,OAAO,QAAQ,QAAQ,GAAG;AACtD;AAEO,MAAM,eAAe,CAAC,OAAe,OAAO,QAAS;AAC1D,QAAM,EAAE,MAAM,MAAA,IAAU,aAAa,OAAO,IAAI;AAEzC,SAAA,MAAM,QAAQ,CAAC,IAAI;AAC5B;"}
|
|
@@ -3,7 +3,7 @@ import { forwardRef, useContext, useRef, useState, useEffect } from "react";
|
|
|
3
3
|
import { ClickAwayListener } from "@mui/base/ClickAwayListener";
|
|
4
4
|
import { Popper } from "@mui/base/Popper";
|
|
5
5
|
import { useForkRef } from "@mui/material/utils";
|
|
6
|
-
import { useTheme } from "@hitachivantara/uikit-react-utils";
|
|
6
|
+
import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-utils";
|
|
7
7
|
import { getContainerElement } from "../../utils/document.js";
|
|
8
8
|
import { setId } from "../../utils/setId.js";
|
|
9
9
|
import { HvFormElementContext } from "../context.js";
|
|
@@ -25,7 +25,7 @@ const HvSuggestions = forwardRef(function HvSuggestions2(props, extRef) {
|
|
|
25
25
|
onSuggestionSelected,
|
|
26
26
|
popperProps,
|
|
27
27
|
...others
|
|
28
|
-
} = props;
|
|
28
|
+
} = useDefaultProps("HvSuggestions", props);
|
|
29
29
|
const { classes, cx } = useClasses(classesProp);
|
|
30
30
|
const { rootId } = useTheme();
|
|
31
31
|
const context = useContext(HvFormElementContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggestions.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useRef, useState } from \"react\";\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n} from \"@mui/base/ClickAwayListener\";\nimport { Popper, PopperProps } from \"@mui/base/Popper\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport {
|
|
1
|
+
{"version":3,"file":"Suggestions.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.tsx"],"sourcesContent":["import { forwardRef, useContext, useEffect, useRef, useState } from \"react\";\nimport {\n ClickAwayListener,\n ClickAwayListenerProps,\n} from \"@mui/base/ClickAwayListener\";\nimport { Popper, PopperProps } from \"@mui/base/Popper\";\nimport { useForkRef } from \"@mui/material/utils\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvListItem } from \"../../ListContainer\";\nimport { HvSelectionList } from \"../../SelectionList\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { getContainerElement } from \"../../utils/document\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFormElementContext } from \"../context\";\nimport { staticClasses, useClasses } from \"./Suggestions.styles\";\n\nexport { staticClasses as suggestionsClasses };\n\nexport type HvSuggestionsClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSuggestion {\n id?: string;\n label: React.ReactNode;\n value?: string;\n disabled?: boolean;\n}\n\nexport interface HvSuggestionsProps extends HvBaseProps {\n /** Whether suggestions is visible */\n open?: boolean;\n /**\n * Whether suggestions is visible.\n * @deprecated use `open` instead.\n * */\n expanded?: boolean;\n /** The HTML element Suggestions attaches to. */\n anchorEl?: HTMLElement | null;\n /** Array of { id, label, ...others } values to display in the suggestion list */\n suggestionValues?: HvSuggestion[] | null;\n /** Function called when a suggestion is selected */\n onSuggestionSelected?: (event: React.MouseEvent, value: HvSuggestion) => void;\n /** Function called when suggestion list is closed */\n onClose?: ClickAwayListenerProps[\"onClickAway\"];\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSuggestionsClasses;\n /**\n * If enabled, the suggestions list will be rendered using a portal.\n * If disabled, it will be under the DOM hierarchy of the parent component.\n * @default false\n * */\n enablePortal?: boolean;\n /** Props passed to the underlying MUI Popper component */\n popperProps?: Partial<PopperProps>;\n}\n\nexport const HvSuggestions = forwardRef<\n // no-indent\n unknown,\n HvSuggestionsProps\n>(function HvSuggestions(props, extRef) {\n const {\n id: idProp,\n className,\n classes: classesProp,\n expanded = false,\n enablePortal = false,\n open: openProp,\n anchorEl,\n suggestionValues = [],\n onClose,\n onSuggestionSelected,\n popperProps,\n ...others\n } = useDefaultProps(\"HvSuggestions\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const context = useContext(HvFormElementContext);\n const id = idProp ?? setId(context.id, \"suggestions\");\n\n const ref = useRef<HTMLDivElement>(null);\n const forkedRef = useForkRef(ref, extRef);\n\n // TODO: remove controlled+uncontrolled `expanded` prop in v6\n const [isOpen, setIsOpen] = useState(expanded);\n useEffect(() => {\n setIsOpen(expanded);\n }, [expanded]);\n\n return (\n <div\n id={id}\n ref={forkedRef}\n className={cx(classes.root, className)}\n {...others}\n >\n <ClickAwayListener\n onClickAway={(event) => {\n setIsOpen(false);\n onClose?.(event);\n }}\n >\n <Popper\n style={{\n // @ts-ignore\n \"--popper-width\": enablePortal\n ? `${anchorEl?.clientWidth}px`\n : \"100%\",\n }}\n open={openProp ?? isOpen}\n disablePortal={!enablePortal}\n container={enablePortal ? getContainerElement(rootId) : undefined}\n anchorEl={anchorEl}\n className={cx(classes.popper, {\n [classes.portal]: enablePortal,\n })}\n {...popperProps}\n >\n <HvSelectionList\n className={classes.list}\n id={setId(id, \"list\")}\n onChange={onSuggestionSelected}\n >\n {suggestionValues?.map((item) => (\n <HvListItem key={item.id} value={item} disabled={item.disabled}>\n {item.label}\n </HvListItem>\n ))}\n </HvSelectionList>\n </Popper>\n </ClickAwayListener>\n </div>\n );\n});\n"],"names":["HvSuggestions"],"mappings":";;;;;;;;;;;;;AA4DO,MAAM,gBAAgB,WAI3B,SAASA,eAAc,OAAO,QAAQ;AAChC,QAAA;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,eAAe;AAAA,IACf,MAAM;AAAA,IACN;AAAA,IACA,mBAAmB,CAAC;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,iBAAiB,KAAK;AAE1C,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,EAAE,OAAO,IAAI,SAAS;AAEtB,QAAA,UAAU,WAAW,oBAAoB;AAC/C,QAAM,KAAK,UAAU,MAAM,QAAQ,IAAI,aAAa;AAE9C,QAAA,MAAM,OAAuB,IAAI;AACjC,QAAA,YAAY,WAAW,KAAK,MAAM;AAGxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,QAAQ;AAC7C,YAAU,MAAM;AACd,cAAU,QAAQ;AAAA,EAAA,GACjB,CAAC,QAAQ,CAAC;AAGX,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,KAAK;AAAA,MACL,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,MACpC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aAAa,CAAC,UAAU;AACtB,sBAAU,KAAK;AACf,sBAAU,KAAK;AAAA,UACjB;AAAA,UAEA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,OAAO;AAAA;AAAA,gBAEL,kBAAkB,eACd,GAAG,UAAU,WAAW,OACxB;AAAA,cACN;AAAA,cACA,MAAM,YAAY;AAAA,cAClB,eAAe,CAAC;AAAA,cAChB,WAAW,eAAe,oBAAoB,MAAM,IAAI;AAAA,cACxD;AAAA,cACA,WAAW,GAAG,QAAQ,QAAQ;AAAA,gBAC5B,CAAC,QAAQ,MAAM,GAAG;AAAA,cAAA,CACnB;AAAA,cACA,GAAG;AAAA,cAEJ,UAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAW,QAAQ;AAAA,kBACnB,IAAI,MAAM,IAAI,MAAM;AAAA,kBACpB,UAAU;AAAA,kBAET,UAAkB,kBAAA,IAAI,CAAC,6BACrB,YAAyB,EAAA,OAAO,MAAM,UAAU,KAAK,UACnD,UAAA,KAAK,MADS,GAAA,KAAK,EAEtB,CACD;AAAA,gBAAA;AAAA,cAAA;AAAA,YACH;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ,CAAC;"}
|
|
@@ -4,6 +4,7 @@ const { staticClasses, useClasses } = createClasses("HvSuggestions", {
|
|
|
4
4
|
root: { position: "relative" },
|
|
5
5
|
list: {
|
|
6
6
|
backgroundColor: theme.colors.atmo1,
|
|
7
|
+
border: `1px solid ${theme.colors.secondary}`,
|
|
7
8
|
boxShadow: theme.colors.shadow,
|
|
8
9
|
padding: theme.space.xs,
|
|
9
10
|
width: "100%"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Suggestions.styles.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSuggestions\", {\n root: { position: \"relative\" },\n list: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n padding: theme.space.xs,\n width: \"100%\",\n },\n popper: {\n width: \"var(--popper-width)\",\n position: \"absolute\",\n zIndex: theme.zIndices.tooltip,\n \":not($portal)\": {\n transform: \"translate3d(0, -1px, 0) !important\",\n },\n },\n portal: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,UAAU,WAAW;AAAA,EAC7B,MAAM;AAAA,IACJ,iBAAiB,MAAM,OAAO;AAAA,IAC9B,WAAW,MAAM,OAAO;AAAA,IACxB,SAAS,MAAM,MAAM;AAAA,IACrB,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ,MAAM,SAAS;AAAA,IACvB,iBAAiB;AAAA,MACf,WAAW;AAAA,IAAA;AAAA,EAEf;AAAA,EACA,QAAQ,CAAA;AACV,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Suggestions.styles.js","sources":["../../../../src/FormElement/Suggestions/Suggestions.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSuggestions\", {\n root: { position: \"relative\" },\n list: {\n backgroundColor: theme.colors.atmo1,\n border: `1px solid ${theme.colors.secondary}`,\n boxShadow: theme.colors.shadow,\n padding: theme.space.xs,\n width: \"100%\",\n },\n popper: {\n width: \"var(--popper-width)\",\n position: \"absolute\",\n zIndex: theme.zIndices.tooltip,\n \":not($portal)\": {\n transform: \"translate3d(0, -1px, 0) !important\",\n },\n },\n portal: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM,EAAE,UAAU,WAAW;AAAA,EAC7B,MAAM;AAAA,IACJ,iBAAiB,MAAM,OAAO;AAAA,IAC9B,QAAQ,aAAa,MAAM,OAAO,SAAS;AAAA,IAC3C,WAAW,MAAM,OAAO;AAAA,IACxB,SAAS,MAAM,MAAM;AAAA,IACrB,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,QAAQ,MAAM,SAAS;AAAA,IACvB,iBAAiB;AAAA,MACf,WAAW;AAAA,IAAA;AAAA,EAEf;AAAA,EACA,QAAQ,CAAA;AACV,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.js","sources":["../../../../src/ListContainer/ListItem/ListItem.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n ReactElement,\n useCallback,\n useContext,\n useMemo,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvFocus } from \"../../Focus\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport HvListContext from \"../ListContext\";\nimport { staticClasses, useClasses } from \"./ListItem.styles\";\n\nexport { staticClasses as listItemClasses };\n\nexport type HvListItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListItemProps extends HvBaseProps<HTMLLIElement> {\n /** Indicates if the list item is selected. */\n selected?: boolean;\n /** Indicated if the list item is _visually_ selectable */\n selectable?: boolean;\n /** If true, the list item will be disabled. */\n disabled?: boolean;\n /**\n * If the list item is focusable and reacts to mouse over events.\n * Defaults to true if the container list is interactive, false otherwise.\n */\n interactive?: boolean;\n /**\n * If `true` compacts the vertical spacing intended to separate the list items.\n * Defaults to the value set in container list.\n */\n condensed?: boolean;\n /**\n * If `true`, the left and right padding is removed.\n * Defaults to the value set in container list.\n */\n disableGutters?: boolean;\n /**\n * Element placed before the children.\n * Also removes the left padding (gutter).\n *\n * Some modifications are applied, assuming that it is either an icon (changing the color when the item is disabled)\n * or a selector (preventing the double focus ring, propagating the checked and disabled states and wiring the onChange event).\n * If unwanted, the element should be placed directly as a child.\n */\n startAdornment?: React.ReactNode;\n /**\n * Element placed after the children and aligned next to the margin.\n * Also removes the right padding (gutter).\n *\n * Some modifications are applied, assuming that it is an icon (changing the color when the item is disabled).\n * If unwanted, the element should be placed directly as a child.\n */\n endAdornment?: React.ReactNode;\n /** The value to be set on the 'li' element */\n value?: any;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListItemClasses;\n}\n\nconst applyClassNameAndStateToElement = (\n element: React.ReactNode,\n selected: boolean | undefined,\n disabled: boolean | undefined,\n onClick: React.MouseEventHandler<HTMLLIElement>,\n className?: string,\n) => {\n if (element == null) return null;\n\n return cloneElement(element as ReactElement, {\n className,\n checked: !!selected,\n disabled,\n onChange: onClick,\n });\n};\n\nconst applyClassNameToElement = (\n element: React.ReactNode,\n className?: string,\n) => {\n if (element == null) return null;\n\n return cloneElement(element as ReactElement, {\n className,\n });\n};\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"ListItem.js","sources":["../../../../src/ListContainer/ListItem/ListItem.tsx"],"sourcesContent":["import {\n cloneElement,\n forwardRef,\n isValidElement,\n ReactElement,\n useCallback,\n useContext,\n useMemo,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvFocus } from \"../../Focus\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport HvListContext from \"../ListContext\";\nimport { staticClasses, useClasses } from \"./ListItem.styles\";\n\nexport { staticClasses as listItemClasses };\n\nexport type HvListItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListItemProps extends HvBaseProps<HTMLLIElement> {\n /** Indicates if the list item is selected. */\n selected?: boolean;\n /** Indicated if the list item is _visually_ selectable */\n selectable?: boolean;\n /** If true, the list item will be disabled. */\n disabled?: boolean;\n /**\n * If the list item is focusable and reacts to mouse over events.\n * Defaults to true if the container list is interactive, false otherwise.\n */\n interactive?: boolean;\n /**\n * If `true` compacts the vertical spacing intended to separate the list items.\n * Defaults to the value set in container list.\n */\n condensed?: boolean;\n /**\n * If `true`, the left and right padding is removed.\n * Defaults to the value set in container list.\n */\n disableGutters?: boolean;\n /**\n * Element placed before the children.\n * Also removes the left padding (gutter).\n *\n * Some modifications are applied, assuming that it is either an icon (changing the color when the item is disabled)\n * or a selector (preventing the double focus ring, propagating the checked and disabled states and wiring the onChange event).\n * If unwanted, the element should be placed directly as a child.\n */\n startAdornment?: React.ReactNode;\n /**\n * Element placed after the children and aligned next to the margin.\n * Also removes the right padding (gutter).\n *\n * Some modifications are applied, assuming that it is an icon (changing the color when the item is disabled).\n * If unwanted, the element should be placed directly as a child.\n */\n endAdornment?: React.ReactNode;\n /** The value to be set on the 'li' element */\n value?: any;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListItemClasses;\n}\n\nconst applyClassNameAndStateToElement = (\n element: React.ReactNode,\n selected: boolean | undefined,\n disabled: boolean | undefined,\n onClick: React.MouseEventHandler<HTMLLIElement>,\n className?: string,\n) => {\n if (element == null) return null;\n\n return cloneElement(element as ReactElement, {\n className,\n checked: !!selected,\n disabled,\n onChange: onClick,\n });\n};\n\nconst applyClassNameToElement = (\n element: React.ReactNode,\n className?: string,\n) => {\n if (element == null) return null;\n\n return cloneElement(element as ReactElement, {\n className,\n });\n};\n\n/**\n * Implements the listitem pattern, akin to the `<li>` element.\n * Should be composed within a `<HvListContainer>` component.\n */\nexport const HvListItem = forwardRef<\n // no-indent\n React.ComponentRef<\"li\">,\n HvListItemProps\n>(function HvListItem(props, ref) {\n const {\n classes: classesProp,\n className,\n role,\n value,\n selected,\n disabled,\n selectable: selectableProp,\n interactive: interactiveProp,\n condensed: condensedProp,\n disableGutters: disableGuttersProp,\n startAdornment,\n endAdornment,\n onClick,\n children,\n tabIndex,\n ...others\n } = useDefaultProps(\"HvListItem\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const {\n topContainerRef,\n condensed: condensedContext,\n disableGutters: disableGuttersContext,\n interactive: interactiveContext,\n selectable: selectableContext,\n } = useContext(HvListContext);\n\n const condensed = condensedProp ?? condensedContext;\n const disableGutters = disableGuttersProp ?? disableGuttersContext;\n const interactive = interactiveProp ?? interactiveContext;\n const selectable = selectableProp ?? selectableContext;\n\n const handleClick = useCallback<React.MouseEventHandler<HTMLLIElement>>(\n (evt) => {\n if (disabled) return;\n onClick?.(evt);\n },\n [disabled, onClick],\n );\n\n const clonedStartAdornment = useMemo(\n () =>\n applyClassNameAndStateToElement(\n startAdornment,\n selected,\n disabled,\n handleClick,\n cx(\n classes.startAdornment,\n { [classes.disabled]: disabled },\n isValidElement(startAdornment)\n ? startAdornment.props.className\n : undefined,\n ),\n ),\n [\n cx,\n classes?.startAdornment,\n classes?.disabled,\n disabled,\n handleClick,\n selected,\n startAdornment,\n ],\n );\n const clonedEndAdornment = useMemo(\n () =>\n applyClassNameToElement(\n endAdornment,\n cx(\n classes.endAdornment,\n { [classes.disabled]: disabled },\n isValidElement(endAdornment)\n ? endAdornment.props.className\n : undefined,\n ),\n ),\n [cx, classes?.endAdornment, classes?.disabled, disabled, endAdornment],\n );\n\n const roleOptionAriaProps =\n role === \"option\" || role === \"menuitem\"\n ? {\n \"aria-disabled\": disabled || undefined,\n \"aria-selected\": selected,\n }\n : {};\n\n const listItem = (\n // For later: this should only have an onClick event if interactive and has the appropriate role.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events\n <li\n ref={ref}\n role={role}\n value={value}\n className={cx(\n classes.root,\n {\n [classes.gutters]: !disableGutters,\n [classes.condensed]: condensed,\n [classes.interactive]: interactive || selectable,\n [classes.selected]: selected || props[\"aria-selected\"],\n [classes.disabled]: disabled || props[\"aria-disabled\"],\n [classes.withStartAdornment]: startAdornment != null,\n [classes.withEndAdornment]: endAdornment != null,\n },\n className,\n )}\n tabIndex={interactive ? undefined : tabIndex}\n onClick={handleClick}\n {...roleOptionAriaProps}\n {...others}\n >\n {clonedStartAdornment}\n {children}\n {clonedEndAdornment}\n </li>\n );\n\n return interactive ? (\n <HvFocus\n rootRef={topContainerRef}\n selected={selected}\n disabledClass={disabled || undefined}\n strategy={role === \"option\" ? \"listbox\" : \"menu\"}\n classes={{ focus: classes.focus }}\n configuration={{\n tabIndex,\n }}\n >\n {listItem}\n </HvFocus>\n ) : (\n listItem\n );\n});\n"],"names":["HvListItem","HvListContext"],"mappings":";;;;;;;AAoEA,MAAM,kCAAkC,CACtC,SACA,UACA,UACA,SACA,cACG;AACC,MAAA,WAAW,KAAa,QAAA;AAE5B,SAAO,aAAa,SAAyB;AAAA,IAC3C;AAAA,IACA,SAAS,CAAC,CAAC;AAAA,IACX;AAAA,IACA,UAAU;AAAA,EAAA,CACX;AACH;AAEA,MAAM,0BAA0B,CAC9B,SACA,cACG;AACC,MAAA,WAAW,KAAa,QAAA;AAE5B,SAAO,aAAa,SAAyB;AAAA,IAC3C;AAAA,EAAA,CACD;AACH;AAMO,MAAM,aAAa,WAIxB,SAASA,YAAW,OAAO,KAAK;AAC1B,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,cAAc,KAAK;AAEvC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,aAAa;AAAA,IACb,YAAY;AAAA,EAAA,IACV,WAAWC,WAAa;AAE5B,QAAM,YAAY,iBAAiB;AACnC,QAAM,iBAAiB,sBAAsB;AAC7C,QAAM,cAAc,mBAAmB;AACvC,QAAM,aAAa,kBAAkB;AAErC,QAAM,cAAc;AAAA,IAClB,CAAC,QAAQ;AACP,UAAI,SAAU;AACd,gBAAU,GAAG;A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QAAQ,gBAAgB,GAAG,gBAAgB;AAAA,UAC9C;AAAA,UACA;AAAA,QACF;AAAA,QACA,UAAU,cAAc,SAAY;AAAA,QACpC,SAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA;AAIL,SAAO,cACL;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAS;AAAA,MACT;AAAA,MACA,eAAe,YAAY;AAAA,MAC3B,UAAU,SAAS,WAAW,YAAY;AAAA,MAC1C,SAAS,EAAE,OAAO,QAAQ,MAAM;AAAA,MAChC,eAAe;AAAA,QACb;AAAA,MACF;AAAA,MAEC,UAAA;AAAA,IAAA;AAAA,EAAA,IAGH;AAEJ,CAAC;"}
|
|
@@ -16,7 +16,6 @@ import { HvFormElement } from "../FormElement/FormElement.js";
|
|
|
16
16
|
import { HvLabel } from "../FormElement/Label/Label.js";
|
|
17
17
|
import { HvInfoMessage } from "../FormElement/InfoMessage/InfoMessage.js";
|
|
18
18
|
import { HvDropdownButton } from "../DropdownButton/DropdownButton.js";
|
|
19
|
-
import { HvPanel } from "../Panel/Panel.js";
|
|
20
19
|
import { HvListContainer } from "../ListContainer/ListContainer.js";
|
|
21
20
|
import { HvWarningText } from "../FormElement/WarningText/WarningText.js";
|
|
22
21
|
function defaultRenderValue(options) {
|
|
@@ -193,8 +192,10 @@ const HvSelect = fixedForwardRef(function HvSelect2(props, ref) {
|
|
|
193
192
|
}
|
|
194
193
|
],
|
|
195
194
|
children: /* @__PURE__ */ jsx(
|
|
196
|
-
|
|
195
|
+
HvListContainer,
|
|
197
196
|
{
|
|
197
|
+
condensed: true,
|
|
198
|
+
selectable: true,
|
|
198
199
|
style: {
|
|
199
200
|
width: variableWidth ? "auto" : (buttonRef.current?.clientWidth || 0) + 2
|
|
200
201
|
},
|
|
@@ -202,7 +203,8 @@ const HvSelect = fixedForwardRef(function HvSelect2(props, ref) {
|
|
|
202
203
|
[classes.panelOpenedUp]: placement.includes("top"),
|
|
203
204
|
[classes.panelOpenedDown]: placement.includes("bottom")
|
|
204
205
|
}),
|
|
205
|
-
|
|
206
|
+
...getListboxProps(),
|
|
207
|
+
children: /* @__PURE__ */ jsx(SelectProvider, { value: contextValue, children })
|
|
206
208
|
}
|
|
207
209
|
)
|
|
208
210
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../src/Select/Select.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useRef, useState } from \"react\";\nimport { Popper } from \"@mui/base/Popper\";\nimport { SelectOption } from \"@mui/base/useOption\";\nimport {\n SelectProvider,\n useSelect,\n UseSelectParameters,\n} from \"@mui/base/useSelect\";\nimport { useControlled, useForkRef } from \"@mui/material/utils\";\nimport type { Placement } from \"@popperjs/core\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButtonProps } from \"../Button\";\nimport { HvDropdownButton } from \"../DropdownButton\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../FormElement\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListContainer } from \"../ListContainer\";\nimport { HvPanel } from \"../Panel\";\nimport { fixedForwardRef } from \"../types/generic\";\nimport { getContainerElement } from \"../utils/document\";\nimport { setId } from \"../utils/setId\";\nimport { HvOption } from \"./Option\";\nimport { staticClasses, useClasses } from \"./Select.styles\";\n\nfunction defaultRenderValue<Value>(\n options: SelectOption<Value> | SelectOption<Value>[] | null,\n) {\n if (Array.isArray(options)) {\n if (options.length === 0) return null;\n return <>{options.map((o) => o.label).join(\", \")}</>;\n }\n\n return options?.label ?? null;\n}\n\nconst mergeIds = (...ids: ClassValue[]) => clsx(ids) || undefined;\n\nfunction renderOptions(options?: HvSelectProps<any>[\"options\"]) {\n return options?.map((option) => (\n <HvOption key={option.value} {...option}>\n {option.label}\n </HvOption>\n ));\n}\n\nexport { staticClasses as selectClasses };\n\nexport type HvSelectClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSelectProps<\n OptionValue extends {},\n Multiple extends boolean = false,\n> extends Omit<HvFormElementProps, \"value\" | \"defaultValue\" | \"onChange\">,\n Pick<\n UseSelectParameters<OptionValue, Multiple>,\n | \"name\"\n | \"required\"\n | \"disabled\"\n | \"multiple\"\n | \"open\"\n | \"defaultOpen\"\n | \"value\"\n | \"defaultValue\"\n | \"buttonRef\"\n | \"options\"\n | \"getSerializedValue\"\n | \"onChange\"\n | \"onOpenChange\"\n >,\n Pick<HvButtonProps, \"size\" | \"variant\"> {\n classes?: HvSelectClasses;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n /** Whether the width of the select panel can vary independently. */\n variableWidth?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** If enabled the panel will be rendered using a portal , if disabled will be under the DOM hierarchy of the parent component. */\n enablePortal?: boolean;\n}\n\n/**\n * The `HvSelect` component is a form control element that allows selection from a list of options.\n *\n * It aims to be aligned with the native HTML `<select>` and `<option>` APIs and be easily integrated with forms.\n *\n * @example\n * <HvSelect name=\"pets\">\n * <HvOption value=\"dog\">Dog</HvOption>\n * <HvOption value=\"cat\">Cat</HvOption>\n * </HvSelect>\n * */\nexport const HvSelect = fixedForwardRef(function HvSelect<\n OptionValue extends {},\n Multiple extends boolean = false,\n>(\n props: HvSelectProps<OptionValue, Multiple>,\n ref: React.Ref<HTMLButtonElement>,\n) {\n const {\n children: childrenProp,\n classes: classesProp,\n className,\n id: idProp,\n size,\n variant = \"secondarySubtle\",\n name,\n required,\n disabled: disabledProp,\n readOnly,\n label,\n open: openProp,\n defaultOpen,\n multiple,\n autoComplete,\n options: optionsProp,\n variableWidth,\n value: valueProp,\n defaultValue,\n placeholder,\n inputProps,\n enablePortal,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n getSerializedValue,\n onClick,\n onChange,\n onOpenChange,\n ...others\n } = useDefaultProps(\"HvSelect\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [placement, setPlacement] = useState<Placement>(\"bottom-start\");\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const handleButtonRef = useForkRef(ref, buttonRef);\n\n const {\n contextValue,\n disabled,\n getButtonProps,\n getListboxProps,\n getHiddenInputProps,\n getOptionMetadata,\n value,\n open,\n } = useSelect<OptionValue, Multiple>({\n componentName: \"HvSelect\",\n name,\n required,\n disabled: disabledProp,\n multiple,\n open: openProp,\n defaultOpen,\n value: valueProp,\n defaultValue,\n options: optionsProp,\n buttonRef: handleButtonRef,\n getSerializedValue,\n onChange,\n onOpenChange: handleOpenChange,\n });\n\n const id = useUniqueId(idProp);\n const labelId = useUniqueId(setId(idProp, \"label\"));\n const descriptionId = useUniqueId(setId(idProp, \"description\"));\n const errorMessageId = useUniqueId(setId(idProp, \"error\"));\n\n const [validationMessage] = useControlled({\n name: \"HvSelect.statusMessage\",\n controlled: statusMessage,\n default: \"Required\",\n });\n const [validationState, setValidationState] = useControlled<HvFormStatus>({\n name: \"HvSelect.status\",\n controlled: status,\n default: \"standBy\",\n });\n\n function handleOpenChange(newOpen: boolean) {\n if (!newOpen) {\n const hasValue = multiple ? (value as OptionValue[]).length > 0 : !!value;\n setValidationState(required && !hasValue ? \"invalid\" : \"valid\");\n }\n onOpenChange?.(newOpen);\n }\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isInvalid = validationState === \"invalid\";\n\n const actualValue = multiple\n ? (value as OptionValue[])\n .map((v) => getOptionMetadata(v))\n .filter((v): v is SelectOption<OptionValue> => v !== undefined)\n : (getOptionMetadata(value as OptionValue) ?? null);\n\n const children = childrenProp ?? renderOptions(optionsProp);\n const isOpen = open && !!children;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n className={cx(classes.root, className, {\n [classes.disabled]: disabled,\n [classes.readOnly]: readOnly,\n })}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n showGutter\n id={labelId}\n htmlFor={id}\n label={label}\n className={classes.label}\n />\n )}\n {description && (\n <HvInfoMessage id={descriptionId} className={classes.description}>\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvDropdownButton\n id={id}\n open={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(classes.select, {\n [classes.invalid]: validationState === \"invalid\",\n })}\n placement={placement}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n aria-labelledby={mergeIds(ariaLabelledBy, { [labelId]: label })}\n aria-invalid={isInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={mergeIds(ariaDescribedBy, {\n [descriptionId]: description,\n })}\n {...getButtonProps()}\n >\n {defaultRenderValue(actualValue) ?? placeholder}\n </HvDropdownButton>\n <Popper\n role=\"none\"\n open={isOpen}\n keepMounted\n disablePortal={!enablePortal}\n container={enablePortal ? getContainerElement(rootId) : undefined}\n anchorEl={buttonRef.current}\n className={classes.popper}\n placement={placement}\n modifiers={[\n {\n enabled: true,\n phase: \"main\",\n fn: ({ state }) => setPlacement(state.placement),\n },\n ]}\n >\n <HvPanel\n style={{\n width: variableWidth\n ? \"auto\"\n : (buttonRef.current?.clientWidth || 0) + 2,\n }}\n className={cx(classes.panel, className, {\n [classes.panelOpenedUp]: placement.includes(\"top\"),\n [classes.panelOpenedDown]: placement.includes(\"bottom\"),\n })}\n >\n <SelectProvider value={contextValue}>\n <HvListContainer condensed selectable {...getListboxProps()}>\n {children}\n </HvListContainer>\n </SelectProvider>\n </HvPanel>\n </Popper>\n <input\n {...getHiddenInputProps()}\n autoComplete={autoComplete}\n {...inputProps}\n />\n {canShowError && (\n <HvWarningText\n id={errorMessageId}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,mBACP,SACA;AACI,MAAA,MAAM,QAAQ,OAAO,GAAG;AACtB,QAAA,QAAQ,WAAW,EAAU,QAAA;AAC1B,WAAA,oBAAA,UAAA,EAAG,UAAQ,QAAA,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,CAAA;AAAA,EAAA;AAGnD,SAAO,SAAS,SAAS;AAC3B;AAEA,MAAM,WAAW,IAAI,QAAsB,KAAK,GAAG,KAAK;AAExD,SAAS,cAAc,SAAyC;AAC9D,SAAO,SAAS,IAAI,CAAC,WAClB,oBAAA,UAAA,EAA6B,GAAG,QAC9B,UAAO,OAAA,MAAA,GADK,OAAO,KAEtB,CACD;AACH;AAmDO,MAAM,WAAW,gBAAgB,SAASA,UAI/C,OACA,KACA;AACM,QAAA;AAAA,IACJ,UAAU;AAAA,IACV,SAAS;AAAA,IACT;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA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,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAEJ;AAEJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../src/Select/Select.tsx"],"sourcesContent":["import { useRef, useState } from \"react\";\nimport { Popper } from \"@mui/base/Popper\";\nimport { SelectOption } from \"@mui/base/useOption\";\nimport {\n SelectProvider,\n useSelect,\n UseSelectParameters,\n} from \"@mui/base/useSelect\";\nimport { useControlled, useForkRef } from \"@mui/material/utils\";\nimport type { Placement } from \"@popperjs/core\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport {\n useDefaultProps,\n useTheme,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButtonProps } from \"../Button\";\nimport { HvDropdownButton } from \"../DropdownButton\";\nimport {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../FormElement\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvListContainer } from \"../ListContainer\";\nimport { fixedForwardRef } from \"../types/generic\";\nimport { getContainerElement } from \"../utils/document\";\nimport { setId } from \"../utils/setId\";\nimport { HvOption } from \"./Option\";\nimport { staticClasses, useClasses } from \"./Select.styles\";\n\nfunction defaultRenderValue<Value>(\n options: SelectOption<Value> | SelectOption<Value>[] | null,\n) {\n if (Array.isArray(options)) {\n if (options.length === 0) return null;\n return <>{options.map((o) => o.label).join(\", \")}</>;\n }\n\n return options?.label ?? null;\n}\n\nconst mergeIds = (...ids: ClassValue[]) => clsx(ids) || undefined;\n\nfunction renderOptions(options?: HvSelectProps<any>[\"options\"]) {\n return options?.map((option) => (\n <HvOption key={option.value} {...option}>\n {option.label}\n </HvOption>\n ));\n}\n\nexport { staticClasses as selectClasses };\n\nexport type HvSelectClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSelectProps<\n OptionValue extends {},\n Multiple extends boolean = false,\n> extends Omit<HvFormElementProps, \"value\" | \"defaultValue\" | \"onChange\">,\n Pick<\n UseSelectParameters<OptionValue, Multiple>,\n | \"name\"\n | \"required\"\n | \"disabled\"\n | \"multiple\"\n | \"open\"\n | \"defaultOpen\"\n | \"value\"\n | \"defaultValue\"\n | \"buttonRef\"\n | \"options\"\n | \"getSerializedValue\"\n | \"onChange\"\n | \"onOpenChange\"\n >,\n Pick<HvButtonProps, \"size\" | \"variant\"> {\n classes?: HvSelectClasses;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n /** Whether the width of the select panel can vary independently. */\n variableWidth?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** If enabled the panel will be rendered using a portal , if disabled will be under the DOM hierarchy of the parent component. */\n enablePortal?: boolean;\n}\n\n/**\n * The `HvSelect` component is a form control element that allows selection from a list of options.\n *\n * It aims to be aligned with the native HTML `<select>` and `<option>` APIs and be easily integrated with forms.\n *\n * @example\n * <HvSelect name=\"pets\">\n * <HvOption value=\"dog\">Dog</HvOption>\n * <HvOption value=\"cat\">Cat</HvOption>\n * </HvSelect>\n * */\nexport const HvSelect = fixedForwardRef(function HvSelect<\n OptionValue extends {},\n Multiple extends boolean = false,\n>(\n props: HvSelectProps<OptionValue, Multiple>,\n ref: React.Ref<HTMLButtonElement>,\n) {\n const {\n children: childrenProp,\n classes: classesProp,\n className,\n id: idProp,\n size,\n variant = \"secondarySubtle\",\n name,\n required,\n disabled: disabledProp,\n readOnly,\n label,\n open: openProp,\n defaultOpen,\n multiple,\n autoComplete,\n options: optionsProp,\n variableWidth,\n value: valueProp,\n defaultValue,\n placeholder,\n inputProps,\n enablePortal,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n getSerializedValue,\n onClick,\n onChange,\n onOpenChange,\n ...others\n } = useDefaultProps(\"HvSelect\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { rootId } = useTheme();\n\n const [placement, setPlacement] = useState<Placement>(\"bottom-start\");\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const handleButtonRef = useForkRef(ref, buttonRef);\n\n const {\n contextValue,\n disabled,\n getButtonProps,\n getListboxProps,\n getHiddenInputProps,\n getOptionMetadata,\n value,\n open,\n } = useSelect<OptionValue, Multiple>({\n componentName: \"HvSelect\",\n name,\n required,\n disabled: disabledProp,\n multiple,\n open: openProp,\n defaultOpen,\n value: valueProp,\n defaultValue,\n options: optionsProp,\n buttonRef: handleButtonRef,\n getSerializedValue,\n onChange,\n onOpenChange: handleOpenChange,\n });\n\n const id = useUniqueId(idProp);\n const labelId = useUniqueId(setId(idProp, \"label\"));\n const descriptionId = useUniqueId(setId(idProp, \"description\"));\n const errorMessageId = useUniqueId(setId(idProp, \"error\"));\n\n const [validationMessage] = useControlled({\n name: \"HvSelect.statusMessage\",\n controlled: statusMessage,\n default: \"Required\",\n });\n const [validationState, setValidationState] = useControlled<HvFormStatus>({\n name: \"HvSelect.status\",\n controlled: status,\n default: \"standBy\",\n });\n\n function handleOpenChange(newOpen: boolean) {\n if (!newOpen) {\n const hasValue = multiple ? (value as OptionValue[]).length > 0 : !!value;\n setValidationState(required && !hasValue ? \"invalid\" : \"valid\");\n }\n onOpenChange?.(newOpen);\n }\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isInvalid = validationState === \"invalid\";\n\n const actualValue = multiple\n ? (value as OptionValue[])\n .map((v) => getOptionMetadata(v))\n .filter((v): v is SelectOption<OptionValue> => v !== undefined)\n : (getOptionMetadata(value as OptionValue) ?? null);\n\n const children = childrenProp ?? renderOptions(optionsProp);\n const isOpen = open && !!children;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={validationState}\n className={cx(classes.root, className, {\n [classes.disabled]: disabled,\n [classes.readOnly]: readOnly,\n })}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel\n showGutter\n id={labelId}\n htmlFor={id}\n label={label}\n className={classes.label}\n />\n )}\n {description && (\n <HvInfoMessage id={descriptionId} className={classes.description}>\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvDropdownButton\n id={id}\n open={isOpen}\n disabled={disabled}\n readOnly={readOnly}\n className={cx(classes.select, {\n [classes.invalid]: validationState === \"invalid\",\n })}\n placement={placement}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n aria-labelledby={mergeIds(ariaLabelledBy, { [labelId]: label })}\n aria-invalid={isInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n aria-describedby={mergeIds(ariaDescribedBy, {\n [descriptionId]: description,\n })}\n {...getButtonProps()}\n >\n {defaultRenderValue(actualValue) ?? placeholder}\n </HvDropdownButton>\n <Popper\n role=\"none\"\n open={isOpen}\n keepMounted\n disablePortal={!enablePortal}\n container={enablePortal ? getContainerElement(rootId) : undefined}\n anchorEl={buttonRef.current}\n className={classes.popper}\n placement={placement}\n modifiers={[\n {\n enabled: true,\n phase: \"main\",\n fn: ({ state }) => setPlacement(state.placement),\n },\n ]}\n >\n <HvListContainer\n condensed\n selectable\n style={{\n width: variableWidth\n ? \"auto\"\n : (buttonRef.current?.clientWidth || 0) + 2,\n }}\n className={cx(classes.panel, className, {\n [classes.panelOpenedUp]: placement.includes(\"top\"),\n [classes.panelOpenedDown]: placement.includes(\"bottom\"),\n })}\n {...getListboxProps()}\n >\n <SelectProvider value={contextValue}>{children}</SelectProvider>\n </HvListContainer>\n </Popper>\n <input\n {...getHiddenInputProps()}\n autoComplete={autoComplete}\n {...inputProps}\n />\n {canShowError && (\n <HvWarningText\n id={errorMessageId}\n disableBorder\n className={classes.error}\n >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,YACC,MAAK;AAAA,YACL,MAAM;AAAA,YACN,aAAW;AAAA,YACX,eAAe,CAAC;AAAA,YAChB,WAAW,eAAe,oBAAoB,MAAM,IAAI;AAAA,YACxD,UAAU,UAAU;AAAA,YACpB,WAAW,QAAQ;AAAA,YACnB;AAAA,YACA,WAAW;AAAA,cACT;AAAA,gBACE,SAAS;AAAA,gBACT,OAAO;AAAA,gBACP,IAAI,CAAC,EAAE,MAAY,MAAA,aAAa,MAAM,SAAS;AAAA,cAAA;AAAA,YAEnD;AAAA,YAEA,UAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAS;AAAA,gBACT,YAAU;AAAA,gBACV,OAAO;AAAA,kBACL,OAAO,gBACH,UACC,UAAU,SAAS,eAAe,KAAK;AAAA,gBAC9C;AAAA,gBACA,WAAW,GAAG,QAAQ,OAAO,WAAW;AAAA,kBACtC,CAAC,QAAQ,aAAa,GAAG,UAAU,SAAS,KAAK;AAAA,kBACjD,CAAC,QAAQ,eAAe,GAAG,UAAU,SAAS,QAAQ;AAAA,gBAAA,CACvD;AAAA,gBACA,GAAG,gBAAgB;AAAA,gBAEpB,UAAC,oBAAA,gBAAA,EAAe,OAAO,cAAe,SAAS,CAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACjD;AAAA,QACF;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACE,GAAG,oBAAoB;AAAA,YACxB;AAAA,YACC,GAAG;AAAA,UAAA;AAAA,QACN;AAAA,QACC,gBACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI;AAAA,YACJ,eAAa;AAAA,YACb,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAEJ;AAEJ,CAAC;"}
|
|
@@ -26,7 +26,13 @@ const { staticClasses, useClasses } = createClasses("HvSelect", {
|
|
|
26
26
|
maxHeight: 400,
|
|
27
27
|
border: `1px solid ${theme.colors.secondary}`,
|
|
28
28
|
marginTop: -1,
|
|
29
|
-
marginBottom: -1
|
|
29
|
+
marginBottom: -1,
|
|
30
|
+
// panel styles
|
|
31
|
+
position: "relative",
|
|
32
|
+
padding: theme.space.xs,
|
|
33
|
+
backgroundColor: theme.colors.atmo1,
|
|
34
|
+
overflowY: "auto",
|
|
35
|
+
borderRadius: "inherit"
|
|
30
36
|
},
|
|
31
37
|
panelOpenedUp: {
|
|
32
38
|
borderRadius: `${theme.radii.base} ${theme.radii.base} 0 0`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.styles.js","sources":["../../../src/Select/Select.styles.ts"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSelect\", {\n root: {\n position: \"relative\",\n \"&$disabled,&$readOnly\": {\n pointerEvents: \"none\",\n },\n },\n disabled: {},\n readOnly: {},\n invalid: {\n border: `1px solid ${theme.colors.negative_120}`,\n },\n labelContainer: {\n display: \"flex\",\n alignItems: \"flex-start\",\n },\n label: {},\n description: {},\n select: {},\n popper: {\n zIndex: theme.zIndices.popover,\n },\n panel: {\n maxHeight: 400,\n border: `1px solid ${theme.colors.secondary}`,\n marginTop: -1,\n marginBottom: -1,\n },\n panelOpenedUp: {\n borderRadius: `${theme.radii.base} ${theme.radii.base} 0 0`,\n },\n panelOpenedDown: {\n borderRadius: `0 0 ${theme.radii.base} ${theme.radii.base}`,\n },\n error: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,YAAY;AAAA,EACrE,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,yBAAyB;AAAA,MACvB,eAAe;AAAA,IAAA;AAAA,EAEnB;AAAA,EACA,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,SAAS;AAAA,IACP,QAAQ,aAAa,MAAM,OAAO,YAAY;AAAA,EAChD;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS;AAAA,IACT,YAAY;AAAA,EACd;AAAA,EACA,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,QAAQ,CAAC;AAAA,EACT,QAAQ;AAAA,IACN,QAAQ,MAAM,SAAS;AAAA,EACzB;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,IACX,QAAQ,aAAa,MAAM,OAAO,SAAS;AAAA,IAC3C,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,eAAe;AAAA,IACb,cAAc,GAAG,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM,IAAI;AAAA,EACvD;AAAA,EACA,iBAAiB;AAAA,IACf,cAAc,OAAO,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM,IAAI;AAAA,EAC3D;AAAA,EACA,OAAO,CAAA;AACT,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Select.styles.js","sources":["../../../src/Select/Select.styles.ts"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSelect\", {\n root: {\n position: \"relative\",\n \"&$disabled,&$readOnly\": {\n pointerEvents: \"none\",\n },\n },\n disabled: {},\n readOnly: {},\n invalid: {\n border: `1px solid ${theme.colors.negative_120}`,\n },\n labelContainer: {\n display: \"flex\",\n alignItems: \"flex-start\",\n },\n label: {},\n description: {},\n select: {},\n popper: {\n zIndex: theme.zIndices.popover,\n },\n panel: {\n maxHeight: 400,\n border: `1px solid ${theme.colors.secondary}`,\n marginTop: -1,\n marginBottom: -1,\n\n // panel styles\n position: \"relative\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.atmo1,\n overflowY: \"auto\",\n borderRadius: \"inherit\",\n },\n panelOpenedUp: {\n borderRadius: `${theme.radii.base} ${theme.radii.base} 0 0`,\n },\n panelOpenedDown: {\n borderRadius: `0 0 ${theme.radii.base} ${theme.radii.base}`,\n },\n error: {},\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,YAAY;AAAA,EACrE,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,yBAAyB;AAAA,MACvB,eAAe;AAAA,IAAA;AAAA,EAEnB;AAAA,EACA,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,SAAS;AAAA,IACP,QAAQ,aAAa,MAAM,OAAO,YAAY;AAAA,EAChD;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS;AAAA,IACT,YAAY;AAAA,EACd;AAAA,EACA,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,QAAQ,CAAC;AAAA,EACT,QAAQ;AAAA,IACN,QAAQ,MAAM,SAAS;AAAA,EACzB;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,IACX,QAAQ,aAAa,MAAM,OAAO,SAAS;AAAA,IAC3C,WAAW;AAAA,IACX,cAAc;AAAA;AAAA,IAGd,UAAU;AAAA,IACV,SAAS,MAAM,MAAM;AAAA,IACrB,iBAAiB,MAAM,OAAO;AAAA,IAC9B,WAAW;AAAA,IACX,cAAc;AAAA,EAChB;AAAA,EACA,eAAe;AAAA,IACb,cAAc,GAAG,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM,IAAI;AAAA,EACvD;AAAA,EACA,iBAAiB;AAAA,IACf,cAAc,OAAO,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM,IAAI;AAAA,EAC3D;AAAA,EACA,OAAO,CAAA;AACT,CAAC;"}
|