@trackunit/react-components 0.0.131 → 0.0.132

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.
@@ -45,6 +45,10 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
45
45
  * The Placeholder text for the input.
46
46
  */
47
47
  placeholder?: string;
48
+ /**
49
+ * A flag to disable interaction with input for example if you want to use input as a child of higher component
50
+ */
51
+ nonInteractive?: boolean;
48
52
  }
49
53
  /**
50
54
  * A base input component that can be used for text inputs, password inputs, etc.
@@ -22,6 +22,10 @@ export interface FormGroupProps extends CommonProps {
22
22
  * If true the input is rendered in its invalid state.
23
23
  */
24
24
  isInvalid?: boolean;
25
+ /**
26
+ * If true interactions are disabled
27
+ */
28
+ disabled?: boolean;
25
29
  children?: React.ReactNode;
26
30
  }
27
31
  /**
@@ -31,4 +35,4 @@ export interface FormGroupProps extends CommonProps {
31
35
  * @param {FormGroupProps} props - The props for the FormGroup component
32
36
  * @returns {JSX.Element} FormGroup component
33
37
  */
34
- export declare const FormGroup: ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, children, }: FormGroupProps) => JSX.Element;
38
+ export declare const FormGroup: ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, children, disabled, }: FormGroupProps) => JSX.Element;
package/index.js CHANGED
@@ -968,9 +968,10 @@ const BaseInput = React.forwardRef((_a, ref) => {
968
968
  addonBefore,
969
969
  addonAfter,
970
970
  actions,
971
- fieldSize = "medium"
971
+ fieldSize = "medium",
972
+ nonInteractive = false
972
973
  } = _a,
973
- rest = __rest(_a, ["className", "isInvalid", "dataTestId", "prefix", "suffix", "addonBefore", "addonAfter", "actions", "fieldSize"]);
974
+ rest = __rest(_a, ["className", "isInvalid", "dataTestId", "prefix", "suffix", "addonBefore", "addonAfter", "actions", "fieldSize", "nonInteractive"]);
974
975
 
975
976
  return jsxs(InputContainer$1, Object.assign({
976
977
  "$fieldSize": fieldSize,
@@ -991,7 +992,9 @@ const BaseInput = React.forwardRef((_a, ref) => {
991
992
  ref: ref,
992
993
  "data-testid": dataTestId,
993
994
  className: tws`tu-input__field`
994
- }, rest)), suffix !== null && addonBefore !== suffix ? jsx(InputSuffix, Object.assign({
995
+ }, rest, {
996
+ readOnly: rest.readOnly || nonInteractive
997
+ })), suffix !== null && addonBefore !== suffix ? jsx(InputSuffix, Object.assign({
995
998
  "data-testid": `${dataTestId}-suffix`
996
999
  }, {
997
1000
  children: suffix
@@ -2128,6 +2131,11 @@ const DateInput = forwardRef((_a, ref) => {
2128
2131
  value: (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) || "",
2129
2132
  onChange: () => {}
2130
2133
  }, rest, {
2134
+ dataTestId: "dateInput",
2135
+ onFocus: () => {
2136
+ onShow();
2137
+ },
2138
+ nonInteractive: true,
2131
2139
  suffix: jsx(Icon$1, {
2132
2140
  dataTestId: "calendar",
2133
2141
  name: "CalendarIcon",
@@ -2139,7 +2147,10 @@ const DateInput = forwardRef((_a, ref) => {
2139
2147
  actions: selectedDay && jsx(RemoveValueContainer, {
2140
2148
  children: jsx(Button, Object.assign({
2141
2149
  intent: "tertiary",
2142
- onClick: () => setSelectedDay(undefined)
2150
+ onClick: e => {
2151
+ e.preventDefault();
2152
+ setSelectedDay(undefined);
2153
+ }
2143
2154
  }, {
2144
2155
  children: jsx(Icon$1, {
2145
2156
  name: "XIcon",
@@ -2157,14 +2168,16 @@ const DateInput = forwardRef((_a, ref) => {
2157
2168
  (_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
2158
2169
  }
2159
2170
  }, popoverProps, {
2160
- children: jsx(PopoverList, {
2171
+ children: jsx(PopoverList, Object.assign({
2172
+ dataTestId: "datePickerPopover"
2173
+ }, {
2161
2174
  children: jsx(DayPicker, {
2162
2175
  onDaySelect: onChangeHandler,
2163
2176
  disabledDays: disabledDays,
2164
2177
  selectedDays: selectedDay,
2165
2178
  language: navigator.language
2166
2179
  })
2167
- })
2180
+ }))
2168
2181
  }))]
2169
2182
  });
2170
2183
  });
@@ -2400,11 +2413,13 @@ const FormGroup = ({
2400
2413
  className,
2401
2414
  dataTestId,
2402
2415
  label,
2403
- children
2416
+ children,
2417
+ disabled = false
2404
2418
  }) => {
2405
2419
  return jsxs(FormGroupRoot, Object.assign({
2406
2420
  className: className,
2407
- "data-testid": dataTestId
2421
+ "data-testid": dataTestId,
2422
+ "$disabled": disabled
2408
2423
  }, {
2409
2424
  children: [jsxs(ContainerBefore, {
2410
2425
  children: [jsx(Label$3, Object.assign({
@@ -2433,6 +2448,11 @@ const FormGroup = ({
2433
2448
  };
2434
2449
  const FormGroupRoot = tw.label`
2435
2450
  tu-form-group
2451
+ ${({
2452
+ $disabled
2453
+ }) => {
2454
+ return $disabled ? "pointer-events-none " : null;
2455
+ }}
2436
2456
  `;
2437
2457
  const ContainerBefore = tw.div`
2438
2458
  tu-form-group__container-before
@@ -2476,6 +2496,7 @@ const DateField = forwardRef((_a, ref) => {
2476
2496
  isInvalid: renderAsInvalid,
2477
2497
  helpText: errorMessage || helpText,
2478
2498
  helpAddon: helpAddon,
2499
+ disabled: rest.disabled,
2479
2500
  dataTestId: `${dataTestId}-FormGroup`
2480
2501
  }, {
2481
2502
  children: jsx(DateInput, Object.assign({
@@ -4655,7 +4676,8 @@ const TextField = React.forwardRef((_a, ref) => {
4655
4676
  length: valueLength,
4656
4677
  maxLength: maxLength
4657
4678
  }),
4658
- dataTestId: `${dataTestId}-FormGroup`
4679
+ dataTestId: `${dataTestId}-FormGroup`,
4680
+ disabled: rest.readOnly
4659
4681
  }, {
4660
4682
  children: jsx(TextInput, Object.assign({
4661
4683
  ref: ref,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.131",
3
+ "version": "0.0.132",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {