@economic/taco 2.34.1 → 2.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/dist/components/Drawer/Context.d.ts +1 -0
  2. package/dist/components/Drawer/Drawer.d.ts +6 -0
  3. package/dist/components/Provider/Localization.d.ts +1 -0
  4. package/dist/components/Select2/Select2.d.ts +25 -4
  5. package/dist/esm/index.css +4 -0
  6. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +13 -3
  7. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
  8. package/dist/esm/packages/taco/src/components/Drawer/Context.js +1 -0
  9. package/dist/esm/packages/taco/src/components/Drawer/Context.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Drawer/Drawer.js +3 -1
  11. package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -1
  12. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +41 -8
  13. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -1
  14. package/dist/esm/packages/taco/src/components/Drawer/util.js +1 -1
  15. package/dist/esm/packages/taco/src/components/Drawer/util.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/List/components/Toggle.js +26 -15
  17. package/dist/esm/packages/taco/src/components/List/components/Toggle.js.map +1 -1
  18. package/dist/esm/packages/taco/src/components/Provider/Localization.js +2 -1
  19. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  20. package/dist/esm/packages/taco/src/components/Select2/Select2.js +48 -10
  21. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js +2 -1
  23. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +1 -1
  25. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  26. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/Body.js +2 -2
  27. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/Body.js.map +1 -1
  28. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js +12 -5
  29. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/util.js.map +1 -1
  30. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +9 -1
  31. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  32. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js +3 -4
  33. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
  34. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js +3 -4
  35. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js.map +1 -1
  36. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +0 -4
  37. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  38. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js +3 -2
  39. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
  40. package/dist/index.css +4 -0
  41. package/dist/primitives/Table/Core/components/Body/util.d.ts +2 -2
  42. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
  43. package/dist/taco.cjs.development.js +164 -62
  44. package/dist/taco.cjs.development.js.map +1 -1
  45. package/dist/taco.cjs.production.min.js +1 -1
  46. package/dist/taco.cjs.production.min.js.map +1 -1
  47. package/package.json +2 -2
@@ -4747,7 +4747,8 @@ const defaultLocalisationTexts = {
4747
4747
  open: 'Open'
4748
4748
  },
4749
4749
  drawer: {
4750
- close: 'Close'
4750
+ close: 'Close',
4751
+ back: 'Back'
4751
4752
  }
4752
4753
  };
4753
4754
  const defaultLocalizationContext = {
@@ -6402,6 +6403,13 @@ const Datepicker = /*#__PURE__*/React.forwardRef(function Datepicker(props, ref)
6402
6403
  texts
6403
6404
  } = useLocalization();
6404
6405
  const className = cn('inline-flex w-full text-black font-normal', externalClassName);
6406
+ const popoverContentRef = React.useRef(null);
6407
+ const handleOpenAutofocus = React.useCallback(e => {
6408
+ var _popoverContentRef$cu, _popoverContentRef$cu2;
6409
+ e.preventDefault();
6410
+ const currentDay = (_popoverContentRef$cu = popoverContentRef === null || popoverContentRef === void 0 ? void 0 : (_popoverContentRef$cu2 = popoverContentRef.current) === null || _popoverContentRef$cu2 === void 0 ? void 0 : _popoverContentRef$cu2.querySelector('table button[name="day"][aria-selected="true"]')) !== null && _popoverContentRef$cu !== void 0 ? _popoverContentRef$cu : null;
6411
+ currentDay === null || currentDay === void 0 ? void 0 : currentDay.focus();
6412
+ }, [popoverContentRef]);
6405
6413
  return /*#__PURE__*/React.createElement("span", {
6406
6414
  className: className,
6407
6415
  "data-taco": "datepicker",
@@ -6412,10 +6420,13 @@ const Datepicker = /*#__PURE__*/React.forwardRef(function Datepicker(props, ref)
6412
6420
  disabled: input.disabled || input.readOnly,
6413
6421
  icon: "calendar",
6414
6422
  tabIndex: -1,
6415
- popover: props => ( /*#__PURE__*/React.createElement(Popover, Object.assign({}, props), /*#__PURE__*/React.createElement(Popover.Content, null, ({
6423
+ popover: props => ( /*#__PURE__*/React.createElement(Popover, Object.assign({}, props), /*#__PURE__*/React.createElement(Popover.Content, {
6424
+ onOpenAutoFocus: handleOpenAutofocus
6425
+ }, ({
6416
6426
  close
6417
6427
  }) => ( /*#__PURE__*/React.createElement("div", {
6418
- className: "-m-3 flex"
6428
+ className: '[&_button[name="day"]:focus]:yt-focus -m-3 flex',
6429
+ ref: popoverContentRef
6419
6430
  }, /*#__PURE__*/React.createElement(Calendar$1, Object.assign({}, calendar, {
6420
6431
  onChange: (date, event) => {
6421
6432
  calendar.onChange(date, event);
@@ -6772,6 +6783,7 @@ const useCurrentMenu = () => {
6772
6783
  const DrawerContext = /*#__PURE__*/React.createContext({
6773
6784
  closeOnEscape: true,
6774
6785
  showCloseButton: true,
6786
+ onClickBack: () => {},
6775
6787
  onClose: () => {},
6776
6788
  onResize: () => {},
6777
6789
  props: {},
@@ -6803,7 +6815,7 @@ const getDrawerContentClassNames = (size, variant, open) => {
6803
6815
  const getDrawerContainerClassNames = variant => {
6804
6816
  return cn('bg-white mx-auto absolute h-full w-full flex flex-col ', {
6805
6817
  'shadow-[0_6px_9px_0_rgba(89,85,98,0.3),0_0_1px_0_rgba(89,85,98,0.2)]': variant === 'overlay',
6806
- 'border-l border-grey h-full': variant === 'embedded'
6818
+ 'border-l border-grey-300 h-full': variant === 'embedded'
6807
6819
  });
6808
6820
  };
6809
6821
  const getDrawerDragHandlerClassNames = () => {
@@ -6869,24 +6881,55 @@ const RenderPropWrapper$2 = /*#__PURE__*/React__default.forwardRef(function Rend
6869
6881
  ...renderProps
6870
6882
  });
6871
6883
  });
6872
- const Title$2 = /*#__PURE__*/React__default.forwardRef(function DrawerTitle(props, ref) {
6884
+ const Title$2 = /*#__PURE__*/React__default.forwardRef(function DrawerTitle(props, externalRef) {
6873
6885
  const {
6874
6886
  className,
6875
6887
  children,
6876
6888
  ...otherProps
6877
6889
  } = props;
6890
+ const ref = useMergedRef(externalRef);
6891
+ const [style, setStyle] = React__default.useState({});
6892
+ const {
6893
+ texts
6894
+ } = useLocalization();
6895
+ const {
6896
+ onClickBack
6897
+ } = useCurrentDrawer();
6878
6898
  /**
6879
6899
  * By design in default drawer version Title has grey separator, but we might have exceptions like Drawer + Tabs scenario,
6880
- * where we might want to hide the grey separator. For this reason separator was rendedr with using of classNames,
6881
- * so it can be easily overriden in exceptional scenarious.
6900
+ * where we might want to hide the grey separator. For this reason separator was rendered with using of classNames,
6901
+ * so it can be easily overriden in exceptional scenarios.
6882
6902
  * */
6883
- const cName = cn('grow-0 py-4 pl-4 justify-self-start mb-0 border-b-[1px] border-grey-300 flex items-center', className);
6903
+ const cName = cn('grow-0 py-4 px-4 justify-self-start mb-0 border-b-[1px] border-grey-300 flex items-start', className);
6904
+ React__default.useEffect(() => {
6905
+ var _ref$current, _drawer$querySelector, _closeButton$offsetWi, _drawer$querySelector2, _actionsWrapper$offse;
6906
+ const drawer = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.closest('[data-taco="drawer"]');
6907
+ // This is the margin amount that we need to deduct from the margins to align with the design
6908
+ const marginAdjust = 4;
6909
+ const closeButton = (_drawer$querySelector = drawer === null || drawer === void 0 ? void 0 : drawer.querySelector(`[aria-label="${texts.drawer.close}"]`)) !== null && _drawer$querySelector !== void 0 ? _drawer$querySelector : null;
6910
+ const closeButtonWidth = (_closeButton$offsetWi = closeButton === null || closeButton === void 0 ? void 0 : closeButton.offsetWidth) !== null && _closeButton$offsetWi !== void 0 ? _closeButton$offsetWi : 0;
6911
+ const closeButtonRightMargin = 8;
6912
+ const actionsWrapper = (_drawer$querySelector2 = drawer === null || drawer === void 0 ? void 0 : drawer.querySelector(`#taco-drawer-actions[data-taco="group"]`)) !== null && _drawer$querySelector2 !== void 0 ? _drawer$querySelector2 : null;
6913
+ const actionsWrapperWidth = (_actionsWrapper$offse = actionsWrapper === null || actionsWrapper === void 0 ? void 0 : actionsWrapper.offsetWidth) !== null && _actionsWrapper$offse !== void 0 ? _actionsWrapper$offse : 0;
6914
+ const actionsWrapperRightMargin = 8;
6915
+ const marginRight = closeButtonWidth + actionsWrapperWidth + closeButtonRightMargin + actionsWrapperRightMargin - marginAdjust;
6916
+ setStyle({
6917
+ marginRight
6918
+ });
6919
+ }, [ref, texts.drawer.close]);
6884
6920
  return /*#__PURE__*/React__default.createElement(DialogPrimitive.Title, Object.assign({
6885
6921
  className: cName
6886
6922
  }, otherProps, {
6887
6923
  ref: ref
6888
- }), /*#__PURE__*/React__default.createElement("span", {
6889
- className: "line-clamp-2 inline-block w-4/6 overflow-y-hidden"
6924
+ }), onClickBack ? ( /*#__PURE__*/React__default.createElement(IconButton, {
6925
+ appearance: "discrete",
6926
+ "aria-label": texts.drawer.back,
6927
+ className: "mr-3 text-base",
6928
+ icon: "chevron-left",
6929
+ onClick: onClickBack
6930
+ })) : null, /*#__PURE__*/React__default.createElement("span", {
6931
+ className: "line-clamp-2 inline-block overflow-y-hidden",
6932
+ style: style
6890
6933
  }, children));
6891
6934
  });
6892
6935
  const Footer$2 = /*#__PURE__*/React__default.forwardRef(function DrawerFooter(props, ref) {
@@ -6909,8 +6952,10 @@ const Actions = /*#__PURE__*/React__default.forwardRef(function Actions(props, r
6909
6952
  ...otherProps
6910
6953
  } = props;
6911
6954
  const cName = cn('absolute top-0 right-10 mr-[8px] mt-4', className);
6955
+ // Id is added to identify the actions wrapper inside a useEffect in Dialog.Title
6912
6956
  return /*#__PURE__*/React__default.createElement(Group, Object.assign({}, otherProps, {
6913
6957
  className: cName,
6958
+ id: "taco-drawer-actions",
6914
6959
  ref: ref
6915
6960
  }));
6916
6961
  });
@@ -7024,8 +7069,8 @@ const DrawerContent = /*#__PURE__*/React__default.forwardRef(function Content(pr
7024
7069
  };
7025
7070
  }, [size, variant, open]);
7026
7071
  const handleEscapeKeyDown = event => {
7027
- var _ref$current;
7028
- const isTargetInsideDrawerContent = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains(event.target);
7072
+ var _ref$current2;
7073
+ const isTargetInsideDrawerContent = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.contains(event.target);
7029
7074
  if (isTargetInsideDrawerContent) {
7030
7075
  if (!closeOnEscape) {
7031
7076
  event.preventDefault();
@@ -7155,6 +7200,7 @@ const Drawer = /*#__PURE__*/React.forwardRef(function Drawer(props, ref) {
7155
7200
  closeOnEscape = true,
7156
7201
  onResize,
7157
7202
  onClose,
7203
+ onClickBack,
7158
7204
  size = 'md',
7159
7205
  trigger,
7160
7206
  children,
@@ -7171,6 +7217,7 @@ const Drawer = /*#__PURE__*/React.forwardRef(function Drawer(props, ref) {
7171
7217
  const [outlet, setOutlet] = React.useState();
7172
7218
  const context = React.useMemo(() => ({
7173
7219
  closeOnEscape,
7220
+ onClickBack,
7174
7221
  onClose,
7175
7222
  onResize,
7176
7223
  props: otherProps,
@@ -7182,7 +7229,7 @@ const Drawer = /*#__PURE__*/React.forwardRef(function Drawer(props, ref) {
7182
7229
  focusTrap,
7183
7230
  showCloseButton,
7184
7231
  outlet
7185
- }), [closeOnEscape, open, setOpen, otherProps, variant, onResize, onClose, size, focusTrap, showCloseButton, outlet]);
7232
+ }), [closeOnEscape, open, setOpen, otherProps, variant, onResize, onClose, size, focusTrap, showCloseButton, outlet, onClickBack]);
7186
7233
  // this prevents two drawers being open at once and used when one drawer getting opened before another one got closed.
7187
7234
  const close = React.useCallback(() => {
7188
7235
  setOpen(false);
@@ -7546,6 +7593,7 @@ Switch.displayName = 'Switch';
7546
7593
  const ToggleItem = /*#__PURE__*/React__default.forwardRef(function Toggle(props, ref) {
7547
7594
  const {
7548
7595
  controlRef,
7596
+ onToggle,
7549
7597
  ...attributes
7550
7598
  } = props;
7551
7599
  function handleClick(event) {
@@ -7556,25 +7604,23 @@ const ToggleItem = /*#__PURE__*/React__default.forwardRef(function Toggle(props,
7556
7604
  if (event.isDefaultPrevented()) {
7557
7605
  return;
7558
7606
  }
7559
- // If event target is not a control or not an element inside the control, then trigger click of the control
7560
- if (event.target !== controlRef.current || !((_controlRef$current = controlRef.current) !== null && _controlRef$current !== void 0 && _controlRef$current.contains(event.target))) {
7561
- var _controlRef$current2;
7562
- (_controlRef$current2 = controlRef.current) === null || _controlRef$current2 === void 0 ? void 0 : _controlRef$current2.click();
7607
+ // If event target is not a control and not an element inside the control, then trigger click of the control
7608
+ if (event.target !== controlRef.current && !((_controlRef$current = controlRef.current) !== null && _controlRef$current !== void 0 && _controlRef$current.contains(event.target))) {
7609
+ onToggle();
7563
7610
  return;
7564
7611
  }
7565
7612
  }
7566
7613
  function handleKeyDown(event) {
7567
- var _controlRef$current3;
7614
+ var _controlRef$current2;
7568
7615
  if (typeof props.onKeyDown === 'function') {
7569
7616
  props.onKeyDown(event);
7570
7617
  }
7571
7618
  if (event.isDefaultPrevented()) {
7572
7619
  return;
7573
7620
  }
7574
- // If event target is not a control or not an element inside the control, then send appropriate "activate" keyboard shortcuts to the control as a click
7575
- if ((event.key === 'Enter' || event.key === ' ') && (event.target !== controlRef.current || !((_controlRef$current3 = controlRef.current) !== null && _controlRef$current3 !== void 0 && _controlRef$current3.contains(event.target)))) {
7576
- var _controlRef$current4;
7577
- (_controlRef$current4 = controlRef.current) === null || _controlRef$current4 === void 0 ? void 0 : _controlRef$current4.click();
7621
+ // If event target is not a control and not an element inside the control, then send appropriate "activate" keyboard shortcuts to the control as a click
7622
+ if ((event.key === 'Enter' || event.key === ' ') && event.target !== controlRef.current && !((_controlRef$current2 = controlRef.current) !== null && _controlRef$current2 !== void 0 && _controlRef$current2.contains(event.target))) {
7623
+ onToggle();
7578
7624
  return;
7579
7625
  }
7580
7626
  }
@@ -7588,44 +7634,56 @@ const ToggleItem = /*#__PURE__*/React__default.forwardRef(function Toggle(props,
7588
7634
  });
7589
7635
  const Switch$1 = /*#__PURE__*/React__default.forwardRef(function Switch$1(props, ref) {
7590
7636
  const {
7591
- checked,
7637
+ checked: externalChecked,
7592
7638
  onChange,
7593
7639
  ...attributes
7594
7640
  } = props;
7641
+ const [checked, setChecked] = React__default.useState(externalChecked);
7595
7642
  const switchRef = React__default.useRef(null);
7643
+ const toggle = React__default.useCallback(() => {
7644
+ setChecked(!checked);
7645
+ onChange(!checked);
7646
+ }, [checked, onChange]);
7596
7647
  const control = /*#__PURE__*/React__default.createElement(Switch, {
7597
7648
  checked: checked,
7598
7649
  className: "group-hover/toggle:[&[aria-checked=false]]:bg-grey-700 group-hover/toggle:[&[aria-checked=true]]:bg-blue-700",
7599
7650
  disabled: props.disabled,
7600
- onChange: onChange,
7651
+ onChange: toggle,
7601
7652
  ref: switchRef,
7602
7653
  tabIndex: -1
7603
7654
  });
7604
7655
  return /*#__PURE__*/React__default.createElement(ToggleItem, Object.assign({}, attributes, {
7605
7656
  control: control,
7606
7657
  controlRef: switchRef,
7607
- ref: ref
7658
+ ref: ref,
7659
+ onToggle: toggle
7608
7660
  }));
7609
7661
  });
7610
7662
  const Checkbox$1 = /*#__PURE__*/React__default.forwardRef(function Switch(props, ref) {
7611
7663
  const {
7612
- checked,
7664
+ checked: externalChecked,
7613
7665
  onChange,
7614
7666
  ...attributes
7615
7667
  } = props;
7668
+ const [checked, setChecked] = React__default.useState(externalChecked);
7616
7669
  const checkboxRef = React__default.useRef(null);
7670
+ const toggle = React__default.useCallback(() => {
7671
+ setChecked(!checked);
7672
+ onChange(!checked);
7673
+ }, [checked, onChange]);
7617
7674
  const control = /*#__PURE__*/React__default.createElement(Checkbox, {
7618
7675
  checked: checked,
7619
7676
  className: "group-hover/toggle:[&[aria-checked=false]]:border-grey-700 group-hover/toggle:[&[aria-checked=true]]:border-blue-700 group-hover/checkbox:[&[aria-checked=true]]:bg-blue-700",
7620
7677
  disabled: props.disabled,
7621
- onChange: onChange,
7678
+ onChange: toggle,
7622
7679
  ref: checkboxRef,
7623
7680
  tabIndex: -1
7624
7681
  });
7625
7682
  return /*#__PURE__*/React__default.createElement(ToggleItem, Object.assign({}, attributes, {
7626
7683
  control: control,
7627
7684
  controlRef: checkboxRef,
7628
- ref: ref
7685
+ ref: ref,
7686
+ onToggle: toggle
7629
7687
  }));
7630
7688
  });
7631
7689
 
@@ -10854,8 +10912,6 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
10854
10912
  // if a search is currently "active", we need to re load all because
10855
10913
  const handleSort = function (sorting) {
10856
10914
  try {
10857
- // set the sorting so we can track if it changed between loads
10858
- _lastUsedSorting.current = sorting;
10859
10915
  if (_lastUsedSearch.current) {
10860
10916
  // we're searching, which means we need to refetch all with the correct sorting applied
10861
10917
  loadAll(sorting, _lastUsedFilters.current);
@@ -10870,8 +10926,6 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
10870
10926
  };
10871
10927
  const handleFilter = function (filters) {
10872
10928
  try {
10873
- // set the filters so we can track if it changed between loads
10874
- _lastUsedFilters.current = filters;
10875
10929
  if (_lastUsedSearch.current) {
10876
10930
  // we're searching, which means we need to refetch all with the correct sorting applied
10877
10931
  loadAll(_lastUsedSorting.current, filters);
@@ -11163,8 +11217,8 @@ function resetHighlightedColumnIndexes(value, table) {
11163
11217
  }
11164
11218
  }
11165
11219
  if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {
11166
- var _row$original, _column$columnDef$met;
11167
- const cellValue = getCellValueAsString((_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original[column.id], (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.dataType);
11220
+ var _column$columnDef$met;
11221
+ const cellValue = getCellValueAsString(get(row.original, column.id), (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.dataType);
11168
11222
  // indexes don't map to sorted data
11169
11223
  if (cellValue !== undefined && isWeakContains(cellValue, value)) {
11170
11224
  indexes.push([rowIndex, columnIndex]);
@@ -12955,7 +13009,15 @@ function HeaderMenu(props) {
12955
13009
  icon: "more",
12956
13010
  menu: popoverElement ? undefined : menuProps => ( /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, null, memoedMenuItems))),
12957
13011
  popover: popoverElement,
12958
- onClickCapture: event => event.preventDefault()
13012
+ onClickCapture: event => event.preventDefault(),
13013
+ onKeyDown: event => {
13014
+ // Removes focus from the column header menu button so that active row shortcuts execute when Tab,
13015
+ // Shift+Tab, or any other keydown event occurs.
13016
+ if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
13017
+ var _event$currentTarget;
13018
+ (_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 ? void 0 : _event$currentTarget.blur();
13019
+ }
13020
+ }
12959
13021
  });
12960
13022
  }
12961
13023
 
@@ -13189,16 +13251,22 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
13189
13251
  })) : null);
13190
13252
  });
13191
13253
 
13192
- const FOCUS_MANAGER_OPTIONS = {
13254
+ const FOCUS_MANAGER_OPTIONS_TAB = {
13193
13255
  accept: element => !!element.closest('tr[data-row-active="true"]'),
13194
13256
  tabbable: true
13195
13257
  };
13258
+ const FOCUS_MANAGER_OPTIONS_ARROW_KEYS = {
13259
+ accept: element => {
13260
+ const acceptTabbable = isElementInteractive(element) ? element.getAttribute('tabindex') !== '-1' : true;
13261
+ return !!element.closest('tr[data-row-active="true"]') && !hasFocusableElement(element) && acceptTabbable;
13262
+ }
13263
+ };
13196
13264
  function useAugmentedFocusManager() {
13197
13265
  const focusManager = focus.useFocusManager();
13198
- const focusPrevious = () => focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);
13199
- const focusNext = () => focusManager.focusNext(FOCUS_MANAGER_OPTIONS);
13200
- const focusFirst = () => focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);
13201
- const focusLast = () => focusManager.focusLast(FOCUS_MANAGER_OPTIONS);
13266
+ const focusPrevious = (arrowNavigation = false) => focusManager.focusPrevious(arrowNavigation ? FOCUS_MANAGER_OPTIONS_ARROW_KEYS : FOCUS_MANAGER_OPTIONS_TAB);
13267
+ const focusNext = (arrowNavigation = false) => focusManager.focusNext(arrowNavigation ? FOCUS_MANAGER_OPTIONS_ARROW_KEYS : FOCUS_MANAGER_OPTIONS_TAB);
13268
+ const focusFirst = () => focusManager.focusFirst(FOCUS_MANAGER_OPTIONS_TAB);
13269
+ const focusLast = () => focusManager.focusLast(FOCUS_MANAGER_OPTIONS_TAB);
13202
13270
  return {
13203
13271
  focusPrevious,
13204
13272
  focusNext,
@@ -13234,10 +13302,10 @@ function Body(props) {
13234
13302
  let focusedElement;
13235
13303
  switch (event.key) {
13236
13304
  case 'ArrowLeft':
13237
- focusedElement = isMetaKeyPressed ? focusManager.focusFirst() : focusManager.focusPrevious();
13305
+ focusedElement = isMetaKeyPressed ? focusManager.focusFirst() : focusManager.focusPrevious(true);
13238
13306
  break;
13239
13307
  case 'ArrowRight':
13240
- focusedElement = isMetaKeyPressed ? focusManager.focusLast() : focusManager.focusNext();
13308
+ focusedElement = isMetaKeyPressed ? focusManager.focusLast() : focusManager.focusNext(true);
13241
13309
  // Scrolls table all the way to the right
13242
13310
  if (isMetaKeyPressed && tableElement) {
13243
13311
  tableElement.scrollLeft = tableElement.scrollWidth;
@@ -15242,6 +15310,9 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15242
15310
  name,
15243
15311
  onChange,
15244
15312
  onCreate,
15313
+ dialogTriggerTitle,
15314
+ dialogTriggerDisabled,
15315
+ dialog,
15245
15316
  onDelete,
15246
15317
  onEdit,
15247
15318
  placeholder,
@@ -15311,6 +15382,9 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15311
15382
  listboxRef,
15312
15383
  multiple,
15313
15384
  onCreate,
15385
+ dialogTriggerTitle,
15386
+ dialogTriggerDisabled,
15387
+ dialog,
15314
15388
  onDelete,
15315
15389
  onEdit,
15316
15390
  open,
@@ -15412,21 +15486,34 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15412
15486
  setValue(nextValue);
15413
15487
  }
15414
15488
  };
15489
+ const handleCreateInDialog = function (name, color) {
15490
+ try {
15491
+ const _temp2 = function () {
15492
+ if (onCreate && dialog) {
15493
+ const _temp = _catch(function () {
15494
+ return Promise.resolve(onCreate(name, color)).then(function (option) {
15495
+ setValue(option.value);
15496
+ // To avoid memory leak we should bind onClose of dialog with setOpen(false)
15497
+ setOpen(false);
15498
+ });
15499
+ }, function (err) {
15500
+ console.log(err);
15501
+ });
15502
+ if (_temp && _temp.then) return _temp.then(function () {});
15503
+ }
15504
+ }();
15505
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
15506
+ } catch (e) {
15507
+ return Promise.reject(e);
15508
+ }
15509
+ };
15415
15510
  const className = cn('border-grey-300 rounded border bg-white py-1.5 shadow-md outline-none"', createCollectionClassName());
15416
15511
  return /*#__PURE__*/React__default.createElement(Select2Context.Provider, {
15417
15512
  value: context
15418
15513
  }, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Root, {
15419
15514
  open: open,
15420
15515
  onOpenChange: setOpen
15421
- }, /*#__PURE__*/React__default.createElement(ControlledHiddenField, {
15422
- emptyValue: emptyValue,
15423
- multiple: multiple || tags,
15424
- name: name,
15425
- options: flattenedChildren.map(child => child.props.value),
15426
- parentRef: internalRef,
15427
- setValue: setValue,
15428
- value: value
15429
- }), /*#__PURE__*/React__default.createElement(PopoverPrimitive.Trigger, {
15516
+ }, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Trigger, {
15430
15517
  asChild: true,
15431
15518
  "data-taco": "Select2"
15432
15519
  }, /*#__PURE__*/React__default.createElement(Trigger$7, Object.assign({}, otherProps, {
@@ -15487,7 +15574,24 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
15487
15574
  }, searchQuery === '' ? ( /*#__PURE__*/React__default.createElement(Collection$1, null, initialChildren)) : ( /*#__PURE__*/React__default.createElement(Collection$1, null, filteredChildren)), onCreate ? /*#__PURE__*/React__default.createElement(Create, {
15488
15575
  onCreate: onCreate,
15489
15576
  options: flattenedChildren
15490
- }) : null)))))));
15577
+ }) : null)), dialog && dialogTriggerTitle && ( /*#__PURE__*/React__default.createElement("span", {
15578
+ className: "border-grey-300 h-9 border-t p-1.5"
15579
+ }, /*#__PURE__*/React__default.createElement(Button$1, {
15580
+ appearance: "discrete",
15581
+ disabled: dialogTriggerDisabled,
15582
+ dialog: dialog(handleCreateInDialog)
15583
+ }, /*#__PURE__*/React__default.createElement(Icon, {
15584
+ className: "text-xs",
15585
+ name: "circle-plus"
15586
+ }), " ", dialogTriggerTitle)))))), /*#__PURE__*/React__default.createElement(ControlledHiddenField, {
15587
+ emptyValue: emptyValue,
15588
+ multiple: multiple || tags,
15589
+ name: name,
15590
+ options: flattenedChildren.map(child => child.props.value),
15591
+ parentRef: internalRef,
15592
+ setValue: setValue,
15593
+ value: value
15594
+ })));
15491
15595
  });
15492
15596
  Select2.Option = Option$1;
15493
15597
  Select2.Group = Group$3;
@@ -15797,8 +15901,7 @@ const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
15797
15901
  allColumns,
15798
15902
  filters,
15799
15903
  onChange: handleChange,
15800
- value = null,
15801
- ...attributes
15904
+ value = null
15802
15905
  } = props;
15803
15906
  const {
15804
15907
  texts
@@ -15811,13 +15914,13 @@ const FilterColumn = /*#__PURE__*/React__default.forwardRef((props, ref) => {
15811
15914
  message: warning ? texts.table.filters.hiddenColumn : undefined,
15812
15915
  warning: warning,
15813
15916
  className: "min-h-[theme(spacing.8)]"
15814
- }, /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
15917
+ }, /*#__PURE__*/React__default.createElement(Select2, {
15815
15918
  ref: ref,
15816
15919
  className: "focus:yt-focus !w-32 flex-shrink-0 ",
15817
15920
  emptyValue: null,
15818
15921
  onChange: handleChange,
15819
15922
  value: value
15820
- }), allColumns.map(column => {
15923
+ }, allColumns.map(column => {
15821
15924
  var _column$columnDef$met, _column$parent, _column$parent$column;
15822
15925
  return /*#__PURE__*/React__default.createElement(Select2.Option, {
15823
15926
  key: column.id,
@@ -15837,19 +15940,18 @@ function FilterComparator(props) {
15837
15940
  const {
15838
15941
  column,
15839
15942
  onChange: handleChange,
15840
- value,
15841
- ...attributes
15943
+ value
15842
15944
  } = props;
15843
15945
  const {
15844
15946
  texts
15845
15947
  } = useLocalization();
15846
15948
  const validComparators = guessComparatorsBasedOnControl(column);
15847
- return /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
15949
+ return /*#__PURE__*/React__default.createElement(Select2, {
15848
15950
  className: "!w-32 flex-shrink-0",
15849
15951
  disabled: !column,
15850
15952
  onChange: handleChange,
15851
15953
  value: value
15852
- }), validComparators.map(comparator => ( /*#__PURE__*/React__default.createElement(Select2.Option, {
15954
+ }, validComparators.map(comparator => ( /*#__PURE__*/React__default.createElement(Select2.Option, {
15853
15955
  key: comparator,
15854
15956
  value: comparator
15855
15957
  }, getComparatorText(comparator, texts, column)))));
@@ -18542,7 +18644,7 @@ function useEditingCellAutofocus(props) {
18542
18644
  tableElement.scrollTo(props.cell.column.getStart() - columnFreezingOffset, tableElement.scrollTop);
18543
18645
  }
18544
18646
  }
18545
- if (event.target === event.currentTarget) {
18647
+ if (event.target === event.currentTarget && hasFocusableElement(event.currentTarget)) {
18546
18648
  focusManager.focusNext();
18547
18649
  }
18548
18650
  };
@@ -18909,7 +19011,7 @@ function Row$2(props) {
18909
19011
  }
18910
19012
  }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);
18911
19013
  const handleFocus = React__default.useCallback(event => {
18912
- if (tableMeta.editing.isEditing && isActiveRow) {
19014
+ if (tableMeta.editing.isEditing) {
18913
19015
  var _event$target$closest, _event$target$closest2;
18914
19016
  const cellIndex = Number((_event$target$closest = (_event$target$closest2 = event.target.closest('td')) === null || _event$target$closest2 === void 0 ? void 0 : _event$target$closest2.getAttribute('data-cell-index')) !== null && _event$target$closest !== void 0 ? _event$target$closest : undefined);
18915
19017
  if (!isNaN(cellIndex)) {