@loadsmart/loadsmart-ui 8.0.6 → 8.1.0-beta.1
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.js +29 -0
- package/dist/DragDropFile.context.js.map +1 -0
- package/dist/components/Banner/Banner.d.ts +2 -3
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Calendar/Pickers/PickerButton.d.ts +1 -2
- package/dist/components/Card/Card.d.ts +3 -3
- package/dist/components/Card/CardTitle.d.ts +3 -2
- package/dist/components/DatePicker/DatePicker.d.ts +1 -2
- package/dist/components/Dialog/Dialog.d.ts +3 -3
- package/dist/components/DragDropFile/styles.d.ts +8 -10
- package/dist/components/Dropdown/Dropdown.d.ts +3 -3
- package/dist/components/Dropdown/DropdownMenu.d.ts +5 -4
- package/dist/components/Layout/Layout.utils.d.ts +2 -3
- package/dist/components/Layout/Stack.d.ts +3 -3
- package/dist/components/Loaders/LoadingBar.d.ts +3 -3
- package/dist/components/Modal/Modal.d.ts +1 -1
- package/dist/components/SideNavigation/Logo/Logo.d.ts +2 -2
- package/dist/components/SideNavigation/Menu/Menu.d.ts +4 -4
- package/dist/components/SideNavigation/Menu/MenuLink.d.ts +3 -2
- package/dist/components/SideNavigation/SideNavigation.d.ts +4 -4
- package/dist/components/Steps/StepsStep.d.ts +3 -2
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/TablePagination/TablePagination.styles.d.ts +1 -2
- package/dist/components/TablePagination/TablePaginationActions.d.ts +1 -2
- package/dist/components/Text/Text.d.ts +3 -3
- package/dist/components/TextField/TextField.d.ts +8 -3
- package/dist/components/ToggleGroup/Toggle.d.ts +3 -2
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +1 -1
- package/dist/components/TopNavigation/Logo/Logo.d.ts +2 -2
- package/dist/components/TopNavigation/Menu/Menu.d.ts +1 -1
- package/dist/components/TopNavigation/Menu/MenuItemDropdown.d.ts +5 -4
- package/dist/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.d.ts +2 -2
- package/dist/components/TopNavigation/TopNavigation.d.ts +2 -2
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +4 -2
- package/dist/index.js +7545 -8177
- package/dist/index.js.map +1 -1
- package/dist/styles/font.d.ts +3 -3
- package/dist/styles/typography.d.ts +2 -2
- package/dist/testing/index.js +318 -219
- package/dist/testing/index.js.map +1 -1
- package/dist/themes.js +2322 -0
- package/dist/themes.js.map +1 -0
- package/dist/theming/index.js +10 -18
- package/dist/theming/index.js.map +1 -1
- package/dist/toArray.js +16 -0
- package/dist/toArray.js.map +1 -0
- package/dist/tools/index.js +2 -7
- package/dist/tools/vite-plugin-replace-jsx-runtime.d.ts +7 -0
- package/dist/tools.js +98 -0
- package/dist/tools.js.map +1 -0
- package/package.json +20 -6
- package/dist/DragDropFile.context-oKnUu6d3.js +0 -33
- package/dist/DragDropFile.context-oKnUu6d3.js.map +0 -1
- package/dist/miranda-compatibility.theme-CIu9fa89.js +0 -2528
- package/dist/miranda-compatibility.theme-CIu9fa89.js.map +0 -1
- package/dist/prop-Fs2axl9W.js +0 -75
- package/dist/prop-Fs2axl9W.js.map +0 -1
- package/dist/toArray-BJJzFRD1.js +0 -13
- package/dist/toArray-BJJzFRD1.js.map +0 -1
- package/dist/tools/index.js.map +0 -1
package/dist/tools.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { get_default } from "./themes.js";
|
|
2
|
+
import { getToken } from "./theming/index.js";
|
|
3
|
+
import { toArray } from "./toArray.js";
|
|
4
|
+
import { isFunction } from "@loadsmart/utils-function";
|
|
5
|
+
import { isObject } from "@loadsmart/utils-object";
|
|
6
|
+
//#region src/tools/conditional.ts
|
|
7
|
+
/**
|
|
8
|
+
* Utility to generate style/class name conditions based on a components props.
|
|
9
|
+
* Expected prop values can be a single value, an array of values or a function/callback.
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* whenProps({
|
|
13
|
+
* 'prop-a': true, // checks `props['prop-a']` === true`
|
|
14
|
+
* 'prop-b': [1, 2], // checks `toArray([1, 2]).includes(props['prop-b'])`
|
|
15
|
+
* 'prop-c': (value) => value + 1 // checks `Boolean(callback(props['prop-c']))`
|
|
16
|
+
* 'prop-d': Boolean // checks `Boolean(Boolean(props['prop-d']))`
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
* @param conditions
|
|
20
|
+
* @returns Returns function that consumes component props.
|
|
21
|
+
*/
|
|
22
|
+
function whenProps(conditions) {
|
|
23
|
+
return function(props) {
|
|
24
|
+
return toArray(conditions).some((condition) => {
|
|
25
|
+
return Object.keys(condition).every((key) => {
|
|
26
|
+
const propValue = get_default(props, key);
|
|
27
|
+
const conditionValue = condition[key];
|
|
28
|
+
if (Array.isArray(conditionValue)) return toArray(conditionValue).includes(propValue);
|
|
29
|
+
if (isFunction(conditionValue)) return Boolean(conditionValue(propValue));
|
|
30
|
+
return conditionValue === propValue;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function handleConditionObject(condition, props) {
|
|
36
|
+
return Object.keys(condition).reduce((acc, key) => {
|
|
37
|
+
let value = condition[key];
|
|
38
|
+
if (isFunction(value)) value = value(props);
|
|
39
|
+
if (value) {
|
|
40
|
+
const result = getToken(key, props) ?? key;
|
|
41
|
+
return [...acc, result];
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, []).join(" ");
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Concatenate style properties or class names conditionally.
|
|
48
|
+
* Conditions can be functions that consume components props,
|
|
49
|
+
* objects, strings, or numbers (that will be coerced to strings).
|
|
50
|
+
* @example
|
|
51
|
+
* ```jsx
|
|
52
|
+
* conditional(1, 'some-class', {
|
|
53
|
+
* 'class-a': true,
|
|
54
|
+
* 'class-b': (props) => props.showClassB,
|
|
55
|
+
* }, (props) => props.className)
|
|
56
|
+
* ```
|
|
57
|
+
* @param conditions
|
|
58
|
+
* @returns Returns function that consumes component props.
|
|
59
|
+
*/
|
|
60
|
+
function conditional(...conditions) {
|
|
61
|
+
return function(props) {
|
|
62
|
+
let classes = [];
|
|
63
|
+
for (let i = 0; i < conditions.length; i++) {
|
|
64
|
+
const condition = conditions[i];
|
|
65
|
+
if (isFunction(condition)) classes.push(condition(props));
|
|
66
|
+
else if (isObject(condition)) classes = classes.concat(handleConditionObject(condition, props));
|
|
67
|
+
else if (condition) classes.push(String(condition));
|
|
68
|
+
}
|
|
69
|
+
return classes.join(" ");
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/tools/prop.ts
|
|
74
|
+
function compare(...args) {
|
|
75
|
+
const [value, defaultValue] = args;
|
|
76
|
+
if (value == null || value === false || Number.isNaN(value)) return defaultValue || value;
|
|
77
|
+
if (typeof value === "string" && value.length === 0) return defaultValue || value;
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Retrieve the key value from the props object
|
|
82
|
+
* @example
|
|
83
|
+
* ```jsx
|
|
84
|
+
* -transform: scaleY(${(props) => props.$height || 1});
|
|
85
|
+
* +transform: scaleY(${prop('$height', 1)});
|
|
86
|
+
* ```
|
|
87
|
+
* @param name a valid property name from the object
|
|
88
|
+
* @param defaultValue a fallback value in case the property value is invalid
|
|
89
|
+
* @param comparatorFn a function to be used to decide between value or defaultValue
|
|
90
|
+
* @returns Returns function that consumes component props.
|
|
91
|
+
*/
|
|
92
|
+
function prop(name, defaultValue, comparatorFn = compare) {
|
|
93
|
+
return (props) => comparatorFn(props[name], defaultValue);
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { conditional, prop, whenProps };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","names":["isObject","isFunction","F","getToken","ThemeToken","ThemedProps","get","toArray","WhenProps","K","value","When","P","Key","whenProps","conditions","Narrow","props","safeConditions","some","condition","keys","Object","every","key","propValue","conditionValue","Array","isArray","includes","Boolean","ConditionObject","Record","handleConditionObject","res","reduce","acc","tokenKey","result","join","Condition","conditional","classes","i","length","push","concat","String","compare","args","value","defaultValue","Number","isNaN","length","prop","P","name","K","NonNullable","comparatorFn","props"],"sources":["../src/tools/conditional.ts","../src/tools/prop.ts"],"sourcesContent":["import { isObject } from '@loadsmart/utils-object'\nimport { isFunction } from '@loadsmart/utils-function'\nimport type { F } from 'ts-toolbelt'\n\nimport { getToken } from 'theming'\nimport type { ThemeToken, ThemedProps } from 'theming'\nimport get from 'utils/toolset/get'\nimport toArray from 'utils/toolset/toArray'\n\ntype WhenProps<K> = K | undefined | ((value: K) => boolean | undefined)\n\nexport type When<P> = {\n [Key in keyof P]?: WhenProps<P[Key]> | WhenProps<P[Key]>[] | undefined\n}\n\n/**\n * Utility to generate style/class name conditions based on a components props.\n * Expected prop values can be a single value, an array of values or a function/callback.\n * @example\n * ```jsx\n * whenProps({\n * 'prop-a': true, // checks `props['prop-a']` === true`\n * 'prop-b': [1, 2], // checks `toArray([1, 2]).includes(props['prop-b'])`\n * 'prop-c': (value) => value + 1 // checks `Boolean(callback(props['prop-c']))`\n * 'prop-d': Boolean // checks `Boolean(Boolean(props['prop-d']))`\n * })\n * ```\n * @param conditions\n * @returns Returns function that consumes component props.\n */\nexport function whenProps<P>(conditions: When<F.Narrow<P>> | When<F.Narrow<P>>[]) {\n return function (props: P): boolean {\n const safeConditions = toArray(conditions)\n\n return safeConditions.some((condition) => {\n const keys = Object.keys(condition)\n\n return keys.every((key) => {\n const propValue = get(props, key) as P[keyof P]\n const conditionValue = condition[key as keyof typeof condition]\n\n if (Array.isArray(conditionValue)) {\n return toArray(conditionValue).includes(propValue)\n }\n if (isFunction(conditionValue)) {\n return Boolean(conditionValue(propValue))\n }\n return (conditionValue as unknown) === propValue\n })\n })\n }\n}\n\ntype ConditionObject<P> = Record<\n string,\n string | number | boolean | ((props: P) => boolean) | undefined\n>\n\nfunction handleConditionObject<P>(condition: ConditionObject<P>, props: P): string {\n const keys = Object.keys(condition)\n\n const res = keys.reduce<string[]>((acc, key) => {\n let value = condition[key]\n\n if (isFunction(value)) {\n value = value(props)\n }\n\n if (value) {\n const tokenKey = key as ThemeToken\n\n const result = (getToken(tokenKey, props as unknown as ThemedProps) ?? key) as string\n return [...acc, result]\n }\n\n return acc\n }, [])\n\n return res.join(' ')\n}\n\ntype Condition<P> = number | string | ConditionObject<P> | ((props: P) => string)\n\n/**\n * Concatenate style properties or class names conditionally.\n * Conditions can be functions that consume components props,\n * objects, strings, or numbers (that will be coerced to strings).\n * @example\n * ```jsx\n * conditional(1, 'some-class', {\n * 'class-a': true,\n * 'class-b': (props) => props.showClassB,\n * }, (props) => props.className)\n * ```\n * @param conditions\n * @returns Returns function that consumes component props.\n */\nfunction conditional<P>(...conditions: Condition<P>[]) {\n return function (props: P): string {\n let classes: string[] = []\n\n for (let i = 0; i < conditions.length; i++) {\n const condition = conditions[i]\n\n if (isFunction(condition)) {\n classes.push(condition(props))\n } else if (isObject(condition)) {\n classes = classes.concat(handleConditionObject(condition, props))\n } else if (condition) {\n classes.push(String(condition))\n }\n }\n\n return classes.join(' ')\n }\n}\n\nexport default conditional\n","function compare(...args: any[]): unknown {\n const [value, defaultValue] = args\n\n if (value == null || value === false || Number.isNaN(value)) {\n return defaultValue || value\n }\n\n if (typeof value === 'string' && value.length === 0) {\n return defaultValue || value\n }\n\n return value\n}\n\n/**\n * Retrieve the key value from the props object\n * @example\n * ```jsx\n * -transform: scaleY(${(props) => props.$height || 1});\n * +transform: scaleY(${prop('$height', 1)});\n * ```\n * @param name a valid property name from the object\n * @param defaultValue a fallback value in case the property value is invalid\n * @param comparatorFn a function to be used to decide between value or defaultValue\n * @returns Returns function that consumes component props.\n */\nfunction prop<P, K extends keyof P = keyof P>(\n name: K,\n defaultValue?: NonNullable<P[K]>,\n comparatorFn = compare\n) {\n return (props: P): P[K] => comparatorFn(props[name], defaultValue) as P[K]\n}\n\nexport default prop\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgBc,UAAaC,YAAqD;AAChF,QAAO,SAAUE,OAAmB;AAGlC,SAFuBV,QAAQQ,WAAW,CAEpBI,MAAMC,cAAc;AAGxC,UAFaE,OAAOD,KAAKD,UAAU,CAEvBG,OAAOC,QAAQ;IACzB,MAAMC,YAAYnB,YAAIW,OAAOO,IAAI;IACjC,MAAME,iBAAiBN,UAAUI;AAEjC,QAAIG,MAAMC,QAAQF,eAAe,CAC/B,QAAOnB,QAAQmB,eAAe,CAACG,SAASJ,UAAU;AAEpD,QAAIxB,WAAWyB,eAAe,CAC5B,QAAOI,QAAQJ,eAAeD,UAAU,CAAC;AAE3C,WAAQC,mBAA+BD;KACvC;IACF;;;AASN,SAASQ,sBAAyBb,WAA+BH,OAAkB;AAoBjF,QAnBaK,OAAOD,KAAKD,UAAU,CAElBe,QAAkBC,KAAKZ,QAAQ;EAC9C,IAAId,QAAQU,UAAUI;AAEtB,MAAIvB,WAAWS,MAAM,CACnBA,SAAQA,MAAMO,MAAM;AAGtB,MAAIP,OAAO;GAGT,MAAM4B,SAAUnC,SAFCqB,KAEkBP,MAAgC,IAAIO;AACvE,UAAO,CAAC,GAAGY,KAAKE,OAAO;;AAGzB,SAAOF;IACN,EAAE,CAAC,CAEKG,KAAK,IAAI;;;;;;;;;;;;;;;;AAmBtB,SAASE,YAAe,GAAG1B,YAA4B;AACrD,QAAO,SAAUE,OAAkB;EACjC,IAAIyB,UAAoB,EAAE;AAE1B,OAAK,IAAIC,IAAI,GAAGA,IAAI5B,WAAW6B,QAAQD,KAAK;GAC1C,MAAMvB,YAAYL,WAAW4B;AAE7B,OAAI1C,WAAWmB,UAAU,CACvBsB,SAAQG,KAAKzB,UAAUH,MAAM,CAAC;YACrBjB,SAASoB,UAAU,CAC5BsB,WAAUA,QAAQI,OAAOb,sBAAsBb,WAAWH,MAAM,CAAC;YACxDG,UACTsB,SAAQG,KAAKE,OAAO3B,UAAU,CAAC;;AAInC,SAAOsB,QAAQH,KAAK,IAAI;;;;;ACjH5B,SAASS,QAAQ,GAAGC,MAAsB;CACxC,MAAM,CAACC,OAAOC,gBAAgBF;AAE9B,KAAIC,SAAS,QAAQA,UAAU,SAASE,OAAOC,MAAMH,MAAM,CACzD,QAAOC,gBAAgBD;AAGzB,KAAI,OAAOA,UAAU,YAAYA,MAAMI,WAAW,EAChD,QAAOH,gBAAgBD;AAGzB,QAAOA;;;;;;;;;;;;;;AAeT,SAASK,KACPE,MACAN,cACAS,eAAeZ,SACf;AACA,SAAQa,UAAmBD,aAAaC,MAAMJ,OAAON,aAAa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadsmart/loadsmart-ui",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.1.0-beta.1",
|
|
4
4
|
"description": "Miranda UI, a React UI library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,6 +8,20 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./theming": {
|
|
17
|
+
"import": "./dist/theming/index.js",
|
|
18
|
+
"types": "./dist/theming/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./testing": {
|
|
21
|
+
"import": "./dist/testing/index.js",
|
|
22
|
+
"types": "./dist/testing/index.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
11
25
|
"scripts": {
|
|
12
26
|
"start": "yarn dev",
|
|
13
27
|
"dev": "storybook dev -p 6006",
|
|
@@ -40,6 +54,7 @@
|
|
|
40
54
|
"@commitlint/cli": "^20.5.0",
|
|
41
55
|
"@commitlint/config-conventional": "^20.5.0",
|
|
42
56
|
"@loadsmart/miranda-tokens": "^4.26.0",
|
|
57
|
+
"@rolldown/plugin-babel": "^0.2.2",
|
|
43
58
|
"@storybook/addon-a11y": "^10.3.3",
|
|
44
59
|
"@storybook/addon-docs": "^10.3.3",
|
|
45
60
|
"@storybook/addon-links": "^10.3.3",
|
|
@@ -57,8 +72,7 @@
|
|
|
57
72
|
"@types/node": "^24.12.0",
|
|
58
73
|
"@types/react": "^18.3.28",
|
|
59
74
|
"@types/react-dom": "^18.3.7",
|
|
60
|
-
"@
|
|
61
|
-
"@vitejs/plugin-react": "^5.2.0",
|
|
75
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
62
76
|
"babel-plugin-styled-components": "^2.1.4",
|
|
63
77
|
"chance": "^1.1.13",
|
|
64
78
|
"commitizen": "^4.3.1",
|
|
@@ -91,12 +105,12 @@
|
|
|
91
105
|
"react-is": "^18.3.1",
|
|
92
106
|
"semantic-release": "^25.0.3",
|
|
93
107
|
"storybook": "^10.3.3",
|
|
94
|
-
"styled-components": "^
|
|
108
|
+
"styled-components": "^6.3.11",
|
|
95
109
|
"tailwindcss": "^4.2.2",
|
|
96
110
|
"ts-toolbelt": "^9.6.0",
|
|
97
111
|
"typescript": "^6.0.2",
|
|
98
112
|
"typescript-eslint": "^8.57.2",
|
|
99
|
-
"vite": "^
|
|
113
|
+
"vite": "^8.0.3",
|
|
100
114
|
"vite-plugin-dts": "^4.5.4",
|
|
101
115
|
"vite-plugin-svgr": "^4.5.0"
|
|
102
116
|
},
|
|
@@ -105,7 +119,7 @@
|
|
|
105
119
|
"@testing-library/react": ">=11.2.6",
|
|
106
120
|
"react": ">=16.8.0",
|
|
107
121
|
"react-dom": ">=16.8.0",
|
|
108
|
-
"styled-components": ">=
|
|
122
|
+
"styled-components": ">=6.0.0"
|
|
109
123
|
},
|
|
110
124
|
"dependencies": {
|
|
111
125
|
"@floating-ui/react-dom": "^2.1.8",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React__default, { createContext, useCallback, useMemo, useContext } from "react";
|
|
2
|
-
const DragDropFileContext = createContext(void 0);
|
|
3
|
-
const DragDropFileProvider = ({
|
|
4
|
-
fileList,
|
|
5
|
-
onFilesAdded,
|
|
6
|
-
onFileRemoved,
|
|
7
|
-
onRetryUpload,
|
|
8
|
-
children
|
|
9
|
-
}) => {
|
|
10
|
-
const onRemoveFile = useCallback((removedItem, index) => {
|
|
11
|
-
onFileRemoved([...fileList.slice(0, index), ...fileList.slice(index + 1)], removedItem, index);
|
|
12
|
-
}, [fileList]);
|
|
13
|
-
const contextValue = useMemo(() => ({
|
|
14
|
-
fileList,
|
|
15
|
-
onFilesAdded,
|
|
16
|
-
onRemoveFile,
|
|
17
|
-
onRetryUpload
|
|
18
|
-
}), [fileList, onFilesAdded, onRemoveFile, onRetryUpload]);
|
|
19
|
-
return /* @__PURE__ */ React__default.createElement(DragDropFileContext.Provider, { value: contextValue }, children);
|
|
20
|
-
};
|
|
21
|
-
const useDragDropFileContext = () => {
|
|
22
|
-
const context = useContext(DragDropFileContext);
|
|
23
|
-
if (!context) {
|
|
24
|
-
throw new Error("useDragDropFileContext must be used within an DragDropFileProvider");
|
|
25
|
-
}
|
|
26
|
-
return context;
|
|
27
|
-
};
|
|
28
|
-
export {
|
|
29
|
-
DragDropFileContext as D,
|
|
30
|
-
DragDropFileProvider as a,
|
|
31
|
-
useDragDropFileContext as u
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=DragDropFile.context-oKnUu6d3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropFile.context-oKnUu6d3.js","sources":["../src/components/DragDropFile/DragDropFile.context.tsx"],"sourcesContent":["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) => {\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":["DragDropFileContext","createContext","undefined","DragDropFileProvider","fileList","onFilesAdded","onFileRemoved","onRetryUpload","children","onRemoveFile","useCallback","removedItem","index","slice","contextValue","useMemo","useDragDropFileContext","context","useContext","Error"],"mappings":";AAIO,MAAMA,sBAAsBC,cAAoDC,MAAS;AAEzF,MAAMC,uBAAuBA,CAAC;AAAA,EACnCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACyB,MAAM;AAC/B,QAAMC,eAAeC,YACnB,CAACC,aAA6BC,UAAkB;AAC9CN,kBAAc,CAAC,GAAGF,SAASS,MAAM,GAAGD,KAAK,GAAG,GAAGR,SAASS,MAAMD,QAAQ,CAAC,CAAC,GAAGD,aAAaC,KAAK;AAAA,EAC/F,GACA,CAACR,QAAQ,CACX;AAEA,QAAMU,eAAeC,QACnB,OAAO;AAAA,IAAEX;AAAAA,IAAUC;AAAAA,IAAcI;AAAAA,IAAcF;AAAAA,EAAAA,IAC/C,CAACH,UAAUC,cAAcI,cAAcF,aAAa,CACtD;AAEA,sDACG,oBAAoB,UAApB,EAA6B,OAAOO,gBAAeN,QAAS;AAEjE;AAEO,MAAMQ,yBAAyBA,MAAgC;AACpE,QAAMC,UAAUC,WAAWlB,mBAAmB;AAE9C,MAAI,CAACiB,SAAS;AACZ,UAAM,IAAIE,MAAM,oEAAoE;AAAA,EACtF;AAEA,SAAOF;AACT;"}
|