@loadsmart/loadsmart-ui 6.1.3 → 6.2.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.
- package/dist/DragDropFile.context-bbb7d631.js +2 -0
- package/dist/DragDropFile.context-bbb7d631.js.map +1 -0
- package/dist/components/Select/Select.fixtures.d.ts +9 -0
- package/dist/components/Select/Select.stories.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +5 -5
- package/dist/components/Table/Table.types.d.ts +6 -1
- package/dist/index.js +122 -104
- package/dist/index.js.map +1 -1
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/src/components/Select/Select.fixtures.ts +24 -0
- package/src/components/Select/Select.stories.tsx +38 -1
- package/src/components/Select/useSelect.ts +32 -16
- package/src/components/Table/Table.stories.tsx +6 -8
- package/src/components/Table/Table.test.tsx +2 -5
- package/src/components/Table/Table.tsx +66 -20
- package/src/components/Table/Table.types.ts +8 -1
- package/dist/DragDropFile.context-c7cd1441.js +0 -2
- package/dist/DragDropFile.context-c7cd1441.js.map +0 -1
package/dist/testing/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../DragDropFile.context-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../DragDropFile.context-bbb7d631.js"),t=require("@testing-library/react"),i=require("../toArray-b56541b4.js"),n=require("../miranda-compatibility.theme-22a9ce26.js"),r=require("react");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@loadsmart/miranda-tokens");var c=o(r);function a(e){return e.parentNode.parentNode.parentNode.parentNode}function d(i){return e.__awaiter(this,void 0,void 0,(function*(){const n=a(i);t.queries.queryByRole(n,"menu")||(yield t.act((()=>e.__awaiter(this,void 0,void 0,(function*(){t.fireEvent.click(i),expect(yield t.queries.findByRole(n,"menu")).toBeInTheDocument()})))))}))}function u(i){return e.__awaiter(this,void 0,void 0,(function*(){const n=a(i);t.queries.queryByRole(n,"menu")&&(yield t.act((()=>e.__awaiter(this,void 0,void 0,(function*(){t.fireEvent.click(t.queries.getByText(n,"Close")),yield t.waitForElementToBeRemoved((()=>t.queries.queryByRole(n,"menu")))})))))}))}const l={getContainer:a,expand:d,collapse:u,pick:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){const r=a(n);yield d(n),yield t.act((()=>e.__awaiter(this,void 0,void 0,(function*(){n.focus();const e=t.queries.getByLabelText(r,i);e&&"false"==e.getAttribute("aria-checked")&&t.fireEvent.click(e)})))),yield u(n)}))},clear:function(i){return e.__awaiter(this,void 0,void 0,(function*(){const n=a(i);yield t.act((()=>e.__awaiter(this,void 0,void 0,(function*(){const e=t.queries.getByLabelText(n,"Clear selection");t.fireEvent.click(e)})))),yield u(i)}))},getSelectedDates:function(i){return e.__awaiter(this,void 0,void 0,(function*(){const e=a(i);yield d(i);const n=t.queries.queryAllByRole(e,"checkbox",{checked:!0});return yield u(i),n}))}};function s(t){return e.__awaiter(this,void 0,void 0,(function*(){yield l.expand(t)}))}function f(t){return e.__awaiter(this,void 0,void 0,(function*(){yield l.collapse(t)}))}const v={getContainer:l.getContainer,expand:s,collapse:f,pick:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){const e=l.getContainer(n);yield s(n);const[r,o]=i;if(null!=r){const i=t.queries.getByTestId(e,"input-date-range-start");yield l.pick(r,i)}if(null!=o){const i=t.queries.getByTestId(e,"input-date-range-end");yield l.pick(o,i)}yield f(n)}))},clear:function(t){return e.__awaiter(this,void 0,void 0,(function*(){yield l.clear(t)}))},getSelectedDates:function(t){return e.__awaiter(this,void 0,void 0,(function*(){return l.getSelectedDates(t)}))}},y=e=>e.parentNode,p={dragOver:e=>{const i=y(e),n=t.createEvent.dragOver(i);t.fireEvent(i,n)},dragLeave:e=>{const i=y(e),n=t.createEvent.dragLeave(i);t.fireEvent(i,n)},dropFiles:(e,n)=>{const r=y(e),o=t.createEvent.drop(r);Object.defineProperty(o,"dataTransfer",{value:{files:i.toArray(n)}}),t.fireEvent(r,o)}};function _(e){return e.parentNode.parentNode.parentNode}function h(e){return e.parentNode.parentNode.nextSibling}function g(e){return e.parentNode.nextSibling.nextSibling}function w(e){return e.parentNode}function b(e){return 3===_(e).children.length}function x(i){return e.__awaiter(this,void 0,void 0,(function*(){const e=w(i);t.within(e).queryByTestId("select-trigger-loading")&&(yield t.waitForElementToBeRemoved((()=>t.within(e).queryByTestId("select-trigger-loading")),{timeout:2500}))}))}function E(i){return e.__awaiter(this,void 0,void 0,(function*(){if(yield x(i),b(i))return;const n=g(i);yield t.waitFor((()=>{expect(n).toBeEnabled()})),t.act((()=>{i.dispatchEvent(new MouseEvent("click",{bubbles:!0}))})),yield t.waitFor((()=>e.__awaiter(this,void 0,void 0,(function*(){expect(yield t.within(_(i)).findByRole("listbox")).toBeInTheDocument()}))))}))}function B(i){return e.__awaiter(this,void 0,void 0,(function*(){if(!b(i))return;const e=g(i);t.fireEvent.click(e),yield t.waitFor((()=>{expect(t.within(_(i)).queryByRole("listbox")).not.toBeInTheDocument()}))}))}const q={select:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){yield E(n);const e=h(n),r=yield t.within(e).findByLabelText(i);r&&"false"==r.getAttribute("aria-selected")&&(t.fireEvent.mouseDown(r),t.act((()=>{r.focus()})),t.fireEvent.mouseUp(r),t.fireEvent.click(r)),yield B(n)}))},unselect:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){yield E(n);const e=h(n),r=yield t.within(e).findByLabelText(i);r&&"true"===r.getAttribute("aria-selected")&&t.fireEvent.click(r),yield B(n)}))},clear:function(i){return e.__awaiter(this,void 0,void 0,(function*(){yield x(i);const e=w(i),n=t.within(e).getByTestId("select-trigger-clear");n&&t.fireEvent.click(n)}))},search:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){t.fireEvent.change(n,{target:{value:i}}),yield x(n);const e=h(n);yield t.within(e).findAllByRole("option")}))},expand:E,collapse:B,getOptions:function(i){return e.__awaiter(this,void 0,void 0,(function*(){yield E(i);const e=h(i),n=t.within(e).queryAllByRole("option");return yield B(i),n}))},getSelectedOptions:function(i){return e.__awaiter(this,void 0,void 0,(function*(){yield E(i);const e=h(i);let n=[];try{n=yield t.within(e).findAllByRole("option",{selected:!0})}catch(e){n=[]}return yield B(i),n}))},isMenuExpanded:b};const m={fileList:[],onFilesAdded:jest.fn(),onRetryUpload:jest.fn(),onRemoveFile:jest.fn()};exports.DatePickerEvent=l,exports.DateRangePickerEvent=v,exports.DragDropFileEvent=p,exports.SelectEvent=q,exports.getInterpolatedStyles=function(e){return i.toArray(e).map((e=>{for(;n.isFunction(e);)e=e({theme:n.alice});return e})).join("")},exports.renderWithDragDropFileProvider=(i,n)=>{const r=Object.assign(Object.assign({},m),n);return t.render((o=i,c.default.createElement(e.DragDropFileContext.Provider,{value:r},o)));var o};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -14,6 +14,8 @@ export type User = {
|
|
|
14
14
|
name: string
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export type Customer = User
|
|
18
|
+
|
|
17
19
|
export const SelectableKeyTypeOptions: { label: string; value: SelectableKeyType }[] = [
|
|
18
20
|
{ label: 'Boolean(true)', value: true },
|
|
19
21
|
{ label: 'Boolean(false)', value: false },
|
|
@@ -107,6 +109,7 @@ function generateSelectOptions() {
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
export const USERS = generateSelectOptions()
|
|
112
|
+
export const CUSTOMERS = generateSelectOptions()
|
|
110
113
|
|
|
111
114
|
export function useSyncFruits(): SelectDatasource<{ label: string; value: string }> {
|
|
112
115
|
return {
|
|
@@ -141,3 +144,24 @@ export function useAsyncUsers(): SelectDatasource<{ uuid: string; name: string }
|
|
|
141
144
|
},
|
|
142
145
|
}
|
|
143
146
|
}
|
|
147
|
+
|
|
148
|
+
export function useAsyncCustomers(): SelectDatasource<{ uuid: string; name: string }> {
|
|
149
|
+
return {
|
|
150
|
+
type: 'customer',
|
|
151
|
+
adapter: {
|
|
152
|
+
getKey: (user) => user.uuid,
|
|
153
|
+
getLabel: (user) => user.name,
|
|
154
|
+
},
|
|
155
|
+
async fetch({ regex, query }) {
|
|
156
|
+
if (query.length < 3) {
|
|
157
|
+
return CUSTOMERS
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return new Promise((resolve) => {
|
|
161
|
+
setTimeout(() => {
|
|
162
|
+
resolve(CUSTOMERS.filter(({ name }) => regex.test(name)))
|
|
163
|
+
}, 500)
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -7,7 +7,16 @@ import { Text } from 'components/Text'
|
|
|
7
7
|
import { HighlightMatch } from 'components/HighlightMatch'
|
|
8
8
|
import { Select } from 'components/Select'
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useSyncFruits,
|
|
12
|
+
useAsyncUsers,
|
|
13
|
+
useAsyncCustomers,
|
|
14
|
+
FRUITS,
|
|
15
|
+
USERS,
|
|
16
|
+
CUSTOMERS,
|
|
17
|
+
Fruit,
|
|
18
|
+
User,
|
|
19
|
+
} from './Select.fixtures'
|
|
11
20
|
|
|
12
21
|
import type {
|
|
13
22
|
Option,
|
|
@@ -345,6 +354,34 @@ MultiMixedDatasource.args = {
|
|
|
345
354
|
multiple: true,
|
|
346
355
|
}
|
|
347
356
|
|
|
357
|
+
const VARIOUS_ASYNC_DATASOURCES = [useAsyncUsers, useAsyncCustomers]
|
|
358
|
+
export const VariousAsyncDatasources: Story<SelectProps> = (args: SelectProps) => {
|
|
359
|
+
return (
|
|
360
|
+
<div className="flex flex-col space-y-4">
|
|
361
|
+
<div className="flex flex-row space-x-4" style={{ width: 720 }}>
|
|
362
|
+
<div className="flex-1">
|
|
363
|
+
<Label htmlFor="select-multi-async">Select the beneficiary</Label>
|
|
364
|
+
<Select
|
|
365
|
+
placeholder="Select async datasources"
|
|
366
|
+
{...omit(args, OMITTED_PROPS)}
|
|
367
|
+
id="select-multi-async"
|
|
368
|
+
name="select-multi-async"
|
|
369
|
+
datasources={VARIOUS_ASYNC_DATASOURCES}
|
|
370
|
+
/>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
<div className="text-sm" style={{ width: 720 }}>
|
|
374
|
+
<p>Available options:</p>
|
|
375
|
+
<code>{[...USERS, ...CUSTOMERS].map(({ name }) => name).join(', ')}</code>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
VariousAsyncDatasources.args = {
|
|
382
|
+
multiple: false,
|
|
383
|
+
}
|
|
384
|
+
|
|
348
385
|
const MixedCustomOption = ({ value }: SelectOptionProps) => {
|
|
349
386
|
const select = useSelect()
|
|
350
387
|
const option = select.getOption(value) || {}
|
|
@@ -34,24 +34,41 @@ import type {
|
|
|
34
34
|
useSelectReturn,
|
|
35
35
|
} from './Select.types'
|
|
36
36
|
|
|
37
|
-
async function
|
|
37
|
+
async function getData(datasources: SelectDatasource<any>[], query: string) {
|
|
38
38
|
const regex = new RegExp(escapeRegExp(query), 'i')
|
|
39
39
|
|
|
40
|
+
const promises = []
|
|
41
|
+
const types: string[] = []
|
|
42
|
+
|
|
40
43
|
for (const ds of datasources) {
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
promises.push(Promise.resolve(ds.fetch({ query, regex })))
|
|
45
|
+
types.push(ds.type)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// We use Promise.allSettled here because Promise.all rejects as soon as one promise fails
|
|
49
|
+
// But we want to continue with the next datasource when one fails.
|
|
50
|
+
const results = await Promise.allSettled(promises)
|
|
51
|
+
|
|
52
|
+
let items: Option[] = []
|
|
53
|
+
|
|
54
|
+
results.forEach((result, index) => {
|
|
55
|
+
if (result.status === 'rejected') {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
const type = types[index]
|
|
60
|
+
|
|
61
|
+
items = items.concat(
|
|
62
|
+
(result.value || []).map((item) => {
|
|
46
63
|
return {
|
|
47
64
|
...item,
|
|
48
|
-
_type:
|
|
65
|
+
_type: type,
|
|
49
66
|
} as Option
|
|
50
67
|
})
|
|
68
|
+
)
|
|
69
|
+
})
|
|
51
70
|
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
71
|
+
return items
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
function getDatasources(props: SelectProps) {
|
|
@@ -96,15 +113,15 @@ function TriggerOnFocusHandler(e: FocusEvent<HTMLInputElement>) {
|
|
|
96
113
|
e.target.select()
|
|
97
114
|
}
|
|
98
115
|
|
|
99
|
-
function mapOptions(items: Option[],
|
|
100
|
-
const
|
|
116
|
+
function mapOptions(items: Option[], adapters: Adapters) {
|
|
117
|
+
const options = new Map<SelectableKeyType, Option>()
|
|
101
118
|
|
|
102
119
|
items.forEach((item) => {
|
|
103
120
|
const adapter = getAdapter(adapters, item._type)
|
|
104
|
-
|
|
121
|
+
options.set(adapter.getKey(item), item)
|
|
105
122
|
})
|
|
106
123
|
|
|
107
|
-
return
|
|
124
|
+
return options
|
|
108
125
|
}
|
|
109
126
|
|
|
110
127
|
function useOptions<T = any>(props: { datasources: SelectDatasource<T>[]; adapters: Adapters }) {
|
|
@@ -135,10 +152,9 @@ function useOptions<T = any>(props: { datasources: SelectDatasource<T>[]; adapte
|
|
|
135
152
|
setOptions(new Map<SelectableKeyType, Option>())
|
|
136
153
|
setStatus('querying')
|
|
137
154
|
|
|
138
|
-
|
|
139
|
-
setOptions((options) => mapOptions(items, options, adapters))
|
|
140
|
-
}
|
|
155
|
+
const items = await getData(datasources, query)
|
|
141
156
|
|
|
157
|
+
setOptions(mapOptions(items, adapters))
|
|
142
158
|
setStatus('queried')
|
|
143
159
|
}
|
|
144
160
|
|
|
@@ -522,15 +522,14 @@ export function WithExpandableRow(args: TableProps): JSX.Element {
|
|
|
522
522
|
<Table.Head>
|
|
523
523
|
<Table.Row>
|
|
524
524
|
<Table.Expandable.HeadCell />
|
|
525
|
-
<Table.Expandable.HeadCell>
|
|
526
|
-
<Table.Expandable.HeadCell>
|
|
527
|
-
<Table.Expandable.HeadCell>
|
|
525
|
+
<Table.Expandable.HeadCell>reference</Table.Expandable.HeadCell>
|
|
526
|
+
<Table.Expandable.HeadCell>product</Table.Expandable.HeadCell>
|
|
527
|
+
<Table.Expandable.HeadCell>price</Table.Expandable.HeadCell>
|
|
528
528
|
</Table.Row>
|
|
529
529
|
</Table.Head>
|
|
530
530
|
|
|
531
|
-
<Table.Body>
|
|
531
|
+
<Table.Body withExpandableRows>
|
|
532
532
|
<Table.Expandable.Row
|
|
533
|
-
index={0}
|
|
534
533
|
leading={leading}
|
|
535
534
|
expandableContent={<div>Forced expanded with custom leading</div>}
|
|
536
535
|
expanded
|
|
@@ -540,7 +539,6 @@ export function WithExpandableRow(args: TableProps): JSX.Element {
|
|
|
540
539
|
<Table.Expandable.Cell>12345</Table.Expandable.Cell>
|
|
541
540
|
</Table.Expandable.Row>
|
|
542
541
|
<Table.Expandable.Row
|
|
543
|
-
index={1}
|
|
544
542
|
leading={leading}
|
|
545
543
|
expandableContent={<div>Initial expanded row with custom leading</div>}
|
|
546
544
|
initialExpanded
|
|
@@ -549,12 +547,12 @@ export function WithExpandableRow(args: TableProps): JSX.Element {
|
|
|
549
547
|
<Table.Expandable.Cell>Body 2</Table.Expandable.Cell>
|
|
550
548
|
<Table.Expandable.Cell>12345</Table.Expandable.Cell>
|
|
551
549
|
</Table.Expandable.Row>
|
|
552
|
-
<Table.Expandable.Row
|
|
550
|
+
<Table.Expandable.Row expandableContent={<div>Expandable row</div>}>
|
|
553
551
|
<Table.Expandable.Cell>123456</Table.Expandable.Cell>
|
|
554
552
|
<Table.Expandable.Cell>Body 3</Table.Expandable.Cell>
|
|
555
553
|
<Table.Expandable.Cell>12345</Table.Expandable.Cell>
|
|
556
554
|
</Table.Expandable.Row>
|
|
557
|
-
<Table.Expandable.Row
|
|
555
|
+
<Table.Expandable.Row expanded>
|
|
558
556
|
<Table.Expandable.Cell>123456</Table.Expandable.Cell>
|
|
559
557
|
<Table.Expandable.Cell>Body 5</Table.Expandable.Cell>
|
|
560
558
|
<Table.Expandable.Cell>12345</Table.Expandable.Cell>
|
|
@@ -196,9 +196,8 @@ describe('<Table />', () => {
|
|
|
196
196
|
<Table.HeadCell alignment="right">Price $</Table.HeadCell>
|
|
197
197
|
</Table.Row>
|
|
198
198
|
</Table.Head>
|
|
199
|
-
<Table.Body>
|
|
199
|
+
<Table.Body withExpandableRows>
|
|
200
200
|
<Table.Expandable.Row
|
|
201
|
-
index={0}
|
|
202
201
|
expandableContent={<div>This is an expandable content on index 0</div>}
|
|
203
202
|
expanded
|
|
204
203
|
>
|
|
@@ -208,7 +207,7 @@ describe('<Table />', () => {
|
|
|
208
207
|
$9876,50
|
|
209
208
|
</Table.Cell>
|
|
210
209
|
</Table.Expandable.Row>
|
|
211
|
-
<Table.Expandable.Row
|
|
210
|
+
<Table.Expandable.Row>
|
|
212
211
|
<Table.Cell format="number">#000000-2</Table.Cell>
|
|
213
212
|
<Table.Cell>Modal X 21</Table.Cell>
|
|
214
213
|
<Table.Cell format="currency" alignment="right">
|
|
@@ -216,7 +215,6 @@ describe('<Table />', () => {
|
|
|
216
215
|
</Table.Cell>
|
|
217
216
|
</Table.Expandable.Row>
|
|
218
217
|
<Table.Expandable.Row
|
|
219
|
-
index={2}
|
|
220
218
|
expandableContent={<div>This is an expandable content on index 2</div>}
|
|
221
219
|
leading={(expanded) => (expanded ? 'open' : 'closed')}
|
|
222
220
|
onExpandedChange={onExpandedChange}
|
|
@@ -228,7 +226,6 @@ describe('<Table />', () => {
|
|
|
228
226
|
</Table.Cell>
|
|
229
227
|
</Table.Expandable.Row>
|
|
230
228
|
<Table.Expandable.Row
|
|
231
|
-
index={3}
|
|
232
229
|
expandableContent={<div>This is an expandable content on index 3</div>}
|
|
233
230
|
expanded={controlledExpanded4}
|
|
234
231
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children, Fragment, isValidElement,
|
|
1
|
+
import React, { Children, Fragment, isValidElement, useEffect, useState } from 'react'
|
|
2
2
|
import styled, { css } from 'styled-components'
|
|
3
3
|
import type { ReactNode } from 'react'
|
|
4
4
|
import { isFunction } from '@loadsmart/utils-function'
|
|
@@ -36,10 +36,15 @@ import type {
|
|
|
36
36
|
TablePickerItemProps,
|
|
37
37
|
TablePickerProps,
|
|
38
38
|
ExpandableTableRowProps,
|
|
39
|
+
TableBodyProps,
|
|
40
|
+
TableHeadCellProps,
|
|
39
41
|
} from './Table.types'
|
|
40
42
|
|
|
41
|
-
const StyledTableBody = styled.tbody
|
|
42
|
-
|
|
43
|
+
const StyledTableBody = styled.tbody<{ $withExpandableRows?: boolean }>`
|
|
44
|
+
background-color: ${conditional({
|
|
45
|
+
'color-neutral-lightest': whenProps({ $withExpandableRows: true }),
|
|
46
|
+
initial: whenProps({ $withExpandableRows: false }),
|
|
47
|
+
})};
|
|
43
48
|
`
|
|
44
49
|
|
|
45
50
|
const StyledTableFoot = styled.tfoot`
|
|
@@ -79,14 +84,21 @@ const StyledTableCell = styled.td<{ alignment?: string; format?: string }>`
|
|
|
79
84
|
})};
|
|
80
85
|
`
|
|
81
86
|
|
|
82
|
-
const StyledTableHeadCell = styled.th<{
|
|
87
|
+
const StyledTableHeadCell = styled.th<{
|
|
88
|
+
alignment?: string
|
|
89
|
+
clickable: boolean
|
|
90
|
+
capitalized?: boolean
|
|
91
|
+
}>`
|
|
83
92
|
${StyledCell}
|
|
84
93
|
|
|
85
94
|
font-family: ${token('font-family-default')};
|
|
86
95
|
|
|
87
96
|
font-weight: ${token('font-weight-bold')};
|
|
88
97
|
|
|
89
|
-
text-transform:
|
|
98
|
+
text-transform: ${conditional({
|
|
99
|
+
uppercase: whenProps({ capitalized: false }),
|
|
100
|
+
capitalize: whenProps({ capitalized: true }),
|
|
101
|
+
})};
|
|
90
102
|
|
|
91
103
|
cursor: ${conditional({
|
|
92
104
|
pointer: whenProps({ clickable: true }),
|
|
@@ -140,11 +152,36 @@ const StyledTableRow = styled(BaseStyledTableRow)<{ selected?: boolean }>`
|
|
|
140
152
|
}
|
|
141
153
|
`
|
|
142
154
|
|
|
143
|
-
const StyledExpandableTableRow = styled
|
|
144
|
-
background-color: ${
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
const StyledExpandableTableRow = styled.tr<{ $isExpanded: boolean }>`
|
|
156
|
+
background-color: ${token('color-neutral-white')};
|
|
157
|
+
|
|
158
|
+
border-color: ${token('color-neutral-light')};
|
|
159
|
+
border-width: 1px;
|
|
160
|
+
border-style: ${conditional({
|
|
161
|
+
solid: whenProps({ $isExpanded: false }),
|
|
162
|
+
'hidden solid': whenProps({ $isExpanded: true }),
|
|
147
163
|
})};
|
|
164
|
+
|
|
165
|
+
box-shadow: ${conditional({
|
|
166
|
+
'0px 4px 8px 3px rgba(32, 42, 49, 0.15), 0px 1px 3px 0px rgba(94, 118, 138, 0.20)': whenProps({
|
|
167
|
+
$isExpanded: true,
|
|
168
|
+
}),
|
|
169
|
+
none: whenProps({ $isExpanded: false }),
|
|
170
|
+
})};
|
|
171
|
+
|
|
172
|
+
${hoverable`
|
|
173
|
+
background-color: ${token('table-row-variant-color')};
|
|
174
|
+
`}
|
|
175
|
+
|
|
176
|
+
${focusable`
|
|
177
|
+
box-shadow: inset ${token('shadow-glow-primary')};
|
|
178
|
+
`}
|
|
179
|
+
`
|
|
180
|
+
|
|
181
|
+
const StyledExpandableContentRow = styled.tr`
|
|
182
|
+
border-color: ${token('color-neutral-light')};
|
|
183
|
+
border-width: 1px;
|
|
184
|
+
border-style: hidden solid;
|
|
148
185
|
`
|
|
149
186
|
|
|
150
187
|
const StyledTable = styled.table<{ scale?: string }>`
|
|
@@ -221,8 +258,16 @@ function TableHead({ children, ...others }: TableSectionProps): JSX.Element {
|
|
|
221
258
|
return <StyledTableHead {...others}>{children}</StyledTableHead>
|
|
222
259
|
}
|
|
223
260
|
|
|
224
|
-
function TableBody({
|
|
225
|
-
|
|
261
|
+
function TableBody({
|
|
262
|
+
children,
|
|
263
|
+
withExpandableRows = false,
|
|
264
|
+
...others
|
|
265
|
+
}: TableBodyProps): JSX.Element {
|
|
266
|
+
return (
|
|
267
|
+
<StyledTableBody {...others} $withExpandableRows={withExpandableRows}>
|
|
268
|
+
{children}
|
|
269
|
+
</StyledTableBody>
|
|
270
|
+
)
|
|
226
271
|
}
|
|
227
272
|
|
|
228
273
|
function TableCell({
|
|
@@ -288,8 +333,8 @@ function SelectionHeadCell<T>(props: SelectionCellProps<T>): JSX.Element {
|
|
|
288
333
|
)
|
|
289
334
|
}
|
|
290
335
|
|
|
291
|
-
function ExpandableHeadCell(props:
|
|
292
|
-
return <TableHeadCell {...props} />
|
|
336
|
+
function ExpandableHeadCell(props: TableHeadCellProps): JSX.Element {
|
|
337
|
+
return <TableHeadCell capitalized {...props} />
|
|
293
338
|
}
|
|
294
339
|
|
|
295
340
|
function ExpandableCell(props: TableCellProps): JSX.Element {
|
|
@@ -307,7 +352,6 @@ function TableRow({ children, ...others }: TableRowProps): JSX.Element {
|
|
|
307
352
|
}
|
|
308
353
|
|
|
309
354
|
function ExpandableTableRow({
|
|
310
|
-
index,
|
|
311
355
|
expandableContent,
|
|
312
356
|
expanded,
|
|
313
357
|
leading: propsLeading,
|
|
@@ -319,8 +363,8 @@ function ExpandableTableRow({
|
|
|
319
363
|
const [openState, setOpenState] = useState(initialExpanded)
|
|
320
364
|
|
|
321
365
|
const open = expanded ?? openState
|
|
366
|
+
const isExpanded = Boolean(open && expandableContent)
|
|
322
367
|
const colSpan = Array.isArray(children) ? children.length + 1 : 1
|
|
323
|
-
const isEven = index % 2 === 0
|
|
324
368
|
|
|
325
369
|
let leading: ReactNode = <RotatableIcon name="caret-right" $rotate={open} />
|
|
326
370
|
if (propsLeading) {
|
|
@@ -336,14 +380,14 @@ function ExpandableTableRow({
|
|
|
336
380
|
|
|
337
381
|
return (
|
|
338
382
|
<>
|
|
339
|
-
<StyledExpandableTableRow {...others} onClick={toggle} $
|
|
383
|
+
<StyledExpandableTableRow {...others} onClick={toggle} $isExpanded={isExpanded}>
|
|
340
384
|
<ExpandableCell>{expandableContent && leading}</ExpandableCell>
|
|
341
385
|
{children}
|
|
342
386
|
</StyledExpandableTableRow>
|
|
343
|
-
{
|
|
344
|
-
<
|
|
387
|
+
{isExpanded && (
|
|
388
|
+
<StyledExpandableContentRow>
|
|
345
389
|
<StyledTableCell colSpan={colSpan}>{expandableContent}</StyledTableCell>
|
|
346
|
-
</
|
|
390
|
+
</StyledExpandableContentRow>
|
|
347
391
|
)}
|
|
348
392
|
</>
|
|
349
393
|
)
|
|
@@ -353,13 +397,15 @@ function TableHeadCell({
|
|
|
353
397
|
alignment = 'left',
|
|
354
398
|
children,
|
|
355
399
|
onClick,
|
|
400
|
+
capitalized = false,
|
|
356
401
|
...others
|
|
357
|
-
}:
|
|
402
|
+
}: TableHeadCellProps): JSX.Element {
|
|
358
403
|
return (
|
|
359
404
|
<StyledTableHeadCell
|
|
360
405
|
clickable={onClick != null}
|
|
361
406
|
alignment={alignment}
|
|
362
407
|
onClick={onClick}
|
|
408
|
+
capitalized={capitalized}
|
|
363
409
|
{...others}
|
|
364
410
|
>
|
|
365
411
|
<Layout.Group space="xs" align="center">
|
|
@@ -38,10 +38,13 @@ export interface TableSectionProps extends HTMLAttributes<HTMLTableSectionElemen
|
|
|
38
38
|
scale?: Scale
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export interface TableBodyProps extends TableSectionProps {
|
|
42
|
+
withExpandableRows?: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
export type TableRowProps = HTMLAttributes<HTMLTableRowElement>
|
|
42
46
|
|
|
43
47
|
export type ExpandableTableRowProps = TableRowProps & {
|
|
44
|
-
index: number
|
|
45
48
|
expandableContent?: ReactNode
|
|
46
49
|
leading?: ReactNode | ((expanded: boolean) => ReactNode)
|
|
47
50
|
initialExpanded?: boolean
|
|
@@ -57,6 +60,10 @@ export interface TableCellProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
|
57
60
|
selected?: boolean
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
export interface TableHeadCellProps extends TableCellProps {
|
|
64
|
+
capitalized?: boolean
|
|
65
|
+
}
|
|
66
|
+
|
|
60
67
|
export type TableColumn<T = Record<string, unknown>> = {
|
|
61
68
|
/**
|
|
62
69
|
* The accessor of you entry interface
|
|
@@ -1,2 +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);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};
|
|
2
|
-
//# sourceMappingURL=DragDropFile.context-c7cd1441.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropFile.context-c7cd1441.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 __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\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 (g && (g = 0, op[0] && (_ = 0)), _) 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 var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\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, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\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: false } : 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\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport default {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __createBinding,\r\n __exportStar,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n __classPrivateFieldIn,\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(\n () => ({ fileList, onFilesAdded, onRemoveFile, onRetryUpload }),\n [fileList, onFilesAdded, onRemoveFile, 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","createElement","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":"uHAwKO,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,OA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