@hitachivantara/uikit-react-core 5.104.1 → 5.105.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.
@@ -22,6 +22,7 @@ const HvFocus = ({
22
22
  const [childFocus, setChildFocus] = React.useState();
23
23
  const [hasRunConfig, setHasRunConfig] = React.useState(false);
24
24
  const { classes, cx } = Focus_styles.useClasses(classesProp);
25
+ const hasFocusVisible = React.useRef(false);
25
26
  const getFocuses = () => {
26
27
  const focuses = rootRef?.current ? Array.from(
27
28
  rootRef.current.getElementsByClassName(
@@ -101,6 +102,7 @@ const HvFocus = ({
101
102
  });
102
103
  };
103
104
  const onFocus = (evt) => {
105
+ hasFocusVisible.current = evt.currentTarget.matches(":focus-visible");
104
106
  addFocusClass(evt);
105
107
  childFocus?.focus?.();
106
108
  onFocusStrategy(evt);
@@ -146,6 +148,23 @@ const HvFocus = ({
146
148
  evt.preventDefault();
147
149
  evt.stopPropagation();
148
150
  }
151
+ if (!hasFocusVisible.current) {
152
+ hasFocusVisible.current = true;
153
+ if (evt.code === "Space" || evt.code === "Enter") {
154
+ focusAndUpdateIndex(
155
+ focuses.current || focuses.first,
156
+ evt.current,
157
+ focusesList
158
+ );
159
+ return;
160
+ }
161
+ if (focuses.current === focuses.first) {
162
+ focuses.previous = void 0;
163
+ focuses.next = void 0;
164
+ focuses.jump = void 0;
165
+ focuses.fall = void 0;
166
+ }
167
+ }
149
168
  const blockedKeys = getEnabledKeys(
150
169
  currentFocusIndex,
151
170
  jump,
@@ -218,6 +237,21 @@ const HvFocus = ({
218
237
  }
219
238
  evt.preventDefault();
220
239
  evt.stopPropagation();
240
+ if (!hasFocusVisible.current) {
241
+ hasFocusVisible.current = true;
242
+ if (evt.code === "Space" || evt.code === "Enter") {
243
+ focusAndUpdateIndex(
244
+ focuses.current || focuses.first,
245
+ evt.current,
246
+ focusesList
247
+ );
248
+ return;
249
+ }
250
+ if (focuses.current === focuses.first) {
251
+ focuses.previous = void 0;
252
+ focuses.next = void 0;
253
+ }
254
+ }
221
255
  switch (evt.code) {
222
256
  case "Space":
223
257
  case "Enter":
@@ -268,6 +302,7 @@ const HvFocus = ({
268
302
  first: focusesList[0],
269
303
  last: focusesList[focusesList.length - 1],
270
304
  previous: focusesList[currentFocus - 1],
305
+ current: focusesList[currentFocus],
271
306
  next: focusesList[currentFocus + 1],
272
307
  fall: focusesList[currentFocus + navigationJump],
273
308
  jump: focusesList[currentFocus - navigationJump]
@@ -154,13 +154,13 @@ const HvList = (props) => {
154
154
  onClick: (evt) => handleSelect(evt, item),
155
155
  startAdornment,
156
156
  endAdornment: item.showNavIcon && /* @__PURE__ */ jsxRuntime.jsx(icons.HvIcon, { name: "CaretRight", className: classes.box, size: "xs" }),
157
+ separator: item.separator,
157
158
  ...otherProps,
158
159
  children: renderSelectItem(item, itemId)
159
160
  },
160
161
  i
161
162
  );
162
163
  };
163
- const renderSeparator = (index) => /* @__PURE__ */ jsxRuntime.jsx("hr", { className: classes.separator }, `separator-${index}`);
164
164
  const filteredList = list.filter((it) => !it.isHidden);
165
165
  const anySelected = list.map((item) => item.selected && !item.disabled).reduce((result, selected) => result || selected, false);
166
166
  const selectedItemIndex = list.findIndex((item) => item.selected);
@@ -216,16 +216,6 @@ const HvList = (props) => {
216
216
  condensed,
217
217
  ariaMultiSelectable
218
218
  ]);
219
- const renderListWithSeparators = () => {
220
- const items = [];
221
- filteredList.forEach((item, i) => {
222
- items.push(renderListItem(item, i));
223
- if (item.separator && i < filteredList.length - 1) {
224
- items.push(renderSeparator(i));
225
- }
226
- });
227
- return items;
228
- };
229
219
  if (filteredList.length === 0) return null;
230
220
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
231
221
  multiSelect && useSelector && showSelectAll && renderSelectAll(),
@@ -240,7 +230,7 @@ const HvList = (props) => {
240
230
  disableGutters: useSelector,
241
231
  "aria-multiselectable": ariaMultiSelectable,
242
232
  ...others,
243
- children: renderListWithSeparators()
233
+ children: filteredList.map((item, i) => renderListItem(item, i))
244
234
  }
245
235
  ) : /* @__PURE__ */ jsxRuntime.jsx(
246
236
  reactWindow.FixedSizeList,
@@ -29,12 +29,6 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvList", {
29
29
  backgroundColor: uikitStyles.theme.colors.bgHover
30
30
  }
31
31
  },
32
- separator: {
33
- height: 1,
34
- backgroundColor: uikitStyles.theme.colors.border,
35
- margin: `${uikitStyles.theme.space.xs} calc(${uikitStyles.theme.space.sm} * -1)`,
36
- border: "none"
37
- },
38
32
  link: {
39
33
  ...uikitStyles.theme.typography.body,
40
34
  textDecoration: "none",
@@ -18,6 +18,7 @@ const HvListItem = React.forwardRef(function HvListItem2(props, ref) {
18
18
  interactive: interactiveProp,
19
19
  condensed: condensedProp,
20
20
  disableGutters: disableGuttersProp,
21
+ separator,
21
22
  startAdornment,
22
23
  endAdornment,
23
24
  onClick,
@@ -110,7 +111,7 @@ const HvListItem = React.forwardRef(function HvListItem2(props, ref) {
110
111
  }
111
112
  )
112
113
  );
113
- return interactive ? /* @__PURE__ */ jsxRuntime.jsx(
114
+ const item = interactive ? /* @__PURE__ */ jsxRuntime.jsx(
114
115
  Focus.HvFocus,
115
116
  {
116
117
  rootRef: topContainerRef,
@@ -124,6 +125,13 @@ const HvListItem = React.forwardRef(function HvListItem2(props, ref) {
124
125
  children: listItem
125
126
  }
126
127
  ) : listItem;
128
+ if (separator) {
129
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
130
+ item,
131
+ /* @__PURE__ */ jsxRuntime.jsx("li", { role: "separator", className: classes.separator, "aria-hidden": "true" })
132
+ ] });
133
+ }
134
+ return item;
127
135
  });
128
136
  exports.listItemClasses = ListItem_styles.staticClasses;
129
137
  exports.HvListItem = HvListItem;
@@ -67,7 +67,18 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvListItem"
67
67
  /** @deprecated use `:has($startAdornment)` instead */
68
68
  withStartAdornment: {},
69
69
  /** @deprecated use `:has($endAdornment)` instead */
70
- withEndAdornment: {}
70
+ withEndAdornment: {},
71
+ separator: {
72
+ height: 1,
73
+ backgroundColor: uikitStyles.theme.colors.border,
74
+ margin: `${uikitStyles.theme.space.xs} calc(${uikitStyles.theme.space.sm} * -1)`,
75
+ border: "none",
76
+ padding: 0,
77
+ listStyleType: "none",
78
+ "&:last-child": {
79
+ display: "none"
80
+ }
81
+ }
71
82
  });
72
83
  exports.staticClasses = staticClasses;
73
84
  exports.useClasses = useClasses;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
- const CheckCircle = require("@phosphor-icons/react/CheckCircle");
6
- const Question = require("@phosphor-icons/react/Question");
7
- const Warning = require("@phosphor-icons/react/Warning");
8
- const WarningDiamond = require("@phosphor-icons/react/WarningDiamond");
5
+ const CheckCircle = require("@phosphor-icons/react/dist/csr/CheckCircle");
6
+ const Question = require("@phosphor-icons/react/dist/csr/Question");
7
+ const Warning = require("@phosphor-icons/react/dist/csr/Warning");
8
+ const WarningDiamond = require("@phosphor-icons/react/dist/csr/WarningDiamond");
9
9
  const uikitReactUtils = require("@hitachivantara/uikit-react-utils");
10
10
  const icons = require("../icons.cjs");
11
11
  const StatusIcon_styles = require("./StatusIcon.styles.cjs");
@@ -1,4 +1,4 @@
1
- import { useState, cloneElement } from "react";
1
+ import { useState, useRef, cloneElement } from "react";
2
2
  import { isBrowser } from "../utils/browser.js";
3
3
  import { isOneOfKeys, isKey } from "../utils/keyboardUtils.js";
4
4
  import { useClasses, staticClasses } from "./Focus.styles.js";
@@ -20,6 +20,7 @@ const HvFocus = ({
20
20
  const [childFocus, setChildFocus] = useState();
21
21
  const [hasRunConfig, setHasRunConfig] = useState(false);
22
22
  const { classes, cx } = useClasses(classesProp);
23
+ const hasFocusVisible = useRef(false);
23
24
  const getFocuses = () => {
24
25
  const focuses = rootRef?.current ? Array.from(
25
26
  rootRef.current.getElementsByClassName(
@@ -99,6 +100,7 @@ const HvFocus = ({
99
100
  });
100
101
  };
101
102
  const onFocus = (evt) => {
103
+ hasFocusVisible.current = evt.currentTarget.matches(":focus-visible");
102
104
  addFocusClass(evt);
103
105
  childFocus?.focus?.();
104
106
  onFocusStrategy(evt);
@@ -144,6 +146,23 @@ const HvFocus = ({
144
146
  evt.preventDefault();
145
147
  evt.stopPropagation();
146
148
  }
149
+ if (!hasFocusVisible.current) {
150
+ hasFocusVisible.current = true;
151
+ if (evt.code === "Space" || evt.code === "Enter") {
152
+ focusAndUpdateIndex(
153
+ focuses.current || focuses.first,
154
+ evt.current,
155
+ focusesList
156
+ );
157
+ return;
158
+ }
159
+ if (focuses.current === focuses.first) {
160
+ focuses.previous = void 0;
161
+ focuses.next = void 0;
162
+ focuses.jump = void 0;
163
+ focuses.fall = void 0;
164
+ }
165
+ }
147
166
  const blockedKeys = getEnabledKeys(
148
167
  currentFocusIndex,
149
168
  jump,
@@ -216,6 +235,21 @@ const HvFocus = ({
216
235
  }
217
236
  evt.preventDefault();
218
237
  evt.stopPropagation();
238
+ if (!hasFocusVisible.current) {
239
+ hasFocusVisible.current = true;
240
+ if (evt.code === "Space" || evt.code === "Enter") {
241
+ focusAndUpdateIndex(
242
+ focuses.current || focuses.first,
243
+ evt.current,
244
+ focusesList
245
+ );
246
+ return;
247
+ }
248
+ if (focuses.current === focuses.first) {
249
+ focuses.previous = void 0;
250
+ focuses.next = void 0;
251
+ }
252
+ }
219
253
  switch (evt.code) {
220
254
  case "Space":
221
255
  case "Enter":
@@ -266,6 +300,7 @@ const HvFocus = ({
266
300
  first: focusesList[0],
267
301
  last: focusesList[focusesList.length - 1],
268
302
  previous: focusesList[currentFocus - 1],
303
+ current: focusesList[currentFocus],
269
304
  next: focusesList[currentFocus + 1],
270
305
  fall: focusesList[currentFocus + navigationJump],
271
306
  jump: focusesList[currentFocus - navigationJump]
@@ -153,13 +153,13 @@ const HvList = (props) => {
153
153
  onClick: (evt) => handleSelect(evt, item),
154
154
  startAdornment,
155
155
  endAdornment: item.showNavIcon && /* @__PURE__ */ jsx(HvIcon, { name: "CaretRight", className: classes.box, size: "xs" }),
156
+ separator: item.separator,
156
157
  ...otherProps,
157
158
  children: renderSelectItem(item, itemId)
158
159
  },
159
160
  i
160
161
  );
161
162
  };
162
- const renderSeparator = (index) => /* @__PURE__ */ jsx("hr", { className: classes.separator }, `separator-${index}`);
163
163
  const filteredList = list.filter((it) => !it.isHidden);
164
164
  const anySelected = list.map((item) => item.selected && !item.disabled).reduce((result, selected) => result || selected, false);
165
165
  const selectedItemIndex = list.findIndex((item) => item.selected);
@@ -215,16 +215,6 @@ const HvList = (props) => {
215
215
  condensed,
216
216
  ariaMultiSelectable
217
217
  ]);
218
- const renderListWithSeparators = () => {
219
- const items = [];
220
- filteredList.forEach((item, i) => {
221
- items.push(renderListItem(item, i));
222
- if (item.separator && i < filteredList.length - 1) {
223
- items.push(renderSeparator(i));
224
- }
225
- });
226
- return items;
227
- };
228
218
  if (filteredList.length === 0) return null;
229
219
  return /* @__PURE__ */ jsxs(Fragment, { children: [
230
220
  multiSelect && useSelector && showSelectAll && renderSelectAll(),
@@ -239,7 +229,7 @@ const HvList = (props) => {
239
229
  disableGutters: useSelector,
240
230
  "aria-multiselectable": ariaMultiSelectable,
241
231
  ...others,
242
- children: renderListWithSeparators()
232
+ children: filteredList.map((item, i) => renderListItem(item, i))
243
233
  }
244
234
  ) : /* @__PURE__ */ jsx(
245
235
  FixedSizeList,
@@ -27,12 +27,6 @@ const { staticClasses, useClasses } = createClasses("HvList", {
27
27
  backgroundColor: theme.colors.bgHover
28
28
  }
29
29
  },
30
- separator: {
31
- height: 1,
32
- backgroundColor: theme.colors.border,
33
- margin: `${theme.space.xs} calc(${theme.space.sm} * -1)`,
34
- border: "none"
35
- },
36
30
  link: {
37
31
  ...theme.typography.body,
38
32
  textDecoration: "none",
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { forwardRef, useContext, useCallback, useMemo, isValidElement, cloneElement } from "react";
3
3
  import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
4
4
  import { useClasses } from "./ListItem.styles.js";
@@ -17,6 +17,7 @@ const HvListItem = forwardRef(function HvListItem2(props, ref) {
17
17
  interactive: interactiveProp,
18
18
  condensed: condensedProp,
19
19
  disableGutters: disableGuttersProp,
20
+ separator,
20
21
  startAdornment,
21
22
  endAdornment,
22
23
  onClick,
@@ -109,7 +110,7 @@ const HvListItem = forwardRef(function HvListItem2(props, ref) {
109
110
  }
110
111
  )
111
112
  );
112
- return interactive ? /* @__PURE__ */ jsx(
113
+ const item = interactive ? /* @__PURE__ */ jsx(
113
114
  HvFocus,
114
115
  {
115
116
  rootRef: topContainerRef,
@@ -123,6 +124,13 @@ const HvListItem = forwardRef(function HvListItem2(props, ref) {
123
124
  children: listItem
124
125
  }
125
126
  ) : listItem;
127
+ if (separator) {
128
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
129
+ item,
130
+ /* @__PURE__ */ jsx("li", { role: "separator", className: classes.separator, "aria-hidden": "true" })
131
+ ] });
132
+ }
133
+ return item;
126
134
  });
127
135
  export {
128
136
  HvListItem,
@@ -65,7 +65,18 @@ const { staticClasses, useClasses } = createClasses("HvListItem", {
65
65
  /** @deprecated use `:has($startAdornment)` instead */
66
66
  withStartAdornment: {},
67
67
  /** @deprecated use `:has($endAdornment)` instead */
68
- withEndAdornment: {}
68
+ withEndAdornment: {},
69
+ separator: {
70
+ height: 1,
71
+ backgroundColor: theme.colors.border,
72
+ margin: `${theme.space.xs} calc(${theme.space.sm} * -1)`,
73
+ border: "none",
74
+ padding: 0,
75
+ listStyleType: "none",
76
+ "&:last-child": {
77
+ display: "none"
78
+ }
79
+ }
69
80
  });
70
81
  export {
71
82
  staticClasses,
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import { CheckCircle } from "@phosphor-icons/react/CheckCircle";
4
- import { Question } from "@phosphor-icons/react/Question";
5
- import { Warning } from "@phosphor-icons/react/Warning";
6
- import { WarningDiamond } from "@phosphor-icons/react/WarningDiamond";
3
+ import { CheckCircle } from "@phosphor-icons/react/dist/csr/CheckCircle";
4
+ import { Question } from "@phosphor-icons/react/dist/csr/Question";
5
+ import { Warning } from "@phosphor-icons/react/dist/csr/Warning";
6
+ import { WarningDiamond } from "@phosphor-icons/react/dist/csr/WarningDiamond";
7
7
  import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-utils";
8
8
  import { HvIcon } from "../icons.js";
9
9
  import { useClasses } from "./StatusIcon.styles.js";
@@ -4516,6 +4516,8 @@ export declare interface HvListItemProps extends HvBaseProps<HTMLLIElement> {
4516
4516
  * If unwanted, the element should be placed directly as a child.
4517
4517
  */
4518
4518
  endAdornment?: React.ReactNode;
4519
+ /** Whether to show a separator after this list item */
4520
+ separator?: boolean;
4519
4521
  /** The value to be set on the 'li' element */
4520
4522
  value?: any;
4521
4523
  /** A Jss Object used to override or extend the styles applied to the component. */
@@ -7646,7 +7648,6 @@ export declare const listClasses: {
7646
7648
  truncate: string;
7647
7649
  item: string;
7648
7650
  itemSelector: string;
7649
- separator: string;
7650
7651
  link: string;
7651
7652
  selectAllSelector: string;
7652
7653
  };
@@ -7667,6 +7668,7 @@ export declare const listItemClasses: {
7667
7668
  endAdornment: string;
7668
7669
  withStartAdornment: string;
7669
7670
  withEndAdornment: string;
7671
+ separator: string;
7670
7672
  };
7671
7673
 
7672
7674
  export declare const loadingClasses: {
@@ -9795,7 +9797,7 @@ declare const useClasses_59: (classesProp?: Partial<Record<"dropdown" | "label"
9795
9797
  readonly cx: (...args: any) => string;
9796
9798
  };
9797
9799
 
9798
- declare const useClasses_6: (classesProp?: Partial<Record<"condensed" | "disabled" | "selected" | "root" | "focus" | "endAdornment" | "startAdornment" | "interactive" | "gutters" | "withStartAdornment" | "withEndAdornment", string>>, addStatic?: boolean) => {
9800
+ declare const useClasses_6: (classesProp?: Partial<Record<"condensed" | "separator" | "disabled" | "selected" | "root" | "focus" | "endAdornment" | "startAdornment" | "interactive" | "gutters" | "withStartAdornment" | "withEndAdornment", string>>, addStatic?: boolean) => {
9799
9801
  readonly classes: {
9800
9802
  root: string;
9801
9803
  focus: string;
@@ -9808,6 +9810,7 @@ declare const useClasses_6: (classesProp?: Partial<Record<"condensed" | "disable
9808
9810
  endAdornment: string;
9809
9811
  withStartAdornment: string;
9810
9812
  withEndAdornment: string;
9813
+ separator: string;
9811
9814
  };
9812
9815
  readonly css: any;
9813
9816
  readonly cx: (...args: any) => string;
@@ -10235,7 +10238,7 @@ declare const useClasses_87: (classesProp?: Partial<Record<"a", string>>, addSta
10235
10238
  readonly cx: (...args: any) => string;
10236
10239
  };
10237
10240
 
10238
- declare const useClasses_88: (classesProp?: Partial<Record<"link" | "separator" | "root" | "item" | "virtualizedRoot" | "selectorRoot" | "selectorContainer" | "box" | "truncate" | "itemSelector" | "selectAllSelector", string>>, addStatic?: boolean) => {
10241
+ declare const useClasses_88: (classesProp?: Partial<Record<"link" | "root" | "item" | "virtualizedRoot" | "selectorRoot" | "selectorContainer" | "box" | "truncate" | "itemSelector" | "selectAllSelector", string>>, addStatic?: boolean) => {
10239
10242
  readonly classes: {
10240
10243
  root: string;
10241
10244
  virtualizedRoot: string;
@@ -10245,7 +10248,6 @@ declare const useClasses_88: (classesProp?: Partial<Record<"link" | "separator"
10245
10248
  truncate: string;
10246
10249
  item: string;
10247
10250
  itemSelector: string;
10248
- separator: string;
10249
10251
  link: string;
10250
10252
  selectAllSelector: string;
10251
10253
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/uikit-react-core",
3
- "version": "5.104.1",
3
+ "version": "5.105.1",
4
4
  "private": false,
5
5
  "author": "Hitachi Vantara UI Kit Team",
6
6
  "description": "UI Kit Core React components.",
@@ -62,7 +62,7 @@
62
62
  "access": "public",
63
63
  "directory": "package"
64
64
  },
65
- "gitHead": "108aeb035cc208aa2603071db6d10135d1501f7e",
65
+ "gitHead": "7beb41faed7988ae23de7802faa1b637504c7c9a",
66
66
  "exports": {
67
67
  ".": {
68
68
  "types": "./dist/types/index.d.ts",