@trackunit/react-components 0.1.201 → 0.1.205

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
@@ -195,6 +195,10 @@ cssClassVarianceUtilities.cvaMerge([
195
195
 
196
196
  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);
197
197
  const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); // This users the object in the Object.keys() to infer the type of the keys.
198
+ const isSafari = () => {
199
+ const ua = navigator.userAgent.toLowerCase();
200
+ return ua.includes("safari") && !ua.includes("chrome");
201
+ };
198
202
  /**
199
203
  * - The Icon component is used to display an Icon.
200
204
  * - Icons are semantic vector graphics that adds character and improves the visual appeal of elements when combined with.
@@ -204,16 +208,22 @@ const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); /
204
208
  * @returns {JSX.Element} Icon component
205
209
  */
206
210
  const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fillColor, type, style, forwardedRef, }) => {
207
- const correctIconType = React__namespace.useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
211
+ const useTagRef = React.useRef(null);
212
+ const correctIconType = React.useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
208
213
  const iconName = uiIcons.iconNames[name];
214
+ const href = React.useMemo(() => ({
215
+ solid: `${IconSpriteSolid__default["default"]}#${iconName}`,
216
+ outline: `${IconSpriteOutline__default["default"]}#${iconName}`,
217
+ }), [iconName]);
218
+ React.useEffect(() => {
219
+ if (isSafari() && useTagRef.current) {
220
+ useTagRef.current.setAttribute("href", href[correctIconType]);
221
+ }
222
+ }, [correctIconType, href]);
209
223
  if (!iconName) {
210
224
  return null;
211
225
  }
212
- const href = {
213
- solid: `${IconSpriteSolid__default["default"]}#${iconName}`,
214
- outline: `${IconSpriteOutline__default["default"]}#${iconName}`,
215
- };
216
- return (jsxRuntime.jsx("span", { className: cvaIcon({ color, size, className }), onClick: onClick, "data-testid": dataTestId, ref: forwardedRef, children: jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", "data-testid": dataTestId ? `${dataTestId}-${iconName}` : iconName, style: fillColor ? Object.assign(Object.assign({}, style), { fill: fillColor }) : Object.assign({}, style), children: jsxRuntime.jsx("use", { href: href[correctIconType] }) }) }));
226
+ return (jsxRuntime.jsx("span", { className: cvaIcon({ color, size, className }), onClick: onClick, "data-testid": dataTestId, ref: forwardedRef, children: jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", "data-testid": dataTestId ? `${dataTestId}-${iconName}` : iconName, style: fillColor ? Object.assign(Object.assign({}, style), { fill: fillColor }) : Object.assign({}, style), children: jsxRuntime.jsx("use", { href: href[correctIconType], ref: useTagRef }) }) }));
217
227
  };
218
228
 
219
229
  const cvaTag = cssClassVarianceUtilities.cvaMerge([
@@ -1221,7 +1231,6 @@ const usePopoverContext = () => {
1221
1231
  *
1222
1232
  * To render the content of the popover, use the `<PopoverContent />` component.
1223
1233
  *
1224
-
1225
1234
  * @param {PopoverProps} props The props for the popover
1226
1235
  * @returns {JSX.Element} A Popover Context Provider containing the children
1227
1236
  */
@@ -1414,7 +1423,6 @@ var WorkerWithSign = "8df3d27593b5fba4.svg";
1414
1423
  * Component representing an empty state.
1415
1424
  * Use this component when there is no data to display or when an error occurs.
1416
1425
  *
1417
-
1418
1426
  * @param {EmptyStateProps} props props
1419
1427
  * @returns {JSX.Element} component
1420
1428
  * @example
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { useState, useMemo, createContext, useContext, forwardRef, isValidElement, cloneElement, useCallback, useEffect, memo, Children, useRef, useReducer } from 'react';
3
+ import React__default, { useRef, useMemo, useEffect, useState, createContext, useContext, forwardRef, isValidElement, cloneElement, useCallback, memo, Children, useReducer } from 'react';
4
4
  import { rentalStatusPalette, intentPalette, generalPalette, criticalityPalette, activityPalette, utilizationPalette, sitesPalette, color } from '@trackunit/ui-design-tokens';
5
5
  import { iconNames } from '@trackunit/ui-icons';
6
6
  import IconSpriteOutline from '@trackunit/ui-icons/icons-sprite-outline.svg';
@@ -166,6 +166,10 @@ cvaMerge([
166
166
 
167
167
  const iconPalette = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, intentPalette), generalPalette), criticalityPalette), activityPalette), utilizationPalette), sitesPalette), rentalStatusPalette);
168
168
  const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); // This users the object in the Object.keys() to infer the type of the keys.
169
+ const isSafari = () => {
170
+ const ua = navigator.userAgent.toLowerCase();
171
+ return ua.includes("safari") && !ua.includes("chrome");
172
+ };
169
173
  /**
170
174
  * - The Icon component is used to display an Icon.
171
175
  * - Icons are semantic vector graphics that adds character and improves the visual appeal of elements when combined with.
@@ -175,16 +179,22 @@ const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); /
175
179
  * @returns {JSX.Element} Icon component
176
180
  */
177
181
  const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fillColor, type, style, forwardedRef, }) => {
178
- const correctIconType = React.useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
182
+ const useTagRef = useRef(null);
183
+ const correctIconType = useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
179
184
  const iconName = iconNames[name];
185
+ const href = useMemo(() => ({
186
+ solid: `${IconSpriteSolid}#${iconName}`,
187
+ outline: `${IconSpriteOutline}#${iconName}`,
188
+ }), [iconName]);
189
+ useEffect(() => {
190
+ if (isSafari() && useTagRef.current) {
191
+ useTagRef.current.setAttribute("href", href[correctIconType]);
192
+ }
193
+ }, [correctIconType, href]);
180
194
  if (!iconName) {
181
195
  return null;
182
196
  }
183
- const href = {
184
- solid: `${IconSpriteSolid}#${iconName}`,
185
- outline: `${IconSpriteOutline}#${iconName}`,
186
- };
187
- return (jsx("span", { className: cvaIcon({ color, size, className }), onClick: onClick, "data-testid": dataTestId, ref: forwardedRef, children: jsx("svg", { viewBox: "0 0 24 24", "data-testid": dataTestId ? `${dataTestId}-${iconName}` : iconName, style: fillColor ? Object.assign(Object.assign({}, style), { fill: fillColor }) : Object.assign({}, style), children: jsx("use", { href: href[correctIconType] }) }) }));
197
+ return (jsx("span", { className: cvaIcon({ color, size, className }), onClick: onClick, "data-testid": dataTestId, ref: forwardedRef, children: jsx("svg", { viewBox: "0 0 24 24", "data-testid": dataTestId ? `${dataTestId}-${iconName}` : iconName, style: fillColor ? Object.assign(Object.assign({}, style), { fill: fillColor }) : Object.assign({}, style), children: jsx("use", { href: href[correctIconType], ref: useTagRef }) }) }));
188
198
  };
189
199
 
190
200
  const cvaTag = cvaMerge([
@@ -1192,7 +1202,6 @@ const usePopoverContext = () => {
1192
1202
  *
1193
1203
  * To render the content of the popover, use the `<PopoverContent />` component.
1194
1204
  *
1195
-
1196
1205
  * @param {PopoverProps} props The props for the popover
1197
1206
  * @returns {JSX.Element} A Popover Context Provider containing the children
1198
1207
  */
@@ -1385,7 +1394,6 @@ var WorkerWithSign = "8df3d27593b5fba4.svg";
1385
1394
  * Component representing an empty state.
1386
1395
  * Use this component when there is no data to display or when an error occurs.
1387
1396
  *
1388
-
1389
1397
  * @param {EmptyStateProps} props props
1390
1398
  * @returns {JSX.Element} component
1391
1399
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.201",
3
+ "version": "0.1.205",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -11,15 +11,15 @@
11
11
  "react": "^18.2.0",
12
12
  "@trackunit/css-class-variance-utilities": "*",
13
13
  "react-use": "^17.4.0",
14
- "react-day-picker": "^8.7.1",
15
- "date-fns": "^2.29.3",
16
- "@floating-ui/react": "^0.25.4",
14
+ "react-day-picker": "^8.9.1",
15
+ "date-fns": "^2.30.0",
16
+ "@floating-ui/react": "^0.26.2",
17
17
  "@trackunit/ui-icons": "*",
18
18
  "@trackunit/shared-utils": "*",
19
19
  "react-useportal": "1.0.18",
20
- "react-router-dom": "6.11.2",
20
+ "react-router-dom": "6.18.0",
21
21
  "react-helmet-async": "^1.3.0",
22
- "zod": "3.22.3",
22
+ "zod": "3.22.4",
23
23
  "lodash": "4.17.21",
24
24
  "jest-fetch-mock": "^3.0.3",
25
25
  "@testing-library/react": "14.0.0"
@@ -14,7 +14,6 @@ export interface EmptyStateProps extends CommonProps {
14
14
  * Component representing an empty state.
15
15
  * Use this component when there is no data to display or when an error occurs.
16
16
  *
17
-
18
17
  * @param {EmptyStateProps} props props
19
18
  * @returns {JSX.Element} component
20
19
  * @example
@@ -1,6 +1,6 @@
1
+ /// <reference types="react" />
1
2
  import { ActivityColors, CriticalityColors, GeneralColors, IntentColors, RentalStatusColors, SitesColors, UtilizationColors } from "@trackunit/ui-design-tokens";
2
3
  import { IconName } from "@trackunit/ui-icons";
3
- import * as React from "react";
4
4
  import { CommonProps, Size } from "../../common/CommonProps";
5
5
  export type IconColors = IntentColors | GeneralColors | CriticalityColors | ActivityColors | UtilizationColors | SitesColors | RentalStatusColors;
6
6
  export declare const iconPalette: {
@@ -190,12 +190,7 @@ export declare const iconPalette: {
190
190
  readonly 300: "212 212 212";
191
191
  readonly 400: "163 163 163";
192
192
  readonly 500: "115 115 115";
193
- readonly 600: "82 82 82"; /**
194
- * The size of the icon.
195
- * Small = 16x16px, medium = 20x20px, Large = 24x24px.
196
- * Default value is Large.
197
- * If a custom size is needed, set it in the className.
198
- */
193
+ readonly 600: "82 82 82";
199
194
  readonly 700: "64 64 64";
200
195
  readonly 800: "38 38 38";
201
196
  readonly 900: "23 23 23";
@@ -214,7 +209,14 @@ export declare const iconPalette: {
214
209
  readonly 400: "96 165 250";
215
210
  readonly 500: "59 130 246";
216
211
  readonly 600: "37 99 235";
217
- readonly 700: "29 78 216";
212
+ readonly 700: "29 78 216"; /**
213
+ * - The Icon component is used to display an Icon.
214
+ * - Icons are semantic vector graphics that adds character and improves the visual appeal of elements when combined with.
215
+ * - All the [HeroIcons](https://heroicons.dev/) as well as custom Trackunit icons are available.
216
+
217
+ * @param {IconProps} props - The props for the Icon component
218
+ * @returns {JSX.Element} Icon component
219
+ */
218
220
  readonly 800: "30 64 175";
219
221
  readonly 900: "30 58 138";
220
222
  };
@@ -1,5 +1,5 @@
1
1
  export declare const cvaIcon: (props?: ({
2
- color?: "primary" | "secondary" | "accent" | "neutral" | "info" | "success" | "warning" | "danger" | "good" | "low" | "critical" | "working" | "idle" | "moving" | "active" | "stopped" | "unknown" | "default" | "black" | "white" | "unused" | "utilized" | "heavily_utilized" | "unknown_utilization" | "site" | "on_rent" | "returned" | "available" | "pickup_ready" | "transfer" | "in_repair" | "other_rental_status" | null | undefined;
2
+ color?: "default" | "primary" | "secondary" | "accent" | "neutral" | "info" | "success" | "warning" | "danger" | "good" | "low" | "critical" | "working" | "idle" | "moving" | "active" | "stopped" | "unknown" | "black" | "white" | "unused" | "utilized" | "heavily_utilized" | "unknown_utilization" | "site" | "on_rent" | "returned" | "available" | "pickup_ready" | "transfer" | "in_repair" | "other_rental_status" | null | undefined;
3
3
  size?: "small" | "medium" | "large" | "font" | null | undefined;
4
4
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
5
5
  export declare const cvaIconComponent: (props?: ({
@@ -33,20 +33,20 @@ export interface MenuItemProps extends CommonProps {
33
33
  * An boolean flag to turn on/off selected state
34
34
  * This is typically used highlight that item is selected
35
35
  *
36
- * @memberof IMenuItemProps
36
+ * @memberof MenuItemProps
37
37
  */
38
38
  selected?: boolean;
39
39
  /**
40
40
  * OnClick event handler it is thrown on root element of the component tree
41
41
  *
42
- * @memberof IMenuItemProps
42
+ * @memberof MenuItemProps
43
43
  */
44
44
  onClick?: React.MouseEventHandler<HTMLDivElement>;
45
45
  /**
46
46
  * An boolean flag to turn on/off focused state
47
47
  * This is typically used for keyboard navigation
48
48
  *
49
- * @memberof IMenuItemProps
49
+ * @memberof MenuItemProps
50
50
  */
51
51
  focused?: boolean;
52
52
  /**
@@ -47,7 +47,7 @@ export declare const usePopoverContext: () => {
47
47
  update: () => void;
48
48
  floatingStyles: import("react").CSSProperties;
49
49
  open: boolean;
50
- onOpenChange: (open: boolean, event?: Event | undefined) => void;
50
+ onOpenChange: (open: boolean, event?: Event | undefined, reason?: import("@floating-ui/react").OpenChangeReason | undefined) => void;
51
51
  events: import("@floating-ui/react").FloatingEvents;
52
52
  dataRef: import("react").MutableRefObject<import("@floating-ui/react").ContextData>;
53
53
  nodeId: string | undefined;
@@ -68,7 +68,6 @@ export declare const usePopoverContext: () => {
68
68
  *
69
69
  * To render the content of the popover, use the `<PopoverContent />` component.
70
70
  *
71
-
72
71
  * @param {PopoverProps} props The props for the popover
73
72
  * @returns {JSX.Element} A Popover Context Provider containing the children
74
73
  */
@@ -48,7 +48,7 @@ export declare const usePopover: ({ initialOpen, placement, isModal, isOpen: con
48
48
  update: () => void;
49
49
  floatingStyles: import("react").CSSProperties;
50
50
  open: boolean;
51
- onOpenChange: (open: boolean, event?: Event | undefined) => void;
51
+ onOpenChange: (open: boolean, event?: Event | undefined, reason?: import("@floating-ui/react").OpenChangeReason | undefined) => void;
52
52
  events: import("@floating-ui/react").FloatingEvents;
53
53
  dataRef: import("react").MutableRefObject<import("@floating-ui/react").ContextData>;
54
54
  nodeId: string | undefined;
@@ -1,6 +1,6 @@
1
1
  export declare const cvaTag: (props?: ({
2
2
  size?: "small" | "medium" | null | undefined;
3
- layout?: "withIcon" | "default" | null | undefined;
3
+ layout?: "default" | "withIcon" | null | undefined;
4
4
  color?: "primary" | "secondary" | "accent" | "neutral" | "black" | "white" | "info" | "success" | "warning" | "danger" | "good" | "low" | "critical" | "working" | "stopped" | "idle" | "unknown" | "moving" | "active" | null | undefined;
5
5
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
6
  export declare const cvaTagIconContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;