@trackunit/react-components 0.0.143 → 0.0.147
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.
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Matcher } from "react-day-picker";
|
|
3
2
|
import { BaseInputProps } from "../BaseInput";
|
|
4
|
-
declare type BaseInputExposedProps = Omit<BaseInputProps, "defaultValue" | "
|
|
3
|
+
declare type BaseInputExposedProps = Omit<BaseInputProps, "defaultValue" | "min" | "max" | "value">;
|
|
5
4
|
export interface DateInputProps extends BaseInputExposedProps {
|
|
6
5
|
/**
|
|
7
|
-
* A
|
|
6
|
+
* A min value in type Date
|
|
8
7
|
*/
|
|
9
|
-
|
|
8
|
+
min?: Date;
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
10
|
+
* A max date value in type Date
|
|
12
11
|
*/
|
|
13
|
-
|
|
12
|
+
max?: Date;
|
|
14
13
|
/**
|
|
15
|
-
* A
|
|
14
|
+
* A default value in type Date
|
|
16
15
|
*/
|
|
17
|
-
|
|
16
|
+
defaultValue?: Date;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* A value in type Date
|
|
20
19
|
*/
|
|
21
|
-
|
|
20
|
+
value?: Date;
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
23
|
* A wrapper around BaseInput with a pop-up day picker.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { CommonProps } from "../../common/CommonProps";
|
|
3
|
+
import "./PageHeading.css";
|
|
4
|
+
export interface PageHeadingProps extends CommonProps {
|
|
3
5
|
/**
|
|
4
6
|
* The title of the page.
|
|
5
7
|
*/
|
|
@@ -9,16 +11,14 @@ interface PageHeadingProps {
|
|
|
9
11
|
*/
|
|
10
12
|
subtitle?: string;
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* The addon could be used to tell the state of a pageheading.
|
|
13
15
|
*/
|
|
14
|
-
|
|
15
|
-
tag?: string;
|
|
16
|
+
addon?: ReactNode;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
* The PageHeading component used on pages.
|
|
19
|
+
* The PageHeading component is used on pages to set the Browser page title.
|
|
19
20
|
*
|
|
20
21
|
* @param {PageHeadingProps} props - The props for the PageHeading component
|
|
21
22
|
* @returns {JSX.Element} PageHeading component
|
|
22
23
|
*/
|
|
23
|
-
export declare const PageHeading: ({ title, subtitle, dataTestId,
|
|
24
|
-
export {};
|
|
24
|
+
export declare const PageHeading: ({ title, subtitle, dataTestId, addon }: PageHeadingProps) => JSX.Element;
|
|
@@ -12,4 +12,4 @@ export declare function isMultiValue<Option>(arg: MultiValue<Option> | SingleVal
|
|
|
12
12
|
* @returns {OptionsOrGroups<Option, Group>} An array of ordered options with selected on top
|
|
13
13
|
*/
|
|
14
14
|
export declare const getOrderedOptions: <Option, Group extends GroupBase<Option>>(options: OptionsOrGroups<Option, Group> | undefined, value: PropsValue<Option> | undefined) => OptionsOrGroups<Option, Group>;
|
|
15
|
-
export declare const SelectPrefix: import("tailwind-styled-components/dist/tailwind").
|
|
15
|
+
export declare const SelectPrefix: import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindComponent<import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindHtmlComponent<"div">, {}>;
|
package/index.css
CHANGED
|
@@ -211,6 +211,16 @@
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
.tu-pageheading {
|
|
215
|
+
@apply w-full;
|
|
216
|
+
|
|
217
|
+
&__flex{
|
|
218
|
+
@apply flex
|
|
219
|
+
items-center
|
|
220
|
+
flex-wrap-reverse
|
|
221
|
+
gap-2;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
214
224
|
/* CSS related to the RadioGroup component */
|
|
215
225
|
.tu-radiogroup {
|
|
216
226
|
@apply flex
|
package/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { tw, tws, twx } from '@trackunit/tailwind-styled-components';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { useState, forwardRef,
|
|
4
|
+
import React__default, { useState, forwardRef, useRef, Fragment as Fragment$1, useCallback, createElement, useEffect, useContext, memo } from 'react';
|
|
5
5
|
import { HeroIconsArray, heroIconLookup, TrackunitSolidIconsArray, TrackunitOutlineIconsArray, trackunitIconLookup } from '@trackunit/ui-icons';
|
|
6
6
|
import EChart from 'echarts-for-react';
|
|
7
7
|
import { v4 } from 'uuid';
|
|
8
8
|
import { useMeasure, useCopyToClipboard, useKeyPressEvent } from 'react-use';
|
|
9
|
-
import {
|
|
10
|
-
import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
|
|
9
|
+
import { format, formatDistance } from 'date-fns';
|
|
11
10
|
import { useSpring, animated } from '@react-spring/web';
|
|
12
11
|
import usePortal from 'react-useportal';
|
|
13
12
|
import { createPopper } from '@popperjs/core';
|
|
13
|
+
import { DayPicker as DayPicker$1 } from 'react-day-picker';
|
|
14
|
+
import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
|
|
14
15
|
import { Helmet } from 'react-helmet';
|
|
15
16
|
import { UNSAFE_NavigationContext } from 'react-router-dom';
|
|
16
17
|
import ReactSelect, { components } from 'react-select';
|
|
@@ -18,7 +19,6 @@ export { default as ValueType } from 'react-select';
|
|
|
18
19
|
import ReactAsyncCreatableSelect from 'react-select/async-creatable';
|
|
19
20
|
import ReactCreatableSelect from 'react-select/creatable';
|
|
20
21
|
import ReactAsyncSelect from 'react-select/async';
|
|
21
|
-
import { format, formatDistance } from 'date-fns';
|
|
22
22
|
import { getColorValue } from '@trackunit/ui-design-tokens';
|
|
23
23
|
|
|
24
24
|
const docs = {
|
|
@@ -1833,64 +1833,45 @@ const StyledCopyableText = tw.span`
|
|
|
1833
1833
|
tu-copyable-text
|
|
1834
1834
|
${p => p.$animating ? tws`tu-copyable-text--animating` : null}`;
|
|
1835
1835
|
|
|
1836
|
-
const localeLookup = {
|
|
1837
|
-
en: enGB,
|
|
1838
|
-
"en-US": enUS,
|
|
1839
|
-
"en-GB": enGB,
|
|
1840
|
-
da,
|
|
1841
|
-
de,
|
|
1842
|
-
cs,
|
|
1843
|
-
nl,
|
|
1844
|
-
fr,
|
|
1845
|
-
fi,
|
|
1846
|
-
hu,
|
|
1847
|
-
it,
|
|
1848
|
-
nb,
|
|
1849
|
-
pl,
|
|
1850
|
-
pt,
|
|
1851
|
-
ru,
|
|
1852
|
-
ro,
|
|
1853
|
-
es,
|
|
1854
|
-
sv,
|
|
1855
|
-
ja,
|
|
1856
|
-
th
|
|
1857
|
-
};
|
|
1858
|
-
/**
|
|
1859
|
-
* A helper function to get the matching Locale object for a given language.
|
|
1860
|
-
*
|
|
1861
|
-
* @param {string} language The language to match
|
|
1862
|
-
* @returns {Locale} The corresponding Locale object
|
|
1863
|
-
*/
|
|
1864
|
-
|
|
1865
|
-
const useLocale = language => {
|
|
1866
|
-
return localeLookup[language] || localeLookup.en;
|
|
1867
|
-
};
|
|
1868
|
-
|
|
1869
1836
|
/**
|
|
1870
|
-
*
|
|
1837
|
+
* A wrapper around BaseInput with a pop-up day picker.
|
|
1871
1838
|
*
|
|
1872
|
-
*
|
|
1873
|
-
* @returns {JSX.Element} DayPicker component
|
|
1839
|
+
* NOTE: If shown with a label, please use the `DateField` component instead.
|
|
1874
1840
|
*/
|
|
1875
1841
|
|
|
1876
|
-
const
|
|
1842
|
+
const DateInput = forwardRef((_a, ref) => {
|
|
1877
1843
|
var {
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1844
|
+
min,
|
|
1845
|
+
max,
|
|
1846
|
+
defaultValue,
|
|
1847
|
+
value
|
|
1882
1848
|
} = _a,
|
|
1883
|
-
rest = __rest(_a, ["
|
|
1849
|
+
rest = __rest(_a, ["min", "max", "defaultValue", "value"]);
|
|
1884
1850
|
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1851
|
+
const formatDateToInputString = date => date ? format(date, "yyyy-MM-dd") : date; // @ts-ignore
|
|
1852
|
+
// Chrome needs it's default icon to have datepicker functionality.
|
|
1853
|
+
// window.chrome doesn't exist in TS but is available on chrome browsers.
|
|
1854
|
+
// If it fails it will just show our icon.
|
|
1855
|
+
|
|
1856
|
+
|
|
1857
|
+
const hideOnChrome = () => window.chrome !== null && typeof window.chrome !== "undefined" ? "hidden" : "";
|
|
1858
|
+
|
|
1859
|
+
return jsx(BaseInput, Object.assign({
|
|
1860
|
+
type: "date",
|
|
1861
|
+
value: formatDateToInputString(value),
|
|
1862
|
+
defaultValue: formatDateToInputString(defaultValue),
|
|
1863
|
+
min: formatDateToInputString(min),
|
|
1864
|
+
max: formatDateToInputString(max),
|
|
1865
|
+
ref: ref,
|
|
1866
|
+
suffix: jsx(Icon$1, {
|
|
1867
|
+
dataTestId: "calendar",
|
|
1868
|
+
name: "CalendarIcon",
|
|
1869
|
+
size: "medium",
|
|
1870
|
+
type: "solid",
|
|
1871
|
+
className: hideOnChrome()
|
|
1872
|
+
})
|
|
1892
1873
|
}, rest));
|
|
1893
|
-
};
|
|
1874
|
+
});
|
|
1894
1875
|
|
|
1895
1876
|
var PopoverLifecycle;
|
|
1896
1877
|
|
|
@@ -2096,101 +2077,6 @@ const StyledCardBody = twx(CardBody)`
|
|
|
2096
2077
|
tu-popover-list-body
|
|
2097
2078
|
`;
|
|
2098
2079
|
|
|
2099
|
-
/**
|
|
2100
|
-
* A wrapper around BaseInput with a pop-up day picker.
|
|
2101
|
-
*
|
|
2102
|
-
* NOTE: If shown with a label, please use the `DateField` component instead.
|
|
2103
|
-
*/
|
|
2104
|
-
|
|
2105
|
-
const DateInput = forwardRef((_a, ref) => {
|
|
2106
|
-
var {
|
|
2107
|
-
defaultValue,
|
|
2108
|
-
disabledDays,
|
|
2109
|
-
disabled,
|
|
2110
|
-
preventDeselect,
|
|
2111
|
-
onChange
|
|
2112
|
-
} = _a,
|
|
2113
|
-
rest = __rest(_a, ["defaultValue", "disabledDays", "disabled", "preventDeselect", "onChange"]);
|
|
2114
|
-
|
|
2115
|
-
const [selectedDay, setSelectedDay] = useState(defaultValue);
|
|
2116
|
-
const onChangeHandler = useCallback(value => {
|
|
2117
|
-
const newValue = (value === null || value === void 0 ? void 0 : value.toLocaleDateString()) === (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) && !preventDeselect ? undefined : value;
|
|
2118
|
-
setSelectedDay(newValue);
|
|
2119
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
2120
|
-
}, [selectedDay, preventDeselect, onChange]);
|
|
2121
|
-
const target = useRef(null);
|
|
2122
|
-
const popover = useRef(null);
|
|
2123
|
-
const {
|
|
2124
|
-
popoverRef,
|
|
2125
|
-
targetRef,
|
|
2126
|
-
onShow,
|
|
2127
|
-
onHide,
|
|
2128
|
-
popoverProps
|
|
2129
|
-
} = usePopover({
|
|
2130
|
-
targetRef: target,
|
|
2131
|
-
popoverRef: popover,
|
|
2132
|
-
placement: "bottom"
|
|
2133
|
-
});
|
|
2134
|
-
return jsxs(Fragment, {
|
|
2135
|
-
children: [jsx(BaseInput, Object.assign({
|
|
2136
|
-
ref: ref,
|
|
2137
|
-
value: (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) || "",
|
|
2138
|
-
onChange: () => {}
|
|
2139
|
-
}, rest, {
|
|
2140
|
-
dataTestId: "dateInput",
|
|
2141
|
-
onFocus: () => {
|
|
2142
|
-
onShow();
|
|
2143
|
-
},
|
|
2144
|
-
nonInteractive: true,
|
|
2145
|
-
suffix: jsx(Icon$1, {
|
|
2146
|
-
dataTestId: "calendar",
|
|
2147
|
-
name: "CalendarIcon",
|
|
2148
|
-
size: "medium",
|
|
2149
|
-
type: "solid",
|
|
2150
|
-
onClick: !disabled ? onShow : undefined,
|
|
2151
|
-
forwardedRef: targetRef
|
|
2152
|
-
}),
|
|
2153
|
-
actions: selectedDay && jsx(RemoveValueContainer, {
|
|
2154
|
-
children: jsx(Button, Object.assign({
|
|
2155
|
-
color: "tertiary",
|
|
2156
|
-
onClick: e => {
|
|
2157
|
-
e.preventDefault();
|
|
2158
|
-
setSelectedDay(undefined);
|
|
2159
|
-
}
|
|
2160
|
-
}, {
|
|
2161
|
-
children: jsx(Icon$1, {
|
|
2162
|
-
name: "XIcon",
|
|
2163
|
-
size: "small"
|
|
2164
|
-
})
|
|
2165
|
-
}))
|
|
2166
|
-
}),
|
|
2167
|
-
onClick: e => e.preventDefault()
|
|
2168
|
-
})), jsx(AnimatedPopover, Object.assign({
|
|
2169
|
-
ref: popoverRef,
|
|
2170
|
-
onRequestClose: () => {
|
|
2171
|
-
var _a;
|
|
2172
|
-
|
|
2173
|
-
onHide();
|
|
2174
|
-
(_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
2175
|
-
}
|
|
2176
|
-
}, popoverProps, {
|
|
2177
|
-
children: jsx(PopoverList, Object.assign({
|
|
2178
|
-
dataTestId: "datePickerPopover"
|
|
2179
|
-
}, {
|
|
2180
|
-
children: jsx(DayPicker, {
|
|
2181
|
-
onDaySelect: onChangeHandler,
|
|
2182
|
-
disabledDays: disabledDays,
|
|
2183
|
-
selectedDays: selectedDay,
|
|
2184
|
-
language: navigator.language
|
|
2185
|
-
})
|
|
2186
|
-
}))
|
|
2187
|
-
}))]
|
|
2188
|
-
});
|
|
2189
|
-
});
|
|
2190
|
-
const RemoveValueContainer = tw.div`
|
|
2191
|
-
tu-date__remove
|
|
2192
|
-
`;
|
|
2193
|
-
|
|
2194
2080
|
/**
|
|
2195
2081
|
* The PopoverListItem component.
|
|
2196
2082
|
*
|
|
@@ -2234,7 +2120,7 @@ const PopoverListItem = ({
|
|
|
2234
2120
|
}, {
|
|
2235
2121
|
children: url ? jsx(UnstyledAnchor, Object.assign({
|
|
2236
2122
|
"$as": renderAs,
|
|
2237
|
-
|
|
2123
|
+
href: url
|
|
2238
2124
|
}, {
|
|
2239
2125
|
children: content
|
|
2240
2126
|
})) : content
|
|
@@ -2516,6 +2402,65 @@ const DateField = forwardRef((_a, ref) => {
|
|
|
2516
2402
|
}));
|
|
2517
2403
|
});
|
|
2518
2404
|
|
|
2405
|
+
const localeLookup = {
|
|
2406
|
+
en: enGB,
|
|
2407
|
+
"en-US": enUS,
|
|
2408
|
+
"en-GB": enGB,
|
|
2409
|
+
da,
|
|
2410
|
+
de,
|
|
2411
|
+
cs,
|
|
2412
|
+
nl,
|
|
2413
|
+
fr,
|
|
2414
|
+
fi,
|
|
2415
|
+
hu,
|
|
2416
|
+
it,
|
|
2417
|
+
nb,
|
|
2418
|
+
pl,
|
|
2419
|
+
pt,
|
|
2420
|
+
ru,
|
|
2421
|
+
ro,
|
|
2422
|
+
es,
|
|
2423
|
+
sv,
|
|
2424
|
+
ja,
|
|
2425
|
+
th
|
|
2426
|
+
};
|
|
2427
|
+
/**
|
|
2428
|
+
* A helper function to get the matching Locale object for a given language.
|
|
2429
|
+
*
|
|
2430
|
+
* @param {string} language The language to match
|
|
2431
|
+
* @returns {Locale} The corresponding Locale object
|
|
2432
|
+
*/
|
|
2433
|
+
|
|
2434
|
+
const useLocale = language => {
|
|
2435
|
+
return localeLookup[language] || localeLookup.en;
|
|
2436
|
+
};
|
|
2437
|
+
|
|
2438
|
+
/**
|
|
2439
|
+
* The DayPicker component is used when the user needs to select a date.
|
|
2440
|
+
*
|
|
2441
|
+
* @param {DayPickerProps} props - The props for the DayPicker component
|
|
2442
|
+
* @returns {JSX.Element} DayPicker component
|
|
2443
|
+
*/
|
|
2444
|
+
|
|
2445
|
+
const DayPicker = _a => {
|
|
2446
|
+
var {
|
|
2447
|
+
onDaySelect,
|
|
2448
|
+
disabledDays,
|
|
2449
|
+
selectedDays,
|
|
2450
|
+
language
|
|
2451
|
+
} = _a,
|
|
2452
|
+
rest = __rest(_a, ["onDaySelect", "disabledDays", "selectedDays", "language"]);
|
|
2453
|
+
|
|
2454
|
+
const locale = useLocale(language);
|
|
2455
|
+
return jsx(DayPicker$1, Object.assign({
|
|
2456
|
+
onDayClick: onDaySelect,
|
|
2457
|
+
selected: selectedDays,
|
|
2458
|
+
locale: locale,
|
|
2459
|
+
disabled: disabledDays,
|
|
2460
|
+
className: "custom-day-picker"
|
|
2461
|
+
}, rest));
|
|
2462
|
+
};
|
|
2463
|
+
|
|
2519
2464
|
/**
|
|
2520
2465
|
* The DayPickerPopover component returns a button which when clicked shows the daypicker.
|
|
2521
2466
|
*
|
|
@@ -3170,100 +3115,7 @@ const Space = tw.div`
|
|
|
3170
3115
|
`;
|
|
3171
3116
|
|
|
3172
3117
|
/**
|
|
3173
|
-
*
|
|
3174
|
-
*
|
|
3175
|
-
* This could be to tell the state of an asset, or label a page as Beta.
|
|
3176
|
-
*
|
|
3177
|
-
* The tag is also used in multiselect components to show selected options.
|
|
3178
|
-
*
|
|
3179
|
-
* **Do:** Use short labels for easy scanning.
|
|
3180
|
-
*
|
|
3181
|
-
* @param {TagProps} props - The props for the tag component
|
|
3182
|
-
* @returns {JSX.Element} tag component
|
|
3183
|
-
*/
|
|
3184
|
-
|
|
3185
|
-
const Tag = React.forwardRef((_a, ref) => {
|
|
3186
|
-
var {
|
|
3187
|
-
className,
|
|
3188
|
-
dataTestId,
|
|
3189
|
-
children,
|
|
3190
|
-
size = "medium",
|
|
3191
|
-
onClose,
|
|
3192
|
-
color = "primary"
|
|
3193
|
-
} = _a;
|
|
3194
|
-
__rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
|
|
3195
|
-
|
|
3196
|
-
return jsxs(StyledText, Object.assign({
|
|
3197
|
-
className: className,
|
|
3198
|
-
"$size": size,
|
|
3199
|
-
"data-testid": `${dataTestId}-tag`,
|
|
3200
|
-
"$as": "span",
|
|
3201
|
-
"$color": color,
|
|
3202
|
-
"$withXIcon": !!onClose,
|
|
3203
|
-
ref: ref
|
|
3204
|
-
}, {
|
|
3205
|
-
children: [children, onClose && // a fix for multiselect deselecting tags working together with fade out animation
|
|
3206
|
-
jsx(IconContainer, Object.assign({
|
|
3207
|
-
onMouseDown: onClose
|
|
3208
|
-
}, {
|
|
3209
|
-
children: jsx(Icon$1, {
|
|
3210
|
-
name: "XCircleIcon",
|
|
3211
|
-
dataTestId: dataTestId + "Icon",
|
|
3212
|
-
type: "solid",
|
|
3213
|
-
style: {
|
|
3214
|
-
WebkitTransition: "-webkit-transform 0.150s"
|
|
3215
|
-
},
|
|
3216
|
-
className: size === "medium" ? tws`tu-tag__icon` : tws`tu-tag__icon tu-tag__icon--small`
|
|
3217
|
-
})
|
|
3218
|
-
}))]
|
|
3219
|
-
}));
|
|
3220
|
-
});
|
|
3221
|
-
|
|
3222
|
-
const getSizeModifierClass = () => ({
|
|
3223
|
-
$size,
|
|
3224
|
-
$withXIcon
|
|
3225
|
-
}) => {
|
|
3226
|
-
const tagSizeModifierClass = {
|
|
3227
|
-
medium: $withXIcon ? tws`tu-tag--with-icon ` : tws` `,
|
|
3228
|
-
small: $withXIcon ? tws`tu-tag--small tu-tag--with-icon` : tws`tu-tag--small`
|
|
3229
|
-
};
|
|
3230
|
-
return tagSizeModifierClass[$size];
|
|
3231
|
-
};
|
|
3232
|
-
|
|
3233
|
-
const getColorModifierClass = () => ({
|
|
3234
|
-
$color
|
|
3235
|
-
}) => {
|
|
3236
|
-
const colorClasses = {
|
|
3237
|
-
primary: tws`tu-tag--primary`,
|
|
3238
|
-
secondary: tws`tu-tag--secondary`,
|
|
3239
|
-
accent: tws`tu-tag--accent`,
|
|
3240
|
-
success: tws`tu-tag--success`,
|
|
3241
|
-
danger: tws`tu-tag--danger`,
|
|
3242
|
-
warning: tws`tu-tag--warning`,
|
|
3243
|
-
info: tws`tu-tag--info`,
|
|
3244
|
-
neutral: tws`tu-tag--neutral`,
|
|
3245
|
-
good: tws`tu-tag--good`,
|
|
3246
|
-
low: tws`tu-tag--low`,
|
|
3247
|
-
critical: tws`tu-tag--critical`,
|
|
3248
|
-
working: tws`tu-tag--working`,
|
|
3249
|
-
idle: tws`tu-tag--idle`,
|
|
3250
|
-
stopped: tws`tu-tag--stopped`,
|
|
3251
|
-
unknown: tws`tu-tag--unknown`
|
|
3252
|
-
};
|
|
3253
|
-
return colorClasses[$color];
|
|
3254
|
-
};
|
|
3255
|
-
|
|
3256
|
-
const StyledText = tw.span`
|
|
3257
|
-
tu-tag
|
|
3258
|
-
${getSizeModifierClass()}
|
|
3259
|
-
${getColorModifierClass()}
|
|
3260
|
-
`;
|
|
3261
|
-
const IconContainer = tw.div`
|
|
3262
|
-
tu-tag__icon-container
|
|
3263
|
-
`;
|
|
3264
|
-
|
|
3265
|
-
/**
|
|
3266
|
-
* The PageHeading component used on pages.
|
|
3118
|
+
* The PageHeading component is used on pages to set the Browser page title.
|
|
3267
3119
|
*
|
|
3268
3120
|
* @param {PageHeadingProps} props - The props for the PageHeading component
|
|
3269
3121
|
* @returns {JSX.Element} PageHeading component
|
|
@@ -3273,11 +3125,9 @@ const PageHeading = ({
|
|
|
3273
3125
|
title,
|
|
3274
3126
|
subtitle,
|
|
3275
3127
|
dataTestId,
|
|
3276
|
-
|
|
3128
|
+
addon
|
|
3277
3129
|
}) => {
|
|
3278
|
-
return jsxs(
|
|
3279
|
-
className: "w-full"
|
|
3280
|
-
}, {
|
|
3130
|
+
return jsxs(PageHeadingContainer, {
|
|
3281
3131
|
children: [jsx(Helmet, {
|
|
3282
3132
|
title: title
|
|
3283
3133
|
}), jsxs(StyledFlex, {
|
|
@@ -3286,11 +3136,7 @@ const PageHeading = ({
|
|
|
3286
3136
|
dataTestId: dataTestId
|
|
3287
3137
|
}, {
|
|
3288
3138
|
children: title
|
|
3289
|
-
})),
|
|
3290
|
-
color: "primary"
|
|
3291
|
-
}, {
|
|
3292
|
-
children: tag
|
|
3293
|
-
}))]
|
|
3139
|
+
})), addon]
|
|
3294
3140
|
}), subtitle && jsx(Heading, Object.assign({
|
|
3295
3141
|
variant: "subtitle",
|
|
3296
3142
|
subtle: true
|
|
@@ -3299,14 +3145,10 @@ const PageHeading = ({
|
|
|
3299
3145
|
})), jsx(Spacer, {
|
|
3300
3146
|
minHeight: "normal"
|
|
3301
3147
|
})]
|
|
3302
|
-
})
|
|
3148
|
+
});
|
|
3303
3149
|
};
|
|
3304
|
-
const
|
|
3305
|
-
|
|
3306
|
-
items-center
|
|
3307
|
-
flex-wrap-reverse
|
|
3308
|
-
gap-2
|
|
3309
|
-
`;
|
|
3150
|
+
const PageHeadingContainer = tw.div`tu-pageheading`;
|
|
3151
|
+
const StyledFlex = tw.div`tu-pageheading__flex`;
|
|
3310
3152
|
|
|
3311
3153
|
function useConfirmExit(confirmExit, when = true) {
|
|
3312
3154
|
const {
|
|
@@ -3611,6 +3453,99 @@ const SelectPrefix = tw.div`
|
|
|
3611
3453
|
tu-select__prefix
|
|
3612
3454
|
`;
|
|
3613
3455
|
|
|
3456
|
+
/**
|
|
3457
|
+
* The tag component is used to categorize elements in the ui.
|
|
3458
|
+
*
|
|
3459
|
+
* This could be to tell the state of an asset, or label a page as Beta.
|
|
3460
|
+
*
|
|
3461
|
+
* The tag is also used in multiselect components to show selected options.
|
|
3462
|
+
*
|
|
3463
|
+
* **Do:** Use short labels for easy scanning.
|
|
3464
|
+
*
|
|
3465
|
+
* @param {TagProps} props - The props for the tag component
|
|
3466
|
+
* @returns {JSX.Element} tag component
|
|
3467
|
+
*/
|
|
3468
|
+
|
|
3469
|
+
const Tag = React.forwardRef((_a, ref) => {
|
|
3470
|
+
var {
|
|
3471
|
+
className,
|
|
3472
|
+
dataTestId,
|
|
3473
|
+
children,
|
|
3474
|
+
size = "medium",
|
|
3475
|
+
onClose,
|
|
3476
|
+
color = "primary"
|
|
3477
|
+
} = _a;
|
|
3478
|
+
__rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
|
|
3479
|
+
|
|
3480
|
+
return jsxs(StyledText, Object.assign({
|
|
3481
|
+
className: className,
|
|
3482
|
+
"$size": size,
|
|
3483
|
+
"data-testid": `${dataTestId}-tag`,
|
|
3484
|
+
"$as": "span",
|
|
3485
|
+
"$color": color,
|
|
3486
|
+
"$withXIcon": !!onClose,
|
|
3487
|
+
ref: ref
|
|
3488
|
+
}, {
|
|
3489
|
+
children: [children, onClose && // a fix for multiselect deselecting tags working together with fade out animation
|
|
3490
|
+
jsx(IconContainer, Object.assign({
|
|
3491
|
+
onMouseDown: onClose
|
|
3492
|
+
}, {
|
|
3493
|
+
children: jsx(Icon$1, {
|
|
3494
|
+
name: "XCircleIcon",
|
|
3495
|
+
dataTestId: dataTestId + "Icon",
|
|
3496
|
+
type: "solid",
|
|
3497
|
+
style: {
|
|
3498
|
+
WebkitTransition: "-webkit-transform 0.150s"
|
|
3499
|
+
},
|
|
3500
|
+
className: size === "medium" ? tws`tu-tag__icon` : tws`tu-tag__icon tu-tag__icon--small`
|
|
3501
|
+
})
|
|
3502
|
+
}))]
|
|
3503
|
+
}));
|
|
3504
|
+
});
|
|
3505
|
+
|
|
3506
|
+
const getSizeModifierClass = () => ({
|
|
3507
|
+
$size,
|
|
3508
|
+
$withXIcon
|
|
3509
|
+
}) => {
|
|
3510
|
+
const tagSizeModifierClass = {
|
|
3511
|
+
medium: $withXIcon ? tws`tu-tag--with-icon ` : tws` `,
|
|
3512
|
+
small: $withXIcon ? tws`tu-tag--small tu-tag--with-icon` : tws`tu-tag--small`
|
|
3513
|
+
};
|
|
3514
|
+
return tagSizeModifierClass[$size];
|
|
3515
|
+
};
|
|
3516
|
+
|
|
3517
|
+
const getColorModifierClass = () => ({
|
|
3518
|
+
$color
|
|
3519
|
+
}) => {
|
|
3520
|
+
const colorClasses = {
|
|
3521
|
+
primary: tws`tu-tag--primary`,
|
|
3522
|
+
secondary: tws`tu-tag--secondary`,
|
|
3523
|
+
accent: tws`tu-tag--accent`,
|
|
3524
|
+
success: tws`tu-tag--success`,
|
|
3525
|
+
danger: tws`tu-tag--danger`,
|
|
3526
|
+
warning: tws`tu-tag--warning`,
|
|
3527
|
+
info: tws`tu-tag--info`,
|
|
3528
|
+
neutral: tws`tu-tag--neutral`,
|
|
3529
|
+
good: tws`tu-tag--good`,
|
|
3530
|
+
low: tws`tu-tag--low`,
|
|
3531
|
+
critical: tws`tu-tag--critical`,
|
|
3532
|
+
working: tws`tu-tag--working`,
|
|
3533
|
+
idle: tws`tu-tag--idle`,
|
|
3534
|
+
stopped: tws`tu-tag--stopped`,
|
|
3535
|
+
unknown: tws`tu-tag--unknown`
|
|
3536
|
+
};
|
|
3537
|
+
return colorClasses[$color];
|
|
3538
|
+
};
|
|
3539
|
+
|
|
3540
|
+
const StyledText = tw.span`
|
|
3541
|
+
tu-tag
|
|
3542
|
+
${getSizeModifierClass()}
|
|
3543
|
+
${getColorModifierClass()}
|
|
3544
|
+
`;
|
|
3545
|
+
const IconContainer = tw.div`
|
|
3546
|
+
tu-tag__icon-container
|
|
3547
|
+
`;
|
|
3548
|
+
|
|
3614
3549
|
/**
|
|
3615
3550
|
* A single select menu item is a basic wrapper around Menu item designed to be used as a single value render in Select list
|
|
3616
3551
|
*
|
|
@@ -3982,7 +3917,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
3982
3917
|
disabled: disabled,
|
|
3983
3918
|
dataTestId: props.label
|
|
3984
3919
|
})) : jsx(SingleSelectMenuItem, Object.assign({}, componentProps, {
|
|
3985
|
-
disabled: disabled,
|
|
3920
|
+
disabled: disabled || props.isDisabled,
|
|
3986
3921
|
dataTestId: props.label
|
|
3987
3922
|
}))
|
|
3988
3923
|
}));
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.147",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@trackunit/css-core": "0.0.51",
|
|
8
|
-
"@trackunit/tailwind-styled-components": "0.0.
|
|
8
|
+
"@trackunit/tailwind-styled-components": "0.0.45",
|
|
9
9
|
"react": "17.0.2",
|
|
10
10
|
"@trackunit/ui-design-tokens": "0.0.43",
|
|
11
11
|
"echarts-for-react": "^3.0.2",
|
|
12
12
|
"uuid": "^8.3.2",
|
|
13
13
|
"react-use": "^17.4.0",
|
|
14
|
-
"react-day-picker": "^8.3.0",
|
|
15
14
|
"date-fns": "^2.29.3",
|
|
15
|
+
"react-day-picker": "^8.3.0",
|
|
16
16
|
"@trackunit/ui-icons": "0.0.46",
|
|
17
17
|
"react-useportal": "1.0.16",
|
|
18
18
|
"react-helmet": "^6.1.0",
|