@hitachivantara/uikit-react-core 5.90.0 → 5.91.1
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/Accordion/Accordion.cjs +1 -1
- package/dist/cjs/Accordion/Accordion.styles.cjs +1 -5
- package/dist/cjs/Avatar/Avatar.cjs +16 -9
- package/dist/cjs/Avatar/Avatar.styles.cjs +13 -37
- package/dist/cjs/AvatarGroup/AvatarGroup.styles.cjs +36 -43
- package/dist/cjs/Badge/Badge.cjs +3 -2
- package/dist/cjs/Badge/Badge.styles.cjs +5 -2
- package/dist/cjs/BaseCheckBox/BaseCheckBox.cjs +8 -11
- package/dist/cjs/BaseCheckBox/BaseCheckBox.styles.cjs +17 -16
- package/dist/cjs/BaseDropdown/BaseDropdown.cjs +4 -3
- package/dist/cjs/BaseDropdown/BaseDropdown.styles.cjs +26 -24
- package/dist/cjs/BaseRadio/BaseRadio.cjs +6 -10
- package/dist/cjs/BaseRadio/BaseRadio.styles.cjs +12 -26
- package/dist/cjs/BaseSwitch/BaseSwitch.styles.cjs +12 -8
- package/dist/cjs/BulkActions/BulkActions.styles.cjs +4 -3
- package/dist/cjs/Button/Button.styles.cjs +13 -14
- package/dist/cjs/Card/Card.styles.cjs +2 -2
- package/dist/cjs/CheckBox/CheckBox.cjs +1 -1
- package/dist/cjs/CheckBox/CheckBox.styles.cjs +13 -4
- package/dist/cjs/ColorPicker/PresetColors/PresetColors.cjs +2 -0
- package/dist/cjs/ColorPicker/SavedColors/SavedColors.cjs +5 -6
- package/dist/cjs/DatePicker/DatePicker.cjs +1 -1
- package/dist/cjs/DatePicker/DatePicker.styles.cjs +1 -1
- package/dist/cjs/DotPagination/DotPagination.cjs +10 -15
- package/dist/cjs/DotPagination/DotPagination.styles.cjs +18 -5
- package/dist/cjs/Drawer/Drawer.styles.cjs +2 -2
- package/dist/cjs/DropDownMenu/DropDownMenu.cjs +2 -2
- package/dist/cjs/DropDownMenu/DropDownMenu.styles.cjs +8 -8
- package/dist/cjs/Dropdown/Dropdown.styles.cjs +5 -6
- package/dist/cjs/DropdownButton/DropdownButton.cjs +2 -3
- package/dist/cjs/DropdownButton/DropdownButton.styles.cjs +9 -10
- package/dist/cjs/FileUploader/File/File.cjs +4 -2
- package/dist/cjs/FileUploader/File/File.styles.cjs +15 -13
- package/dist/cjs/FileUploader/FileList/FileList.cjs +1 -1
- package/dist/cjs/FileUploader/FileList/FileList.styles.cjs +2 -10
- package/dist/cjs/Focus/Focus.cjs +10 -25
- package/dist/cjs/Focus/Focus.styles.cjs +0 -17
- package/dist/cjs/Footer/Footer.styles.cjs +4 -12
- package/dist/cjs/Header/Header.styles.cjs +1 -1
- package/dist/cjs/InlineEditor/InlineEditor.cjs +1 -2
- package/dist/cjs/InlineEditor/InlineEditor.styles.cjs +1 -1
- package/dist/cjs/MultiButton/MultiButton.styles.cjs +11 -9
- package/dist/cjs/Pagination/Pagination.styles.cjs +2 -3
- package/dist/cjs/QueryBuilder/QueryBuilder.styles.cjs +2 -3
- package/dist/cjs/Radio/Radio.styles.cjs +1 -6
- package/dist/cjs/Select/Select.cjs +1 -1
- package/dist/cjs/Select/Select.styles.cjs +12 -7
- package/dist/cjs/Skeleton/Skeleton.cjs +2 -5
- package/dist/cjs/Slider/Slider.styles.cjs +3 -3
- package/dist/cjs/Slider/SliderInput/SliderInput.cjs +2 -3
- package/dist/cjs/Slider/SliderInput/SliderInput.styles.cjs +9 -3
- package/dist/cjs/Table/TableHeader/TableHeader.cjs +0 -1
- package/dist/cjs/Tag/Tag.cjs +19 -10
- package/dist/cjs/Tag/Tag.styles.cjs +35 -8
- package/dist/cjs/TimePicker/TimePicker.styles.cjs +1 -1
- package/dist/cjs/Tooltip/Tooltip.styles.cjs +1 -1
- package/dist/cjs/VerticalNavigation/NavigationSlider/NavigationSlider.cjs +1 -1
- package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.cjs +1 -1
- package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.styles.cjs +1 -0
- package/dist/cjs/VerticalNavigation/VerticalNavigation.styles.cjs +2 -2
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/utils/Callout.cjs +1 -1
- package/dist/esm/Accordion/Accordion.js +1 -1
- package/dist/esm/Accordion/Accordion.js.map +1 -1
- package/dist/esm/Accordion/Accordion.styles.js +1 -5
- package/dist/esm/Accordion/Accordion.styles.js.map +1 -1
- package/dist/esm/Avatar/Avatar.js +14 -7
- package/dist/esm/Avatar/Avatar.js.map +1 -1
- package/dist/esm/Avatar/Avatar.styles.js +13 -37
- package/dist/esm/Avatar/Avatar.styles.js.map +1 -1
- package/dist/esm/AvatarGroup/AvatarGroup.styles.js +36 -43
- package/dist/esm/AvatarGroup/AvatarGroup.styles.js.map +1 -1
- package/dist/esm/Badge/Badge.js +3 -2
- package/dist/esm/Badge/Badge.js.map +1 -1
- package/dist/esm/Badge/Badge.styles.js +5 -2
- package/dist/esm/Badge/Badge.styles.js.map +1 -1
- package/dist/esm/BaseCheckBox/BaseCheckBox.js +4 -7
- package/dist/esm/BaseCheckBox/BaseCheckBox.js.map +1 -1
- package/dist/esm/BaseCheckBox/BaseCheckBox.styles.js +17 -16
- package/dist/esm/BaseCheckBox/BaseCheckBox.styles.js.map +1 -1
- package/dist/esm/BaseDropdown/BaseDropdown.js +4 -3
- package/dist/esm/BaseDropdown/BaseDropdown.js.map +1 -1
- package/dist/esm/BaseDropdown/BaseDropdown.styles.js +26 -24
- package/dist/esm/BaseDropdown/BaseDropdown.styles.js.map +1 -1
- package/dist/esm/BaseRadio/BaseRadio.js +4 -8
- package/dist/esm/BaseRadio/BaseRadio.js.map +1 -1
- package/dist/esm/BaseRadio/BaseRadio.styles.js +12 -26
- package/dist/esm/BaseRadio/BaseRadio.styles.js.map +1 -1
- package/dist/esm/BaseSwitch/BaseSwitch.styles.js +12 -8
- package/dist/esm/BaseSwitch/BaseSwitch.styles.js.map +1 -1
- package/dist/esm/BulkActions/BulkActions.styles.js +4 -3
- package/dist/esm/BulkActions/BulkActions.styles.js.map +1 -1
- package/dist/esm/Button/Button.styles.js +13 -14
- package/dist/esm/Button/Button.styles.js.map +1 -1
- package/dist/esm/Card/Card.styles.js +2 -2
- package/dist/esm/Card/Card.styles.js.map +1 -1
- package/dist/esm/CheckBox/CheckBox.js +1 -1
- package/dist/esm/CheckBox/CheckBox.js.map +1 -1
- package/dist/esm/CheckBox/CheckBox.styles.js +13 -4
- package/dist/esm/CheckBox/CheckBox.styles.js.map +1 -1
- package/dist/esm/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/esm/ColorPicker/PresetColors/PresetColors.js +2 -0
- package/dist/esm/ColorPicker/PresetColors/PresetColors.js.map +1 -1
- package/dist/esm/ColorPicker/SavedColors/SavedColors.js +5 -6
- package/dist/esm/ColorPicker/SavedColors/SavedColors.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.js +1 -1
- package/dist/esm/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.styles.js +1 -1
- package/dist/esm/DatePicker/DatePicker.styles.js.map +1 -1
- package/dist/esm/DotPagination/DotPagination.js +10 -15
- package/dist/esm/DotPagination/DotPagination.js.map +1 -1
- package/dist/esm/DotPagination/DotPagination.styles.js +18 -5
- package/dist/esm/DotPagination/DotPagination.styles.js.map +1 -1
- package/dist/esm/Drawer/Drawer.styles.js +2 -2
- package/dist/esm/Drawer/Drawer.styles.js.map +1 -1
- package/dist/esm/DropDownMenu/DropDownMenu.js +2 -2
- package/dist/esm/DropDownMenu/DropDownMenu.js.map +1 -1
- package/dist/esm/DropDownMenu/DropDownMenu.styles.js +8 -8
- package/dist/esm/DropDownMenu/DropDownMenu.styles.js.map +1 -1
- package/dist/esm/Dropdown/Dropdown.styles.js +5 -6
- package/dist/esm/Dropdown/Dropdown.styles.js.map +1 -1
- package/dist/esm/DropdownButton/DropdownButton.js +2 -3
- package/dist/esm/DropdownButton/DropdownButton.js.map +1 -1
- package/dist/esm/DropdownButton/DropdownButton.styles.js +9 -10
- package/dist/esm/DropdownButton/DropdownButton.styles.js.map +1 -1
- package/dist/esm/FileUploader/File/File.js +4 -2
- package/dist/esm/FileUploader/File/File.js.map +1 -1
- package/dist/esm/FileUploader/File/File.styles.js +15 -13
- package/dist/esm/FileUploader/File/File.styles.js.map +1 -1
- package/dist/esm/FileUploader/FileList/FileList.js +1 -1
- package/dist/esm/FileUploader/FileList/FileList.js.map +1 -1
- package/dist/esm/FileUploader/FileList/FileList.styles.js +2 -10
- package/dist/esm/FileUploader/FileList/FileList.styles.js.map +1 -1
- package/dist/esm/Focus/Focus.js +10 -25
- package/dist/esm/Focus/Focus.js.map +1 -1
- package/dist/esm/Focus/Focus.styles.js +0 -17
- package/dist/esm/Focus/Focus.styles.js.map +1 -1
- package/dist/esm/Footer/Footer.styles.js +4 -12
- package/dist/esm/Footer/Footer.styles.js.map +1 -1
- package/dist/esm/Header/Header.styles.js +1 -1
- package/dist/esm/Header/Header.styles.js.map +1 -1
- package/dist/esm/InlineEditor/InlineEditor.js +1 -2
- package/dist/esm/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/InlineEditor/InlineEditor.styles.js +1 -1
- package/dist/esm/InlineEditor/InlineEditor.styles.js.map +1 -1
- package/dist/esm/MultiButton/MultiButton.styles.js +11 -9
- package/dist/esm/MultiButton/MultiButton.styles.js.map +1 -1
- package/dist/esm/Pagination/Pagination.styles.js +2 -3
- package/dist/esm/Pagination/Pagination.styles.js.map +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.styles.js +2 -3
- package/dist/esm/QueryBuilder/QueryBuilder.styles.js.map +1 -1
- package/dist/esm/Radio/Radio.styles.js +1 -6
- package/dist/esm/Radio/Radio.styles.js.map +1 -1
- package/dist/esm/Select/Select.js +1 -1
- package/dist/esm/Select/Select.js.map +1 -1
- package/dist/esm/Select/Select.styles.js +12 -7
- package/dist/esm/Select/Select.styles.js.map +1 -1
- package/dist/esm/SimpleGrid/SimpleGrid.js.map +1 -1
- package/dist/esm/Skeleton/Skeleton.js +2 -5
- package/dist/esm/Skeleton/Skeleton.js.map +1 -1
- package/dist/esm/Slider/Slider.styles.js +3 -3
- package/dist/esm/Slider/Slider.styles.js.map +1 -1
- package/dist/esm/Slider/SliderInput/SliderInput.js +3 -4
- package/dist/esm/Slider/SliderInput/SliderInput.js.map +1 -1
- package/dist/esm/Slider/SliderInput/SliderInput.styles.js +9 -3
- package/dist/esm/Slider/SliderInput/SliderInput.styles.js.map +1 -1
- package/dist/esm/Table/TableHeader/TableHeader.js +0 -1
- package/dist/esm/Table/TableHeader/TableHeader.js.map +1 -1
- package/dist/esm/Tag/Tag.js +20 -11
- package/dist/esm/Tag/Tag.js.map +1 -1
- package/dist/esm/Tag/Tag.styles.js +35 -8
- package/dist/esm/Tag/Tag.styles.js.map +1 -1
- package/dist/esm/TimePicker/TimePicker.styles.js +1 -1
- package/dist/esm/TimePicker/TimePicker.styles.js.map +1 -1
- package/dist/esm/Tooltip/Tooltip.styles.js +1 -1
- package/dist/esm/Tooltip/Tooltip.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.js +1 -1
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.styles.js +1 -0
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/VerticalNavigation.styles.js +2 -2
- package/dist/esm/VerticalNavigation/VerticalNavigation.styles.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/utils/Callout.js +1 -1
- package/dist/esm/utils/Callout.js.map +1 -1
- package/dist/types/index.d.ts +39 -31
- package/package.json +6 -6
- package/dist/cjs/utils/ConditionalWrapper.cjs +0 -8
- package/dist/esm/utils/ConditionalWrapper.js +0 -8
- package/dist/esm/utils/ConditionalWrapper.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.styles.js","sources":["../../../src/Radio/Radio.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvRadio\", {\n root: { display: \"inline-block\" },\n container: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n transition: \"background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms\",\n borderRadius: theme.radii.base,\n\n \":hover:not($disabled)\": {\n backgroundColor: theme.colors.bgHover,\n },\n },\n invalidContainer: {},\n disabled: {\n cursor: \"not-allowed\",\n\n \"& $label\": { color: theme.colors.textDisabled, cursor: \"not-allowed\" },\n },\n radio: {
|
|
1
|
+
{"version":3,"file":"Radio.styles.js","sources":["../../../src/Radio/Radio.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvRadio\", {\n root: { display: \"inline-block\" },\n container: {\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n transition: \"background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms\",\n borderRadius: theme.radii.base,\n\n \":hover:not($disabled)\": {\n backgroundColor: theme.colors.bgHover,\n },\n },\n invalidContainer: {},\n disabled: {\n cursor: \"not-allowed\",\n\n \"& $label\": { color: theme.colors.textDisabled, cursor: \"not-allowed\" },\n },\n radio: {},\n invalidRadio: {},\n label: {\n verticalAlign: \"middle\",\n paddingRight: theme.space.xs,\n ...theme.typography.body,\n cursor: \"pointer\",\n lineHeight: \"32px\",\n width: \"100%\",\n },\n focusVisible: {\n backgroundColor: theme.colors.bgPageSecondary,\n ...outlineStyles,\n },\n checked: {},\n semantic: {},\n});\n"],"names":[],"mappings":";;;AAKO,MAAM,EAAE,eAAe,eAAe,cAAc,WAAW;AAAA,EACpE,MAAM,EAAE,SAAS,eAAe;AAAA,EAChC,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,cAAc,MAAM,MAAM;AAAA,IAE1B,yBAAyB;AAAA,MACvB,iBAAiB,MAAM,OAAO;AAAA,IAAA;AAAA,EAElC;AAAA,EACA,kBAAkB,CAAC;AAAA,EACnB,UAAU;AAAA,IACR,QAAQ;AAAA,IAER,YAAY,EAAE,OAAO,MAAM,OAAO,cAAc,QAAQ,cAAc;AAAA,EACxE;AAAA,EACA,OAAO,CAAC;AAAA,EACR,cAAc,CAAC;AAAA,EACf,OAAO;AAAA,IACL,eAAe;AAAA,IACf,cAAc,MAAM,MAAM;AAAA,IAC1B,GAAG,MAAM,WAAW;AAAA,IACpB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACA,cAAc;AAAA,IACZ,iBAAiB,MAAM,OAAO;AAAA,IAC9B,GAAG;AAAA,EACL;AAAA,EACA,SAAS,CAAC;AAAA,EACV,UAAU,CAAA;AACZ,CAAC;"}
|
|
@@ -199,7 +199,7 @@ const HvSelect = fixedForwardRef(function HvSelect2(props, ref) {
|
|
|
199
199
|
style: {
|
|
200
200
|
width: variableWidth ? "auto" : (buttonRef.current?.clientWidth || 0) + 2
|
|
201
201
|
},
|
|
202
|
-
className: cx(classes.panel,
|
|
202
|
+
className: cx(classes.panel, {
|
|
203
203
|
[classes.panelOpenedUp]: placement.includes("top"),
|
|
204
204
|
[classes.panelOpenedDown]: placement.includes("bottom")
|
|
205
205
|
}),
|
|
@@ -1 +1 @@
|
|
|
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 >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,mBACP,SACA;AACI,MAAA,MAAM,QAAQ,OAAO,GAAG;AACtB,QAAA,QAAQ,WAAW,EAAU,QAAA;AAC1B,W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;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;"}
|
|
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, {\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 >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,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,IAA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ACH,UACC,UAAU,SAAS,eAAe,KAAK;AAAA,gBAC9C;AAAA,gBACA,WAAW,GAAG,QAAQ,OAAO;AAAA,kBAC3B,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;"}
|
|
@@ -20,7 +20,14 @@ const { staticClasses, useClasses } = createClasses("HvSelect", {
|
|
|
20
20
|
description: {},
|
|
21
21
|
select: {},
|
|
22
22
|
popper: {
|
|
23
|
-
zIndex: theme.zIndices.popover
|
|
23
|
+
zIndex: theme.zIndices.popover,
|
|
24
|
+
"--r": theme.radii.base,
|
|
25
|
+
"&[data-popper-placement*='top'] $panel": {
|
|
26
|
+
borderRadius: `var(--r) var(--r) 0 0`
|
|
27
|
+
},
|
|
28
|
+
"&[data-popper-placement*='bottom'] $panel": {
|
|
29
|
+
borderRadius: `0 0 var(--r) var(--r)`
|
|
30
|
+
}
|
|
24
31
|
},
|
|
25
32
|
panel: {
|
|
26
33
|
maxHeight: 400,
|
|
@@ -34,12 +41,10 @@ const { staticClasses, useClasses } = createClasses("HvSelect", {
|
|
|
34
41
|
overflowY: "auto",
|
|
35
42
|
borderRadius: "inherit"
|
|
36
43
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
panelOpenedDown: {
|
|
41
|
-
borderRadius: `0 0 ${theme.radii.base} ${theme.radii.base}`
|
|
42
|
-
},
|
|
44
|
+
/** @deprecated leverage `[data-popper-placement]` instead */
|
|
45
|
+
panelOpenedUp: {},
|
|
46
|
+
/** @deprecated leverage `[data-popper-placement]` instead */
|
|
47
|
+
panelOpenedDown: {},
|
|
43
48
|
error: {}
|
|
44
49
|
});
|
|
45
50
|
export {
|
|
@@ -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 borderColor: theme.form.errorColor,\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.text}`,\n marginTop: -1,\n marginBottom: -1,\n\n // panel styles\n position: \"relative\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.bgContainer,\n overflowY: \"auto\",\n borderRadius: \"inherit\",\n },\n
|
|
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 borderColor: theme.form.errorColor,\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 \"--r\": theme.radii.base,\n \"&[data-popper-placement*='top'] $panel\": {\n borderRadius: `var(--r) var(--r) 0 0`,\n },\n \"&[data-popper-placement*='bottom'] $panel\": {\n borderRadius: `0 0 var(--r) var(--r)`,\n },\n },\n panel: {\n maxHeight: 400,\n border: `1px solid ${theme.colors.text}`,\n marginTop: -1,\n marginBottom: -1,\n\n // panel styles\n position: \"relative\",\n padding: theme.space.xs,\n backgroundColor: theme.colors.bgContainer,\n overflowY: \"auto\",\n borderRadius: \"inherit\",\n },\n /** @deprecated leverage `[data-popper-placement]` instead */\n panelOpenedUp: {},\n /** @deprecated leverage `[data-popper-placement]` instead */\n panelOpenedDown: {},\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,aAAa,MAAM,KAAK;AAAA,EAC1B;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,IAEvB,OAAO,MAAM,MAAM;AAAA,IACnB,0CAA0C;AAAA,MACxC,cAAc;AAAA,IAChB;AAAA,IACA,6CAA6C;AAAA,MAC3C,cAAc;AAAA,IAAA;AAAA,EAElB;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,IACX,QAAQ,aAAa,MAAM,OAAO,IAAI;AAAA,IACtC,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;AAAA,EAEA,eAAe,CAAC;AAAA;AAAA,EAEhB,iBAAiB,CAAC;AAAA,EAClB,OAAO,CAAA;AACT,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleGrid.js","sources":["../../../src/SimpleGrid/SimpleGrid.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport {\n getContainerStyle,\n staticClasses,\n useClasses,\n} from \"./SimpleGrid.styles\";\n\nexport { staticClasses as simpleGridClasses };\n\n
|
|
1
|
+
{"version":3,"file":"SimpleGrid.js","sources":["../../../src/SimpleGrid/SimpleGrid.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport {\n getContainerStyle,\n staticClasses,\n useClasses,\n} from \"./SimpleGrid.styles\";\n\nexport { staticClasses as simpleGridClasses };\n\n/** @deprecated use `HvBreakpoints` instead */\nexport type Spacing = HvBreakpoints;\n\n// TODO: rename in v6 (or inline)\nexport interface Breakpoint {\n cols?: number;\n maxWidth?: number;\n minWidth?: number;\n spacing?: HvBreakpoints;\n}\n\nexport type HvSimpleGridClasses = ExtractNames<typeof useClasses>;\n\n/** Grid component that enables you to create columns of equal width and define your own breakpoints and responsive behavior. */\nexport interface HvSimpleGridProps extends HvBaseProps {\n /** Spacing with pre-defined values according the values defined in the theme */\n spacing?: HvBreakpoints;\n /**\n * Provide an array to define responsive behavior:\n * - `maxWidth` or `minWidth`: max-width or min-width at which media query will work\n * - `cols`: number of columns per row at given max-width\n * - `spacing`: optional spacing at given max-width, if not provided spacing from component prop will be used instead\n */\n breakpoints?: Breakpoint[];\n /** Number of how many columns the content will be displayed */\n cols?: number;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSimpleGridClasses;\n}\n\nexport const HvSimpleGrid = (props: HvSimpleGridProps) => {\n const {\n children,\n breakpoints,\n spacing,\n cols,\n className,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvSimpleGrid\", props);\n\n const { classes, cx, css } = useClasses(classesProp);\n\n const containerStyle = getContainerStyle(breakpoints, spacing, cols);\n\n return (\n <div\n className={cx(css(containerStyle), classes.root, className)}\n {...others}\n >\n {children}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AA6Ca,MAAA,eAAe,CAAC,UAA6B;AAClD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,GAAG;AAAA,EAAA,IACD,gBAAgB,gBAAgB,KAAK;AAEzC,QAAM,EAAE,SAAS,IAAI,IAAI,IAAI,WAAW,WAAW;AAEnD,QAAM,iBAAiB,kBAAkB,aAAa,SAAS,IAAI;AAGjE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,GAAG,IAAI,cAAc,GAAG,QAAQ,MAAM,SAAS;AAAA,MACzD,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
|
|
@@ -24,17 +24,14 @@ const HvSkeleton = (props) => {
|
|
|
24
24
|
className: cx(
|
|
25
25
|
classes.root,
|
|
26
26
|
classes[variant],
|
|
27
|
-
|
|
27
|
+
classes[animation],
|
|
28
28
|
className
|
|
29
29
|
),
|
|
30
30
|
style: {
|
|
31
31
|
width,
|
|
32
32
|
height,
|
|
33
33
|
...backgroundImage && {
|
|
34
|
-
|
|
35
|
-
backgroundSize: "contain",
|
|
36
|
-
backgroundPosition: "center",
|
|
37
|
-
backgroundRepeat: "no-repeat"
|
|
34
|
+
background: `center / contain no-repeat url(${backgroundImage})`
|
|
38
35
|
},
|
|
39
36
|
...style
|
|
40
37
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skeleton.js","sources":["../../../src/Skeleton/Skeleton.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { staticClasses, useClasses } from \"./Skeleton.styles\";\n\nexport { staticClasses as skeletonClasses };\n\nexport type HvSkeletonClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSkeletonProps extends HvBaseProps {\n /** Whether the skeleton element is hidden or not. */\n hidden?: boolean;\n /** The type of skeleton element. @default \"text\" */\n variant?: \"circle\" | \"square\" | \"text\";\n /** The animation the skeleton element will display. @default \"pulse\" */\n animation?: \"pulse\" | \"wave\";\n /** The width of the skeleton element. */\n width?: React.CSSProperties[\"width\"];\n /** The height of the skeleton element. */\n height?: React.CSSProperties[\"height\"];\n /** The url for a placeholder image to use on the skeleton element. */\n backgroundImage?: string;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSkeletonClasses;\n}\n\n/**\n * The `HvSkeleton` component is used to create a placeholder element that represents the shape and size of the content that will be loaded.\n */\nexport const HvSkeleton = (props: HvSkeletonProps) => {\n const {\n classes: classesProp,\n className,\n children,\n hidden = false,\n variant = \"text\",\n animation = \"pulse\",\n backgroundImage,\n width,\n height,\n style,\n ...others\n } = useDefaultProps(\"HvSkeleton\", props);\n const { classes, cx } = useClasses(classesProp);\n\n if (hidden) return <div className={classes.content}>{children}</div>;\n\n return (\n <div\n className={cx(\n classes.root,\n classes[variant],\n
|
|
1
|
+
{"version":3,"file":"Skeleton.js","sources":["../../../src/Skeleton/Skeleton.tsx"],"sourcesContent":["import {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseProps } from \"../types/generic\";\nimport { staticClasses, useClasses } from \"./Skeleton.styles\";\n\nexport { staticClasses as skeletonClasses };\n\nexport type HvSkeletonClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSkeletonProps extends HvBaseProps {\n /** Whether the skeleton element is hidden or not. */\n hidden?: boolean;\n /** The type of skeleton element. @default \"text\" */\n variant?: \"circle\" | \"square\" | \"text\";\n /** The animation the skeleton element will display. @default \"pulse\" */\n animation?: \"pulse\" | \"wave\";\n /** The width of the skeleton element. */\n width?: React.CSSProperties[\"width\"];\n /** The height of the skeleton element. */\n height?: React.CSSProperties[\"height\"];\n /** The url for a placeholder image to use on the skeleton element. */\n backgroundImage?: string;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSkeletonClasses;\n}\n\n/**\n * The `HvSkeleton` component is used to create a placeholder element that represents the shape and size of the content that will be loaded.\n */\nexport const HvSkeleton = (props: HvSkeletonProps) => {\n const {\n classes: classesProp,\n className,\n children,\n hidden = false,\n variant = \"text\",\n animation = \"pulse\",\n backgroundImage,\n width,\n height,\n style,\n ...others\n } = useDefaultProps(\"HvSkeleton\", props);\n const { classes, cx } = useClasses(classesProp);\n\n if (hidden) return <div className={classes.content}>{children}</div>;\n\n return (\n <div\n className={cx(\n classes.root,\n classes[variant],\n classes[animation],\n className,\n )}\n style={{\n width,\n height,\n ...(backgroundImage && {\n background: `center / contain no-repeat url(${backgroundImage})`,\n }),\n ...style,\n }}\n {...others}\n >\n {children}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAgCa,MAAA,aAAa,CAAC,UAA2B;AAC9C,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,cAAc,KAAK;AACvC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAE9C,MAAI,OAAe,QAAA,oBAAC,SAAI,WAAW,QAAQ,SAAU,UAAS;AAG5D,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ,OAAO;AAAA,QACf,QAAQ,SAAS;AAAA,QACjB;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,GAAI,mBAAmB;AAAA,UACrB,YAAY,kCAAkC,eAAe;AAAA,QAC/D;AAAA,QACA,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
|
|
@@ -30,7 +30,7 @@ const dragSquare = {
|
|
|
30
30
|
const ring = {
|
|
31
31
|
width: "32px",
|
|
32
32
|
height: "32px",
|
|
33
|
-
borderRadius: theme.radii.
|
|
33
|
+
borderRadius: theme.radii.full,
|
|
34
34
|
border: `9px solid ${theme.colors.primaryDimmed}`,
|
|
35
35
|
opacity: "100%",
|
|
36
36
|
content: "''",
|
|
@@ -41,7 +41,7 @@ const ring = {
|
|
|
41
41
|
const border = {
|
|
42
42
|
width: "20px",
|
|
43
43
|
height: "20px",
|
|
44
|
-
borderRadius: theme.radii.
|
|
44
|
+
borderRadius: theme.radii.full,
|
|
45
45
|
border: `2px solid ${theme.colors.textDimmed}`,
|
|
46
46
|
content: "''",
|
|
47
47
|
position: "absolute",
|
|
@@ -91,7 +91,7 @@ const sliderStyles = {
|
|
|
91
91
|
knobOuter: {
|
|
92
92
|
position: "relative",
|
|
93
93
|
borderColor: "transparent",
|
|
94
|
-
borderRadius: theme.radii.
|
|
94
|
+
borderRadius: theme.radii.full,
|
|
95
95
|
boxShadow: "none",
|
|
96
96
|
backgroundColor: theme.colors.border,
|
|
97
97
|
width: "32px",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.styles.js","sources":["../../../src/Slider/Slider.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\nimport base from \"./base\";\n\nconst dot: React.CSSProperties = {\n position: \"absolute\",\n bottom: \"-1px\",\n marginLeft: \"0px\",\n width: \"1px\",\n height: \"4px\",\n border: \"none\",\n backgroundColor: theme.colors.border,\n cursor: \"pointer\",\n verticalAlign: \"middle\",\n zIndex: \"-3\",\n};\n\nconst dragSquare: React.CSSProperties = {\n cursor: \"grab\",\n width: \"calc(100% - 40px)\",\n left: \"20px\",\n height: \"27px\",\n position: \"absolute\",\n top: \"-12px\",\n content: \"''\",\n background: \"transparent\",\n borderTop: `12px solid ${theme.colors.primaryDimmed}`,\n borderBottom: `12px solid ${theme.colors.primaryDimmed}`,\n zIndex: \"-2\",\n};\n\nconst ring: React.CSSProperties = {\n width: \"32px\",\n height: \"32px\",\n borderRadius: theme.radii.
|
|
1
|
+
{"version":3,"file":"Slider.styles.js","sources":["../../../src/Slider/Slider.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"../utils/focusUtils\";\nimport base from \"./base\";\n\nconst dot: React.CSSProperties = {\n position: \"absolute\",\n bottom: \"-1px\",\n marginLeft: \"0px\",\n width: \"1px\",\n height: \"4px\",\n border: \"none\",\n backgroundColor: theme.colors.border,\n cursor: \"pointer\",\n verticalAlign: \"middle\",\n zIndex: \"-3\",\n};\n\nconst dragSquare: React.CSSProperties = {\n cursor: \"grab\",\n width: \"calc(100% - 40px)\",\n left: \"20px\",\n height: \"27px\",\n position: \"absolute\",\n top: \"-12px\",\n content: \"''\",\n background: \"transparent\",\n borderTop: `12px solid ${theme.colors.primaryDimmed}`,\n borderBottom: `12px solid ${theme.colors.primaryDimmed}`,\n zIndex: \"-2\",\n};\n\nconst ring: React.CSSProperties = {\n width: \"32px\",\n height: \"32px\",\n borderRadius: theme.radii.full,\n border: `9px solid ${theme.colors.primaryDimmed}`,\n opacity: \"100%\",\n content: \"''\",\n position: \"absolute\",\n top: \"-10px\",\n left: \"-10px\",\n};\n\nconst border: React.CSSProperties = {\n width: \"20px\",\n height: \"20px\",\n borderRadius: theme.radii.full,\n border: `2px solid ${theme.colors.textDimmed}`,\n content: \"''\",\n position: \"absolute\",\n top: \"-4px\",\n left: \"-4px\",\n};\n\nexport const sliderStyles = {\n mark: {\n ...theme.typography.caption1,\n fontFamily: theme.fontFamily.body,\n top: \"-2px\",\n zIndex: -1,\n },\n disabledMark: {\n ...theme.typography.caption1,\n fontFamily: theme.fontFamily.body,\n color: theme.colors.textDisabled,\n cursor: \"not-allowed\",\n top: \"-2px\",\n },\n dot: {\n ...dot,\n },\n dotDisabled: {\n ...dot,\n cursor: \"not-allowed\",\n },\n knobHidden: { display: \"none\" },\n knobHiddenLast: {\n borderColor: \"transparent\",\n height: \"3px\",\n width: \"2px\",\n marginLeft: \"-1px\",\n border: \"none\",\n marginTop: \"0px\",\n left: \"100%\",\n touchAction: \"none\",\n cursor: \"default\",\n },\n knobInner: {\n borderColor: \"transparent\",\n boxShadow: \"none\",\n backgroundColor: theme.colors.text,\n width: \"16px\",\n height: \"16px\",\n },\n knobOuter: {\n position: \"relative\",\n borderColor: \"transparent\",\n borderRadius: theme.radii.full,\n boxShadow: \"none\",\n backgroundColor: theme.colors.border,\n width: \"32px\",\n height: \"32px\",\n top: \"-80%\",\n left: \"-80%\",\n zIndex: \"-1\",\n },\n track: {\n backgroundColor: theme.colors.text,\n height: \"3px\",\n zIndex: \"-1\",\n marginTop: \"-1px\",\n },\n rail: { backgroundColor: theme.colors.border, height: \"1px\", zIndex: \"-3\" },\n} satisfies Record<string, React.CSSProperties>;\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSlider\", {\n sliderBase: { ...base },\n rootDisabled: {\n cursor: \"not-allowed\",\n \"&& .rc-slider-disabled\": {\n background: \"transparent\",\n },\n },\n sliderContainer: { marginBottom: \"18px\", padding: \"0 23px\" },\n error: { padding: \"0 8px\" },\n trackDragging: {\n cursor: \"grabbing\",\n\n \"&& .rc-slider-track\": {\n \"&::before\": {\n ...dragSquare,\n cursor: \"grabbing\",\n },\n },\n },\n trackStandBy: {\n \"&& .rc-slider-track\": {\n \"&:hover\": {\n \"&::before\": {\n ...dragSquare,\n },\n },\n },\n },\n sliderRoot: { zIndex: 0 },\n rootRange: {},\n handleContainer: {\n \"&& .rc-slider-handle\": {\n cursor: \"pointer\",\n marginTop: \"-8px\",\n opacity: 1,\n \"&:active\": {\n cursor: \"grab\",\n \"&::before\": {\n ...ring,\n },\n \"&::after\": {\n ...border,\n },\n },\n \"&:hover\": {\n \"&::before\": {\n ...ring,\n },\n \"&::after\": {\n ...border,\n },\n },\n\n // Note about the usage of `!important below`: the way the rc-slider allows us to\n // style the knobs is through inline styles. This means that the `box-shadow`, which\n // is an inline style and is set to `none` to prevent the default rc-slider style to\n // show, can't be overridden for the focus scenario unless we use the `!important` flag.\n \"&:focus-visible\": {\n ...outlineStyles,\n boxShadow: \"0 0 0 3px #52A8EC, 0 0 0 7px rgba(29,155,209,.3)!important\",\n \"&::after\": {\n ...border,\n },\n },\n },\n },\n handle: {},\n handleContainerDisabled: {\n \"&& .rc-slider-handle\": {\n cursor: \"not-allowed\",\n marginTop: \"-8px\",\n opacity: 1,\n \"&:active\": {\n cursor: \"not-allowed\",\n },\n \"&:hover\": {\n cursor: \"not-allowed\",\n },\n },\n },\n handleHiddenContainer: { display: \"none\" },\n labelContainer: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n marginBottom: \"12px\",\n marginLeft: \"20px\",\n marginRight: \"20px\",\n },\n labelIncluded: { justifyContent: \"space-between\" },\n onlyInput: { justifyContent: \"flex-end\" },\n label: {},\n root: {},\n sliderTooltip: {\n \"&& .rc-slider-tooltip-inner\": {\n background: theme.colors.bgContainer,\n borderRadius: 0,\n maxWidth: \"532px\",\n height: \"100%\",\n padding: theme.space.sm,\n ...theme.typography.body,\n fontFamily: theme.fontFamily.body,\n boxShadow: \"none\",\n },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AA,EACf;AAAA,EACA,eAAe,EAAE,gBAAgB,gBAAgB;AAAA,EACjD,WAAW,EAAE,gBAAgB,WAAW;AAAA,EACxC,OAAO,CAAC;AAAA,EACR,MAAM,CAAC;AAAA,EACP,eAAe;AAAA,IACb,+BAA+B;AAAA,MAC7B,YAAY,MAAM,OAAO;AAAA,MACzB,cAAc;AAAA,MACd,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,SAAS,MAAM,MAAM;AAAA,MACrB,GAAG,MAAM,WAAW;AAAA,MACpB,YAAY,MAAM,WAAW;AAAA,MAC7B,WAAW;AAAA,IACb;AAAA,IAEA,+BAA+B;AAAA,MAC7B,YAAY;AAAA,IAAA;AAAA,EACd;AAEJ,CAAC;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
import { Remove } from "@hitachivantara/uikit-react-icons";
|
|
2
|
+
import { useState, useEffect, Fragment } from "react";
|
|
4
3
|
import { setId } from "../../utils/setId.js";
|
|
5
4
|
import { knobsValuesToString, stringValuesToKnobs } from "../utils.js";
|
|
6
5
|
import { useClasses } from "./SliderInput.styles.js";
|
|
@@ -31,8 +30,8 @@ const HvSliderInput = ({
|
|
|
31
30
|
useEffect(() => {
|
|
32
31
|
setInputValues(knobsValuesToString(valuesProp, markDigits));
|
|
33
32
|
}, [markDigits, valuesProp]);
|
|
34
|
-
return /* @__PURE__ */ jsx("div", { className: cx(classes.
|
|
35
|
-
index !== 0 && /* @__PURE__ */ jsx(
|
|
33
|
+
return /* @__PURE__ */ jsx("div", { className: cx(classes.root, className), ...others, children: inputValues.map((value, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
34
|
+
index !== 0 && /* @__PURE__ */ jsx("span", { children: "—" }),
|
|
36
35
|
/* @__PURE__ */ jsx(
|
|
37
36
|
HvInput,
|
|
38
37
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderInput.js","sources":["../../../../src/Slider/SliderInput/SliderInput.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"SliderInput.js","sources":["../../../../src/Slider/SliderInput/SliderInput.tsx"],"sourcesContent":["import { Fragment, useEffect, useState } from \"react\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvFormStatus } from \"../../FormElement\";\nimport { HvInput, HvInputProps } from \"../../Input\";\nimport { HvBaseProps } from \"../../types/generic\";\nimport { setId } from \"../../utils/setId\";\nimport { knobsValuesToString, stringValuesToKnobs } from \"../utils\";\nimport { staticClasses, useClasses } from \"./SliderInput.styles\";\n\nexport { staticClasses as sliderInputClasses };\n\nexport type HvSliderInputClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSliderInputProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * Used to generate the aria-label for the inputs.\n */\n label?: React.ReactNode;\n /**\n * Input status.\n */\n status?: HvFormStatus[];\n /**\n * The values array to apply to the component\n */\n values?: number[];\n /**\n * Callback function to be triggered when the selected date has changed.\n */\n onChange?: (values: number[], index: number) => void;\n /**\n * Attributes applied to the input element.\n */\n inputProps?: HvInputProps[];\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is read only.\n */\n readOnly?: boolean;\n /**\n * Indicates how many decimals to use.\n */\n markDigits?: number;\n /**\n * Styles applied from the theme.\n */\n classes?: HvSliderInputClasses;\n}\n\nexport const HvSliderInput = ({\n classes: classesProp,\n className,\n id,\n label,\n status,\n values: valuesProp = [],\n inputProps = [],\n readOnly = false,\n disabled = false,\n markDigits = 0,\n onChange,\n ...others\n}: HvSliderInputProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const [inputValues, setInputValues] = useState<string[]>(\n knobsValuesToString(valuesProp, markDigits),\n );\n\n const handleChange = (index: number) => {\n if (disabled) return;\n\n onChange?.(stringValuesToKnobs(inputValues), index);\n };\n\n useEffect(() => {\n setInputValues(knobsValuesToString(valuesProp, markDigits));\n }, [markDigits, valuesProp]);\n\n return (\n <div className={cx(classes.root, className)} {...others}>\n {inputValues.map((value, index) => (\n <Fragment key={setId(id, index)}>\n {index !== 0 && <span>—</span>}\n <HvInput\n id={setId(id, index)}\n aria-label={`${label}-${index}`}\n className={classes.input}\n disabled={disabled}\n type=\"number\"\n value={Number.isNaN(value) || value == null ? \"\" : value.toString()}\n onEnter={() => handleChange(index)}\n onBlur={() => handleChange(index)}\n onChange={(_, inputValue) => {\n const newValues = [...inputValues];\n newValues[index] = inputValue;\n setInputValues(newValues);\n }}\n status={status?.[index] || \"standBy\"}\n readOnly={readOnly}\n disableClear\n {...inputProps[index]}\n />\n </Fragment>\n ))}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAsDO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,aAAa,CAAC;AAAA,EACtB,aAAa,CAAC;AAAA,EACd,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb;AAAA,EACA,GAAG;AACL,MAA0B;AACxB,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,CAAC,aAAa,cAAc,IAAI;AAAA,IACpC,oBAAoB,YAAY,UAAU;AAAA,EAC5C;AAEM,QAAA,eAAe,CAAC,UAAkB;AACtC,QAAI,SAAU;AAEH,eAAA,oBAAoB,WAAW,GAAG,KAAK;AAAA,EACpD;AAEA,YAAU,MAAM;AACC,mBAAA,oBAAoB,YAAY,UAAU,CAAC;AAAA,EAAA,GACzD,CAAC,YAAY,UAAU,CAAC;AAE3B,6BACG,OAAI,EAAA,WAAW,GAAG,QAAQ,MAAM,SAAS,GAAI,GAAG,QAC9C,sBAAY,IAAI,CAAC,OAAO,+BACtB,UACE,EAAA,UAAA;AAAA,IAAU,UAAA,KAAM,oBAAA,QAAA,EAAK,UAAC,KAAA;AAAA,IACvB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,MAAM,IAAI,KAAK;AAAA,QACnB,cAAY,GAAG,KAAK,IAAI,KAAK;AAAA,QAC7B,WAAW,QAAQ;AAAA,QACnB;AAAA,QACA,MAAK;AAAA,QACL,OAAO,OAAO,MAAM,KAAK,KAAK,SAAS,OAAO,KAAK,MAAM,SAAS;AAAA,QAClE,SAAS,MAAM,aAAa,KAAK;AAAA,QACjC,QAAQ,MAAM,aAAa,KAAK;AAAA,QAChC,UAAU,CAAC,GAAG,eAAe;AACrB,gBAAA,YAAY,CAAC,GAAG,WAAW;AACjC,oBAAU,KAAK,IAAI;AACnB,yBAAe,SAAS;AAAA,QAC1B;AAAA,QACA,QAAQ,SAAS,KAAK,KAAK;AAAA,QAC3B;AAAA,QACA,cAAY;AAAA,QACX,GAAG,WAAW,KAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EACtB,EAAA,GApBa,MAAM,IAAI,KAAK,CAqB9B,CACD,EACH,CAAA;AAEJ;"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { createClasses } from "@hitachivantara/uikit-react-utils";
|
|
2
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
3
|
const { staticClasses, useClasses } = createClasses("HvSliderInput", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
root: {
|
|
5
|
+
display: "flex",
|
|
6
|
+
alignItems: "center",
|
|
7
|
+
color: theme.colors.textSubtle,
|
|
8
|
+
gap: theme.space.xs,
|
|
9
|
+
fontSize: 16
|
|
10
|
+
},
|
|
11
|
+
input: { maxWidth: "50px" }
|
|
6
12
|
});
|
|
7
13
|
export {
|
|
8
14
|
staticClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderInput.styles.js","sources":["../../../../src/Slider/SliderInput/SliderInput.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSliderInput\", {\n
|
|
1
|
+
{"version":3,"file":"SliderInput.styles.js","sources":["../../../../src/Slider/SliderInput/SliderInput.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvSliderInput\", {\n root: {\n display: \"flex\",\n alignItems: \"center\",\n color: theme.colors.textSubtle,\n gap: theme.space.xs,\n fontSize: 16,\n },\n input: { maxWidth: \"50px\" },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,iBAAiB;AAAA,EAC1E,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,OAAO,MAAM,OAAO;AAAA,IACpB,KAAK,MAAM,MAAM;AAAA,IACjB,UAAU;AAAA,EACZ;AAAA,EACA,OAAO,EAAE,UAAU,OAAO;AAC5B,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHeader.js","sources":["../../../../src/Table/TableHeader/TableHeader.tsx"],"sourcesContent":["import { forwardRef, useContext, useMemo } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButton, HvButtonProps } from \"../../Button\";\nimport { HvTypography, HvTypographyProps } from \"../../Typography\";\nimport { capitalize } from \"../../utils/helpers\";\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\nimport TableContext from \"../TableContext\";\nimport { TableSectionContext } from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableHeader.styles\";\nimport { getSortIcon, isParagraph } from \"./utils\";\n\nexport { staticClasses as tableHeaderClasses };\n\nexport type HvTableHeaderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableHeaderProps\n extends Omit<React.ThHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to th. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** The scope of cells that the header element relates to. */\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\";\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant;\n /** Specify the cell type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is sorted */\n sorted?: boolean;\n /** Whether or not the cell is sortable */\n sortable?: boolean;\n /** Set sort direction icon and aria-sort. */\n sortDirection?: \"ascending\" | \"descending\" | false;\n /** Extra props to be passed onto the text in the header. */\n headerTextProps?: HvTypographyProps;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** The resize props injected in the resize handler */\n resizerProps?: React.HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableHeaderClasses;\n /** Extra props to be passed onto the sort button in the header. */\n sortButtonProps?: HvButtonProps;\n}\n\nconst defaultComponent = \"th\";\n\n/**\n * `HvTableHeader` acts as a `th` element and inherits styles from its context\n */\nexport const HvTableHeader = forwardRef<HTMLElement, HvTableHeaderProps>(\n function HvTableHeader(props, ref) {\n const {\n children,\n component,\n className,\n style: styleProp,\n classes: classesProp,\n scope: scopeProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sortDirection = \"none\",\n sorted,\n sortable,\n headerTextProps,\n resizerProps = {},\n resizable = false,\n resizing = false,\n sortButtonProps,\n ...others\n } = useDefaultProps(\"HvTableHeader\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n const isHeadCell = type === \"head\";\n\n const scope = scopeProp ?? (isHeadCell ? \"col\" : \"row\");\n\n const Sort = useMemo(\n () => getSortIcon(sorted && sortDirection),\n [sorted, sortDirection],\n );\n\n const Component =\n component || tableContext?.components?.Th || defaultComponent;\n\n const role =\n Component === defaultComponent\n ? null\n : isHeadCell\n ? \"columnheader\"\n : \"rowheader\";\n const paragraph = isParagraph(children);\n\n // Keep the header sticky\n const style = stickyColumn\n ? { ...styleProp, position: \"sticky\" }\n : styleProp;\n\n return (\n <Component\n ref={ref}\n role={role}\n scope={scope}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n align !== \"inherit\" && classes[`align${capitalize(align)}`],\n variant !== \"default\" && classes[`variant${capitalize(variant)}`],\n {\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.sortable]: sortable,\n [classes.sorted]: sorted,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.variantList]: tableContext.variant === \"listrow\",\n },\n className,\n )}\n aria-sort={sortable ? sortDirection : undefined}\n {...others}\n >\n <div\n className={cx(\n classes.headerContent,\n align !== \"inherit\" && classes[`alignFlex${capitalize(align)}`],\n )}\n >\n {isHeadCell && sortable && (\n <HvButton\n className={classes.sortButton}\n icon\n
|
|
1
|
+
{"version":3,"file":"TableHeader.js","sources":["../../../../src/Table/TableHeader/TableHeader.tsx"],"sourcesContent":["import { forwardRef, useContext, useMemo } from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvButton, HvButtonProps } from \"../../Button\";\nimport { HvTypography, HvTypographyProps } from \"../../Typography\";\nimport { capitalize } from \"../../utils/helpers\";\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\nimport TableContext from \"../TableContext\";\nimport { TableSectionContext } from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableHeader.styles\";\nimport { getSortIcon, isParagraph } from \"./utils\";\n\nexport { staticClasses as tableHeaderClasses };\n\nexport type HvTableHeaderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableHeaderProps\n extends Omit<React.ThHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to th. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** The scope of cells that the header element relates to. */\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\";\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant;\n /** Specify the cell type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is sorted */\n sorted?: boolean;\n /** Whether or not the cell is sortable */\n sortable?: boolean;\n /** Set sort direction icon and aria-sort. */\n sortDirection?: \"ascending\" | \"descending\" | false;\n /** Extra props to be passed onto the text in the header. */\n headerTextProps?: HvTypographyProps;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** The resize props injected in the resize handler */\n resizerProps?: React.HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableHeaderClasses;\n /** Extra props to be passed onto the sort button in the header. */\n sortButtonProps?: HvButtonProps;\n}\n\nconst defaultComponent = \"th\";\n\n/**\n * `HvTableHeader` acts as a `th` element and inherits styles from its context\n */\nexport const HvTableHeader = forwardRef<HTMLElement, HvTableHeaderProps>(\n function HvTableHeader(props, ref) {\n const {\n children,\n component,\n className,\n style: styleProp,\n classes: classesProp,\n scope: scopeProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sortDirection = \"none\",\n sorted,\n sortable,\n headerTextProps,\n resizerProps = {},\n resizable = false,\n resizing = false,\n sortButtonProps,\n ...others\n } = useDefaultProps(\"HvTableHeader\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n const isHeadCell = type === \"head\";\n\n const scope = scopeProp ?? (isHeadCell ? \"col\" : \"row\");\n\n const Sort = useMemo(\n () => getSortIcon(sorted && sortDirection),\n [sorted, sortDirection],\n );\n\n const Component =\n component || tableContext?.components?.Th || defaultComponent;\n\n const role =\n Component === defaultComponent\n ? null\n : isHeadCell\n ? \"columnheader\"\n : \"rowheader\";\n const paragraph = isParagraph(children);\n\n // Keep the header sticky\n const style = stickyColumn\n ? { ...styleProp, position: \"sticky\" }\n : styleProp;\n\n return (\n <Component\n ref={ref}\n role={role}\n scope={scope}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n align !== \"inherit\" && classes[`align${capitalize(align)}`],\n variant !== \"default\" && classes[`variant${capitalize(variant)}`],\n {\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.sortable]: sortable,\n [classes.sorted]: sorted,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.variantList]: tableContext.variant === \"listrow\",\n },\n className,\n )}\n aria-sort={sortable ? sortDirection : undefined}\n {...others}\n >\n <div\n className={cx(\n classes.headerContent,\n align !== \"inherit\" && classes[`alignFlex${capitalize(align)}`],\n )}\n >\n {isHeadCell && sortable && (\n <HvButton\n className={classes.sortButton}\n icon\n aria-label=\"Sort\"\n {...sortButtonProps}\n >\n <Sort className={classes.sortIcon} />\n </HvButton>\n )}\n <HvTypography\n component=\"div\"\n className={cx({\n [classes.headerText]: !paragraph,\n [classes.headerParagraph]: paragraph,\n [classes.sortableHeaderText]: sortable,\n })}\n variant=\"label\"\n {...headerTextProps}\n >\n {children}\n </HvTypography>\n </div>\n {resizable && <div {...resizerProps} className={classes.resizer} />}\n </Component>\n );\n },\n);\n"],"names":["HvTableHeader"],"mappings":";;;;;;;;;;;AAmEA,MAAM,mBAAmB;AAKlB,MAAM,gBAAgB;AAAA,EAC3B,SAASA,eAAc,OAAO,KAAK;AAC3B,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,SAAS;AAAA,MACT,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe;AAAA,MACf,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,CAAC;AAAA,MAChB,YAAY;AAAA,MACZ,WAAW;AAAA,MACX;AAAA,MACA,GAAG;AAAA,IAAA,IACD,gBAAgB,iBAAiB,KAAK;AAC1C,UAAM,EAAE,SAAS,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AA;AAAA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,gBACT,QAAQ;AAAA,gBACR,UAAU,aAAa,QAAQ,YAAY,WAAW,KAAK,CAAC,EAAE;AAAA,cAChE;AAAA,cAEC,UAAA;AAAA,gBAAA,cAAc,YACb;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAW,QAAQ;AAAA,oBACnB,MAAI;AAAA,oBACJ,cAAW;AAAA,oBACV,GAAG;AAAA,oBAEJ,UAAC,oBAAA,MAAA,EAAK,WAAW,QAAQ,SAAU,CAAA;AAAA,kBAAA;AAAA,gBACrC;AAAA,gBAEF;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAU;AAAA,oBACV,WAAW,GAAG;AAAA,sBACZ,CAAC,QAAQ,UAAU,GAAG,CAAC;AAAA,sBACvB,CAAC,QAAQ,eAAe,GAAG;AAAA,sBAC3B,CAAC,QAAQ,kBAAkB,GAAG;AAAA,oBAAA,CAC/B;AAAA,oBACD,SAAQ;AAAA,oBACP,GAAG;AAAA,oBAEH;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,YAAA;AAAA,UACF;AAAA,UACC,aAAc,oBAAA,OAAA,EAAK,GAAG,cAAc,WAAW,QAAQ,QAAS,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACnE;AAAA,EAAA;AAGN;"}
|
package/dist/esm/Tag/Tag.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef, isValidElement, cloneElement } from "react";
|
|
3
3
|
import { CloseXS, CheckboxCheck, Checkbox } from "@hitachivantara/uikit-react-icons";
|
|
4
4
|
import { useDefaultProps, mergeStyles } from "@hitachivantara/uikit-react-utils";
|
|
5
|
-
import {
|
|
5
|
+
import { theme, getColor } from "@hitachivantara/uikit-styles";
|
|
6
6
|
import { useControlled } from "../hooks/useControlled.js";
|
|
7
7
|
import { isDeleteKey } from "../utils/keyboardUtils.js";
|
|
8
8
|
import { useClasses } from "./Tag.styles.js";
|
|
@@ -17,20 +17,22 @@ const HvTag = forwardRef(function HvTag2(props, ref) {
|
|
|
17
17
|
style,
|
|
18
18
|
label,
|
|
19
19
|
disabled,
|
|
20
|
+
size = "xs",
|
|
21
|
+
variant,
|
|
20
22
|
type = "semantic",
|
|
21
23
|
selectable,
|
|
22
24
|
selected,
|
|
23
25
|
defaultSelected = false,
|
|
26
|
+
showSelectIcon = selectable,
|
|
24
27
|
color,
|
|
28
|
+
icon: iconProp,
|
|
25
29
|
deleteIcon: deleteIconProp,
|
|
26
30
|
onDelete,
|
|
27
31
|
onClick,
|
|
28
32
|
onKeyDown,
|
|
29
33
|
onKeyUp,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
deleteButtonArialLabel = "Delete tag",
|
|
33
|
-
deleteButtonProps = {},
|
|
34
|
+
deleteButtonArialLabel,
|
|
35
|
+
deleteButtonProps,
|
|
34
36
|
...others
|
|
35
37
|
} = useDefaultProps("HvTag", props);
|
|
36
38
|
const { classes, cx } = useClasses(classesProp);
|
|
@@ -42,7 +44,11 @@ const HvTag = forwardRef(function HvTag2(props, ref) {
|
|
|
42
44
|
event.stopPropagation();
|
|
43
45
|
onDelete?.(event);
|
|
44
46
|
};
|
|
45
|
-
const
|
|
47
|
+
const tagColor = (
|
|
48
|
+
// backwards-compatibility for `type` prop
|
|
49
|
+
type === "categorical" && theme.alpha(color || "cat1", 0.2) || // use the palette color if it matches
|
|
50
|
+
theme.palette[color]?.[600] || getColor(color)
|
|
51
|
+
);
|
|
46
52
|
const isClickable = !!(onClick || onDelete || selectable);
|
|
47
53
|
const CheckboxIcon = isSelected ? CheckboxCheck : Checkbox;
|
|
48
54
|
const deleteIcon = deleteIconProp && isValidElement(deleteIconProp) ? cloneElement(deleteIconProp, {
|
|
@@ -67,12 +73,14 @@ const HvTag = forwardRef(function HvTag2(props, ref) {
|
|
|
67
73
|
disabled,
|
|
68
74
|
"data-color": color,
|
|
69
75
|
style: mergeStyles(style, {
|
|
70
|
-
"--
|
|
76
|
+
"--tagColor": tagColor
|
|
71
77
|
}),
|
|
72
|
-
className: cx(classes.root, classes.chipRoot, className, {
|
|
73
|
-
[classes.
|
|
74
|
-
[classes.selected]: isSelected,
|
|
78
|
+
className: cx(classes.root, classes.chipRoot, classes[size], className, {
|
|
79
|
+
[classes.hasIcon]: iconProp || selectable && showSelectIcon,
|
|
75
80
|
[classes.clickable]: isClickable && !disabled,
|
|
81
|
+
[classes.selected]: isSelected,
|
|
82
|
+
[classes.disabled]: disabled,
|
|
83
|
+
[classes.outlined]: variant === "outlined",
|
|
76
84
|
[classes.categorical]: type === "categorical",
|
|
77
85
|
[classes.categoricalFocus]: type === "categorical" && !disabled,
|
|
78
86
|
[classes.categoricalDisabled]: type === "categorical" && disabled
|
|
@@ -91,7 +99,8 @@ const HvTag = forwardRef(function HvTag2(props, ref) {
|
|
|
91
99
|
selected: isClickable && isSelected,
|
|
92
100
|
...others,
|
|
93
101
|
children: [
|
|
94
|
-
|
|
102
|
+
iconProp,
|
|
103
|
+
selectable && showSelectIcon && /* @__PURE__ */ jsx(
|
|
95
104
|
CheckboxIcon,
|
|
96
105
|
{
|
|
97
106
|
className: classes.icon,
|
package/dist/esm/Tag/Tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","sources":["../../../src/Tag/Tag.tsx"],"sourcesContent":["import { cloneElement, forwardRef, isValidElement } from \"react\";\nimport {\n Checkbox,\n CheckboxCheck,\n CloseXS,\n} from \"@hitachivantara/uikit-react-icons\";\nimport {\n mergeStyles,\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport {
|
|
1
|
+
{"version":3,"file":"Tag.js","sources":["../../../src/Tag/Tag.tsx"],"sourcesContent":["import { cloneElement, forwardRef, isValidElement } from \"react\";\nimport {\n Checkbox,\n CheckboxCheck,\n CloseXS,\n} from \"@hitachivantara/uikit-react-icons\";\nimport {\n mergeStyles,\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\nimport {\n getColor,\n theme,\n type HvColorAny,\n type HvSize,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { HvButtonBase, HvButtonBaseProps } from \"../ButtonBase\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { HvTypography } from \"../Typography\";\nimport { isDeleteKey } from \"../utils/keyboardUtils\";\nimport { staticClasses, useClasses } from \"./Tag.styles\";\n\nexport { staticClasses as tagClasses };\n\nexport type HvTagClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagProps\n extends Omit<\n HvButtonBaseProps,\n \"type\" | \"color\" | \"classes\" | \"onClick\" | \"onToggle\"\n > {\n /** The label of the tag element. */\n label?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** The type of the tag element. A tag can be of semantic or categoric type. */\n type?: \"semantic\" | \"categorical\";\n /** @deprecated */\n variant?: \"filled\" | \"outlined\";\n size?: Extract<HvSize, \"xs\" | \"sm\" | \"md\">;\n icon?: React.ReactNode;\n /** Whether to show the select icon checkbox. */\n showSelectIcon?: boolean;\n /** The color variant of the tag */\n color?: HvColorAny;\n /** Icon used to customize the delete icon */\n deleteIcon?: React.ReactElement;\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component, in order to render the delete icon\n * */\n onDelete?: React.EventHandler<any>;\n /** Callback triggered when any item is clicked. */\n onClick?: (event: React.MouseEvent<HTMLElement>, selected?: boolean) => void;\n /** Aria properties to apply to delete button in tag. @deprecated no longer used */\n deleteButtonArialLabel?: string;\n /** Props to apply to delete icon */\n deleteButtonProps?: React.HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagClasses;\n /** Determines whether or not the tag is selectable. */\n selectable?: boolean;\n /** Defines if the tag is selected. When defined the tag state becomes controlled. */\n selected?: boolean;\n /** When uncontrolled, defines the initial selected state. */\n defaultSelected?: boolean;\n}\n\n/**\n * A Tag is one word that describes a specific aspect of an asset. A single asset can have\n * multiple tags.\n * Use tags to highlight an item's status for quick recognition and navigation\n * Use color to indicate meanings that users can learn and recognize across products.\n */\nexport const HvTag = forwardRef<\n // no-indent\n HTMLElement,\n HvTagProps\n>(function HvTag(props, ref) {\n const {\n classes: classesProp,\n className,\n component,\n style,\n label,\n disabled,\n size = \"xs\",\n variant,\n type = \"semantic\",\n selectable,\n selected,\n defaultSelected = false,\n showSelectIcon = selectable,\n color,\n icon: iconProp,\n deleteIcon: deleteIconProp,\n onDelete,\n onClick,\n onKeyDown,\n onKeyUp,\n deleteButtonArialLabel,\n deleteButtonProps,\n ...others\n } = useDefaultProps(\"HvTag\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const [isSelected, setIsSelected] = useControlled(\n selected,\n Boolean(defaultSelected),\n );\n\n const handleDeleteClick = (event: React.MouseEvent) => {\n // Stop the event from bubbling up to the tag\n event.stopPropagation();\n onDelete?.(event);\n };\n\n const tagColor =\n // backwards-compatibility for `type` prop\n (type === \"categorical\" && theme.alpha(color || \"cat1\", 0.2)) ||\n // use the palette color if it matches\n theme.palette[color as keyof typeof theme.palette]?.[600] ||\n getColor(color);\n\n const isClickable = !!(onClick || onDelete || selectable);\n\n const CheckboxIcon = isSelected ? CheckboxCheck : Checkbox;\n\n const deleteIcon =\n deleteIconProp && isValidElement(deleteIconProp) ? (\n cloneElement<any>(deleteIconProp, {\n className: cx(classes.deleteIcon, {\n [classes.disabledDeleteIcon]: disabled,\n }),\n onClick: handleDeleteClick,\n })\n ) : (\n <CloseXS\n size=\"XS\"\n onClick={handleDeleteClick}\n className={cx(classes.deleteIcon, classes.button, classes.tagButton)}\n {...deleteButtonProps}\n />\n );\n\n return (\n <HvButtonBase\n ref={ref as any}\n component={isClickable ? HvButtonBase : \"div\"}\n disabled={disabled}\n data-color={color}\n style={mergeStyles(style, {\n \"--tagColor\": tagColor,\n })}\n className={cx(classes.root, classes.chipRoot, classes[size], className, {\n [classes.hasIcon]: iconProp || (selectable && showSelectIcon),\n [classes.clickable]: isClickable && !disabled,\n [classes.selected]: isSelected,\n [classes.disabled]: disabled,\n [classes.outlined]: variant === \"outlined\",\n [classes.categorical]: type === \"categorical\",\n [classes.categoricalFocus]: type === \"categorical\" && !disabled,\n [classes.categoricalDisabled]: type === \"categorical\" && disabled,\n })}\n onKeyUp={(event: React.KeyboardEvent<HTMLButtonElement>) => {\n // Ignore events from children.\n if (event.currentTarget === event.target && isDeleteKey(event)) {\n onDelete?.(event);\n }\n\n onKeyUp?.(event);\n }}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) return;\n if (selectable) setIsSelected(!isSelected);\n onClick?.(event, !isSelected);\n }}\n selected={isClickable && isSelected}\n {...others}\n >\n {iconProp}\n {selectable && showSelectIcon && (\n <CheckboxIcon\n className={classes.icon}\n color={(disabled && [\"bgPageSecondary\", \"textDisabled\"]) || undefined}\n size=\"XS\"\n />\n )}\n <HvTypography\n noWrap\n variant=\"caption2\"\n component=\"span\"\n className={classes.label}\n >\n {label}\n </HvTypography>\n {onDelete && !disabled && deleteIcon}\n </HvButtonBase>\n );\n});\n"],"names":["HvTag"],"mappings":";;;;;;;;;;;AA4EO,MAAM,QAAQ,WAInB,SAASA,OAAM,OAAO,KAAK;AACrB,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,IACjB;AAAA,IACA,MAAM;AAAA,IACN,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD,gBAAgB,SAAS,KAAK;AAClC,QAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,QAAA,CAAC,YAAY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S;AAAA,QAChC,CAAC,QAAQ,gBAAgB,GAAG,SAAS,iBAAiB,CAAC;AAAA,QACvD,CAAC,QAAQ,mBAAmB,GAAG,SAAS,iBAAiB;AAAA,MAAA,CAC1D;AAAA,MACD,SAAS,CAAC,UAAkD;AAE1D,YAAI,MAAM,kBAAkB,MAAM,UAAU,YAAY,KAAK,GAAG;AAC9D,qBAAW,KAAK;AAAA,QAAA;AAGlB,kBAAU,KAAK;AAAA,MACjB;AAAA,MACA,SAAS,CAAC,UAA+C;AACvD,YAAI,SAAU;AACV,YAAA,WAA0B,eAAA,CAAC,UAAU;AAC/B,kBAAA,OAAO,CAAC,UAAU;AAAA,MAC9B;AAAA,MACA,UAAU,eAAe;AAAA,MACxB,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA;AAAA,QACA,cAAc,kBACb;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW,QAAQ;AAAA,YACnB,OAAQ,YAAY,CAAC,mBAAmB,cAAc,KAAM;AAAA,YAC5D,MAAK;AAAA,UAAA;AAAA,QACP;AAAA,QAEF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,QAAM;AAAA,YACN,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,WAAW,QAAQ;AAAA,YAElB,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,QACC,YAAY,CAAC,YAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EAC5B;AAEJ,CAAC;"}
|
|
@@ -7,24 +7,51 @@ const { staticClasses, useClasses } = createClasses("HvTag", {
|
|
|
7
7
|
justifyContent: "center",
|
|
8
8
|
cursor: "default",
|
|
9
9
|
color: theme.colors.textDark,
|
|
10
|
-
|
|
11
|
-
height: 16,
|
|
10
|
+
borderColor: theme.colors.border,
|
|
12
11
|
borderRadius: 0,
|
|
13
12
|
maxWidth: 180,
|
|
14
13
|
whiteSpace: "nowrap",
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
transition: "background-color 0.3s ease",
|
|
15
|
+
"&,:hover,:focus-visible": {
|
|
16
|
+
backgroundColor: "var(--tagColor)"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
+
hasIcon: {
|
|
20
|
+
paddingLeft: 2
|
|
21
|
+
},
|
|
22
|
+
/** @deprecated */
|
|
23
|
+
outlined: {
|
|
24
|
+
outlineStyle: "solid"
|
|
25
|
+
},
|
|
26
|
+
/** @deprecated */
|
|
19
27
|
categorical: {
|
|
20
28
|
borderRadius: 8,
|
|
21
29
|
"& $label": {
|
|
22
30
|
color: theme.colors.text
|
|
31
|
+
},
|
|
32
|
+
"& $icon": {
|
|
33
|
+
display: "none"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
xs: {
|
|
37
|
+
height: 16
|
|
38
|
+
},
|
|
39
|
+
sm: {
|
|
40
|
+
height: 24,
|
|
41
|
+
"& $label": {
|
|
42
|
+
...theme.typography.caption1,
|
|
43
|
+
color: "inherit"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
md: {
|
|
47
|
+
height: 32,
|
|
48
|
+
"& $label": {
|
|
49
|
+
...theme.typography.body,
|
|
50
|
+
color: "inherit"
|
|
23
51
|
}
|
|
24
52
|
},
|
|
25
53
|
disabled: {
|
|
26
|
-
|
|
27
|
-
":hover, :focus": {
|
|
54
|
+
"&,:hover,:focus-visible": {
|
|
28
55
|
backgroundColor: theme.colors.bgDisabled
|
|
29
56
|
},
|
|
30
57
|
"& $label": {
|
|
@@ -46,10 +73,10 @@ const { staticClasses, useClasses } = createClasses("HvTag", {
|
|
|
46
73
|
clickable: {
|
|
47
74
|
cursor: "pointer"
|
|
48
75
|
},
|
|
76
|
+
// TODO: remove in favour of `hasIcon` once it's no longer needed
|
|
49
77
|
icon: {
|
|
50
78
|
width: 12,
|
|
51
|
-
height: 12
|
|
52
|
-
marginLeft: 2
|
|
79
|
+
height: 12
|
|
53
80
|
},
|
|
54
81
|
/** @deprecated use `root` instead */
|
|
55
82
|
chipRoot: {},
|