@ifto/mantine-kit 0.4.0 → 0.5.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.
Files changed (35) hide show
  1. package/README.md +81 -10
  2. package/dist/component/organism/Table/Table.d.ts +9 -9
  3. package/dist/component/organism/Table/Table.js +21 -24
  4. package/dist/component/organism/Table/Table.js.map +1 -1
  5. package/dist/component/organism/Table/TableData.d.ts +24 -0
  6. package/dist/component/organism/Table/TableData.js +1 -0
  7. package/dist/component/organism/Table/useClientPagination.d.ts +21 -0
  8. package/dist/component/organism/Table/useClientPagination.js +43 -0
  9. package/dist/component/organism/Table/useClientPagination.js.map +1 -0
  10. package/dist/component/organism/Table/useServerPagination.d.ts +24 -0
  11. package/dist/component/organism/Table/useServerPagination.js +105 -0
  12. package/dist/component/organism/Table/useServerPagination.js.map +1 -0
  13. package/dist/component/organism/ViewTable/DataTableView.d.ts +39 -0
  14. package/dist/component/organism/ViewTable/DataTableView.js +52 -0
  15. package/dist/component/organism/ViewTable/DataTableView.js.map +1 -0
  16. package/dist/component/organism/ViewTable/TableState.d.ts +30 -0
  17. package/dist/component/organism/ViewTable/TableState.js +19 -0
  18. package/dist/component/organism/ViewTable/TableState.js.map +1 -0
  19. package/dist/component/organism/ViewTable/ViewTable.d.ts +11 -33
  20. package/dist/component/organism/ViewTable/ViewTable.js +16 -101
  21. package/dist/component/organism/ViewTable/ViewTable.js.map +1 -1
  22. package/dist/component/organism/ViewTable/useClientTableState.d.ts +25 -0
  23. package/dist/component/organism/ViewTable/useClientTableState.js +68 -0
  24. package/dist/component/organism/ViewTable/useClientTableState.js.map +1 -0
  25. package/dist/component/template/ListPage/ListPage.d.ts +9 -19
  26. package/dist/component/template/ListPage/ListPage.js +5 -14
  27. package/dist/component/template/ListPage/ListPage.js.map +1 -1
  28. package/dist/data/PageDataSource.d.ts +10 -0
  29. package/dist/data/PageDataSource.js +1 -0
  30. package/dist/data/PageRequest.d.ts +29 -0
  31. package/dist/data/PageRequest.js +1 -0
  32. package/dist/hook/useService.d.ts +3 -3
  33. package/dist/hook/useService.js +2 -0
  34. package/dist/hook/useService.js.map +1 -1
  35. package/package.json +1 -1
@@ -7,6 +7,8 @@ function useService(fetchMethod, initialData) {
7
7
  const [loading, setLoading] = useState(true);
8
8
  useEffect(() => {
9
9
  let obsolete = false;
10
+ setLoading(true);
11
+ setError(null);
10
12
  fetchMethod().then((responseData) => !obsolete && setData(responseData)).catch((e) => !obsolete && setError(e)).finally(() => !obsolete && setLoading(false));
11
13
  return () => {
12
14
  obsolete = true;
@@ -1 +1 @@
1
- {"version":3,"file":"useService.js","names":[],"sources":["../../src/hook/useService.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** Values returned by {@link useService}. */\nexport type UseService<D> = {\n /** Data of the fetch, or the initial value while it has not finished (or if it failed). */\n data: D;\n\n /** Error of the fetch; `null` if it has not finished yet or succeeded. */\n error: unknown | null;\n\n /** Whether the fetch has not finished yet. */\n loading: boolean;\n};\n\n/**\n * Fetches data when the component mounts and every time `fetchMethod` changes.\n * Without an initial value, `data` is `undefined` while loading (or after a failure), so the caller must handle it.\n * @param fetchMethod function that fetches the data. It must be stable (e.g. with `useCallback`), since a new function\n * triggers a new fetch\n * @return the data (`undefined` until the fetch finishes), the error and whether the fetch is still running\n */\nfunction useService<T>(fetchMethod: () => Promise<T>): UseService<T | undefined>;\n\n/**\n * Fetches data when the component mounts and every time `fetchMethod` changes, starting with the given value (e.g. an\n * empty array for a list), so `data` always has the type of the fetched data.\n * @param fetchMethod function that fetches the data. It must be stable (e.g. with `useCallback`), since a new function\n * triggers a new fetch\n * @param initialData value of `data` until the fetch finishes (and after a failure)\n * @return the data, the error and whether the fetch is still running\n */\nfunction useService<T>(fetchMethod: () => Promise<T>, initialData: T): UseService<T>;\n\nfunction useService<T>(fetchMethod: () => Promise<T>, initialData?: T): UseService<T | undefined> {\n const [data, setData] = useState<T | undefined>(initialData);\n const [error, setError] = useState<unknown | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n /* When fetchMethod changes (e.g. another filter), the previous fetch becomes obsolete. If its response arrives\n after the one of the new fetch, it cannot overwrite the current data. */\n let obsolete = false;\n fetchMethod()\n .then(responseData => !obsolete && setData(responseData))\n .catch(e => !obsolete && setError(e))\n .finally(() => !obsolete && setLoading(false));\n\n return () => {\n obsolete = true;\n };\n }, [fetchMethod]);\n\n return { data, error, loading };\n}\n\nexport default useService;\n"],"mappings":";;;AAiCA,SAAS,WAAc,aAA+B,aAA4C;CAC9F,MAAM,CAAC,MAAM,WAAW,SAAwB,WAAW;CAC3D,MAAM,CAAC,OAAO,YAAY,SAAyB,IAAI;CACvD,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAE3C,gBAAgB;EAGZ,IAAI,WAAW;EACf,YAAY,CAAC,CACR,MAAK,iBAAgB,CAAC,YAAY,QAAQ,YAAY,CAAC,CAAC,CACxD,OAAM,MAAK,CAAC,YAAY,SAAS,CAAC,CAAC,CAAC,CACpC,cAAc,CAAC,YAAY,WAAW,KAAK,CAAC;EAEjD,aAAa;GACT,WAAW;EACf;CACJ,GAAG,CAAC,WAAW,CAAC;CAEhB,OAAO;EAAE;EAAM;EAAO;CAAQ;AAClC"}
1
+ {"version":3,"file":"useService.js","names":[],"sources":["../../src/hook/useService.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** Values returned by {@link useService}. */\nexport type UseService<D> = {\n /** Data of the last successful fetch, or the initial value if none has finished yet. */\n data: D;\n\n /** Error of the current fetch; `null` if it has not finished yet or succeeded. */\n error: unknown | null;\n\n /** Whether the current fetch has not finished yet. */\n loading: boolean;\n};\n\n/**\n * Fetches data when the component mounts and every time `fetchMethod` changes.\n * Without an initial value, `data` is `undefined` while loading (or after a failure), so the caller must handle it.\n * @param fetchMethod function that fetches the data. It must be stable (e.g. with `useCallback`), since a new function\n * triggers a new fetch\n * @return the data (`undefined` until the fetch finishes), the error and whether the fetch is still running\n */\nfunction useService<T>(fetchMethod: () => Promise<T>): UseService<T | undefined>;\n\n/**\n * Fetches data when the component mounts and every time `fetchMethod` changes, starting with the given value (e.g. an\n * empty array for a list), so `data` always has the type of the fetched data.\n * @param fetchMethod function that fetches the data. It must be stable (e.g. with `useCallback`), since a new function\n * triggers a new fetch\n * @param initialData value of `data` until the fetch finishes (and after a failure)\n * @return the data, the error and whether the fetch is still running\n */\nfunction useService<T>(fetchMethod: () => Promise<T>, initialData: T): UseService<T>;\n\nfunction useService<T>(fetchMethod: () => Promise<T>, initialData?: T): UseService<T | undefined> {\n const [data, setData] = useState<T | undefined>(initialData);\n const [error, setError] = useState<unknown | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n /* When fetchMethod changes (e.g. another filter), the previous fetch becomes obsolete. If its response arrives\n after the one of the new fetch, it cannot overwrite the current data. */\n let obsolete = false;\n setLoading(true);\n setError(null);\n fetchMethod()\n .then(responseData => !obsolete && setData(responseData))\n .catch(e => !obsolete && setError(e))\n .finally(() => !obsolete && setLoading(false));\n\n return () => {\n obsolete = true;\n };\n }, [fetchMethod]);\n\n return { data, error, loading };\n}\n\nexport default useService;\n"],"mappings":";;;AAiCA,SAAS,WAAc,aAA+B,aAA4C;CAC9F,MAAM,CAAC,MAAM,WAAW,SAAwB,WAAW;CAC3D,MAAM,CAAC,OAAO,YAAY,SAAyB,IAAI;CACvD,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAE3C,gBAAgB;EAGZ,IAAI,WAAW;EACf,WAAW,IAAI;EACf,SAAS,IAAI;EACb,YAAY,CAAC,CACR,MAAK,iBAAgB,CAAC,YAAY,QAAQ,YAAY,CAAC,CAAC,CACxD,OAAM,MAAK,CAAC,YAAY,SAAS,CAAC,CAAC,CAAC,CACpC,cAAc,CAAC,YAAY,WAAW,KAAK,CAAC;EAEjD,aAAa;GACT,WAAW;EACf;CACJ,GAAG,CAAC,WAAW,CAAC;CAEhB,OAAO;EAAE;EAAM;EAAO;CAAQ;AAClC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifto/mantine-kit",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "General purpose Mantine components for React apps: CRUD tables and forms, layout, ECharts charts, Excel/CSV export, print pages and a REST HTTP client, with i18n (en-US and pt-BR).",
5
5
  "license": "MIT",
6
6
  "author": "IFTO - Campus Palmas",