@lumx/react 4.11.0-next.8 → 4.11.0-next.9

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.
Files changed (3) hide show
  1. package/index.js +33 -20
  2. package/index.js.map +1 -1
  3. package/package.json +3 -3
package/index.js CHANGED
@@ -2434,11 +2434,11 @@ const SelectionChipGroup$1 = (props, {
2434
2434
  const customProps = getChipProps?.(v) || {};
2435
2435
  const chipIsDisabled = customProps.isDisabled || isDisabled;
2436
2436
  const chipName = typeof customProps.children === 'string' ? customProps.children : name;
2437
- const ariaLabel = chipRemoveLabel ? `${chipName} \u2014 ${chipRemoveLabel}` : chipName;
2437
+ const ariaLabel = chipRemoveLabel ? `${chipName} - ${chipRemoveLabel}` : chipName;
2438
2438
  return /*#__PURE__*/jsx(Tooltip, {
2439
2439
  label: !chipIsDisabled ? ariaLabel : undefined,
2440
2440
  children: /*#__PURE__*/jsx(Chip, {
2441
- "aria-label": label,
2441
+ "aria-label": ariaLabel,
2442
2442
  ...customProps,
2443
2443
  size: "s",
2444
2444
  after: /*#__PURE__*/jsx(Icon, {
@@ -6100,6 +6100,12 @@ function useEventCallback(fn) {
6100
6100
  return React__default.useCallback((...args) => ref.current?.(...args), []);
6101
6101
  }
6102
6102
 
6103
+ /** Unref a react ref or element */
6104
+ function unref(maybeElement) {
6105
+ if (maybeElement instanceof HTMLElement) return maybeElement;
6106
+ return maybeElement?.current;
6107
+ }
6108
+
6103
6109
  const useRovingTabIndexContainer = ({
6104
6110
  containerRef,
6105
6111
  itemSelector,
@@ -6110,7 +6116,7 @@ const useRovingTabIndexContainer = ({
6110
6116
  }) => {
6111
6117
  const onItemFocused = useEventCallback(unstableOnItemFocused);
6112
6118
  useIsomorphicLayoutEffect(() => {
6113
- const container = containerRef?.current;
6119
+ const container = unref(containerRef);
6114
6120
  if (!container) {
6115
6121
  return undefined;
6116
6122
  }
@@ -6151,7 +6157,7 @@ const SelectionChipGroup = ({
6151
6157
  chipRemoveLabel,
6152
6158
  ...forwardedProps
6153
6159
  }) => {
6154
- const containerRef = React__default.useRef(null);
6160
+ const [container, setContainer] = React__default.useState(null);
6155
6161
 
6156
6162
  // Store latest values in refs so the event handlers always access current state.
6157
6163
  const valueRef = React__default.useRef(value);
@@ -6159,27 +6165,40 @@ const SelectionChipGroup = ({
6159
6165
  const onChangeRef = React__default.useRef(onChange);
6160
6166
  onChangeRef.current = onChange;
6161
6167
 
6162
- // Attach event listeners
6168
+ // Attach event listeners. Re-runs when the container mounts/unmounts, inputRef or getOptionId change.
6163
6169
  React__default.useEffect(() => {
6164
6170
  return setupSelectionChipGroupEvents({
6165
- getContainer: () => containerRef.current,
6171
+ getContainer: () => container,
6166
6172
  getInput: () => inputRef?.current,
6167
6173
  onChange: newValue => onChangeRef.current?.(newValue),
6168
6174
  getValue: () => valueRef.current,
6169
6175
  getOptionId
6170
6176
  });
6171
- }, [inputRef, getOptionId]);
6177
+ }, [container, inputRef, getOptionId]);
6172
6178
  useRovingTabIndexContainer({
6173
- containerRef,
6179
+ containerRef: container,
6174
6180
  itemSelector: `.${CLASSNAME$1i}`,
6175
6181
  itemDisabledSelector: `.${CLASSNAME$1i}[aria-disabled="true"]`
6176
6182
  });
6177
6183
 
6178
- // Handle renderChip or fallback to getChipProps from props
6179
- const getChipProps = renderChip ? option => {
6180
- const customChip = renderChip(option);
6181
- return isComponentType(Chip)(customChip) && customChip.props || {};
6182
- } : getChipPropsProp;
6184
+ // Merge getChipProps and renderChip: getChipProps provides base props, renderChip overrides them,
6185
+ // and the core JSX template props take final priority (applied in the core component).
6186
+ const getChipProps = option => {
6187
+ const chipProps = getChipPropsProp?.(option) || {};
6188
+ let renderChipProps = {};
6189
+ if (renderChip) {
6190
+ const customChip = renderChip(option);
6191
+ if (isComponentType(Chip)(customChip)) {
6192
+ renderChipProps = customChip.props || {};
6193
+ }
6194
+ }
6195
+ // Filter out undefined values from renderChipProps so they don't override chipProps
6196
+ const definedRenderChipProps = Object.fromEntries(Object.entries(renderChipProps).filter(([, v]) => v !== undefined));
6197
+ return {
6198
+ ...chipProps,
6199
+ ...definedRenderChipProps
6200
+ };
6201
+ };
6183
6202
  return SelectionChipGroup$1({
6184
6203
  ...forwardedProps,
6185
6204
  value,
@@ -6190,7 +6209,7 @@ const SelectionChipGroup = ({
6190
6209
  label,
6191
6210
  chipRemoveLabel,
6192
6211
  getChipProps,
6193
- ref: containerRef
6212
+ ref: setContainer
6194
6213
  }, {
6195
6214
  Chip,
6196
6215
  ChipGroup,
@@ -13549,12 +13568,6 @@ const ImageSlideshow = ({
13549
13568
  });
13550
13569
  };
13551
13570
 
13552
- /** Unref a react ref or element */
13553
- function unref(maybeElement) {
13554
- if (maybeElement instanceof HTMLElement) return maybeElement;
13555
- return maybeElement?.current;
13556
- }
13557
-
13558
13571
  function setupViewTransitionName(elementRef, name) {
13559
13572
  let originalName = null;
13560
13573
  return {