@trackunit/react-components 0.1.270 → 0.1.272

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/index.cjs.js CHANGED
@@ -4,11 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
+ var sharedUtils = require('@trackunit/shared-utils');
7
8
  var uiDesignTokens = require('@trackunit/ui-design-tokens');
8
9
  var uiIcons = require('@trackunit/ui-icons');
9
10
  var IconSpriteMini = require('@trackunit/ui-icons/icons-sprite-mini.svg');
10
11
  var IconSpriteOutline = require('@trackunit/ui-icons/icons-sprite-outline.svg');
11
12
  var IconSpriteSolid = require('@trackunit/ui-icons/icons-sprite-solid.svg');
13
+ var stringTs = require('string-ts');
12
14
  var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
13
15
  var reactUse = require('react-use');
14
16
  var reactDayPicker = require('react-day-picker');
@@ -162,8 +164,7 @@ cssClassVarianceUtilities.cvaMerge([
162
164
  ]);
163
165
 
164
166
  const iconPalette = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, uiDesignTokens.intentPalette), uiDesignTokens.generalPalette), uiDesignTokens.criticalityPalette), uiDesignTokens.activityPalette), uiDesignTokens.utilizationPalette), uiDesignTokens.sitesPalette), uiDesignTokens.rentalStatusPalette);
165
- // eslint-disable-next-line local-rules/no-typescript-assertion
166
- const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); // This users the object in the Object.keys() to infer the type of the keys.
167
+ const iconColorNames = sharedUtils.objectKeys(iconPalette).map(key => stringTs.snakeCase(key));
167
168
  const isSafari = () => {
168
169
  const ua = navigator.userAgent.toLowerCase();
169
170
  return ua.includes("safari") && !ua.includes("chrome");
@@ -1907,6 +1908,39 @@ const useModal = ({ closeOnOutsideClick } = {}) => {
1907
1908
  };
1908
1909
  };
1909
1910
 
1911
+ const cvaPage = cssClassVarianceUtilities.cvaMerge(["grid", "h-full"], {
1912
+ variants: {
1913
+ layout: {
1914
+ content: ["grid-rows-1"],
1915
+ "header-content": "grid-rows-min-fr",
1916
+ "sidebar-content": ["grid-cols-[360px_minmax(0,1fr)]", "grid-rows-1"],
1917
+ none: [],
1918
+ },
1919
+ },
1920
+ defaultVariants: {
1921
+ layout: "none",
1922
+ },
1923
+ });
1924
+ const cvaPageContent = cssClassVarianceUtilities.cvaMerge(["overflow-auto", "p-4", "md:p-6", "lg:p-8"]);
1925
+
1926
+ /**
1927
+ * Renders the page component. Adds padding and layout to the page.
1928
+ */
1929
+ const Page = ({ layout, className, children, dataTestId }) => {
1930
+ return (jsxRuntime.jsx("div", { className: cvaPage({ className, layout }), "data-testid": dataTestId || "page", children: children }));
1931
+ };
1932
+
1933
+ /**
1934
+ * Renders the content of a page.
1935
+ * Applies padding to content. To be used within a <Page/>
1936
+ *
1937
+ * @param {PageContentProps} props - The component props.
1938
+ * @returns {React.ReactNode} - The rendered component.
1939
+ */
1940
+ const PageContent = ({ className, children, dataTestId }) => {
1941
+ return (jsxRuntime.jsx("div", { className: cvaPageContent({ className }), "data-testid": dataTestId || "page-content", children: children }));
1942
+ };
1943
+
1910
1944
  const cvaNotice = cssClassVarianceUtilities.cvaMerge(["flex", "items-center"]);
1911
1945
  const cvaNoticeLabel = cssClassVarianceUtilities.cvaMerge(["pl-1", "pr-1", "font-medium", "text-sm"], {
1912
1946
  variants: {
@@ -2247,7 +2281,7 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
2247
2281
  childUniqueIdentifierAttribute: "id",
2248
2282
  threshold: overflowThreshold !== null && overflowThreshold !== void 0 ? overflowThreshold : 0.8,
2249
2283
  });
2250
- const overflowItemCount = Object.values(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
2284
+ const overflowItemCount = sharedUtils.objectValues(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
2251
2285
  const itemVisibilityClassName = (id) => {
2252
2286
  if (itemOverflowMap[id]) {
2253
2287
  return "invisible";
@@ -3116,6 +3150,8 @@ exports.ModalBackdrop = ModalBackdrop;
3116
3150
  exports.MoreMenu = MoreMenu;
3117
3151
  exports.Notice = Notice;
3118
3152
  exports.PackageNameStoryComponent = PackageNameStoryComponent;
3153
+ exports.Page = Page;
3154
+ exports.PageContent = PageContent;
3119
3155
  exports.PageHeader = PageHeader;
3120
3156
  exports.Pagination = Pagination;
3121
3157
  exports.Popover = Popover;
package/index.esm.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { useRef, useMemo, useEffect, useState, useCallback, memo, createContext, useContext, forwardRef, isValidElement, cloneElement, Children, useReducer } from 'react';
4
+ import { objectKeys, objectValues } from '@trackunit/shared-utils';
4
5
  import { rentalStatusPalette, intentPalette, generalPalette, criticalityPalette, activityPalette, utilizationPalette, sitesPalette, color } from '@trackunit/ui-design-tokens';
5
6
  import { iconNames } from '@trackunit/ui-icons';
6
7
  import IconSpriteMini from '@trackunit/ui-icons/icons-sprite-mini.svg';
7
8
  import IconSpriteOutline from '@trackunit/ui-icons/icons-sprite-outline.svg';
8
9
  import IconSpriteSolid from '@trackunit/ui-icons/icons-sprite-solid.svg';
10
+ import { snakeCase } from 'string-ts';
9
11
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
10
12
  import { useMeasure, useCopyToClipboard, usePrevious } from 'react-use';
11
13
  import { DayPicker as DayPicker$1 } from 'react-day-picker';
@@ -131,8 +133,7 @@ cvaMerge([
131
133
  ]);
132
134
 
133
135
  const iconPalette = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, intentPalette), generalPalette), criticalityPalette), activityPalette), utilizationPalette), sitesPalette), rentalStatusPalette);
134
- // eslint-disable-next-line local-rules/no-typescript-assertion
135
- const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); // This users the object in the Object.keys() to infer the type of the keys.
136
+ const iconColorNames = objectKeys(iconPalette).map(key => snakeCase(key));
136
137
  const isSafari = () => {
137
138
  const ua = navigator.userAgent.toLowerCase();
138
139
  return ua.includes("safari") && !ua.includes("chrome");
@@ -1876,6 +1877,39 @@ const useModal = ({ closeOnOutsideClick } = {}) => {
1876
1877
  };
1877
1878
  };
1878
1879
 
1880
+ const cvaPage = cvaMerge(["grid", "h-full"], {
1881
+ variants: {
1882
+ layout: {
1883
+ content: ["grid-rows-1"],
1884
+ "header-content": "grid-rows-min-fr",
1885
+ "sidebar-content": ["grid-cols-[360px_minmax(0,1fr)]", "grid-rows-1"],
1886
+ none: [],
1887
+ },
1888
+ },
1889
+ defaultVariants: {
1890
+ layout: "none",
1891
+ },
1892
+ });
1893
+ const cvaPageContent = cvaMerge(["overflow-auto", "p-4", "md:p-6", "lg:p-8"]);
1894
+
1895
+ /**
1896
+ * Renders the page component. Adds padding and layout to the page.
1897
+ */
1898
+ const Page = ({ layout, className, children, dataTestId }) => {
1899
+ return (jsx("div", { className: cvaPage({ className, layout }), "data-testid": dataTestId || "page", children: children }));
1900
+ };
1901
+
1902
+ /**
1903
+ * Renders the content of a page.
1904
+ * Applies padding to content. To be used within a <Page/>
1905
+ *
1906
+ * @param {PageContentProps} props - The component props.
1907
+ * @returns {React.ReactNode} - The rendered component.
1908
+ */
1909
+ const PageContent = ({ className, children, dataTestId }) => {
1910
+ return (jsx("div", { className: cvaPageContent({ className }), "data-testid": dataTestId || "page-content", children: children }));
1911
+ };
1912
+
1879
1913
  const cvaNotice = cvaMerge(["flex", "items-center"]);
1880
1914
  const cvaNoticeLabel = cvaMerge(["pl-1", "pr-1", "font-medium", "text-sm"], {
1881
1915
  variants: {
@@ -2216,7 +2250,7 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
2216
2250
  childUniqueIdentifierAttribute: "id",
2217
2251
  threshold: overflowThreshold !== null && overflowThreshold !== void 0 ? overflowThreshold : 0.8,
2218
2252
  });
2219
- const overflowItemCount = Object.values(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
2253
+ const overflowItemCount = objectValues(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
2220
2254
  const itemVisibilityClassName = (id) => {
2221
2255
  if (itemOverflowMap[id]) {
2222
2256
  return "invisible";
@@ -3060,4 +3094,4 @@ const useVisibilityChange = ({ onChange, targetState = "hidden" }) => {
3060
3094
  }, [onChange, targetState]);
3061
3095
  };
3062
3096
 
3063
- export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, Notice, PackageNameStoryComponent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, Tooltip, ValueBar, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useVisibilityChange };
3097
+ export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, Tooltip, ValueBar, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useVisibilityChange };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.270",
3
+ "version": "0.1.272",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -23,7 +23,8 @@
23
23
  "lodash": "4.17.21",
24
24
  "jest-fetch-mock": "^3.0.3",
25
25
  "@testing-library/react": "14.0.0",
26
- "@floating-ui/react": "^0.26.6"
26
+ "@floating-ui/react": "^0.26.6",
27
+ "string-ts": "^2.0.0"
27
28
  },
28
29
  "module": "./index.esm.js",
29
30
  "main": "./index.cjs.js"
@@ -205,11 +205,7 @@ export declare const iconPalette: {
205
205
  readonly 50: "239 246 255";
206
206
  readonly 100: "219 234 254";
207
207
  readonly 200: "191 219 254";
208
- readonly 300: "147 197 253"; /**
209
- * Select if the icon should be rendered as solid or outline.
210
- * Default value depends on the Size prop, mini == solid, medium == solid, large == outline.
211
- * Trackunit icons might not support both outline and Solid.
212
- */
208
+ readonly 300: "147 197 253";
213
209
  readonly 400: "96 165 250";
214
210
  readonly 500: "59 130 246";
215
211
  readonly 600: "37 99 235";
@@ -221,7 +217,11 @@ export declare const iconPalette: {
221
217
  readonly 50: "240 253 244";
222
218
  readonly 100: "220 252 231";
223
219
  readonly 200: "187 247 208";
224
- readonly 300: "134 239 172";
220
+ readonly 300: "134 239 172"; /**
221
+ * Custom styles object used to override existing styles or add some extra styling
222
+ *
223
+ * @memberof IconProps
224
+ */
225
225
  readonly 400: "74 222 128";
226
226
  readonly 500: "34 197 94";
227
227
  readonly 600: "22 163 74";
@@ -0,0 +1,20 @@
1
+ import { VariantProps } from "@trackunit/css-class-variance-utilities";
2
+ import * as React from "react";
3
+ import { CommonProps } from "../../common";
4
+ import { cvaPage } from "./Page.variants";
5
+ /**
6
+ * The layout of the page.
7
+ */
8
+ export type Layout = VariantProps<typeof cvaPage>["layout"];
9
+ /**
10
+ * The props for the page component.
11
+ */
12
+ export interface PageProps extends CommonProps {
13
+ layout: Layout;
14
+ children?: React.ReactNode;
15
+ dataTestId?: string;
16
+ }
17
+ /**
18
+ * Renders the page component. Adds padding and layout to the page.
19
+ */
20
+ export declare const Page: ({ layout, className, children, dataTestId }: PageProps) => JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare const cvaPage: (props?: ({
2
+ layout?: "content" | "header-content" | "sidebar-content" | "none" | null | undefined;
3
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
4
+ export declare const cvaPageContent: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { CommonProps } from "../../common";
3
+ /**
4
+ * The props for the page content component.
5
+ */
6
+ interface PageContentProps extends CommonProps {
7
+ children?: React.ReactNode;
8
+ }
9
+ /**
10
+ * Renders the content of a page.
11
+ * Applies padding to content. To be used within a <Page/>
12
+ *
13
+ * @param {PageContentProps} props - The component props.
14
+ * @returns {React.ReactNode} - The rendered component.
15
+ */
16
+ export declare const PageContent: ({ className, children, dataTestId }: PageContentProps) => JSX.Element;
17
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./Page";
2
+ export * from "./PageContent";
@@ -12,6 +12,7 @@ export * from "./Icon/Icon";
12
12
  export * from "./Indicator";
13
13
  export * from "./Menu";
14
14
  export * from "./Modal";
15
+ export * from "./Page";
15
16
  export * from "./Notice";
16
17
  export * from "./PageHeader";
17
18
  export * from "./Pagination/Pagination";