@loadsmart/loadsmart-ui 5.16.0 → 5.17.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 (88) hide show
  1. package/dist/DragDropFile.context-0f0ede42.js +2 -0
  2. package/dist/DragDropFile.context-0f0ede42.js.map +1 -0
  3. package/dist/common/BackButton/BackButton.d.ts +0 -1
  4. package/dist/common/CloseButton/CloseButton.d.ts +0 -1
  5. package/dist/components/Accordion/Accordion.stories.d.ts +0 -1
  6. package/dist/components/Banner/Banner.stories.d.ts +0 -1
  7. package/dist/components/Button/Button.stories.d.ts +0 -1
  8. package/dist/components/Calendar/Calendar.d.ts +0 -1
  9. package/dist/components/Calendar/Calendar.stories.d.ts +0 -1
  10. package/dist/components/Calendar/DateFormat.helper.d.ts +4 -2
  11. package/dist/components/Calendar/PickerModeToggle.d.ts +0 -1
  12. package/dist/components/Calendar/Pickers/DayPicker.d.ts +0 -1
  13. package/dist/components/Calendar/Pickers/MonthPicker.d.ts +0 -1
  14. package/dist/components/Calendar/Pickers/YearPicker.d.ts +0 -1
  15. package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -1
  16. package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -1
  17. package/dist/components/DatePicker/DateRangePicker.d.ts +0 -1
  18. package/dist/components/DatePicker/DateRangePicker.stories.d.ts +0 -1
  19. package/dist/components/DatePicker/useDatePicker.d.ts +0 -2
  20. package/dist/components/DatePicker/useDateRangePicker.d.ts +0 -3
  21. package/dist/components/Dialog/Dialog.stories.d.ts +0 -1
  22. package/dist/components/DragDropFile/DragDropFile.d.ts +0 -1
  23. package/dist/components/DragDropFile/DragDropFile.stories.d.ts +0 -1
  24. package/dist/components/DragDropFile/components/Wrapper.d.ts +0 -1
  25. package/dist/components/DragDropFile/styles.d.ts +0 -1
  26. package/dist/components/EmptyState/EmptyState.stories.d.ts +0 -1
  27. package/dist/components/ErrorMessage/ErrorMessage.d.ts +0 -1
  28. package/dist/components/ErrorMessage/ErrorMessage.stories.d.ts +0 -1
  29. package/dist/components/Icon/Icon.d.ts +0 -1
  30. package/dist/components/IconFactory/IconFactory.d.ts +0 -1
  31. package/dist/components/Label/Label.stories.d.ts +0 -1
  32. package/dist/components/Layout/Layout.stories.d.ts +0 -1
  33. package/dist/components/Link/Link.stories.d.ts +0 -1
  34. package/dist/components/Loaders/LoadingDots.d.ts +0 -1
  35. package/dist/components/Loaders/Spinner.d.ts +0 -1
  36. package/dist/components/Modal/Modal.stories.d.ts +0 -1
  37. package/dist/components/Pagination/Pagination.d.ts +0 -1
  38. package/dist/components/Pagination/PaginationItem.d.ts +0 -1
  39. package/dist/components/ProgressBar/ProgressBar.stories.d.ts +0 -1
  40. package/dist/components/Radio/Radio.stories.d.ts +0 -1
  41. package/dist/components/Section/Sections.stories.d.ts +0 -1
  42. package/dist/components/Select/SelectCreatableOption.d.ts +0 -1
  43. package/dist/components/Select/SelectEmpty.d.ts +0 -1
  44. package/dist/components/Select/SelectOption.d.ts +0 -1
  45. package/dist/components/SideNavigation/Separator/Separator.d.ts +0 -1
  46. package/dist/components/SideNavigation/SideNavigation.stories.d.ts +0 -1
  47. package/dist/components/Steps/ProgressSteps/ProgressSteps.d.ts +0 -1
  48. package/dist/components/Table/Table.d.ts +0 -1
  49. package/dist/components/Table/Table.stories.d.ts +0 -1
  50. package/dist/components/Table/TableSortHandle.d.ts +0 -1
  51. package/dist/components/TablePagination/RowsPerPage.d.ts +0 -1
  52. package/dist/components/TablePagination/TablePagination.d.ts +0 -1
  53. package/dist/components/TablePagination/TablePaginationActions.d.ts +0 -1
  54. package/dist/components/Tabs/Tabs.stories.d.ts +0 -1
  55. package/dist/components/Tag/Tag.stories.d.ts +0 -1
  56. package/dist/components/TextField/TextField.stories.d.ts +0 -1
  57. package/dist/components/Textarea/Textarea.stories.d.ts +0 -1
  58. package/dist/components/Toast/Toast.stories.d.ts +0 -1
  59. package/dist/components/ToggleGroup/Toggle.d.ts +0 -1
  60. package/dist/components/ToggleGroup/ToggleGroup.d.ts +0 -1
  61. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -1
  62. package/dist/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.d.ts +0 -1
  63. package/dist/components/TopNavigation/TopNavigation.stories.d.ts +0 -1
  64. package/dist/components/VisuallyHidden/VisuallyHidden.stories.d.ts +0 -2
  65. package/dist/index.js +448 -448
  66. package/dist/index.js.map +1 -1
  67. package/dist/miranda-compatibility.theme-4cecc6cf.js +1 -1
  68. package/dist/miranda-compatibility.theme-4cecc6cf.js.map +1 -1
  69. package/dist/prop-a330029f.js.map +1 -1
  70. package/dist/testing/index.js +1 -1
  71. package/dist/testing/index.js.map +1 -1
  72. package/dist/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.d.ts +2 -1
  73. package/dist/theming/index.js.map +1 -1
  74. package/dist/toArray-b56541b4.js.map +1 -1
  75. package/dist/utils/toolset/getOrdinalSuffix.d.ts +1 -0
  76. package/dist/{addons/Theme/register.d.ts → utils/toolset/getOrdinalSuffix.test.d.ts} +0 -0
  77. package/dist/utils/toolset/highlightMatch.d.ts +0 -1
  78. package/package.json +218 -207
  79. package/src/components/Calendar/DateFormat.helper.test.ts +27 -0
  80. package/src/components/Calendar/DateFormat.helper.ts +41 -9
  81. package/src/components/Dropdown/Dropdown.test.tsx +4 -2
  82. package/src/components/Table/Table.test.tsx +2 -2
  83. package/src/components/TablePagination/TablePagination.test.tsx +2 -2
  84. package/src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx +2 -1
  85. package/src/utils/toolset/getOrdinalSuffix.test.ts +27 -0
  86. package/src/utils/toolset/getOrdinalSuffix.ts +15 -0
  87. package/dist/DragDropFile.context-cf460901.js +0 -16
  88. package/dist/DragDropFile.context-cf460901.js.map +0 -1
@@ -2,11 +2,18 @@ import { identity } from '@loadsmart/utils-function'
2
2
  import { padded } from './Date.helper'
3
3
 
4
4
  import type { CalendarDate } from './Date.helper'
5
+ import { getOrdinalSuffix } from 'utils/toolset/getOrdinalSuffix'
5
6
 
6
7
  export interface DateFormat {
7
8
  format(date: CalendarDate): string
8
9
  }
9
10
 
11
+ const getTokenValue = (date: CalendarDate, token: string) => {
12
+ const value = DEFAULT_FORMATTERS[token].format(date.get())
13
+
14
+ return (ADDITIONAL_FORMATTERS[token] || identity)(value)
15
+ }
16
+
10
17
  /**
11
18
  * This helpers provides a convenient layer on top of `Intl.DateTimeFormat`,
12
19
  * using common tokens (based on `momentjs`) to format dates.
@@ -17,11 +24,16 @@ export default function DateFormatHelper(format: string): DateFormat {
17
24
  return {
18
25
  format(date: CalendarDate) {
19
26
  return tokens
20
- .map((token) => {
27
+ .map((token, index) => {
28
+ const previousIndex = index - 1
29
+ const previousToken = tokens[previousIndex]
30
+
21
31
  if (token in DEFAULT_FORMATTERS) {
22
- const value = DEFAULT_FORMATTERS[token].format(date.get())
32
+ return getTokenValue(date, token)
33
+ }
23
34
 
24
- return (ADDITIONAL_FORMATTERS[token] || identity)(value)
35
+ if (token in COMPOUND_FORMATTERS && COMPOUND_FORMATTERS[token].valid(previousToken)) {
36
+ return COMPOUND_FORMATTERS[token].format(getTokenValue(date, previousToken))
25
37
  }
26
38
 
27
39
  return token
@@ -39,16 +51,18 @@ export default function DateFormatHelper(format: string): DateFormat {
39
51
  *| Month | MM | 01, 02, ..., 11, 12 |
40
52
  *| | MMM | Jan, Feb, ..., Nov, Dec |
41
53
  *| | MMMM | January, February, ..., November,December |
42
- *| Day of Month | DD | 01, 02, ..., 30, 31 |
54
+ *| Day of Month | D | 1, 2, ..., 30, 31 |
55
+ *| Day of Month with leading 0 | DD | 01, 02, ..., 30, 31 |
43
56
  *| Day of week | ddd | Sun, Mon, ... Fri, Sat |
44
57
  *| | dddd | Sunday, Monday, ..., Friday, Saturday |
45
58
  *| Year | YYYY | 1970, 1971, ..., 2029, 2030 |
46
59
  *| Hour | HH | 00, 01, ..., 22, 23 |
47
60
  *| | hh | 00, 01, ..., 11, 12 |
48
- *| Minute | mm | 01, 02, ..., 11, 12 |
61
+ *| Minute | mm | 01, 02, ..., 58, 59 |
49
62
  *| Seconds | ss | 01, 02, ..., 58, 59 |
50
63
  *| Post or ante meridiem | a | am, pm |
51
64
  *| | A | AM, PM |
65
+ *| Ordinal numbers | o | 1st, 2nd, 3rd, ..., 10th |
52
66
  *| Scaped sequence | [] | |
53
67
  *
54
68
  * @param format
@@ -56,7 +70,10 @@ export default function DateFormatHelper(format: string): DateFormat {
56
70
  */
57
71
  export function tokenizer(format: string): string[] {
58
72
  function getType(char?: string): string {
59
- if (char != undefined && ['M', 'd', 'D', 'Y', 'H', 'h', 'm', 's', 'A', 'a'].includes(char)) {
73
+ if (
74
+ char != undefined &&
75
+ ['M', 'd', 'D', 'Y', 'H', 'h', 'm', 's', 'A', 'a', 'o'].includes(char)
76
+ ) {
60
77
  return 'token'
61
78
  }
62
79
 
@@ -110,6 +127,9 @@ const DEFAULT_FORMATTERS: Record<string, Intl.DateTimeFormat> = {
110
127
  MMMM: new Intl.DateTimeFormat('en-US', {
111
128
  month: 'long',
112
129
  }),
130
+ D: new Intl.DateTimeFormat('en-US', {
131
+ day: 'numeric',
132
+ }),
113
133
  DD: new Intl.DateTimeFormat('en-US', {
114
134
  day: '2-digit',
115
135
  }),
@@ -154,10 +174,22 @@ const DEFAULT_FORMATTERS: Record<string, Intl.DateTimeFormat> = {
154
174
  * Padding, for example, is applied in some cases due to [this](https://bugs.chromium.org/p/chromium/issues/detail?id=527926) bug.
155
175
  */
156
176
  const ADDITIONAL_FORMATTERS: Record<string, (value: string) => string> = {
157
- hh: (value: string) => (value ? padded(value.split(' ')[0], 2) : value),
177
+ hh: (value: string) => (value ? padded(value.split(/\s/)[0], 2) : value),
158
178
  HH: (value: string) => (value ? padded(value, 2) : value),
159
179
  mm: (value: string) => (value ? padded(value, 2) : value),
160
180
  ss: (value: string) => (value ? padded(value, 2) : value),
161
- a: (value: string) => (value ? (value.split(' ')[1] || '').toLowerCase() : value),
162
- A: (value: string) => (value ? (value.split(' ')[1] || '').toUpperCase() : value),
181
+ a: (value: string) => (value ? (value.split(/\s/)[1] || '').toLowerCase() : value),
182
+ A: (value: string) => (value ? (value.split(/\s/)[1] || '').toUpperCase() : value),
183
+ }
184
+
185
+ type CompoundFormatter = {
186
+ valid: (token: string) => boolean
187
+ format: (value: string) => string
188
+ }
189
+
190
+ const COMPOUND_FORMATTERS: Record<string, CompoundFormatter> = {
191
+ o: {
192
+ valid: (token) => new Set(['D', 'DD']).has(token),
193
+ format: (value: string) => getOrdinalSuffix(parseInt(value, 10)),
194
+ },
163
195
  }
@@ -23,12 +23,14 @@ describe('Dropdown', () => {
23
23
  }
24
24
  })
25
25
 
26
- it('renders all options when expanded', () => {
26
+ it('renders all options when expanded', async () => {
27
27
  setup()
28
28
 
29
29
  user.click(screen.getByText('Actions'))
30
30
 
31
- for (let i = 0; i < ACTIONS.length; i++) {
31
+ expect(await screen.findByText(ACTIONS[0].label)).toBeInTheDocument()
32
+
33
+ for (let i = 1; i < ACTIONS.length; i++) {
32
34
  expect(screen.getByText(ACTIONS[i].label)).toBeInTheDocument()
33
35
  }
34
36
  })
@@ -53,7 +53,7 @@ describe('<Table />', () => {
53
53
  })
54
54
 
55
55
  describe('Column Picker', () => {
56
- it('should pick columns', () => {
56
+ it('should pick columns', async () => {
57
57
  const onChange = jest.fn()
58
58
  const OPTION_1 = { title: 'Title1', option: 'Option1', key: 'key1' }
59
59
  const OPTION_2 = { title: 'Title2', option: 'Option2', key: 'Key2' }
@@ -71,7 +71,7 @@ describe('<Table />', () => {
71
71
 
72
72
  user.click(screen.getByRole('button', { name: 'Pick a column' }))
73
73
 
74
- expect(screen.getAllByRole('option')).toHaveLength(2)
74
+ expect(await screen.findAllByRole('option')).toHaveLength(2)
75
75
 
76
76
  expect(screen.getByRole('option', { selected: true })).toHaveTextContent('Option1')
77
77
 
@@ -58,7 +58,7 @@ describe('TablePagination', () => {
58
58
  expect(onPageChange).toHaveBeenLastCalledWith(4)
59
59
  })
60
60
 
61
- it('calls the onRowsPerPageChange with the selected option', () => {
61
+ it('calls the onRowsPerPageChange with the selected option', async () => {
62
62
  const onPageChange = jest.fn()
63
63
  const onRowsPerPageChange = jest.fn()
64
64
  setup({
@@ -67,7 +67,7 @@ describe('TablePagination', () => {
67
67
  onRowsPerPageChange,
68
68
  })
69
69
  userEvent.click(screen.getByTestId('rows-per-page-button'))
70
- userEvent.click(screen.getByText(/50 per page/i))
70
+ userEvent.click(await screen.findByText(/50 per page/i))
71
71
 
72
72
  expect(onRowsPerPageChange).toHaveBeenLastCalledWith(50)
73
73
  })
@@ -1,5 +1,6 @@
1
1
  import React, { ReactNode } from 'react'
2
2
  import { render } from '@testing-library/react'
3
+ import type { RenderResult } from '@testing-library/react'
3
4
 
4
5
  import type { DragDropFileContextValue } from '../../components/DragDropFile/types'
5
6
  import { DragDropFileContext } from '../../components/DragDropFile/DragDropFile.context'
@@ -14,7 +15,7 @@ const defaultContextValueMock: DragDropFileContextValue = {
14
15
  const renderWithDragDropFileProvider = (
15
16
  ui: ReactNode,
16
17
  customContext?: Partial<DragDropFileContextValue>
17
- ) => {
18
+ ): RenderResult => {
18
19
  const contextValue = { ...defaultContextValueMock, ...customContext }
19
20
 
20
21
  const renderedUi = (children: ReactNode) => (
@@ -0,0 +1,27 @@
1
+ import { getOrdinalSuffix } from './getOrdinalSuffix'
2
+
3
+ it('should return "st" for numbers ending with 1', () => {
4
+ expect(getOrdinalSuffix(1)).toBe('st')
5
+ expect(getOrdinalSuffix(101)).toBe('st')
6
+ expect(getOrdinalSuffix(1001)).toBe('st')
7
+ })
8
+
9
+ it('should return "nd" for numbers ending with 2', () => {
10
+ expect(getOrdinalSuffix(2)).toBe('nd')
11
+ expect(getOrdinalSuffix(102)).toBe('nd')
12
+ expect(getOrdinalSuffix(1002)).toBe('nd')
13
+ })
14
+
15
+ it('should return "rd" for numbers ending with 3', () => {
16
+ expect(getOrdinalSuffix(3)).toBe('rd')
17
+ expect(getOrdinalSuffix(103)).toBe('rd')
18
+ expect(getOrdinalSuffix(1003)).toBe('rd')
19
+ })
20
+
21
+ it('should return "th" for 0 and numbers higher than 3 but not ending with 1, 2 or 3', () => {
22
+ expect(getOrdinalSuffix(0)).toBe('th')
23
+ expect(getOrdinalSuffix(4)).toBe('th')
24
+ expect(getOrdinalSuffix(10)).toBe('th')
25
+ expect(getOrdinalSuffix(100)).toBe('th')
26
+ expect(getOrdinalSuffix(1000)).toBe('th')
27
+ })
@@ -0,0 +1,15 @@
1
+ export const getOrdinalSuffix = (number: number): 'st' | 'nd' | 'rd' | 'th' => {
2
+ if (number % 10 === 1 && number !== 11) {
3
+ return 'st'
4
+ }
5
+
6
+ if (number % 10 === 2 && number !== 12) {
7
+ return 'nd'
8
+ }
9
+
10
+ if (number % 10 === 3 && number !== 13) {
11
+ return 'rd'
12
+ }
13
+
14
+ return 'th'
15
+ }
@@ -1,16 +0,0 @@
1
- "use strict";var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */function r(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e){return this instanceof o?(this.v=e,this):new o(e)}const i=e.createContext(void 0);exports.DragDropFileContext=i,exports.DragDropFileProvider=({fileList:t,onFilesAdded:r,onFileRemoved:o,onRetryUpload:a,children:u})=>{const c=e.useCallback(((e,n)=>{o([...t.slice(0,n),...t.slice(n+1)],e,n)}),[t]),l=e.useMemo((()=>({fileList:t,onFilesAdded:r,onRemoveFile:c,onRetryUpload:a})),[t,r,c,a]);return n.default.createElement(i.Provider,{value:l},u)},exports.__asyncGenerator=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),a=[];return r={},u("next"),u("throw"),u("return"),r[Symbol.asyncIterator]=function(){return this},r;function u(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){a.push([e,t,n,r])>1||c(e,t)}))})}function c(e,t){try{(n=i[e](t)).value instanceof o?Promise.resolve(n.value.v).then(l,s):f(a[0][2],n)}catch(e){f(a[0][3],e)}var n}function l(e){c("next",e)}function s(e){c("throw",e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}},exports.__asyncValues=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=r(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}},exports.__await=o,exports.__awaiter=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))},exports.__rest=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},exports.useDragDropFileContext=()=>{const t=e.useContext(i);if(!t)throw new Error("useDragDropFileContext must be used within an DragDropFileProvider");return t};
16
- //# sourceMappingURL=DragDropFile.context-cf460901.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DragDropFile.context-cf460901.js","sources":["../node_modules/tslib/tslib.es6.js","../src/components/DragDropFile/DragDropFile.context.tsx"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import React, { createContext, useContext, useCallback, useMemo } from 'react'\n\nimport type { DragDropFileContextValue, DragDropFileProviderProps, FileWithStatus } from './types'\n\nexport const DragDropFileContext = createContext<DragDropFileContextValue | undefined>(undefined)\n\nexport const DragDropFileProvider = ({\n fileList,\n onFilesAdded,\n onFileRemoved,\n onRetryUpload,\n children,\n}: DragDropFileProviderProps): JSX.Element => {\n const onRemoveFile = useCallback(\n (removedItem: FileWithStatus, index: number) => {\n onFileRemoved([...fileList.slice(0, index), ...fileList.slice(index + 1)], removedItem, index)\n },\n [fileList]\n )\n\n const contextValue = useMemo(() => ({ fileList, onFilesAdded, onRemoveFile, onRetryUpload }), [\n fileList,\n onFilesAdded,\n onRemoveFile,\n onRetryUpload,\n ])\n\n return (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n}\n\nexport const useDragDropFileContext = (): DragDropFileContextValue => {\n const context = useContext(DragDropFileContext)\n\n if (!context) {\n throw new Error('useDragDropFileContext must be used within an DragDropFileProvider')\n }\n\n return context\n}\n"],"names":["__values","o","s","Symbol","iterator","m","i","call","length","next","value","done","TypeError","__await","v","this","DragDropFileContext","createContext","undefined","fileList","onFilesAdded","onFileRemoved","onRetryUpload","children","onRemoveFile","useCallback","removedItem","index","slice","contextValue","useMemo","React","Provider","thisArg","_arguments","generator","asyncIterator","g","apply","q","verb","n","Promise","a","b","push","resume","r","resolve","then","fulfill","reject","settle","e","f","shift","d","P","fulfilled","step","rejected","result","t","p","Object","prototype","hasOwnProperty","indexOf","getOwnPropertySymbols","propertyIsEnumerable","context","useContext","Error"],"mappings":";;;;;;;;;;;;;;gFAuHO,SAASA,EAASC,GACrB,IAAIC,EAAsB,mBAAXC,QAAyBA,OAAOC,SAAUC,EAAIH,GAAKD,EAAEC,GAAII,EAAI,EAC5E,GAAID,EAAG,OAAOA,EAAEE,KAAKN,GACrB,GAAIA,GAAyB,iBAAbA,EAAEO,OAAqB,MAAO,CAC1CC,KAAM,WAEF,OADIR,GAAKK,GAAKL,EAAEO,SAAQP,OAAI,GACrB,CAAES,MAAOT,GAAKA,EAAEK,KAAMK,MAAOV,KAG5C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