@hitachivantara/uikit-react-core 5.87.1 → 5.87.2
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/BaseRadio/BaseRadio.styles.cjs +7 -6
- package/dist/cjs/BulkActions/BulkActions.cjs +9 -18
- package/dist/cjs/CheckBoxGroup/CheckBoxGroup.cjs +9 -9
- package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs +9 -10
- package/dist/cjs/Radio/Radio.cjs +2 -1
- package/dist/cjs/Radio/Radio.styles.cjs +7 -27
- package/dist/cjs/Table/TableCell/TableCell.styles.cjs +14 -14
- package/dist/cjs/Table/TableHeader/TableHeader.styles.cjs +16 -15
- package/dist/cjs/utils/CounterLabel.cjs +15 -0
- package/dist/esm/BaseRadio/BaseRadio.styles.js +7 -6
- package/dist/esm/BaseRadio/BaseRadio.styles.js.map +1 -1
- package/dist/esm/BulkActions/BulkActions.js +10 -19
- package/dist/esm/BulkActions/BulkActions.js.map +1 -1
- package/dist/esm/CheckBoxGroup/CheckBoxGroup.js +10 -10
- package/dist/esm/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js +9 -10
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/Radio/Radio.js +2 -1
- package/dist/esm/Radio/Radio.js.map +1 -1
- package/dist/esm/Radio/Radio.styles.js +7 -27
- package/dist/esm/Radio/Radio.styles.js.map +1 -1
- package/dist/esm/Table/TableCell/TableCell.styles.js +14 -14
- package/dist/esm/Table/TableCell/TableCell.styles.js.map +1 -1
- package/dist/esm/Table/TableHeader/TableHeader.styles.js +16 -15
- package/dist/esm/Table/TableHeader/TableHeader.styles.js.map +1 -1
- package/dist/esm/utils/CounterLabel.js +15 -0
- package/dist/esm/utils/CounterLabel.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +6 -6
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useRef, useMemo, Children, useCallback, cloneElement } from "react";
|
|
3
3
|
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
4
4
|
import { useControlled } from "../hooks/useControlled.js";
|
|
5
5
|
import { useUniqueId } from "../hooks/useUniqueId.js";
|
|
6
|
+
import { CounterLabel } from "../utils/CounterLabel.js";
|
|
6
7
|
import { multiSelectionEventHandler } from "../utils/multiSelectionEventHandler.js";
|
|
7
8
|
import { setId } from "../utils/setId.js";
|
|
8
9
|
import { useClasses } from "./CheckBoxGroup.styles.js";
|
|
@@ -48,7 +49,6 @@ const HvCheckBoxGroup = forwardRef(
|
|
|
48
49
|
disabled,
|
|
49
50
|
showSelectAll,
|
|
50
51
|
orientation = "vertical",
|
|
51
|
-
selectAllLabel = "All",
|
|
52
52
|
selectAllConjunctionLabel = "/",
|
|
53
53
|
"aria-label": ariaLabel,
|
|
54
54
|
"aria-labelledby": ariaLabelledBy,
|
|
@@ -165,13 +165,6 @@ const HvCheckBoxGroup = forwardRef(
|
|
|
165
165
|
return newValue;
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
|
-
const selectAllLabelComponent = selectedCount === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
169
|
-
/* @__PURE__ */ jsx("b", { children: selectAllLabel }),
|
|
170
|
-
` (${Children.toArray(children).length})`
|
|
171
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
172
|
-
/* @__PURE__ */ jsx("b", { children: selectedCount }),
|
|
173
|
-
` ${selectAllConjunctionLabel} ${Children.toArray(children).length}`
|
|
174
|
-
] });
|
|
175
168
|
const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && required);
|
|
176
169
|
const errorMessageId = canShowError ? setId(elementId, "error") : ariaErrorMessage;
|
|
177
170
|
return /* @__PURE__ */ jsxs(
|
|
@@ -218,7 +211,14 @@ const HvCheckBoxGroup = forwardRef(
|
|
|
218
211
|
{
|
|
219
212
|
checked: selectAllState === "all",
|
|
220
213
|
indeterminate: selectAllState === "some",
|
|
221
|
-
label:
|
|
214
|
+
label: /* @__PURE__ */ jsx(
|
|
215
|
+
CounterLabel,
|
|
216
|
+
{
|
|
217
|
+
selected: selectedCount,
|
|
218
|
+
total: Children.count(children),
|
|
219
|
+
conjunctionLabel: selectAllConjunctionLabel
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
222
|
disabled,
|
|
223
223
|
readOnly,
|
|
224
224
|
className: classes.selectAll,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBoxGroup.js","sources":["../../../src/CheckBoxGroup/CheckBoxGroup.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../CheckBox\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../FormElement\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { multiSelectionEventHandler } from \"../utils/multiSelectionEventHandler\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./CheckBoxGroup.styles\";\n\nconst computeSelectAllState = (selected: number, total: number) => {\n if (selected === 0) {\n return \"none\";\n }\n\n if (selected === total) {\n return \"all\";\n }\n\n return \"some\";\n};\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const selectedValues = Children.toArray(children)\n .map((child: any) => {\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n return childIsSelected ? child?.props?.value : undefined;\n })\n .filter((v) => v !== undefined);\n\n return selectedValues;\n};\n\nexport { staticClasses as checkBoxGroupClasses };\n\nexport type HvCheckBoxGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCheckBoxGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children checkboxes, unless they already have one.\n */\n name?: string;\n /**\n * The value of the form element. An array of values represented in the child checkboxes.\n *\n * When defined the checkbox group state becomes controlled.\n */\n value?: any[];\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any[];\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children checkboxes.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children checkboxes.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any[]) => void;\n /**\n * Indicates whether the checkbox group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Indicates if an additional select all checkbox should be shown.\n */\n showSelectAll?: boolean;\n /**\n * The label of the select all checkbox. Defaults to \"All\".\n */\n selectAllLabel?: string;\n /**\n * Custom label for select all checkbox conjunction\n */\n selectAllConjunctionLabel?: string;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvCheckBoxGroupClasses;\n}\n\n/**\n * A checkbox group is a type of selection list that allows the user to select multiple options through the use of checkboxes.\n */\nexport const HvCheckBoxGroup = forwardRef<HTMLDivElement, HvCheckBoxGroupProps>(\n function HvCheckBoxGroup(props, ref) {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n label,\n description,\n status,\n statusMessage,\n defaultValue,\n value: valueProp,\n required,\n readOnly,\n disabled,\n showSelectAll,\n orientation = \"vertical\",\n selectAllLabel = \"All\",\n selectAllConjunctionLabel = \"/\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvCheckBoxGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children),\n );\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id);\n\n const selectionAnchor = useRef(undefined);\n\n const [allValues, selectedState, selectedCount] = useMemo(() => {\n const childValues: any[] = [];\n const childSelectedState: boolean[] = [];\n let childSelectedCounter = 0;\n\n Children.toArray(children).forEach((child: any, i: number) => {\n const childValue = child?.props?.value;\n const childIsSelected = value.indexOf(childValue) !== -1;\n\n childValues[i] = childValue;\n childSelectedState[i] = childIsSelected;\n\n if (childIsSelected) {\n childSelectedCounter += 1;\n }\n });\n\n return [childValues, childSelectedState, childSelectedCounter];\n }, [children, value]);\n\n const selectAllState = computeSelectAllState(\n value.length,\n selectedState.length,\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n index: number,\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => {\n const newValue = multiSelectionEventHandler(\n event,\n index,\n selectionAnchor,\n allValues,\n selectedState,\n isChecked,\n );\n\n childOnChange?.(event, isChecked);\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n },\n [\n allValues,\n onChange,\n required,\n selectedState,\n setValidationState,\n setValue,\n ],\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any, i: number) => {\n const childIsSelected = selectedState[i];\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) =>\n onChildChangeInterceptor(\n i,\n child?.props?.onChange,\n event,\n isChecked,\n ),\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n name,\n onChildChangeInterceptor,\n readOnly,\n selectedState,\n ]);\n\n const handleSelectAll = (\n event: React.ChangeEvent<HTMLInputElement>,\n selectAllChecked: boolean,\n ) => {\n let newValue: any[];\n if (selectAllState === \"some\") {\n newValue = [];\n } else if (selectAllChecked) {\n newValue = [...allValues];\n } else {\n newValue = [];\n }\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n };\n\n const selectAllLabelComponent =\n selectedCount === 0 ? (\n <>\n <b>{selectAllLabel}</b>\n {` (${Children.toArray(children).length})`}\n </>\n ) : (\n <>\n <b>{selectedCount}</b>\n {` ${selectAllConjunctionLabel} ${Children.toArray(children).length}`}\n </>\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 errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n showGutter\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <div\n ref={ref}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-disabled={disabled ? true : undefined}\n aria-invalid={validationState === \"invalid\" ? true : undefined}\n aria-errormessage={\n validationState === \"invalid\" ? errorMessageId : undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={cx(classes.group, {\n [classes.vertical]: orientation === \"vertical\",\n [classes.horizontal]: orientation === \"horizontal\",\n [classes.invalid]: validationState === \"invalid\",\n })}\n {...others}\n >\n {showSelectAll && (\n <HvCheckBox\n checked={selectAllState === \"all\"}\n indeterminate={selectAllState === \"some\"}\n label={selectAllLabelComponent}\n disabled={disabled}\n readOnly={readOnly}\n className={classes.selectAll}\n onChange={handleSelectAll}\n />\n )}\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":["HvCheckBoxGroup"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAM,wBAAwB,CAAC,UAAkB,UAAkB;AACjE,MAAI,aAAa,GAAG;AACX,WAAA;AAAA,EAAA;AAGT,MAAI,aAAa,OAAO;AACf,WAAA;AAAA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AA,IAEJ;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"CheckBoxGroup.js","sources":["../../../src/CheckBoxGroup/CheckBoxGroup.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../CheckBox\";\nimport {\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"../FormElement\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { CounterLabel } from \"../utils/CounterLabel\";\nimport { multiSelectionEventHandler } from \"../utils/multiSelectionEventHandler\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./CheckBoxGroup.styles\";\n\nconst computeSelectAllState = (selected: number, total: number) => {\n if (selected === 0) {\n return \"none\";\n }\n\n if (selected === total) {\n return \"all\";\n }\n\n return \"some\";\n};\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const selectedValues = Children.toArray(children)\n .map((child: any) => {\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n return childIsSelected ? child?.props?.value : undefined;\n })\n .filter((v) => v !== undefined);\n\n return selectedValues;\n};\n\nexport { staticClasses as checkBoxGroupClasses };\n\nexport type HvCheckBoxGroupClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvCheckBoxGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children checkboxes, unless they already have one.\n */\n name?: string;\n /**\n * The value of the form element. An array of values represented in the child checkboxes.\n *\n * When defined the checkbox group state becomes controlled.\n */\n value?: any[];\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any[];\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children checkboxes.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children checkboxes.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any[]) => void;\n /**\n * Indicates whether the checkbox group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * Indicates if an additional select all checkbox should be shown.\n */\n showSelectAll?: boolean;\n /**\n * The label of the select all checkbox. Defaults to \"All\". @deprecated no longer used\n */\n selectAllLabel?: string;\n /**\n * Custom label for select all checkbox conjunction\n */\n selectAllConjunctionLabel?: string;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvCheckBoxGroupClasses;\n}\n\n/**\n * A checkbox group is a type of selection list that allows the user to select multiple options through the use of checkboxes.\n */\nexport const HvCheckBoxGroup = forwardRef<HTMLDivElement, HvCheckBoxGroupProps>(\n function HvCheckBoxGroup(props, ref) {\n const {\n id,\n classes: classesProp,\n className,\n children,\n name,\n label,\n description,\n status,\n statusMessage,\n defaultValue,\n value: valueProp,\n required,\n readOnly,\n disabled,\n showSelectAll,\n orientation = \"vertical\",\n selectAllConjunctionLabel = \"/\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvCheckBoxGroup\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children),\n );\n\n const [validationState, setValidationState] = useControlled<HvFormStatus>(\n status,\n \"standBy\",\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id);\n\n const selectionAnchor = useRef(undefined);\n\n const [allValues, selectedState, selectedCount] = useMemo(() => {\n const childValues: any[] = [];\n const childSelectedState: boolean[] = [];\n let childSelectedCounter = 0;\n\n Children.toArray(children).forEach((child: any, i: number) => {\n const childValue = child?.props?.value;\n const childIsSelected = value.indexOf(childValue) !== -1;\n\n childValues[i] = childValue;\n childSelectedState[i] = childIsSelected;\n\n if (childIsSelected) {\n childSelectedCounter += 1;\n }\n });\n\n return [childValues, childSelectedState, childSelectedCounter];\n }, [children, value]);\n\n const selectAllState = computeSelectAllState(\n value.length,\n selectedState.length,\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n index: number,\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) => {\n const newValue = multiSelectionEventHandler(\n event,\n index,\n selectionAnchor,\n allValues,\n selectedState,\n isChecked,\n );\n\n childOnChange?.(event, isChecked);\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\n },\n [\n allValues,\n onChange,\n required,\n selectedState,\n setValidationState,\n setValue,\n ],\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any, i: number) => {\n const childIsSelected = selectedState[i];\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n ) =>\n onChildChangeInterceptor(\n i,\n child?.props?.onChange,\n event,\n isChecked,\n ),\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n name,\n onChildChangeInterceptor,\n readOnly,\n selectedState,\n ]);\n\n const handleSelectAll = (\n event: React.ChangeEvent<HTMLInputElement>,\n selectAllChecked: boolean,\n ) => {\n let newValue: any[];\n if (selectAllState === \"some\") {\n newValue = [];\n } else if (selectAllChecked) {\n newValue = [...allValues];\n } else {\n newValue = [];\n }\n\n onChange?.(event, newValue);\n\n setValue(() => {\n // This will only run if uncontrolled\n if (required && newValue.length === 0) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newValue;\n });\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 errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n showGutter\n id={setId(elementId, \"label\")}\n label={label}\n className={classes.label}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <div\n ref={ref}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-disabled={disabled ? true : undefined}\n aria-invalid={validationState === \"invalid\" ? true : undefined}\n aria-errormessage={\n validationState === \"invalid\" ? errorMessageId : undefined\n }\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={cx(classes.group, {\n [classes.vertical]: orientation === \"vertical\",\n [classes.horizontal]: orientation === \"horizontal\",\n [classes.invalid]: validationState === \"invalid\",\n })}\n {...others}\n >\n {showSelectAll && (\n <HvCheckBox\n checked={selectAllState === \"all\"}\n indeterminate={selectAllState === \"some\"}\n label={\n <CounterLabel\n selected={selectedCount}\n total={Children.count(children)}\n conjunctionLabel={selectAllConjunctionLabel}\n />\n }\n disabled={disabled}\n readOnly={readOnly}\n className={classes.selectAll}\n onChange={handleSelectAll}\n />\n )}\n {modifiedChildren}\n </div>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":["HvCheckBoxGroup"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,wBAAwB,CAAC,UAAkB,UAAkB;AACjE,MAAI,aAAa,GAAG;AACX,WAAA;AAAA,EAAA;AAGT,MAAI,aAAa,OAAO;AACf,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;AAEA,MAAM,+BAA+B,CAAC,aAA8B;AAClE,QAAM,iBAAiB,SAAS,QAAQ,QAAQ,EAC7C,IAAI,CAAC,UAAe;AACb,UAAA,oBAAoB,OAAO,OAAO,YAAY;AACpD,UAAM,kBAAkB,oBACpB,OAAO,OAAO,UACd,OAAO,OAAO;AAEX,WAAA,kBAAkB,OAAO,OAAO,QAAQ;AAAA,EAChD,CAAA,EACA,OAAO,CAAC,MAAM,MAAM,MAAS;AAEzB,SAAA;AACT;AA+FO,MAAM,kBAAkB;AAAA,EAC7B,SAASA,iBAAgB,OAAO,KAAK;AAC7B,UAAA;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MACT;AAAA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AAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,SAAS,mBAAmB;AAAA,oBAC5B,eAAe,mBAAmB;AAAA,oBAClC,OACE;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,UAAU;AAAA,wBACV,OAAO,SAAS,MAAM,QAAQ;AAAA,wBAC9B,kBAAkB;AAAA,sBAAA;AAAA,oBACpB;AAAA,oBAEF;AAAA,oBACA;AAAA,oBACA,WAAW,QAAQ;AAAA,oBACnB,UAAU;AAAA,kBAAA;AAAA,gBACZ;AAAA,gBAED;AAAA,cAAA;AAAA,YAAA;AAAA,UACH;AAAA,UAEC,gBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI,MAAM,WAAW,OAAO;AAAA,cAC5B,eAAa;AAAA,cACb,WAAW,QAAQ;AAAA,cAElB,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useContext, useMemo, useCallback, useEffect } from "react";
|
|
3
|
+
import { CounterLabel } from "../../utils/CounterLabel.js";
|
|
3
4
|
import { setId } from "../../utils/setId.js";
|
|
4
5
|
import { HvFilterGroupContext } from "../FilterGroupContext.js";
|
|
5
6
|
import { useClasses } from "./RightPanel.styles.js";
|
|
6
7
|
import { staticClasses } from "./RightPanel.styles.js";
|
|
7
|
-
import { HvTypography } from "../../Typography/Typography.js";
|
|
8
8
|
import { HvCheckBox } from "../../CheckBox/CheckBox.js";
|
|
9
9
|
import { HvPanel } from "../../Panel/Panel.js";
|
|
10
10
|
import { HvInput } from "../../Input/Input.js";
|
|
@@ -94,19 +94,18 @@ const HvFilterGroupRightPanel = ({
|
|
|
94
94
|
searchStr
|
|
95
95
|
]);
|
|
96
96
|
const SelectAll = useCallback(() => {
|
|
97
|
-
const nbrSelected = activeFilterValues?.length;
|
|
98
|
-
const defaultLabel = /* @__PURE__ */ jsx(HvTypography, { component: "span", children: nbrSelected > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
99
|
-
/* @__PURE__ */ jsx("b", { children: nbrSelected }),
|
|
100
|
-
` ${labels?.multiSelectionConjunction} ${allActiveGroupOptions.length}`
|
|
101
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
102
|
-
/* @__PURE__ */ jsx("b", { children: labels?.selectAll }),
|
|
103
|
-
` (${allActiveGroupOptions.length})`
|
|
104
|
-
] }) });
|
|
105
97
|
return /* @__PURE__ */ jsx("div", { className: classes.selectAllContainer, children: /* @__PURE__ */ jsx(
|
|
106
98
|
HvCheckBox,
|
|
107
99
|
{
|
|
108
100
|
id: setId(id, "select-all"),
|
|
109
|
-
label:
|
|
101
|
+
label: /* @__PURE__ */ jsx(
|
|
102
|
+
CounterLabel,
|
|
103
|
+
{
|
|
104
|
+
selected: activeFilterValues?.length,
|
|
105
|
+
total: allActiveGroupOptions.length,
|
|
106
|
+
conjunctionLabel: labels?.multiSelectionConjunction
|
|
107
|
+
}
|
|
108
|
+
),
|
|
110
109
|
onChange: () => handleSelectAll(),
|
|
111
110
|
className: classes.selectAll,
|
|
112
111
|
indeterminate: anySelected && !allSelected,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RightPanel.js","sources":["../../../../src/FilterGroup/RightPanel/RightPanel.tsx"],"sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../../CheckBox\";\nimport { HvInput } from \"../../Input\";\nimport { HvList, HvListProps } from \"../../List\";\nimport { HvPanel } from \"../../Panel\";\nimport {
|
|
1
|
+
{"version":3,"file":"RightPanel.js","sources":["../../../../src/FilterGroup/RightPanel/RightPanel.tsx"],"sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport { type ExtractNames } from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvCheckBox } from \"../../CheckBox\";\nimport { HvInput } from \"../../Input\";\nimport { HvList, HvListProps } from \"../../List\";\nimport { HvPanel } from \"../../Panel\";\nimport { CounterLabel } from \"../../utils/CounterLabel\";\nimport { setId } from \"../../utils/setId\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { staticClasses, useClasses } from \"./RightPanel.styles\";\n\nexport { staticClasses as filterGroupRightPanelClasses };\n\nexport type HvFilterGroupRightPanelClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupRightPanelProps {\n id?: string;\n className?: string;\n labels?: {\n searchBoxPlaceholder?: string;\n selectAll?: string;\n multiSelectionConjunction?: string;\n };\n emptyElement?: React.ReactNode;\n classes?: HvFilterGroupRightPanelClasses;\n}\n\nexport const HvFilterGroupRightPanel = ({\n id,\n className,\n labels,\n emptyElement,\n classes: classesProp,\n}: HvFilterGroupRightPanelProps) => {\n const { classes } = useClasses(classesProp);\n const [searchStr, setSearchStr] = useState(\"\");\n const [allSelected, setAllSelected] = useState(false);\n const [anySelected, setAnySelected] = useState(false);\n\n const {\n filterOptions,\n filterValues = [],\n setFilterValues,\n activeGroup,\n } = useContext(HvFilterGroupContext);\n\n const { all: allActiveGroupOptions, enabled: enabledActiveGroupOptions } =\n useMemo(() => {\n const filteredOptions = filterOptions[activeGroup]?.data.filter(\n (option) => option.name.toLowerCase().includes(searchStr.toLowerCase()),\n );\n\n return {\n all: filteredOptions?.map((option) => option.id) || [],\n enabled:\n filteredOptions\n ?.filter((option) => !option.disabled)\n ?.map((option) => option.id) || [],\n };\n }, [filterOptions, activeGroup, searchStr]);\n\n const activeFilterValues = useMemo(\n () =>\n filterValues[activeGroup]?.filter((value) =>\n allActiveGroupOptions.includes(value),\n ) || [],\n [filterValues, allActiveGroupOptions, activeGroup],\n );\n\n const listValues = useMemo(\n () =>\n filterOptions[activeGroup]?.data.map((option) => ({\n ...option,\n label: option.name,\n selected: filterValues[activeGroup]?.includes(option.id),\n isHidden:\n option.name.toLowerCase().indexOf(searchStr.toLowerCase()) < 0,\n })) || [],\n [filterOptions, filterValues, activeGroup, searchStr],\n );\n\n const updateSelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === allActiveGroupOptions.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n }, [activeFilterValues, allActiveGroupOptions]);\n\n useEffect(() => {\n updateSelectAll();\n }, [activeFilterValues, updateSelectAll]);\n\n useEffect(() => setSearchStr(\"\"), [activeGroup]);\n\n const onChangeHandler: HvListProps[\"onChange\"] = (values) => {\n const newFilterValues = filterOptions.map((_, i) =>\n activeGroup === i\n ? values.filter((v) => v.selected).map((v) => v.id)\n : [...(filterValues[i] || [])],\n );\n setFilterValues(newFilterValues as any);\n };\n\n const handleSelectAll = useCallback(() => {\n const newFilterValues = structuredClone(filterValues);\n\n if (anySelected) {\n if (searchStr !== \"\") {\n newFilterValues[activeGroup] = filterValues[activeGroup]?.filter(\n (value) => !enabledActiveGroupOptions.includes(value),\n );\n } else {\n newFilterValues[activeGroup] = [];\n }\n } else {\n const currentOptions = newFilterValues[activeGroup] || [];\n newFilterValues[activeGroup] = [\n ...currentOptions,\n ...enabledActiveGroupOptions,\n ];\n }\n\n setFilterValues(newFilterValues);\n }, [\n activeGroup,\n enabledActiveGroupOptions,\n anySelected,\n filterValues,\n setFilterValues,\n searchStr,\n ]);\n\n const SelectAll = useCallback(() => {\n return (\n <div className={classes.selectAllContainer}>\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={\n <CounterLabel\n selected={activeFilterValues?.length}\n total={allActiveGroupOptions.length}\n conjunctionLabel={labels?.multiSelectionConjunction}\n />\n }\n onChange={() => handleSelectAll()}\n className={classes.selectAll}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n );\n }, [\n activeFilterValues?.length,\n allActiveGroupOptions.length,\n allSelected,\n anySelected,\n handleSelectAll,\n id,\n labels,\n classes?.selectAllContainer,\n classes?.selectAll,\n ]);\n\n return (\n <HvPanel id={setId(id, \"rightPanel\")} className={className}>\n {listValues.length > 0 ? (\n <>\n <HvInput\n id={setId(id, \"search\")}\n classes={{\n root: classes.search,\n }}\n type=\"search\"\n placeholder={labels?.searchBoxPlaceholder}\n value={searchStr}\n onChange={(_, str) => setSearchStr(str)}\n />\n <SelectAll />\n <HvList\n key={activeGroup}\n id={setId(id, \"list\")}\n values={listValues}\n className={classes.list}\n multiSelect\n useSelector\n showSelectAll={false}\n onChange={onChangeHandler}\n selectable\n condensed\n hasTooltips\n />\n </>\n ) : (\n emptyElement\n )}\n </HvPanel>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA4BO,MAAM,0BAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AACX,MAAoC;AAClC,QAAM,EAAE,QAAA,IAAY,WAAW,WAAW;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,EAAE;AAC7C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AAE9C,QAAA;AAAA,IACJ;AAAA,IACA,eAAe,CAAC;AAAA,IAChB;AAAA,IACA;AAAA,EAAA,IACE,WAAW,oBAAoB;AAEnC,QAAM,EAAE,KAAK,uBAAuB,SAAS,0BAA0B,IACrE,QAAQ,MAAM;AACZ,UAAM,kBAAkB,cAAc,WAAW,GAAG,KAAK;AAAA,MACvD,CAAC,WAAW,OAAO,KAAK,cAAc,SAAS,UAAU,YAAa,CAAA;AAAA,IACxE;AAEO,WAAA;AAAA,MACL,KAAK,iBAAiB,IAAI,CAAC,WAAW,OAAO,EAAE,KAAK,CAAC;AAAA,MACrD,SACE,iBACI,OAAO,CAAC,WAAW,CAAC,OAAO,QAAQ,GACnC,IAAI,CAAC,WAAW,OAAO,EAAE,KAA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C;AAAA,MAAA;AAAA,QACC,IAAI,MAAM,IAAI,QAAQ;AAAA,QACtB,SAAS;AAAA,UACP,MAAM,QAAQ;AAAA,QAChB;AAAA,QACA,MAAK;AAAA,QACL,aAAa,QAAQ;AAAA,QACrB,OAAO;AAAA,QACP,UAAU,CAAC,GAAG,QAAQ,aAAa,GAAG;AAAA,MAAA;AAAA,IACxC;AAAA,wBACC,WAAU,EAAA;AAAA,IACX;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,IAAI,MAAM,IAAI,MAAM;AAAA,QACpB,QAAQ;AAAA,QACR,WAAW,QAAQ;AAAA,QACnB,aAAW;AAAA,QACX,aAAW;AAAA,QACX,eAAe;AAAA,QACf,UAAU;AAAA,QACV,YAAU;AAAA,QACV,WAAS;AAAA,QACT,aAAW;AAAA,MAAA;AAAA,MAVN;AAAA,IAAA;AAAA,EAWP,EACF,CAAA,IAEA,cAEJ;AAEJ;"}
|
package/dist/esm/Radio/Radio.js
CHANGED
|
@@ -125,6 +125,7 @@ const HvRadio = forwardRef(
|
|
|
125
125
|
/* @__PURE__ */ jsx(
|
|
126
126
|
HvLabel,
|
|
127
127
|
{
|
|
128
|
+
noWrap: true,
|
|
128
129
|
id: setId(elementId, "label"),
|
|
129
130
|
htmlFor: setId(elementId, "input"),
|
|
130
131
|
label,
|
|
@@ -135,7 +136,7 @@ const HvRadio = forwardRef(
|
|
|
135
136
|
]
|
|
136
137
|
}
|
|
137
138
|
) : radio,
|
|
138
|
-
canShowError && /* @__PURE__ */ jsx(HvWarningText, { id: setId(elementId, "error"),
|
|
139
|
+
canShowError && /* @__PURE__ */ jsx(HvWarningText, { id: setId(elementId, "error"), children: statusMessage })
|
|
139
140
|
]
|
|
140
141
|
}
|
|
141
142
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../../src/Radio/Radio.tsx"],"sourcesContent":["import { forwardRef, useCallback, useState } from \"react\";\nimport { RadioProps as MuiRadioProps } from \"@mui/material/Radio\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseRadio } from \"../BaseRadio\";\nimport {\n HvFormElement,\n HvLabel,\n HvLabelProps,\n HvWarningText,\n isInvalid,\n} from \"../FormElement\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Radio.styles\";\n\nexport { staticClasses as radioClasses };\n\nexport type HvRadioClasses = ExtractNames<typeof useClasses>;\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n */\n status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any,\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /** @ignore */\n ref?: MuiRadioProps[\"ref\"];\n /** @ignore */\n component?: MuiRadioProps[\"component\"];\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user **may select just one option** to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = forwardRef<HTMLButtonElement, HvRadioProps>(\n function HvRadio(props, ref) {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value = \"on\",\n required,\n readOnly,\n disabled,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = useDefaultProps(\"HvRadio\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible],\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur],\n );\n\n const [isChecked, setIsChecked] = useControlled(checked, defaultChecked);\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value],\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\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <HvBaseRadio\n ref={ref}\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={cx(classes.radio, {\n [classes.invalidRadio]: isStateInvalid,\n })}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {hasLabel ? (\n <div\n className={cx(classes.container, {\n [classes.disabled]: disabled,\n [classes.focusVisible]: !!(focusVisible && label),\n [classes.invalidContainer]: isStateInvalid,\n [classes.checked]: isChecked,\n [classes.semantic]: semantic,\n })}\n >\n {radio}\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n </div>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")} disableBorder>\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":["HvRadio"],"mappings":";;;;;;;;;;;;;AAqIO,MAAM,UAAU;AAAA,EACrB,SAASA,SAAQ,OAAO,KAAK;AACrB,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA,qBAAqB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACD,gBAAgB,WAAW,KAAK;AAEpC,UAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,UAAA,YAAY,YAAY,EAAE;AAEhC,UAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AAEtD,UAAM,yBAAyB;AAAA,MAC7B,CAAC,QAA+B;AAC9B,wBAAgB,IAAI;AACpB,yBAAiB,GAAG;AAAA,MACtB;AAAA,MACA,CAAC,cAAc;AAAA,IACjB;AAEA,UAAM,iBAAiB;AAAA,MACrB,CAAC,QAA+B;AAC9B,wBAAgB,KAAK;AACrB,iBAAS,GAAG;AAAA,MACd;AAAA,MACA,CAAC,MAAM;AAAA,IACT;AAEA,UAAM,CAAC,WAAW,YAAY,IAAI,cAAc,SAAS,cAAc;AAEvE,UAAM,gBAAgB;AAAA,MACpB,CAAC,KAA0C,eAAwB;AACjE,qBAAa,UAAU;AAEZ,mBAAA,KAAK,YAAY,KAAK;AAAA,MACnC;AAAA,MACA,CAAC,UAAU,cAAc,KAAK;AAAA,IAChC;AAKA,UAAM,eACJ,oBA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gBAAA;AAAA,gBACD;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,IAAI,MAAM,WAAW,OAAO;AAAA,oBAC5B,SAAS,MAAM,WAAW,OAAO;AAAA,oBACjC;AAAA,oBACA,WAAW,QAAQ;AAAA,oBAClB,GAAG;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACN;AAAA,YAAA;AAAA,UAAA,IAGF;AAAA,UAED,gBACE,oBAAA,eAAA,EAAc,IAAI,MAAM,WAAW,OAAO,GAAG,eAAa,MACxD,UACH,cAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../../src/Radio/Radio.tsx"],"sourcesContent":["import { forwardRef, useCallback, useState } from \"react\";\nimport { RadioProps as MuiRadioProps } from \"@mui/material/Radio\";\nimport {\n useDefaultProps,\n type ExtractNames,\n} from \"@hitachivantara/uikit-react-utils\";\n\nimport { HvBaseRadio } from \"../BaseRadio\";\nimport {\n HvFormElement,\n HvLabel,\n HvLabelProps,\n HvWarningText,\n isInvalid,\n} from \"../FormElement\";\nimport { useControlled } from \"../hooks/useControlled\";\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { setId } from \"../utils/setId\";\nimport { staticClasses, useClasses } from \"./Radio.styles\";\n\nexport { staticClasses as radioClasses };\n\nexport type HvRadioClasses = ExtractNames<typeof useClasses>;\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n */\n status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any,\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /** @ignore */\n ref?: MuiRadioProps[\"ref\"];\n /** @ignore */\n component?: MuiRadioProps[\"component\"];\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user **may select just one option** to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = forwardRef<HTMLButtonElement, HvRadioProps>(\n function HvRadio(props, ref) {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value = \"on\",\n required,\n readOnly,\n disabled,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = useDefaultProps(\"HvRadio\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id);\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible],\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur],\n );\n\n const [isChecked, setIsChecked] = useControlled(checked, defaultChecked);\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value],\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\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <HvBaseRadio\n ref={ref}\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={cx(classes.radio, {\n [classes.invalidRadio]: isStateInvalid,\n })}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {hasLabel ? (\n <div\n className={cx(classes.container, {\n [classes.disabled]: disabled,\n [classes.focusVisible]: !!(focusVisible && label),\n [classes.invalidContainer]: isStateInvalid,\n [classes.checked]: isChecked,\n [classes.semantic]: semantic,\n })}\n >\n {radio}\n <HvLabel\n noWrap\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n </div>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")}>\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n },\n);\n"],"names":["HvRadio"],"mappings":";;;;;;;;;;;;;AAqIO,MAAM,UAAU;AAAA,EACrB,SAASA,SAAQ,OAAO,KAAK;AACrB,UAAA;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA,qBAAqB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACD,gBAAgB,WAAW,KAAK;AAEpC,UAAM,EAAE,SAAS,OAAO,WAAW,WAAW;AAExC,UAAA,YAAY,YAAY,EAAE;AAEhC,UAAM,CAAC,cAAc,eAAe,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AAA,IACN;AAIA,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,QAAQ,UAAU;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW,GAAG,QAAQ,MAAM,SAAS;AAAA,QAEpC,UAAA;AAAA,UACC,WAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,QAAQ,WAAW;AAAA,gBAC/B,CAAC,QAAQ,QAAQ,GAAG;AAAA,gBACpB,CAAC,QAAQ,YAAY,GAAG,CAAC,EAAE,gBAAgB;AAAA,gBAC3C,CAAC,QAAQ,gBAAgB,GAAG;AAAA,gBAC5B,CAAC,QAAQ,OAAO,GAAG;AAAA,gBACnB,CAAC,QAAQ,QAAQ,GAAG;AAAA,cAAA,CACrB;AAAA,cAEA,UAAA;AAAA,gBAAA;AAAA,gBACD;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,QAAM;AAAA,oBACN,IAAI,MAAM,WAAW,OAAO;AAAA,oBAC5B,SAAS,MAAM,WAAW,OAAO;AAAA,oBACjC;AAAA,oBACA,WAAW,QAAQ;AAAA,oBAClB,GAAG;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACN;AAAA,YAAA;AAAA,UAAA,IAGF;AAAA,UAED,oCACE,eAAc,EAAA,IAAI,MAAM,WAAW,OAAO,GACxC,UACH,cAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
|
|
@@ -6,50 +6,30 @@ const { staticClasses, useClasses } = createClasses("HvRadio", {
|
|
|
6
6
|
container: {
|
|
7
7
|
cursor: "pointer",
|
|
8
8
|
display: "flex",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"&:hover": {
|
|
15
|
-
backgroundColor: theme.colors.containerBackgroundHover,
|
|
16
|
-
borderRadius: theme.radii.base
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
invalidContainer: {
|
|
20
|
-
borderBottom: `1px solid ${theme.colors.negative_120}`,
|
|
21
|
-
"&:hover": {
|
|
22
|
-
borderBottomLeftRadius: "0px",
|
|
23
|
-
borderBottomRightRadius: "0px"
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
transition: "background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
11
|
+
borderRadius: theme.radii.base,
|
|
12
|
+
":hover:not($disabled)": {
|
|
13
|
+
backgroundColor: theme.colors.containerBackgroundHover
|
|
24
14
|
}
|
|
25
15
|
},
|
|
16
|
+
invalidContainer: {},
|
|
26
17
|
disabled: {
|
|
27
18
|
cursor: "not-allowed",
|
|
28
19
|
"& $label": { color: theme.colors.secondary_60, cursor: "not-allowed" }
|
|
29
20
|
},
|
|
30
21
|
radio: {
|
|
31
|
-
height: "32px",
|
|
32
22
|
"& svg": {
|
|
33
23
|
outline: "none",
|
|
34
24
|
boxShadow: "none"
|
|
35
25
|
}
|
|
36
26
|
},
|
|
37
|
-
invalidRadio: {
|
|
38
|
-
borderBottom: `1px solid ${theme.colors.negative_120}`,
|
|
39
|
-
"&:hover": {
|
|
40
|
-
borderBottomLeftRadius: "0px",
|
|
41
|
-
borderBottomRightRadius: "0px"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
27
|
+
invalidRadio: {},
|
|
44
28
|
label: {
|
|
45
|
-
overflow: "hidden",
|
|
46
|
-
textOverflow: "ellipsis",
|
|
47
29
|
verticalAlign: "middle",
|
|
48
30
|
paddingRight: theme.space.xs,
|
|
49
|
-
whiteSpace: "nowrap",
|
|
50
31
|
...theme.typography.body,
|
|
51
32
|
cursor: "pointer",
|
|
52
|
-
height: "32px",
|
|
53
33
|
lineHeight: "32px",
|
|
54
34
|
width: "100%"
|
|
55
35
|
},
|
|
@@ -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
|
|
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.containerBackgroundHover,\n },\n },\n invalidContainer: {},\n disabled: {\n cursor: \"not-allowed\",\n\n \"& $label\": { color: theme.colors.secondary_60, cursor: \"not-allowed\" },\n },\n radio: {\n \"& svg\": {\n outline: \"none\",\n boxShadow: \"none\",\n },\n },\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: { backgroundColor: theme.colors.atmo3, ...outlineStyles },\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;AAAA,IACL,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,IAAA;AAAA,EAEf;AAAA,EACA,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,EAAE,iBAAiB,MAAM,OAAO,OAAO,GAAG,cAAc;AAAA,EACtE,SAAS,CAAC;AAAA,EACV,UAAU,CAAA;AACZ,CAAC;"}
|
|
@@ -6,8 +6,9 @@ const { staticClasses, useClasses } = createClasses("HvTableCell", {
|
|
|
6
6
|
verticalAlign: "inherit",
|
|
7
7
|
alignContent: "inherit",
|
|
8
8
|
textAlign: "left",
|
|
9
|
+
borderColor: theme.colors.atmo4,
|
|
9
10
|
padding: `calc(${theme.space.xs} - 2px ) ${theme.space.xs} calc(${theme.space.xs} - 3px ) ${theme.spacing(4)}`,
|
|
10
|
-
|
|
11
|
+
borderBottomWidth: 1
|
|
11
12
|
},
|
|
12
13
|
/** Styles applied to the cell when it's in the table head. */
|
|
13
14
|
head: {
|
|
@@ -16,7 +17,6 @@ const { staticClasses, useClasses } = createClasses("HvTableCell", {
|
|
|
16
17
|
alignContent: "start",
|
|
17
18
|
backgroundColor: theme.colors.atmo1,
|
|
18
19
|
borderTop: "1px solid transparent",
|
|
19
|
-
borderBottom: `1px solid ${theme.colors.atmo4}`,
|
|
20
20
|
...theme.typography.label
|
|
21
21
|
},
|
|
22
22
|
/** Styles applied to the cell when it's in the table body. */
|
|
@@ -61,7 +61,7 @@ const { staticClasses, useClasses } = createClasses("HvTableCell", {
|
|
|
61
61
|
padding: 0,
|
|
62
62
|
width: 32,
|
|
63
63
|
maxWidth: 32,
|
|
64
|
-
|
|
64
|
+
borderRightWidth: 1
|
|
65
65
|
},
|
|
66
66
|
/** Styles applied to the component root when its variant is actions */
|
|
67
67
|
variantActions: {
|
|
@@ -69,7 +69,7 @@ const { staticClasses, useClasses } = createClasses("HvTableCell", {
|
|
|
69
69
|
padding: 0,
|
|
70
70
|
width: 32,
|
|
71
71
|
maxWidth: 32,
|
|
72
|
-
|
|
72
|
+
borderLeftWidth: 1
|
|
73
73
|
},
|
|
74
74
|
/** Styles applied to the component root when its variant is expand */
|
|
75
75
|
variantExpand: {
|
|
@@ -84,7 +84,7 @@ const { staticClasses, useClasses } = createClasses("HvTableCell", {
|
|
|
84
84
|
height: 52
|
|
85
85
|
},
|
|
86
86
|
padding: "0, 0, 0, 32px",
|
|
87
|
-
|
|
87
|
+
borderWidth: 0
|
|
88
88
|
},
|
|
89
89
|
/** Styles applied to the cell when its variant is list and the type is head. */
|
|
90
90
|
variantListHead: {
|
|
@@ -122,40 +122,40 @@ const { staticClasses, useClasses } = createClasses("HvTableCell", {
|
|
|
122
122
|
},
|
|
123
123
|
/** Styles applied to the cell when it's part of the last sticky to the left column. */
|
|
124
124
|
stickyColumnMostLeft: {
|
|
125
|
-
|
|
125
|
+
borderRightWidth: 1
|
|
126
126
|
},
|
|
127
127
|
/** Styles applied to the cell when it's part of the first right sticky column. */
|
|
128
128
|
stickyColumnLeastRight: {
|
|
129
|
-
|
|
129
|
+
borderLeftWidth: 1
|
|
130
130
|
},
|
|
131
131
|
/** Styles applied to the cell when it's part of the first column in the group. */
|
|
132
132
|
groupColumnMostLeft: {
|
|
133
|
-
|
|
133
|
+
borderLeftWidth: 1,
|
|
134
134
|
"&:first-of-type": {
|
|
135
|
-
|
|
135
|
+
borderLeftWidth: 0
|
|
136
136
|
}
|
|
137
137
|
},
|
|
138
138
|
/** Styles applied to the cell when it's part of the last column in the group. */
|
|
139
139
|
groupColumnMostRight: {
|
|
140
|
-
|
|
140
|
+
borderRightWidth: 1,
|
|
141
141
|
// due to the ":has()" selector not being supported in browsers,
|
|
142
142
|
// this need to be managed with inline styles
|
|
143
143
|
// To be uncommented when not needed (see comment in src/Table/hooks/useSticky.js)
|
|
144
144
|
// "&:last-child,&:has(+ $stickyColumnLeastRight)": {
|
|
145
145
|
"&:last-child": {
|
|
146
|
-
|
|
146
|
+
borderRightWidth: 0
|
|
147
147
|
},
|
|
148
148
|
"&+:not($stickyColumn)": {
|
|
149
|
-
|
|
149
|
+
borderLeftWidth: 0
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
/** Styles applied to the cell when it's part of a resizable column. */
|
|
153
153
|
resizable: {
|
|
154
|
-
|
|
154
|
+
borderRightWidth: 1
|
|
155
155
|
},
|
|
156
156
|
/** Styles applied to the cell when it's part of a resizing column. */
|
|
157
157
|
resizing: {
|
|
158
|
-
borderRight: `solid
|
|
158
|
+
borderRight: `2px solid ${theme.colors.primary_80}`
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.styles.js","sources":["../../../../src/Table/TableCell/TableCell.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTableCell\", {\n /** Styles applied to the component root class. */\n root: {\n verticalAlign: \"inherit\",\n alignContent: \"inherit\",\n textAlign: \"left\",\n padding: `calc(${theme.space.xs} - 2px ) ${theme.space.xs} calc(${\n theme.space.xs\n } - 3px ) ${theme.spacing(4)}`,\n
|
|
1
|
+
{"version":3,"file":"TableCell.styles.js","sources":["../../../../src/Table/TableCell/TableCell.styles.tsx"],"sourcesContent":["import { createClasses } from \"@hitachivantara/uikit-react-utils\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTableCell\", {\n /** Styles applied to the component root class. */\n root: {\n verticalAlign: \"inherit\",\n alignContent: \"inherit\",\n textAlign: \"left\",\n borderColor: theme.colors.atmo4,\n padding: `calc(${theme.space.xs} - 2px ) ${theme.space.xs} calc(${\n theme.space.xs\n } - 3px ) ${theme.spacing(4)}`,\n borderBottomWidth: 1,\n },\n /** Styles applied to the cell when it's in the table head. */\n head: {\n height: 52,\n verticalAlign: \"top\",\n alignContent: \"start\",\n\n backgroundColor: theme.colors.atmo1,\n borderTop: \"1px solid transparent\",\n ...theme.typography.label,\n },\n /** Styles applied to the cell when it's in the table body. */\n body: {\n minHeight: 32,\n \"td&\": {\n height: 32,\n },\n backgroundColor: \"inherit\",\n\n \"&$sorted\": {\n backgroundColor: theme.alpha(\"primary\", 0.1),\n },\n },\n /** Styles applied to the cell when it's in the table footer. */\n footer: {},\n /** Styles applied to the cell when it's part of a sorted column. */\n sorted: {},\n /** Styles applied to the component root when it is left aligned */\n alignLeft: {\n textAlign: \"left\",\n },\n /** Styles applied to the component root when it is center aligned */\n alignCenter: {\n textAlign: \"center\",\n },\n /** Styles applied to the component root when it is right aligned */\n alignRight: {\n textAlign: \"right\",\n flexDirection: \"row-reverse\",\n },\n /** Styles applied to the component root when it is justified */\n alignJustify: {\n textAlign: \"justify\",\n },\n\n /** Styles applied to the component root when its variant is none */\n variantNone: {\n padding: 0,\n },\n /** Styles applied to the component root when its variant is checkbox */\n variantCheckbox: {\n boxSizing: \"content-box\",\n padding: 0,\n width: 32,\n maxWidth: 32,\n borderRightWidth: 1,\n },\n /** Styles applied to the component root when its variant is actions */\n variantActions: {\n boxSizing: \"content-box\",\n padding: 0,\n width: 32,\n maxWidth: 32,\n borderLeftWidth: 1,\n },\n /** Styles applied to the component root when its variant is expand */\n variantExpand: {\n paddingLeft: 0,\n paddingTop: 0,\n paddingBottom: 0,\n },\n /** Styles applied to the component root when its variant is list */\n variantList: {\n minHeight: 52,\n \"td&\": {\n height: 52,\n },\n padding: \"0, 0, 0, 32px\",\n borderWidth: 0,\n },\n /** Styles applied to the cell when its variant is list and the type is head. */\n variantListHead: {\n backgroundColor: \"inherit\",\n \"td&\": {\n height: 16,\n },\n },\n /** Styles applied to the cell when its variant is list and actions. */\n variantListactions: {\n verticalAlign: \"middle\",\n alignContent: \"center\",\n borderLeft: \"none\",\n paddingLeft: \"0\",\n textAlign: \"center\",\n width: 130,\n maxWidth: 130,\n },\n /** Styles applied to the cell when its variant is list and checkbox. */\n variantListcheckbox: {\n borderRight: \"none\",\n padding: 0,\n textAlign: \"center\",\n width: 34,\n maxWidth: 34,\n },\n /** Styles applied to the cell when it's part of a sticky column. */\n stickyColumn: {\n position: \"sticky\",\n zIndex: 2,\n backgroundColor: theme.colors.atmo2,\n\n \"&$groupColumnMostRight+$stickyColumn\": {\n borderLeft: 0,\n },\n },\n /** Styles applied to the cell when it's part of the last sticky to the left column. */\n stickyColumnMostLeft: {\n borderRightWidth: 1,\n },\n /** Styles applied to the cell when it's part of the first right sticky column. */\n stickyColumnLeastRight: {\n borderLeftWidth: 1,\n },\n\n /** Styles applied to the cell when it's part of the first column in the group. */\n groupColumnMostLeft: {\n borderLeftWidth: 1,\n\n \"&:first-of-type\": {\n borderLeftWidth: 0,\n },\n },\n /** Styles applied to the cell when it's part of the last column in the group. */\n groupColumnMostRight: {\n borderRightWidth: 1,\n\n // due to the \":has()\" selector not being supported in browsers,\n // this need to be managed with inline styles\n // To be uncommented when not needed (see comment in src/Table/hooks/useSticky.js)\n // \"&:last-child,&:has(+ $stickyColumnLeastRight)\": {\n \"&:last-child\": {\n borderRightWidth: 0,\n },\n\n \"&+:not($stickyColumn)\": {\n borderLeftWidth: 0,\n },\n },\n\n /** Styles applied to the cell when it's part of a resizable column. */\n resizable: {\n borderRightWidth: 1,\n },\n /** Styles applied to the cell when it's part of a resizing column. */\n resizing: {\n borderRight: `2px solid ${theme.colors.primary_80}`,\n },\n});\n"],"names":[],"mappings":";;AAGO,MAAM,EAAE,eAAe,eAAe,cAAc,eAAe;AAAA;AAAA,EAExE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AA,IACR,aAAa,aAAa,MAAM,OAAO,UAAU;AAAA,EAAA;AAErD,CAAC;"}
|
|
@@ -9,7 +9,8 @@ const { staticClasses, useClasses } = createClasses("HvTableHeader", {
|
|
|
9
9
|
alignContent: "inherit",
|
|
10
10
|
textAlign: "left",
|
|
11
11
|
padding: theme.spacing(0, 1, 0, 4),
|
|
12
|
-
|
|
12
|
+
borderColor: theme.colors.atmo4,
|
|
13
|
+
borderBottomWidth: 1
|
|
13
14
|
},
|
|
14
15
|
head: {
|
|
15
16
|
paddingTop: 8,
|
|
@@ -17,14 +18,14 @@ const { staticClasses, useClasses } = createClasses("HvTableHeader", {
|
|
|
17
18
|
alignContent: "start",
|
|
18
19
|
...theme.typography.label,
|
|
19
20
|
backgroundColor: theme.colors.atmo1,
|
|
20
|
-
|
|
21
|
+
borderBottomWidth: 1,
|
|
21
22
|
"*:first-of-type > &": {
|
|
22
23
|
height: "var(--first-row-cell-height)",
|
|
23
24
|
borderTop: "1px solid transparent"
|
|
24
25
|
},
|
|
25
26
|
"&$variantList": {
|
|
26
27
|
backgroundColor: "inherit",
|
|
27
|
-
|
|
28
|
+
borderBottomWidth: 0,
|
|
28
29
|
"*:first-of-type > &": {
|
|
29
30
|
borderTop: 0
|
|
30
31
|
}
|
|
@@ -58,23 +59,23 @@ const { staticClasses, useClasses } = createClasses("HvTableHeader", {
|
|
|
58
59
|
position: "sticky",
|
|
59
60
|
zIndex: 2,
|
|
60
61
|
"&$groupColumnMostRight+$stickyColumn": {
|
|
61
|
-
|
|
62
|
+
borderLeftWidth: 0
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
|
-
stickyColumnMostLeft: {
|
|
65
|
-
stickyColumnLeastRight: {
|
|
66
|
-
groupColumnMostLeft: {
|
|
65
|
+
stickyColumnMostLeft: { borderRightWidth: 1 },
|
|
66
|
+
stickyColumnLeastRight: { borderLeftWidth: 1 },
|
|
67
|
+
groupColumnMostLeft: { borderLeftWidth: 1 },
|
|
67
68
|
groupColumnMostRight: {
|
|
68
|
-
|
|
69
|
+
borderRightWidth: 1,
|
|
69
70
|
// due to the ":has()" selector not being supported in browsers,
|
|
70
71
|
// this need to be managed with inline styles
|
|
71
72
|
// To be uncommented when not needed (see comment in src/Table/hooks/useSticky.js)
|
|
72
73
|
// "&:last-child,&:has(+ $stickyColumnLeastRight)": {
|
|
73
74
|
"&:last-child": {
|
|
74
|
-
|
|
75
|
+
borderRightWidth: 0
|
|
75
76
|
},
|
|
76
77
|
"&+:not($stickyColumn)": {
|
|
77
|
-
|
|
78
|
+
borderLeftWidth: 0
|
|
78
79
|
}
|
|
79
80
|
},
|
|
80
81
|
headerContent: { display: "flex", alignItems: "flex-start", width: "100%" },
|
|
@@ -106,27 +107,27 @@ const { staticClasses, useClasses } = createClasses("HvTableHeader", {
|
|
|
106
107
|
padding: 0,
|
|
107
108
|
width: 32,
|
|
108
109
|
maxWidth: 32,
|
|
109
|
-
|
|
110
|
+
borderRightWidth: 1
|
|
110
111
|
},
|
|
111
112
|
variantExpand: {},
|
|
112
113
|
variantActions: {
|
|
113
114
|
padding: 0,
|
|
114
115
|
width: 32,
|
|
115
116
|
maxWidth: 32,
|
|
116
|
-
|
|
117
|
+
borderLeftWidth: 1
|
|
117
118
|
},
|
|
118
119
|
variantNone: { padding: 0 },
|
|
119
120
|
variantList: {
|
|
120
121
|
backgroundColor: "inherit",
|
|
121
|
-
|
|
122
|
+
borderBottomWidth: 0,
|
|
122
123
|
height: 16,
|
|
123
124
|
":first-of-type > &": {
|
|
124
|
-
|
|
125
|
+
borderTopWidth: 0,
|
|
125
126
|
height: 16
|
|
126
127
|
}
|
|
127
128
|
},
|
|
128
129
|
resizable: {
|
|
129
|
-
|
|
130
|
+
borderRightWidth: 1,
|
|
130
131
|
":has($resizer:hover)": {
|
|
131
132
|
borderRight: `2px solid ${theme.colors.primary_80}`
|
|
132
133
|
}
|