@royaloperahouse/harmonic 1.0.1-e → 1.0.1-g

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.
@@ -6857,12 +6857,15 @@ var CastFilters = function CastFilters(_ref) {
6857
6857
  listRoleDescription = _ref.listRoleDescription,
6858
6858
  className = _ref.className,
6859
6859
  onSelect = _ref.onSelect,
6860
+ onSelectId = _ref.onSelectId,
6860
6861
  onApply = _ref.onApply,
6862
+ onApplyIds = _ref.onApplyIds,
6861
6863
  onClear = _ref.onClear,
6862
6864
  _ref$greyscale = _ref.greyscale,
6863
6865
  greyscale = _ref$greyscale === void 0 ? false : _ref$greyscale,
6864
6866
  _ref$selectedIndices = _ref.selectedIndices,
6865
- selectedIndices = _ref$selectedIndices === void 0 ? [] : _ref$selectedIndices;
6867
+ selectedIndices = _ref$selectedIndices === void 0 ? [] : _ref$selectedIndices,
6868
+ selectedIds = _ref.selectedIds;
6866
6869
  var _useViewport = useViewport(),
6867
6870
  isMobile = _useViewport.isMobile;
6868
6871
  var castWrapperRef = useRef(null);
@@ -6964,15 +6967,51 @@ var CastFilters = function CastFilters(_ref) {
6964
6967
  isDraggingRef.current = false;
6965
6968
  hasDraggedRef.current = false;
6966
6969
  }, [isMobile]);
6967
- var handleClick = React__default.useCallback(function (index, onClick) {
6970
+ var getCastItemSelectionId = useCallback(function (person) {
6971
+ if (person.id !== undefined && person.id !== null) return String(person.id);
6972
+ if (person.slug !== undefined && person.slug !== null) return String(person.slug);
6973
+ return person.name;
6974
+ }, []);
6975
+ var isIdSelectionMode = selectedIds !== undefined;
6976
+ var selectedIdsSet = useMemo(function () {
6977
+ var ids = selectedIds != null ? selectedIds : [];
6978
+ return new Set(ids.map(function (id) {
6979
+ return String(id);
6980
+ }));
6981
+ }, [selectedIds]);
6982
+ var selectedStateIndices = useMemo(function () {
6983
+ if (!isIdSelectionMode) return selectedIndices;
6984
+ return cast.flatMap(function (person, index) {
6985
+ var itemId = getCastItemSelectionId(person);
6986
+ return selectedIdsSet.has(itemId) ? [index] : [];
6987
+ });
6988
+ }, [cast, getCastItemSelectionId, isIdSelectionMode, selectedIdsSet, selectedIndices]);
6989
+ var selectedStateIds = useMemo(function () {
6990
+ if (isIdSelectionMode) {
6991
+ return cast.filter(function (person) {
6992
+ return selectedIdsSet.has(getCastItemSelectionId(person));
6993
+ }).map(function (person) {
6994
+ return getCastItemSelectionId(person);
6995
+ });
6996
+ }
6997
+ return selectedIndices.map(function (index) {
6998
+ return cast[index];
6999
+ }).filter(function (person) {
7000
+ return person !== undefined;
7001
+ }).map(function (person) {
7002
+ return getCastItemSelectionId(person);
7003
+ });
7004
+ }, [cast, getCastItemSelectionId, isIdSelectionMode, selectedIdsSet, selectedIndices]);
7005
+ var handleClick = React__default.useCallback(function (index, itemId, onClick) {
6968
7006
  if (hasDraggedRef.current) return;
7007
+ if (onSelectId) onSelectId(itemId);
6969
7008
  if (onSelect) onSelect(index);
6970
7009
  if (onClick) onClick();
6971
- }, [onSelect]);
6972
- var handlePersonKeydown = React__default.useCallback(function (e, index, onClick) {
7010
+ }, [onSelect, onSelectId]);
7011
+ var handlePersonKeydown = React__default.useCallback(function (e, index, itemId, onClick) {
6973
7012
  if (e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar') {
6974
7013
  e.preventDefault();
6975
- handleClick(index, onClick);
7014
+ handleClick(index, itemId, onClick);
6976
7015
  }
6977
7016
  }, [handleClick]);
6978
7017
  var handleClearKeydown = React__default.useCallback(function (e) {
@@ -6987,21 +7026,20 @@ var CastFilters = function CastFilters(_ref) {
6987
7026
  image = person.image,
6988
7027
  _onClick = person.onClick,
6989
7028
  ariaLabel = person['aria-label'];
6990
- var isSelected = selectedIndices.includes(index);
7029
+ var personSelectionId = getCastItemSelectionId(person);
7030
+ var isSelected = isIdSelectionMode ? selectedIdsSet.has(personSelectionId) : selectedIndices.includes(index);
6991
7031
  var personImage = image || placeholderImage || defaultPlaceholderImage;
6992
7032
  return /*#__PURE__*/React__default.createElement(PersonWrapper, {
6993
- key: index,
7033
+ key: personSelectionId,
6994
7034
  "aria-selected": isSelected,
6995
- "aria-label": ariaLabel || (isSelected ? 'Deselect' : 'Select') + " " + name,
6996
- "aria-posinset": index + 1,
6997
- "aria-setsize": cast.length,
7035
+ "aria-label": ariaLabel != null ? ariaLabel : name,
6998
7036
  role: "option",
6999
7037
  tabIndex: 0,
7000
7038
  onClick: function onClick() {
7001
- return handleClick(index, _onClick);
7039
+ return handleClick(index, personSelectionId, _onClick);
7002
7040
  },
7003
7041
  onKeyDown: function onKeyDown(e) {
7004
- return handlePersonKeydown(e, index, _onClick);
7042
+ return handlePersonKeydown(e, index, personSelectionId, _onClick);
7005
7043
  }
7006
7044
  }, /*#__PURE__*/React__default.createElement(PersonToggle, {
7007
7045
  isSelected: isSelected
@@ -7043,7 +7081,8 @@ var CastFilters = function CastFilters(_ref) {
7043
7081
  ref: castWrapperRef,
7044
7082
  role: "listbox",
7045
7083
  "aria-roledescription": listRoleDescription != null ? listRoleDescription : 'filter list',
7046
- "aria-multiselectable": true,
7084
+ "aria-label": "filter list",
7085
+ "aria-multiselectable": "true",
7047
7086
  onMouseDown: handleMouseDown,
7048
7087
  onMouseMove: handleMouseMove,
7049
7088
  onMouseUp: handleMouseUp,
@@ -7054,14 +7093,15 @@ var CastFilters = function CastFilters(_ref) {
7054
7093
  ref: swipeRef,
7055
7094
  onOverflowChange: handleOverflowChange,
7056
7095
  limitDragToNavigableRange: true
7057
- }, getPersonCards())))), showActionButtonsSection && (/*#__PURE__*/React__default.createElement(ActionButtons, null, selectedIndices.length === 0 && emptySelectionText && (/*#__PURE__*/React__default.createElement(BodyCopyHarmonic, {
7096
+ }, getPersonCards())))), showActionButtonsSection && (/*#__PURE__*/React__default.createElement(ActionButtons, null, selectedStateIndices.length === 0 && emptySelectionText && (/*#__PURE__*/React__default.createElement(BodyCopyHarmonic, {
7058
7097
  size: "medium",
7059
7098
  className: "mobile-only"
7060
- }, emptySelectionText)), selectedIndices.length === 0 && !emptySelectionText && /*#__PURE__*/React__default.createElement(EmptySelectionTextSpacer, null), selectedIndices.length > 0 && (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, onApply && /*#__PURE__*/React__default.createElement(PrimaryButton, {
7099
+ }, emptySelectionText)), selectedStateIndices.length === 0 && !emptySelectionText && /*#__PURE__*/React__default.createElement(EmptySelectionTextSpacer, null), selectedStateIndices.length > 0 && (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, (onApply || onApplyIds) && (/*#__PURE__*/React__default.createElement(PrimaryButton, {
7061
7100
  onClick: function onClick() {
7062
- return onApply(selectedIndices);
7101
+ if (onApply) onApply(selectedStateIndices);
7102
+ if (onApplyIds) onApplyIds(selectedStateIds);
7063
7103
  }
7064
- }, ctaText != null ? ctaText : 'Apply'), onClear && (/*#__PURE__*/React__default.createElement(TextLink, {
7104
+ }, ctaText != null ? ctaText : 'Apply')), onClear && (/*#__PURE__*/React__default.createElement(TextLink, {
7065
7105
  tabIndex: 0,
7066
7106
  role: "button",
7067
7107
  onClick: onClear,
@@ -12255,7 +12295,7 @@ var CloseButton = /*#__PURE__*/styled.button(_templateObject2$19 || (_templateOb
12255
12295
  var ContentWrapper$3 = /*#__PURE__*/styled.div(_templateObject3$V || (_templateObject3$V = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
12256
12296
  var Overlay = /*#__PURE__*/styled(Grid)(_templateObject4$N || (_templateObject4$N = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100vh;\n align-content: center;\n background-color: rgba(0, 0, 0, 0.4);\n"])));
12257
12297
 
12258
- var _excluded$s = ["isOpen", "setIsOpen", "children", "appElementId"];
12298
+ var _excluded$s = ["isOpen", "setIsOpen", "children", "appElementId", "closeButtonAriaLabel"];
12259
12299
  var MAX_Z_INDEX = 9999999999;
12260
12300
  if (Modal.defaultStyles.content) {
12261
12301
  Modal.defaultStyles.content.position = 'static';
@@ -12329,6 +12369,8 @@ var ModalWindow = function ModalWindow(_ref) {
12329
12369
  setIsOpen = _ref.setIsOpen,
12330
12370
  children = _ref.children,
12331
12371
  appElementId = _ref.appElementId,
12372
+ _ref$closeButtonAriaL = _ref.closeButtonAriaLabel,
12373
+ closeButtonAriaLabel = _ref$closeButtonAriaL === void 0 ? 'Close modal window' : _ref$closeButtonAriaL,
12332
12374
  modalProps = _objectWithoutPropertiesLoose(_ref, _excluded$s);
12333
12375
  var isMobile = useMobile();
12334
12376
  var customStyles = {
@@ -12361,10 +12403,11 @@ var ModalWindow = function ModalWindow(_ref) {
12361
12403
  columnSpanSmallDevice: 14
12362
12404
  }, /*#__PURE__*/React__default.createElement(InnerModal, null, /*#__PURE__*/React__default.createElement(CloseButton, {
12363
12405
  onClick: closeModalHandler,
12364
- "aria-label": "Close modal window",
12406
+ "aria-label": closeButtonAriaLabel,
12365
12407
  tabIndex: 0
12366
12408
  }, /*#__PURE__*/React__default.createElement(Icon, {
12367
- iconName: "Close"
12409
+ iconName: "Close",
12410
+ "aria-hidden": "true"
12368
12411
  })), /*#__PURE__*/React__default.createElement(ContentWrapper$3, null, children))), /*#__PURE__*/React__default.createElement(ScrollLock, null)));
12369
12412
  };
12370
12413