@trackunit/react-components 0.0.100 → 0.0.103

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.
@@ -61,8 +61,11 @@ export interface ChartProps extends CommonProps {
61
61
  }
62
62
  /**
63
63
  * The Chart component is a wrapper component for ECharts.
64
+ *
64
65
  * Handles events and click functionality.
65
66
  *
67
+ * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
68
+ *
66
69
  * @param {ChartProps} props - The props for the Chart component
67
70
  * @returns {JSX.Element} Chart component
68
71
  */
@@ -13,7 +13,7 @@ export interface CopyableTextProps extends CommonProps {
13
13
  alternativeText?: string;
14
14
  }
15
15
  /**
16
- * The CopyableText component is used where the user should have easy access to copy some information.
16
+ * The CopyableText component is used where the user should have easy access to copy information.
17
17
  *
18
18
  * @param {CopyableTextProps} props - The props for the CopyableText component
19
19
  * @returns {JSX.Element} CopyableText component
@@ -1,30 +1,19 @@
1
1
  /// <reference types="react" />
2
- import { Matcher } from "react-day-picker";
3
- import { BaseInputProps } from "../BaseInput";
4
- export interface DateFieldProps extends Pick<BaseInputProps, "placeholder" | "id" | "dataTestId" | "onChange" | "readOnly"> {
2
+ import { DateInputProps } from "../DateInput/DateInput";
3
+ import { FormGroupProps } from "../FormGroup/FormGroup";
4
+ declare type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
5
+ export interface DateFieldProps extends DateInputProps, FormGroupExposedProps {
5
6
  /**
6
- * A text label to be displayed next to the indicator
7
+ * If a value is set, the field is rendered in its invalid state.
7
8
  */
8
- label?: string;
9
- /**
10
- * A text to be displayed under the input with a short description of field purpose
11
- */
12
- description?: string;
13
- /**
14
- * A default value to be displayed by a input field
15
- */
16
- defaultValue?: string;
17
- /**
18
- * A flag that can be used to disable the input, default value is false
19
- */
20
- disabled?: boolean;
21
- /**
22
- * Specification of dates not allowed to be selected - i the form of react-day-picker matcher
23
- */
24
- disabledDays?: Matcher | Matcher[] | undefined;
25
- /**
26
- * A flag that can be set to true to disallow the user to deselect a date. (if false the user can click the selected date to deselect)
27
- */
28
- preventDeselect?: boolean;
9
+ errorMessage?: string;
29
10
  }
11
+ /**
12
+ * The date field component is used for entering date values.
13
+ *
14
+ * _**Do use**_ the DateField for date input.
15
+ *
16
+ * _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
17
+ */
30
18
  export declare const DateField: import("react").ForwardRefExoticComponent<DateFieldProps & import("react").RefAttributes<HTMLInputElement>>;
19
+ export {};
@@ -0,0 +1,29 @@
1
+ /// <reference types="react" />
2
+ import { Matcher } from "react-day-picker";
3
+ import { BaseInputProps } from "../BaseInput";
4
+ declare type BaseInputExposedProps = Omit<BaseInputProps, "defaultValue" | "onChange">;
5
+ export interface DateInputProps extends BaseInputExposedProps {
6
+ /**
7
+ * A default value to be displayed by a input field
8
+ */
9
+ defaultValue?: Date;
10
+ /**
11
+ * Specification of dates not allowed to be selected - i the form of react-day-picker matcher
12
+ */
13
+ disabledDays?: Matcher | Matcher[] | undefined;
14
+ /**
15
+ * A flag that can be set to true to disallow the user to deselect a date. (if false the user can click the selected date to deselect)
16
+ */
17
+ preventDeselect?: boolean;
18
+ /**
19
+ * onChange function returning the date instead of input event
20
+ */
21
+ onChange?: (date: Date) => void;
22
+ }
23
+ /**
24
+ * A wrapper around BaseInput with a pop-up day picker.
25
+ *
26
+ * NOTE: If shown with a label, please use the `DateField` component instead.
27
+ */
28
+ export declare const DateInput: import("react").ForwardRefExoticComponent<DateInputProps & import("react").RefAttributes<HTMLInputElement>>;
29
+ export {};
@@ -1,21 +1,20 @@
1
1
  /// <reference types="react" />
2
2
  import { CommonProps } from "../../common";
3
- interface SpacerProps extends CommonProps {
3
+ export interface SpacerProps extends CommonProps {
4
4
  /**
5
5
  * The minimum height of the spacer. Defaults to 1px.
6
6
  * Possible values are "normal"(8px), and "large" (32px).
7
7
  */
8
- minHeight?: string;
8
+ minHeight?: "normal" | "large";
9
9
  /**
10
10
  * The border of the spacer.
11
11
  */
12
12
  border?: boolean;
13
13
  }
14
14
  /**
15
- * The Spacer component is used for adding a bit of space.
15
+ * The Spacer component is used for adding a bit of space in the ui.
16
16
  *
17
17
  * @param {SpacerProps} props - The props for the Spacer component
18
18
  * @returns {JSX.Element} Spacer component
19
19
  */
20
20
  export declare const Spacer: ({ minHeight, border, dataTestId }: SpacerProps) => JSX.Element;
21
- export {};
@@ -25,11 +25,13 @@ export interface TagProps extends CommonProps {
25
25
  size?: TagSize;
26
26
  }
27
27
  /**
28
- * Tags allow users to enter information and filter content.
28
+ * The tag component is used to categorize elements in the ui.
29
29
  *
30
- * Multiple or single tags can be used to categorise items.
30
+ * This could be to tell the state of an asset, or label a page as Beta.
31
31
  *
32
- * Use short labels for easy scanning. Use two words only if necessary to describe the status and differentiate it from other tags.
32
+ * The tag is also used in multiselect components to show selected options.
33
+ *
34
+ * **Do:** Use short labels for easy scanning.
33
35
  *
34
36
  * @param {TagProps} props - The props for the tag component
35
37
  * @returns {JSX.Element} tag component
@@ -47,7 +47,11 @@ export interface TextProps extends CommonProps {
47
47
  underline?: boolean;
48
48
  }
49
49
  /**
50
- * The Text component.
50
+ * The Text component is used to apply Trackunit default typography styles to text.
51
+ *
52
+ * ### When to use
53
+ *
54
+ * Use Text when you want to show a text section, use Heading if you want to show a heading.
51
55
  *
52
56
  * @param {TextProps} props - The props for the Text component
53
57
  * @returns {JSX.Element} Text component
@@ -7,7 +7,8 @@ export * from "./Chart";
7
7
  export * from "./Checkbox";
8
8
  export * from "./Collapse";
9
9
  export * from "./CopyableText";
10
- export * from "./DateField";
10
+ export * from "./DateField/DateField";
11
+ export * from "./DateInput/DateInput";
11
12
  export * from "./DayPicker";
12
13
  export * from "./FormGroup/FormGroup";
13
14
  export * from "./Heading";
package/index.js CHANGED
@@ -17,7 +17,7 @@ import ReactAsyncCreatableSelect from 'react-select/async-creatable';
17
17
  import ReactCreatableSelect from 'react-select/creatable';
18
18
  import ReactSelect from 'react-select';
19
19
  import ReactAsyncSelect from 'react-select/async';
20
- import ReactMoment from 'react-moment';
20
+ import { format, formatDistance } from 'date-fns';
21
21
 
22
22
  const docs = {
23
23
  source: {
@@ -494,7 +494,11 @@ const CustomIcon = tw(Icon$1)`
494
494
  `;
495
495
 
496
496
  /**
497
- * The Text component.
497
+ * The Text component is used to apply Trackunit default typography styles to text.
498
+ *
499
+ * ### When to use
500
+ *
501
+ * Use Text when you want to show a text section, use Heading if you want to show a heading.
498
502
  *
499
503
  * @param {TextProps} props - The props for the Text component
500
504
  * @returns {JSX.Element} Text component
@@ -796,7 +800,7 @@ const IconContainer$1 = tw.div`
796
800
 
797
801
  const Badge = _a => {
798
802
  var {
799
- color = "neutral",
803
+ color = "danger",
800
804
  subtle = false,
801
805
  className,
802
806
  count,
@@ -1288,8 +1292,11 @@ const HeadingContainer = tw.div`
1288
1292
 
1289
1293
  /**
1290
1294
  * The Chart component is a wrapper component for ECharts.
1295
+ *
1291
1296
  * Handles events and click functionality.
1292
1297
  *
1298
+ * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
1299
+ *
1293
1300
  * @param {ChartProps} props - The props for the Chart component
1294
1301
  * @returns {JSX.Element} Chart component
1295
1302
  */
@@ -1686,7 +1693,7 @@ const StyledCollapsible = tw.div`
1686
1693
  `;
1687
1694
 
1688
1695
  /**
1689
- * The CopyableText component is used where the user should have easy access to copy some information.
1696
+ * The CopyableText component is used where the user should have easy access to copy information.
1690
1697
  *
1691
1698
  * @param {CopyableTextProps} props - The props for the CopyableText component
1692
1699
  * @returns {JSX.Element} CopyableText component
@@ -1719,19 +1726,8 @@ const CopyableText = ({
1719
1726
  }));
1720
1727
  };
1721
1728
  const StyledCopyableText = tw.span`
1722
- py-1
1723
- px-2
1724
- border
1725
- border-dashed
1726
- border-neutral-600
1727
- rounded
1728
- cursor-pointer
1729
- inline
1730
- transition-all
1731
- ease-in-out
1732
- leading-7
1733
- break-words
1734
- ${p => p.$animating ? tws`animate-copy` : null}`;
1729
+ tu-copyable-text
1730
+ ${p => p.$animating ? tws`tu-copyable-text--animating` : null}`;
1735
1731
 
1736
1732
  const localeLookup = {
1737
1733
  en: enGB,
@@ -1992,23 +1988,28 @@ const StyledCardBody = tw(CardBody)`
1992
1988
  max-h-full
1993
1989
  `;
1994
1990
 
1995
- const DateField = forwardRef(({
1996
- defaultValue,
1997
- onChange,
1998
- disabled = false,
1999
- readOnly = false,
2000
- id,
2001
- dataTestId,
2002
- placeholder,
2003
- disabledDays,
2004
- preventDeselect = false
2005
- }, ref) => {
2006
- const [selectedDay, setSelectedDay] = useState(defaultValue ? new Date(defaultValue) : undefined);
1991
+ /**
1992
+ * A wrapper around BaseInput with a pop-up day picker.
1993
+ *
1994
+ * NOTE: If shown with a label, please use the `DateField` component instead.
1995
+ */
1996
+
1997
+ const DateInput = forwardRef((_a, ref) => {
1998
+ var {
1999
+ defaultValue,
2000
+ disabledDays,
2001
+ disabled,
2002
+ preventDeselect,
2003
+ onChange
2004
+ } = _a,
2005
+ rest = __rest(_a, ["defaultValue", "disabledDays", "disabled", "preventDeselect", "onChange"]);
2006
+
2007
+ const [selectedDay, setSelectedDay] = useState(defaultValue);
2007
2008
  const onChangeHandler = useCallback(value => {
2008
2009
  const newValue = (value === null || value === void 0 ? void 0 : value.toLocaleDateString()) === (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) && !preventDeselect ? undefined : value;
2009
2010
  setSelectedDay(newValue);
2010
2011
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
2011
- }, [setSelectedDay, onChange, selectedDay, preventDeselect]);
2012
+ }, [selectedDay, preventDeselect, onChange]);
2012
2013
  const target = useRef(null);
2013
2014
  const popover = useRef(null);
2014
2015
  const {
@@ -2023,15 +2024,11 @@ const DateField = forwardRef(({
2023
2024
  placement: "bottom"
2024
2025
  });
2025
2026
  return jsxs(Fragment, {
2026
- children: [jsx(BaseInput, {
2027
- placeholder: placeholder,
2028
- value: (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) || "",
2029
- onChange: () => {},
2030
- disabled: disabled,
2031
- readOnly: readOnly,
2032
- dataTestId: dataTestId,
2033
- id: id,
2027
+ children: [jsx(BaseInput, Object.assign({
2034
2028
  ref: ref,
2029
+ value: (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) || "",
2030
+ onChange: () => {}
2031
+ }, rest, {
2035
2032
  suffix: jsx(Icon$1, {
2036
2033
  dataTestId: "calendar",
2037
2034
  name: "CalendarIcon",
@@ -2050,8 +2047,9 @@ const DateField = forwardRef(({
2050
2047
  size: "small"
2051
2048
  })
2052
2049
  }))
2053
- })
2054
- }), jsx(AnimatedPopover, Object.assign({
2050
+ }),
2051
+ onClick: e => e.preventDefault()
2052
+ })), jsx(AnimatedPopover, Object.assign({
2055
2053
  ref: popoverRef,
2056
2054
  onRequestClose: () => {
2057
2055
  var _a;
@@ -2075,6 +2073,34 @@ const RemoveValueContainer = tw.div`
2075
2073
  tu-date__remove
2076
2074
  `;
2077
2075
 
2076
+ /**
2077
+ * The Label component is used for labels for input fields.
2078
+ * This component is **not used directly**, but is part of the FormGroup and Field components.
2079
+ *
2080
+ * @param {LabelProps} props - The props for the Label component
2081
+ * @returns {JSX.Element} Label component
2082
+ */
2083
+
2084
+ const Label$5 = ({
2085
+ id,
2086
+ htmlFor,
2087
+ children,
2088
+ className,
2089
+ dataTestId
2090
+ }) => {
2091
+ return jsx(Root$2, Object.assign({
2092
+ className: className,
2093
+ id: id,
2094
+ "data-testid": dataTestId,
2095
+ htmlFor: htmlFor
2096
+ }, {
2097
+ children: children
2098
+ }));
2099
+ };
2100
+ const Root$2 = tw.label`
2101
+ tu-label
2102
+ `;
2103
+
2078
2104
  /**
2079
2105
  * The PopoverListItem component.
2080
2106
  *
@@ -2190,143 +2216,6 @@ const StyledText$1 = tw(Text)`
2190
2216
  text-neutral-500
2191
2217
  `;
2192
2218
 
2193
- /**
2194
- * The DayPickerPopover component returns a button which when clicked shows the daypicker.
2195
- *
2196
- * @param {DayPickerPopoverProps} props - The props for the DayPickerPopover component
2197
- * @returns {JSX.Element} DayPickerPopover component
2198
- */
2199
-
2200
- const DayPickerPopover = ({
2201
- disabledDays,
2202
- className,
2203
- selectedDay,
2204
- onDaySelect,
2205
- intent = "secondary",
2206
- placement = "bottom",
2207
- size = "small",
2208
- buttonContent,
2209
- language
2210
- }) => {
2211
- const target = useRef(null);
2212
- const popover = useRef(null);
2213
- const {
2214
- popoverRef,
2215
- targetRef,
2216
- onShow,
2217
- onHide,
2218
- popoverProps
2219
- } = usePopover({
2220
- targetRef: target,
2221
- popoverRef: popover,
2222
- placement: placement
2223
- });
2224
- return jsxs(Fragment$1, {
2225
- children: [jsx(Button, Object.assign({
2226
- intent: intent,
2227
- size: size,
2228
- className: className,
2229
- prefix: jsx(Icon$1, {
2230
- name: "CalendarIcon",
2231
- size: "small"
2232
- }),
2233
- ref: targetRef,
2234
- onClick: onShow
2235
- }, {
2236
- children: buttonContent
2237
- })), jsx(AnimatedPopover, Object.assign({
2238
- ref: popoverRef,
2239
- onRequestClose: () => {
2240
- var _a;
2241
-
2242
- onHide();
2243
- (_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
2244
- }
2245
- }, popoverProps, {
2246
- children: jsx(PopoverList, {
2247
- children: jsx(DayPicker, {
2248
- disabledDays: disabledDays,
2249
- onDaySelect: onDaySelect,
2250
- selectedDays: selectedDay,
2251
- language: language
2252
- })
2253
- })
2254
- }))]
2255
- });
2256
- };
2257
-
2258
- /**
2259
- * The DayRangePicker component should be used when the user needs to select a range of dates.
2260
- *
2261
- * @param {DayRangePickerProps} props - The props for the DayRangePicker component
2262
- * @returns {JSX.Element} DayRangePicker component
2263
- */
2264
-
2265
- const DayRangePicker = ({
2266
- onRangeSelect,
2267
- selectedDays,
2268
- disabledDays,
2269
- dataTestId,
2270
- language
2271
- }) => {
2272
- const locale = useLocale(language);
2273
- const onSelect = useCallback(range => {
2274
- if (onRangeSelect && range === undefined) {
2275
- onRangeSelect(undefined);
2276
- }
2277
-
2278
- if (onRangeSelect && range) {
2279
- const from = range.from;
2280
- const to = range.to ? range.to : range.from;
2281
- onRangeSelect({
2282
- from,
2283
- to
2284
- });
2285
- }
2286
- }, [onRangeSelect]);
2287
- return jsx("div", Object.assign({
2288
- "data-testid": dataTestId
2289
- }, {
2290
- children: jsx(DayPicker$1, {
2291
- mode: "range",
2292
- onSelect: onSelect,
2293
- selected: selectedDays,
2294
- defaultMonth: selectedDays && selectedDays.from,
2295
- locale: locale,
2296
- disabled: disabledDays,
2297
- className: "custom-day-picker range-picker"
2298
- })
2299
- }));
2300
- };
2301
-
2302
- /**
2303
- * The Label component is used for labels for input fields.
2304
- * This component is **not used directly**, but is part of the FormGroup and Field components.
2305
- *
2306
- * @param {LabelProps} props - The props for the Label component
2307
- * @returns {JSX.Element} Label component
2308
- */
2309
-
2310
- const Label$5 = ({
2311
- id,
2312
- htmlFor,
2313
- children,
2314
- className,
2315
- dataTestId
2316
- }) => {
2317
- return jsx(Root$2, Object.assign({
2318
- className: className,
2319
- id: id,
2320
- "data-testid": dataTestId,
2321
- htmlFor: htmlFor
2322
- }, {
2323
- children: children
2324
- }));
2325
- };
2326
- const Root$2 = tw.label`
2327
- tu-label
2328
- `;
2329
-
2330
2219
  /**
2331
2220
  * The Tooltip component.
2332
2221
  *
@@ -2502,6 +2391,157 @@ const HelpAddon = tw.span`
2502
2391
  tu-form-group__help-addon
2503
2392
  `;
2504
2393
 
2394
+ /**
2395
+ * The date field component is used for entering date values.
2396
+ *
2397
+ * _**Do use**_ the DateField for date input.
2398
+ *
2399
+ * _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
2400
+ */
2401
+
2402
+ const DateField = forwardRef((_a, ref) => {
2403
+ var {
2404
+ label,
2405
+ tip,
2406
+ helpText,
2407
+ errorMessage,
2408
+ helpAddon,
2409
+ isInvalid,
2410
+ className,
2411
+ defaultValue,
2412
+ dataTestId
2413
+ } = _a,
2414
+ rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
2415
+
2416
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2417
+ return jsx(FormGroup, Object.assign({
2418
+ label: label,
2419
+ tip: tip,
2420
+ isInvalid: renderAsInvalid,
2421
+ helpText: errorMessage || helpText,
2422
+ helpAddon: helpAddon,
2423
+ dataTestId: `${dataTestId}-FormGroup`
2424
+ }, {
2425
+ children: jsx(DateInput, Object.assign({
2426
+ ref: ref,
2427
+ defaultValue: defaultValue,
2428
+ isInvalid: renderAsInvalid
2429
+ }, rest, {
2430
+ className: className,
2431
+ dataTestId: dataTestId
2432
+ }))
2433
+ }));
2434
+ });
2435
+
2436
+ /**
2437
+ * The DayPickerPopover component returns a button which when clicked shows the daypicker.
2438
+ *
2439
+ * @param {DayPickerPopoverProps} props - The props for the DayPickerPopover component
2440
+ * @returns {JSX.Element} DayPickerPopover component
2441
+ */
2442
+
2443
+ const DayPickerPopover = ({
2444
+ disabledDays,
2445
+ className,
2446
+ selectedDay,
2447
+ onDaySelect,
2448
+ intent = "secondary",
2449
+ placement = "bottom",
2450
+ size = "small",
2451
+ buttonContent,
2452
+ language
2453
+ }) => {
2454
+ const target = useRef(null);
2455
+ const popover = useRef(null);
2456
+ const {
2457
+ popoverRef,
2458
+ targetRef,
2459
+ onShow,
2460
+ onHide,
2461
+ popoverProps
2462
+ } = usePopover({
2463
+ targetRef: target,
2464
+ popoverRef: popover,
2465
+ placement: placement
2466
+ });
2467
+ return jsxs(Fragment$1, {
2468
+ children: [jsx(Button, Object.assign({
2469
+ intent: intent,
2470
+ size: size,
2471
+ className: className,
2472
+ prefix: jsx(Icon$1, {
2473
+ name: "CalendarIcon",
2474
+ size: "small"
2475
+ }),
2476
+ ref: targetRef,
2477
+ onClick: onShow
2478
+ }, {
2479
+ children: buttonContent
2480
+ })), jsx(AnimatedPopover, Object.assign({
2481
+ ref: popoverRef,
2482
+ onRequestClose: () => {
2483
+ var _a;
2484
+
2485
+ onHide();
2486
+ (_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
2487
+ }
2488
+ }, popoverProps, {
2489
+ children: jsx(PopoverList, {
2490
+ children: jsx(DayPicker, {
2491
+ disabledDays: disabledDays,
2492
+ onDaySelect: onDaySelect,
2493
+ selectedDays: selectedDay,
2494
+ language: language
2495
+ })
2496
+ })
2497
+ }))]
2498
+ });
2499
+ };
2500
+
2501
+ /**
2502
+ * The DayRangePicker component should be used when the user needs to select a range of dates.
2503
+ *
2504
+ * @param {DayRangePickerProps} props - The props for the DayRangePicker component
2505
+ * @returns {JSX.Element} DayRangePicker component
2506
+ */
2507
+
2508
+ const DayRangePicker = ({
2509
+ onRangeSelect,
2510
+ selectedDays,
2511
+ disabledDays,
2512
+ dataTestId,
2513
+ language
2514
+ }) => {
2515
+ const locale = useLocale(language);
2516
+ const onSelect = useCallback(range => {
2517
+ if (onRangeSelect && range === undefined) {
2518
+ onRangeSelect(undefined);
2519
+ }
2520
+
2521
+ if (onRangeSelect && range) {
2522
+ const from = range.from;
2523
+ const to = range.to ? range.to : range.from;
2524
+ onRangeSelect({
2525
+ from,
2526
+ to
2527
+ });
2528
+ }
2529
+ }, [onRangeSelect]);
2530
+ return jsx("div", Object.assign({
2531
+ "data-testid": dataTestId
2532
+ }, {
2533
+ children: jsx(DayPicker$1, {
2534
+ mode: "range",
2535
+ onSelect: onSelect,
2536
+ selected: selectedDays,
2537
+ defaultMonth: selectedDays && selectedDays.from,
2538
+ locale: locale,
2539
+ disabled: disabledDays,
2540
+ className: "custom-day-picker range-picker"
2541
+ })
2542
+ }));
2543
+ };
2544
+
2505
2545
  /**
2506
2546
  * Indicators are non-interactive elements that communicate essential aspects of the state of an asset.
2507
2547
  *
@@ -3053,34 +3093,15 @@ const NumberField = forwardRef((_a, ref) => {
3053
3093
  }));
3054
3094
  });
3055
3095
 
3056
- const GetSpacerHeight = () => ({
3057
- minHeight
3058
- }) => {
3059
- if (!minHeight) {
3060
- return "";
3061
- }
3062
-
3063
- switch (minHeight) {
3064
- case "normal":
3065
- return tws`min-h-[8px]`;
3066
-
3067
- case "large":
3068
- return tws`min-h-[32px]`;
3069
-
3070
- default:
3071
- return "";
3072
- }
3073
- };
3074
3096
  /**
3075
- * The Spacer component is used for adding a bit of space.
3097
+ * The Spacer component is used for adding a bit of space in the ui.
3076
3098
  *
3077
3099
  * @param {SpacerProps} props - The props for the Spacer component
3078
3100
  * @returns {JSX.Element} Spacer component
3079
3101
  */
3080
3102
 
3081
-
3082
3103
  const Spacer = ({
3083
- minHeight = "",
3104
+ minHeight,
3084
3105
  border,
3085
3106
  dataTestId
3086
3107
  }) => {
@@ -3090,17 +3111,35 @@ const Spacer = ({
3090
3111
  border: border
3091
3112
  });
3092
3113
  };
3114
+
3115
+ const GetSpacerHeight = () => ({
3116
+ minHeight
3117
+ }) => {
3118
+ switch (minHeight) {
3119
+ case "normal":
3120
+ return tws`tu-spacer--normal`;
3121
+
3122
+ case "large":
3123
+ return tws`tu-spacer--large`;
3124
+
3125
+ default:
3126
+ return "";
3127
+ }
3128
+ };
3129
+
3093
3130
  const Space = tw.div`
3094
- ${p => `${p.border ? `tu-spacer--border` : null}`}
3095
- ${GetSpacerHeight()}
3131
+ ${p => `${p.border ? `tu-spacer--border` : null}`}
3132
+ ${GetSpacerHeight()}
3096
3133
  `;
3097
3134
 
3098
3135
  /**
3099
- * Tags allow users to enter information and filter content.
3136
+ * The tag component is used to categorize elements in the ui.
3100
3137
  *
3101
- * Multiple or single tags can be used to categorise items.
3138
+ * This could be to tell the state of an asset, or label a page as Beta.
3102
3139
  *
3103
- * Use short labels for easy scanning. Use two words only if necessary to describe the status and differentiate it from other tags.
3140
+ * The tag is also used in multiselect components to show selected options.
3141
+ *
3142
+ * **Do:** Use short labels for easy scanning.
3104
3143
  *
3105
3144
  * @param {TagProps} props - The props for the tag component
3106
3145
  * @returns {JSX.Element} tag component
@@ -3729,12 +3768,12 @@ const SkeletonLines = memo(({
3729
3768
  for (let i = 0; i < lines; i++) {
3730
3769
  skeletonLines.push(jsx(SkeletonLine, Object.assign({
3731
3770
  "data-testid": dataTestId,
3732
- margin: margin,
3733
3771
  "data-type": "loading-skeleton-line",
3734
3772
  className: className,
3735
3773
  style: {
3736
3774
  height: getHeight(i),
3737
- width: getWidth(i)
3775
+ width: getWidth(i),
3776
+ margin: margin
3738
3777
  }
3739
3778
  }, {
3740
3779
  children: "\u00A0"
@@ -4010,12 +4049,9 @@ const TimelineElement = ({
4010
4049
  size: "large"
4011
4050
  })
4012
4051
  }),
4013
- header = jsx(ReactMoment, Object.assign({
4014
- format: "LLL",
4015
- fromNow: true
4016
- }, {
4017
- children: date
4018
- }))
4052
+ header = `${format(date, "MMM d, yyyy")} (${formatDistance(date, new Date(), {
4053
+ addSuffix: true
4054
+ })})`
4019
4055
  }) => {
4020
4056
  var _a;
4021
4057
 
@@ -4518,4 +4554,4 @@ const Layout = tw.div`
4518
4554
  tu-layout-TwoColumnLayout
4519
4555
  `;
4520
4556
 
4521
- export { Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$5 as Label, LegendItem, MenuButton, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, intentColors, useContainerProps, useCustomComponents, useCustomStyles, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
4557
+ export { Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$5 as Label, LegendItem, MenuButton, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, intentColors, useContainerProps, useCustomComponents, useCustomStyles, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.100",
3
+ "version": "0.0.103",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "UNLICENSED",
6
6
  "dependencies": {
@@ -20,8 +20,7 @@
20
20
  "@popperjs/core": "^2.11.4",
21
21
  "history": "^5.3.0",
22
22
  "react-router-dom": "^6.2.2",
23
- "react-select": "^5.4.0",
24
- "react-moment": "^1.1.2"
23
+ "react-select": "^5.4.0"
25
24
  },
26
25
  "module": "./index.js",
27
26
  "main": "./index.js",
@@ -1 +0,0 @@
1
- export * from "./DateField";