@equinor/eds-core-react 0.41.4 → 0.42.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/dist/eds-core-react.cjs +242 -121
- package/dist/esm/components/Datepicker/DatePicker.js +49 -46
- package/dist/esm/components/Datepicker/DateRangePicker.js +46 -43
- package/dist/esm/components/Datepicker/fields/FieldWrapper.js +0 -1
- package/dist/esm/components/Datepicker/utils/useGetLocale.js +13 -0
- package/dist/esm/components/Popover/Popover.js +7 -3
- package/dist/esm/components/Scrim/Scrim.js +2 -2
- package/dist/esm/components/Table/Cell.js +7 -0
- package/dist/esm/components/Table/Foot/Foot.js +30 -0
- package/dist/esm/components/Table/Foot/Foot.tokens.js +30 -0
- package/dist/esm/components/Table/FooterCell/FooterCell.js +55 -0
- package/dist/esm/components/Table/Inner.context.js +2 -2
- package/dist/esm/components/Table/index.js +3 -0
- package/dist/types/components/Datepicker/DatePicker.d.ts +1 -0
- package/dist/types/components/Datepicker/props.d.ts +5 -0
- package/dist/types/components/Datepicker/utils/useGetLocale.d.ts +1 -0
- package/dist/types/components/Table/Foot/Foot.d.ts +9 -0
- package/dist/types/components/Table/Foot/Foot.tokens.d.ts +2 -0
- package/dist/types/components/Table/Foot/index.d.ts +1 -0
- package/dist/types/components/Table/FooterCell/FooterCell.d.ts +4 -0
- package/dist/types/components/Table/FooterCell/index.d.ts +1 -0
- package/dist/types/components/Table/Inner.context.d.ts +1 -1
- package/dist/types/components/Table/index.d.ts +3 -1
- package/package.json +3 -3
package/dist/eds-core-react.cjs
CHANGED
|
@@ -859,7 +859,7 @@ const primary$6 = mergeDeepRight(primary$a, contained_icon);
|
|
|
859
859
|
const secondary$1 = mergeDeepRight(secondary$5, contained_icon);
|
|
860
860
|
const danger$2 = mergeDeepRight(danger$6, contained_icon);
|
|
861
861
|
|
|
862
|
-
const token$
|
|
862
|
+
const token$6 = {
|
|
863
863
|
primary: {
|
|
864
864
|
contained: primary$a,
|
|
865
865
|
outlined: primary$9,
|
|
@@ -904,17 +904,17 @@ const InnerFullWidth = /*#__PURE__*/react.forwardRef(function InnerFullWidth({
|
|
|
904
904
|
});
|
|
905
905
|
});
|
|
906
906
|
|
|
907
|
-
const initalState$
|
|
907
|
+
const initalState$2 = {
|
|
908
908
|
/** Density for all components inside `EdsProvider` */
|
|
909
909
|
density: 'comfortable'
|
|
910
910
|
};
|
|
911
|
-
const EdsContext = /*#__PURE__*/react.createContext(initalState$
|
|
911
|
+
const EdsContext = /*#__PURE__*/react.createContext(initalState$2);
|
|
912
912
|
const EdsProvider = ({
|
|
913
913
|
children,
|
|
914
914
|
density
|
|
915
915
|
}) => {
|
|
916
916
|
const [state, setState] = react.useState({
|
|
917
|
-
...initalState$
|
|
917
|
+
...initalState$2,
|
|
918
918
|
density: density || 'comfortable'
|
|
919
919
|
});
|
|
920
920
|
const setDensity = density => setState(prevState => ({
|
|
@@ -955,12 +955,12 @@ const getVariant$1 = (tokenSet, variant) => {
|
|
|
955
955
|
const getToken$1 = (variant, color) => {
|
|
956
956
|
switch (color) {
|
|
957
957
|
case 'danger':
|
|
958
|
-
return getVariant$1(token$
|
|
958
|
+
return getVariant$1(token$6.danger, variant);
|
|
959
959
|
case 'secondary':
|
|
960
|
-
return getVariant$1(token$
|
|
960
|
+
return getVariant$1(token$6.secondary, variant);
|
|
961
961
|
case 'primary':
|
|
962
962
|
default:
|
|
963
|
-
return getVariant$1(token$
|
|
963
|
+
return getVariant$1(token$6.primary, variant);
|
|
964
964
|
}
|
|
965
965
|
};
|
|
966
966
|
const Inner = styled__default.default.span.withConfig({
|
|
@@ -1485,12 +1485,12 @@ const {
|
|
|
1485
1485
|
},
|
|
1486
1486
|
ui: {
|
|
1487
1487
|
background__medium: {
|
|
1488
|
-
rgba: borderColor$
|
|
1488
|
+
rgba: borderColor$5
|
|
1489
1489
|
}
|
|
1490
1490
|
},
|
|
1491
1491
|
interactive: {
|
|
1492
1492
|
table__cell__fill_resting: {
|
|
1493
|
-
rgba: backgroundColor$
|
|
1493
|
+
rgba: backgroundColor$6
|
|
1494
1494
|
},
|
|
1495
1495
|
table__cell__fill_hover: {
|
|
1496
1496
|
rgba: hoverBackgroundColor$3
|
|
@@ -1523,14 +1523,14 @@ const {
|
|
|
1523
1523
|
} = edsTokens.tokens;
|
|
1524
1524
|
const tableCell = {
|
|
1525
1525
|
height: 'var(--eds_table__cell__height, 48px)',
|
|
1526
|
-
background: backgroundColor$
|
|
1526
|
+
background: backgroundColor$6,
|
|
1527
1527
|
align: {
|
|
1528
1528
|
vertical: 'var(--eds_table__cell__vertical_align, inherit)'
|
|
1529
1529
|
},
|
|
1530
1530
|
border: {
|
|
1531
1531
|
type: 'bordergroup',
|
|
1532
1532
|
bottom: {
|
|
1533
|
-
color: borderColor$
|
|
1533
|
+
color: borderColor$5,
|
|
1534
1534
|
width: '1px',
|
|
1535
1535
|
style: 'solid'
|
|
1536
1536
|
}
|
|
@@ -1646,10 +1646,10 @@ const Table$1 = /*#__PURE__*/react.forwardRef(function Table({
|
|
|
1646
1646
|
|
|
1647
1647
|
// Table.displayName = 'EdsTable'
|
|
1648
1648
|
|
|
1649
|
-
const
|
|
1649
|
+
const initialState = {
|
|
1650
1650
|
variant: 'body'
|
|
1651
1651
|
};
|
|
1652
|
-
const InnerContext = /*#__PURE__*/react.createContext(
|
|
1652
|
+
const InnerContext = /*#__PURE__*/react.createContext(initialState);
|
|
1653
1653
|
|
|
1654
1654
|
const TableBase = styled__default.default.tbody.withConfig({
|
|
1655
1655
|
displayName: "Body__TableBase",
|
|
@@ -1671,7 +1671,7 @@ const Body = /*#__PURE__*/react.forwardRef(function Body({
|
|
|
1671
1671
|
});
|
|
1672
1672
|
});
|
|
1673
1673
|
|
|
1674
|
-
const StyledTableCell$
|
|
1674
|
+
const StyledTableCell$2 = styled__default.default.td.withConfig({
|
|
1675
1675
|
displayName: "DataCell__StyledTableCell",
|
|
1676
1676
|
componentId: "sc-15tuitc-0"
|
|
1677
1677
|
})(({
|
|
@@ -1702,7 +1702,7 @@ const TableDataCell = /*#__PURE__*/react.forwardRef(function TableDataCell({
|
|
|
1702
1702
|
}, applyVariant(variant, tableCell));
|
|
1703
1703
|
return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
|
|
1704
1704
|
theme: token,
|
|
1705
|
-
children: /*#__PURE__*/jsxRuntime.jsx(StyledTableCell$
|
|
1705
|
+
children: /*#__PURE__*/jsxRuntime.jsx(StyledTableCell$2, {
|
|
1706
1706
|
...rest,
|
|
1707
1707
|
ref: ref,
|
|
1708
1708
|
children: children
|
|
@@ -1727,12 +1727,12 @@ const {
|
|
|
1727
1727
|
},
|
|
1728
1728
|
ui: {
|
|
1729
1729
|
background__medium: {
|
|
1730
|
-
rgba: borderColor$
|
|
1730
|
+
rgba: borderColor$4
|
|
1731
1731
|
}
|
|
1732
1732
|
},
|
|
1733
1733
|
interactive: {
|
|
1734
1734
|
table__header__fill_resting: {
|
|
1735
|
-
rgba: backgroundColor$
|
|
1735
|
+
rgba: backgroundColor$5
|
|
1736
1736
|
},
|
|
1737
1737
|
table__header__fill_hover: {
|
|
1738
1738
|
rgba: hoverBackgroundColor$2
|
|
@@ -1760,9 +1760,9 @@ const {
|
|
|
1760
1760
|
}
|
|
1761
1761
|
}
|
|
1762
1762
|
} = edsTokens.tokens;
|
|
1763
|
-
const token$
|
|
1763
|
+
const token$5 = {
|
|
1764
1764
|
height: 'var(--eds_table__cell__height, 48px)',
|
|
1765
|
-
background: backgroundColor$
|
|
1765
|
+
background: backgroundColor$5,
|
|
1766
1766
|
align: {
|
|
1767
1767
|
vertical: 'var(--eds_table__cell__vertical_align, inherit)'
|
|
1768
1768
|
},
|
|
@@ -1776,7 +1776,7 @@ const token$4 = {
|
|
|
1776
1776
|
bottom: {
|
|
1777
1777
|
type: 'border',
|
|
1778
1778
|
width: '2px',
|
|
1779
|
-
color: borderColor$
|
|
1779
|
+
color: borderColor$4,
|
|
1780
1780
|
style: 'solid'
|
|
1781
1781
|
}
|
|
1782
1782
|
},
|
|
@@ -1838,7 +1838,7 @@ const token$4 = {
|
|
|
1838
1838
|
}
|
|
1839
1839
|
};
|
|
1840
1840
|
|
|
1841
|
-
const StyledTableCell = styled__default.default.th.withConfig({
|
|
1841
|
+
const StyledTableCell$1 = styled__default.default.th.withConfig({
|
|
1842
1842
|
displayName: "HeaderCell__StyledTableCell",
|
|
1843
1843
|
componentId: "sc-18w2o3a-0"
|
|
1844
1844
|
})(props => {
|
|
@@ -1864,7 +1864,7 @@ const StyledTableCell = styled__default.default.th.withConfig({
|
|
|
1864
1864
|
}
|
|
1865
1865
|
return styled.css(["min-height:", ";height:", ";background:", ";box-sizing:border-box;", " ", " ", " ", " ", " ", ""], height, height, background, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(theme.border), sortStylingHover, sortStylingActive, $sticky ? styled.css(["position:sticky;top:0;z-index:1;"]) : '');
|
|
1866
1866
|
});
|
|
1867
|
-
const CellInner = styled__default.default.div.withConfig({
|
|
1867
|
+
const CellInner$1 = styled__default.default.div.withConfig({
|
|
1868
1868
|
displayName: "HeaderCell__CellInner",
|
|
1869
1869
|
componentId: "sc-18w2o3a-1"
|
|
1870
1870
|
})(["display:flex;align-items:center;"]);
|
|
@@ -1879,7 +1879,7 @@ const TableHeaderCell = /*#__PURE__*/react.forwardRef(function TableHeaderCell({
|
|
|
1879
1879
|
} = useEds();
|
|
1880
1880
|
const token = edsUtils.useToken({
|
|
1881
1881
|
density
|
|
1882
|
-
}, token$
|
|
1882
|
+
}, token$5);
|
|
1883
1883
|
const props = {
|
|
1884
1884
|
ref,
|
|
1885
1885
|
$sticky: sticky,
|
|
@@ -1887,8 +1887,55 @@ const TableHeaderCell = /*#__PURE__*/react.forwardRef(function TableHeaderCell({
|
|
|
1887
1887
|
};
|
|
1888
1888
|
return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
|
|
1889
1889
|
theme: token,
|
|
1890
|
-
children: /*#__PURE__*/jsxRuntime.jsx(StyledTableCell, {
|
|
1890
|
+
children: /*#__PURE__*/jsxRuntime.jsx(StyledTableCell$1, {
|
|
1891
1891
|
"aria-sort": sort,
|
|
1892
|
+
...props,
|
|
1893
|
+
children: /*#__PURE__*/jsxRuntime.jsx(CellInner$1, {
|
|
1894
|
+
children: children
|
|
1895
|
+
})
|
|
1896
|
+
})
|
|
1897
|
+
});
|
|
1898
|
+
});
|
|
1899
|
+
|
|
1900
|
+
const StyledTableCell = styled__default.default.th.withConfig({
|
|
1901
|
+
displayName: "FooterCell__StyledTableCell",
|
|
1902
|
+
componentId: "sc-1xq9z77-0"
|
|
1903
|
+
})(props => {
|
|
1904
|
+
const {
|
|
1905
|
+
theme,
|
|
1906
|
+
$sticky
|
|
1907
|
+
} = props;
|
|
1908
|
+
const {
|
|
1909
|
+
background,
|
|
1910
|
+
height,
|
|
1911
|
+
typography,
|
|
1912
|
+
spacings
|
|
1913
|
+
} = theme;
|
|
1914
|
+
return styled.css(["min-height:", ";height:", ";background:", ";box-sizing:border-box;", " ", " ", " ", ""], height, height, background, edsUtils.spacingsTemplate(spacings), edsUtils.typographyTemplate(typography), edsUtils.bordersTemplate(theme.border), $sticky ? styled.css(["position:sticky;bottom:0;z-index:2;"]) : '');
|
|
1915
|
+
});
|
|
1916
|
+
const CellInner = styled__default.default.div.withConfig({
|
|
1917
|
+
displayName: "FooterCell__CellInner",
|
|
1918
|
+
componentId: "sc-1xq9z77-1"
|
|
1919
|
+
})(["display:flex;align-items:center;"]);
|
|
1920
|
+
const TableFooterCell = /*#__PURE__*/react.forwardRef(function TableFooterCell({
|
|
1921
|
+
children,
|
|
1922
|
+
sticky,
|
|
1923
|
+
...rest
|
|
1924
|
+
}, ref) {
|
|
1925
|
+
const {
|
|
1926
|
+
density
|
|
1927
|
+
} = useEds();
|
|
1928
|
+
const token = edsUtils.useToken({
|
|
1929
|
+
density
|
|
1930
|
+
}, token$5);
|
|
1931
|
+
const props = {
|
|
1932
|
+
ref,
|
|
1933
|
+
$sticky: sticky,
|
|
1934
|
+
...rest
|
|
1935
|
+
};
|
|
1936
|
+
return /*#__PURE__*/jsxRuntime.jsx(styled.ThemeProvider, {
|
|
1937
|
+
theme: token,
|
|
1938
|
+
children: /*#__PURE__*/jsxRuntime.jsx(StyledTableCell, {
|
|
1892
1939
|
...props,
|
|
1893
1940
|
children: /*#__PURE__*/jsxRuntime.jsx(CellInner, {
|
|
1894
1941
|
children: children
|
|
@@ -1912,6 +1959,12 @@ const Cell = /*#__PURE__*/react.forwardRef(function Cell({
|
|
|
1912
1959
|
sticky: sticky,
|
|
1913
1960
|
...rest
|
|
1914
1961
|
});
|
|
1962
|
+
case 'foot':
|
|
1963
|
+
return /*#__PURE__*/jsxRuntime.jsx(TableFooterCell, {
|
|
1964
|
+
ref: ref,
|
|
1965
|
+
sticky: sticky,
|
|
1966
|
+
...rest
|
|
1967
|
+
});
|
|
1915
1968
|
default:
|
|
1916
1969
|
case 'body':
|
|
1917
1970
|
return /*#__PURE__*/jsxRuntime.jsx(TableDataCell, {
|
|
@@ -1927,24 +1980,24 @@ const {
|
|
|
1927
1980
|
colors: {
|
|
1928
1981
|
ui: {
|
|
1929
1982
|
background__medium: {
|
|
1930
|
-
rgba: borderColor$
|
|
1983
|
+
rgba: borderColor$3
|
|
1931
1984
|
}
|
|
1932
1985
|
},
|
|
1933
1986
|
interactive: {
|
|
1934
1987
|
table__header__fill_resting: {
|
|
1935
|
-
rgba: backgroundColor$
|
|
1988
|
+
rgba: backgroundColor$4
|
|
1936
1989
|
}
|
|
1937
1990
|
}
|
|
1938
1991
|
}
|
|
1939
1992
|
} = edsTokens.tokens;
|
|
1940
|
-
const token$
|
|
1941
|
-
background: backgroundColor$
|
|
1993
|
+
const token$4 = {
|
|
1994
|
+
background: backgroundColor$4,
|
|
1942
1995
|
border: {
|
|
1943
1996
|
type: 'bordergroup',
|
|
1944
1997
|
bottom: {
|
|
1945
1998
|
type: 'border',
|
|
1946
1999
|
width: '2px',
|
|
1947
|
-
color: borderColor$
|
|
2000
|
+
color: borderColor$3,
|
|
1948
2001
|
style: 'solid'
|
|
1949
2002
|
}
|
|
1950
2003
|
}
|
|
@@ -1953,7 +2006,7 @@ const token$3 = {
|
|
|
1953
2006
|
const StyledTableHead = styled__default.default.thead.withConfig({
|
|
1954
2007
|
displayName: "Head__StyledTableHead",
|
|
1955
2008
|
componentId: "sc-g9tch7-0"
|
|
1956
|
-
})(["", " background:", ";"], edsUtils.bordersTemplate(token$
|
|
2009
|
+
})(["", " background:", ";"], edsUtils.bordersTemplate(token$4.border), token$4.background);
|
|
1957
2010
|
const Head = /*#__PURE__*/react.forwardRef(function Head({
|
|
1958
2011
|
children,
|
|
1959
2012
|
sticky,
|
|
@@ -1972,6 +2025,55 @@ const Head = /*#__PURE__*/react.forwardRef(function Head({
|
|
|
1972
2025
|
});
|
|
1973
2026
|
});
|
|
1974
2027
|
|
|
2028
|
+
const {
|
|
2029
|
+
colors: {
|
|
2030
|
+
ui: {
|
|
2031
|
+
background__medium: {
|
|
2032
|
+
rgba: borderColor$2
|
|
2033
|
+
}
|
|
2034
|
+
},
|
|
2035
|
+
interactive: {
|
|
2036
|
+
table__header__fill_resting: {
|
|
2037
|
+
rgba: backgroundColor$3
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
} = edsTokens.tokens;
|
|
2042
|
+
const token$3 = {
|
|
2043
|
+
background: backgroundColor$3,
|
|
2044
|
+
border: {
|
|
2045
|
+
type: 'bordergroup',
|
|
2046
|
+
bottom: {
|
|
2047
|
+
type: 'border',
|
|
2048
|
+
width: '2px',
|
|
2049
|
+
color: borderColor$2,
|
|
2050
|
+
style: 'solid'
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
|
|
2055
|
+
const StyledTableFoot = styled__default.default.tfoot.withConfig({
|
|
2056
|
+
displayName: "Foot__StyledTableFoot",
|
|
2057
|
+
componentId: "sc-3w9vih-0"
|
|
2058
|
+
})(["", " background:", ";"], edsUtils.bordersTemplate(token$3.border), token$3.background);
|
|
2059
|
+
const Foot = /*#__PURE__*/react.forwardRef(function Foot({
|
|
2060
|
+
children,
|
|
2061
|
+
sticky,
|
|
2062
|
+
...props
|
|
2063
|
+
}, ref) {
|
|
2064
|
+
return /*#__PURE__*/jsxRuntime.jsx(InnerContext.Provider, {
|
|
2065
|
+
value: {
|
|
2066
|
+
variant: 'foot',
|
|
2067
|
+
sticky
|
|
2068
|
+
},
|
|
2069
|
+
children: /*#__PURE__*/jsxRuntime.jsx(StyledTableFoot, {
|
|
2070
|
+
...props,
|
|
2071
|
+
ref: ref,
|
|
2072
|
+
children: children
|
|
2073
|
+
})
|
|
2074
|
+
});
|
|
2075
|
+
});
|
|
2076
|
+
|
|
1975
2077
|
const {
|
|
1976
2078
|
colors: {
|
|
1977
2079
|
interactive: {
|
|
@@ -2037,11 +2139,13 @@ const Table = Table$1;
|
|
|
2037
2139
|
Table.Body = Body;
|
|
2038
2140
|
Table.Cell = Cell;
|
|
2039
2141
|
Table.Head = Head;
|
|
2142
|
+
Table.Foot = Foot;
|
|
2040
2143
|
Table.Row = Row;
|
|
2041
2144
|
Table.Caption = Caption;
|
|
2042
2145
|
Table.Body.displayName = 'Table.Body';
|
|
2043
2146
|
Table.Cell.displayName = 'Table.Cell';
|
|
2044
2147
|
Table.Head.displayName = 'Table.Head';
|
|
2148
|
+
Table.Foot.displayName = 'Table.Foot';
|
|
2045
2149
|
Table.Row.displayName = 'Table.Row';
|
|
2046
2150
|
Table.Caption.displayName = 'Table.Caption';
|
|
2047
2151
|
|
|
@@ -4743,6 +4847,7 @@ const Scrim = /*#__PURE__*/react.forwardRef(function Scrim({
|
|
|
4743
4847
|
...rest
|
|
4744
4848
|
}, ref) {
|
|
4745
4849
|
const scrimRef = react.useRef(null);
|
|
4850
|
+
edsUtils.useHideBodyScroll(open);
|
|
4746
4851
|
const combinedScrimRef = react.useMemo(() => edsUtils.mergeRefs(scrimRef, ref), [scrimRef, ref]);
|
|
4747
4852
|
edsUtils.useGlobalKeyPress('Escape', () => {
|
|
4748
4853
|
if (isDismissable && onClose && open) {
|
|
@@ -4760,7 +4865,6 @@ const Scrim = /*#__PURE__*/react.forwardRef(function Scrim({
|
|
|
4760
4865
|
return null;
|
|
4761
4866
|
}
|
|
4762
4867
|
return /*#__PURE__*/jsxRuntime.jsx(StyledScrim, {
|
|
4763
|
-
lockScroll: true,
|
|
4764
4868
|
onMouseDown: handleMouseClose,
|
|
4765
4869
|
ref: combinedScrimRef,
|
|
4766
4870
|
...rest,
|
|
@@ -6398,9 +6502,13 @@ const Popover$1 = /*#__PURE__*/react.forwardRef(function Popover({
|
|
|
6398
6502
|
const {
|
|
6399
6503
|
getFloatingProps
|
|
6400
6504
|
} = react$1.useInteractions([react$1.useDismiss(context)]);
|
|
6401
|
-
|
|
6505
|
+
react.useEffect(() => {
|
|
6402
6506
|
if (open) {
|
|
6403
|
-
|
|
6507
|
+
setTimeout(() => {
|
|
6508
|
+
if (refs.floating.current?.isConnected) {
|
|
6509
|
+
refs.floating.current.showPopover();
|
|
6510
|
+
}
|
|
6511
|
+
}, 1);
|
|
6404
6512
|
} else {
|
|
6405
6513
|
refs.floating.current?.hidePopover();
|
|
6406
6514
|
}
|
|
@@ -11669,7 +11777,6 @@ const FieldWrapper = /*#__PURE__*/react.forwardRef(({
|
|
|
11669
11777
|
onClose: () => setIsOpen(false),
|
|
11670
11778
|
anchorEl: ref.current,
|
|
11671
11779
|
placement: 'bottom-start',
|
|
11672
|
-
withinPortal: true,
|
|
11673
11780
|
children: calendar
|
|
11674
11781
|
})]
|
|
11675
11782
|
});
|
|
@@ -11904,6 +12011,16 @@ const getCalendarDate = (value, timezone, showTimeInput = false) => {
|
|
|
11904
12011
|
return showTimeInput ? date.toCalendarDateTime(date.fromDate(value, timezone)) : date.toCalendarDate(date.fromDate(value, timezone));
|
|
11905
12012
|
};
|
|
11906
12013
|
|
|
12014
|
+
const useGetLocale = locale => {
|
|
12015
|
+
const {
|
|
12016
|
+
locale: externalLocale
|
|
12017
|
+
} = reactAria.useLocale();
|
|
12018
|
+
// react-aria defaults to navigator.language if no locale is provided. If these are equal, we override by using the system default locale
|
|
12019
|
+
const defaultLocale = typeof navigator !== 'undefined' && navigator.language || 'en-US';
|
|
12020
|
+
const fallbackLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
12021
|
+
return locale ?? (externalLocale === defaultLocale ? undefined : externalLocale) ?? fallbackLocale;
|
|
12022
|
+
};
|
|
12023
|
+
|
|
11907
12024
|
const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
11908
12025
|
onChange,
|
|
11909
12026
|
label,
|
|
@@ -11914,6 +12031,7 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
11914
12031
|
Footer,
|
|
11915
12032
|
Header,
|
|
11916
12033
|
timezone,
|
|
12034
|
+
locale: propLocale,
|
|
11917
12035
|
defaultValue,
|
|
11918
12036
|
showTimeInput,
|
|
11919
12037
|
granularity,
|
|
@@ -11973,16 +12091,14 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
11973
12091
|
}
|
|
11974
12092
|
}, [onChange, isOpen, showTimeInput, timezone]);
|
|
11975
12093
|
const _value = getCalendarDate(value, timezone, showTimeInput) ?? innerValue;
|
|
11976
|
-
const
|
|
11977
|
-
locale
|
|
11978
|
-
} = reactAria.useLocale();
|
|
12094
|
+
const locale = useGetLocale(propLocale);
|
|
11979
12095
|
const dateCreateProps = {
|
|
11980
12096
|
helperProps,
|
|
11981
12097
|
variant,
|
|
11982
12098
|
isDisabled,
|
|
11983
12099
|
value: _value,
|
|
11984
12100
|
hideTimeZone: true,
|
|
11985
|
-
locale,
|
|
12101
|
+
locale: locale,
|
|
11986
12102
|
createCalendar: date.createCalendar,
|
|
11987
12103
|
onChange: _onChange,
|
|
11988
12104
|
minValue: _minValue,
|
|
@@ -12013,49 +12129,52 @@ const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
12013
12129
|
react.useEffect(() => {
|
|
12014
12130
|
if (!defaultValue && !value) setInnerValue(null);
|
|
12015
12131
|
}, [defaultValue, value]);
|
|
12016
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
label: label,
|
|
12027
|
-
calendar: /*#__PURE__*/jsxRuntime.jsx(Calendar, {
|
|
12028
|
-
ref: pickerRef,
|
|
12029
|
-
Footer: Footer,
|
|
12030
|
-
Header: Header,
|
|
12031
|
-
...calendarProps
|
|
12032
|
-
}),
|
|
12033
|
-
disabled: isDisabled,
|
|
12034
|
-
readOnly: isReadOnly,
|
|
12035
|
-
color: pickerState.isInvalid ? 'warning' : variant,
|
|
12036
|
-
helperProps: helperPropsInvalid ?? helperProps,
|
|
12037
|
-
children: /*#__PURE__*/jsxRuntime.jsx(DateField, {
|
|
12038
|
-
fieldProps: fieldProps,
|
|
12039
|
-
groupProps: groupProps,
|
|
12040
|
-
dateCreateProps: dateCreateProps,
|
|
12132
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactAria.I18nProvider, {
|
|
12133
|
+
locale: locale,
|
|
12134
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
|
|
12135
|
+
timezone: timezone,
|
|
12136
|
+
formatOptions: formatOptions,
|
|
12137
|
+
children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
|
|
12138
|
+
...props,
|
|
12139
|
+
isOpen: isOpen,
|
|
12140
|
+
readonly: fieldProps.isReadOnly,
|
|
12141
|
+
pickerRef: pickerRef,
|
|
12041
12142
|
ref: ref,
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
readonly: isReadOnly,
|
|
12050
|
-
reset: () => _onChange(null),
|
|
12051
|
-
buttonProps: buttonProps,
|
|
12052
|
-
valueString: pickerState.formatValue(locale, {
|
|
12053
|
-
year: 'numeric',
|
|
12054
|
-
month: 'short',
|
|
12055
|
-
day: '2-digit'
|
|
12056
|
-
})
|
|
12143
|
+
setIsOpen: setIsOpen,
|
|
12144
|
+
label: label,
|
|
12145
|
+
calendar: /*#__PURE__*/jsxRuntime.jsx(Calendar, {
|
|
12146
|
+
ref: pickerRef,
|
|
12147
|
+
Footer: Footer,
|
|
12148
|
+
Header: Header,
|
|
12149
|
+
...calendarProps
|
|
12057
12150
|
}),
|
|
12058
|
-
|
|
12151
|
+
disabled: isDisabled,
|
|
12152
|
+
readOnly: isReadOnly,
|
|
12153
|
+
color: pickerState.isInvalid ? 'warning' : variant,
|
|
12154
|
+
helperProps: helperPropsInvalid ?? helperProps,
|
|
12155
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DateField, {
|
|
12156
|
+
fieldProps: fieldProps,
|
|
12157
|
+
groupProps: groupProps,
|
|
12158
|
+
dateCreateProps: dateCreateProps,
|
|
12159
|
+
ref: ref,
|
|
12160
|
+
onChange: _onChange,
|
|
12161
|
+
rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
|
|
12162
|
+
showClearButton: showClearButton,
|
|
12163
|
+
setOpen: setIsOpen,
|
|
12164
|
+
open: isOpen,
|
|
12165
|
+
icon: edsIcons.calendar,
|
|
12166
|
+
disabled: isDisabled,
|
|
12167
|
+
readonly: isReadOnly,
|
|
12168
|
+
reset: () => _onChange(null),
|
|
12169
|
+
buttonProps: buttonProps,
|
|
12170
|
+
valueString: pickerState.formatValue(locale, {
|
|
12171
|
+
year: 'numeric',
|
|
12172
|
+
month: 'short',
|
|
12173
|
+
day: '2-digit'
|
|
12174
|
+
})
|
|
12175
|
+
}),
|
|
12176
|
+
variant: variant
|
|
12177
|
+
})
|
|
12059
12178
|
})
|
|
12060
12179
|
})
|
|
12061
12180
|
});
|
|
@@ -12174,6 +12293,7 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
12174
12293
|
Header,
|
|
12175
12294
|
timezone,
|
|
12176
12295
|
defaultValue,
|
|
12296
|
+
locale: propLocale,
|
|
12177
12297
|
formatOptions,
|
|
12178
12298
|
hideClearButton,
|
|
12179
12299
|
disabled: isDisabled,
|
|
@@ -12199,9 +12319,7 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
12199
12319
|
const inputRef = react.useRef(null);
|
|
12200
12320
|
const pickerRef = react.useRef(null);
|
|
12201
12321
|
const ref = forwardedRef || inputRef;
|
|
12202
|
-
const
|
|
12203
|
-
locale
|
|
12204
|
-
} = reactAria.useLocale();
|
|
12322
|
+
const locale = useGetLocale(propLocale);
|
|
12205
12323
|
const {
|
|
12206
12324
|
_minValue,
|
|
12207
12325
|
_maxValue,
|
|
@@ -12267,47 +12385,50 @@ const DateRangePicker = /*#__PURE__*/react.forwardRef(({
|
|
|
12267
12385
|
if (!defaultValue && !value) setInnerValue(null);
|
|
12268
12386
|
if (!val?.from && !val?.to) setInnerValue(null);
|
|
12269
12387
|
}, [defaultValue, value]);
|
|
12270
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
setIsOpen: setIsOpen,
|
|
12282
|
-
label: label,
|
|
12283
|
-
calendar: /*#__PURE__*/jsxRuntime.jsx(RangeCalendar, {
|
|
12284
|
-
ref: pickerRef,
|
|
12285
|
-
maxValue: _maxValue,
|
|
12286
|
-
minValue: _minValue,
|
|
12287
|
-
isDateUnavailable: _isDateUnavailable,
|
|
12288
|
-
Footer: Footer,
|
|
12289
|
-
Header: Header,
|
|
12290
|
-
...calendarProps
|
|
12291
|
-
}),
|
|
12292
|
-
children: /*#__PURE__*/jsxRuntime.jsx(DateRangeField, {
|
|
12293
|
-
startFieldProps: startFieldProps,
|
|
12294
|
-
endFieldProps: endFieldProps,
|
|
12295
|
-
groupProps: groupProps,
|
|
12388
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactAria.I18nProvider, {
|
|
12389
|
+
locale: locale,
|
|
12390
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
|
|
12391
|
+
timezone: timezone,
|
|
12392
|
+
formatOptions: formatOptions,
|
|
12393
|
+
children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
|
|
12394
|
+
...props,
|
|
12395
|
+
isOpen: isOpen,
|
|
12396
|
+
color: state.isInvalid ? 'warning' : props.variant,
|
|
12397
|
+
helperProps: helperProps ?? props.helperProps,
|
|
12398
|
+
readonly: startFieldProps.isReadOnly,
|
|
12296
12399
|
ref: ref,
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
|
|
12400
|
+
pickerRef: pickerRef,
|
|
12401
|
+
setIsOpen: setIsOpen,
|
|
12402
|
+
label: label,
|
|
12403
|
+
calendar: /*#__PURE__*/jsxRuntime.jsx(RangeCalendar, {
|
|
12404
|
+
ref: pickerRef,
|
|
12405
|
+
maxValue: _maxValue,
|
|
12406
|
+
minValue: _minValue,
|
|
12407
|
+
isDateUnavailable: _isDateUnavailable,
|
|
12408
|
+
Footer: Footer,
|
|
12409
|
+
Header: Header,
|
|
12410
|
+
...calendarProps
|
|
12411
|
+
}),
|
|
12412
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DateRangeField, {
|
|
12413
|
+
startFieldProps: startFieldProps,
|
|
12414
|
+
endFieldProps: endFieldProps,
|
|
12415
|
+
groupProps: groupProps,
|
|
12416
|
+
ref: ref,
|
|
12417
|
+
variant: props.variant,
|
|
12302
12418
|
disabled: isDisabled,
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12419
|
+
rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
|
|
12420
|
+
showClearButton: showClearButton,
|
|
12421
|
+
buttonProps: buttonProps,
|
|
12422
|
+
disabled: isDisabled,
|
|
12423
|
+
readonly: isReadOnly,
|
|
12424
|
+
reset: () => {
|
|
12425
|
+
_onChange(null);
|
|
12426
|
+
},
|
|
12427
|
+
setOpen: setIsOpen,
|
|
12428
|
+
open: isOpen,
|
|
12429
|
+
icon: edsIcons.calendar_date_range,
|
|
12430
|
+
valueString: valueString
|
|
12431
|
+
})
|
|
12311
12432
|
})
|
|
12312
12433
|
})
|
|
12313
12434
|
})
|
|
@@ -6,12 +6,13 @@ import { useConvertedValidationFunctions } from './utils/useConvertedValidationF
|
|
|
6
6
|
import { FieldWrapper } from './fields/FieldWrapper.js';
|
|
7
7
|
import { Toggle } from './fields/Toggle.js';
|
|
8
8
|
import { toCalendarDateTime, fromDate, toCalendarDate, createCalendar } from '@internationalized/date';
|
|
9
|
-
import {
|
|
9
|
+
import { useDatePicker, I18nProvider } from 'react-aria';
|
|
10
10
|
import { useDatePickerState } from '@react-stately/datepicker';
|
|
11
11
|
import { DatePickerProvider, defaultTimezone } from './utils/context.js';
|
|
12
12
|
import { tokens } from '@equinor/eds-tokens';
|
|
13
13
|
import { Icon } from '../Icon/index.js';
|
|
14
14
|
import { getCalendarDate } from './utils/get-calendar-date.js';
|
|
15
|
+
import { useGetLocale } from './utils/useGetLocale.js';
|
|
15
16
|
import { jsx } from 'react/jsx-runtime';
|
|
16
17
|
|
|
17
18
|
const DatePicker = /*#__PURE__*/forwardRef(({
|
|
@@ -24,6 +25,7 @@ const DatePicker = /*#__PURE__*/forwardRef(({
|
|
|
24
25
|
Footer,
|
|
25
26
|
Header,
|
|
26
27
|
timezone,
|
|
28
|
+
locale: propLocale,
|
|
27
29
|
defaultValue,
|
|
28
30
|
showTimeInput,
|
|
29
31
|
granularity,
|
|
@@ -83,16 +85,14 @@ const DatePicker = /*#__PURE__*/forwardRef(({
|
|
|
83
85
|
}
|
|
84
86
|
}, [onChange, isOpen, showTimeInput, timezone]);
|
|
85
87
|
const _value = getCalendarDate(value, timezone, showTimeInput) ?? innerValue;
|
|
86
|
-
const
|
|
87
|
-
locale
|
|
88
|
-
} = useLocale();
|
|
88
|
+
const locale = useGetLocale(propLocale);
|
|
89
89
|
const dateCreateProps = {
|
|
90
90
|
helperProps,
|
|
91
91
|
variant,
|
|
92
92
|
isDisabled,
|
|
93
93
|
value: _value,
|
|
94
94
|
hideTimeZone: true,
|
|
95
|
-
locale,
|
|
95
|
+
locale: locale,
|
|
96
96
|
createCalendar,
|
|
97
97
|
onChange: _onChange,
|
|
98
98
|
minValue: _minValue,
|
|
@@ -123,49 +123,52 @@ const DatePicker = /*#__PURE__*/forwardRef(({
|
|
|
123
123
|
useEffect(() => {
|
|
124
124
|
if (!defaultValue && !value) setInnerValue(null);
|
|
125
125
|
}, [defaultValue, value]);
|
|
126
|
-
return /*#__PURE__*/jsx(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
label: label,
|
|
137
|
-
calendar: /*#__PURE__*/jsx(Calendar, {
|
|
138
|
-
ref: pickerRef,
|
|
139
|
-
Footer: Footer,
|
|
140
|
-
Header: Header,
|
|
141
|
-
...calendarProps
|
|
142
|
-
}),
|
|
143
|
-
disabled: isDisabled,
|
|
144
|
-
readOnly: isReadOnly,
|
|
145
|
-
color: pickerState.isInvalid ? 'warning' : variant,
|
|
146
|
-
helperProps: helperPropsInvalid ?? helperProps,
|
|
147
|
-
children: /*#__PURE__*/jsx(DateField, {
|
|
148
|
-
fieldProps: fieldProps,
|
|
149
|
-
groupProps: groupProps,
|
|
150
|
-
dateCreateProps: dateCreateProps,
|
|
126
|
+
return /*#__PURE__*/jsx(I18nProvider, {
|
|
127
|
+
locale: locale,
|
|
128
|
+
children: /*#__PURE__*/jsx(DatePickerProvider, {
|
|
129
|
+
timezone: timezone,
|
|
130
|
+
formatOptions: formatOptions,
|
|
131
|
+
children: /*#__PURE__*/jsx(FieldWrapper, {
|
|
132
|
+
...props,
|
|
133
|
+
isOpen: isOpen,
|
|
134
|
+
readonly: fieldProps.isReadOnly,
|
|
135
|
+
pickerRef: pickerRef,
|
|
151
136
|
ref: ref,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
readonly: isReadOnly,
|
|
160
|
-
reset: () => _onChange(null),
|
|
161
|
-
buttonProps: buttonProps,
|
|
162
|
-
valueString: pickerState.formatValue(locale, {
|
|
163
|
-
year: 'numeric',
|
|
164
|
-
month: 'short',
|
|
165
|
-
day: '2-digit'
|
|
166
|
-
})
|
|
137
|
+
setIsOpen: setIsOpen,
|
|
138
|
+
label: label,
|
|
139
|
+
calendar: /*#__PURE__*/jsx(Calendar, {
|
|
140
|
+
ref: pickerRef,
|
|
141
|
+
Footer: Footer,
|
|
142
|
+
Header: Header,
|
|
143
|
+
...calendarProps
|
|
167
144
|
}),
|
|
168
|
-
|
|
145
|
+
disabled: isDisabled,
|
|
146
|
+
readOnly: isReadOnly,
|
|
147
|
+
color: pickerState.isInvalid ? 'warning' : variant,
|
|
148
|
+
helperProps: helperPropsInvalid ?? helperProps,
|
|
149
|
+
children: /*#__PURE__*/jsx(DateField, {
|
|
150
|
+
fieldProps: fieldProps,
|
|
151
|
+
groupProps: groupProps,
|
|
152
|
+
dateCreateProps: dateCreateProps,
|
|
153
|
+
ref: ref,
|
|
154
|
+
onChange: _onChange,
|
|
155
|
+
rightAdornments: /*#__PURE__*/jsx(Toggle, {
|
|
156
|
+
showClearButton: showClearButton,
|
|
157
|
+
setOpen: setIsOpen,
|
|
158
|
+
open: isOpen,
|
|
159
|
+
icon: calendar,
|
|
160
|
+
disabled: isDisabled,
|
|
161
|
+
readonly: isReadOnly,
|
|
162
|
+
reset: () => _onChange(null),
|
|
163
|
+
buttonProps: buttonProps,
|
|
164
|
+
valueString: pickerState.formatValue(locale, {
|
|
165
|
+
year: 'numeric',
|
|
166
|
+
month: 'short',
|
|
167
|
+
day: '2-digit'
|
|
168
|
+
})
|
|
169
|
+
}),
|
|
170
|
+
variant: variant
|
|
171
|
+
})
|
|
169
172
|
})
|
|
170
173
|
})
|
|
171
174
|
});
|
|
@@ -4,7 +4,7 @@ import { warning_outlined, calendar_date_range } from '@equinor/eds-icons';
|
|
|
4
4
|
import { useConvertedValidationFunctions } from './utils/useConvertedValidationFunctions.js';
|
|
5
5
|
import { FieldWrapper } from './fields/FieldWrapper.js';
|
|
6
6
|
import { Toggle } from './fields/Toggle.js';
|
|
7
|
-
import {
|
|
7
|
+
import { useDateRangePicker, I18nProvider } from 'react-aria';
|
|
8
8
|
import { useDateRangePickerState } from '@react-stately/datepicker';
|
|
9
9
|
import { DateRangeField } from './fields/DateRangeField.js';
|
|
10
10
|
import { toCalendarDate, fromDate } from '@internationalized/date';
|
|
@@ -12,6 +12,7 @@ import { DatePickerProvider, defaultTimezone } from './utils/context.js';
|
|
|
12
12
|
import { tokens } from '@equinor/eds-tokens';
|
|
13
13
|
import { Icon } from '../Icon/index.js';
|
|
14
14
|
import { getCalendarDate } from './utils/get-calendar-date.js';
|
|
15
|
+
import { useGetLocale } from './utils/useGetLocale.js';
|
|
15
16
|
import { jsx } from 'react/jsx-runtime';
|
|
16
17
|
|
|
17
18
|
const DateRangePicker = /*#__PURE__*/forwardRef(({
|
|
@@ -25,6 +26,7 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
|
|
|
25
26
|
Header,
|
|
26
27
|
timezone,
|
|
27
28
|
defaultValue,
|
|
29
|
+
locale: propLocale,
|
|
28
30
|
formatOptions,
|
|
29
31
|
hideClearButton,
|
|
30
32
|
disabled: isDisabled,
|
|
@@ -50,9 +52,7 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
|
|
|
50
52
|
const inputRef = useRef(null);
|
|
51
53
|
const pickerRef = useRef(null);
|
|
52
54
|
const ref = forwardedRef || inputRef;
|
|
53
|
-
const
|
|
54
|
-
locale
|
|
55
|
-
} = useLocale();
|
|
55
|
+
const locale = useGetLocale(propLocale);
|
|
56
56
|
const {
|
|
57
57
|
_minValue,
|
|
58
58
|
_maxValue,
|
|
@@ -118,47 +118,50 @@ const DateRangePicker = /*#__PURE__*/forwardRef(({
|
|
|
118
118
|
if (!defaultValue && !value) setInnerValue(null);
|
|
119
119
|
if (!val?.from && !val?.to) setInnerValue(null);
|
|
120
120
|
}, [defaultValue, value]);
|
|
121
|
-
return /*#__PURE__*/jsx(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
setIsOpen: setIsOpen,
|
|
133
|
-
label: label,
|
|
134
|
-
calendar: /*#__PURE__*/jsx(RangeCalendar, {
|
|
135
|
-
ref: pickerRef,
|
|
136
|
-
maxValue: _maxValue,
|
|
137
|
-
minValue: _minValue,
|
|
138
|
-
isDateUnavailable: _isDateUnavailable,
|
|
139
|
-
Footer: Footer,
|
|
140
|
-
Header: Header,
|
|
141
|
-
...calendarProps
|
|
142
|
-
}),
|
|
143
|
-
children: /*#__PURE__*/jsx(DateRangeField, {
|
|
144
|
-
startFieldProps: startFieldProps,
|
|
145
|
-
endFieldProps: endFieldProps,
|
|
146
|
-
groupProps: groupProps,
|
|
121
|
+
return /*#__PURE__*/jsx(I18nProvider, {
|
|
122
|
+
locale: locale,
|
|
123
|
+
children: /*#__PURE__*/jsx(DatePickerProvider, {
|
|
124
|
+
timezone: timezone,
|
|
125
|
+
formatOptions: formatOptions,
|
|
126
|
+
children: /*#__PURE__*/jsx(FieldWrapper, {
|
|
127
|
+
...props,
|
|
128
|
+
isOpen: isOpen,
|
|
129
|
+
color: state.isInvalid ? 'warning' : props.variant,
|
|
130
|
+
helperProps: helperProps ?? props.helperProps,
|
|
131
|
+
readonly: startFieldProps.isReadOnly,
|
|
147
132
|
ref: ref,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
133
|
+
pickerRef: pickerRef,
|
|
134
|
+
setIsOpen: setIsOpen,
|
|
135
|
+
label: label,
|
|
136
|
+
calendar: /*#__PURE__*/jsx(RangeCalendar, {
|
|
137
|
+
ref: pickerRef,
|
|
138
|
+
maxValue: _maxValue,
|
|
139
|
+
minValue: _minValue,
|
|
140
|
+
isDateUnavailable: _isDateUnavailable,
|
|
141
|
+
Footer: Footer,
|
|
142
|
+
Header: Header,
|
|
143
|
+
...calendarProps
|
|
144
|
+
}),
|
|
145
|
+
children: /*#__PURE__*/jsx(DateRangeField, {
|
|
146
|
+
startFieldProps: startFieldProps,
|
|
147
|
+
endFieldProps: endFieldProps,
|
|
148
|
+
groupProps: groupProps,
|
|
149
|
+
ref: ref,
|
|
150
|
+
variant: props.variant,
|
|
153
151
|
disabled: isDisabled,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
152
|
+
rightAdornments: /*#__PURE__*/jsx(Toggle, {
|
|
153
|
+
showClearButton: showClearButton,
|
|
154
|
+
buttonProps: buttonProps,
|
|
155
|
+
disabled: isDisabled,
|
|
156
|
+
readonly: isReadOnly,
|
|
157
|
+
reset: () => {
|
|
158
|
+
_onChange(null);
|
|
159
|
+
},
|
|
160
|
+
setOpen: setIsOpen,
|
|
161
|
+
open: isOpen,
|
|
162
|
+
icon: calendar_date_range,
|
|
163
|
+
valueString: valueString
|
|
164
|
+
})
|
|
162
165
|
})
|
|
163
166
|
})
|
|
164
167
|
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useLocale } from 'react-aria';
|
|
2
|
+
|
|
3
|
+
const useGetLocale = locale => {
|
|
4
|
+
const {
|
|
5
|
+
locale: externalLocale
|
|
6
|
+
} = useLocale();
|
|
7
|
+
// react-aria defaults to navigator.language if no locale is provided. If these are equal, we override by using the system default locale
|
|
8
|
+
const defaultLocale = typeof navigator !== 'undefined' && navigator.language || 'en-US';
|
|
9
|
+
const fallbackLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
10
|
+
return locale ?? (externalLocale === defaultLocale ? undefined : externalLocale) ?? fallbackLocale;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { useGetLocale };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, useRef, useMemo, useEffect } from 'react';
|
|
2
2
|
import styled, { css, ThemeProvider } from 'styled-components';
|
|
3
|
-
import { typographyTemplate, bordersTemplate, outlineTemplate, mergeRefs,
|
|
3
|
+
import { typographyTemplate, bordersTemplate, outlineTemplate, mergeRefs, useToken } from '@equinor/eds-utils';
|
|
4
4
|
import { popover } from './Popover.tokens.js';
|
|
5
5
|
import { useFloating, offset, flip, shift, arrow, autoUpdate, useInteractions, useDismiss, FloatingFocusManager } from '@floating-ui/react';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -96,9 +96,13 @@ const Popover = /*#__PURE__*/forwardRef(function Popover({
|
|
|
96
96
|
const {
|
|
97
97
|
getFloatingProps
|
|
98
98
|
} = useInteractions([useDismiss(context)]);
|
|
99
|
-
|
|
99
|
+
useEffect(() => {
|
|
100
100
|
if (open) {
|
|
101
|
-
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
if (refs.floating.current?.isConnected) {
|
|
103
|
+
refs.floating.current.showPopover();
|
|
104
|
+
}
|
|
105
|
+
}, 1);
|
|
102
106
|
} else {
|
|
103
107
|
refs.floating.current?.hidePopover();
|
|
104
108
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { forwardRef, useRef, useMemo } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { scrim } from './Scrim.tokens.js';
|
|
4
|
-
import { mergeRefs, useGlobalKeyPress } from '@equinor/eds-utils';
|
|
4
|
+
import { useHideBodyScroll, mergeRefs, useGlobalKeyPress } from '@equinor/eds-utils';
|
|
5
5
|
import { FloatingOverlay } from '@floating-ui/react';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -24,6 +24,7 @@ const Scrim = /*#__PURE__*/forwardRef(function Scrim({
|
|
|
24
24
|
...rest
|
|
25
25
|
}, ref) {
|
|
26
26
|
const scrimRef = useRef(null);
|
|
27
|
+
useHideBodyScroll(open);
|
|
27
28
|
const combinedScrimRef = useMemo(() => mergeRefs(scrimRef, ref), [scrimRef, ref]);
|
|
28
29
|
useGlobalKeyPress('Escape', () => {
|
|
29
30
|
if (isDismissable && onClose && open) {
|
|
@@ -41,7 +42,6 @@ const Scrim = /*#__PURE__*/forwardRef(function Scrim({
|
|
|
41
42
|
return null;
|
|
42
43
|
}
|
|
43
44
|
return /*#__PURE__*/jsx(StyledScrim, {
|
|
44
|
-
lockScroll: true,
|
|
45
45
|
onMouseDown: handleMouseClose,
|
|
46
46
|
ref: combinedScrimRef,
|
|
47
47
|
...rest,
|
|
@@ -2,6 +2,7 @@ import { forwardRef } from 'react';
|
|
|
2
2
|
import { InnerContext } from './Inner.context.js';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { TableDataCell } from './DataCell/DataCell.js';
|
|
5
|
+
import { TableFooterCell } from './FooterCell/FooterCell.js';
|
|
5
6
|
import { TableHeaderCell } from './HeaderCell/HeaderCell.js';
|
|
6
7
|
|
|
7
8
|
const Cell = /*#__PURE__*/forwardRef(function Cell({
|
|
@@ -19,6 +20,12 @@ const Cell = /*#__PURE__*/forwardRef(function Cell({
|
|
|
19
20
|
sticky: sticky,
|
|
20
21
|
...rest
|
|
21
22
|
});
|
|
23
|
+
case 'foot':
|
|
24
|
+
return /*#__PURE__*/jsx(TableFooterCell, {
|
|
25
|
+
ref: ref,
|
|
26
|
+
sticky: sticky,
|
|
27
|
+
...rest
|
|
28
|
+
});
|
|
22
29
|
default:
|
|
23
30
|
case 'body':
|
|
24
31
|
return /*#__PURE__*/jsx(TableDataCell, {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { token } from './Foot.tokens.js';
|
|
4
|
+
import { bordersTemplate } from '@equinor/eds-utils';
|
|
5
|
+
import { InnerContext } from '../Inner.context.js';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
const StyledTableFoot = styled.tfoot.withConfig({
|
|
9
|
+
displayName: "Foot__StyledTableFoot",
|
|
10
|
+
componentId: "sc-3w9vih-0"
|
|
11
|
+
})(["", " background:", ";"], bordersTemplate(token.border), token.background);
|
|
12
|
+
const Foot = /*#__PURE__*/forwardRef(function Foot({
|
|
13
|
+
children,
|
|
14
|
+
sticky,
|
|
15
|
+
...props
|
|
16
|
+
}, ref) {
|
|
17
|
+
return /*#__PURE__*/jsx(InnerContext.Provider, {
|
|
18
|
+
value: {
|
|
19
|
+
variant: 'foot',
|
|
20
|
+
sticky
|
|
21
|
+
},
|
|
22
|
+
children: /*#__PURE__*/jsx(StyledTableFoot, {
|
|
23
|
+
...props,
|
|
24
|
+
ref: ref,
|
|
25
|
+
children: children
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export { Foot };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { tokens } from '@equinor/eds-tokens';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
colors: {
|
|
5
|
+
ui: {
|
|
6
|
+
background__medium: {
|
|
7
|
+
rgba: borderColor
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
interactive: {
|
|
11
|
+
table__header__fill_resting: {
|
|
12
|
+
rgba: backgroundColor
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
} = tokens;
|
|
17
|
+
const token = {
|
|
18
|
+
background: backgroundColor,
|
|
19
|
+
border: {
|
|
20
|
+
type: 'bordergroup',
|
|
21
|
+
bottom: {
|
|
22
|
+
type: 'border',
|
|
23
|
+
width: '2px',
|
|
24
|
+
color: borderColor,
|
|
25
|
+
style: 'solid'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { token };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import styled, { css, ThemeProvider } from 'styled-components';
|
|
3
|
+
import { spacingsTemplate, typographyTemplate, bordersTemplate, useToken } from '@equinor/eds-utils';
|
|
4
|
+
import { token } from '../HeaderCell/HeaderCell.tokens.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
import { useEds } from '../../EdsProvider/eds.context.js';
|
|
7
|
+
|
|
8
|
+
const StyledTableCell = styled.th.withConfig({
|
|
9
|
+
displayName: "FooterCell__StyledTableCell",
|
|
10
|
+
componentId: "sc-1xq9z77-0"
|
|
11
|
+
})(props => {
|
|
12
|
+
const {
|
|
13
|
+
theme,
|
|
14
|
+
$sticky
|
|
15
|
+
} = props;
|
|
16
|
+
const {
|
|
17
|
+
background,
|
|
18
|
+
height,
|
|
19
|
+
typography,
|
|
20
|
+
spacings
|
|
21
|
+
} = theme;
|
|
22
|
+
return css(["min-height:", ";height:", ";background:", ";box-sizing:border-box;", " ", " ", " ", ""], height, height, background, spacingsTemplate(spacings), typographyTemplate(typography), bordersTemplate(theme.border), $sticky ? css(["position:sticky;bottom:0;z-index:2;"]) : '');
|
|
23
|
+
});
|
|
24
|
+
const CellInner = styled.div.withConfig({
|
|
25
|
+
displayName: "FooterCell__CellInner",
|
|
26
|
+
componentId: "sc-1xq9z77-1"
|
|
27
|
+
})(["display:flex;align-items:center;"]);
|
|
28
|
+
const TableFooterCell = /*#__PURE__*/forwardRef(function TableFooterCell({
|
|
29
|
+
children,
|
|
30
|
+
sticky,
|
|
31
|
+
...rest
|
|
32
|
+
}, ref) {
|
|
33
|
+
const {
|
|
34
|
+
density
|
|
35
|
+
} = useEds();
|
|
36
|
+
const token$1 = useToken({
|
|
37
|
+
density
|
|
38
|
+
}, token);
|
|
39
|
+
const props = {
|
|
40
|
+
ref,
|
|
41
|
+
$sticky: sticky,
|
|
42
|
+
...rest
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/jsx(ThemeProvider, {
|
|
45
|
+
theme: token$1,
|
|
46
|
+
children: /*#__PURE__*/jsx(StyledTableCell, {
|
|
47
|
+
...props,
|
|
48
|
+
children: /*#__PURE__*/jsx(CellInner, {
|
|
49
|
+
children: children
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export { TableFooterCell };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const initialState = {
|
|
4
4
|
variant: 'body'
|
|
5
5
|
};
|
|
6
|
-
const InnerContext = /*#__PURE__*/createContext(
|
|
6
|
+
const InnerContext = /*#__PURE__*/createContext(initialState);
|
|
7
7
|
|
|
8
8
|
export { InnerContext };
|
|
@@ -3,17 +3,20 @@ import { Body } from './Body.js';
|
|
|
3
3
|
import { Cell } from './Cell.js';
|
|
4
4
|
import { Caption } from './Caption.js';
|
|
5
5
|
import { Head } from './Head/Head.js';
|
|
6
|
+
import { Foot } from './Foot/Foot.js';
|
|
6
7
|
import { Row } from './Row/Row.js';
|
|
7
8
|
|
|
8
9
|
const Table = Table$1;
|
|
9
10
|
Table.Body = Body;
|
|
10
11
|
Table.Cell = Cell;
|
|
11
12
|
Table.Head = Head;
|
|
13
|
+
Table.Foot = Foot;
|
|
12
14
|
Table.Row = Row;
|
|
13
15
|
Table.Caption = Caption;
|
|
14
16
|
Table.Body.displayName = 'Table.Body';
|
|
15
17
|
Table.Cell.displayName = 'Table.Cell';
|
|
16
18
|
Table.Head.displayName = 'Table.Head';
|
|
19
|
+
Table.Foot.displayName = 'Table.Foot';
|
|
17
20
|
Table.Row.displayName = 'Table.Row';
|
|
18
21
|
Table.Caption.displayName = 'Table.Caption';
|
|
19
22
|
|
|
@@ -21,4 +21,5 @@ export declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<
|
|
|
21
21
|
timezone: string;
|
|
22
22
|
granularity?: "hour" | "minute" | "second";
|
|
23
23
|
formatOptions?: import("react-aria").DateFormatterOptions;
|
|
24
|
+
locale?: string;
|
|
24
25
|
}> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -93,6 +93,11 @@ export type DatePickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> &
|
|
|
93
93
|
* Only applies when input is blurred
|
|
94
94
|
*/
|
|
95
95
|
formatOptions?: DateFormatterOptions;
|
|
96
|
+
/**
|
|
97
|
+
* The locale to use for formatting the date.
|
|
98
|
+
* Defaults to browser's language setting
|
|
99
|
+
*/
|
|
100
|
+
locale?: string;
|
|
96
101
|
}>;
|
|
97
102
|
export type DateTimePickerProps = Omit<DatePickerProps, 'onChange' | 'value' | 'multiple'> & {
|
|
98
103
|
onChange: (date: Date | null) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useGetLocale: (locale?: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type FootProps = {
|
|
3
|
+
/** Footer will stick to bottom when scrolling */
|
|
4
|
+
sticky?: boolean;
|
|
5
|
+
} & HTMLAttributes<HTMLTableSectionElement>;
|
|
6
|
+
export declare const Foot: import("react").ForwardRefExoticComponent<{
|
|
7
|
+
/** Footer will stick to bottom when scrolling */
|
|
8
|
+
sticky?: boolean;
|
|
9
|
+
} & HTMLAttributes<HTMLTableSectionElement> & import("react").RefAttributes<HTMLTableSectionElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Foot';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FooterCell';
|
|
@@ -2,15 +2,17 @@ import { Table as BaseTable, TableProps } from './Table';
|
|
|
2
2
|
import { Body, BodyProps } from './Body';
|
|
3
3
|
import { Cell, CellProps } from './Cell';
|
|
4
4
|
import { Head, HeadProps } from './Head';
|
|
5
|
+
import { Foot, FootProps } from './Foot';
|
|
5
6
|
import { Row, RowProps } from './Row';
|
|
6
7
|
import { Caption, CaptionProps } from './Caption';
|
|
7
8
|
type TableCompoundProps = typeof BaseTable & {
|
|
8
9
|
Body: typeof Body;
|
|
9
10
|
Cell: typeof Cell;
|
|
10
11
|
Head: typeof Head;
|
|
12
|
+
Foot: typeof Foot;
|
|
11
13
|
Row: typeof Row;
|
|
12
14
|
Caption: typeof Caption;
|
|
13
15
|
};
|
|
14
16
|
declare const Table: TableCompoundProps;
|
|
15
17
|
export { Table };
|
|
16
|
-
export type { TableProps, CellProps, BodyProps, RowProps, CaptionProps, HeadProps, };
|
|
18
|
+
export type { TableProps, CellProps, BodyProps, RowProps, CaptionProps, HeadProps, FootProps, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-core-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "The React implementation of the Equinor Design System",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
"downshift": "9.0.8",
|
|
90
90
|
"react-aria": "^3.34.1",
|
|
91
91
|
"@equinor/eds-icons": "^0.21.0",
|
|
92
|
-
"@equinor/eds-
|
|
93
|
-
"@equinor/eds-
|
|
92
|
+
"@equinor/eds-tokens": "0.9.2",
|
|
93
|
+
"@equinor/eds-utils": "0.8.5"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build": "rollup -c --bundleConfigAsCjs && tsc -p tsconfig.build.json",
|