@economic/taco 1.15.0 → 1.16.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.
Files changed (112) hide show
  1. package/dist/components/AlertDialog/components/Content.d.ts +1 -1
  2. package/dist/components/Banner/Banner.d.ts +4 -0
  3. package/dist/components/Calendar/Calendar.d.ts +1 -1
  4. package/dist/components/Calendar/Calendar.stories.d.ts +1 -1
  5. package/dist/components/Card/Card.d.ts +1 -1
  6. package/dist/components/Datepicker/Datepicker.d.ts +1 -1
  7. package/dist/components/Datepicker/Datepicker.stories.d.ts +1 -1
  8. package/dist/components/Dialog/components/Content.d.ts +1 -1
  9. package/dist/components/Dialog/components/Drawer.d.ts +1 -1
  10. package/dist/components/IconButton/IconButton.d.ts +2 -2
  11. package/dist/components/IconButton/IconButton.stories.d.ts +1 -1
  12. package/dist/components/Listbox/Listbox.d.ts +2 -2
  13. package/dist/components/Listbox/Listbox.stories.d.ts +1 -1
  14. package/dist/components/Listbox/ScrollableList.d.ts +1 -1
  15. package/dist/components/Menu/Menu.d.ts +6 -1
  16. package/dist/components/Menu/Menu.stories.d.ts +2 -0
  17. package/dist/components/Menu/components/Checkbox.d.ts +1 -1
  18. package/dist/components/Menu/components/Content.d.ts +4 -2
  19. package/dist/components/Menu/components/Item.d.ts +1 -1
  20. package/dist/components/Menu/components/Link.d.ts +1 -1
  21. package/dist/components/Menu/components/Trigger.d.ts +1 -1
  22. package/dist/components/Provider/Localization.d.ts +157 -0
  23. package/dist/components/Provider/Provider.d.ts +1 -148
  24. package/dist/components/SearchInput/SearchInput.d.ts +6 -2
  25. package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -1
  26. package/dist/components/Select/Select.d.ts +1 -1
  27. package/dist/components/Select/Select.stories.d.ts +1 -1
  28. package/dist/components/Select2/Select2.d.ts +6 -4
  29. package/dist/components/Select2/Select2.stories.d.ts +1 -0
  30. package/dist/components/Select2/components/Option.d.ts +1 -1
  31. package/dist/components/Select2/components/Trigger.d.ts +1 -1
  32. package/dist/components/Table/hooks/plugins/useRowActions.d.ts +1 -1
  33. package/dist/components/Tag/Tag.d.ts +1 -1
  34. package/dist/esm/index.css +71 -71
  35. package/dist/esm/packages/taco/src/components/Banner/Banner.js +5 -0
  36. package/dist/esm/packages/taco/src/components/Banner/Banner.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Calendar/Calendar.js +1 -1
  38. package/dist/esm/packages/taco/src/components/Calendar/Calendar.js.map +1 -1
  39. package/dist/esm/packages/taco/src/components/Card/Card.js +0 -54
  40. package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +17 -5
  42. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Combobox/Combobox.js +6 -2
  44. package/dist/esm/packages/taco/src/components/Combobox/Combobox.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +1 -1
  46. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +1 -1
  48. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  49. package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +5 -1
  50. package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Dialog/components/Drawer.js +1 -1
  52. package/dist/esm/packages/taco/src/components/Hanger/Hanger.js +1 -1
  53. package/dist/esm/packages/taco/src/components/Hanger/Hanger.js.map +1 -1
  54. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +24 -19
  55. package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
  56. package/dist/esm/packages/taco/src/components/Listbox/useMultiListbox.js +1 -1
  57. package/dist/esm/packages/taco/src/components/Listbox/useMultiListbox.js.map +1 -1
  58. package/dist/esm/packages/taco/src/components/Listbox/useTypeahead.js +1 -1
  59. package/dist/esm/packages/taco/src/components/Menu/Menu.js +12 -2
  60. package/dist/esm/packages/taco/src/components/Menu/Menu.js.map +1 -1
  61. package/dist/esm/packages/taco/src/components/Menu/components/Content.js +4 -3
  62. package/dist/esm/packages/taco/src/components/Menu/components/Content.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js +1 -1
  64. package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Pagination/Pagination.js +1 -1
  66. package/dist/esm/packages/taco/src/components/Pagination/Pagination.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Provider/Localization.js +112 -0
  68. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -0
  69. package/dist/esm/packages/taco/src/components/Provider/Provider.js +6 -106
  70. package/dist/esm/packages/taco/src/components/Provider/Provider.js.map +1 -1
  71. package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js +2 -53
  72. package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
  73. package/dist/esm/packages/taco/src/components/Select/useSelect.js +1 -1
  74. package/dist/esm/packages/taco/src/components/Select/useSelect.js.map +1 -1
  75. package/dist/esm/packages/taco/src/components/Select2/Select2.js +7 -5
  76. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  77. package/dist/esm/packages/taco/src/components/Select2/components/Collection.js +0 -6
  78. package/dist/esm/packages/taco/src/components/Select2/components/Collection.js.map +1 -1
  79. package/dist/esm/packages/taco/src/components/Select2/components/Create.js +1 -1
  80. package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
  81. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
  82. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
  83. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +49 -23
  84. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  85. package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js +3 -2
  86. package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js.map +1 -1
  87. package/dist/esm/packages/taco/src/components/Switch/Switch.js +18 -6
  88. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  89. package/dist/esm/packages/taco/src/components/Table/components/Table.js +5 -1
  90. package/dist/esm/packages/taco/src/components/Table/components/Table.js.map +1 -1
  91. package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js +1 -1
  92. package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js.map +1 -1
  93. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js.map +1 -1
  94. package/dist/esm/packages/taco/src/components/Table/hooks/useTable.js +1 -1
  95. package/dist/esm/packages/taco/src/components/Table/hooks/useTable.js.map +1 -1
  96. package/dist/esm/packages/taco/src/components/Toast/Toast.js +1 -1
  97. package/dist/esm/packages/taco/src/components/Toast/Toast.js.map +1 -1
  98. package/dist/esm/packages/taco/src/components/Tour/Tour.js +1 -1
  99. package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
  100. package/dist/esm/packages/taco/src/index.js +4 -3
  101. package/dist/esm/packages/taco/src/index.js.map +1 -1
  102. package/dist/esm/packages/taco/src/utils/hooks/useDraggable.js +8 -0
  103. package/dist/esm/packages/taco/src/utils/hooks/useDraggable.js.map +1 -1
  104. package/dist/index.css +71 -71
  105. package/dist/index.d.ts +1 -0
  106. package/dist/taco.cjs.development.js +719 -626
  107. package/dist/taco.cjs.development.js.map +1 -1
  108. package/dist/taco.cjs.production.min.js +1 -1
  109. package/dist/taco.cjs.production.min.js.map +1 -1
  110. package/dist/types.d.ts +1 -0
  111. package/package.json +3 -3
  112. package/types.json +59 -39
@@ -11,18 +11,18 @@ var cn = _interopDefault(require('classnames'));
11
11
  var AccordionPrimitive = require('@radix-ui/react-accordion');
12
12
  var TooltipPrimitive = require('@radix-ui/react-tooltip');
13
13
  var ReactDayPicker = _interopDefault(require('react-day-picker'));
14
- var uuid = require('uuid');
15
- var framerMotion = require('framer-motion');
16
14
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
15
+ var uuid = require('uuid');
17
16
  var PopoverPrimitive = require('@radix-ui/react-popover');
18
17
  var debounce$1 = _interopDefault(require('lodash/debounce'));
19
18
  var dateFns = require('date-fns');
20
19
  var DialogPrimitive = require('@radix-ui/react-dialog');
21
20
  var interactions = require('@react-aria/interactions');
21
+ var framerMotion = require('framer-motion');
22
22
  var HoverCardPrimitive = require('@radix-ui/react-hover-card');
23
23
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
24
- var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
25
24
  var reactUseControllableState = require('@radix-ui/react-use-controllable-state');
25
+ var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
26
26
  var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
27
27
  var reactTable = require('react-table');
28
28
  var reactIntersectionObserver = require('react-intersection-observer');
@@ -3489,18 +3489,130 @@ const IconButton = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
3489
3489
  }, button);
3490
3490
  });
3491
3491
 
3492
+ const defaultLocalisationTexts = {
3493
+ calendar: {
3494
+ months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
3495
+ weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
3496
+ actions: {
3497
+ previousMonth: 'Previous month',
3498
+ nextMonth: 'Next month',
3499
+ previousYear: 'Previous year',
3500
+ nextYear: 'Next year',
3501
+ today: 'Today'
3502
+ }
3503
+ },
3504
+ combobox: {
3505
+ tooltip: 'Search in list'
3506
+ },
3507
+ datepicker: {
3508
+ calendar: 'Calendar',
3509
+ clear: 'Clear',
3510
+ expand: 'Show calendar',
3511
+ shortcuts: 'Shortcuts'
3512
+ },
3513
+ hanger: {
3514
+ close: 'Close'
3515
+ },
3516
+ banner: {
3517
+ close: 'Close'
3518
+ },
3519
+ listbox: {
3520
+ loading: 'Loading results...',
3521
+ empty: 'No results found',
3522
+ allOption: 'All'
3523
+ },
3524
+ dialog: {
3525
+ close: 'Close',
3526
+ drag: 'Drag'
3527
+ },
3528
+ pagination: {
3529
+ label: 'Pagination',
3530
+ pageSize: 'Items per page',
3531
+ showingXofYofTotal: 'Showing [X] - [Y] of [total]',
3532
+ actions: {
3533
+ firstPage: 'Goto first page',
3534
+ firstPageWithShortcut: 'Goto first page (Home)',
3535
+ previousPage: 'Goto previous page',
3536
+ previousPageWithShortcut: 'Goto previous page (Page Up)',
3537
+ nextPage: 'Goto next page',
3538
+ nextPageWithShortcut: 'Goto next page (Page Down)',
3539
+ lastPage: 'Goto last page',
3540
+ lastPageWithShortcut: 'Goto last page (End)',
3541
+ pageX: 'Goto page [X]'
3542
+ }
3543
+ },
3544
+ table: {
3545
+ actions: 'Other actions',
3546
+ edit: 'Edit (e)',
3547
+ copy: 'Copy (c)',
3548
+ del: 'Delete (del)',
3549
+ newSubRow: 'New row (shift + n)',
3550
+ loading: 'Loading...'
3551
+ },
3552
+ select: {
3553
+ allOptionsSelected: 'All'
3554
+ },
3555
+ select2: {
3556
+ allSelect: 'Select all',
3557
+ allDeselect: 'Deselect all',
3558
+ cancel: 'Cancel',
3559
+ chooseColor: 'Pick a color',
3560
+ create: 'Create',
3561
+ delete: 'Delete',
3562
+ save: 'Save',
3563
+ search: 'Search...',
3564
+ searchOrCreate: 'Search or create...'
3565
+ },
3566
+ toasts: {
3567
+ dismiss: 'Dismiss'
3568
+ },
3569
+ tour: {
3570
+ back: 'Back',
3571
+ close: 'Close',
3572
+ skip: 'Close and complete',
3573
+ last: 'Done',
3574
+ next: 'Next',
3575
+ open: 'Open'
3576
+ },
3577
+ searchInput: {
3578
+ inputLabel: 'Search...',
3579
+ buttonLabel: 'Search'
3580
+ }
3581
+ };
3582
+ const defaultLocalizationContext = {
3583
+ locale: 'en-GB',
3584
+ texts: defaultLocalisationTexts,
3585
+ formatting: {
3586
+ date: 'dd.mm.yy'
3587
+ }
3588
+ };
3589
+ const LocalizationContext = /*#__PURE__*/React.createContext(defaultLocalizationContext);
3590
+ const LocalizationProvider = ({
3591
+ localization,
3592
+ children
3593
+ }) => {
3594
+ return /*#__PURE__*/React.createElement(LocalizationContext.Provider, {
3595
+ value: localization || defaultLocalizationContext
3596
+ }, children);
3597
+ };
3598
+ const useLocalization = () => React.useContext(LocalizationContext);
3599
+
3492
3600
  const Banner = /*#__PURE__*/React.forwardRef(function Banner(props, ref) {
3493
3601
  const {
3494
3602
  children,
3495
3603
  state,
3496
3604
  onClose
3497
3605
  } = props;
3606
+ const {
3607
+ texts
3608
+ } = useLocalization();
3498
3609
  const className = cn('bg-white relative flex items-center gap-2 py-2 px-4 leading-6 shadow-md z-10', props.className);
3499
3610
  return /*#__PURE__*/React.createElement("div", {
3500
3611
  className: className,
3501
3612
  "data-taco": "banner",
3502
3613
  ref: ref
3503
3614
  }, getBannerIcon(state), children, onClose ? /*#__PURE__*/React.createElement(IconButton, {
3615
+ "aria-label": texts.banner.close,
3504
3616
  className: "ml-auto -mr-2 self-start",
3505
3617
  icon: "close",
3506
3618
  appearance: "discrete",
@@ -3554,542 +3666,101 @@ const Button$1 = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
3554
3666
  }, button);
3555
3667
  });
3556
3668
 
3557
- function useTimer(duration = 0, callback) {
3558
- const timer = React.useRef();
3559
- const [tracker, setTracker] = React.useState({
3560
- remaining: duration,
3561
- started: null
3562
- });
3563
- React.useEffect(() => {
3564
- if (duration) {
3565
- if (tracker.started) {
3566
- timer.current = window.setTimeout(callback, tracker.remaining);
3567
- } else {
3568
- clearTimeout(timer.current);
3569
- }
3570
- }
3571
- return () => {
3572
- clearTimeout(timer.current);
3573
- };
3574
- }, [tracker.started]);
3575
- return {
3576
- running: !!tracker.started,
3577
- start: () => {
3578
- setTracker({
3579
- remaining: duration,
3580
- started: Date.now()
3581
- });
3582
- },
3583
- pause: () => {
3584
- if (tracker.started) {
3585
- setTracker({
3586
- remaining: tracker.remaining - (Date.now() - tracker.started),
3587
- started: null
3588
- });
3589
- }
3590
- },
3591
- resume: () => {
3592
- if (tracker.remaining && !tracker.started) {
3593
- setTracker({
3594
- remaining: tracker.remaining,
3595
- started: Date.now()
3596
- });
3669
+ const thisYear = /*#__PURE__*/new Date().getFullYear();
3670
+ const years = [];
3671
+ for (let i = thisYear - 10; i <= thisYear + 10; i += 1) {
3672
+ years.push(i);
3673
+ }
3674
+ const Navbar = /*#__PURE__*/React.memo(({
3675
+ onMonthChange,
3676
+ onNextClick,
3677
+ onPreviousClick,
3678
+ value = new Date()
3679
+ }) => {
3680
+ const {
3681
+ texts: {
3682
+ calendar: {
3683
+ actions,
3684
+ months
3597
3685
  }
3598
3686
  }
3687
+ } = useLocalization();
3688
+ const handleChange = function handleChange(event) {
3689
+ const {
3690
+ year,
3691
+ month
3692
+ } = event.target.form;
3693
+ onMonthChange(new Date(year.value, month.value));
3599
3694
  };
3600
- }
3601
-
3602
- const Spinner$1 = /*#__PURE__*/React__default.forwardRef(function Spinner(props, ref) {
3695
+ return /*#__PURE__*/React.createElement("div", {
3696
+ className: "mb-2 flex items-center justify-between"
3697
+ }, /*#__PURE__*/React.createElement("form", {
3698
+ className: "inline-flex space-x-1"
3699
+ }, /*#__PURE__*/React.createElement("select", {
3700
+ className: "h-8 px-2",
3701
+ name: "month",
3702
+ onChange: handleChange,
3703
+ value: value.getMonth()
3704
+ }, months.map((month, i) => /*#__PURE__*/React.createElement("option", {
3705
+ key: month,
3706
+ value: i
3707
+ }, month))), /*#__PURE__*/React.createElement("select", {
3708
+ className: "h-8 px-2",
3709
+ name: "year",
3710
+ onChange: handleChange,
3711
+ value: value.getFullYear()
3712
+ }, years.map(year => /*#__PURE__*/React.createElement("option", {
3713
+ key: year,
3714
+ value: year
3715
+ }, String(year))))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(IconButton, {
3716
+ appearance: "discrete",
3717
+ icon: "chevron-left",
3718
+ "aria-label": actions.previousMonth,
3719
+ onClick: () => onPreviousClick(),
3720
+ rounded: true
3721
+ }), /*#__PURE__*/React.createElement(IconButton, {
3722
+ appearance: "discrete",
3723
+ icon: "chevron-right",
3724
+ "aria-label": actions.nextMonth,
3725
+ onClick: () => onNextClick(),
3726
+ rounded: true
3727
+ })));
3728
+ });
3729
+ const Calendar$1 = /*#__PURE__*/React.forwardRef(function Calendar(props, ref) {
3603
3730
  const {
3604
- delay = 500,
3605
- label,
3731
+ onChange: handleChange,
3732
+ value,
3733
+ disabledDays,
3606
3734
  ...otherProps
3607
3735
  } = props;
3608
- const [visible, setVisibility] = React__default.useState(!delay);
3609
- React__default.useEffect(() => {
3610
- let timeout;
3611
- if (delay) {
3612
- timeout = window.setTimeout(() => setVisibility(true), delay);
3736
+ const {
3737
+ locale,
3738
+ texts
3739
+ } = useLocalization();
3740
+ const [visibleMonth, setVisibleMonth] = React.useState(value !== null && value !== void 0 ? value : new Date());
3741
+ React.useEffect(() => {
3742
+ if (visibleMonth !== value) {
3743
+ setVisibleMonth(value !== null && value !== void 0 ? value : new Date());
3613
3744
  }
3614
- return () => {
3615
- if (timeout) {
3616
- clearTimeout(timeout);
3617
- }
3618
- };
3619
- }, [delay]);
3620
- if (!visible) {
3621
- return null;
3622
- }
3623
- const className = cn('inline-flex flex-col relative items-center', otherProps.className);
3624
- return /*#__PURE__*/React__default.createElement("div", Object.assign({}, otherProps, {
3625
- className: className,
3626
- "data-taco": "spinner",
3627
- ref: ref
3628
- }), /*#__PURE__*/React__default.createElement("svg", {
3629
- className: "h-10 w-10 animate-[spinnerRotation_2s_linear_infinite]",
3630
- viewBox: "0 0 100 100",
3631
- xmlns: "http://www.w3.org/2000/svg"
3632
- }, /*#__PURE__*/React__default.createElement("circle", {
3633
- cx: "50",
3634
- cy: "50",
3635
- r: "45"
3636
- })), label && /*#__PURE__*/React__default.createElement("span", {
3637
- className: "mt-4"
3638
- }, label));
3639
- });
3640
-
3641
- const getBadgeIcon = type => {
3642
- const css = 'rounded-full flex-shrink-0 mr-2 mt-1 self-start';
3643
- switch (type) {
3644
- case 'success':
3645
- return /*#__PURE__*/React__default.createElement(Icon, {
3646
- name: "tick",
3647
- className: cn(css, 'yt-green-solid ')
3648
- });
3649
- case 'warning':
3650
- return /*#__PURE__*/React__default.createElement(Icon, {
3651
- name: "warning",
3652
- className: cn(css, 'yt-yellow-solid')
3653
- });
3654
- case 'error':
3655
- return /*#__PURE__*/React__default.createElement(Icon, {
3656
- name: "warning",
3657
- className: cn(css, 'yt-red-solid')
3658
- });
3659
- case 'information':
3660
- return /*#__PURE__*/React__default.createElement(Icon, {
3661
- name: "info",
3662
- className: cn(css, 'yt-blue-solid')
3663
- });
3664
- case 'loading':
3665
- return /*#__PURE__*/React__default.createElement(Spinner$1, {
3666
- delay: 0,
3667
- className: cn(css, 'h-6 w-6')
3668
- });
3669
- default:
3670
- return null;
3671
- }
3672
- };
3673
-
3674
- const Toast = ({
3675
- content,
3676
- lastUpdated,
3677
- onClose: handleClose,
3678
- options,
3679
- ...props
3680
- }) => {
3681
- const {
3682
- texts
3683
- } = useLocalization();
3684
- const {
3685
- autoClose,
3686
- type = 'default'
3687
- } = options;
3688
- const className = cn('bg-white relative flex items-center py-1 px-2 mt-3 w-full rounded yt-shadow', {
3689
- 'border border-grey': type === 'default' || type === 'loading' || !type,
3690
- 'border border-grey-darker': type === 'success',
3691
- 'border border-blue': type === 'information',
3692
- 'border border-yellow-dark': type === 'warning',
3693
- 'border border-red': type === 'error'
3694
- });
3695
- const timer = useTimer(autoClose, handleClose);
3696
- const controls = framerMotion.useAnimation();
3697
- if (!content) {
3698
- console.warn(`Toast requires 'content' property, which can't be empty string, null or undefined. Current content value is set to ${content === '' ? 'empty string' : content}.`);
3699
- }
3700
- React__default.useEffect(() => {
3701
- if (autoClose) {
3702
- timer.start();
3703
- }
3704
- }, [autoClose]);
3705
- const triggerUpdateAnimation = function () {
3706
- try {
3707
- return Promise.resolve(controls.start({
3708
- scale: 1.05
3709
- })).then(function () {
3710
- return Promise.resolve(controls.start({
3711
- scale: 1
3712
- })).then(function () {});
3713
- });
3714
- } catch (e) {
3715
- return Promise.reject(e);
3716
- }
3717
- };
3718
- React__default.useEffect(() => {
3719
- if (lastUpdated) {
3720
- triggerUpdateAnimation();
3721
- if (timer.running) {
3722
- timer.start();
3723
- }
3724
- }
3725
- }, [lastUpdated]);
3726
- return /*#__PURE__*/React__default.createElement(framerMotion.motion.div, Object.assign({}, props, {
3727
- animate: controls,
3728
- className: className,
3729
- "data-taco": "toast",
3730
- onMouseEnter: timer.pause,
3731
- onMouseLeave: timer.resume
3732
- }), getBadgeIcon(type), /*#__PURE__*/React__default.createElement("div", {
3733
- className: "flex-grow"
3734
- }, content), /*#__PURE__*/React__default.createElement(IconButton, {
3735
- appearance: "discrete",
3736
- className: "text-grey-darkest -mr-2 cursor-pointer self-start !px-0",
3737
- icon: "close",
3738
- "aria-label": texts.toasts.dismiss,
3739
- onClick: handleClose
3740
- }));
3741
- };
3742
-
3743
- const DEFAULT_AUTO_CLOSE_TIMEOUT = 7500;
3744
- const ToastContext = /*#__PURE__*/React.createContext({});
3745
- const insertToastWithoutDuplicates = (currentToasts, id, content, options, close) => {
3746
- const nextToasts = [...currentToasts];
3747
- const existingToastIndex = currentToasts.findIndex(toast => JSON.stringify(toast.content) === JSON.stringify(content));
3748
- if (existingToastIndex > -1) {
3749
- nextToasts[existingToastIndex].lastDuplicateId = id;
3750
- nextToasts[existingToastIndex].lastUpdated = Date.now();
3751
- } else {
3752
- nextToasts.push({
3753
- id,
3754
- content: typeof content === 'function' ? content(close) : content,
3755
- options
3756
- });
3757
- }
3758
- return nextToasts;
3759
- };
3760
- const ToastProvider = ({
3761
- children,
3762
- ...props
3763
- }) => {
3764
- const [toasts, setToasts] = React.useState([]);
3765
- const handleClose = id => {
3766
- setToasts(currentToasts => currentToasts.filter(toast => toast.id !== id));
3767
- };
3768
- // memoize (useCallback) this function,
3769
- // it is the value of the context provider and we don't want it to trigger state tree re-renders on provider children
3770
- const toaster = React.useCallback((content, options) => {
3771
- const id = uuid.v4();
3772
- const close = () => handleClose(id);
3773
- setToasts(currentToasts => insertToastWithoutDuplicates(currentToasts, id, content, options, close));
3774
- const update = (content, options) => {
3775
- setToasts(currentToasts => {
3776
- const nextToasts = currentToasts.filter(toast => {
3777
- if (toast.lastDuplicateId) {
3778
- return toast.lastDuplicateId !== id;
3779
- }
3780
- return toast.id !== id;
3781
- });
3782
- return insertToastWithoutDuplicates(nextToasts, uuid.v4(), content, options, close);
3783
- });
3784
- };
3785
- const success = (content, options) => {
3786
- update(content, {
3787
- autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT,
3788
- ...options,
3789
- type: 'success'
3790
- });
3791
- };
3792
- const error = (content, options) => {
3793
- update(content, {
3794
- ...options,
3795
- type: 'error'
3796
- });
3797
- };
3798
- const warning = (content, options) => {
3799
- update(content, {
3800
- ...options,
3801
- type: 'warning'
3802
- });
3803
- };
3804
- const information = (content, options) => {
3805
- update(content, {
3806
- ...options,
3807
- type: 'information'
3808
- });
3809
- };
3810
- const loading = (content, options) => {
3811
- update(content, {
3812
- ...options,
3813
- type: 'loading'
3814
- });
3815
- };
3816
- return {
3817
- success,
3818
- error,
3819
- warning,
3820
- information,
3821
- loading,
3822
- close
3823
- };
3824
- }, []);
3825
- // no need to rebind these every render, do them once in an effect
3826
- React.useEffect(() => {
3827
- toaster.success = (content, options) => toaster(content, {
3828
- autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT,
3829
- ...options,
3830
- type: 'success'
3831
- });
3832
- toaster.error = (content, options) => toaster(content, {
3833
- ...options,
3834
- type: 'error'
3835
- });
3836
- toaster.warning = (content, options) => toaster(content, {
3837
- ...options,
3838
- type: 'warning'
3839
- });
3840
- toaster.information = (content, options) => toaster(content, {
3841
- ...options,
3842
- type: 'information'
3843
- });
3844
- toaster.loading = (content, options) => toaster(content, {
3845
- ...options,
3846
- type: 'loading'
3847
- });
3848
- }, []);
3849
- return /*#__PURE__*/React.createElement(ToastContext.Provider, Object.assign({}, props, {
3850
- value: toaster
3851
- }), children, /*#__PURE__*/React.createElement("div", {
3852
- id: "yt-toast__container",
3853
- className: "pointer-events-all absolute bottom-0 right-0 !left-auto z-[1000] mb-4 mr-4 flex max-w-md flex-col items-end justify-end",
3854
- role: "log"
3855
- }, /*#__PURE__*/React.createElement(framerMotion.AnimatePresence, {
3856
- initial: false
3857
- }, toasts.map(toast => /*#__PURE__*/React.createElement(framerMotion.motion.div, {
3858
- key: toast.id,
3859
- transition: {
3860
- type: 'spring',
3861
- damping: 20,
3862
- stiffness: 300
3863
- },
3864
- initial: {
3865
- opacity: 0,
3866
- y: 10,
3867
- scale: 0.5
3868
- },
3869
- animate: {
3870
- opacity: 1,
3871
- y: 0,
3872
- scale: 1
3873
- },
3874
- exit: {
3875
- opacity: 0,
3876
- scale: 0.5,
3877
- transition: {
3878
- duration: 0.2
3879
- }
3880
- }
3881
- }, /*#__PURE__*/React.createElement(Toast, Object.assign({}, toast, {
3882
- onClose: () => handleClose(toast.id)
3883
- })))))));
3884
- };
3885
- const useToast = () => React.useContext(ToastContext);
3886
-
3887
- const defaultLocalisationTexts = {
3888
- calendar: {
3889
- months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
3890
- weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
3891
- actions: {
3892
- previousMonth: 'Previous month',
3893
- nextMonth: 'Next month',
3894
- previousYear: 'Previous year',
3895
- nextYear: 'Next year',
3896
- today: 'Today'
3897
- }
3898
- },
3899
- combobox: {
3900
- tooltip: 'Search in list'
3901
- },
3902
- datepicker: {
3903
- calendar: 'Calendar',
3904
- clear: 'Clear',
3905
- expand: 'Show calendar',
3906
- shortcuts: 'Shortcuts'
3907
- },
3908
- hanger: {
3909
- close: 'Close'
3910
- },
3911
- listbox: {
3912
- loading: 'Loading results...',
3913
- empty: 'No results found',
3914
- allOption: 'All'
3915
- },
3916
- dialog: {
3917
- close: 'Close',
3918
- drag: 'Drag'
3919
- },
3920
- pagination: {
3921
- label: 'Pagination',
3922
- pageSize: 'Items per page',
3923
- showingXofYofTotal: 'Showing [X] - [Y] of [total]',
3924
- actions: {
3925
- firstPage: 'Goto first page',
3926
- firstPageWithShortcut: 'Goto first page (Home)',
3927
- previousPage: 'Goto previous page',
3928
- previousPageWithShortcut: 'Goto previous page (Page Up)',
3929
- nextPage: 'Goto next page',
3930
- nextPageWithShortcut: 'Goto next page (Page Down)',
3931
- lastPage: 'Goto last page',
3932
- lastPageWithShortcut: 'Goto last page (End)',
3933
- pageX: 'Goto page [X]'
3934
- }
3935
- },
3936
- table: {
3937
- actions: 'Other actions',
3938
- edit: 'Edit (e)',
3939
- copy: 'Copy (c)',
3940
- del: 'Delete (del)',
3941
- newSubRow: 'New row (shift + n)',
3942
- loading: 'Loading...'
3943
- },
3944
- select: {
3945
- allOptionsSelected: 'All'
3946
- },
3947
- select2: {
3948
- allSelect: 'Select all',
3949
- allDeselect: 'Deselect all',
3950
- cancel: 'Cancel',
3951
- chooseColor: 'Pick a color',
3952
- create: 'Create',
3953
- delete: 'Delete',
3954
- save: 'Save',
3955
- search: 'Search...',
3956
- searchOrCreate: 'Search or create...'
3957
- },
3958
- toasts: {
3959
- dismiss: 'Dismiss'
3960
- },
3961
- tour: {
3962
- back: 'Back',
3963
- close: 'Close',
3964
- skip: 'Close and complete',
3965
- last: 'Done',
3966
- next: 'Next',
3967
- open: 'Open'
3968
- },
3969
- searchInput: {
3970
- inputLabel: 'Search...'
3971
- }
3972
- };
3973
- const defaultLocalizationContext = {
3974
- locale: 'en-GB',
3975
- texts: defaultLocalisationTexts,
3976
- formatting: {
3977
- date: 'dd.mm.yy'
3978
- }
3979
- };
3980
- const Context = /*#__PURE__*/React.createContext({
3981
- localization: defaultLocalizationContext
3982
- });
3983
- const Provider = props => {
3984
- const {
3985
- children,
3986
- localization = defaultLocalizationContext
3987
- } = props;
3988
- const value = React.useMemo(() => ({
3989
- localization
3990
- }), [localization]);
3991
- return /*#__PURE__*/React.createElement(Context.Provider, {
3992
- value: value
3993
- }, /*#__PURE__*/React.createElement(TooltipPrimitive.Provider, null, /*#__PURE__*/React.createElement(ToastProvider, null, children)));
3994
- };
3995
- const useTaco = () => React.useContext(Context);
3996
- const useLocalization = () => useTaco().localization;
3997
-
3998
- const thisYear = /*#__PURE__*/new Date().getFullYear();
3999
- const years = [];
4000
- for (let i = thisYear - 10; i <= thisYear + 10; i += 1) {
4001
- years.push(i);
4002
- }
4003
- const Navbar = /*#__PURE__*/React.memo(({
4004
- onMonthChange,
4005
- onNextClick,
4006
- onPreviousClick,
4007
- value = new Date()
4008
- }) => {
4009
- const {
4010
- texts: {
4011
- calendar: {
4012
- actions,
4013
- months
4014
- }
4015
- }
4016
- } = useLocalization();
4017
- const handleChange = function handleChange(event) {
4018
- const {
4019
- year,
4020
- month
4021
- } = event.target.form;
4022
- onMonthChange(new Date(year.value, month.value));
4023
- };
4024
- return /*#__PURE__*/React.createElement("div", {
4025
- className: "mb-2 flex items-center justify-between"
4026
- }, /*#__PURE__*/React.createElement("form", {
4027
- className: "inline-flex space-x-1"
4028
- }, /*#__PURE__*/React.createElement("select", {
4029
- className: "h-8 px-2",
4030
- name: "month",
4031
- onChange: handleChange,
4032
- value: value.getMonth()
4033
- }, months.map((month, i) => /*#__PURE__*/React.createElement("option", {
4034
- key: month,
4035
- value: i
4036
- }, month))), /*#__PURE__*/React.createElement("select", {
4037
- className: "h-8 px-2",
4038
- name: "year",
4039
- onChange: handleChange,
4040
- value: value.getFullYear()
4041
- }, years.map(year => /*#__PURE__*/React.createElement("option", {
4042
- key: year,
4043
- value: year
4044
- }, String(year))))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(IconButton, {
4045
- appearance: "discrete",
4046
- icon: "chevron-left",
4047
- "aria-label": actions.previousMonth,
4048
- onClick: () => onPreviousClick(),
4049
- rounded: true
4050
- }), /*#__PURE__*/React.createElement(IconButton, {
4051
- appearance: "discrete",
4052
- icon: "chevron-right",
4053
- "aria-label": actions.nextMonth,
4054
- onClick: () => onNextClick(),
4055
- rounded: true
4056
- })));
4057
- });
4058
- const Calendar$1 = /*#__PURE__*/React.forwardRef(function Calendar(props, ref) {
4059
- const {
4060
- onChange: handleChange,
4061
- value,
4062
- disabledDays,
4063
- ...otherProps
4064
- } = props;
4065
- const {
4066
- locale,
4067
- texts
4068
- } = useLocalization();
4069
- const [visibleMonth, setVisibleMonth] = React.useState(value !== null && value !== void 0 ? value : new Date());
4070
- React.useEffect(() => {
4071
- if (visibleMonth !== value) {
4072
- setVisibleMonth(value !== null && value !== void 0 ? value : new Date());
4073
- }
4074
- }, [value]);
4075
- const handleDayClick = (date, modifiers, event) => {
4076
- if (modifiers.outside || modifiers.disabled) {
4077
- return;
4078
- }
4079
- handleChange(date, event);
4080
- };
4081
- const handleCalendarClickToday = () => {
4082
- const today = new Date();
4083
- // set to midday to avoid UTC offset causing dates to be mismatched server side
4084
- today.setHours(12);
4085
- today.setMinutes(0);
4086
- today.setSeconds(0);
4087
- handleChange(today);
4088
- };
4089
- const className = cn('flex bg-white text-xs p-4', otherProps.className);
4090
- return /*#__PURE__*/React.createElement("div", {
4091
- "data-taco": "calendar"
4092
- }, /*#__PURE__*/React.createElement(ReactDayPicker, Object.assign({}, otherProps, {
3745
+ }, [value]);
3746
+ const handleDayClick = (date, modifiers, event) => {
3747
+ if (modifiers.outside || modifiers.disabled) {
3748
+ return;
3749
+ }
3750
+ handleChange(date, event);
3751
+ };
3752
+ const handleCalendarClickToday = () => {
3753
+ const today = new Date();
3754
+ // set to midday to avoid UTC offset causing dates to be mismatched server side
3755
+ today.setHours(12);
3756
+ today.setMinutes(0);
3757
+ today.setSeconds(0);
3758
+ handleChange(today);
3759
+ };
3760
+ const className = cn('flex bg-white text-xs p-4', otherProps.className);
3761
+ return /*#__PURE__*/React.createElement("div", {
3762
+ "data-taco": "calendar"
3763
+ }, /*#__PURE__*/React.createElement(ReactDayPicker, Object.assign({}, otherProps, {
4093
3764
  className: className,
4094
3765
  month: visibleMonth,
4095
3766
  selectedDays: value,
@@ -4149,6 +3820,11 @@ const Card = /*#__PURE__*/React.forwardRef(function Card(props, ref) {
4149
3820
  });
4150
3821
  Card.Content = Content$2;
4151
3822
 
3823
+ // React 18 has this built-in, when we upgrade this hook should be removed and the uuid dependency should be removed
3824
+ const useId = nativeId => {
3825
+ return React__default.useMemo(() => nativeId !== null && nativeId !== void 0 ? nativeId : uuid.v4(), []);
3826
+ };
3827
+
4152
3828
  const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4153
3829
  const {
4154
3830
  checked,
@@ -4159,6 +3835,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4159
3835
  onChange,
4160
3836
  ...otherProps
4161
3837
  } = props;
3838
+ const id = useId(props.id);
4162
3839
  const className = cn('bg-white h-5 w-5 border rounded text-sm flex-shrink-0 self-start mt-[0.1rem] focus:yt-focus',
4163
3840
  //hover:shadow-[0_0_0_1px_rgba(235,235,235,1)]
4164
3841
  props.className, {
@@ -4171,7 +3848,14 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4171
3848
  if (onChange) {
4172
3849
  handleChange = checked => onChange(checked === 'indeterminate' ? false : checked);
4173
3850
  }
4174
- const element = /*#__PURE__*/React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, {
3851
+ let labelledByProps = null;
3852
+ if (label) {
3853
+ labelledByProps = {
3854
+ ['aria-labelledby']: `${id}-label`,
3855
+ id
3856
+ };
3857
+ }
3858
+ const element = /*#__PURE__*/React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, labelledByProps, {
4175
3859
  "data-taco": "checkbox",
4176
3860
  checked: indeterminate ? 'indeterminate' : checked,
4177
3861
  className: className,
@@ -4184,12 +3868,15 @@ const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4184
3868
  className: "!h-full !w-full"
4185
3869
  })));
4186
3870
  if (label) {
4187
- const labelClassName = cn('flex items-center cursor-pointer gap-2', {
3871
+ const labelContainerClassName = cn('flex items-center cursor-pointer gap-2', {
4188
3872
  'cursor-not-allowed text-grey-dark': props.disabled
4189
3873
  }, props.className);
4190
- return /*#__PURE__*/React.createElement("label", {
4191
- className: labelClassName
4192
- }, element, label);
3874
+ return /*#__PURE__*/React.createElement("span", {
3875
+ className: labelContainerClassName
3876
+ }, element, /*#__PURE__*/React.createElement("label", {
3877
+ htmlFor: id,
3878
+ id: `${id}-label`
3879
+ }, label));
4193
3880
  }
4194
3881
  return element;
4195
3882
  });
@@ -4362,6 +4049,45 @@ const useListScrollTo = (internalRef, itemRefs) => {
4362
4049
  };
4363
4050
  };
4364
4051
 
4052
+ const Spinner$1 = /*#__PURE__*/React__default.forwardRef(function Spinner(props, ref) {
4053
+ const {
4054
+ delay = 500,
4055
+ label,
4056
+ ...otherProps
4057
+ } = props;
4058
+ const [visible, setVisibility] = React__default.useState(!delay);
4059
+ React__default.useEffect(() => {
4060
+ let timeout;
4061
+ if (delay) {
4062
+ timeout = window.setTimeout(() => setVisibility(true), delay);
4063
+ }
4064
+ return () => {
4065
+ if (timeout) {
4066
+ clearTimeout(timeout);
4067
+ }
4068
+ };
4069
+ }, [delay]);
4070
+ if (!visible) {
4071
+ return null;
4072
+ }
4073
+ const className = cn('inline-flex flex-col relative items-center', otherProps.className);
4074
+ return /*#__PURE__*/React__default.createElement("div", Object.assign({}, otherProps, {
4075
+ className: className,
4076
+ "data-taco": "spinner",
4077
+ ref: ref
4078
+ }), /*#__PURE__*/React__default.createElement("svg", {
4079
+ className: "h-10 w-10 animate-[spinnerRotation_2s_linear_infinite]",
4080
+ viewBox: "0 0 100 100",
4081
+ xmlns: "http://www.w3.org/2000/svg"
4082
+ }, /*#__PURE__*/React__default.createElement("circle", {
4083
+ cx: "50",
4084
+ cy: "50",
4085
+ r: "45"
4086
+ })), label && /*#__PURE__*/React__default.createElement("span", {
4087
+ className: "mt-4"
4088
+ }, label));
4089
+ });
4090
+
4365
4091
  const getId = (id, value) => `${id}_${value}`;
4366
4092
  const getNextEnabledItem = (event, data, index) => {
4367
4093
  const nextIndex = getNextIndexFromKey(event.key, data.length, index);
@@ -4452,22 +4178,6 @@ const ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(pro
4452
4178
  return selectedIndexes.findIndex(i => i === index) !== -1;
4453
4179
  }
4454
4180
  };
4455
- const list = {
4456
- ...otherProps,
4457
- className: cn('inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto', getInputClasses(props), {
4458
- 'yt-list--multiselect': multiselect,
4459
- 'pointer-events-none': disabled,
4460
- 'cursor-not-allowed': disabled || readOnly
4461
- }, otherProps.className),
4462
- disabled,
4463
- id,
4464
- onFocus: !disabled && !readOnly ? handleFocus : undefined,
4465
- onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,
4466
- readOnly,
4467
- ref: listRef,
4468
- role: 'listbox',
4469
- tabIndex: otherProps.tabIndex || 0
4470
- };
4471
4181
  const options = data.map((option, index) => {
4472
4182
  const depth = option.path ? option.path.split('.').length - 1 : 0;
4473
4183
  return {
@@ -4489,6 +4199,22 @@ const ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(pro
4489
4199
  } : undefined
4490
4200
  };
4491
4201
  });
4202
+ const list = {
4203
+ ...otherProps,
4204
+ className: cn('inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto', getInputClasses(props), {
4205
+ 'yt-list--multiselect': multiselect,
4206
+ 'pointer-events-none': disabled,
4207
+ 'cursor-not-allowed': disabled || readOnly
4208
+ }, otherProps.className),
4209
+ disabled,
4210
+ id,
4211
+ onFocus: !disabled && !readOnly ? handleFocus : undefined,
4212
+ onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,
4213
+ readOnly,
4214
+ ref: listRef,
4215
+ role: options.length <= 0 || loading ? 'presentation' : 'listbox',
4216
+ tabIndex: otherProps.tabIndex || 0
4217
+ };
4492
4218
  return /*#__PURE__*/React.createElement("ul", Object.assign({}, list, {
4493
4219
  "data-taco": "scrollable-list"
4494
4220
  }), loading ? /*#__PURE__*/React.createElement("li", {
@@ -4501,7 +4227,12 @@ const ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(pro
4501
4227
  ...optionProps
4502
4228
  }) => /*#__PURE__*/React.createElement("li", Object.assign({}, optionProps), icon, /*#__PURE__*/React.createElement("span", {
4503
4229
  className: "flex-grow truncate text-left"
4504
- }, children), multiselect && /*#__PURE__*/React.createElement(Checkbox, {
4230
+ }, children), multiselect && /*#__PURE__*/React.createElement(Checkbox
4231
+ // In multiselect variant, this checkbox only acts as visual representation of item being selected,
4232
+ // so need to be taken out of screen reader scope.
4233
+ , {
4234
+ "aria-hidden": true,
4235
+ tabIndex: -1,
4505
4236
  checked: optionProps['aria-selected'],
4506
4237
  onChange: () => null,
4507
4238
  className: "pointer-events-none ml-2 self-center p-px"
@@ -4997,7 +4728,11 @@ const Combobox = /*#__PURE__*/React.forwardRef(function Combobox(props, ref) {
4997
4728
  ref: ref
4998
4729
  }), /*#__PURE__*/React.createElement(Input, Object.assign({}, input, {
4999
4730
  autoComplete: "off",
5000
- button: props.inline ? /*#__PURE__*/React.createElement(IconButton, {
4731
+ button: props.inline ? /*#__PURE__*/React.createElement(IconButton
4732
+ // In case of inline combobox, this icon button acts only as visual chevron representation,
4733
+ // so should be taken out of screen reader scope.
4734
+ , {
4735
+ "aria-hidden": true,
5001
4736
  appearance: "discrete",
5002
4737
  className: "!border-l-0 focus:!border-none focus:!shadow-none active:!border-none",
5003
4738
  icon: popover.open ? 'chevron-up' : 'chevron-down',
@@ -5382,9 +5117,13 @@ const useDraggable = ref => {
5382
5117
  x: 0,
5383
5118
  y: 0
5384
5119
  });
5120
+ const [dragging, setDragging] = React__default.useState(false);
5385
5121
  const {
5386
5122
  moveProps
5387
5123
  } = interactions.useMove({
5124
+ onMoveStart() {
5125
+ setDragging(true);
5126
+ },
5388
5127
  onMove(event) {
5389
5128
  var _ref$current;
5390
5129
  const rect = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect();
@@ -5403,10 +5142,14 @@ const useDraggable = ref => {
5403
5142
  y
5404
5143
  };
5405
5144
  });
5145
+ },
5146
+ onMoveEnd() {
5147
+ setDragging(false);
5406
5148
  }
5407
5149
  });
5408
5150
  return {
5409
5151
  position,
5152
+ dragging,
5410
5153
  handleProps: moveProps
5411
5154
  };
5412
5155
  };
@@ -5453,6 +5196,7 @@ const Content$4 = /*#__PURE__*/React.forwardRef(function DialogContent(props, re
5453
5196
  const internalRef = useMergedRef(ref);
5454
5197
  const {
5455
5198
  position,
5199
+ dragging,
5456
5200
  handleProps: dragHandleProps
5457
5201
  } = useDraggable(internalRef);
5458
5202
  const {
@@ -5499,6 +5243,9 @@ const Content$4 = /*#__PURE__*/React.forwardRef(function DialogContent(props, re
5499
5243
  className: containerClassName,
5500
5244
  "data-taco": "dialog"
5501
5245
  }, output, dialog.draggable && /*#__PURE__*/React.createElement("div", Object.assign({}, dragHandleProps, {
5246
+ role: "button",
5247
+ draggable: true,
5248
+ "aria-grabbed": dragging,
5502
5249
  "aria-label": texts.dialog.drag,
5503
5250
  className: "yt-dialog__drag absolute-center-x bg-grey-light top-1.5 h-3 w-24 cursor-move rounded text-center"
5504
5251
  })), dialog.showCloseButton ? /*#__PURE__*/React.createElement(DialogPrimitive.Close, {
@@ -5847,6 +5594,7 @@ const SearchInput = /*#__PURE__*/React.forwardRef(function SearchInput({
5847
5594
  "aria-label": texts.searchInput.inputLabel
5848
5595
  }, props, {
5849
5596
  button: /*#__PURE__*/React.createElement(IconButton, {
5597
+ "aria-label": texts.searchInput.buttonLabel,
5850
5598
  icon: "search",
5851
5599
  className: "!border-transparent !bg-transparent focus:!border-transparent peer-focus:!border-transparent peer-focus:peer-active:!border-transparent",
5852
5600
  disabled: props.disabled,
@@ -5858,6 +5606,51 @@ const SearchInput = /*#__PURE__*/React.forwardRef(function SearchInput({
5858
5606
  }));
5859
5607
  });
5860
5608
 
5609
+ function useTimer(duration = 0, callback) {
5610
+ const timer = React.useRef();
5611
+ const [tracker, setTracker] = React.useState({
5612
+ remaining: duration,
5613
+ started: null
5614
+ });
5615
+ React.useEffect(() => {
5616
+ if (duration) {
5617
+ if (tracker.started) {
5618
+ timer.current = window.setTimeout(callback, tracker.remaining);
5619
+ } else {
5620
+ clearTimeout(timer.current);
5621
+ }
5622
+ }
5623
+ return () => {
5624
+ clearTimeout(timer.current);
5625
+ };
5626
+ }, [tracker.started]);
5627
+ return {
5628
+ running: !!tracker.started,
5629
+ start: () => {
5630
+ setTracker({
5631
+ remaining: duration,
5632
+ started: Date.now()
5633
+ });
5634
+ },
5635
+ pause: () => {
5636
+ if (tracker.started) {
5637
+ setTracker({
5638
+ remaining: tracker.remaining - (Date.now() - tracker.started),
5639
+ started: null
5640
+ });
5641
+ }
5642
+ },
5643
+ resume: () => {
5644
+ if (tracker.remaining && !tracker.started) {
5645
+ setTracker({
5646
+ remaining: tracker.remaining,
5647
+ started: Date.now()
5648
+ });
5649
+ }
5650
+ }
5651
+ };
5652
+ }
5653
+
5861
5654
  const useTypeahead = ({
5862
5655
  data,
5863
5656
  currentIndex
@@ -6224,17 +6017,18 @@ const Content$7 = /*#__PURE__*/React.forwardRef(function MenuContent(props, ref)
6224
6017
  const internalRef = useMergedRef(ref);
6225
6018
  const menu = useCurrentMenu();
6226
6019
  const {
6020
+ align = 'start',
6227
6021
  children,
6228
6022
  placement: side,
6229
6023
  ...otherProps
6230
6024
  } = props;
6231
- const className = cn('border rounded block outline-none p-1 wcag-white border-grey yt-shadow', props.className);
6025
+ const className = cn('border border-transparent rounded block outline-none p-1 yt-shadow wcag-white', props.className);
6232
6026
  return /*#__PURE__*/React.createElement(DropdownMenuPrimitive.Portal, null, /*#__PURE__*/React.createElement(DropdownMenuPrimitive.Content, Object.assign({}, otherProps, {
6233
- align: "start",
6027
+ align: align,
6234
6028
  className: className,
6235
6029
  "data-taco": "menu",
6236
6030
  side: side,
6237
- sideOffset: 2,
6031
+ sideOffset: 3,
6238
6032
  style: {
6239
6033
  minWidth: menu === null || menu === void 0 ? void 0 : menu.minWidth
6240
6034
  },
@@ -6553,12 +6347,21 @@ const Header = /*#__PURE__*/React.forwardRef(function MenuHeader(props, ref) {
6553
6347
  const Menu$1 = /*#__PURE__*/React.forwardRef(function Menu(externalProps, ref) {
6554
6348
  const {
6555
6349
  children,
6350
+ defaultOpen: defaultProp,
6351
+ onChange,
6352
+ open: prop,
6556
6353
  trigger,
6557
6354
  ...props
6558
6355
  } = externalProps;
6559
- const [open, setOpen] = React.useState(false);
6560
6356
  const [indented, setIndented] = React.useState(false);
6561
6357
  const [minWidth, setMinWidth] = React.useState(undefined);
6358
+ const [open, setOpen] = reactUseControllableState.useControllableState({
6359
+ // uncontrolled
6360
+ defaultProp,
6361
+ // controlled
6362
+ onChange,
6363
+ prop
6364
+ });
6562
6365
  const context = React.useMemo(() => ({
6563
6366
  indented,
6564
6367
  registerIndentation: () => setIndented(true),
@@ -6571,7 +6374,7 @@ const Menu$1 = /*#__PURE__*/React.forwardRef(function Menu(externalProps, ref) {
6571
6374
  }, /*#__PURE__*/React.createElement(DropdownMenuPrimitive.Root, Object.assign({}, props, {
6572
6375
  modal: false,
6573
6376
  open: open,
6574
- onOpenChange: setOpen
6377
+ onOpenChange: onChange
6575
6378
  }), trigger && /*#__PURE__*/React.createElement(Trigger$5, {
6576
6379
  ref: ref
6577
6380
  }, trigger), children));
@@ -7237,34 +7040,285 @@ const Pagination = /*#__PURE__*/React.forwardRef(function Pagination(props, ref)
7237
7040
  })));
7238
7041
  });
7239
7042
 
7240
- const Progress = ({
7241
- duration = undefined,
7043
+ const Progress = ({
7044
+ duration = undefined,
7045
+ ...props
7046
+ }) => {
7047
+ let style;
7048
+ if (duration) {
7049
+ style = {
7050
+ animationDuration: `${duration}ms`
7051
+ };
7052
+ }
7053
+ const className = cn('bg-grey-light rounded block h-1 overflow-hidden w-full', props.className);
7054
+ const progressClassName = cn('yt-progress__bar block h-1', {
7055
+ "w-full before:h-1 before:bg-grey-dark before:block before:animate-[progress-indeterminate_2s_cubic-bezier(0.4,0,0.2,1)_infinite] before:content-[' ']": !duration,
7056
+ [`w-0 bg-grey-dark animate-[progress_linear]`]: duration
7057
+ });
7058
+ return /*#__PURE__*/React__default.createElement("span", Object.assign({}, props, {
7059
+ "data-taco": "progress",
7060
+ className: className
7061
+ }), /*#__PURE__*/React__default.createElement("span", {
7062
+ className: progressClassName,
7063
+ "data-taco": "progress-bar",
7064
+ style: style
7065
+ }));
7066
+ };
7067
+
7068
+ const getBadgeIcon = type => {
7069
+ const css = 'rounded-full flex-shrink-0 mr-2 mt-1 self-start';
7070
+ switch (type) {
7071
+ case 'success':
7072
+ return /*#__PURE__*/React__default.createElement(Icon, {
7073
+ name: "tick",
7074
+ className: cn(css, 'yt-green-solid ')
7075
+ });
7076
+ case 'warning':
7077
+ return /*#__PURE__*/React__default.createElement(Icon, {
7078
+ name: "warning",
7079
+ className: cn(css, 'yt-yellow-solid')
7080
+ });
7081
+ case 'error':
7082
+ return /*#__PURE__*/React__default.createElement(Icon, {
7083
+ name: "warning",
7084
+ className: cn(css, 'yt-red-solid')
7085
+ });
7086
+ case 'information':
7087
+ return /*#__PURE__*/React__default.createElement(Icon, {
7088
+ name: "info",
7089
+ className: cn(css, 'yt-blue-solid')
7090
+ });
7091
+ case 'loading':
7092
+ return /*#__PURE__*/React__default.createElement(Spinner$1, {
7093
+ delay: 0,
7094
+ className: cn(css, 'h-6 w-6')
7095
+ });
7096
+ default:
7097
+ return null;
7098
+ }
7099
+ };
7100
+
7101
+ const Toast = ({
7102
+ content,
7103
+ lastUpdated,
7104
+ onClose: handleClose,
7105
+ options,
7106
+ ...props
7107
+ }) => {
7108
+ const {
7109
+ texts
7110
+ } = useLocalization();
7111
+ const {
7112
+ autoClose,
7113
+ type = 'default'
7114
+ } = options;
7115
+ const className = cn('bg-white relative flex items-center py-1 px-2 mt-3 w-full rounded yt-shadow', {
7116
+ 'border border-grey': type === 'default' || type === 'loading' || !type,
7117
+ 'border border-grey-darker': type === 'success',
7118
+ 'border border-blue': type === 'information',
7119
+ 'border border-yellow-dark': type === 'warning',
7120
+ 'border border-red': type === 'error'
7121
+ });
7122
+ const timer = useTimer(autoClose, handleClose);
7123
+ const controls = framerMotion.useAnimation();
7124
+ if (!content) {
7125
+ console.warn(`Toast requires 'content' property, which can't be empty string, null or undefined. Current content value is set to ${content === '' ? 'empty string' : content}.`);
7126
+ }
7127
+ React__default.useEffect(() => {
7128
+ if (autoClose) {
7129
+ timer.start();
7130
+ }
7131
+ }, [autoClose]);
7132
+ const triggerUpdateAnimation = function () {
7133
+ try {
7134
+ return Promise.resolve(controls.start({
7135
+ scale: 1.05
7136
+ })).then(function () {
7137
+ return Promise.resolve(controls.start({
7138
+ scale: 1
7139
+ })).then(function () {});
7140
+ });
7141
+ } catch (e) {
7142
+ return Promise.reject(e);
7143
+ }
7144
+ };
7145
+ React__default.useEffect(() => {
7146
+ if (lastUpdated) {
7147
+ triggerUpdateAnimation();
7148
+ if (timer.running) {
7149
+ timer.start();
7150
+ }
7151
+ }
7152
+ }, [lastUpdated]);
7153
+ return /*#__PURE__*/React__default.createElement(framerMotion.motion.div, Object.assign({}, props, {
7154
+ animate: controls,
7155
+ className: className,
7156
+ "data-taco": "toast",
7157
+ onMouseEnter: timer.pause,
7158
+ onMouseLeave: timer.resume
7159
+ }), getBadgeIcon(type), /*#__PURE__*/React__default.createElement("div", {
7160
+ className: "flex-grow"
7161
+ }, content), /*#__PURE__*/React__default.createElement(IconButton, {
7162
+ appearance: "discrete",
7163
+ className: "text-grey-darkest -mr-2 cursor-pointer self-start !px-0",
7164
+ icon: "close",
7165
+ "aria-label": texts.toasts.dismiss,
7166
+ onClick: handleClose
7167
+ }));
7168
+ };
7169
+
7170
+ const DEFAULT_AUTO_CLOSE_TIMEOUT = 7500;
7171
+ const ToastContext = /*#__PURE__*/React.createContext({});
7172
+ const insertToastWithoutDuplicates = (currentToasts, id, content, options, close) => {
7173
+ const nextToasts = [...currentToasts];
7174
+ const existingToastIndex = currentToasts.findIndex(toast => JSON.stringify(toast.content) === JSON.stringify(content));
7175
+ if (existingToastIndex > -1) {
7176
+ nextToasts[existingToastIndex].lastDuplicateId = id;
7177
+ nextToasts[existingToastIndex].lastUpdated = Date.now();
7178
+ } else {
7179
+ nextToasts.push({
7180
+ id,
7181
+ content: typeof content === 'function' ? content(close) : content,
7182
+ options
7183
+ });
7184
+ }
7185
+ return nextToasts;
7186
+ };
7187
+ const ToastProvider = ({
7188
+ children,
7242
7189
  ...props
7243
7190
  }) => {
7244
- let style;
7245
- if (duration) {
7246
- style = {
7247
- animationDuration: `${duration}ms`
7191
+ const [toasts, setToasts] = React.useState([]);
7192
+ const handleClose = id => {
7193
+ setToasts(currentToasts => currentToasts.filter(toast => toast.id !== id));
7194
+ };
7195
+ // memoize (useCallback) this function,
7196
+ // it is the value of the context provider and we don't want it to trigger state tree re-renders on provider children
7197
+ const toaster = React.useCallback((content, options) => {
7198
+ const id = uuid.v4();
7199
+ const close = () => handleClose(id);
7200
+ setToasts(currentToasts => insertToastWithoutDuplicates(currentToasts, id, content, options, close));
7201
+ const update = (content, options) => {
7202
+ setToasts(currentToasts => {
7203
+ const nextToasts = currentToasts.filter(toast => {
7204
+ if (toast.lastDuplicateId) {
7205
+ return toast.lastDuplicateId !== id;
7206
+ }
7207
+ return toast.id !== id;
7208
+ });
7209
+ return insertToastWithoutDuplicates(nextToasts, uuid.v4(), content, options, close);
7210
+ });
7248
7211
  };
7249
- }
7250
- const className = cn('bg-grey-light rounded block h-1 overflow-hidden w-full', props.className);
7251
- const progressClassName = cn('yt-progress__bar block h-1', {
7252
- "w-full before:h-1 before:bg-grey-dark before:block before:animate-[progress-indeterminate_2s_cubic-bezier(0.4,0,0.2,1)_infinite] before:content-[' ']": !duration,
7253
- [`w-0 bg-grey-dark animate-[progress_linear]`]: duration
7254
- });
7255
- return /*#__PURE__*/React__default.createElement("span", Object.assign({}, props, {
7256
- "data-taco": "progress",
7257
- className: className
7258
- }), /*#__PURE__*/React__default.createElement("span", {
7259
- className: progressClassName,
7260
- "data-taco": "progress-bar",
7261
- style: style
7262
- }));
7212
+ const success = (content, options) => {
7213
+ update(content, {
7214
+ autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT,
7215
+ ...options,
7216
+ type: 'success'
7217
+ });
7218
+ };
7219
+ const error = (content, options) => {
7220
+ update(content, {
7221
+ ...options,
7222
+ type: 'error'
7223
+ });
7224
+ };
7225
+ const warning = (content, options) => {
7226
+ update(content, {
7227
+ ...options,
7228
+ type: 'warning'
7229
+ });
7230
+ };
7231
+ const information = (content, options) => {
7232
+ update(content, {
7233
+ ...options,
7234
+ type: 'information'
7235
+ });
7236
+ };
7237
+ const loading = (content, options) => {
7238
+ update(content, {
7239
+ ...options,
7240
+ type: 'loading'
7241
+ });
7242
+ };
7243
+ return {
7244
+ success,
7245
+ error,
7246
+ warning,
7247
+ information,
7248
+ loading,
7249
+ close
7250
+ };
7251
+ }, []);
7252
+ // no need to rebind these every render, do them once in an effect
7253
+ React.useEffect(() => {
7254
+ toaster.success = (content, options) => toaster(content, {
7255
+ autoClose: DEFAULT_AUTO_CLOSE_TIMEOUT,
7256
+ ...options,
7257
+ type: 'success'
7258
+ });
7259
+ toaster.error = (content, options) => toaster(content, {
7260
+ ...options,
7261
+ type: 'error'
7262
+ });
7263
+ toaster.warning = (content, options) => toaster(content, {
7264
+ ...options,
7265
+ type: 'warning'
7266
+ });
7267
+ toaster.information = (content, options) => toaster(content, {
7268
+ ...options,
7269
+ type: 'information'
7270
+ });
7271
+ toaster.loading = (content, options) => toaster(content, {
7272
+ ...options,
7273
+ type: 'loading'
7274
+ });
7275
+ }, []);
7276
+ return /*#__PURE__*/React.createElement(ToastContext.Provider, Object.assign({}, props, {
7277
+ value: toaster
7278
+ }), children, /*#__PURE__*/React.createElement("div", {
7279
+ id: "yt-toast__container",
7280
+ className: "pointer-events-all absolute bottom-0 right-0 !left-auto z-[1000] mb-4 mr-4 flex max-w-md flex-col items-end justify-end",
7281
+ role: "log"
7282
+ }, /*#__PURE__*/React.createElement(framerMotion.AnimatePresence, {
7283
+ initial: false
7284
+ }, toasts.map(toast => /*#__PURE__*/React.createElement(framerMotion.motion.div, {
7285
+ key: toast.id,
7286
+ transition: {
7287
+ type: 'spring',
7288
+ damping: 20,
7289
+ stiffness: 300
7290
+ },
7291
+ initial: {
7292
+ opacity: 0,
7293
+ y: 10,
7294
+ scale: 0.5
7295
+ },
7296
+ animate: {
7297
+ opacity: 1,
7298
+ y: 0,
7299
+ scale: 1
7300
+ },
7301
+ exit: {
7302
+ opacity: 0,
7303
+ scale: 0.5,
7304
+ transition: {
7305
+ duration: 0.2
7306
+ }
7307
+ }
7308
+ }, /*#__PURE__*/React.createElement(Toast, Object.assign({}, toast, {
7309
+ onClose: () => handleClose(toast.id)
7310
+ })))))));
7263
7311
  };
7312
+ const useToast = () => React.useContext(ToastContext);
7264
7313
 
7265
- // React 18 has this built-in, when we upgrade this hook should be removed and the uuid dependency should be removed
7266
- const useId = nativeId => {
7267
- return React__default.useMemo(() => nativeId !== null && nativeId !== void 0 ? nativeId : uuid.v4(), []);
7314
+ const Provider = props => {
7315
+ const {
7316
+ children,
7317
+ localization
7318
+ } = props;
7319
+ return /*#__PURE__*/React.createElement(LocalizationProvider, {
7320
+ localization: localization
7321
+ }, /*#__PURE__*/React.createElement(TooltipPrimitive.Provider, null, /*#__PURE__*/React.createElement(ToastProvider, null, children)));
7268
7322
  };
7269
7323
 
7270
7324
  const isAriaSelectionKey = event => {
@@ -8007,7 +8061,7 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
8007
8061
  type: "button"
8008
8062
  }), children, /*#__PURE__*/React__default.createElement(Icon, {
8009
8063
  name: open ? 'chevron-up' : 'chevron-down',
8010
- className: "-mr-1 ml-auto"
8064
+ className: "pointer-events-none -mr-1 ml-auto"
8011
8065
  }));
8012
8066
  });
8013
8067
  const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSingle(props, ref) {
@@ -8058,22 +8112,12 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
8058
8112
  setValue,
8059
8113
  tags
8060
8114
  } = useSelect2Context();
8061
- const contentRef = React__default.useRef(null);
8062
- const createClickHandler = tagValue => event => {
8063
- event === null || event === void 0 ? void 0 : event.stopPropagation();
8064
- event === null || event === void 0 ? void 0 : event.preventDefault();
8065
- if (!disabled && !readOnly) {
8066
- setValue(tagValue);
8067
- }
8068
- };
8069
8115
  const valuesAsChildren = values.map(value => children.find(c => c.props.value === value));
8116
+ let content;
8117
+ let className = buttonProps.className;
8070
8118
  if (open) {
8071
- return /*#__PURE__*/React__default.createElement("span", {
8072
- className: "relative h-8"
8073
- }, /*#__PURE__*/React__default.createElement(Button$2, Object.assign({}, buttonProps, {
8074
- className: cn('absolute z-20', buttonProps.className),
8075
- ref: ref
8076
- }), /*#__PURE__*/React__default.createElement(ScrollArea, {
8119
+ className = cn('absolute z-20', buttonProps.className);
8120
+ content = /*#__PURE__*/React__default.createElement(ScrollArea, {
8077
8121
  className: "my-1 flex max-h-[5.5rem] flex-col"
8078
8122
  }, /*#__PURE__*/React__default.createElement("span", {
8079
8123
  className: "flex flex-wrap gap-1"
@@ -8083,18 +8127,54 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
8083
8127
  color: tags ? child.props.color : undefined,
8084
8128
  disabled: disabled,
8085
8129
  icon: child.props.icon,
8086
- onDelete: open ? createClickHandler(child.props.value) : undefined,
8130
+ onDelete: event => {
8131
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
8132
+ event === null || event === void 0 ? void 0 : event.preventDefault();
8133
+ if (!disabled && !readOnly) {
8134
+ setValue(child.props.value);
8135
+ }
8136
+ },
8087
8137
  readOnly: readOnly
8088
- }, child.props.children))))));
8138
+ }, child.props.children))));
8139
+ } else {
8140
+ content = /*#__PURE__*/React__default.createElement(MultipleValue, {
8141
+ key: String(open),
8142
+ valuesAsChildren: valuesAsChildren
8143
+ });
8089
8144
  }
8090
- const boundaryIndex = contentRef.current ? getIndexOfFirstChildOverflowingParent(contentRef.current, 30) : undefined;
8091
- return /*#__PURE__*/React__default.createElement(Button$2, Object.assign({}, buttonProps, {
8145
+ return /*#__PURE__*/React__default.createElement("span", {
8146
+ className: cn({
8147
+ 'relative h-8': open
8148
+ })
8149
+ }, /*#__PURE__*/React__default.createElement(Button$2, Object.assign({}, buttonProps, {
8150
+ className: className,
8092
8151
  ref: ref
8093
- }), /*#__PURE__*/React__default.createElement("span", {
8152
+ }), content));
8153
+ });
8154
+ const MultipleValue = ({
8155
+ valuesAsChildren
8156
+ }) => {
8157
+ const {
8158
+ disabled,
8159
+ open,
8160
+ readOnly,
8161
+ setValue,
8162
+ tags
8163
+ } = useSelect2Context();
8164
+ const [contentRef, setContentRef] = React__default.useState(null);
8165
+ const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;
8166
+ const createClickHandler = tagValue => event => {
8167
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
8168
+ event === null || event === void 0 ? void 0 : event.preventDefault();
8169
+ if (!disabled && !readOnly) {
8170
+ setValue(tagValue);
8171
+ }
8172
+ };
8173
+ return /*#__PURE__*/React__default.createElement("span", {
8094
8174
  className: "relative flex items-center gap-1 overflow-hidden"
8095
8175
  }, /*#__PURE__*/React__default.createElement("span", {
8096
8176
  className: "flex gap-1 truncate",
8097
- ref: contentRef
8177
+ ref: el => setContentRef(el)
8098
8178
  }, valuesAsChildren.map((child, index) => {
8099
8179
  const tag = /*#__PURE__*/React__default.createElement(Tag$1, {
8100
8180
  key: child.props.value,
@@ -8119,8 +8199,8 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
8119
8199
  title: valuesAsChildren.slice(boundaryIndex + 1).map(child => child ? String(child.props.children) : '').join(', ')
8120
8200
  }, /*#__PURE__*/React__default.createElement(Badge, {
8121
8201
  className: "flex-shrink-0"
8122
- }, "+", valuesAsChildren.length - (boundaryIndex + 1))) : null));
8123
- });
8202
+ }, "+", valuesAsChildren.length - (boundaryIndex + 1))) : null);
8203
+ };
8124
8204
  const matchesValue = value => child => {
8125
8205
  if (Array.isArray(value)) {
8126
8206
  return value.includes(child.props.value);
@@ -8270,14 +8350,15 @@ const useChildren = ({
8270
8350
  const [searchQuery, setSearchQuery] = React__default.useState('');
8271
8351
  // support empty value - probably a more elegant way to achieve this
8272
8352
  const allChildren = React__default.useMemo(() => {
8353
+ const initial = initialChildren || [];
8273
8354
  if (emptyValue !== undefined) {
8274
8355
  return [/*#__PURE__*/React__default.createElement(Option$1, {
8275
8356
  key: "__empty",
8276
8357
  children: "",
8277
8358
  value: emptyValue
8278
- }), ...initialChildren];
8359
+ }), ...initial];
8279
8360
  }
8280
- return initialChildren;
8361
+ return initial;
8281
8362
  }, [initialChildren, emptyValue]);
8282
8363
  // set an initial value if none is set, we have to trigger state updates for controlled components
8283
8364
  React__default.useEffect(() => {
@@ -8383,12 +8464,6 @@ const Collection = props => {
8383
8464
  const {
8384
8465
  children
8385
8466
  } = props;
8386
- if (!children.length) {
8387
- return /*#__PURE__*/React__default.createElement("div", {
8388
- className: "text-grey-darkest -mt-0.5 flex h-8 items-center px-2",
8389
- role: "presentation"
8390
- }, "No results found...");
8391
- }
8392
8467
  return /*#__PURE__*/React__default.createElement(ScrollArea, {
8393
8468
  className: "flex max-h-[10.25rem] w-full flex-col gap-y-0.5 px-1.5"
8394
8469
  }, children);
@@ -8498,8 +8573,7 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
8498
8573
  value: value
8499
8574
  }), /*#__PURE__*/React__default.createElement(PopoverPrimitive.Trigger, {
8500
8575
  asChild: true,
8501
- "data-taco": "Select2",
8502
- type: undefined
8576
+ "data-taco": "Select2"
8503
8577
  }, /*#__PURE__*/React__default.createElement(Trigger$6, Object.assign({}, otherProps, {
8504
8578
  "aria-haspopup": "listbox",
8505
8579
  children: allChildren,
@@ -8527,10 +8601,13 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
8527
8601
  style: {
8528
8602
  minWidth: dimensions !== null && dimensions !== void 0 && dimensions.width ? `${dimensions.width}px` : undefined
8529
8603
  }
8530
- }, !disableSearch ? /*#__PURE__*/React__default.createElement(Search$1, {
8604
+ }, !disableSearch && (allChildren.length > 0 || onCreate) ? /*#__PURE__*/React__default.createElement(Search$1, {
8531
8605
  placeholder: onCreate ? texts.select2.searchOrCreate : texts.select2.search,
8532
8606
  ref: searchRef
8533
- }) : null, /*#__PURE__*/React__default.createElement(Root$1, {
8607
+ }) : null, allChildren.length <= 0 ? /*#__PURE__*/React__default.createElement("div", {
8608
+ className: "text-grey-darkest -mt-0.5 flex h-8 items-center px-2",
8609
+ role: "presentation"
8610
+ }, "No results found...") : /*#__PURE__*/React__default.createElement(Root$1, {
8534
8611
  className: "flex flex-col gap-0.5",
8535
8612
  customSelector: ":scope > button",
8536
8613
  disabled: disabled,
@@ -9748,7 +9825,11 @@ const Table = /*#__PURE__*/React__default.forwardRef(function Table(props, ref)
9748
9825
  instance: instance,
9749
9826
  headerGroups: tableProps.headerGroups
9750
9827
  }));
9751
- }) : emptyStateRenderer()), paginationElement);
9828
+ }) : /*#__PURE__*/React__default.createElement("div", {
9829
+ role: "row"
9830
+ }, /*#__PURE__*/React__default.createElement("div", {
9831
+ role: "gridcell"
9832
+ }, emptyStateRenderer()))), paginationElement);
9752
9833
  });
9753
9834
  Table.Column = () => null;
9754
9835
  Table.Group = () => null;
@@ -10154,25 +10235,36 @@ const Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
10154
10235
  onChange,
10155
10236
  ...otherProps
10156
10237
  } = props;
10238
+ const id = useId(props.id);
10157
10239
  const className = cn('group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex', {
10158
10240
  'mr-2': !!label,
10159
10241
  'bg-grey-darker hover:bg-grey-dark aria-checked:bg-blue aria-checked:hover:bg-blue-light focus:yt-focus': !props.disabled,
10160
10242
  'bg-grey-light cursor-not-allowed aria-checked:bg-blue-light': props.disabled
10161
10243
  }, props.className);
10162
- const element = /*#__PURE__*/React.createElement(PrimitiveSwitch.Root, Object.assign({}, otherProps, {
10244
+ let labelledByProps = null;
10245
+ if (label) {
10246
+ labelledByProps = {
10247
+ ['aria-labelledby']: `${id}-label`,
10248
+ id
10249
+ };
10250
+ }
10251
+ const element = /*#__PURE__*/React.createElement(PrimitiveSwitch.Root, Object.assign({}, otherProps, labelledByProps, {
10163
10252
  className: className,
10164
10253
  onCheckedChange: onChange,
10165
10254
  ref: ref
10166
10255
  }), /*#__PURE__*/React.createElement(PrimitiveSwitch.Thumb, {
10167
- className: "'will-change-transform group-aria-checked:translate-x-[1.1rem] mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform group-disabled:opacity-50"
10256
+ className: "'will-change-transform mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]"
10168
10257
  }));
10169
10258
  if (label) {
10170
- const labelClassName = cn('flex self-start cursor-pointer', {
10259
+ const labelContainerClassName = cn('flex self-start cursor-pointer', {
10171
10260
  'cursor-not-allowed text-grey-dark': props.disabled
10172
10261
  });
10173
- return /*#__PURE__*/React.createElement("label", {
10174
- className: labelClassName
10175
- }, element, label);
10262
+ return /*#__PURE__*/React.createElement("span", {
10263
+ className: labelContainerClassName
10264
+ }, element, /*#__PURE__*/React.createElement("label", {
10265
+ htmlFor: id,
10266
+ id: `${id}-label`
10267
+ }, label));
10176
10268
  }
10177
10269
  return element;
10178
10270
  });
@@ -10344,6 +10436,8 @@ exports.Icon = Icon;
10344
10436
  exports.IconButton = IconButton;
10345
10437
  exports.Input = Input;
10346
10438
  exports.Listbox = Listbox;
10439
+ exports.LocalizationContext = LocalizationContext;
10440
+ exports.LocalizationProvider = LocalizationProvider;
10347
10441
  exports.Menu = Menu$1;
10348
10442
  exports.MultiListbox = MultiListbox;
10349
10443
  exports.Navigation = Navigation;
@@ -10395,6 +10489,5 @@ exports.useOnClickOutside = useOnClickOutside;
10395
10489
  exports.usePagination = usePagination;
10396
10490
  exports.useRadioGroup = useRadioGroup;
10397
10491
  exports.useTableRowCreation = useTableRowCreation;
10398
- exports.useTaco = useTaco;
10399
10492
  exports.useToast = useToast;
10400
10493
  //# sourceMappingURL=taco.cjs.development.js.map