cetec-design-system 3.4.0-0 → 3.5.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/dist/panda.buildinfo.json +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9183,7 +9183,7 @@ function useListNavigation(context2, props) {
|
|
|
9183
9183
|
const isCrossCloseKey = isCrossOrientationCloseKey(event.key, orientation, rtl, cols);
|
|
9184
9184
|
const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
|
|
9185
9185
|
const isMainKey = isMainOrientationKey(event.key, orientation);
|
|
9186
|
-
const
|
|
9186
|
+
const isNavigationKey2 = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
|
|
9187
9187
|
if (virtual && open) {
|
|
9188
9188
|
const rootNode = tree == null ? void 0 : tree.nodesRef.current.find((node) => node.parentId == null);
|
|
9189
9189
|
const deepestNode = tree && rootNode ? getDeepestNode(tree.nodesRef.current, rootNode.id) : null;
|
|
@@ -9216,7 +9216,7 @@ function useListNavigation(context2, props) {
|
|
|
9216
9216
|
if (!open && !openOnArrowKeyDown && isArrowKey) {
|
|
9217
9217
|
return;
|
|
9218
9218
|
}
|
|
9219
|
-
if (
|
|
9219
|
+
if (isNavigationKey2) {
|
|
9220
9220
|
const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
|
|
9221
9221
|
keyRef.current = nested && isParentMainKey ? null : event.key;
|
|
9222
9222
|
}
|
|
@@ -23193,6 +23193,8 @@ const isSelectOptionElement = (child) => {
|
|
|
23193
23193
|
const getOptionText = (option) => {
|
|
23194
23194
|
return option.props.label;
|
|
23195
23195
|
};
|
|
23196
|
+
const NAVIGATION_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "Home", "End"]);
|
|
23197
|
+
const isNavigationKey = (event) => NAVIGATION_KEYS.has(event.key) || event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
|
|
23196
23198
|
const getSelectedDisplay = (options, value, multiple, placeholder) => {
|
|
23197
23199
|
if (value === null || value === void 0 || value === "") {
|
|
23198
23200
|
return placeholder;
|
|
@@ -23252,9 +23254,12 @@ const Select = (props) => {
|
|
|
23252
23254
|
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
23253
23255
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
23254
23256
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
23257
|
+
const [hasNavigated, setHasNavigated] = useState(false);
|
|
23258
|
+
const [openedByKeyboard, setOpenedByKeyboard] = useState(false);
|
|
23255
23259
|
const isOpenControlled = controlledOpen !== void 0;
|
|
23256
23260
|
const isOpen = isOpenControlled ? controlledOpen : internalOpen;
|
|
23257
23261
|
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
23262
|
+
const [prevIsOpen, setPrevIsOpen] = useState(isOpen);
|
|
23258
23263
|
const options = useMemo(() => {
|
|
23259
23264
|
return Children.toArray(children).filter(isSelectOptionElement);
|
|
23260
23265
|
}, [children]);
|
|
@@ -23285,10 +23290,15 @@ const Select = (props) => {
|
|
|
23285
23290
|
);
|
|
23286
23291
|
}, [options]);
|
|
23287
23292
|
const initialActiveIndex = selectedIndex >= 0 ? selectedIndex : firstEnabledIndex >= 0 ? firstEnabledIndex : null;
|
|
23288
|
-
|
|
23293
|
+
if (isOpen !== prevIsOpen) {
|
|
23294
|
+
setPrevIsOpen(isOpen);
|
|
23295
|
+
setActiveIndex(isOpen ? initialActiveIndex : null);
|
|
23296
|
+
setHasNavigated(isOpen && openedByKeyboard);
|
|
23297
|
+
setOpenedByKeyboard(false);
|
|
23298
|
+
}
|
|
23299
|
+
const resolvedActiveIndex = isOpen ? activeIndex ?? (hasNavigated ? null : initialActiveIndex) : null;
|
|
23289
23300
|
const activeOptionId = resolvedActiveIndex !== null ? `${triggerId}-option-${resolvedActiveIndex}` : void 0;
|
|
23290
23301
|
const setOpenState = (nextOpen) => {
|
|
23291
|
-
setActiveIndex(nextOpen ? initialActiveIndex : null);
|
|
23292
23302
|
if (!isOpenControlled) {
|
|
23293
23303
|
setInternalOpen(nextOpen);
|
|
23294
23304
|
}
|
|
@@ -23376,6 +23386,7 @@ const Select = (props) => {
|
|
|
23376
23386
|
}
|
|
23377
23387
|
if (!isOpen && (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ")) {
|
|
23378
23388
|
event.preventDefault();
|
|
23389
|
+
setOpenedByKeyboard(true);
|
|
23379
23390
|
setOpenState(true);
|
|
23380
23391
|
}
|
|
23381
23392
|
if (!multiple && hasValue && (event.key === "Backspace" || event.key === "Delete")) {
|
|
@@ -23505,10 +23516,26 @@ const Select = (props) => {
|
|
|
23505
23516
|
density,
|
|
23506
23517
|
className: menuClasses.wrapper,
|
|
23507
23518
|
style: floating.floatingStyles,
|
|
23508
|
-
...getFloatingProps(
|
|
23519
|
+
...getFloatingProps({
|
|
23520
|
+
// floating-ui also reports `onNavigate` while opening, so
|
|
23521
|
+
// only real input on the list counts as the user pointing
|
|
23522
|
+
// at a row. Option events bubble here, and the listbox
|
|
23523
|
+
// itself holds focus after the pointer leaves the options.
|
|
23524
|
+
onKeyDown: (event) => {
|
|
23525
|
+
if (isNavigationKey(event)) {
|
|
23526
|
+
setHasNavigated(true);
|
|
23527
|
+
}
|
|
23528
|
+
},
|
|
23529
|
+
onPointerMove: (event) => {
|
|
23530
|
+
if (event.pointerType !== "touch") {
|
|
23531
|
+
setHasNavigated(true);
|
|
23532
|
+
}
|
|
23533
|
+
}
|
|
23534
|
+
}),
|
|
23509
23535
|
children: options.map((option, index2) => {
|
|
23510
23536
|
const optionLabel = getOptionText(option);
|
|
23511
23537
|
const isSelected = multiple ? selectedValueSet.has(option.props.value) : value === option.props.value;
|
|
23538
|
+
const isPointed = !option.props.disabled && hasNavigated && activeIndex === index2;
|
|
23512
23539
|
return /* @__PURE__ */ jsx(
|
|
23513
23540
|
ListItem,
|
|
23514
23541
|
{
|
|
@@ -23522,7 +23549,7 @@ const Select = (props) => {
|
|
|
23522
23549
|
variant: multiple ? "checkbox" : "default",
|
|
23523
23550
|
label: optionLabel,
|
|
23524
23551
|
description: option.props.description,
|
|
23525
|
-
iconBefore: !multiple ? option.props.iconLeft ?? "check" : option.props.iconLeft,
|
|
23552
|
+
iconBefore: !multiple ? isSelected && isPointed ? "x" : option.props.iconLeft ?? "check" : option.props.iconLeft,
|
|
23526
23553
|
iconBeforeFill: !multiple ? isSelected ? "icon" : option.props.iconLeft ? void 0 : "transparent" : void 0,
|
|
23527
23554
|
iconAfter: option.props.iconRight,
|
|
23528
23555
|
...getItemProps({
|