@trackunit/react-components 0.0.99 → 0.0.102

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.js CHANGED
@@ -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,
@@ -947,8 +951,8 @@ const InputContainer = tw.div`
947
951
 
948
952
  const ROLE_CARD = "region";
949
953
  /**
950
- * The Card component is a container for ui elements.
951
- * Is also used for modals etc.
954
+ * The Card component is a container for ui elements, and is the main component of the modal.
955
+ * To get the most out of the Card use it in combination with the CardHeader, CardBody and CardFooter.
952
956
  *
953
957
  * @param {CardProps} props - The props for the Card component
954
958
  * @returns {JSX.Element} Card component
@@ -1090,7 +1094,7 @@ ${DensityFinder}
1090
1094
  *
1091
1095
  * @summary For applying padding and gap to a Card.
1092
1096
  * @description The padding must live here, and not on the Card itself, as to not inset the scrollbar in case of overflow
1093
- * @param {CardContentProps} props - The props for the CardBody component
1097
+ * @param {CardBodyProps} props - The props for the CardBody component
1094
1098
  * @returns {JSX.Element} CardBody component
1095
1099
  */
1096
1100
 
@@ -1154,20 +1158,16 @@ const CardFooter = ({
1154
1158
  className: className,
1155
1159
  "$density": density
1156
1160
  }, {
1157
- children: jsx(StyledFlex$1, {
1161
+ children: jsx(Body, {
1158
1162
  children: children
1159
1163
  })
1160
1164
  }));
1161
1165
  };
1162
1166
  const TopBorderedDensityContainer = tw(DensityContainer)`
1163
- border-t-2
1164
- border-neutral-200
1167
+ tu-card__footer-density-container
1165
1168
  `;
1166
- const StyledFlex$1 = tw.div`
1167
- flex
1168
- gap-2
1169
- flex-wrap
1170
- justify-end
1169
+ const Body = tw.div`
1170
+ tu-card__footer
1171
1171
  `;
1172
1172
 
1173
1173
  /**
@@ -1281,23 +1281,22 @@ const CardHeader = ({
1281
1281
  }));
1282
1282
  };
1283
1283
  const BottomBorderedDensityContainer = tw(DensityContainer)`
1284
- border-b-2
1285
- border-neutral-200`;
1284
+ tu-card__header-density-container
1285
+ `;
1286
1286
  const Container$6 = tw.div`
1287
- flex
1288
- justify-between
1289
- items-start
1287
+ tu-card__header
1290
1288
  `;
1291
1289
  const HeadingContainer = tw.div`
1292
- flex
1293
- items-center
1294
- gap-4
1290
+ tu-card__header-heading-container
1295
1291
  `;
1296
1292
 
1297
1293
  /**
1298
1294
  * The Chart component is a wrapper component for ECharts.
1295
+ *
1299
1296
  * Handles events and click functionality.
1300
1297
  *
1298
+ * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
1299
+ *
1301
1300
  * @param {ChartProps} props - The props for the Chart component
1302
1301
  * @returns {JSX.Element} Chart component
1303
1302
  */
@@ -1694,7 +1693,7 @@ const StyledCollapsible = tw.div`
1694
1693
  `;
1695
1694
 
1696
1695
  /**
1697
- * 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.
1698
1697
  *
1699
1698
  * @param {CopyableTextProps} props - The props for the CopyableText component
1700
1699
  * @returns {JSX.Element} CopyableText component
@@ -1727,19 +1726,8 @@ const CopyableText = ({
1727
1726
  }));
1728
1727
  };
1729
1728
  const StyledCopyableText = tw.span`
1730
- py-1
1731
- px-2
1732
- border
1733
- border-dashed
1734
- border-neutral-600
1735
- rounded
1736
- cursor-pointer
1737
- inline
1738
- transition-all
1739
- ease-in-out
1740
- leading-7
1741
- break-words
1742
- ${p => p.$animating ? tws`animate-copy` : null}`;
1729
+ tu-copyable-text
1730
+ ${p => p.$animating ? tws`tu-copyable-text--animating` : null}`;
1743
1731
 
1744
1732
  const localeLookup = {
1745
1733
  en: enGB,
@@ -2000,23 +1988,28 @@ const StyledCardBody = tw(CardBody)`
2000
1988
  max-h-full
2001
1989
  `;
2002
1990
 
2003
- const DateField = forwardRef(({
2004
- defaultValue,
2005
- onChange,
2006
- disabled = false,
2007
- readOnly = false,
2008
- id,
2009
- dataTestId,
2010
- placeholder,
2011
- disabledDays,
2012
- preventDeselect = false
2013
- }, ref) => {
2014
- 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);
2015
2008
  const onChangeHandler = useCallback(value => {
2016
2009
  const newValue = (value === null || value === void 0 ? void 0 : value.toLocaleDateString()) === (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) && !preventDeselect ? undefined : value;
2017
2010
  setSelectedDay(newValue);
2018
2011
  onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
2019
- }, [setSelectedDay, onChange, selectedDay, preventDeselect]);
2012
+ }, [selectedDay, preventDeselect, onChange]);
2020
2013
  const target = useRef(null);
2021
2014
  const popover = useRef(null);
2022
2015
  const {
@@ -2031,15 +2024,11 @@ const DateField = forwardRef(({
2031
2024
  placement: "bottom"
2032
2025
  });
2033
2026
  return jsxs(Fragment, {
2034
- children: [jsx(BaseInput, {
2035
- placeholder: placeholder,
2036
- value: (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) || "",
2037
- onChange: () => {},
2038
- disabled: disabled,
2039
- readOnly: readOnly,
2040
- dataTestId: dataTestId,
2041
- id: id,
2027
+ children: [jsx(BaseInput, Object.assign({
2042
2028
  ref: ref,
2029
+ value: (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) || "",
2030
+ onChange: () => {}
2031
+ }, rest, {
2043
2032
  suffix: jsx(Icon$1, {
2044
2033
  dataTestId: "calendar",
2045
2034
  name: "CalendarIcon",
@@ -2058,8 +2047,9 @@ const DateField = forwardRef(({
2058
2047
  size: "small"
2059
2048
  })
2060
2049
  }))
2061
- })
2062
- }), jsx(AnimatedPopover, Object.assign({
2050
+ }),
2051
+ onClick: e => e.preventDefault()
2052
+ })), jsx(AnimatedPopover, Object.assign({
2063
2053
  ref: popoverRef,
2064
2054
  onRequestClose: () => {
2065
2055
  var _a;
@@ -2083,6 +2073,34 @@ const RemoveValueContainer = tw.div`
2083
2073
  tu-date__remove
2084
2074
  `;
2085
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
+
2086
2104
  /**
2087
2105
  * The PopoverListItem component.
2088
2106
  *
@@ -2198,143 +2216,6 @@ const StyledText$1 = tw(Text)`
2198
2216
  text-neutral-500
2199
2217
  `;
2200
2218
 
2201
- /**
2202
- * The DayPickerPopover component returns a button which when clicked shows the daypicker.
2203
- *
2204
- * @param {DayPickerPopoverProps} props - The props for the DayPickerPopover component
2205
- * @returns {JSX.Element} DayPickerPopover component
2206
- */
2207
-
2208
- const DayPickerPopover = ({
2209
- disabledDays,
2210
- className,
2211
- selectedDay,
2212
- onDaySelect,
2213
- intent = "secondary",
2214
- placement = "bottom",
2215
- size = "small",
2216
- buttonContent,
2217
- language
2218
- }) => {
2219
- const target = useRef(null);
2220
- const popover = useRef(null);
2221
- const {
2222
- popoverRef,
2223
- targetRef,
2224
- onShow,
2225
- onHide,
2226
- popoverProps
2227
- } = usePopover({
2228
- targetRef: target,
2229
- popoverRef: popover,
2230
- placement: placement
2231
- });
2232
- return jsxs(Fragment$1, {
2233
- children: [jsx(Button, Object.assign({
2234
- intent: intent,
2235
- size: size,
2236
- className: className,
2237
- prefix: jsx(Icon$1, {
2238
- name: "CalendarIcon",
2239
- size: "small"
2240
- }),
2241
- ref: targetRef,
2242
- onClick: onShow
2243
- }, {
2244
- children: buttonContent
2245
- })), jsx(AnimatedPopover, Object.assign({
2246
- ref: popoverRef,
2247
- onRequestClose: () => {
2248
- var _a;
2249
-
2250
- onHide();
2251
- (_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
2252
- }
2253
- }, popoverProps, {
2254
- children: jsx(PopoverList, {
2255
- children: jsx(DayPicker, {
2256
- disabledDays: disabledDays,
2257
- onDaySelect: onDaySelect,
2258
- selectedDays: selectedDay,
2259
- language: language
2260
- })
2261
- })
2262
- }))]
2263
- });
2264
- };
2265
-
2266
- /**
2267
- * The DayRangePicker component should be used when the user needs to select a range of dates.
2268
- *
2269
- * @param {DayRangePickerProps} props - The props for the DayRangePicker component
2270
- * @returns {JSX.Element} DayRangePicker component
2271
- */
2272
-
2273
- const DayRangePicker = ({
2274
- onRangeSelect,
2275
- selectedDays,
2276
- disabledDays,
2277
- dataTestId,
2278
- language
2279
- }) => {
2280
- const locale = useLocale(language);
2281
- const onSelect = useCallback(range => {
2282
- if (onRangeSelect && range === undefined) {
2283
- onRangeSelect(undefined);
2284
- }
2285
-
2286
- if (onRangeSelect && range) {
2287
- const from = range.from;
2288
- const to = range.to ? range.to : range.from;
2289
- onRangeSelect({
2290
- from,
2291
- to
2292
- });
2293
- }
2294
- }, [onRangeSelect]);
2295
- return jsx("div", Object.assign({
2296
- "data-testid": dataTestId
2297
- }, {
2298
- children: jsx(DayPicker$1, {
2299
- mode: "range",
2300
- onSelect: onSelect,
2301
- selected: selectedDays,
2302
- defaultMonth: selectedDays && selectedDays.from,
2303
- locale: locale,
2304
- disabled: disabledDays,
2305
- className: "custom-day-picker range-picker"
2306
- })
2307
- }));
2308
- };
2309
-
2310
- /**
2311
- * The Label component is used for labels for input fields.
2312
- * This component is **not used directly**, but is part of the FormGroup and Field components.
2313
- *
2314
- * @param {LabelProps} props - The props for the Label component
2315
- * @returns {JSX.Element} Label component
2316
- */
2317
-
2318
- const Label$5 = ({
2319
- id,
2320
- htmlFor,
2321
- children,
2322
- className,
2323
- dataTestId
2324
- }) => {
2325
- return jsx(Root$2, Object.assign({
2326
- className: className,
2327
- id: id,
2328
- "data-testid": dataTestId,
2329
- htmlFor: htmlFor
2330
- }, {
2331
- children: children
2332
- }));
2333
- };
2334
- const Root$2 = tw.label`
2335
- tu-label
2336
- `;
2337
-
2338
2219
  /**
2339
2220
  * The Tooltip component.
2340
2221
  *
@@ -2510,6 +2391,157 @@ const HelpAddon = tw.span`
2510
2391
  tu-form-group__help-addon
2511
2392
  `;
2512
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
+
2513
2545
  /**
2514
2546
  * Indicators are non-interactive elements that communicate essential aspects of the state of an asset.
2515
2547
  *
@@ -3061,34 +3093,15 @@ const NumberField = forwardRef((_a, ref) => {
3061
3093
  }));
3062
3094
  });
3063
3095
 
3064
- const GetSpacerHeight = () => ({
3065
- minHeight
3066
- }) => {
3067
- if (!minHeight) {
3068
- return "";
3069
- }
3070
-
3071
- switch (minHeight) {
3072
- case "normal":
3073
- return tws`min-h-[8px]`;
3074
-
3075
- case "large":
3076
- return tws`min-h-[32px]`;
3077
-
3078
- default:
3079
- return "";
3080
- }
3081
- };
3082
3096
  /**
3083
- * 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.
3084
3098
  *
3085
3099
  * @param {SpacerProps} props - The props for the Spacer component
3086
3100
  * @returns {JSX.Element} Spacer component
3087
3101
  */
3088
3102
 
3089
-
3090
3103
  const Spacer = ({
3091
- minHeight = "",
3104
+ minHeight,
3092
3105
  border,
3093
3106
  dataTestId
3094
3107
  }) => {
@@ -3098,17 +3111,35 @@ const Spacer = ({
3098
3111
  border: border
3099
3112
  });
3100
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
+
3101
3130
  const Space = tw.div`
3102
- ${p => `${p.border ? `tu-spacer--border` : null}`}
3103
- ${GetSpacerHeight()}
3131
+ ${p => `${p.border ? `tu-spacer--border` : null}`}
3132
+ ${GetSpacerHeight()}
3104
3133
  `;
3105
3134
 
3106
3135
  /**
3107
- * Tags allow users to enter information and filter content.
3136
+ * The tag component is used to categorize elements in the ui.
3108
3137
  *
3109
- * 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.
3110
3139
  *
3111
- * 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.
3112
3143
  *
3113
3144
  * @param {TagProps} props - The props for the tag component
3114
3145
  * @returns {JSX.Element} tag component
@@ -3468,7 +3499,7 @@ const SelectContainer = ({
3468
3499
  htmlFor: id
3469
3500
  }, {
3470
3501
  children: label
3471
- })), children, (hasError || info) && jsx(InformativeText$1, Object.assign({
3502
+ })), children, (hasError || info) && jsx(InformativeText, Object.assign({
3472
3503
  size: "small",
3473
3504
  "$hasError": hasError !== null && hasError !== void 0 ? hasError : false
3474
3505
  }, {
@@ -3479,7 +3510,7 @@ const SelectContainer = ({
3479
3510
  const Container = tw.label`
3480
3511
  tu-select__container
3481
3512
  `;
3482
- const InformativeText$1 = tw(Text)`
3513
+ const InformativeText = tw(Text)`
3483
3514
  tu-informative-text
3484
3515
  ${p => p.$hasError ? `tu-informative-text--error` : null}
3485
3516
  `;
@@ -3737,12 +3768,12 @@ const SkeletonLines = memo(({
3737
3768
  for (let i = 0; i < lines; i++) {
3738
3769
  skeletonLines.push(jsx(SkeletonLine, Object.assign({
3739
3770
  "data-testid": dataTestId,
3740
- margin: margin,
3741
3771
  "data-type": "loading-skeleton-line",
3742
3772
  className: className,
3743
3773
  style: {
3744
3774
  height: getHeight(i),
3745
- width: getWidth(i)
3775
+ width: getWidth(i),
3776
+ margin: margin
3746
3777
  }
3747
3778
  }, {
3748
3779
  children: "\u00A0"
@@ -3758,87 +3789,63 @@ const SkeletonLine = tw.div`
3758
3789
  tu-skeleton-line
3759
3790
  `;
3760
3791
 
3761
- const TextArea = React.forwardRef(({
3762
- id,
3763
- name,
3764
- label,
3765
- description,
3766
- info,
3767
- error,
3768
- value,
3769
- rows,
3770
- disabled,
3771
- placeholder,
3772
- readOnly,
3773
- tabIndex,
3774
- onChange,
3775
- onFocus,
3776
- onBlur,
3777
- maxLength,
3778
- resize = "vertical",
3779
- defaultValue,
3780
- className,
3781
- required,
3782
- dataTestId
3783
- }, ref) => {
3784
- const hasError = !!error;
3785
- return jsxs(TextAreaContainer, Object.assign({
3786
- className: className
3787
- }, {
3788
- children: [jsx(Label$5, Object.assign({
3789
- htmlFor: id
3790
- }, {
3791
- children: label
3792
- })), jsx(StyledTextArea, {
3793
- name: name,
3794
- id: id,
3795
- "data-testid": dataTestId,
3796
- value: value,
3797
- rows: rows,
3798
- disabled: disabled,
3799
- placeholder: placeholder,
3800
- readOnly: readOnly,
3801
- tabIndex: tabIndex,
3802
- onChange: onChange,
3803
- onFocus: onFocus,
3804
- onBlur: onBlur,
3805
- maxLength: maxLength,
3806
- "$resize": resize,
3807
- "$hasError": hasError,
3808
- ref: ref,
3809
- defaultValue: defaultValue,
3810
- required: required
3811
- }), (hasError || info) && jsx(InformativeText, Object.assign({
3812
- size: "small",
3813
- "$hasError": hasError
3814
- }, {
3815
- children: hasError ? error : info
3816
- }))]
3792
+ /**
3793
+ * The TextArea is a base component, and should not be used very often.
3794
+ * For most cases the TextAreaField is the correct component.
3795
+ */
3796
+
3797
+ const TextArea = React.forwardRef((_a, ref) => {
3798
+ var {
3799
+ id,
3800
+ name,
3801
+ value,
3802
+ rows,
3803
+ disabled,
3804
+ placeholder,
3805
+ readOnly,
3806
+ tabIndex,
3807
+ onChange,
3808
+ onFocus,
3809
+ onBlur,
3810
+ maxLength,
3811
+ resize = "vertical",
3812
+ defaultValue,
3813
+ className,
3814
+ required,
3815
+ dataTestId,
3816
+ isInvalid
3817
+ } = _a,
3818
+ rest = __rest(_a, ["id", "name", "value", "rows", "disabled", "placeholder", "readOnly", "tabIndex", "onChange", "onFocus", "onBlur", "maxLength", "resize", "defaultValue", "className", "required", "dataTestId", "isInvalid"]);
3819
+
3820
+ return jsx(StyledTextArea, Object.assign({
3821
+ name: name,
3822
+ value: value,
3823
+ rows: rows,
3824
+ disabled: disabled,
3825
+ placeholder: placeholder,
3826
+ readOnly: readOnly,
3827
+ tabIndex: tabIndex,
3828
+ onFocus: onFocus,
3829
+ onBlur: onBlur,
3830
+ maxLength: maxLength,
3831
+ "$resize": resize,
3832
+ "$invalid": isInvalid,
3833
+ ref: ref,
3834
+ defaultValue: defaultValue,
3835
+ required: required
3836
+ }, rest, {
3837
+ onChange: onChange,
3838
+ "data-testId": dataTestId
3817
3839
  }));
3818
3840
  });
3819
- const TextAreaContainer = tw.div``;
3820
3841
  const StyledTextArea = tw.textarea`
3821
- input
3822
- w-full
3823
- block
3824
- p-2
3825
- overflow-auto
3826
- appearance-none
3827
- text-base
3828
- text-slate-900
3829
- placeholder-slate-400
3830
- focus-visible:outline-none
3831
- border-box
3832
- h-20
3833
-
3834
- transition
3835
-
3842
+ tu-textarea
3836
3843
  ${({
3837
- $hasError
3838
- }) => $hasError ? tws`tu-input--invalid` : null}
3844
+ $invalid
3845
+ }) => $invalid ? tws`tu-textarea--invalid` : null}
3839
3846
  ${({
3840
3847
  disabled
3841
- }) => disabled ? tws`tu-input--disabled` : null}
3848
+ }) => disabled ? tws`tu-textarea--disabled` : null}
3842
3849
  ${({
3843
3850
  $resize
3844
3851
  }) => {
@@ -3859,25 +3866,8 @@ const StyledTextArea = tw.textarea`
3859
3866
  return null;
3860
3867
  }
3861
3868
  }};
3862
-
3863
-
3864
- `;
3865
- const InformativeText = tw(Text)`
3866
- mt-1
3867
- ${p => p.$hasError ? tws`text-red-500` : tws`text-neutral-600`};
3868
3869
  `;
3869
3870
 
3870
- /**
3871
- * A thin wrapper around the `BaseInput` component for text input fields.
3872
- *
3873
- * NOTE: If shown with a label, please use the `TextField` component instead.
3874
- */
3875
-
3876
- const TextInput = forwardRef((props, ref) => jsx(BaseInput, Object.assign({
3877
- ref: ref,
3878
- type: "text"
3879
- }, props)));
3880
-
3881
3871
  /**
3882
3872
  * The TextLengthIndicator component shows a `{length}/{maxLength}` label.
3883
3873
  * Used for TextFields to communicate a maximum allowed input length.
@@ -3898,6 +3888,67 @@ const Root = tw.span`
3898
3888
  font-mono
3899
3889
  `;
3900
3890
 
3891
+ const TextAreaField = React.forwardRef((_a, ref) => {
3892
+ var {
3893
+ label,
3894
+ tip,
3895
+ helpText,
3896
+ helpAddon,
3897
+ errorMessage,
3898
+ isInvalid,
3899
+ maxLength,
3900
+ onChange,
3901
+ className,
3902
+ value,
3903
+ dataTestId
3904
+ } = _a,
3905
+ rest = __rest(_a, ["label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
3906
+
3907
+ const [valueLength, setValueLength] = React.useState(value ? `${value}`.length : 0);
3908
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
3909
+ const handleChange = React.useCallback(event => {
3910
+ setValueLength(event.target.value.length);
3911
+
3912
+ if (onChange) {
3913
+ onChange(event);
3914
+ }
3915
+ }, [onChange]);
3916
+ return jsx(FormGroup, Object.assign({
3917
+ label: label,
3918
+ tip: tip,
3919
+ isInvalid: renderAsInvalid,
3920
+ helpText: errorMessage || helpText,
3921
+ helpAddon: helpAddon || maxLength !== null && maxLength !== undefined && jsx(TextLengthIndicator, {
3922
+ length: valueLength,
3923
+ maxLength: maxLength
3924
+ }),
3925
+ className: className,
3926
+ dataTestId: `${dataTestId}-FormGroup`
3927
+ }, {
3928
+ children: jsx(TextArea, Object.assign({
3929
+ ref: ref,
3930
+ maxLength: maxLength,
3931
+ value: value,
3932
+ isInvalid: renderAsInvalid
3933
+ }, rest, {
3934
+ className: className,
3935
+ onChange: handleChange,
3936
+ dataTestId: dataTestId
3937
+ }))
3938
+ }));
3939
+ });
3940
+
3941
+ /**
3942
+ * A thin wrapper around the `BaseInput` component for text input fields.
3943
+ *
3944
+ * NOTE: If shown with a label, please use the `TextField` component instead.
3945
+ */
3946
+
3947
+ const TextInput = forwardRef((props, ref) => jsx(BaseInput, Object.assign({
3948
+ ref: ref,
3949
+ type: "text"
3950
+ }, props)));
3951
+
3901
3952
  /**
3902
3953
  * Text fields enable the user to interact with and input content and data. This component can be used for long and short form entries. Allow the size of the text input box to reflect the length of the content you expect the user to enter.
3903
3954
  *
@@ -4506,4 +4557,4 @@ const Layout = tw.div`
4506
4557
  tu-layout-TwoColumnLayout
4507
4558
  `;
4508
4559
 
4509
- 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, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, intentColors, useContainerProps, useCustomComponents, useCustomStyles, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
4560
+ 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 };