@ifto/mantine-kit 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +475 -2
- package/dist/component/atom/AppMain/App.module.js +7 -0
- package/dist/component/atom/AppMain/App.module.js.map +1 -0
- package/dist/component/atom/AppMain/AppMain.d.ts +7 -0
- package/dist/component/atom/AppMain/AppMain.js +14 -0
- package/dist/component/atom/AppMain/AppMain.js.map +1 -0
- package/dist/component/atom/CancelEditButton/CancelEditButton.d.ts +6 -0
- package/dist/component/atom/CancelEditButton/CancelEditButton.js +24 -0
- package/dist/component/atom/CancelEditButton/CancelEditButton.js.map +1 -0
- package/dist/component/atom/ConfirmEditButton/ConfirmEditButton.d.ts +13 -0
- package/dist/component/atom/ConfirmEditButton/ConfirmEditButton.js +30 -0
- package/dist/component/atom/ConfirmEditButton/ConfirmEditButton.js.map +1 -0
- package/dist/component/atom/DateField/DateField.d.ts +7 -0
- package/dist/component/atom/DateField/DateField.js +21 -0
- package/dist/component/atom/DateField/DateField.js.map +1 -0
- package/dist/component/atom/EditValueButton/EditValueButton.d.ts +6 -0
- package/dist/component/atom/EditValueButton/EditValueButton.js +24 -0
- package/dist/component/atom/EditValueButton/EditValueButton.js.map +1 -0
- package/dist/component/atom/ErrorAlert/ErrorAlert.d.ts +8 -0
- package/dist/component/atom/ErrorAlert/ErrorAlert.js +21 -0
- package/dist/component/atom/ErrorAlert/ErrorAlert.js.map +1 -0
- package/dist/component/atom/Surface/Surface.d.ts +20 -0
- package/dist/component/atom/Surface/Surface.js +15 -0
- package/dist/component/atom/Surface/Surface.js.map +1 -0
- package/dist/component/molecule/Breadcrumb/Breadcrumb.d.ts +12 -0
- package/dist/component/molecule/Breadcrumb/Breadcrumb.js +38 -0
- package/dist/component/molecule/Breadcrumb/Breadcrumb.js.map +1 -0
- package/dist/component/molecule/ExportMenuButton/ExportMenuButton.d.ts +25 -0
- package/dist/component/molecule/ExportMenuButton/ExportMenuButton.js +49 -0
- package/dist/component/molecule/ExportMenuButton/ExportMenuButton.js.map +1 -0
- package/dist/component/molecule/PaperCard/PaperCard.d.ts +7 -0
- package/dist/component/molecule/PaperCard/PaperCard.js +17 -0
- package/dist/component/molecule/PaperCard/PaperCard.js.map +1 -0
- package/dist/component/molecule/PrintSection/PrintSection.d.ts +14 -0
- package/dist/component/molecule/PrintSection/PrintSection.js +29 -0
- package/dist/component/molecule/PrintSection/PrintSection.js.map +1 -0
- package/dist/component/molecule/SelectField/SelectField.d.ts +32 -0
- package/dist/component/molecule/SelectField/SelectField.js +38 -0
- package/dist/component/molecule/SelectField/SelectField.js.map +1 -0
- package/dist/component/molecule/StatsCard/Stats.module.js +15 -0
- package/dist/component/molecule/StatsCard/Stats.module.js.map +1 -0
- package/dist/component/molecule/StatsCard/StatsCard.d.ts +18 -0
- package/dist/component/molecule/StatsCard/StatsCard.js +60 -0
- package/dist/component/molecule/StatsCard/StatsCard.js.map +1 -0
- package/dist/component/organism/DataForm/DataForm.d.ts +26 -0
- package/dist/component/organism/DataForm/DataForm.js +83 -0
- package/dist/component/organism/DataForm/DataForm.js.map +1 -0
- package/dist/component/organism/DataTabList/DataTabList.d.ts +24 -0
- package/dist/component/organism/DataTabList/DataTabList.js +37 -0
- package/dist/component/organism/DataTabList/DataTabList.js.map +1 -0
- package/dist/component/organism/DataTabList/DataTabList.module.js +13 -0
- package/dist/component/organism/DataTabList/DataTabList.module.js.map +1 -0
- package/dist/component/organism/EChart/EChart.d.ts +47 -0
- package/dist/component/organism/EChart/EChart.js +37 -0
- package/dist/component/organism/EChart/EChart.js.map +1 -0
- package/dist/component/organism/EChart/buildEChartOption.d.ts +40 -0
- package/dist/component/organism/EChart/buildEChartOption.js +57 -0
- package/dist/component/organism/EChart/buildEChartOption.js.map +1 -0
- package/dist/component/organism/EChart/chart/BarChart.d.ts +22 -0
- package/dist/component/organism/EChart/chart/BarChart.js +34 -0
- package/dist/component/organism/EChart/chart/BarChart.js.map +1 -0
- package/dist/component/organism/EChart/chart/CartesianChart.d.ts +48 -0
- package/dist/component/organism/EChart/chart/CartesianChart.js +63 -0
- package/dist/component/organism/EChart/chart/CartesianChart.js.map +1 -0
- package/dist/component/organism/EChart/chart/ChartHeader.d.ts +36 -0
- package/dist/component/organism/EChart/chart/ChartHeader.js +105 -0
- package/dist/component/organism/EChart/chart/ChartHeader.js.map +1 -0
- package/dist/component/organism/EChart/chart/ChartSeries.d.ts +50 -0
- package/dist/component/organism/EChart/chart/ChartSeries.js +23 -0
- package/dist/component/organism/EChart/chart/ChartSeries.js.map +1 -0
- package/dist/component/organism/EChart/chart/ChartTexts.d.ts +12 -0
- package/dist/component/organism/EChart/chart/ChartTexts.js +21 -0
- package/dist/component/organism/EChart/chart/ChartTexts.js.map +1 -0
- package/dist/component/organism/EChart/chart/ChartType.d.ts +50 -0
- package/dist/component/organism/EChart/chart/ChartType.js +1 -0
- package/dist/component/organism/EChart/chart/ChartTypeId.d.ts +2 -0
- package/dist/component/organism/EChart/chart/ChartTypeId.js +1 -0
- package/dist/component/organism/EChart/chart/ChartTypes.d.ts +15 -0
- package/dist/component/organism/EChart/chart/ChartTypes.js +24 -0
- package/dist/component/organism/EChart/chart/ChartTypes.js.map +1 -0
- package/dist/component/organism/EChart/chart/DonutChart.d.ts +32 -0
- package/dist/component/organism/EChart/chart/DonutChart.js +111 -0
- package/dist/component/organism/EChart/chart/DonutChart.js.map +1 -0
- package/dist/component/organism/EChart/chart/LineChart.d.ts +11 -0
- package/dist/component/organism/EChart/chart/LineChart.js +20 -0
- package/dist/component/organism/EChart/chart/LineChart.js.map +1 -0
- package/dist/component/organism/EChart/chart/StackedBarChart.d.ts +15 -0
- package/dist/component/organism/EChart/chart/StackedBarChart.js +30 -0
- package/dist/component/organism/EChart/chart/StackedBarChart.js.map +1 -0
- package/dist/component/organism/EChart/chart/UnitPanels.d.ts +63 -0
- package/dist/component/organism/EChart/chart/UnitPanels.js +127 -0
- package/dist/component/organism/EChart/chart/UnitPanels.js.map +1 -0
- package/dist/component/organism/EChart/echartDefaults.d.ts +32 -0
- package/dist/component/organism/EChart/echartDefaults.js +47 -0
- package/dist/component/organism/EChart/echartDefaults.js.map +1 -0
- package/dist/component/organism/EChart/useEChart.d.ts +35 -0
- package/dist/component/organism/EChart/useEChart.js +112 -0
- package/dist/component/organism/EChart/useEChart.js.map +1 -0
- package/dist/component/organism/Navbar/NavItem.d.ts +16 -0
- package/dist/component/organism/Navbar/NavItem.js +1 -0
- package/dist/component/organism/Navbar/Navbar.d.ts +20 -0
- package/dist/component/organism/Navbar/Navbar.js +64 -0
- package/dist/component/organism/Navbar/Navbar.js.map +1 -0
- package/dist/component/organism/Navbar/Navbar.module.js +19 -0
- package/dist/component/organism/Navbar/Navbar.module.js.map +1 -0
- package/dist/component/organism/PageHeader/PageHeader.d.ts +14 -0
- package/dist/component/organism/PageHeader/PageHeader.js +55 -0
- package/dist/component/organism/PageHeader/PageHeader.js.map +1 -0
- package/dist/component/organism/StatsGrid/StatsGrid.d.ts +12 -0
- package/dist/component/organism/StatsGrid/StatsGrid.js +46 -0
- package/dist/component/organism/StatsGrid/StatsGrid.js.map +1 -0
- package/dist/component/organism/StatsGrid/StatsGrid.module.js +17 -0
- package/dist/component/organism/StatsGrid/StatsGrid.module.js.map +1 -0
- package/dist/component/organism/Table/RowActions.d.ts +23 -0
- package/dist/component/organism/Table/RowActions.js +121 -0
- package/dist/component/organism/Table/RowActions.js.map +1 -0
- package/dist/component/organism/Table/Table.d.ts +51 -0
- package/dist/component/organism/Table/Table.js +110 -0
- package/dist/component/organism/Table/Table.js.map +1 -0
- package/dist/component/organism/ViewTable/ColumnComparator.d.ts +11 -0
- package/dist/component/organism/ViewTable/ColumnComparator.js +25 -0
- package/dist/component/organism/ViewTable/ColumnComparator.js.map +1 -0
- package/dist/component/organism/ViewTable/ViewTable.d.ts +53 -0
- package/dist/component/organism/ViewTable/ViewTable.js +115 -0
- package/dist/component/organism/ViewTable/ViewTable.js.map +1 -0
- package/dist/component/organism/ViewTable/useRowKey.d.ts +8 -0
- package/dist/component/organism/ViewTable/useRowKey.js +24 -0
- package/dist/component/organism/ViewTable/useRowKey.js.map +1 -0
- package/dist/component/template/CreateFormPage/CreateFormPage.d.ts +19 -0
- package/dist/component/template/CreateFormPage/CreateFormPage.js +41 -0
- package/dist/component/template/CreateFormPage/CreateFormPage.js.map +1 -0
- package/dist/component/template/EditFormPage/EditFormPage.d.ts +19 -0
- package/dist/component/template/EditFormPage/EditFormPage.js +42 -0
- package/dist/component/template/EditFormPage/EditFormPage.js.map +1 -0
- package/dist/component/template/FormPage/FormPage.d.ts +25 -0
- package/dist/component/template/FormPage/FormPage.js +130 -0
- package/dist/component/template/FormPage/FormPage.js.map +1 -0
- package/dist/component/template/FormPage/FormType.d.ts +6 -0
- package/dist/component/template/FormPage/FormType.js +12 -0
- package/dist/component/template/FormPage/FormType.js.map +1 -0
- package/dist/component/template/Layout/Layout.d.ts +21 -0
- package/dist/component/template/Layout/Layout.js +121 -0
- package/dist/component/template/Layout/Layout.js.map +1 -0
- package/dist/component/template/Layout/Layout.module.js +19 -0
- package/dist/component/template/Layout/Layout.module.js.map +1 -0
- package/dist/component/template/ListPage/ListPage.d.ts +32 -0
- package/dist/component/template/ListPage/ListPage.js +47 -0
- package/dist/component/template/ListPage/ListPage.js.map +1 -0
- package/dist/component/template/PrintPage/PrintPage.d.ts +25 -0
- package/dist/component/template/PrintPage/PrintPage.js +115 -0
- package/dist/component/template/PrintPage/PrintPage.js.map +1 -0
- package/dist/component/template/ViewPage/ViewPage.d.ts +11 -0
- package/dist/component/template/ViewPage/ViewPage.js +49 -0
- package/dist/component/template/ViewPage/ViewPage.js.map +1 -0
- package/dist/data/ListDataSource.d.ts +12 -0
- package/dist/data/ListDataSource.js +1 -0
- package/dist/data/SaveDataSource.d.ts +16 -0
- package/dist/data/SaveDataSource.js +1 -0
- package/dist/export/ExportCellText.d.ts +18 -0
- package/dist/export/ExportCellText.js +60 -0
- package/dist/export/ExportCellText.js.map +1 -0
- package/dist/export/ExportDocument.d.ts +127 -0
- package/dist/export/ExportDocument.js +59 -0
- package/dist/export/ExportDocument.js.map +1 -0
- package/dist/export/ExportDownload.d.ts +9 -0
- package/dist/export/ExportDownload.js +19 -0
- package/dist/export/ExportDownload.js.map +1 -0
- package/dist/export/ExportFileName.d.ts +11 -0
- package/dist/export/ExportFileName.js +24 -0
- package/dist/export/ExportFileName.js.map +1 -0
- package/dist/export/ExportFormat.d.ts +30 -0
- package/dist/export/ExportFormat.js +1 -0
- package/dist/export/ExportFormats.d.ts +12 -0
- package/dist/export/ExportFormats.js +16 -0
- package/dist/export/ExportFormats.js.map +1 -0
- package/dist/export/ExportTexts.d.ts +14 -0
- package/dist/export/ExportTexts.js +23 -0
- package/dist/export/ExportTexts.js.map +1 -0
- package/dist/export/csv/CsvFormat.d.ts +41 -0
- package/dist/export/csv/CsvFormat.js +91 -0
- package/dist/export/csv/CsvFormat.js.map +1 -0
- package/dist/export/xlsx/XlsxFormat.d.ts +35 -0
- package/dist/export/xlsx/XlsxFormat.js +66 -0
- package/dist/export/xlsx/XlsxFormat.js.map +1 -0
- package/dist/export/xlsx/XlsxNumberFormat.d.ts +8 -0
- package/dist/export/xlsx/XlsxNumberFormat.js +15 -0
- package/dist/export/xlsx/XlsxNumberFormat.js.map +1 -0
- package/dist/export/xlsx/XlsxSheetName.d.ts +12 -0
- package/dist/export/xlsx/XlsxSheetName.js +62 -0
- package/dist/export/xlsx/XlsxSheetName.js.map +1 -0
- package/dist/export/xlsx/XlsxSheetWriter.d.ts +67 -0
- package/dist/export/xlsx/XlsxSheetWriter.js +215 -0
- package/dist/export/xlsx/XlsxSheetWriter.js.map +1 -0
- package/dist/export/xlsx/XlsxStyle.d.ts +51 -0
- package/dist/export/xlsx/XlsxStyle.js +87 -0
- package/dist/export/xlsx/XlsxStyle.js.map +1 -0
- package/dist/hook/useIsMobile.d.ts +5 -0
- package/dist/hook/useIsMobile.js +16 -0
- package/dist/hook/useIsMobile.js.map +1 -0
- package/dist/hook/useKeyedService.d.ts +22 -0
- package/dist/hook/useKeyedService.js +38 -0
- package/dist/hook/useKeyedService.js.map +1 -0
- package/dist/hook/useLightColorSchemeOnPrint.d.ts +9 -0
- package/dist/hook/useLightColorSchemeOnPrint.js +36 -0
- package/dist/hook/useLightColorSchemeOnPrint.js.map +1 -0
- package/dist/hook/useService.d.ts +27 -0
- package/dist/hook/useService.js +23 -0
- package/dist/hook/useService.js.map +1 -0
- package/dist/http/ApiError.d.ts +13 -0
- package/dist/http/ApiError.js +22 -0
- package/dist/http/ApiError.js.map +1 -0
- package/dist/http/AxiosHttpClient.d.ts +21 -0
- package/dist/http/AxiosHttpClient.js +67 -0
- package/dist/http/AxiosHttpClient.js.map +1 -0
- package/dist/http/AxiosHttpClientConfig.d.ts +37 -0
- package/dist/http/AxiosHttpClientConfig.js +19 -0
- package/dist/http/AxiosHttpClientConfig.js.map +1 -0
- package/dist/i18n/KitLocale.d.ts +4 -0
- package/dist/i18n/KitLocale.js +7 -0
- package/dist/i18n/KitLocale.js.map +1 -0
- package/dist/i18n/KitMessages.d.ts +146 -0
- package/dist/i18n/KitMessages.js +1 -0
- package/dist/i18n/messages/enUS.d.ts +3 -0
- package/dist/i18n/messages/enUS.js +112 -0
- package/dist/i18n/messages/enUS.js.map +1 -0
- package/dist/i18n/messages/ptBR.d.ts +3 -0
- package/dist/i18n/messages/ptBR.js +97 -0
- package/dist/i18n/messages/ptBR.js.map +1 -0
- package/dist/i18n/resolveMessages.d.ts +13 -0
- package/dist/i18n/resolveMessages.js +29 -0
- package/dist/i18n/resolveMessages.js.map +1 -0
- package/dist/model/Identifiable.d.ts +7 -0
- package/dist/model/Identifiable.js +1 -0
- package/dist/provider/KitConfig.d.ts +26 -0
- package/dist/provider/KitConfig.js +1 -0
- package/dist/provider/KitContext.d.ts +9 -0
- package/dist/provider/KitContext.js +27 -0
- package/dist/provider/KitContext.js.map +1 -0
- package/dist/provider/KitProvider.d.ts +7 -0
- package/dist/provider/KitProvider.js +31 -0
- package/dist/provider/KitProvider.js.map +1 -0
- package/dist/provider/useKit.d.ts +15 -0
- package/dist/provider/useKit.js +28 -0
- package/dist/provider/useKit.js.map +1 -0
- package/dist/router/FormRouteSegments.d.ts +16 -0
- package/dist/router/FormRouteSegments.js +19 -0
- package/dist/router/FormRouteSegments.js.map +1 -0
- package/dist/router/RouterAdapter.d.ts +24 -0
- package/dist/router/RouterAdapter.js +1 -0
- package/dist/router/anchorRouter.d.ts +7 -0
- package/dist/router/anchorRouter.js +23 -0
- package/dist/router/anchorRouter.js.map +1 -0
- package/dist/styles/print.css +93 -0
- package/dist/styles.css +188 -0
- package/dist/util/ArrayUtil.d.ts +39 -0
- package/dist/util/ArrayUtil.js +48 -0
- package/dist/util/ArrayUtil.js.map +1 -0
- package/dist/util/ColorUtil.d.ts +7 -0
- package/dist/util/ColorUtil.js +16 -0
- package/dist/util/ColorUtil.js.map +1 -0
- package/dist/util/CompareUtil.d.ts +19 -0
- package/dist/util/CompareUtil.js +51 -0
- package/dist/util/CompareUtil.js.map +1 -0
- package/dist/util/DateUtil.d.ts +38 -0
- package/dist/util/DateUtil.js +55 -0
- package/dist/util/DateUtil.js.map +1 -0
- package/dist/util/DownloadUtil.d.ts +6 -0
- package/dist/util/DownloadUtil.js +25 -0
- package/dist/util/DownloadUtil.js.map +1 -0
- package/dist/util/EnumUtil.d.ts +19 -0
- package/dist/util/EnumUtil.js +32 -0
- package/dist/util/EnumUtil.js.map +1 -0
- package/dist/util/FormUtil.d.ts +8 -0
- package/dist/util/FormUtil.js +14 -0
- package/dist/util/FormUtil.js.map +1 -0
- package/dist/util/HtmlUtil.d.ts +8 -0
- package/dist/util/HtmlUtil.js +23 -0
- package/dist/util/HtmlUtil.js.map +1 -0
- package/dist/util/Notifications.d.ts +30 -0
- package/dist/util/Notifications.js +59 -0
- package/dist/util/Notifications.js.map +1 -0
- package/dist/util/NumberUtil.d.ts +19 -0
- package/dist/util/NumberUtil.js +33 -0
- package/dist/util/NumberUtil.js.map +1 -0
- package/dist/util/ObjectUtil.d.ts +22 -0
- package/dist/util/ObjectUtil.js +34 -0
- package/dist/util/ObjectUtil.js.map +1 -0
- package/dist/util/SearchParamsUtil.d.ts +23 -0
- package/dist/util/SearchParamsUtil.js +29 -0
- package/dist/util/SearchParamsUtil.js.map +1 -0
- package/dist/util/TransformData.d.ts +14 -0
- package/dist/util/TransformData.js +31 -0
- package/dist/util/TransformData.js.map +1 -0
- package/dist/util/ValidationUtil.d.ts +9 -0
- package/dist/util/ValidationUtil.js +16 -0
- package/dist/util/ValidationUtil.js.map +1 -0
- package/dist/util/parseActionsPageParams.d.ts +14 -0
- package/dist/util/parseActionsPageParams.js +29 -0
- package/dist/util/parseActionsPageParams.js.map +1 -0
- package/package.json +158 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/util/EnumUtil.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns the number values of an enum. Values of other types are not returned.
|
|
5
|
+
* @param enumType enum to read the values from
|
|
6
|
+
*/
|
|
7
|
+
function getEnumValues(enumType) {
|
|
8
|
+
return Object.values(enumType).filter((value) => typeof value === "number");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns the keys of an enum.
|
|
12
|
+
* @param enumType enum to read the keys from
|
|
13
|
+
* @template KeyType type of the returned keys. The keys are strings by default. To use them to read the enum values
|
|
14
|
+
* as an array (`MyEnum[key]`), use `keyof typeof MyEnum`.
|
|
15
|
+
*/
|
|
16
|
+
function getEnumKeys(enumType) {
|
|
17
|
+
return Object.values(enumType).filter((key) => typeof key === "string").map((key) => key);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns a `Map` whose keys are the values of the enum items and whose values are the keys of these items.
|
|
21
|
+
* @param enumType enum to read the entries from
|
|
22
|
+
* @template KeyType type of the returned keys. The keys are strings by default. To use them to read the enum values
|
|
23
|
+
* as an array (`MyEnum[key]`), use `keyof typeof MyEnum`.
|
|
24
|
+
*/
|
|
25
|
+
function getEnumEntries(enumType) {
|
|
26
|
+
const map = /* @__PURE__ */ new Map();
|
|
27
|
+
Object.entries(enumType).filter(([, value]) => typeof value === "number").forEach(([key, value]) => map.set(value, key));
|
|
28
|
+
return map;
|
|
29
|
+
}
|
|
30
|
+
export { getEnumEntries, getEnumKeys, getEnumValues };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=EnumUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnumUtil.js","names":[],"sources":["../../src/util/EnumUtil.ts"],"sourcesContent":["/**\n * Returns the number values of an enum. Values of other types are not returned.\n * @param enumType enum to read the values from\n */\nexport function getEnumValues(enumType: object): number[] {\n return Object.values(enumType).filter(value => typeof value === 'number');\n}\n\n/**\n * Returns the keys of an enum.\n * @param enumType enum to read the keys from\n * @template KeyType type of the returned keys. The keys are strings by default. To use them to read the enum values\n * as an array (`MyEnum[key]`), use `keyof typeof MyEnum`.\n */\nexport function getEnumKeys<KeyType = string>(enumType: object): KeyType[] {\n return Object.values(enumType)\n .filter(key => typeof key === 'string')\n .map(key => key as KeyType);\n}\n\n/**\n * Returns a `Map` whose keys are the values of the enum items and whose values are the keys of these items.\n * @param enumType enum to read the entries from\n * @template KeyType type of the returned keys. The keys are strings by default. To use them to read the enum values\n * as an array (`MyEnum[key]`), use `keyof typeof MyEnum`.\n */\nexport function getEnumEntries<KeyType = string>(enumType: object): Map<number, KeyType> {\n const map = new Map<number, KeyType>();\n Object.entries(enumType)\n .filter(([, value]) => typeof value === 'number')\n .forEach(([key, value]) => map.set(value, key as KeyType));\n\n return map;\n}\n"],"mappings":";;;;;;AAIA,SAAgB,cAAc,UAA4B;CACtD,OAAO,OAAO,OAAO,QAAQ,CAAC,CAAC,QAAO,UAAS,OAAO,UAAU,QAAQ;AAC5E;;;;;;;AAQA,SAAgB,YAA8B,UAA6B;CACvE,OAAO,OAAO,OAAO,QAAQ,CAAC,CACzB,QAAO,QAAO,OAAO,QAAQ,QAAQ,CAAC,CACtC,KAAI,QAAO,GAAc;AAClC;;;;;;;AAQA,SAAgB,eAAiC,UAAwC;CACrF,MAAM,sBAAM,IAAI,IAAqB;CACrC,OAAO,QAAQ,QAAQ,CAAC,CACnB,QAAQ,GAAG,WAAW,OAAO,UAAU,QAAQ,CAAC,CAChD,SAAS,CAAC,KAAK,WAAW,IAAI,IAAI,OAAO,GAAc,CAAC;CAE7D,OAAO;AACX"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UseFormReturnType } from '@mantine/form';
|
|
2
|
+
import { Identifiable } from '../model/Identifiable';
|
|
3
|
+
/**
|
|
4
|
+
* Fills a form with the data of a saved record. A record without an id (not saved yet) is ignored.
|
|
5
|
+
* @param initialize {@link UseFormReturnType#initialize} function of the form
|
|
6
|
+
* @param data data to fill the form with
|
|
7
|
+
*/
|
|
8
|
+
export declare function initForm<D extends Identifiable>(initialize: UseFormReturnType<D>['initialize'], data: D | null): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/util/FormUtil.ts
|
|
3
|
+
/**
|
|
4
|
+
* Fills a form with the data of a saved record. A record without an id (not saved yet) is ignored.
|
|
5
|
+
* @param initialize {@link UseFormReturnType#initialize} function of the form
|
|
6
|
+
* @param data data to fill the form with
|
|
7
|
+
*/
|
|
8
|
+
function initForm(initialize, data) {
|
|
9
|
+
if (!data?.id) return;
|
|
10
|
+
initialize(data);
|
|
11
|
+
}
|
|
12
|
+
export { initForm };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=FormUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormUtil.js","names":[],"sources":["../../src/util/FormUtil.ts"],"sourcesContent":["import type { UseFormReturnType } from '@mantine/form';\n\nimport { Identifiable } from '../model/Identifiable';\n\n/**\n * Fills a form with the data of a saved record. A record without an id (not saved yet) is ignored.\n * @param initialize {@link UseFormReturnType#initialize} function of the form\n * @param data data to fill the form with\n */\nexport function initForm<D extends Identifiable>(initialize: UseFormReturnType<D>['initialize'], data: D | null): void {\n if (!data?.id) return;\n\n initialize(data);\n}\n"],"mappings":";;;;;;;AASA,SAAgB,SAAiC,YAAgD,MAAsB;CACnH,IAAI,CAAC,MAAM,IAAI;CAEf,WAAW,IAAI;AACnB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes the HTML special characters of a text, so it is shown as text, and not interpreted as HTML, when inserted in
|
|
3
|
+
* an HTML snippet built as a string (e.g. an ECharts tooltip). It prevents data typed by a user with a tag (e.g.
|
|
4
|
+
* `<img onerror=...>`) from running JavaScript (XSS).
|
|
5
|
+
* @param text text to escape
|
|
6
|
+
* @return the text with `&`, `<`, `>`, `"` and `'` replaced by the corresponding HTML entities
|
|
7
|
+
*/
|
|
8
|
+
export declare function escapeHtml(text: string): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/util/HtmlUtil.ts
|
|
3
|
+
/** Characters with a special meaning in HTML and the entities that represent them as text. */
|
|
4
|
+
var HTML_ENTITIES = {
|
|
5
|
+
"&": "&",
|
|
6
|
+
"<": "<",
|
|
7
|
+
">": ">",
|
|
8
|
+
"\"": """,
|
|
9
|
+
"'": "'"
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Escapes the HTML special characters of a text, so it is shown as text, and not interpreted as HTML, when inserted in
|
|
13
|
+
* an HTML snippet built as a string (e.g. an ECharts tooltip). It prevents data typed by a user with a tag (e.g.
|
|
14
|
+
* `<img onerror=...>`) from running JavaScript (XSS).
|
|
15
|
+
* @param text text to escape
|
|
16
|
+
* @return the text with `&`, `<`, `>`, `"` and `'` replaced by the corresponding HTML entities
|
|
17
|
+
*/
|
|
18
|
+
function escapeHtml(text) {
|
|
19
|
+
return text.replace(/[&<>"']/g, (char) => HTML_ENTITIES[char]);
|
|
20
|
+
}
|
|
21
|
+
export { escapeHtml };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=HtmlUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HtmlUtil.js","names":[],"sources":["../../src/util/HtmlUtil.ts"],"sourcesContent":["/** Characters with a special meaning in HTML and the entities that represent them as text. */\nconst HTML_ENTITIES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''\n};\n\n/**\n * Escapes the HTML special characters of a text, so it is shown as text, and not interpreted as HTML, when inserted in\n * an HTML snippet built as a string (e.g. an ECharts tooltip). It prevents data typed by a user with a tag (e.g.\n * `<img onerror=...>`) from running JavaScript (XSS).\n * @param text text to escape\n * @return the text with `&`, `<`, `>`, `\"` and `'` replaced by the corresponding HTML entities\n */\nexport function escapeHtml(text: string): string {\n return text.replace(/[&<>\"']/g, char => HTML_ENTITIES[char]);\n}\n"],"mappings":";;;AACA,IAAM,gBAAwC;CAC1C,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;AACT;;;;;;;;AASA,SAAgB,WAAW,MAAsB;CAC7C,OAAO,KAAK,QAAQ,aAAY,SAAQ,cAAc,KAAK;AAC/D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { hideNotification } from '@mantine/notifications';
|
|
2
|
+
export { hideNotification };
|
|
3
|
+
/**
|
|
4
|
+
* Shows a success message.
|
|
5
|
+
* @param message message of the notification
|
|
6
|
+
* @param title title of the notification; components give the one of their locale (`common.success`)
|
|
7
|
+
* @return the id of the notification, to hide it later with {@link hideNotification}
|
|
8
|
+
*/
|
|
9
|
+
export declare function showSuccessNotification(message: string, title?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Shows a warning: something that did not go as expected, but is not an error (e.g. an action done only in part).
|
|
12
|
+
* @param message message of the warning
|
|
13
|
+
* @param title title of the warning; components give the one of their locale (`common.warning`)
|
|
14
|
+
* @return the id of the notification, to hide it later with {@link hideNotification}
|
|
15
|
+
*/
|
|
16
|
+
export declare function showWarningNotification(message: string, title?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Shows an error.
|
|
19
|
+
* @param error error to show, used when there is no `message`
|
|
20
|
+
* @param message message of the notification; if absent, the message of the error
|
|
21
|
+
* @param title title of the notification; components give the one of their locale (`common.error`)
|
|
22
|
+
* @return the id of the notification, to hide it later with {@link hideNotification}
|
|
23
|
+
*/
|
|
24
|
+
export declare function showErrorNotification(error: unknown, message?: string, title?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the message of an error, to show to the user.
|
|
27
|
+
* @param error the error, which may be an {@link Error}, an object with `message` or any other thrown value
|
|
28
|
+
* @return the `message` attribute of the error, if any, or the error itself converted to text
|
|
29
|
+
*/
|
|
30
|
+
export declare function errorMessage(error: unknown): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DEFAULT_MESSAGES } from "../i18n/resolveMessages.js";
|
|
3
|
+
import { hideNotification, showNotification } from "@mantine/notifications";
|
|
4
|
+
// src/util/Notifications.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Shows a success message.
|
|
7
|
+
* @param message message of the notification
|
|
8
|
+
* @param title title of the notification; components give the one of their locale (`common.success`)
|
|
9
|
+
* @return the id of the notification, to hide it later with {@link hideNotification}
|
|
10
|
+
*/
|
|
11
|
+
function showSuccessNotification(message, title = DEFAULT_MESSAGES.common.success) {
|
|
12
|
+
return showNotification({
|
|
13
|
+
withBorder: true,
|
|
14
|
+
color: "green",
|
|
15
|
+
title,
|
|
16
|
+
message
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Shows a warning: something that did not go as expected, but is not an error (e.g. an action done only in part).
|
|
21
|
+
* @param message message of the warning
|
|
22
|
+
* @param title title of the warning; components give the one of their locale (`common.warning`)
|
|
23
|
+
* @return the id of the notification, to hide it later with {@link hideNotification}
|
|
24
|
+
*/
|
|
25
|
+
function showWarningNotification(message, title = DEFAULT_MESSAGES.common.warning) {
|
|
26
|
+
return showNotification({
|
|
27
|
+
withBorder: true,
|
|
28
|
+
color: "yellow",
|
|
29
|
+
title,
|
|
30
|
+
message
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Shows an error.
|
|
35
|
+
* @param error error to show, used when there is no `message`
|
|
36
|
+
* @param message message of the notification; if absent, the message of the error
|
|
37
|
+
* @param title title of the notification; components give the one of their locale (`common.error`)
|
|
38
|
+
* @return the id of the notification, to hide it later with {@link hideNotification}
|
|
39
|
+
*/
|
|
40
|
+
function showErrorNotification(error, message, title = DEFAULT_MESSAGES.common.error) {
|
|
41
|
+
return showNotification({
|
|
42
|
+
withBorder: true,
|
|
43
|
+
color: "red",
|
|
44
|
+
title,
|
|
45
|
+
message: message ?? errorMessage(error)
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the message of an error, to show to the user.
|
|
50
|
+
* @param error the error, which may be an {@link Error}, an object with `message` or any other thrown value
|
|
51
|
+
* @return the `message` attribute of the error, if any, or the error itself converted to text
|
|
52
|
+
*/
|
|
53
|
+
function errorMessage(error) {
|
|
54
|
+
if (typeof error === "object" && error !== null && "message" in error) return String(error.message);
|
|
55
|
+
return String(error);
|
|
56
|
+
}
|
|
57
|
+
export { errorMessage, hideNotification, showErrorNotification, showSuccessNotification, showWarningNotification };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=Notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifications.js","names":[],"sources":["../../src/util/Notifications.tsx"],"sourcesContent":["import { hideNotification, showNotification } from '@mantine/notifications';\n\nimport { DEFAULT_MESSAGES } from '../i18n/resolveMessages';\n\nexport { hideNotification };\n\n/**\n * Shows a success message.\n * @param message message of the notification\n * @param title title of the notification; components give the one of their locale (`common.success`)\n * @return the id of the notification, to hide it later with {@link hideNotification}\n */\nexport function showSuccessNotification(message: string, title: string = DEFAULT_MESSAGES.common.success): string {\n return showNotification({\n withBorder: true,\n color: 'green',\n title,\n message\n });\n}\n\n/**\n * Shows a warning: something that did not go as expected, but is not an error (e.g. an action done only in part).\n * @param message message of the warning\n * @param title title of the warning; components give the one of their locale (`common.warning`)\n * @return the id of the notification, to hide it later with {@link hideNotification}\n */\nexport function showWarningNotification(message: string, title: string = DEFAULT_MESSAGES.common.warning): string {\n return showNotification({\n withBorder: true,\n color: 'yellow',\n title,\n message\n });\n}\n\n/**\n * Shows an error.\n * @param error error to show, used when there is no `message`\n * @param message message of the notification; if absent, the message of the error\n * @param title title of the notification; components give the one of their locale (`common.error`)\n * @return the id of the notification, to hide it later with {@link hideNotification}\n */\nexport function showErrorNotification(\n error: unknown,\n message?: string,\n title: string = DEFAULT_MESSAGES.common.error\n): string {\n return showNotification({\n withBorder: true,\n color: 'red',\n title,\n message: message ?? errorMessage(error)\n });\n}\n\n/**\n * Returns the message of an error, to show to the user.\n * @param error the error, which may be an {@link Error}, an object with `message` or any other thrown value\n * @return the `message` attribute of the error, if any, or the error itself converted to text\n */\nexport function errorMessage(error: unknown): string {\n if (typeof error === 'object' && error !== null && 'message' in error) return String(error.message);\n return String(error);\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,wBAAwB,SAAiB,QAAgB,iBAAiB,OAAO,SAAiB;CAC9G,OAAO,iBAAiB;EACpB,YAAY;EACZ,OAAO;EACP;EACA;CACJ,CAAC;AACL;;;;;;;AAQA,SAAgB,wBAAwB,SAAiB,QAAgB,iBAAiB,OAAO,SAAiB;CAC9G,OAAO,iBAAiB;EACpB,YAAY;EACZ,OAAO;EACP;EACA;CACJ,CAAC;AACL;;;;;;;;AASA,SAAgB,sBACZ,OACA,SACA,QAAgB,iBAAiB,OAAO,OAClC;CACN,OAAO,iBAAiB;EACpB,YAAY;EACZ,OAAO;EACP;EACA,SAAS,WAAW,aAAa,KAAK;CAC1C,CAAC;AACL;;;;;;AAOA,SAAgB,aAAa,OAAwB;CACjD,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,OAAO,OAAO,OAAO,MAAM,OAAO;CAClG,OAAO,OAAO,KAAK;AACvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the fractional part of a number.
|
|
3
|
+
* @param value number to get the fractional part from
|
|
4
|
+
*/
|
|
5
|
+
declare function getDecimalPlaces(value: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Checks whether a number has no fractional part.
|
|
8
|
+
* @param value number to check
|
|
9
|
+
*/
|
|
10
|
+
declare function hasNoDecimalPlaces(value: number): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Formats a number according to a locale, with a fixed number of decimal places.
|
|
13
|
+
* @param number number to format
|
|
14
|
+
* @param minimumFractionDigits decimal places shown (the number is rounded to them)
|
|
15
|
+
* @param locale locale of the format; defaults to `en-US`
|
|
16
|
+
* @return the formatted number, such as "1.234,56" in `pt-BR` or "1,234.56" in `en-US`
|
|
17
|
+
*/
|
|
18
|
+
declare function numberFormat(number: number, minimumFractionDigits?: number, locale?: string): string;
|
|
19
|
+
export { getDecimalPlaces, hasNoDecimalPlaces, numberFormat };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DEFAULT_LOCALE } from "../i18n/KitLocale.js";
|
|
3
|
+
// src/util/NumberUtil.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns the fractional part of a number.
|
|
6
|
+
* @param value number to get the fractional part from
|
|
7
|
+
*/
|
|
8
|
+
function getDecimalPlaces(value) {
|
|
9
|
+
return value - Number(value.toFixed(0));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Checks whether a number has no fractional part.
|
|
13
|
+
* @param value number to check
|
|
14
|
+
*/
|
|
15
|
+
function hasNoDecimalPlaces(value) {
|
|
16
|
+
return getDecimalPlaces(value) === 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Formats a number according to a locale, with a fixed number of decimal places.
|
|
20
|
+
* @param number number to format
|
|
21
|
+
* @param minimumFractionDigits decimal places shown (the number is rounded to them)
|
|
22
|
+
* @param locale locale of the format; defaults to `en-US`
|
|
23
|
+
* @return the formatted number, such as "1.234,56" in `pt-BR` or "1,234.56" in `en-US`
|
|
24
|
+
*/
|
|
25
|
+
function numberFormat(number, minimumFractionDigits = 2, locale = DEFAULT_LOCALE) {
|
|
26
|
+
return new Intl.NumberFormat(locale, {
|
|
27
|
+
minimumFractionDigits,
|
|
28
|
+
maximumFractionDigits: minimumFractionDigits
|
|
29
|
+
}).format(number);
|
|
30
|
+
}
|
|
31
|
+
export { getDecimalPlaces, hasNoDecimalPlaces, numberFormat };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=NumberUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberUtil.js","names":[],"sources":["../../src/util/NumberUtil.ts"],"sourcesContent":["import { DEFAULT_LOCALE } from '../i18n/KitLocale';\n\n/**\n * Returns the fractional part of a number.\n * @param value number to get the fractional part from\n */\nfunction getDecimalPlaces(value: number): number {\n return value - Number(value.toFixed(0));\n}\n\n/**\n * Checks whether a number has no fractional part.\n * @param value number to check\n */\nfunction hasNoDecimalPlaces(value: number): boolean {\n return getDecimalPlaces(value) === 0;\n}\n\n/**\n * Formats a number according to a locale, with a fixed number of decimal places.\n * @param number number to format\n * @param minimumFractionDigits decimal places shown (the number is rounded to them)\n * @param locale locale of the format; defaults to `en-US`\n * @return the formatted number, such as \"1.234,56\" in `pt-BR` or \"1,234.56\" in `en-US`\n */\nfunction numberFormat(number: number, minimumFractionDigits: number = 2, locale: string = DEFAULT_LOCALE): string {\n const formatter = new Intl.NumberFormat(locale, {\n minimumFractionDigits,\n maximumFractionDigits: minimumFractionDigits\n });\n return formatter.format(number);\n}\n\nexport { getDecimalPlaces, hasNoDecimalPlaces, numberFormat };\n"],"mappings":";;;;;;;AAMA,SAAS,iBAAiB,OAAuB;CAC7C,OAAO,QAAQ,OAAO,MAAM,QAAQ,CAAC,CAAC;AAC1C;;;;;AAMA,SAAS,mBAAmB,OAAwB;CAChD,OAAO,iBAAiB,KAAK,MAAM;AACvC;;;;;;;;AASA,SAAS,aAAa,QAAgB,wBAAgC,GAAG,SAAiB,gBAAwB;CAK9G,OAAO,IAJe,KAAK,aAAa,QAAQ;EAC5C;EACA,uBAAuB;CAC3B,CACO,CAAA,CAAU,OAAO,MAAM;AAClC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain object, whose attributes can be read and assigned by name.
|
|
3
|
+
*/
|
|
4
|
+
type PlainObject = Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Checks whether a value is a plain object (a `{}` literal), and not an array, `null`, a date, a function etc.
|
|
7
|
+
* Only plain objects are merged recursively by {@link mergeDeep}.
|
|
8
|
+
* @param value value to check
|
|
9
|
+
* @return `true` if the value is a plain object, which can be merged recursively
|
|
10
|
+
*/
|
|
11
|
+
export declare function isPlainObject(value: unknown): value is PlainObject;
|
|
12
|
+
/**
|
|
13
|
+
* Merges two objects recursively, returning a new object without changing the original ones.
|
|
14
|
+
* The attributes of `override` take precedence over the ones of `base`. When an attribute is a plain object in both,
|
|
15
|
+
* they are merged recursively; otherwise (including arrays), the value of `override` replaces the one of `base`.
|
|
16
|
+
* `undefined` attributes in `override` are ignored, keeping the value of `base`.
|
|
17
|
+
* @param base object with the default values
|
|
18
|
+
* @param override object with the values that replace the ones of `base`
|
|
19
|
+
* @return a new object with both merged
|
|
20
|
+
*/
|
|
21
|
+
export declare function mergeDeep<T extends object>(base: T, override: Partial<T>): T;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/util/ObjectUtil.ts
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether a value is a plain object (a `{}` literal), and not an array, `null`, a date, a function etc.
|
|
5
|
+
* Only plain objects are merged recursively by {@link mergeDeep}.
|
|
6
|
+
* @param value value to check
|
|
7
|
+
* @return `true` if the value is a plain object, which can be merged recursively
|
|
8
|
+
*/
|
|
9
|
+
function isPlainObject(value) {
|
|
10
|
+
if (value === null || typeof value !== "object") return false;
|
|
11
|
+
const prototype = Object.getPrototypeOf(value);
|
|
12
|
+
return prototype === Object.prototype || prototype === null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Merges two objects recursively, returning a new object without changing the original ones.
|
|
16
|
+
* The attributes of `override` take precedence over the ones of `base`. When an attribute is a plain object in both,
|
|
17
|
+
* they are merged recursively; otherwise (including arrays), the value of `override` replaces the one of `base`.
|
|
18
|
+
* `undefined` attributes in `override` are ignored, keeping the value of `base`.
|
|
19
|
+
* @param base object with the default values
|
|
20
|
+
* @param override object with the values that replace the ones of `base`
|
|
21
|
+
* @return a new object with both merged
|
|
22
|
+
*/
|
|
23
|
+
function mergeDeep(base, override) {
|
|
24
|
+
const result = { ...base };
|
|
25
|
+
for (const [key, overrideValue] of Object.entries(override)) {
|
|
26
|
+
if (overrideValue === void 0) continue;
|
|
27
|
+
const baseValue = result[key];
|
|
28
|
+
result[key] = isPlainObject(baseValue) && isPlainObject(overrideValue) ? mergeDeep(baseValue, overrideValue) : overrideValue;
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
export { isPlainObject, mergeDeep };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=ObjectUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectUtil.js","names":[],"sources":["../../src/util/ObjectUtil.ts"],"sourcesContent":["/**\n * Plain object, whose attributes can be read and assigned by name.\n */\ntype PlainObject = Record<string, unknown>;\n\n/**\n * Checks whether a value is a plain object (a `{}` literal), and not an array, `null`, a date, a function etc.\n * Only plain objects are merged recursively by {@link mergeDeep}.\n * @param value value to check\n * @return `true` if the value is a plain object, which can be merged recursively\n */\nexport function isPlainObject(value: unknown): value is PlainObject {\n if (value === null || typeof value !== 'object') return false;\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Merges two objects recursively, returning a new object without changing the original ones.\n * The attributes of `override` take precedence over the ones of `base`. When an attribute is a plain object in both,\n * they are merged recursively; otherwise (including arrays), the value of `override` replaces the one of `base`.\n * `undefined` attributes in `override` are ignored, keeping the value of `base`.\n * @param base object with the default values\n * @param override object with the values that replace the ones of `base`\n * @return a new object with both merged\n */\nexport function mergeDeep<T extends object>(base: T, override: Partial<T>): T {\n const result = { ...base } as PlainObject;\n\n for (const [key, overrideValue] of Object.entries(override)) {\n if (overrideValue === undefined) continue;\n\n const baseValue = result[key];\n result[key] =\n isPlainObject(baseValue) && isPlainObject(overrideValue)\n ? mergeDeep(baseValue, overrideValue)\n : overrideValue;\n }\n\n return result as T;\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,cAAc,OAAsC;CAChE,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CACxD,MAAM,YAAY,OAAO,eAAe,KAAK;CAE7C,OAAO,cAAc,OAAO,aAAa,cAAc;AAC3D;;;;;;;;;;AAWA,SAAgB,UAA4B,MAAS,UAAyB;CAC1E,MAAM,SAAS,EAAE,GAAG,KAAK;CAEzB,KAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,QAAQ,GAAG;EACzD,IAAI,kBAAkB,KAAA,GAAW;EAEjC,MAAM,YAAY,OAAO;EACzB,OAAO,OACH,cAAc,SAAS,KAAK,cAAc,aAAa,IACjD,UAAU,WAAW,aAAa,IAClC;CACd;CAEA,OAAO;AACX"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query string in the format of the `searchParams` prop that Next.js gives to pages (in a `Promise`, since Next.js
|
|
3
|
+
* 15): each parameter has a value, an array of values (when it repeats in the URL) or `undefined` (when it is absent).
|
|
4
|
+
*/
|
|
5
|
+
type SearchParams = Record<string, string | string[] | undefined>;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the value of a query string parameter received by a page.
|
|
8
|
+
* @param searchParams URL parameters, as received by the page (already resolved with `use()` or `await`)
|
|
9
|
+
* @param name name of the parameter
|
|
10
|
+
* @return the value of the parameter; the first one, if it repeats in the URL; or `null`, if it is absent
|
|
11
|
+
*/
|
|
12
|
+
declare function getSearchParam(searchParams: SearchParams, name: string): string | null;
|
|
13
|
+
/** Value of a parameter when building a URL. `undefined`, `null` and an empty string leave the parameter out. */
|
|
14
|
+
type SearchParamValue = number | string | null | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Builds a URL with the query string of the parameters that have a value.
|
|
17
|
+
* @param path path of the page
|
|
18
|
+
* @param params parameters indexed by name; the ones without a value ({@link SearchParamValue}) are left out
|
|
19
|
+
* @return the path with the query string, or just the path if no parameter has a value
|
|
20
|
+
*/
|
|
21
|
+
declare function buildUrl(path: string, params: Record<string, SearchParamValue>): string;
|
|
22
|
+
export type { SearchParams, SearchParamValue };
|
|
23
|
+
export { buildUrl, getSearchParam };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/util/SearchParamsUtil.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns the value of a query string parameter received by a page.
|
|
5
|
+
* @param searchParams URL parameters, as received by the page (already resolved with `use()` or `await`)
|
|
6
|
+
* @param name name of the parameter
|
|
7
|
+
* @return the value of the parameter; the first one, if it repeats in the URL; or `null`, if it is absent
|
|
8
|
+
*/
|
|
9
|
+
function getSearchParam(searchParams, name) {
|
|
10
|
+
const value = searchParams[name];
|
|
11
|
+
return (Array.isArray(value) ? value[0] : value) ?? null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Builds a URL with the query string of the parameters that have a value.
|
|
15
|
+
* @param path path of the page
|
|
16
|
+
* @param params parameters indexed by name; the ones without a value ({@link SearchParamValue}) are left out
|
|
17
|
+
* @return the path with the query string, or just the path if no parameter has a value
|
|
18
|
+
*/
|
|
19
|
+
function buildUrl(path, params) {
|
|
20
|
+
const query = new URLSearchParams();
|
|
21
|
+
Object.entries(params).forEach(([name, value]) => {
|
|
22
|
+
if (value !== void 0 && value !== null && value !== "") query.set(name, String(value));
|
|
23
|
+
});
|
|
24
|
+
const queryString = query.toString();
|
|
25
|
+
return queryString ? `${path}?${queryString}` : path;
|
|
26
|
+
}
|
|
27
|
+
export { buildUrl, getSearchParam };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=SearchParamsUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchParamsUtil.js","names":[],"sources":["../../src/util/SearchParamsUtil.ts"],"sourcesContent":["/**\n * Query string in the format of the `searchParams` prop that Next.js gives to pages (in a `Promise`, since Next.js\n * 15): each parameter has a value, an array of values (when it repeats in the URL) or `undefined` (when it is absent).\n */\ntype SearchParams = Record<string, string | string[] | undefined>;\n\n/**\n * Returns the value of a query string parameter received by a page.\n * @param searchParams URL parameters, as received by the page (already resolved with `use()` or `await`)\n * @param name name of the parameter\n * @return the value of the parameter; the first one, if it repeats in the URL; or `null`, if it is absent\n */\nfunction getSearchParam(searchParams: SearchParams, name: string): string | null {\n const value = searchParams[name];\n return (Array.isArray(value) ? value[0] : value) ?? null;\n}\n\n/** Value of a parameter when building a URL. `undefined`, `null` and an empty string leave the parameter out. */\ntype SearchParamValue = number | string | null | undefined;\n\n/**\n * Builds a URL with the query string of the parameters that have a value.\n * @param path path of the page\n * @param params parameters indexed by name; the ones without a value ({@link SearchParamValue}) are left out\n * @return the path with the query string, or just the path if no parameter has a value\n */\nfunction buildUrl(path: string, params: Record<string, SearchParamValue>): string {\n const query = new URLSearchParams();\n Object.entries(params).forEach(([name, value]) => {\n if (value !== undefined && value !== null && value !== '') query.set(name, String(value));\n });\n\n const queryString = query.toString();\n return queryString ? `${path}?${queryString}` : path;\n}\n\nexport type { SearchParams, SearchParamValue };\nexport { buildUrl, getSearchParam };\n"],"mappings":";;;;;;;;AAYA,SAAS,eAAe,cAA4B,MAA6B;CAC7E,MAAM,QAAQ,aAAa;CAC3B,QAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,UAAU;AACxD;;;;;;;AAWA,SAAS,SAAS,MAAc,QAAkD;CAC9E,MAAM,QAAQ,IAAI,gBAAgB;CAClC,OAAO,QAAQ,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,WAAW;EAC9C,IAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IAAI,MAAM,IAAI,MAAM,OAAO,KAAK,CAAC;CAC5F,CAAC;CAED,MAAM,cAAc,MAAM,SAAS;CACnC,OAAO,cAAc,GAAG,KAAK,GAAG,gBAAgB;AACpD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** Converts the dates of the form data, without changing the input or the structure of the arrays. */
|
|
3
|
+
export declare function formatValues(obj: object): Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* If the props of a component have no `placeholder`, builds the placeholder from the `label` prop (e.g. the label
|
|
6
|
+
* "Region" gives "Select the Region" in `en-US`). It is not a React hook: it just transforms the given props.
|
|
7
|
+
* @param placeholder function that builds the placeholder from the label
|
|
8
|
+
* @param props props of the component
|
|
9
|
+
* @return a copy of the props, with the given placeholder or the one built from the label
|
|
10
|
+
*/
|
|
11
|
+
export declare const withPlaceholderFromLabel: <P extends {
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
label?: ReactNode;
|
|
14
|
+
}>(placeholder: (label: string) => string, props: P) => P;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { formatDateToISO } from "./DateUtil.js";
|
|
3
|
+
// src/util/TransformData.ts
|
|
4
|
+
/**
|
|
5
|
+
* Converts a form value to the format sent to the backend: dates in ISO 8601, recursively inside arrays and objects.
|
|
6
|
+
* @param value value of a form field
|
|
7
|
+
*/
|
|
8
|
+
function formatValue(value) {
|
|
9
|
+
if (value instanceof Date) return formatDateToISO(value);
|
|
10
|
+
if (Array.isArray(value)) return value.map(formatValue);
|
|
11
|
+
if (typeof value === "object" && value !== null) return formatValues(value);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
/** Converts the dates of the form data, without changing the input or the structure of the arrays. */
|
|
15
|
+
function formatValues(obj) {
|
|
16
|
+
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, formatValue(value)]));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* If the props of a component have no `placeholder`, builds the placeholder from the `label` prop (e.g. the label
|
|
20
|
+
* "Region" gives "Select the Region" in `en-US`). It is not a React hook: it just transforms the given props.
|
|
21
|
+
* @param placeholder function that builds the placeholder from the label
|
|
22
|
+
* @param props props of the component
|
|
23
|
+
* @return a copy of the props, with the given placeholder or the one built from the label
|
|
24
|
+
*/
|
|
25
|
+
var withPlaceholderFromLabel = (placeholder, props) => ({
|
|
26
|
+
...props,
|
|
27
|
+
placeholder: props.placeholder || placeholder(String(props.label))
|
|
28
|
+
});
|
|
29
|
+
export { formatValues, withPlaceholderFromLabel };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=TransformData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformData.js","names":[],"sources":["../../src/util/TransformData.ts"],"sourcesContent":["import { ReactNode } from 'react';\n\nimport { formatDateToISO } from './DateUtil';\n\n/**\n * Converts a form value to the format sent to the backend: dates in ISO 8601, recursively inside arrays and objects.\n * @param value value of a form field\n */\nfunction formatValue(value: unknown): unknown {\n if (value instanceof Date) return formatDateToISO(value);\n if (Array.isArray(value)) return value.map(formatValue);\n if (typeof value === 'object' && value !== null) return formatValues(value);\n\n return value;\n}\n\n/** Converts the dates of the form data, without changing the input or the structure of the arrays. */\nexport function formatValues(obj: object): Record<string, unknown> {\n return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, formatValue(value)]));\n}\n\n/**\n * If the props of a component have no `placeholder`, builds the placeholder from the `label` prop (e.g. the label\n * \"Region\" gives \"Select the Region\" in `en-US`). It is not a React hook: it just transforms the given props.\n * @param placeholder function that builds the placeholder from the label\n * @param props props of the component\n * @return a copy of the props, with the given placeholder or the one built from the label\n */\nexport const withPlaceholderFromLabel = <P extends { placeholder?: string; label?: ReactNode }>(\n placeholder: (label: string) => string,\n props: P\n): P => ({ ...props, placeholder: props.placeholder || placeholder(String(props.label)) });\n"],"mappings":";;;;;;;AAQA,SAAS,YAAY,OAAyB;CAC1C,IAAI,iBAAiB,MAAM,OAAO,gBAAgB,KAAK;CACvD,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,WAAW;CACtD,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,aAAa,KAAK;CAE1E,OAAO;AACX;;AAGA,SAAgB,aAAa,KAAsC;CAC/D,OAAO,OAAO,YAAY,OAAO,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC;AAClG;;;;;;;;AASA,IAAa,4BACT,aACA,WACK;CAAE,GAAG;CAAO,aAAa,MAAM,eAAe,YAAY,OAAO,MAAM,KAAK,CAAC;AAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the validation rule of a required field that stores the id of an item chosen in a select (e.g. the region
|
|
4
|
+
* of a city). The field starts with `0` (nothing chosen) and receives `null` when the select is cleared; in both cases,
|
|
5
|
+
* the validation fails with the given message.
|
|
6
|
+
* @param message message shown in the field when no valid item was chosen
|
|
7
|
+
* @return the Zod schema that accepts only positive integer ids
|
|
8
|
+
*/
|
|
9
|
+
export declare function selectedId(message: string): z.ZodNumberFormat;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/util/ValidationUtil.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates the validation rule of a required field that stores the id of an item chosen in a select (e.g. the region
|
|
6
|
+
* of a city). The field starts with `0` (nothing chosen) and receives `null` when the select is cleared; in both cases,
|
|
7
|
+
* the validation fails with the given message.
|
|
8
|
+
* @param message message shown in the field when no valid item was chosen
|
|
9
|
+
* @return the Zod schema that accepts only positive integer ids
|
|
10
|
+
*/
|
|
11
|
+
function selectedId(message) {
|
|
12
|
+
return z.int({ error: message }).positive({ error: message });
|
|
13
|
+
}
|
|
14
|
+
export { selectedId };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=ValidationUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationUtil.js","names":[],"sources":["../../src/util/ValidationUtil.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Creates the validation rule of a required field that stores the id of an item chosen in a select (e.g. the region\n * of a city). The field starts with `0` (nothing chosen) and receives `null` when the select is cleared; in both cases,\n * the validation fails with the given message.\n * @param message message shown in the field when no valid item was chosen\n * @return the Zod schema that accepts only positive integer ids\n */\nexport function selectedId(message: string): z.ZodNumberFormat {\n return z.int({ error: message }).positive({ error: message });\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,WAAW,SAAoC;CAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,QAAQ,CAAC;AAChE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormType } from '../component/template/FormPage/FormType';
|
|
2
|
+
import { FormRouteSegments } from '../router/FormRouteSegments';
|
|
3
|
+
/** Action of a form page, read from the URL: create, edit or view, with the record id in the last two. */
|
|
4
|
+
export type FormRoute = {
|
|
5
|
+
action: FormType;
|
|
6
|
+
id?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Converts the segments of the catch-all route of a feature (e.g. `create`, `edit/:id`, `view/:id`) to the
|
|
10
|
+
* form action. Throws an error if the segments do not form one of these routes.
|
|
11
|
+
* @param params URL segments after the route of the feature (e.g. `['edit', '5']`)
|
|
12
|
+
* @param segments names of the create, edit and view segments; defaults to {@link DEFAULT_FORM_ROUTE_SEGMENTS}
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseActionsPageParams(params: string[] | string | null | undefined, segments?: FormRouteSegments): FormRoute;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FormType } from "../component/template/FormPage/FormType.js";
|
|
3
|
+
import { DEFAULT_FORM_ROUTE_SEGMENTS } from "../router/FormRouteSegments.js";
|
|
4
|
+
// src/util/parseActionsPageParams.ts
|
|
5
|
+
/**
|
|
6
|
+
* Converts the segments of the catch-all route of a feature (e.g. `create`, `edit/:id`, `view/:id`) to the
|
|
7
|
+
* form action. Throws an error if the segments do not form one of these routes.
|
|
8
|
+
* @param params URL segments after the route of the feature (e.g. `['edit', '5']`)
|
|
9
|
+
* @param segments names of the create, edit and view segments; defaults to {@link DEFAULT_FORM_ROUTE_SEGMENTS}
|
|
10
|
+
*/
|
|
11
|
+
function parseActionsPageParams(params, segments = DEFAULT_FORM_ROUTE_SEGMENTS) {
|
|
12
|
+
const slugItems = Array.isArray(params) ? params : [params ?? ""];
|
|
13
|
+
const type = slugItems[0];
|
|
14
|
+
const id = slugItems[1];
|
|
15
|
+
if (id && type === segments.edit) return {
|
|
16
|
+
action: FormType.Edit,
|
|
17
|
+
id
|
|
18
|
+
};
|
|
19
|
+
if (id && type === segments.view) return {
|
|
20
|
+
action: FormType.View,
|
|
21
|
+
id
|
|
22
|
+
};
|
|
23
|
+
if (type === segments.create) return { action: FormType.Create };
|
|
24
|
+
const msg = slugItems.length == 1 && slugItems[0] == "" ? "Missing params" : "Invalid params: " + slugItems;
|
|
25
|
+
throw new Error(msg);
|
|
26
|
+
}
|
|
27
|
+
export { parseActionsPageParams };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=parseActionsPageParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseActionsPageParams.js","names":[],"sources":["../../src/util/parseActionsPageParams.ts"],"sourcesContent":["import { FormType } from '../component/template/FormPage/FormType';\nimport { DEFAULT_FORM_ROUTE_SEGMENTS, FormRouteSegments } from '../router/FormRouteSegments';\n\n/** Action of a form page, read from the URL: create, edit or view, with the record id in the last two. */\nexport type FormRoute = { action: FormType; id?: string };\n\n/**\n * Converts the segments of the catch-all route of a feature (e.g. `create`, `edit/:id`, `view/:id`) to the\n * form action. Throws an error if the segments do not form one of these routes.\n * @param params URL segments after the route of the feature (e.g. `['edit', '5']`)\n * @param segments names of the create, edit and view segments; defaults to {@link DEFAULT_FORM_ROUTE_SEGMENTS}\n */\nexport function parseActionsPageParams(\n params: string[] | string | null | undefined,\n segments: FormRouteSegments = DEFAULT_FORM_ROUTE_SEGMENTS\n): FormRoute {\n const slugItems = Array.isArray(params) ? params : [params ?? ''];\n const type = slugItems[0];\n const id = slugItems[1];\n\n if (id && type === segments.edit) {\n return { action: FormType.Edit, id };\n }\n if (id && type === segments.view) {\n return { action: FormType.View, id };\n }\n if (type === segments.create) {\n return { action: FormType.Create };\n }\n\n // An array with a single empty element means that no parameter was given.\n const msg = slugItems.length == 1 && slugItems[0] == '' ? 'Missing params' : 'Invalid params: ' + slugItems;\n throw new Error(msg);\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,uBACZ,QACA,WAA8B,6BACrB;CACT,MAAM,YAAY,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,UAAU,EAAE;CAChE,MAAM,OAAO,UAAU;CACvB,MAAM,KAAK,UAAU;CAErB,IAAI,MAAM,SAAS,SAAS,MACxB,OAAO;EAAE,QAAQ,SAAS;EAAM;CAAG;CAEvC,IAAI,MAAM,SAAS,SAAS,MACxB,OAAO;EAAE,QAAQ,SAAS;EAAM;CAAG;CAEvC,IAAI,SAAS,SAAS,QAClB,OAAO,EAAE,QAAQ,SAAS,OAAO;CAIrC,MAAM,MAAM,UAAU,UAAU,KAAK,UAAU,MAAM,KAAK,mBAAmB,qBAAqB;CAClG,MAAM,IAAI,MAAM,GAAG;AACvB"}
|