@gaddario98/react-core 2.1.7 → 2.1.9
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/form/index.js +7 -32
- package/dist/form/index.js.map +1 -1
- package/dist/form/index.mjs +5 -30
- package/dist/form/index.mjs.map +1 -1
- package/dist/pages/index.d.ts +14 -11
- package/dist/pages/index.js +80 -143
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/index.mjs +80 -143
- package/dist/pages/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/pages/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx,jsxs}from'react/jsx-runtime';import {useRef,useState,useEffect,useCallback,memo,useMemo,createContext,useContext}from'react';import {
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import {useRef,useState,useEffect,useCallback,memo,useMemo,createContext,useContext}from'react';import {c}from'react/compiler-runtime';import {atomStateGenerator}from'../state/index.mjs';import equal from'fast-deep-equal';import {useFormValues,useFormManager}from'../form/index.mjs';import {atom,useAtom}from'jotai';import {useApiValues,useApiConfigValue,useApi,useInvalidateQueries}from'../queries/index.mjs';import {atomFamily}from'jotai-family';import {QueryObserver}from'@tanstack/react-query';/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -1534,147 +1534,88 @@ function useFormData({
|
|
|
1534
1534
|
formData
|
|
1535
1535
|
};
|
|
1536
1536
|
};const EMPTY_ARRAY = [];
|
|
1537
|
-
const usePageConfig =
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
} = t0;
|
|
1548
|
-
const queries = t1 === undefined ? EMPTY_ARRAY : t1;
|
|
1549
|
-
let t3;
|
|
1550
|
-
if ($[0] !== t2) {
|
|
1551
|
-
t3 = t2 === undefined ? {} : t2;
|
|
1552
|
-
$[0] = t2;
|
|
1553
|
-
$[1] = t3;
|
|
1554
|
-
} else {
|
|
1555
|
-
t3 = $[1];
|
|
1556
|
-
}
|
|
1557
|
-
const viewSettings = t3;
|
|
1537
|
+
const usePageConfig = ({
|
|
1538
|
+
queries = EMPTY_ARRAY,
|
|
1539
|
+
form,
|
|
1540
|
+
ns,
|
|
1541
|
+
viewSettings = {},
|
|
1542
|
+
meta,
|
|
1543
|
+
variables,
|
|
1544
|
+
pageId
|
|
1545
|
+
}) => {
|
|
1546
|
+
// Use global config usage if needed, but per-page config is primary
|
|
1558
1547
|
const globalConfig = usePageConfigValue();
|
|
1559
|
-
|
|
1560
|
-
if ($[2] !== form || $[3] !== ns || $[4] !== pageId) {
|
|
1561
|
-
t4 = {
|
|
1562
|
-
form,
|
|
1563
|
-
pageId,
|
|
1564
|
-
ns
|
|
1565
|
-
};
|
|
1566
|
-
$[2] = form;
|
|
1567
|
-
$[3] = ns;
|
|
1568
|
-
$[4] = pageId;
|
|
1569
|
-
$[5] = t4;
|
|
1570
|
-
} else {
|
|
1571
|
-
t4 = $[5];
|
|
1572
|
-
}
|
|
1548
|
+
// 1. Form Management
|
|
1573
1549
|
const {
|
|
1574
1550
|
formData
|
|
1575
|
-
} = usePageFormManager(
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
initialValues: variables
|
|
1581
|
-
};
|
|
1582
|
-
$[6] = pageId;
|
|
1583
|
-
$[7] = variables;
|
|
1584
|
-
$[8] = t5;
|
|
1585
|
-
} else {
|
|
1586
|
-
t5 = $[8];
|
|
1587
|
-
}
|
|
1551
|
+
} = usePageFormManager({
|
|
1552
|
+
form,
|
|
1553
|
+
pageId,
|
|
1554
|
+
ns
|
|
1555
|
+
});
|
|
1588
1556
|
const {
|
|
1589
1557
|
get,
|
|
1590
1558
|
set
|
|
1591
|
-
} = usePageValues(
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
$[17] = t7;
|
|
1641
|
-
} else {
|
|
1642
|
-
t7 = $[17];
|
|
1643
|
-
}
|
|
1644
|
-
useApi(processedQueries, t7);
|
|
1645
|
-
let t8;
|
|
1646
|
-
if ($[18] !== pageId || $[19] !== viewSettings) {
|
|
1647
|
-
t8 = {
|
|
1648
|
-
viewSettings,
|
|
1649
|
-
pageId
|
|
1650
|
-
};
|
|
1651
|
-
$[18] = pageId;
|
|
1652
|
-
$[19] = viewSettings;
|
|
1653
|
-
$[20] = t8;
|
|
1654
|
-
} else {
|
|
1655
|
-
t8 = $[20];
|
|
1656
|
-
}
|
|
1657
|
-
const mappedViewSettings = useViewSettings(t8);
|
|
1658
|
-
let t9;
|
|
1659
|
-
if ($[21] !== form || $[22] !== formData || $[23] !== globalConfig || $[24] !== mappedViewSettings || $[25] !== meta) {
|
|
1660
|
-
t9 = {
|
|
1559
|
+
} = usePageValues({
|
|
1560
|
+
pageId,
|
|
1561
|
+
initialValues: variables
|
|
1562
|
+
});
|
|
1563
|
+
// 2. Query Generation
|
|
1564
|
+
const processedQueries = useMemo(() => {
|
|
1565
|
+
return queries.map(q => {
|
|
1566
|
+
if (q.type === "mutation") {
|
|
1567
|
+
const mutationConfig = typeof q.mutationConfig === "function" ? q.mutationConfig({
|
|
1568
|
+
get,
|
|
1569
|
+
set
|
|
1570
|
+
}) : q.mutationConfig;
|
|
1571
|
+
return Object.assign(Object.assign({}, q), {
|
|
1572
|
+
mutationConfig
|
|
1573
|
+
});
|
|
1574
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1575
|
+
} else if (q.type === "query") {
|
|
1576
|
+
const queryConfig = typeof q.queryConfig === "function" ? q.queryConfig({
|
|
1577
|
+
get,
|
|
1578
|
+
set
|
|
1579
|
+
}) : q.queryConfig;
|
|
1580
|
+
return Object.assign(Object.assign({}, q), {
|
|
1581
|
+
queryConfig
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
return q;
|
|
1585
|
+
});
|
|
1586
|
+
}, [queries, get, set]);
|
|
1587
|
+
useApi(processedQueries, {
|
|
1588
|
+
persistToAtoms: true,
|
|
1589
|
+
scopeId: pageId
|
|
1590
|
+
});
|
|
1591
|
+
const {
|
|
1592
|
+
invalidateQueries
|
|
1593
|
+
} = useInvalidateQueries();
|
|
1594
|
+
const refreshQueries = useCallback(() => {
|
|
1595
|
+
processedQueries.filter(el => el.type === "query").forEach(({
|
|
1596
|
+
queryConfig: queryConfig_0
|
|
1597
|
+
}) => {
|
|
1598
|
+
if (queryConfig_0 === null || queryConfig_0 === void 0 ? void 0 : queryConfig_0.queryKey) invalidateQueries([queryConfig_0 === null || queryConfig_0 === void 0 ? void 0 : queryConfig_0.queryKey]);
|
|
1599
|
+
});
|
|
1600
|
+
}, [processedQueries]);
|
|
1601
|
+
const mappedViewSettings = useViewSettings({
|
|
1602
|
+
viewSettings,
|
|
1603
|
+
pageId
|
|
1604
|
+
});
|
|
1605
|
+
// Merge custom configuration with defaults
|
|
1606
|
+
const mergedConfig = useMemo(() => {
|
|
1607
|
+
return {
|
|
1661
1608
|
formData,
|
|
1662
1609
|
form,
|
|
1663
1610
|
mappedViewSettings,
|
|
1664
1611
|
meta,
|
|
1665
|
-
globalConfig
|
|
1612
|
+
globalConfig // Expose global config if needed
|
|
1666
1613
|
};
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
$[26] = t9;
|
|
1673
|
-
} else {
|
|
1674
|
-
t9 = $[26];
|
|
1675
|
-
}
|
|
1676
|
-
const mergedConfig = t9;
|
|
1677
|
-
return mergedConfig;
|
|
1614
|
+
}, [formData, form, mappedViewSettings, meta, globalConfig]);
|
|
1615
|
+
return {
|
|
1616
|
+
mergedConfig,
|
|
1617
|
+
refreshQueries
|
|
1618
|
+
};
|
|
1678
1619
|
};/**
|
|
1679
1620
|
* Hook for evaluating and managing dynamic metadata.
|
|
1680
1621
|
*
|
|
@@ -1921,7 +1862,10 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
1921
1862
|
viewSettings,
|
|
1922
1863
|
ns
|
|
1923
1864
|
} = useMemo(() => selectedProps, [selectedProps]);
|
|
1924
|
-
const
|
|
1865
|
+
const {
|
|
1866
|
+
mergedConfig,
|
|
1867
|
+
refreshQueries
|
|
1868
|
+
} = usePageConfig({
|
|
1925
1869
|
queries,
|
|
1926
1870
|
form,
|
|
1927
1871
|
ns: ns !== null && ns !== void 0 ? ns : "",
|
|
@@ -1929,9 +1873,6 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
1929
1873
|
pageId: id,
|
|
1930
1874
|
variables
|
|
1931
1875
|
});
|
|
1932
|
-
const {
|
|
1933
|
-
mappedViewSettings
|
|
1934
|
-
} = config;
|
|
1935
1876
|
const {
|
|
1936
1877
|
allContents,
|
|
1937
1878
|
body,
|
|
@@ -1941,8 +1882,11 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
1941
1882
|
contents,
|
|
1942
1883
|
pageId: id,
|
|
1943
1884
|
ns,
|
|
1944
|
-
pageConfig:
|
|
1885
|
+
pageConfig: mergedConfig
|
|
1945
1886
|
});
|
|
1887
|
+
const {
|
|
1888
|
+
mappedViewSettings
|
|
1889
|
+
} = mergedConfig;
|
|
1946
1890
|
const LayoutComponent = useMemo(() => {
|
|
1947
1891
|
var _a_0;
|
|
1948
1892
|
return (_a_0 = mappedViewSettings.layoutComponent) !== null && _a_0 !== void 0 ? _a_0 : BodyContainer;
|
|
@@ -1960,13 +1904,6 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
1960
1904
|
return (_a_3 = mappedViewSettings.pageContainerProps) !== null && _a_3 !== void 0 ? _a_3 : {};
|
|
1961
1905
|
}, [mappedViewSettings.pageContainerProps]);
|
|
1962
1906
|
const layoutBody = useMemo(() => body, [body]);
|
|
1963
|
-
const store = useStore();
|
|
1964
|
-
const refreshQueries = useCallback(() => {
|
|
1965
|
-
const val = store.get(queriesAtom);
|
|
1966
|
-
Object.values(val).forEach(query => {
|
|
1967
|
-
query.refetch();
|
|
1968
|
-
});
|
|
1969
|
-
}, [store]);
|
|
1970
1907
|
return jsxs(PageContainerComponent, Object.assign({
|
|
1971
1908
|
id: id
|
|
1972
1909
|
}, pageContainerProps, {
|