@equinor/eds-core-react 0.18.0 → 0.19.0-dev.20220404

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.
@@ -126,7 +126,7 @@ const button = {
126
126
  focus: {
127
127
  outline: {
128
128
  type: 'outline',
129
- offset: '2px',
129
+ offset: '3px',
130
130
  style: 'dashed',
131
131
  color: outline.color,
132
132
  width: outline.width
@@ -716,7 +716,12 @@ const {
716
716
  default__base: clicboundHeight,
717
717
  compact__standard: compactClickboundHeight
718
718
  },
719
- shape: shape$3
719
+ shape: shape$3,
720
+ interactions: {
721
+ focused: {
722
+ width: focusOutlineWidth$8
723
+ }
724
+ }
720
725
  } = edsTokens.tokens;
721
726
  const primary$6 = mergeDeepRight$1(button, {
722
727
  height: shape$3.icon_button.minHeight,
@@ -756,7 +761,7 @@ const primary$6 = mergeDeepRight$1(button, {
756
761
  },
757
762
  focus: {
758
763
  outline: {
759
- offset: '0px'
764
+ offset: "-".concat(parseInt(focusOutlineWidth$8), "px")
760
765
  }
761
766
  }
762
767
  },
@@ -974,7 +979,12 @@ const Button = /*#__PURE__*/react.forwardRef(function Button(_ref2, ref) {
974
979
 
975
980
  const {
976
981
  typography: typography$g,
977
- colors: colorsToken
982
+ colors: colorsToken,
983
+ interactions: {
984
+ focused: {
985
+ width: focusOutlineWidth$7
986
+ }
987
+ }
978
988
  } = edsTokens.tokens;
979
989
  const {
980
990
  heading,
@@ -1020,7 +1030,7 @@ const link = {
1020
1030
  states: {
1021
1031
  focus: {
1022
1032
  outline: {
1023
- width: '1px',
1033
+ width: focusOutlineWidth$7,
1024
1034
  color: focus$1,
1025
1035
  style: 'dashed',
1026
1036
  type: 'outline',
@@ -3038,6 +3048,11 @@ const {
3038
3048
  comfortable: {
3039
3049
  medium: mediumSpacing
3040
3050
  }
3051
+ },
3052
+ interactions: {
3053
+ focused: {
3054
+ width: focusOutlineWidth$6
3055
+ }
3041
3056
  }
3042
3057
  } = edsTokens.tokens;
3043
3058
  const accordion = {
@@ -3070,7 +3085,7 @@ const accordion = {
3070
3085
  type: 'outline',
3071
3086
  color: focusOutlineColor$6,
3072
3087
  style: 'dashed',
3073
- width: '1px',
3088
+ width: focusOutlineWidth$6,
3074
3089
  offset: '2px'
3075
3090
  }
3076
3091
  },
@@ -3217,7 +3232,11 @@ const {
3217
3232
  chevron: chevronToken
3218
3233
  }
3219
3234
  } = accordion;
3220
- const StyledAccordionHeader = styled__default["default"].div.attrs(_ref => {
3235
+ const StyledAccordionHeader = styled__default["default"].div.withConfig({
3236
+ displayName: "AccordionHeader__StyledAccordionHeader",
3237
+ componentId: "sc-cu2e95-0"
3238
+ })(["margin:0;padding:0;"]);
3239
+ const StyledAccordionHeaderButton = styled__default["default"].button.attrs(_ref => {
3221
3240
  let {
3222
3241
  panelId,
3223
3242
  isExpanded,
@@ -3226,14 +3245,13 @@ const StyledAccordionHeader = styled__default["default"].div.attrs(_ref => {
3226
3245
  return {
3227
3246
  'aria-expanded': isExpanded,
3228
3247
  'aria-controls': panelId,
3229
- role: 'button',
3230
3248
  'aria-disabled': isExpanded && disabled,
3231
3249
  tabIndex: disabled ? -1 : 0,
3232
3250
  disabled
3233
3251
  };
3234
3252
  }).withConfig({
3235
- displayName: "AccordionHeader__StyledAccordionHeader",
3236
- componentId: "sc-cu2e95-0"
3253
+ displayName: "AccordionHeader__StyledAccordionHeaderButton",
3254
+ componentId: "sc-cu2e95-1"
3237
3255
  })(_ref2 => {
3238
3256
  let {
3239
3257
  theme,
@@ -3247,7 +3265,7 @@ const StyledAccordionHeader = styled__default["default"].div.attrs(_ref => {
3247
3265
  },
3248
3266
  border
3249
3267
  } = theme;
3250
- return styled.css(["", " ", " ", " &[data-focus-visible-added]:focus{", "}&:focus-visible{", "}border-top:", ";background:", ";height:", ";margin:0;display:flex;align-items:center;box-sizing:border-box;", " > svg{color:", ";}"], edsUtils.typographyTemplate(header.typography), edsUtils.bordersTemplate(border), edsUtils.spacingsTemplate(header.spacings), edsUtils.outlineTemplate(header.states.focus.outline), edsUtils.outlineTemplate(header.states.focus.outline), parentIndex === 0 ? null : 'none', header.background, header.height, disabled ? styled.css({
3268
+ return styled.css(["", " ", " ", " &[data-focus-visible-added]:focus{", "}&:focus-visible{", "}border-top:", ";width:100%;background:", ";height:", ";margin:0;display:flex;align-items:center;box-sizing:border-box;", " > svg{color:", ";}"], edsUtils.typographyTemplate(header.typography), edsUtils.bordersTemplate(border), edsUtils.spacingsTemplate(header.spacings), edsUtils.outlineTemplate(header.states.focus.outline), edsUtils.outlineTemplate(header.states.focus.outline), parentIndex === 0 ? null : 'none', header.background, header.height, disabled ? styled.css({
3251
3269
  color: header.states.disabled.typography.color,
3252
3270
  cursor: 'not-allowed'
3253
3271
  }) : styled.css({
@@ -3262,7 +3280,7 @@ const StyledAccordionHeader = styled__default["default"].div.attrs(_ref => {
3262
3280
  });
3263
3281
  const StyledIcon$1 = styled__default["default"](Icon$1).withConfig({
3264
3282
  displayName: "AccordionHeader__StyledIcon",
3265
- componentId: "sc-cu2e95-1"
3283
+ componentId: "sc-cu2e95-2"
3266
3284
  })(_ref3 => {
3267
3285
  let {
3268
3286
  chevronPosition
@@ -3340,16 +3358,18 @@ const AccordionHeader = /*#__PURE__*/react.forwardRef(function AccordionHeader(_
3340
3358
  });
3341
3359
  const newChildren = [chevron, headerChildren];
3342
3360
  return /*#__PURE__*/jsxRuntime.jsx(StyledAccordionHeader, {
3343
- isExpanded: isExpanded,
3344
- parentIndex: parentIndex,
3345
3361
  as: headerLevel,
3346
- disabled: disabled,
3347
- ...props,
3348
- panelId: panelId,
3349
- onClick: handleClick,
3350
- onKeyDown: handleKeyDown,
3351
- ref: ref,
3352
- children: chevronPosition === 'left' ? newChildren : newChildren.reverse()
3362
+ children: /*#__PURE__*/jsxRuntime.jsx(StyledAccordionHeaderButton, {
3363
+ isExpanded: isExpanded,
3364
+ parentIndex: parentIndex,
3365
+ disabled: disabled,
3366
+ panelId: panelId,
3367
+ onClick: handleClick,
3368
+ onKeyDown: handleKeyDown,
3369
+ ref: ref,
3370
+ ...props,
3371
+ children: chevronPosition === 'left' ? newChildren : newChildren.reverse()
3372
+ })
3353
3373
  });
3354
3374
  }); // AccordionHeader.displayName = 'EdsAccordionHeader'
3355
3375
 
@@ -3450,6 +3470,11 @@ const {
3450
3470
  comfortable: {
3451
3471
  medium: spacingMedium$7
3452
3472
  }
3473
+ },
3474
+ interactions: {
3475
+ focused: {
3476
+ width: focusOutlineWidth$5
3477
+ }
3453
3478
  }
3454
3479
  } = edsTokens.tokens;
3455
3480
  const token$1 = {
@@ -3463,7 +3488,7 @@ const token$1 = {
3463
3488
  focus: {
3464
3489
  outline: {
3465
3490
  type: 'outline',
3466
- width: '1px',
3491
+ width: focusOutlineWidth$5,
3467
3492
  style: 'dashed',
3468
3493
  color: focusOutlineColor$5
3469
3494
  }
@@ -3510,8 +3535,8 @@ const token$1 = {
3510
3535
  focus: {
3511
3536
  outline: {
3512
3537
  type: 'outline',
3513
- width: '1px',
3514
- offset: '-1px',
3538
+ width: focusOutlineWidth$5,
3539
+ offset: "-".concat(parseInt(focusOutlineWidth$5), "px"),
3515
3540
  style: 'dashed',
3516
3541
  color: focusOutlineColor$5
3517
3542
  }
@@ -4247,10 +4272,11 @@ const Scrim = /*#__PURE__*/react.forwardRef(function Scrim(_ref, ref) {
4247
4272
  isDismissable = false,
4248
4273
  ...rest
4249
4274
  } = _ref;
4275
+ const scrimRef = react.useRef(null);
4276
+ const combinedScrimRef = edsUtils.useCombinedRefs(scrimRef, ref);
4250
4277
  const props = { ...rest,
4251
4278
  open,
4252
- isDismissable,
4253
- ref
4279
+ isDismissable
4254
4280
  };
4255
4281
  edsUtils.useHideBodyScroll(open);
4256
4282
  edsUtils.useGlobalKeyPress('Escape', () => {
@@ -4260,27 +4286,22 @@ const Scrim = /*#__PURE__*/react.forwardRef(function Scrim(_ref, ref) {
4260
4286
  });
4261
4287
 
4262
4288
  const handleMouseClose = event => {
4263
- if (event) {
4289
+ if (event && event.target === scrimRef.current) {
4264
4290
  if (event.type === 'click' && isDismissable && open) {
4265
4291
  onClose && onClose();
4266
4292
  }
4267
4293
  }
4268
4294
  };
4269
4295
 
4270
- const handleContentClick = event => {
4271
- // Avoid event bubbling inside dialog/content inside scrim
4272
- event.stopPropagation();
4273
- };
4274
-
4275
4296
  if (!open) {
4276
4297
  return null;
4277
4298
  }
4278
4299
 
4279
4300
  return /*#__PURE__*/jsxRuntime.jsx(StyledScrim, {
4280
4301
  onClick: handleMouseClose,
4302
+ ref: combinedScrimRef,
4281
4303
  ...props,
4282
4304
  children: /*#__PURE__*/jsxRuntime.jsx(ScrimContent, {
4283
- onClick: handleContentClick,
4284
4305
  children: children
4285
4306
  })
4286
4307
  });
@@ -4866,6 +4887,11 @@ const {
4866
4887
  rounded: {
4867
4888
  borderRadius: borderRadius$4
4868
4889
  }
4890
+ },
4891
+ interactions: {
4892
+ focused: {
4893
+ width: focusOutlineWidth$4
4894
+ }
4869
4895
  }
4870
4896
  } = edsTokens.tokens;
4871
4897
  const enabled$3 = {
@@ -4898,11 +4924,11 @@ const enabled$3 = {
4898
4924
  },
4899
4925
  focus: {
4900
4926
  outline: {
4901
- width: '1px',
4927
+ width: focusOutlineWidth$4,
4902
4928
  color: focusOutlineColor$4,
4903
4929
  style: 'dashed',
4904
4930
  type: 'outline',
4905
- offset: '2px'
4931
+ offset: '3px'
4906
4932
  }
4907
4933
  },
4908
4934
  active: {
@@ -5514,6 +5540,11 @@ const {
5514
5540
  },
5515
5541
  typography: {
5516
5542
  paragraph
5543
+ },
5544
+ interactions: {
5545
+ focused: {
5546
+ width: focusOutlineWidth$3
5547
+ }
5517
5548
  }
5518
5549
  } = edsTokens.tokens;
5519
5550
  const slider = {
@@ -5566,9 +5597,9 @@ const slider = {
5566
5597
  outline: {
5567
5598
  type: 'outline',
5568
5599
  color: focusOutlineColor$3,
5569
- width: '1px',
5600
+ width: focusOutlineWidth$3,
5570
5601
  style: 'dashed',
5571
- offset: '2px'
5602
+ offset: '3px'
5572
5603
  }
5573
5604
  },
5574
5605
  hover: {
@@ -5802,7 +5833,22 @@ const Slider = /*#__PURE__*/react.forwardRef(function Slider(_ref10, ref) {
5802
5833
  ...rest
5803
5834
  } = _ref10;
5804
5835
  const isRangeSlider = Array.isArray(value);
5805
- const [sliderValue, setSliderValue] = react.useState(isRangeSlider ? value : [value]);
5836
+ const parsedValue = isRangeSlider ? value : [value];
5837
+ const [initalValue, setInitalValue] = react.useState(parsedValue);
5838
+ const [sliderValue, setSliderValue] = react.useState(parsedValue);
5839
+ react.useEffect(() => {
5840
+ if (isRangeSlider) {
5841
+ if (value[0] !== initalValue[0] || value[1] !== initalValue[1]) {
5842
+ setInitalValue(value);
5843
+ setSliderValue(value);
5844
+ }
5845
+ } else {
5846
+ if (value !== initalValue[0]) {
5847
+ setInitalValue([value]);
5848
+ setSliderValue([value]);
5849
+ }
5850
+ }
5851
+ }, [value, initalValue, isRangeSlider]);
5806
5852
  const minRange = react.useRef(null);
5807
5853
  const maxRange = react.useRef(null);
5808
5854
 
@@ -5832,7 +5878,7 @@ const Slider = /*#__PURE__*/react.forwardRef(function Slider(_ref10, ref) {
5832
5878
  };
5833
5879
 
5834
5880
  const handleKeyUp = event => {
5835
- if (event.keyCode === 37 || event.keyCode === 39) {
5881
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
5836
5882
  handleCommitedValue(event);
5837
5883
  }
5838
5884
  };
@@ -6092,7 +6138,13 @@ const Tooltip = /*#__PURE__*/react.forwardRef(function Tooltip(_ref, ref) {
6092
6138
  const {
6093
6139
  styles,
6094
6140
  attributes
6095
- } = edsUtils.usePopper(anchorRef.current, popperEl, arrowRef, placement, 14);
6141
+ } = edsUtils.usePopper({
6142
+ anchorEl: anchorRef.current,
6143
+ popperEl,
6144
+ arrowRef,
6145
+ placement,
6146
+ offset: 14
6147
+ });
6096
6148
  const props = {
6097
6149
  open,
6098
6150
  style: { ...styles.popper,
@@ -6424,7 +6476,12 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover(_ref5, ref) {
6424
6476
  const {
6425
6477
  styles,
6426
6478
  attributes
6427
- } = edsUtils.usePopper(storedAnchorEl, popperEl, arrowRef, placement);
6479
+ } = edsUtils.usePopper({
6480
+ anchorEl: storedAnchorEl,
6481
+ popperEl,
6482
+ arrowRef,
6483
+ placement
6484
+ });
6428
6485
  const props = {
6429
6486
  open,
6430
6487
  ...rest,
@@ -7363,6 +7420,7 @@ Breadcrumbs.Breadcrumb.displayName = 'Breadcrumbs.Breadcrumb';
7363
7420
 
7364
7421
  const initalState = {
7365
7422
  focusedIndex: -1,
7423
+ initialFocus: null,
7366
7424
  onClose: null
7367
7425
  };
7368
7426
  const MenuContext = /*#__PURE__*/react.createContext(initalState);
@@ -7373,6 +7431,7 @@ const MenuProvider = _ref => {
7373
7431
  const [state, setState] = react.useState(initalState);
7374
7432
  const {
7375
7433
  focusedIndex,
7434
+ initialFocus,
7376
7435
  onClose
7377
7436
  } = state;
7378
7437
 
@@ -7382,9 +7441,16 @@ const MenuProvider = _ref => {
7382
7441
  }));
7383
7442
  };
7384
7443
 
7444
+ const setInitialFocus = initialFocus => {
7445
+ setState(prevState => ({ ...prevState,
7446
+ initialFocus: initialFocus
7447
+ }));
7448
+ };
7449
+
7385
7450
  const setOnClose = onClose => {
7386
7451
  const onCloseHelper = () => {
7387
7452
  setFocusedIndex(-1);
7453
+ setInitialFocus(null);
7388
7454
  onClose();
7389
7455
  };
7390
7456
 
@@ -7396,6 +7462,8 @@ const MenuProvider = _ref => {
7396
7462
  const value = {
7397
7463
  setFocusedIndex,
7398
7464
  focusedIndex,
7465
+ setInitialFocus,
7466
+ initialFocus,
7399
7467
  setOnClose,
7400
7468
  onClose
7401
7469
  };
@@ -7670,17 +7738,21 @@ function isIndexable(item) {
7670
7738
  const MenuList = /*#__PURE__*/react.forwardRef(function MenuList(_ref, ref) {
7671
7739
  let {
7672
7740
  children,
7673
- focus,
7674
7741
  ...rest
7675
7742
  } = _ref;
7676
7743
  const {
7677
7744
  focusedIndex,
7678
- setFocusedIndex
7745
+ setFocusedIndex,
7746
+ initialFocus
7679
7747
  } = useMenu();
7680
7748
  let index = -1;
7681
7749
  const focusableIndexs = react.useMemo(() => [], []);
7682
7750
  const updatedChildren = react.useMemo(() => react.Children.map(children, child => {
7751
+ if (!child) return child;
7752
+
7683
7753
  if (child.type === MenuSection) {
7754
+ index++;
7755
+ const menuSectionIndex = index;
7684
7756
  const updatedGrandChildren = react.Children.map(child.props.children, grandChild => {
7685
7757
  index++;
7686
7758
  if (isIndexable(grandChild)) focusableIndexs.push(index);
@@ -7688,7 +7760,9 @@ const MenuList = /*#__PURE__*/react.forwardRef(function MenuList(_ref, ref) {
7688
7760
  index
7689
7761
  });
7690
7762
  });
7691
- return /*#__PURE__*/react.cloneElement(child, null, updatedGrandChildren);
7763
+ return /*#__PURE__*/react.cloneElement(child, {
7764
+ index: menuSectionIndex
7765
+ }, updatedGrandChildren);
7692
7766
  } else {
7693
7767
  index++;
7694
7768
  if (isIndexable(child)) focusableIndexs.push(index);
@@ -7700,15 +7774,15 @@ const MenuList = /*#__PURE__*/react.forwardRef(function MenuList(_ref, ref) {
7700
7774
  const firstFocusIndex = focusableIndexs[0];
7701
7775
  const lastFocusIndex = focusableIndexs[focusableIndexs.length - 1];
7702
7776
  react.useEffect(() => {
7703
- if (focus === 'first') {
7777
+ if (initialFocus === 'first') {
7704
7778
  setFocusedIndex(firstFocusIndex);
7705
7779
  }
7706
7780
 
7707
- if (focus === 'last') {
7781
+ if (initialFocus === 'last') {
7708
7782
  setFocusedIndex(lastFocusIndex);
7709
7783
  } // eslint-disable-next-line react-hooks/exhaustive-deps
7710
7784
 
7711
- }, [focus, firstFocusIndex, lastFocusIndex]);
7785
+ }, [initialFocus, firstFocusIndex, lastFocusIndex]);
7712
7786
 
7713
7787
  const handleMenuItemChange = (direction, fallbackIndex) => {
7714
7788
  const i = direction === 'down' ? 1 : -1;
@@ -7769,13 +7843,45 @@ const MenuContainer = /*#__PURE__*/react.forwardRef(function MenuContainer(_ref2
7769
7843
  } = _ref2;
7770
7844
  const {
7771
7845
  setOnClose,
7772
- onClose
7846
+ onClose,
7847
+ setInitialFocus
7773
7848
  } = useMenu();
7774
7849
  react.useEffect(() => {
7775
7850
  if (onClose === null && onCloseCallback) {
7776
7851
  setOnClose(onCloseCallback);
7777
7852
  }
7778
7853
  }, [onClose, onCloseCallback, setOnClose]);
7854
+ react.useEffect(() => {
7855
+ const openWithKey = e => {
7856
+ const {
7857
+ key
7858
+ } = e; //activate menu with arrows according to wai-aria best practices
7859
+
7860
+ if (key === 'ArrowDown' || key === 'ArrowUp') {
7861
+ e.preventDefault();
7862
+ e.stopPropagation();
7863
+ anchorEl.dispatchEvent(new Event('click', {
7864
+ bubbles: true
7865
+ }));
7866
+ }
7867
+
7868
+ switch (key) {
7869
+ case 'Enter':
7870
+ case 'ArrowDown':
7871
+ setInitialFocus('first');
7872
+ break;
7873
+
7874
+ case 'ArrowUp':
7875
+ setInitialFocus('last');
7876
+ break;
7877
+ }
7878
+ };
7879
+
7880
+ if (anchorEl) anchorEl.addEventListener('keydown', openWithKey);
7881
+ return () => {
7882
+ if (anchorEl) anchorEl.removeEventListener('keydown', openWithKey);
7883
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
7884
+ }, [anchorEl]);
7779
7885
  edsUtils.useOutsideClick(containerEl, e => {
7780
7886
  if (open && onClose !== null && !anchorEl.contains(e.target)) {
7781
7887
  onClose();
@@ -7826,7 +7932,12 @@ const Menu$1 = /*#__PURE__*/react.forwardRef(function Menu(_ref3, ref) {
7826
7932
  const {
7827
7933
  styles,
7828
7934
  attributes
7829
- } = edsUtils.usePopper(storedAnchorEl, containerEl, null, placement, 4);
7935
+ } = edsUtils.usePopper({
7936
+ anchorEl: storedAnchorEl,
7937
+ popperEl: containerEl,
7938
+ placement,
7939
+ offset: 4
7940
+ });
7830
7941
  const props = {
7831
7942
  open,
7832
7943
  style: { ...styles.popper,
@@ -8550,6 +8661,11 @@ const {
8550
8661
  clickbounds: {
8551
8662
  default__base: clicboundSize$1,
8552
8663
  compact__standard: compactClickboundSize$1
8664
+ },
8665
+ interactions: {
8666
+ focused: {
8667
+ width: focusOutlineWidth$2
8668
+ }
8553
8669
  }
8554
8670
  } = edsTokens.tokens;
8555
8671
  const checkbox = {
@@ -8575,9 +8691,9 @@ const checkbox = {
8575
8691
  outline: {
8576
8692
  type: 'outline',
8577
8693
  style: 'dashed',
8578
- width: '1px',
8694
+ width: focusOutlineWidth$2,
8579
8695
  color: focusOutlineColor$2,
8580
- offset: '11px'
8696
+ offset: '10px'
8581
8697
  }
8582
8698
  }
8583
8699
  },
@@ -8597,9 +8713,9 @@ const checkbox = {
8597
8713
  outline: {
8598
8714
  type: 'outline',
8599
8715
  style: 'dashed',
8600
- width: '1px',
8716
+ width: focusOutlineWidth$2,
8601
8717
  color: focusOutlineColor$2,
8602
- offset: '3px'
8718
+ offset: '2px'
8603
8719
  }
8604
8720
  }
8605
8721
  }
@@ -9011,6 +9127,11 @@ const {
9011
9127
  clickbounds: {
9012
9128
  default__base: clicboundSize,
9013
9129
  compact__standard: compactClickboundSize
9130
+ },
9131
+ interactions: {
9132
+ focused: {
9133
+ width: focusOutlineWidth$1
9134
+ }
9014
9135
  }
9015
9136
  } = edsTokens.tokens;
9016
9137
  const comfortable$1 = {
@@ -9036,9 +9157,9 @@ const comfortable$1 = {
9036
9157
  outline: {
9037
9158
  type: 'outline',
9038
9159
  style: 'dashed',
9039
- width: '1px',
9160
+ width: focusOutlineWidth$1,
9040
9161
  color: focusOutlineColor$1,
9041
- offset: '11px'
9162
+ offset: '10px'
9042
9163
  }
9043
9164
  }
9044
9165
  },
@@ -9058,9 +9179,9 @@ const comfortable$1 = {
9058
9179
  outline: {
9059
9180
  type: 'outline',
9060
9181
  style: 'dashed',
9061
- width: '1px',
9182
+ width: focusOutlineWidth$1,
9062
9183
  color: focusOutlineColor$1,
9063
- offset: '3px'
9184
+ offset: '2px'
9064
9185
  }
9065
9186
  }
9066
9187
  }
@@ -9441,6 +9562,11 @@ const {
9441
9562
  icon_button: compactIconButton
9442
9563
  }
9443
9564
  }
9565
+ },
9566
+ interactions: {
9567
+ focused: {
9568
+ width: focusOutlineWidth
9569
+ }
9444
9570
  }
9445
9571
  } = edsTokens.tokens;
9446
9572
  const comfortable = {
@@ -9532,7 +9658,7 @@ const comfortable = {
9532
9658
  },
9533
9659
  focus: {
9534
9660
  outline: {
9535
- width: '1px',
9661
+ width: focusOutlineWidth,
9536
9662
  type: 'outline',
9537
9663
  style: 'dashed',
9538
9664
  color: focusOutlineColor
@@ -42,6 +42,11 @@ const {
42
42
  comfortable: {
43
43
  medium: mediumSpacing
44
44
  }
45
+ },
46
+ interactions: {
47
+ focused: {
48
+ width: focusOutlineWidth
49
+ }
45
50
  }
46
51
  } = tokens;
47
52
  const accordion = {
@@ -74,7 +79,7 @@ const accordion = {
74
79
  type: 'outline',
75
80
  color: focusOutlineColor,
76
81
  style: 'dashed',
77
- width: '1px',
82
+ width: focusOutlineWidth,
78
83
  offset: '2px'
79
84
  }
80
85
  },
@@ -12,7 +12,11 @@ const {
12
12
  chevron: chevronToken
13
13
  }
14
14
  } = accordion;
15
- const StyledAccordionHeader = styled.div.attrs(_ref => {
15
+ const StyledAccordionHeader = styled.div.withConfig({
16
+ displayName: "AccordionHeader__StyledAccordionHeader",
17
+ componentId: "sc-cu2e95-0"
18
+ })(["margin:0;padding:0;"]);
19
+ const StyledAccordionHeaderButton = styled.button.attrs(_ref => {
16
20
  let {
17
21
  panelId,
18
22
  isExpanded,
@@ -21,14 +25,13 @@ const StyledAccordionHeader = styled.div.attrs(_ref => {
21
25
  return {
22
26
  'aria-expanded': isExpanded,
23
27
  'aria-controls': panelId,
24
- role: 'button',
25
28
  'aria-disabled': isExpanded && disabled,
26
29
  tabIndex: disabled ? -1 : 0,
27
30
  disabled
28
31
  };
29
32
  }).withConfig({
30
- displayName: "AccordionHeader__StyledAccordionHeader",
31
- componentId: "sc-cu2e95-0"
33
+ displayName: "AccordionHeader__StyledAccordionHeaderButton",
34
+ componentId: "sc-cu2e95-1"
32
35
  })(_ref2 => {
33
36
  let {
34
37
  theme,
@@ -42,7 +45,7 @@ const StyledAccordionHeader = styled.div.attrs(_ref => {
42
45
  },
43
46
  border
44
47
  } = theme;
45
- return css(["", " ", " ", " &[data-focus-visible-added]:focus{", "}&:focus-visible{", "}border-top:", ";background:", ";height:", ";margin:0;display:flex;align-items:center;box-sizing:border-box;", " > svg{color:", ";}"], typographyTemplate(header.typography), bordersTemplate(border), spacingsTemplate(header.spacings), outlineTemplate(header.states.focus.outline), outlineTemplate(header.states.focus.outline), parentIndex === 0 ? null : 'none', header.background, header.height, disabled ? css({
48
+ return css(["", " ", " ", " &[data-focus-visible-added]:focus{", "}&:focus-visible{", "}border-top:", ";width:100%;background:", ";height:", ";margin:0;display:flex;align-items:center;box-sizing:border-box;", " > svg{color:", ";}"], typographyTemplate(header.typography), bordersTemplate(border), spacingsTemplate(header.spacings), outlineTemplate(header.states.focus.outline), outlineTemplate(header.states.focus.outline), parentIndex === 0 ? null : 'none', header.background, header.height, disabled ? css({
46
49
  color: header.states.disabled.typography.color,
47
50
  cursor: 'not-allowed'
48
51
  }) : css({
@@ -57,7 +60,7 @@ const StyledAccordionHeader = styled.div.attrs(_ref => {
57
60
  });
58
61
  const StyledIcon = styled(Icon).withConfig({
59
62
  displayName: "AccordionHeader__StyledIcon",
60
- componentId: "sc-cu2e95-1"
63
+ componentId: "sc-cu2e95-2"
61
64
  })(_ref3 => {
62
65
  let {
63
66
  chevronPosition
@@ -135,16 +138,18 @@ const AccordionHeader = /*#__PURE__*/forwardRef(function AccordionHeader(_ref4,
135
138
  });
136
139
  const newChildren = [chevron, headerChildren];
137
140
  return /*#__PURE__*/jsx(StyledAccordionHeader, {
138
- isExpanded: isExpanded,
139
- parentIndex: parentIndex,
140
141
  as: headerLevel,
141
- disabled: disabled,
142
- ...props,
143
- panelId: panelId,
144
- onClick: handleClick,
145
- onKeyDown: handleKeyDown,
146
- ref: ref,
147
- children: chevronPosition === 'left' ? newChildren : newChildren.reverse()
142
+ children: /*#__PURE__*/jsx(StyledAccordionHeaderButton, {
143
+ isExpanded: isExpanded,
144
+ parentIndex: parentIndex,
145
+ disabled: disabled,
146
+ panelId: panelId,
147
+ onClick: handleClick,
148
+ onKeyDown: handleKeyDown,
149
+ ref: ref,
150
+ ...props,
151
+ children: chevronPosition === 'left' ? newChildren : newChildren.reverse()
152
+ })
148
153
  });
149
154
  }); // AccordionHeader.displayName = 'EdsAccordionHeader'
150
155
 
@@ -92,7 +92,7 @@ const button = {
92
92
  focus: {
93
93
  outline: {
94
94
  type: 'outline',
95
- offset: '2px',
95
+ offset: '3px',
96
96
  style: 'dashed',
97
97
  color: outline.color,
98
98
  width: outline.width
@@ -35,7 +35,12 @@ const {
35
35
  default__base: clicboundHeight,
36
36
  compact__standard: compactClickboundHeight
37
37
  },
38
- shape
38
+ shape,
39
+ interactions: {
40
+ focused: {
41
+ width: focusOutlineWidth
42
+ }
43
+ }
39
44
  } = tokens;
40
45
  const primary = mergeDeepRight(button, {
41
46
  height: shape.icon_button.minHeight,
@@ -75,7 +80,7 @@ const primary = mergeDeepRight(button, {
75
80
  },
76
81
  focus: {
77
82
  outline: {
78
- offset: '0px'
83
+ offset: "-".concat(parseInt(focusOutlineWidth), "px")
79
84
  }
80
85
  }
81
86
  },
@@ -31,6 +31,11 @@ const {
31
31
  clickbounds: {
32
32
  default__base: clicboundSize,
33
33
  compact__standard: compactClickboundSize
34
+ },
35
+ interactions: {
36
+ focused: {
37
+ width: focusOutlineWidth
38
+ }
34
39
  }
35
40
  } = tokens;
36
41
  const checkbox = {
@@ -56,9 +61,9 @@ const checkbox = {
56
61
  outline: {
57
62
  type: 'outline',
58
63
  style: 'dashed',
59
- width: '1px',
64
+ width: focusOutlineWidth,
60
65
  color: focusOutlineColor,
61
- offset: '11px'
66
+ offset: '10px'
62
67
  }
63
68
  }
64
69
  },
@@ -78,9 +83,9 @@ const checkbox = {
78
83
  outline: {
79
84
  type: 'outline',
80
85
  style: 'dashed',
81
- width: '1px',
86
+ width: focusOutlineWidth,
82
87
  color: focusOutlineColor,
83
- offset: '3px'
88
+ offset: '2px'
84
89
  }
85
90
  }
86
91
  }
@@ -56,6 +56,11 @@ const {
56
56
  rounded: {
57
57
  borderRadius
58
58
  }
59
+ },
60
+ interactions: {
61
+ focused: {
62
+ width: focusOutlineWidth
63
+ }
59
64
  }
60
65
  } = tokens$1;
61
66
  const enabled = {
@@ -88,11 +93,11 @@ const enabled = {
88
93
  },
89
94
  focus: {
90
95
  outline: {
91
- width: '1px',
96
+ width: focusOutlineWidth,
92
97
  color: focusOutlineColor,
93
98
  style: 'dashed',
94
99
  type: 'outline',
95
- offset: '2px'
100
+ offset: '3px'
96
101
  }
97
102
  },
98
103
  active: {
@@ -3,6 +3,7 @@ import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  const initalState = {
5
5
  focusedIndex: -1,
6
+ initialFocus: null,
6
7
  onClose: null
7
8
  };
8
9
  const MenuContext = /*#__PURE__*/createContext(initalState);
@@ -13,6 +14,7 @@ const MenuProvider = _ref => {
13
14
  const [state, setState] = useState(initalState);
14
15
  const {
15
16
  focusedIndex,
17
+ initialFocus,
16
18
  onClose
17
19
  } = state;
18
20
 
@@ -22,9 +24,16 @@ const MenuProvider = _ref => {
22
24
  }));
23
25
  };
24
26
 
27
+ const setInitialFocus = initialFocus => {
28
+ setState(prevState => ({ ...prevState,
29
+ initialFocus: initialFocus
30
+ }));
31
+ };
32
+
25
33
  const setOnClose = onClose => {
26
34
  const onCloseHelper = () => {
27
35
  setFocusedIndex(-1);
36
+ setInitialFocus(null);
28
37
  onClose();
29
38
  };
30
39
 
@@ -36,6 +45,8 @@ const MenuProvider = _ref => {
36
45
  const value = {
37
46
  setFocusedIndex,
38
47
  focusedIndex,
48
+ setInitialFocus,
49
+ initialFocus,
39
50
  setOnClose,
40
51
  onClose
41
52
  };
@@ -34,13 +34,45 @@ const MenuContainer = /*#__PURE__*/forwardRef(function MenuContainer(_ref2, ref)
34
34
  } = _ref2;
35
35
  const {
36
36
  setOnClose,
37
- onClose
37
+ onClose,
38
+ setInitialFocus
38
39
  } = useMenu();
39
40
  useEffect(() => {
40
41
  if (onClose === null && onCloseCallback) {
41
42
  setOnClose(onCloseCallback);
42
43
  }
43
44
  }, [onClose, onCloseCallback, setOnClose]);
45
+ useEffect(() => {
46
+ const openWithKey = e => {
47
+ const {
48
+ key
49
+ } = e; //activate menu with arrows according to wai-aria best practices
50
+
51
+ if (key === 'ArrowDown' || key === 'ArrowUp') {
52
+ e.preventDefault();
53
+ e.stopPropagation();
54
+ anchorEl.dispatchEvent(new Event('click', {
55
+ bubbles: true
56
+ }));
57
+ }
58
+
59
+ switch (key) {
60
+ case 'Enter':
61
+ case 'ArrowDown':
62
+ setInitialFocus('first');
63
+ break;
64
+
65
+ case 'ArrowUp':
66
+ setInitialFocus('last');
67
+ break;
68
+ }
69
+ };
70
+
71
+ if (anchorEl) anchorEl.addEventListener('keydown', openWithKey);
72
+ return () => {
73
+ if (anchorEl) anchorEl.removeEventListener('keydown', openWithKey);
74
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
75
+ }, [anchorEl]);
44
76
  useOutsideClick(containerEl, e => {
45
77
  if (open && onClose !== null && !anchorEl.contains(e.target)) {
46
78
  onClose();
@@ -91,7 +123,12 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref3, ref) {
91
123
  const {
92
124
  styles,
93
125
  attributes
94
- } = usePopper(storedAnchorEl, containerEl, null, placement, 4);
126
+ } = usePopper({
127
+ anchorEl: storedAnchorEl,
128
+ popperEl: containerEl,
129
+ placement,
130
+ offset: 4
131
+ });
95
132
  const props = {
96
133
  open,
97
134
  style: { ...styles.popper,
@@ -20,17 +20,21 @@ function isIndexable(item) {
20
20
  const MenuList = /*#__PURE__*/forwardRef(function MenuList(_ref, ref) {
21
21
  let {
22
22
  children,
23
- focus,
24
23
  ...rest
25
24
  } = _ref;
26
25
  const {
27
26
  focusedIndex,
28
- setFocusedIndex
27
+ setFocusedIndex,
28
+ initialFocus
29
29
  } = useMenu();
30
30
  let index = -1;
31
31
  const focusableIndexs = useMemo(() => [], []);
32
32
  const updatedChildren = useMemo(() => Children.map(children, child => {
33
+ if (!child) return child;
34
+
33
35
  if (child.type === MenuSection) {
36
+ index++;
37
+ const menuSectionIndex = index;
34
38
  const updatedGrandChildren = Children.map(child.props.children, grandChild => {
35
39
  index++;
36
40
  if (isIndexable(grandChild)) focusableIndexs.push(index);
@@ -38,7 +42,9 @@ const MenuList = /*#__PURE__*/forwardRef(function MenuList(_ref, ref) {
38
42
  index
39
43
  });
40
44
  });
41
- return /*#__PURE__*/cloneElement(child, null, updatedGrandChildren);
45
+ return /*#__PURE__*/cloneElement(child, {
46
+ index: menuSectionIndex
47
+ }, updatedGrandChildren);
42
48
  } else {
43
49
  index++;
44
50
  if (isIndexable(child)) focusableIndexs.push(index);
@@ -50,15 +56,15 @@ const MenuList = /*#__PURE__*/forwardRef(function MenuList(_ref, ref) {
50
56
  const firstFocusIndex = focusableIndexs[0];
51
57
  const lastFocusIndex = focusableIndexs[focusableIndexs.length - 1];
52
58
  useEffect(() => {
53
- if (focus === 'first') {
59
+ if (initialFocus === 'first') {
54
60
  setFocusedIndex(firstFocusIndex);
55
61
  }
56
62
 
57
- if (focus === 'last') {
63
+ if (initialFocus === 'last') {
58
64
  setFocusedIndex(lastFocusIndex);
59
65
  } // eslint-disable-next-line react-hooks/exhaustive-deps
60
66
 
61
- }, [focus, firstFocusIndex, lastFocusIndex]);
67
+ }, [initialFocus, firstFocusIndex, lastFocusIndex]);
62
68
 
63
69
  const handleMenuItemChange = (direction, fallbackIndex) => {
64
70
  const i = direction === 'down' ? 1 : -1;
@@ -75,7 +75,12 @@ const Popover = /*#__PURE__*/forwardRef(function Popover(_ref5, ref) {
75
75
  const {
76
76
  styles,
77
77
  attributes
78
- } = usePopper(storedAnchorEl, popperEl, arrowRef, placement);
78
+ } = usePopper({
79
+ anchorEl: storedAnchorEl,
80
+ popperEl,
81
+ arrowRef,
82
+ placement
83
+ });
79
84
  const props = {
80
85
  open,
81
86
  ...rest,
@@ -31,6 +31,11 @@ const {
31
31
  clickbounds: {
32
32
  default__base: clicboundSize,
33
33
  compact__standard: compactClickboundSize
34
+ },
35
+ interactions: {
36
+ focused: {
37
+ width: focusOutlineWidth
38
+ }
34
39
  }
35
40
  } = tokens;
36
41
  const comfortable = {
@@ -56,9 +61,9 @@ const comfortable = {
56
61
  outline: {
57
62
  type: 'outline',
58
63
  style: 'dashed',
59
- width: '1px',
64
+ width: focusOutlineWidth,
60
65
  color: focusOutlineColor,
61
- offset: '11px'
66
+ offset: '10px'
62
67
  }
63
68
  }
64
69
  },
@@ -78,9 +83,9 @@ const comfortable = {
78
83
  outline: {
79
84
  type: 'outline',
80
85
  style: 'dashed',
81
- width: '1px',
86
+ width: focusOutlineWidth,
82
87
  color: focusOutlineColor,
83
- offset: '3px'
88
+ offset: '2px'
84
89
  }
85
90
  }
86
91
  }
@@ -1,7 +1,7 @@
1
- import { forwardRef } from 'react';
1
+ import { forwardRef, useRef } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { scrim } from './Scrim.tokens.js';
4
- import { useHideBodyScroll, useGlobalKeyPress } from '@equinor/eds-utils';
4
+ import { useCombinedRefs, useHideBodyScroll, useGlobalKeyPress } from '@equinor/eds-utils';
5
5
  import { jsx } from 'react/jsx-runtime';
6
6
 
7
7
  const {
@@ -25,10 +25,11 @@ const Scrim = /*#__PURE__*/forwardRef(function Scrim(_ref, ref) {
25
25
  isDismissable = false,
26
26
  ...rest
27
27
  } = _ref;
28
+ const scrimRef = useRef(null);
29
+ const combinedScrimRef = useCombinedRefs(scrimRef, ref);
28
30
  const props = { ...rest,
29
31
  open,
30
- isDismissable,
31
- ref
32
+ isDismissable
32
33
  };
33
34
  useHideBodyScroll(open);
34
35
  useGlobalKeyPress('Escape', () => {
@@ -38,27 +39,22 @@ const Scrim = /*#__PURE__*/forwardRef(function Scrim(_ref, ref) {
38
39
  });
39
40
 
40
41
  const handleMouseClose = event => {
41
- if (event) {
42
+ if (event && event.target === scrimRef.current) {
42
43
  if (event.type === 'click' && isDismissable && open) {
43
44
  onClose && onClose();
44
45
  }
45
46
  }
46
47
  };
47
48
 
48
- const handleContentClick = event => {
49
- // Avoid event bubbling inside dialog/content inside scrim
50
- event.stopPropagation();
51
- };
52
-
53
49
  if (!open) {
54
50
  return null;
55
51
  }
56
52
 
57
53
  return /*#__PURE__*/jsx(StyledScrim, {
58
54
  onClick: handleMouseClose,
55
+ ref: combinedScrimRef,
59
56
  ...props,
60
57
  children: /*#__PURE__*/jsx(ScrimContent, {
61
- onClick: handleContentClick,
62
58
  children: children
63
59
  })
64
60
  });
@@ -1,4 +1,4 @@
1
- import { forwardRef, useState, useRef } from 'react';
1
+ import { forwardRef, useState, useEffect, useRef } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { slider } from './Slider.tokens.js';
4
4
  import { MinMax } from './MinMax.js';
@@ -101,7 +101,22 @@ const Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
101
101
  ...rest
102
102
  } = _ref10;
103
103
  const isRangeSlider = Array.isArray(value);
104
- const [sliderValue, setSliderValue] = useState(isRangeSlider ? value : [value]);
104
+ const parsedValue = isRangeSlider ? value : [value];
105
+ const [initalValue, setInitalValue] = useState(parsedValue);
106
+ const [sliderValue, setSliderValue] = useState(parsedValue);
107
+ useEffect(() => {
108
+ if (isRangeSlider) {
109
+ if (value[0] !== initalValue[0] || value[1] !== initalValue[1]) {
110
+ setInitalValue(value);
111
+ setSliderValue(value);
112
+ }
113
+ } else {
114
+ if (value !== initalValue[0]) {
115
+ setInitalValue([value]);
116
+ setSliderValue([value]);
117
+ }
118
+ }
119
+ }, [value, initalValue, isRangeSlider]);
105
120
  const minRange = useRef(null);
106
121
  const maxRange = useRef(null);
107
122
 
@@ -131,7 +146,7 @@ const Slider = /*#__PURE__*/forwardRef(function Slider(_ref10, ref) {
131
146
  };
132
147
 
133
148
  const handleKeyUp = event => {
134
- if (event.keyCode === 37 || event.keyCode === 39) {
149
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
135
150
  handleCommitedValue(event);
136
151
  }
137
152
  };
@@ -41,6 +41,11 @@ const {
41
41
  },
42
42
  typography: {
43
43
  paragraph
44
+ },
45
+ interactions: {
46
+ focused: {
47
+ width: focusOutlineWidth
48
+ }
44
49
  }
45
50
  } = tokens;
46
51
  const slider = {
@@ -93,9 +98,9 @@ const slider = {
93
98
  outline: {
94
99
  type: 'outline',
95
100
  color: focusOutlineColor,
96
- width: '1px',
101
+ width: focusOutlineWidth,
97
102
  style: 'dashed',
98
- offset: '2px'
103
+ offset: '3px'
99
104
  }
100
105
  },
101
106
  hover: {
@@ -57,6 +57,11 @@ const {
57
57
  icon_button: compactIconButton
58
58
  }
59
59
  }
60
+ },
61
+ interactions: {
62
+ focused: {
63
+ width: focusOutlineWidth
64
+ }
60
65
  }
61
66
  } = tokens;
62
67
  const comfortable = {
@@ -148,7 +153,7 @@ const comfortable = {
148
153
  },
149
154
  focus: {
150
155
  outline: {
151
- width: '1px',
156
+ width: focusOutlineWidth,
152
157
  type: 'outline',
153
158
  style: 'dashed',
154
159
  color: focusOutlineColor
@@ -34,6 +34,11 @@ const {
34
34
  comfortable: {
35
35
  medium: spacingMedium
36
36
  }
37
+ },
38
+ interactions: {
39
+ focused: {
40
+ width: focusOutlineWidth
41
+ }
37
42
  }
38
43
  } = tokens;
39
44
  const token = {
@@ -47,7 +52,7 @@ const token = {
47
52
  focus: {
48
53
  outline: {
49
54
  type: 'outline',
50
- width: '1px',
55
+ width: focusOutlineWidth,
51
56
  style: 'dashed',
52
57
  color: focusOutlineColor
53
58
  }
@@ -94,8 +99,8 @@ const token = {
94
99
  focus: {
95
100
  outline: {
96
101
  type: 'outline',
97
- width: '1px',
98
- offset: '-1px',
102
+ width: focusOutlineWidth,
103
+ offset: "-".concat(parseInt(focusOutlineWidth), "px"),
99
104
  style: 'dashed',
100
105
  color: focusOutlineColor
101
106
  }
@@ -68,7 +68,13 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(_ref, ref) {
68
68
  const {
69
69
  styles,
70
70
  attributes
71
- } = usePopper(anchorRef.current, popperEl, arrowRef, placement, 14);
71
+ } = usePopper({
72
+ anchorEl: anchorRef.current,
73
+ popperEl,
74
+ arrowRef,
75
+ placement,
76
+ offset: 14
77
+ });
72
78
  const props = {
73
79
  open,
74
80
  style: { ...styles.popper,
@@ -2,7 +2,12 @@ import { tokens } from '@equinor/eds-tokens';
2
2
 
3
3
  const {
4
4
  typography,
5
- colors: colorsToken
5
+ colors: colorsToken,
6
+ interactions: {
7
+ focused: {
8
+ width: focusOutlineWidth
9
+ }
10
+ }
6
11
  } = tokens;
7
12
  const {
8
13
  heading,
@@ -48,7 +53,7 @@ const link = {
48
53
  states: {
49
54
  focus: {
50
55
  outline: {
51
- width: '1px',
56
+ width: focusOutlineWidth,
52
57
  color: focus,
53
58
  style: 'dashed',
54
59
  type: 'outline',
@@ -15,7 +15,7 @@ export declare type AccordionHeaderProps = {
15
15
  toggleExpanded?: () => void;
16
16
  /** Accordion item toggle callback */
17
17
  onToggle?: () => void;
18
- } & AccordionProps & HTMLAttributes<HTMLDivElement>;
18
+ } & AccordionProps & HTMLAttributes<HTMLButtonElement>;
19
19
  declare const AccordionHeader: import("react").ForwardRefExoticComponent<{
20
20
  /** The id of the button that toggles expansion */
21
21
  id?: string;
@@ -31,5 +31,5 @@ declare const AccordionHeader: import("react").ForwardRefExoticComponent<{
31
31
  toggleExpanded?: () => void;
32
32
  /** Accordion item toggle callback */
33
33
  onToggle?: () => void;
34
- } & AccordionProps & HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
34
+ } & AccordionProps & HTMLAttributes<HTMLButtonElement> & import("react").RefAttributes<HTMLButtonElement>>;
35
35
  export { AccordionHeader };
@@ -1,10 +1,13 @@
1
1
  import { ReactNode, MouseEvent } from 'react';
2
+ import type { FocusTarget } from './Menu.types';
2
3
  export declare type State = {
3
4
  focusedIndex: number;
5
+ initialFocus: FocusTarget;
4
6
  onClose: (e?: MouseEvent) => void;
5
7
  };
6
8
  declare type UseMenu<T> = T & {
7
9
  setFocusedIndex: (index: number) => void;
10
+ setInitialFocus: (initialFocus: FocusTarget) => void;
8
11
  setOnClose: (onClose: (e?: MouseEvent) => void) => void;
9
12
  };
10
13
  declare type ProviderProps = {
@@ -1,13 +1,10 @@
1
1
  import { HTMLAttributes } from 'react';
2
2
  import { Placement } from '@equinor/eds-utils';
3
- import type { FocusTarget } from './Menu.types';
4
3
  export declare type MenuProps = {
5
4
  /** Anchor element for Menu */
6
5
  anchorEl?: HTMLElement | null;
7
6
  /** Is Menu open */
8
7
  open: boolean;
9
- /** Which Menu child to focus when open */
10
- focus?: FocusTarget;
11
8
  /** onClose handler */
12
9
  onClose?: () => void;
13
10
  /** Menu placement relative to anchorEl */
@@ -18,8 +15,6 @@ export declare const Menu: import("react").ForwardRefExoticComponent<{
18
15
  anchorEl?: HTMLElement | null;
19
16
  /** Is Menu open */
20
17
  open: boolean;
21
- /** Which Menu child to focus when open */
22
- focus?: FocusTarget;
23
18
  /** onClose handler */
24
19
  onClose?: () => void;
25
20
  /** Menu placement relative to anchorEl */
@@ -1,7 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import type { FocusTarget } from './Menu.types';
3
2
  declare type MenuListProps = {
4
- focus?: FocusTarget;
5
3
  children: ReactNode;
6
4
  };
7
5
  export declare const MenuList: import("react").ForwardRefExoticComponent<MenuListProps & import("react").RefAttributes<HTMLDivElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-core-react",
3
- "version": "0.18.0",
3
+ "version": "0.19.0-dev.20220404",
4
4
  "description": "The React implementation of the Equinor Design System",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -72,7 +72,7 @@
72
72
  "rollup-plugin-postcss": "^4.0.2",
73
73
  "styled-components": "5.3.0",
74
74
  "tsc-watch": "^4.6.0",
75
- "typescript": "^4.5.5"
75
+ "typescript": "^4.6.3"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "react": ">=16.8",
@@ -83,7 +83,7 @@
83
83
  "@babel/runtime": "^7.17.0",
84
84
  "@equinor/eds-icons": "0.10.0",
85
85
  "@equinor/eds-tokens": "0.7.0",
86
- "@equinor/eds-utils": "0.1.0",
86
+ "@equinor/eds-utils": "0.2.0",
87
87
  "@popperjs/core": "2.9.2",
88
88
  "downshift": "^6.1.7",
89
89
  "react-fast-compare": "3.2.0",