@dmsi/wedgekit-react 0.0.28 → 0.0.30

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 (43) hide show
  1. package/dist/{chunk-57WRM337.js → chunk-5POWRPIO.js} +3 -2
  2. package/dist/{chunk-S5KPS4IQ.js → chunk-HXEPUO5W.js} +189 -95
  3. package/dist/chunk-KHQX42T7.js +127 -0
  4. package/dist/{chunk-OUSNH76S.js → chunk-PCCJ7L3N.js} +29 -6
  5. package/dist/{chunk-PDDZ5PMY.js → chunk-S46RZBT4.js} +3 -2
  6. package/dist/components/CalendarRange.cjs +28 -5
  7. package/dist/components/CalendarRange.js +1 -1
  8. package/dist/components/DataGrid.cjs +490 -217
  9. package/dist/components/DataGrid.js +303 -122
  10. package/dist/components/DataGridCell.cjs +192 -96
  11. package/dist/components/DataGridCell.js +4 -2
  12. package/dist/components/DateInput.cjs +231 -30
  13. package/dist/components/DateInput.js +101 -27
  14. package/dist/components/DateRangeInput.cjs +550 -37
  15. package/dist/components/DateRangeInput.js +413 -34
  16. package/dist/components/MenuOption.cjs +3 -2
  17. package/dist/components/MenuOption.js +1 -1
  18. package/dist/components/MobileDataGrid.cjs +3 -2
  19. package/dist/components/MobileDataGrid.js +1 -1
  20. package/dist/components/NestedMenu.cjs +3 -2
  21. package/dist/components/NestedMenu.js +1 -1
  22. package/dist/components/Notification.cjs +3 -2
  23. package/dist/components/Notification.js +1 -1
  24. package/dist/components/SideMenuGroup.cjs +3 -2
  25. package/dist/components/SideMenuGroup.js +1 -1
  26. package/dist/components/SideMenuItem.cjs +3 -2
  27. package/dist/components/SideMenuItem.js +1 -1
  28. package/dist/components/Stack.cjs +3 -2
  29. package/dist/components/Stack.js +1 -1
  30. package/dist/components/Swatch.cjs +3 -2
  31. package/dist/components/Swatch.js +1 -1
  32. package/dist/components/Time.cjs +3 -2
  33. package/dist/components/Time.js +1 -1
  34. package/dist/index.css +9 -0
  35. package/package.json +1 -1
  36. package/src/components/CalendarRange.tsx +37 -6
  37. package/src/components/DataGrid.tsx +284 -48
  38. package/src/components/DataGridCell.tsx +122 -35
  39. package/src/components/DateInput.tsx +118 -25
  40. package/src/components/DateRangeInput.tsx +544 -30
  41. package/src/components/MenuOption.tsx +18 -14
  42. package/src/components/Stack.tsx +4 -2
  43. package/src/utils/date.ts +206 -0
@@ -60,6 +60,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
60
60
  // src/components/DataGridCell.tsx
61
61
  var DataGridCell_exports = {};
62
62
  __export(DataGridCell_exports, {
63
+ DataCellHeader: () => DataCellHeader,
63
64
  DataGridCell: () => DataGridCell,
64
65
  DragAlongCell: () => DragAlongCell,
65
66
  DraggableCellHeader: () => DraggableCellHeader
@@ -1547,7 +1548,8 @@ var MenuOption = ({
1547
1548
  );
1548
1549
  const actionDisabledStyles = variant === "action" && disabled && (0, import_clsx7.default)("text-text-action-disabled");
1549
1550
  const disabledStyles = disabled && (0, import_clsx7.default)("bg-transparent cursor-default pointer-events-none");
1550
- const renderChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
1551
+ const processChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
1552
+ const renderChildren = typeof children === "object" ? children : variant === "action" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { padded: true, className: textLabelStyles, children: processChildren }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Paragraph, { padded: true, className: textLabelStyles, children: processChildren });
1551
1553
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1552
1554
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1553
1555
  "div",
@@ -1581,7 +1583,7 @@ var MenuOption = ({
1581
1583
  "aria-haspopup": subMenu ? "menu" : void 0,
1582
1584
  children: [
1583
1585
  before && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
1584
- variant === "action" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { padded: true, className: textLabelStyles, children: renderChildren }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Paragraph, { padded: true, className: textLabelStyles, children: renderChildren }),
1586
+ renderChildren,
1585
1587
  renderAfterProp()
1586
1588
  ]
1587
1589
  })
@@ -1734,7 +1736,7 @@ var DataGridCell = (0, import_react8.memo)(
1734
1736
  lockedHeaderBgStyles,
1735
1737
  iconComponentStyles,
1736
1738
  className,
1737
- "flex flex-1 items-center gap-1 whitespace-nowrap min-w-full max-h-10 relative text-text-primary-normal",
1739
+ "flex flex-1 items-center gap-1 whitespace-nowrap h-10 relative text-text-primary-normal",
1738
1740
  "focus-within:!z-10",
1739
1741
  component === "input" && "border",
1740
1742
  component === "input" && !error && !warning && "border-border-primary-normal",
@@ -1750,7 +1752,7 @@ var DataGridCell = (0, import_react8.memo)(
1750
1752
  Element,
1751
1753
  __spreadProps(__spreadValues({
1752
1754
  id,
1753
- className: (0, import_clsx8.default)("flex", !width && "flex-1"),
1755
+ className: (0, import_clsx8.default)("flex h-10", !width && "flex-1"),
1754
1756
  style: { width }
1755
1757
  }, props), {
1756
1758
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1773,33 +1775,41 @@ var DataGridCell = (0, import_react8.memo)(
1773
1775
  }
1774
1776
  );
1775
1777
  DataGridCell.displayName = "DataGridCell";
1776
- function DraggableCellHeader(_a) {
1778
+ function DataCellHeader(_a) {
1777
1779
  var _b = _a, {
1778
1780
  header,
1779
1781
  children,
1780
- locked = false,
1782
+ setNodeRef,
1783
+ node,
1781
1784
  id
1782
1785
  } = _b, props = __objRest(_b, [
1783
1786
  "header",
1784
1787
  "children",
1785
- "locked",
1788
+ "setNodeRef",
1789
+ "node",
1786
1790
  "id"
1787
1791
  ]);
1788
1792
  var _a2;
1789
- const { attributes, isDragging, listeners, setNodeRef, transform, node } = (0, import_sortable.useSortable)({
1790
- id: header.column.id
1791
- });
1792
1793
  const [showMenu, setShowMenu] = (0, import_react8.useState)(false);
1793
1794
  const [filter, setFilter] = (0, import_react8.useState)(
1794
1795
  (_a2 = header.column.getFilterValue()) != null ? _a2 : ""
1795
1796
  );
1797
+ const ref = (0, import_react8.useRef)(null);
1798
+ const predeterminedPinned = (0, import_react8.useRef)(false);
1796
1799
  const {
1797
1800
  menuRootRef,
1798
1801
  isMenuActive,
1799
1802
  registerSubMenu,
1800
1803
  listeners: subMenuListeners,
1801
1804
  mobileHide
1802
- } = useSubMenuSystem(node);
1805
+ } = useSubMenuSystem(node ? node : ref);
1806
+ (0, import_react8.useEffect)(() => {
1807
+ var _a3;
1808
+ const columnPinning = (_a3 = header.getContext().table.options.initialState) == null ? void 0 : _a3.columnPinning;
1809
+ const left = (columnPinning == null ? void 0 : columnPinning.left) ? columnPinning.left : [];
1810
+ const right = (columnPinning == null ? void 0 : columnPinning.right) ? columnPinning.right : [];
1811
+ predeterminedPinned.current = [...left, ...right].includes(header.column.id);
1812
+ }, []);
1803
1813
  (0, import_react8.useEffect)(() => {
1804
1814
  const handler = setTimeout(() => {
1805
1815
  header.column.setFilterValue(filter);
@@ -1808,107 +1818,160 @@ function DraggableCellHeader(_a) {
1808
1818
  clearTimeout(handler);
1809
1819
  };
1810
1820
  }, [filter]);
1811
- const style = {
1812
- opacity: isDragging ? 0.8 : 1,
1821
+ const style = __spreadValues({
1813
1822
  position: "relative",
1814
- transform: CSS.Translate.toString(transform),
1815
- transition: "width transform 0.2s ease-in-out",
1816
1823
  whiteSpace: "nowrap",
1817
1824
  width: header.column.getSize(),
1818
- zIndex: isDragging ? 1 : 0,
1819
1825
  "--color-text-primary-normal": "var(--color-neutral-000)"
1820
- };
1826
+ }, props.style);
1821
1827
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1822
1828
  DataGridCell,
1823
- __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
1829
+ __spreadProps(__spreadValues({
1824
1830
  id,
1825
- locked,
1831
+ ref: setNodeRef ? setNodeRef : ref,
1826
1832
  type: "header",
1827
1833
  component: "header",
1828
- ref: setNodeRef,
1829
- colSpan: header.colSpan,
1830
- style
1831
- }, props), {
1834
+ style,
1832
1835
  onClick: header.column.getToggleSortingHandler(),
1833
1836
  onRightClick: () => setShowMenu(!showMenu)
1834
- }), locked ? {} : attributes), locked ? {} : listeners), {
1837
+ }, props), {
1835
1838
  children: [
1836
1839
  children,
1837
- header.column.getCanFilter() && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1840
+ header.column.getCanFilter() && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1838
1841
  Menu,
1839
1842
  {
1840
1843
  id: id ? `${id}-menu` : void 0,
1841
1844
  ref: menuRootRef,
1842
- positionTo: node,
1845
+ positionTo: node ? node : ref,
1843
1846
  show: showMenu,
1844
1847
  setShow: setShowMenu,
1845
1848
  mobileHide,
1846
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1847
- MenuOption,
1848
- __spreadProps(__spreadValues({
1849
- id: id ? `${id}-filter-option` : void 0
1850
- }, subMenuListeners), {
1851
- subMenu: (_b2) => {
1852
- var _c = _b2, { menuId, subMenuLevel } = _c, props2 = __objRest(_c, ["menuId", "subMenuLevel"]);
1853
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1854
- Menu,
1855
- __spreadProps(__spreadValues({
1856
- id: id ? `${id}-filter-submenu` : void 0
1857
- }, props2), {
1858
- show: isMenuActive(menuId, subMenuLevel),
1859
- ref: (el) => {
1860
- registerSubMenu(menuId, el);
1861
- },
1862
- children: [
1863
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: (0, import_clsx8.default)(paddingUsingComponentGap), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1864
- Search,
1865
- {
1866
- id: id ? `${id}-filter-search` : void 0,
1867
- onChange: (event) => {
1868
- setFilter(event.target.value);
1869
- },
1870
- onKeyDown: (event) => {
1871
- if ([" ", "Space"].includes(event.key)) {
1872
- event.stopPropagation();
1873
- }
1874
- },
1875
- value: filter != null ? filter : ""
1876
- }
1877
- ) }),
1878
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1879
- MenuOption,
1880
- {
1881
- id: id ? `${id}-filter-contains` : void 0,
1882
- onClick: handleFilterFnChange,
1883
- before: menuOptionIcon("includesString"),
1884
- children: "Contains"
1885
- }
1886
- ),
1887
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1888
- MenuOption,
1889
- {
1890
- id: id ? `${id}-filter-startswith` : void 0,
1891
- onClick: handleFilterFnChange,
1892
- before: menuOptionIcon("startsWith"),
1893
- children: "Starts with"
1894
- }
1895
- ),
1896
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1897
- MenuOption,
1898
- {
1899
- id: id ? `${id}-filter-endswith` : void 0,
1900
- onClick: handleFilterFnChange,
1901
- before: menuOptionIcon("endsWith"),
1902
- children: "Ends with"
1903
- }
1904
- )
1905
- ]
1906
- })
1907
- );
1908
- },
1909
- children: "Filter"
1910
- })
1911
- )
1849
+ children: [
1850
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1851
+ MenuOption,
1852
+ __spreadProps(__spreadValues({
1853
+ id: id ? `${id}-filter-option` : void 0
1854
+ }, subMenuListeners), {
1855
+ subMenu: (_b2) => {
1856
+ var _c = _b2, { menuId, subMenuLevel } = _c, props2 = __objRest(_c, ["menuId", "subMenuLevel"]);
1857
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1858
+ Menu,
1859
+ __spreadProps(__spreadValues({
1860
+ id: id ? `${id}-filter-submenu` : void 0
1861
+ }, props2), {
1862
+ show: isMenuActive(menuId, subMenuLevel),
1863
+ ref: (el) => {
1864
+ registerSubMenu(menuId, el);
1865
+ },
1866
+ children: [
1867
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: (0, import_clsx8.default)(paddingUsingComponentGap), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1868
+ Search,
1869
+ {
1870
+ id: id ? `${id}-filter-search` : void 0,
1871
+ onChange: (event) => {
1872
+ setFilter(event.target.value);
1873
+ },
1874
+ onKeyDown: (event) => {
1875
+ if ([" ", "Space"].includes(event.key)) {
1876
+ event.stopPropagation();
1877
+ }
1878
+ },
1879
+ value: filter != null ? filter : ""
1880
+ }
1881
+ ) }),
1882
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1883
+ MenuOption,
1884
+ {
1885
+ id: id ? `${id}-filter-contains` : void 0,
1886
+ onClick: handleFilterFnChange,
1887
+ before: menuOptionIcon("includesString"),
1888
+ children: "Contains"
1889
+ }
1890
+ ),
1891
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1892
+ MenuOption,
1893
+ {
1894
+ id: id ? `${id}-filter-startswith` : void 0,
1895
+ onClick: handleFilterFnChange,
1896
+ before: menuOptionIcon("startsWith"),
1897
+ children: "Starts with"
1898
+ }
1899
+ ),
1900
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1901
+ MenuOption,
1902
+ {
1903
+ id: id ? `${id}-filter-endswith` : void 0,
1904
+ onClick: handleFilterFnChange,
1905
+ before: menuOptionIcon("endsWith"),
1906
+ children: "Ends with"
1907
+ }
1908
+ )
1909
+ ]
1910
+ })
1911
+ );
1912
+ },
1913
+ children: "Filter"
1914
+ })
1915
+ ),
1916
+ !predeterminedPinned.current && header.column.getCanPin() && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1917
+ MenuOption,
1918
+ __spreadProps(__spreadValues({
1919
+ onClick: () => {
1920
+ setShowMenu(!showMenu);
1921
+ }
1922
+ }, subMenuListeners), {
1923
+ subMenu: (_d) => {
1924
+ var _e = _d, { menuId, subMenuLevel } = _e, props2 = __objRest(_e, ["menuId", "subMenuLevel"]);
1925
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1926
+ Menu,
1927
+ __spreadProps(__spreadValues({}, props2), {
1928
+ show: isMenuActive(menuId, subMenuLevel),
1929
+ ref: (el) => {
1930
+ registerSubMenu(menuId, el);
1931
+ },
1932
+ children: [
1933
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1934
+ MenuOption,
1935
+ {
1936
+ selected: header.column.getIsPinned() === "left",
1937
+ onClick: () => {
1938
+ if (header.column.getIsPinned() === "left") {
1939
+ header.column.pin(false);
1940
+ } else {
1941
+ header.column.pin("left");
1942
+ }
1943
+ },
1944
+ after: header.column.getIsPinned() === "left" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "check" }),
1945
+ children: "Left"
1946
+ }
1947
+ ),
1948
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1949
+ MenuOption,
1950
+ {
1951
+ selected: header.column.getIsPinned() === "right",
1952
+ onClick: () => {
1953
+ if (header.column.getIsPinned() === "right") {
1954
+ header.column.pin(false);
1955
+ } else {
1956
+ header.column.pin("right");
1957
+ }
1958
+ },
1959
+ after: header.column.getIsPinned() === "right" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "check" }),
1960
+ children: "Right"
1961
+ }
1962
+ )
1963
+ ]
1964
+ })
1965
+ );
1966
+ },
1967
+ children: [
1968
+ "Freeze [",
1969
+ header.column.columnDef.header,
1970
+ "]"
1971
+ ]
1972
+ })
1973
+ )
1974
+ ]
1912
1975
  }
1913
1976
  )
1914
1977
  ]
@@ -1926,7 +1989,6 @@ function DraggableCellHeader(_a) {
1926
1989
  );
1927
1990
  }
1928
1991
  function handleFilterFnChange(_id, value) {
1929
- var _a3;
1930
1992
  let filterFn = "includesString";
1931
1993
  const currentFilterFn = header.column.columnDef.filterFn;
1932
1994
  if ((value == null ? void 0 : value.toLowerCase()) === "starts with") {
@@ -1939,9 +2001,43 @@ function DraggableCellHeader(_a) {
1939
2001
  filterFn = currentFilterFn === "includesString" ? "auto" : "includesString";
1940
2002
  }
1941
2003
  header.column.columnDef.filterFn = filterFn;
1942
- header.column.setFilterValue((_a3 = header.column.getFilterValue()) != null ? _a3 : "");
2004
+ header.column.setFilterValue(filter);
1943
2005
  }
1944
2006
  }
2007
+ DataCellHeader.displayName = "DataCellHeader";
2008
+ function DraggableCellHeader(_a) {
2009
+ var _b = _a, {
2010
+ header,
2011
+ children
2012
+ } = _b, props = __objRest(_b, [
2013
+ "header",
2014
+ "children"
2015
+ ]);
2016
+ const { attributes, isDragging, listeners, setNodeRef, transform, node } = (0, import_sortable.useSortable)({
2017
+ id: header.column.id
2018
+ });
2019
+ const style = {
2020
+ opacity: isDragging ? 0.8 : 1,
2021
+ position: "relative",
2022
+ transform: CSS.Translate.toString(transform),
2023
+ transition: "width transform 0.2s ease-in-out",
2024
+ whiteSpace: "nowrap",
2025
+ zIndex: isDragging ? 1 : 0,
2026
+ width: header.column.getSize(),
2027
+ "--color-text-primary-normal": "var(--color-neutral-000)"
2028
+ };
2029
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2030
+ DataCellHeader,
2031
+ __spreadProps(__spreadValues(__spreadValues(__spreadValues({
2032
+ header,
2033
+ setNodeRef,
2034
+ node,
2035
+ style
2036
+ }, props), attributes), listeners), {
2037
+ children
2038
+ })
2039
+ );
2040
+ }
1945
2041
  DraggableCellHeader.displayName = "DraggableCellHeader";
1946
2042
  function DragAlongCell(_a) {
1947
2043
  var _b = _a, {
@@ -1959,15 +2055,15 @@ function DragAlongCell(_a) {
1959
2055
  position: "relative",
1960
2056
  transform: CSS.Translate.toString(transform),
1961
2057
  transition: "width transform 0.2s ease-in-out",
1962
- zIndex: isDragging ? 1 : 0,
1963
2058
  width: cell.column.getSize(),
1964
- minWidth: "min-content"
2059
+ zIndex: isDragging ? 1 : 0
1965
2060
  };
1966
2061
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DataGridCell, __spreadProps(__spreadValues({ style, ref: setNodeRef }, props), { children }));
1967
2062
  }
1968
2063
  DragAlongCell.displayName = "DragAlongCell";
1969
2064
  // Annotate the CommonJS export names for ESM import in node:
1970
2065
  0 && (module.exports = {
2066
+ DataCellHeader,
1971
2067
  DataGridCell,
1972
2068
  DragAlongCell,
1973
2069
  DraggableCellHeader
@@ -1,12 +1,13 @@
1
1
  "use client";
2
2
  import {
3
+ DataCellHeader,
3
4
  DataGridCell,
4
5
  DragAlongCell,
5
6
  DraggableCellHeader
6
- } from "../chunk-S5KPS4IQ.js";
7
+ } from "../chunk-HXEPUO5W.js";
7
8
  import "../chunk-VC3R5EUH.js";
8
9
  import "../chunk-Z4UCFUF7.js";
9
- import "../chunk-PDDZ5PMY.js";
10
+ import "../chunk-S46RZBT4.js";
10
11
  import "../chunk-SEKKGFM6.js";
11
12
  import "../chunk-SKHSGGO3.js";
12
13
  import "../chunk-WVUIIBRR.js";
@@ -18,6 +19,7 @@ import "../chunk-IGQVA7SC.js";
18
19
  import "../chunk-RDLEIAQU.js";
19
20
  import "../chunk-ORMEWXMH.js";
20
21
  export {
22
+ DataCellHeader,
21
23
  DataGridCell,
22
24
  DragAlongCell,
23
25
  DraggableCellHeader