lkd-web-kit 0.8.0 → 0.8.2
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/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/components/EmptyState/index.cjs +38 -52
- package/dist/components/EmptyState/index.js +37 -48
- package/dist/components/Icon.cjs +46 -50
- package/dist/components/Icon.js +44 -46
- package/dist/components/InfinityLoadMoreButton/index.cjs +30 -42
- package/dist/components/InfinityLoadMoreButton/index.js +28 -38
- package/dist/components/InfinitySelect/index.cjs +126 -168
- package/dist/components/InfinitySelect/index.js +125 -164
- package/dist/components/MyCheckboxGroup/index.cjs +14 -22
- package/dist/components/MyCheckboxGroup/index.js +13 -18
- package/dist/components/MyDateInput/index.cjs +12 -18
- package/dist/components/MyDateInput/index.js +11 -14
- package/dist/components/MyDatePickerInput/CalendarIcon.cjs +45 -64
- package/dist/components/MyDatePickerInput/CalendarIcon.js +43 -61
- package/dist/components/MyDatePickerInput/index.cjs +12 -18
- package/dist/components/MyDatePickerInput/index.js +11 -14
- package/dist/components/MyDateTimePicker/index.cjs +12 -18
- package/dist/components/MyDateTimePicker/index.js +11 -14
- package/dist/components/MyMonthPickerInput/index.cjs +12 -18
- package/dist/components/MyMonthPickerInput/index.js +11 -14
- package/dist/components/MyMultiSelect/index.cjs +9 -9
- package/dist/components/MyMultiSelect/index.js +8 -5
- package/dist/components/MyNotifications/index.cjs +11 -17
- package/dist/components/MyNotifications/index.js +10 -13
- package/dist/components/MyNumberInput/index.cjs +9 -15
- package/dist/components/MyNumberInput/index.js +8 -11
- package/dist/components/MyRadioGroup/index.cjs +14 -22
- package/dist/components/MyRadioGroup/index.js +13 -18
- package/dist/components/MySelect/index.cjs +9 -15
- package/dist/components/MySelect/index.js +8 -11
- package/dist/components/MyTextInput/index.cjs +9 -15
- package/dist/components/MyTextInput/index.js +8 -11
- package/dist/components/MyTextarea/index.cjs +9 -15
- package/dist/components/MyTextarea/index.js +8 -11
- package/dist/components/MyTimeInput/index.cjs +9 -15
- package/dist/components/MyTimeInput/index.js +8 -11
- package/dist/components/NavItems.cjs +28 -38
- package/dist/components/NavItems.js +26 -34
- package/dist/consts/http-status.cjs +66 -69
- package/dist/consts/http-status.js +66 -65
- package/dist/consts/revalidate.cjs +10 -13
- package/dist/consts/revalidate.js +10 -9
- package/dist/contexts/NavigationHistoryContext/hook.cjs +41 -42
- package/dist/contexts/NavigationHistoryContext/hook.js +40 -38
- package/dist/contexts/NavigationHistoryContext/index.cjs +31 -28
- package/dist/contexts/NavigationHistoryContext/index.js +30 -24
- package/dist/contexts/PageDataContext/index.cjs +15 -18
- package/dist/contexts/PageDataContext/index.js +14 -14
- package/dist/form/Form.cjs +19 -28
- package/dist/form/Form.js +18 -24
- package/dist/form/FormSubmitButton.cjs +15 -27
- package/dist/form/FormSubmitButton.js +14 -23
- package/dist/form/base/FormCheckbox.cjs +15 -23
- package/dist/form/base/FormCheckbox.js +14 -19
- package/dist/form/base/FormCheckboxGroup.cjs +10 -16
- package/dist/form/base/FormCheckboxGroup.js +9 -12
- package/dist/form/base/FormDateInput.cjs +10 -16
- package/dist/form/base/FormDateInput.js +9 -12
- package/dist/form/base/FormDatePickerInput.cjs +10 -16
- package/dist/form/base/FormDatePickerInput.js +9 -12
- package/dist/form/base/FormDateTimePicker.cjs +10 -16
- package/dist/form/base/FormDateTimePicker.js +9 -12
- package/dist/form/base/FormMonthPickerInput.cjs +10 -16
- package/dist/form/base/FormMonthPickerInput.js +9 -12
- package/dist/form/base/FormMultiSelect.cjs +10 -10
- package/dist/form/base/FormMultiSelect.js +9 -6
- package/dist/form/base/FormNumberInput.cjs +12 -12
- package/dist/form/base/FormNumberInput.js +10 -8
- package/dist/form/base/FormRadioGroup.cjs +10 -16
- package/dist/form/base/FormRadioGroup.js +9 -12
- package/dist/form/base/FormSelect.cjs +10 -16
- package/dist/form/base/FormSelect.js +9 -12
- package/dist/form/base/FormSelectInfinity.cjs +15 -21
- package/dist/form/base/FormSelectInfinity.js +14 -17
- package/dist/form/base/FormTextInput.cjs +10 -16
- package/dist/form/base/FormTextInput.js +9 -12
- package/dist/form/base/FormTextarea.cjs +10 -10
- package/dist/form/base/FormTextarea.js +9 -6
- package/dist/form/base/FormTimeInput.cjs +18 -24
- package/dist/form/base/FormTimeInput.js +17 -20
- package/dist/form/utils/nullable-but-required.cjs +14 -17
- package/dist/form/utils/nullable-but-required.js +13 -13
- package/dist/form/utils/optional-but-required.cjs +14 -17
- package/dist/form/utils/optional-but-required.js +13 -13
- package/dist/form/utils/zodValidator.cjs +9 -13
- package/dist/form/utils/zodValidator.js +9 -9
- package/dist/hocs/withController.cjs +43 -54
- package/dist/hocs/withController.js +42 -50
- package/dist/hocs/withModalManager.cjs +29 -35
- package/dist/hocs/withModalManager.js +28 -31
- package/dist/hooks/useBreakpoint.cjs +8 -12
- package/dist/hooks/useBreakpoint.js +7 -8
- package/dist/hooks/useFetchNextPageOnScroll.cjs +13 -21
- package/dist/hooks/useFetchNextPageOnScroll.js +13 -17
- package/dist/hooks/useOnScrollProgress.cjs +33 -37
- package/dist/hooks/useOnScrollProgress.js +32 -33
- package/dist/hooks/useUpdateSearchParams.cjs +22 -22
- package/dist/hooks/useUpdateSearchParams.js +21 -18
- package/dist/hooks/useZodConfig.cjs +14 -19
- package/dist/hooks/useZodConfig.js +12 -15
- package/dist/index.cjs +130 -136
- package/dist/index.d.ts +13 -13
- package/dist/index.js +62 -61
- package/dist/mantine/breakpoints-with-px.cjs +9 -12
- package/dist/mantine/breakpoints-with-px.js +9 -8
- package/dist/mantine/my-default-theme.cjs +23 -42
- package/dist/mantine/my-default-theme.js +22 -38
- package/dist/mantine/to-tailwind-colors.cjs +9 -18
- package/dist/mantine/to-tailwind-colors.js +9 -14
- package/dist/utils/array/groupBy.cjs +30 -40
- package/dist/utils/array/groupBy.js +30 -36
- package/dist/utils/array/shuffleArray.cjs +11 -17
- package/dist/utils/array/shuffleArray.js +11 -13
- package/dist/utils/formatBytes.cjs +12 -11
- package/dist/utils/formatBytes.js +12 -7
- package/dist/utils/isInfinityEmpty.cjs +3 -6
- package/dist/utils/isInfinityEmpty.js +3 -2
- package/dist/utils/ky/addBodyJsonHook.cjs +9 -14
- package/dist/utils/ky/addBodyJsonHook.js +8 -10
- package/dist/utils/ky/parseJson.cjs +6 -9
- package/dist/utils/ky/parseJson.js +6 -5
- package/dist/utils/new-route.cjs +30 -39
- package/dist/utils/new-route.js +30 -35
- package/dist/utils/query-stringify.cjs +5 -8
- package/dist/utils/query-stringify.js +5 -4
- package/dist/utils/virtual-styles.cjs +21 -26
- package/dist/utils/virtual-styles.js +21 -22
- package/package.json +20 -19
- package/dist/node_modules/@mantine/notifications/styles.css +0 -42
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.cjs +0 -74
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.js +0 -45
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +0 -886
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +0 -872
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +0 -75
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +0 -68
|
@@ -1,44 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Select: core.Select.extend({
|
|
24
|
-
defaultProps: {
|
|
25
|
-
allowDeselect: false,
|
|
26
|
-
withCheckIcon: false,
|
|
27
|
-
clearable: true
|
|
28
|
-
}
|
|
29
|
-
}),
|
|
30
|
-
Menu: core.Menu.extend({
|
|
31
|
-
defaultProps: {
|
|
32
|
-
position: "bottom-end"
|
|
33
|
-
}
|
|
34
|
-
}),
|
|
35
|
-
Tooltip: core.Tooltip.extend({
|
|
36
|
-
defaultProps: {
|
|
37
|
-
multiline: true,
|
|
38
|
-
maw: 300
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_breakpoints_with_px = require("./breakpoints-with-px.cjs");
|
|
3
|
+
let _mantine_core = require("@mantine/core");
|
|
4
|
+
//#region src/mantine/my-default-theme.ts
|
|
5
|
+
var myDefaultTheme = {
|
|
6
|
+
breakpoints: require_breakpoints_with_px.breakpointsWithPx,
|
|
7
|
+
cursorType: "pointer",
|
|
8
|
+
defaultRadius: "sm",
|
|
9
|
+
components: {
|
|
10
|
+
Notification: _mantine_core.Notification.extend({ defaultProps: { withBorder: true } }),
|
|
11
|
+
AppShell: _mantine_core.AppShell.extend({ defaultProps: { padding: 0 } }),
|
|
12
|
+
Select: _mantine_core.Select.extend({ defaultProps: {
|
|
13
|
+
allowDeselect: false,
|
|
14
|
+
withCheckIcon: false,
|
|
15
|
+
clearable: true
|
|
16
|
+
} }),
|
|
17
|
+
Menu: _mantine_core.Menu.extend({ defaultProps: { position: "bottom-end" } }),
|
|
18
|
+
Tooltip: _mantine_core.Tooltip.extend({ defaultProps: {
|
|
19
|
+
multiline: true,
|
|
20
|
+
maw: 300
|
|
21
|
+
} })
|
|
22
|
+
}
|
|
42
23
|
};
|
|
43
|
-
|
|
24
|
+
//#endregion
|
|
44
25
|
exports.myDefaultTheme = myDefaultTheme;
|
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
withCheckIcon: false,
|
|
23
|
-
clearable: true
|
|
24
|
-
}
|
|
25
|
-
}),
|
|
26
|
-
Menu: Menu.extend({
|
|
27
|
-
defaultProps: {
|
|
28
|
-
position: "bottom-end"
|
|
29
|
-
}
|
|
30
|
-
}),
|
|
31
|
-
Tooltip: Tooltip.extend({
|
|
32
|
-
defaultProps: {
|
|
33
|
-
multiline: true,
|
|
34
|
-
maw: 300
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
}
|
|
1
|
+
import { breakpointsWithPx } from "./breakpoints-with-px.js";
|
|
2
|
+
import { AppShell, Menu, Notification, Select, Tooltip } from "@mantine/core";
|
|
3
|
+
//#region src/mantine/my-default-theme.ts
|
|
4
|
+
var myDefaultTheme = {
|
|
5
|
+
breakpoints: breakpointsWithPx,
|
|
6
|
+
cursorType: "pointer",
|
|
7
|
+
defaultRadius: "sm",
|
|
8
|
+
components: {
|
|
9
|
+
Notification: Notification.extend({ defaultProps: { withBorder: true } }),
|
|
10
|
+
AppShell: AppShell.extend({ defaultProps: { padding: 0 } }),
|
|
11
|
+
Select: Select.extend({ defaultProps: {
|
|
12
|
+
allowDeselect: false,
|
|
13
|
+
withCheckIcon: false,
|
|
14
|
+
clearable: true
|
|
15
|
+
} }),
|
|
16
|
+
Menu: Menu.extend({ defaultProps: { position: "bottom-end" } }),
|
|
17
|
+
Tooltip: Tooltip.extend({ defaultProps: {
|
|
18
|
+
multiline: true,
|
|
19
|
+
maw: 300
|
|
20
|
+
} })
|
|
21
|
+
}
|
|
38
22
|
};
|
|
39
|
-
|
|
23
|
+
//#endregion
|
|
40
24
|
export { myDefaultTheme };
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return acc2;
|
|
11
|
-
},
|
|
12
|
-
{}
|
|
13
|
-
);
|
|
14
|
-
return acc;
|
|
15
|
-
},
|
|
16
|
-
{}
|
|
17
|
-
);
|
|
18
|
-
|
|
1
|
+
//#region src/mantine/to-tailwind-colors.ts
|
|
2
|
+
var toTailwindColors = (colors) => Object.entries(colors).reduce((acc, [key, value]) => {
|
|
3
|
+
acc[key] = value.reduce((acc, color, index) => {
|
|
4
|
+
acc[index] = color;
|
|
5
|
+
return acc;
|
|
6
|
+
}, {});
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
//#endregion
|
|
19
10
|
exports.toTailwindColors = toTailwindColors;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return acc;
|
|
11
|
-
},
|
|
12
|
-
{}
|
|
13
|
-
);
|
|
14
|
-
|
|
1
|
+
//#region src/mantine/to-tailwind-colors.ts
|
|
2
|
+
var toTailwindColors = (colors) => Object.entries(colors).reduce((acc, [key, value]) => {
|
|
3
|
+
acc[key] = value.reduce((acc, color, index) => {
|
|
4
|
+
acc[index] = color;
|
|
5
|
+
return acc;
|
|
6
|
+
}, {});
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
//#endregion
|
|
15
10
|
export { toTailwindColors };
|
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
1
|
+
//#region src/utils/array/groupBy.ts
|
|
5
2
|
function indexBy(arr, getKey, getValue) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const key = getKey(item);
|
|
19
|
-
if (key === void 0) return acc;
|
|
20
|
-
acc[key] = item;
|
|
21
|
-
return acc;
|
|
22
|
-
},
|
|
23
|
-
{}
|
|
24
|
-
);
|
|
3
|
+
if (getValue) return arr.reduce((acc, item) => {
|
|
4
|
+
const key = getKey(item);
|
|
5
|
+
if (key === void 0) return acc;
|
|
6
|
+
acc[key] = getValue(item);
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
return arr.reduce((acc, item) => {
|
|
10
|
+
const key = getKey(item);
|
|
11
|
+
if (key === void 0) return acc;
|
|
12
|
+
acc[key] = item;
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
16
|
+
var groupBy = (arr, getKey) => {
|
|
17
|
+
const groups = {};
|
|
18
|
+
arr?.forEach((item) => {
|
|
19
|
+
const key = getKey(item);
|
|
20
|
+
if (key === null) return;
|
|
21
|
+
if (Array.isArray(key)) {
|
|
22
|
+
key.forEach((k) => {
|
|
23
|
+
if (!groups[k]) groups[k] = [];
|
|
24
|
+
groups[k]?.push(item);
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!groups[key]) groups[key] = [];
|
|
29
|
+
groups[key]?.push(item);
|
|
30
|
+
});
|
|
31
|
+
return groups;
|
|
42
32
|
};
|
|
43
|
-
|
|
33
|
+
//#endregion
|
|
44
34
|
exports.groupBy = groupBy;
|
|
45
35
|
exports.indexBy = indexBy;
|
|
@@ -1,40 +1,34 @@
|
|
|
1
|
+
//#region src/utils/array/groupBy.ts
|
|
1
2
|
function indexBy(arr, getKey, getValue) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const key = getKey(item);
|
|
15
|
-
if (key === void 0) return acc;
|
|
16
|
-
acc[key] = item;
|
|
17
|
-
return acc;
|
|
18
|
-
},
|
|
19
|
-
{}
|
|
20
|
-
);
|
|
3
|
+
if (getValue) return arr.reduce((acc, item) => {
|
|
4
|
+
const key = getKey(item);
|
|
5
|
+
if (key === void 0) return acc;
|
|
6
|
+
acc[key] = getValue(item);
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
return arr.reduce((acc, item) => {
|
|
10
|
+
const key = getKey(item);
|
|
11
|
+
if (key === void 0) return acc;
|
|
12
|
+
acc[key] = item;
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
var groupBy = (arr, getKey) => {
|
|
17
|
+
const groups = {};
|
|
18
|
+
arr?.forEach((item) => {
|
|
19
|
+
const key = getKey(item);
|
|
20
|
+
if (key === null) return;
|
|
21
|
+
if (Array.isArray(key)) {
|
|
22
|
+
key.forEach((k) => {
|
|
23
|
+
if (!groups[k]) groups[k] = [];
|
|
24
|
+
groups[k]?.push(item);
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!groups[key]) groups[key] = [];
|
|
29
|
+
groups[key]?.push(item);
|
|
30
|
+
});
|
|
31
|
+
return groups;
|
|
38
32
|
};
|
|
39
|
-
|
|
33
|
+
//#endregion
|
|
40
34
|
export { groupBy, indexBy };
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[shuffledArray[currentIndex], shuffledArray[randomIndex]] = [
|
|
12
|
-
shuffledArray[randomIndex],
|
|
13
|
-
shuffledArray[currentIndex]
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
return shuffledArray;
|
|
1
|
+
//#region src/utils/array/shuffleArray.ts
|
|
2
|
+
var shuffleArray = (array) => {
|
|
3
|
+
const shuffledArray = [...array];
|
|
4
|
+
let currentIndex = shuffledArray.length, randomIndex;
|
|
5
|
+
while (currentIndex > 0) {
|
|
6
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
7
|
+
currentIndex--;
|
|
8
|
+
[shuffledArray[currentIndex], shuffledArray[randomIndex]] = [shuffledArray[randomIndex], shuffledArray[currentIndex]];
|
|
9
|
+
}
|
|
10
|
+
return shuffledArray;
|
|
17
11
|
};
|
|
18
|
-
|
|
12
|
+
//#endregion
|
|
19
13
|
exports.shuffleArray = shuffleArray;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return shuffledArray;
|
|
1
|
+
//#region src/utils/array/shuffleArray.ts
|
|
2
|
+
var shuffleArray = (array) => {
|
|
3
|
+
const shuffledArray = [...array];
|
|
4
|
+
let currentIndex = shuffledArray.length, randomIndex;
|
|
5
|
+
while (currentIndex > 0) {
|
|
6
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
7
|
+
currentIndex--;
|
|
8
|
+
[shuffledArray[currentIndex], shuffledArray[randomIndex]] = [shuffledArray[randomIndex], shuffledArray[currentIndex]];
|
|
9
|
+
}
|
|
10
|
+
return shuffledArray;
|
|
13
11
|
};
|
|
14
|
-
|
|
12
|
+
//#endregion
|
|
15
13
|
export { shuffleArray };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
1
|
+
//#region src/utils/formatBytes.ts
|
|
5
2
|
function formatBytes(bytes, decimals = 2) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
if (!+bytes) return "0 Bytes";
|
|
4
|
+
const k = 1024;
|
|
5
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
6
|
+
const sizes = [
|
|
7
|
+
"Bytes",
|
|
8
|
+
"KB",
|
|
9
|
+
"MB"
|
|
10
|
+
];
|
|
11
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
12
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
//#endregion
|
|
14
15
|
exports.formatBytes = formatBytes;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
//#region src/utils/formatBytes.ts
|
|
1
2
|
function formatBytes(bytes, decimals = 2) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
if (!+bytes) return "0 Bytes";
|
|
4
|
+
const k = 1024;
|
|
5
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
6
|
+
const sizes = [
|
|
7
|
+
"Bytes",
|
|
8
|
+
"KB",
|
|
9
|
+
"MB"
|
|
10
|
+
];
|
|
11
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
12
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
8
13
|
}
|
|
9
|
-
|
|
14
|
+
//#endregion
|
|
10
15
|
export { formatBytes };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const isInfinityEmpty = (data) => data?.pages[0].data.length === 0;
|
|
6
|
-
|
|
1
|
+
//#region src/utils/isInfinityEmpty.ts
|
|
2
|
+
var isInfinityEmpty = (data) => data?.pages[0].data.length === 0;
|
|
3
|
+
//#endregion
|
|
7
4
|
exports.isInfinityEmpty = isInfinityEmpty;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return error;
|
|
10
|
-
}
|
|
11
|
-
const bodyJson = error.data ?? {};
|
|
12
|
-
error.response.bodyJson = bodyJson;
|
|
13
|
-
return error;
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let ky = require("ky");
|
|
3
|
+
//#region src/utils/ky/addBodyJsonHook.ts
|
|
4
|
+
var addBodyJsonHook = async ({ error }) => {
|
|
5
|
+
if (!(0, ky.isHTTPError)(error)) return error;
|
|
6
|
+
const bodyJson = error.data ?? {};
|
|
7
|
+
error.response.bodyJson = bodyJson;
|
|
8
|
+
return error;
|
|
14
9
|
};
|
|
15
|
-
|
|
10
|
+
//#endregion
|
|
16
11
|
exports.addBodyJsonHook = addBodyJsonHook;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { isHTTPError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
error.response.bodyJson = bodyJson;
|
|
9
|
-
return error;
|
|
1
|
+
import { isHTTPError } from "ky";
|
|
2
|
+
//#region src/utils/ky/addBodyJsonHook.ts
|
|
3
|
+
var addBodyJsonHook = async ({ error }) => {
|
|
4
|
+
if (!isHTTPError(error)) return error;
|
|
5
|
+
const bodyJson = error.data ?? {};
|
|
6
|
+
error.response.bodyJson = bodyJson;
|
|
7
|
+
return error;
|
|
10
8
|
};
|
|
11
|
-
|
|
9
|
+
//#endregion
|
|
12
10
|
export { addBodyJsonHook };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return response.text().then(function(text) {
|
|
7
|
-
return text ? JSON.parse(text) : {};
|
|
8
|
-
});
|
|
1
|
+
//#region src/utils/ky/parseJson.ts
|
|
2
|
+
var parseJSON = async (response) => {
|
|
3
|
+
return response.text().then(function(text) {
|
|
4
|
+
return text ? JSON.parse(text) : {};
|
|
5
|
+
});
|
|
9
6
|
};
|
|
10
|
-
|
|
7
|
+
//#endregion
|
|
11
8
|
exports.parseJSON = parseJSON;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/utils/ky/parseJson.ts
|
|
2
|
+
var parseJSON = async (response) => {
|
|
3
|
+
return response.text().then(function(text) {
|
|
4
|
+
return text ? JSON.parse(text) : {};
|
|
5
|
+
});
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
//#endregion
|
|
7
8
|
export { parseJSON };
|
package/dist/utils/new-route.cjs
CHANGED
|
@@ -1,45 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const queryStringify = require('./query-stringify.cjs');
|
|
6
|
-
|
|
1
|
+
const require_query_stringify = require("./query-stringify.cjs");
|
|
2
|
+
//#region src/utils/new-route.ts
|
|
7
3
|
function buildPathFromTemplate(path, params) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return encodeURIComponent(String(value));
|
|
14
|
-
});
|
|
4
|
+
return path.replace(/:([a-zA-Z0-9_]+)/g, (_, key) => {
|
|
5
|
+
const value = params[key];
|
|
6
|
+
if (value === void 0) throw new Error(`Falta el parámetro de ruta: ${key}`);
|
|
7
|
+
return encodeURIComponent(String(value));
|
|
8
|
+
});
|
|
15
9
|
}
|
|
16
10
|
function createNewRoute(config) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return newRoute2;
|
|
11
|
+
const globalQueryBuilder = config?.queryBuilder;
|
|
12
|
+
function getPathStrategy(arg, options) {
|
|
13
|
+
if (options?.pathBuilder) return (params) => options.pathBuilder(params);
|
|
14
|
+
else if (typeof arg === "string") {
|
|
15
|
+
const template = arg;
|
|
16
|
+
return (params) => buildPathFromTemplate(template, params);
|
|
17
|
+
} else {
|
|
18
|
+
const fn = arg;
|
|
19
|
+
return (params) => fn(params);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function newRoute(arg, options) {
|
|
23
|
+
const pathStrategy = getPathStrategy(arg, options);
|
|
24
|
+
const queryBuilder = options?.queryBuilder || globalQueryBuilder;
|
|
25
|
+
const queryStrategy = queryBuilder ? (query) => queryBuilder(query) : require_query_stringify.queryStringify;
|
|
26
|
+
return (params = {}) => {
|
|
27
|
+
const { query = {}, ...pathParams } = params;
|
|
28
|
+
return pathStrategy(pathParams) + queryStrategy(query);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return newRoute;
|
|
41
32
|
}
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
var newRoute = createNewRoute();
|
|
34
|
+
//#endregion
|
|
44
35
|
exports.createNewRoute = createNewRoute;
|
|
45
36
|
exports.newRoute = newRoute;
|