ferns-ui 1.8.0 → 1.9.1

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.
Files changed (48) hide show
  1. package/dist/BooleanField.d.ts +2 -2
  2. package/dist/BooleanField.js.map +1 -1
  3. package/dist/Box.js +43 -1
  4. package/dist/Box.js.map +1 -1
  5. package/dist/Common.d.ts +35 -28
  6. package/dist/Common.js.map +1 -1
  7. package/dist/CustomSelectField.d.ts +2 -2
  8. package/dist/CustomSelectField.js.map +1 -1
  9. package/dist/DataTable.d.ts +2 -2
  10. package/dist/DataTable.js.map +1 -1
  11. package/dist/DateTimeField.d.ts +2 -2
  12. package/dist/DateTimeField.js +48 -8
  13. package/dist/DateTimeField.js.map +1 -1
  14. package/dist/DateTimeField.test.js +5 -5
  15. package/dist/DateTimeField.test.js.map +1 -1
  16. package/dist/FernsProvider.d.ts +3 -3
  17. package/dist/FernsProvider.js.map +1 -1
  18. package/dist/Icon.d.ts +2 -2
  19. package/dist/Icon.js.map +1 -1
  20. package/dist/Pagination.d.ts +2 -2
  21. package/dist/Pagination.js.map +1 -1
  22. package/dist/SegmentedControl.d.ts +2 -2
  23. package/dist/SegmentedControl.js.map +1 -1
  24. package/dist/Signature.native.d.ts +2 -2
  25. package/dist/Signature.native.js.map +1 -1
  26. package/dist/Spinner.d.ts +2 -2
  27. package/dist/Spinner.js.map +1 -1
  28. package/dist/TapToEdit.d.ts +2 -2
  29. package/dist/TapToEdit.js +11 -1
  30. package/dist/TapToEdit.js.map +1 -1
  31. package/dist/TimezonePicker.d.ts +2 -2
  32. package/dist/TimezonePicker.js.map +1 -1
  33. package/package.json +12 -1
  34. package/src/BooleanField.tsx +3 -3
  35. package/src/Box.tsx +45 -1
  36. package/src/Common.ts +40 -27
  37. package/src/CustomSelectField.tsx +3 -3
  38. package/src/DataTable.tsx +10 -10
  39. package/src/DateTimeField.test.tsx +5 -5
  40. package/src/DateTimeField.tsx +57 -12
  41. package/src/FernsProvider.tsx +6 -6
  42. package/src/Icon.tsx +3 -3
  43. package/src/Pagination.tsx +15 -15
  44. package/src/SegmentedControl.tsx +2 -2
  45. package/src/Signature.native.tsx +2 -2
  46. package/src/Spinner.tsx +2 -2
  47. package/src/TapToEdit.tsx +26 -9
  48. package/src/TimezonePicker.tsx +2 -2
package/src/TapToEdit.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React, {ReactElement, useEffect, useRef, useState} from "react";
1
+ import React, {FC, useEffect, useRef, useState} from "react";
2
2
  import {Linking, View} from "react-native";
3
3
 
4
4
  import {Box} from "./Box";
@@ -9,15 +9,15 @@ import {Icon} from "./Icon";
9
9
  // import {useOpenAPISpec} from "./OpenAPIContext";
10
10
  import {Text} from "./Text";
11
11
 
12
- const TapToEditTitle = ({
13
- title,
14
- helperText,
15
- onlyShowHelperTextWhileEditing,
16
- }: {
12
+ const TapToEditTitle: FC<{
17
13
  onlyShowHelperTextWhileEditing?: boolean;
18
14
  title: string;
19
15
  helperText?: string;
20
- }): ReactElement => {
16
+ }> = ({
17
+ title,
18
+ helperText,
19
+ onlyShowHelperTextWhileEditing,
20
+ }) => {
21
21
  return (
22
22
  <View style={{flex: 1, justifyContent: "center"}}>
23
23
  <Text bold>{title}</Text>
@@ -68,7 +68,7 @@ export function formatAddress(address: AddressInterface, asString = false): stri
68
68
  }
69
69
  }
70
70
 
71
- export const TapToEdit = ({
71
+ export const TapToEdit: FC<TapToEditProps> = ({
72
72
  value,
73
73
  setValue,
74
74
  title,
@@ -81,8 +81,9 @@ export const TapToEdit = ({
81
81
  confirmationTitle = "Confirm",
82
82
  helperText: propsHelperText,
83
83
  onlyShowHelperTextWhileEditing = true,
84
+ showClearButton = false,
84
85
  ...fieldProps
85
- }: TapToEditProps): ReactElement => {
86
+ }) => {
86
87
  const [editing, setEditing] = useState(false);
87
88
  const [initialValue, setInitialValue] = useState();
88
89
  const helperText: string | undefined = propsHelperText;
@@ -141,6 +142,22 @@ export const TapToEdit = ({
141
142
  setEditing(false);
142
143
  }}
143
144
  />
145
+ {(showClearButton || ["date", "datetime", "time"].includes(fieldProps?.type)) && (
146
+ <Button
147
+ text="Clear"
148
+ variant="muted"
149
+ onClick={(): void => {
150
+ if (setValue) {
151
+ setValue("");
152
+ setInitialValue("" as any);
153
+ }
154
+ if (onSave) {
155
+ onSave("");
156
+ }
157
+ setEditing(false);
158
+ }}
159
+ />
160
+ )}
144
161
  <View style={{marginLeft: 8}}>
145
162
  <Button
146
163
  confirmationText={confirmationText}
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, {FC} from "react";
2
2
 
3
3
  import {SelectFieldPropsBase} from "./Common";
4
4
  import {getTimezoneOptions} from "./DateUtilities";
@@ -12,7 +12,7 @@ interface TimezonePickerProps extends Omit<SelectFieldPropsBase, "options"> {
12
12
  shortTimezone?: boolean;
13
13
  }
14
14
 
15
- export const TimezonePicker: React.FC<TimezonePickerProps> = ({
15
+ export const TimezonePicker: FC<TimezonePickerProps> = ({
16
16
  timezone,
17
17
  onChange,
18
18
  location = "USA",