@jobber/components 2.86.0 → 2.86.2

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 (269) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/Autocomplete/Autocomplete.d.ts +47 -47
  3. package/dist/Autocomplete/Menu.d.ts +9 -9
  4. package/dist/Autocomplete/Option.d.ts +15 -15
  5. package/dist/Autocomplete/index.d.ts +2 -2
  6. package/dist/Autocomplete/index.js +215 -211
  7. package/dist/Avatar/Avatar.d.ts +37 -37
  8. package/dist/Avatar/index.d.ts +1 -1
  9. package/dist/Avatar/index.js +7 -74
  10. package/dist/Avatar/utilities.d.ts +1 -1
  11. package/dist/Avatar-cfd04e86.js +82 -0
  12. package/dist/Banner/Banner.d.ts +19 -19
  13. package/dist/Banner/index.d.ts +1 -1
  14. package/dist/Banner/index.js +67 -65
  15. package/dist/Button/Button.d.ts +64 -64
  16. package/dist/Button/index.d.ts +1 -1
  17. package/dist/Button/index.js +9 -53
  18. package/dist/Button-5b2f1636.js +60 -0
  19. package/dist/ButtonDismiss/ButtonDismiss.d.ts +7 -7
  20. package/dist/ButtonDismiss/index.d.ts +1 -1
  21. package/dist/ButtonDismiss/index.js +10 -15
  22. package/dist/ButtonDismiss-4cde8f7c.js +15 -0
  23. package/dist/Card/Card.d.ts +31 -31
  24. package/dist/Card/CardClickable.d.ts +12 -12
  25. package/dist/Card/index.d.ts +1 -1
  26. package/dist/Card/index.js +7 -61
  27. package/dist/Card-368e01a3.js +68 -0
  28. package/dist/Checkbox/Checkbox.d.ts +52 -52
  29. package/dist/Checkbox/index.d.ts +1 -1
  30. package/dist/Checkbox/index.js +34 -32
  31. package/dist/Chips/Chip.d.ts +8 -8
  32. package/dist/Chips/ChipDismissible.d.ts +7 -7
  33. package/dist/Chips/ChipTypes.d.ts +59 -59
  34. package/dist/Chips/Chips.d.ts +2 -2
  35. package/dist/Chips/ChipsTypes.d.ts +82 -82
  36. package/dist/Chips/InternalChip.d.ts +2 -2
  37. package/dist/Chips/InternalChipAffix.d.ts +10 -10
  38. package/dist/Chips/InternalChipButton.d.ts +10 -10
  39. package/dist/Chips/InternalChipDismissible/InternalChipDismissible.d.ts +2 -2
  40. package/dist/Chips/InternalChipDismissible/InternalChipDismissibleInput.d.ts +2 -2
  41. package/dist/Chips/InternalChipDismissible/InternalChipDismissibleTypes.d.ts +13 -13
  42. package/dist/Chips/InternalChipDismissible/hooks/index.d.ts +5 -5
  43. package/dist/Chips/InternalChipDismissible/hooks/useInView.d.ts +5 -5
  44. package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissible.d.ts +15 -15
  45. package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +28 -28
  46. package/dist/Chips/InternalChipDismissible/hooks/useRepositionMenu.d.ts +16 -16
  47. package/dist/Chips/InternalChipDismissible/hooks/useScrollToActive.d.ts +2 -2
  48. package/dist/Chips/InternalChipDismissible/index.d.ts +1 -1
  49. package/dist/Chips/InternalChipMultiSelect.d.ts +4 -4
  50. package/dist/Chips/InternalChipSingleSelect.d.ts +4 -4
  51. package/dist/Chips/index.d.ts +3 -3
  52. package/dist/Chips/index.js +493 -491
  53. package/dist/Chips/utils/mdxUtils.d.ts +9 -9
  54. package/dist/ConfirmationModal/ConfirmationModal.d.ts +62 -62
  55. package/dist/ConfirmationModal/index.d.ts +1 -1
  56. package/dist/ConfirmationModal/index.js +20 -109
  57. package/dist/ConfirmationModal-b7ef110f.js +103 -0
  58. package/dist/Content/Content.d.ts +13 -13
  59. package/dist/Content/index.d.ts +1 -1
  60. package/dist/Content/index.js +5 -19
  61. package/dist/Content-18de5fbb.js +26 -0
  62. package/dist/Countdown/Countdown.d.ts +31 -31
  63. package/dist/Countdown/computeTimeUnit.d.ts +3 -3
  64. package/dist/Countdown/index.d.ts +1 -1
  65. package/dist/Countdown/index.js +63 -61
  66. package/dist/DataDump/DataDump.d.ts +20 -20
  67. package/dist/DataDump/index.d.ts +1 -1
  68. package/dist/DataDump/index.js +18 -17
  69. package/dist/DatePicker/DatePicker.d.ts +50 -50
  70. package/dist/DatePicker/DatePickerActivator.d.ts +12 -12
  71. package/dist/DatePicker/DatePickerCustomHeader.d.ts +2 -2
  72. package/dist/DatePicker/index.d.ts +1 -1
  73. package/dist/DatePicker/index.js +13 -97
  74. package/dist/DatePicker/useFocusOnSelectedDate.d.ts +5 -5
  75. package/dist/DatePicker-ad6f8630.js +103 -0
  76. package/dist/DescriptionList/DescriptionList.d.ts +10 -10
  77. package/dist/DescriptionList/index.d.ts +1 -1
  78. package/dist/DescriptionList/index.js +16 -15
  79. package/dist/Disclosure/Disclosure.d.ts +20 -20
  80. package/dist/Disclosure/index.d.ts +1 -1
  81. package/dist/Disclosure/index.js +32 -31
  82. package/dist/Divider/Divider.d.ts +16 -16
  83. package/dist/Divider/index.d.ts +1 -1
  84. package/dist/Divider/index.js +19 -17
  85. package/dist/Drawer/Drawer.d.ts +13 -13
  86. package/dist/Drawer/DrawerGrid.d.ts +6 -6
  87. package/dist/Drawer/index.d.ts +2 -2
  88. package/dist/Drawer/index.js +39 -37
  89. package/dist/Emphasis/Emphasis.d.ts +11 -11
  90. package/dist/Emphasis/index.d.ts +1 -1
  91. package/dist/Emphasis/index.js +7 -17
  92. package/dist/Emphasis-fd845639.js +21 -0
  93. package/dist/FeatureSwitch/FeatureSwitch.d.ts +51 -51
  94. package/dist/FeatureSwitch/index.d.ts +1 -1
  95. package/dist/FeatureSwitch/index.js +57 -55
  96. package/dist/Form/Form.d.ts +18 -18
  97. package/dist/Form/index.d.ts +1 -1
  98. package/dist/Form/index.js +58 -57
  99. package/dist/FormField/FormField.d.ts +2 -2
  100. package/dist/FormField/FormFieldAffix.d.ts +13 -13
  101. package/dist/FormField/FormFieldDescription.d.ts +6 -6
  102. package/dist/FormField/FormFieldPostFix.d.ts +5 -5
  103. package/dist/FormField/FormFieldTypes.d.ts +160 -160
  104. package/dist/FormField/FormFieldWrapper.d.ts +9 -9
  105. package/dist/FormField/index.d.ts +2 -2
  106. package/dist/FormField/index.js +15 -208
  107. package/dist/FormField-a92c7bac.js +213 -0
  108. package/dist/FormatDate/FormatDate.d.ts +12 -12
  109. package/dist/FormatDate/index.d.ts +1 -1
  110. package/dist/FormatDate/index.js +24 -23
  111. package/dist/FormatEmail/FormatEmail.d.ts +8 -8
  112. package/dist/FormatEmail/index.d.ts +1 -1
  113. package/dist/FormatEmail/index.js +12 -10
  114. package/dist/FormatFile/FormatFile.d.ts +30 -30
  115. package/dist/FormatFile/FormatFileDeleteButton.d.ts +6 -6
  116. package/dist/FormatFile/InternalThumbnail.d.ts +9 -9
  117. package/dist/FormatFile/index.d.ts +1 -1
  118. package/dist/FormatFile/index.js +21 -112
  119. package/dist/FormatFile-5391d4cf.js +112 -0
  120. package/dist/FormatRelativeDateTime/FormatRelativeDateTime.d.ts +11 -11
  121. package/dist/FormatRelativeDateTime/index.d.ts +1 -1
  122. package/dist/FormatRelativeDateTime/index.js +64 -63
  123. package/dist/FormatTime/FormatTime.d.ts +15 -15
  124. package/dist/FormatTime/index.d.ts +1 -1
  125. package/dist/FormatTime/index.js +28 -27
  126. package/dist/Gallery/Gallery.d.ts +2 -2
  127. package/dist/Gallery/GalleryTypes.d.ts +31 -31
  128. package/dist/Gallery/index.d.ts +1 -1
  129. package/dist/Gallery/index.js +82 -80
  130. package/dist/Heading/Heading.d.ts +14 -14
  131. package/dist/Heading/index.d.ts +1 -1
  132. package/dist/Heading/index.js +7 -53
  133. package/dist/Heading-56750113.js +57 -0
  134. package/dist/Icon/Icon.d.ts +22 -22
  135. package/dist/Icon/index.d.ts +1 -1
  136. package/dist/Icon/index.js +4 -35
  137. package/dist/Icon-d5ad1a6d.js +41 -0
  138. package/dist/InlineLabel/InlineLabel.d.ts +17 -17
  139. package/dist/InlineLabel/index.d.ts +1 -1
  140. package/dist/InlineLabel/index.js +20 -18
  141. package/dist/InputAvatar/InputAvatar.d.ts +22 -22
  142. package/dist/InputAvatar/index.d.ts +1 -1
  143. package/dist/InputAvatar/index.js +57 -56
  144. package/dist/InputDate/InputDate.d.ts +19 -19
  145. package/dist/InputDate/index.d.ts +1 -1
  146. package/dist/InputDate/index.js +34 -33
  147. package/dist/InputEmail/InputEmail.d.ts +5 -5
  148. package/dist/InputEmail/index.d.ts +1 -1
  149. package/dist/InputEmail/index.js +29 -28
  150. package/dist/InputFile/InputFile.d.ts +121 -121
  151. package/dist/InputFile/index.d.ts +1 -1
  152. package/dist/InputFile/index.js +15 -168
  153. package/dist/InputFile-b5cf90c3.js +174 -0
  154. package/dist/InputGroup/InputGroup.d.ts +11 -11
  155. package/dist/InputGroup/index.d.ts +1 -1
  156. package/dist/InputGroup/index.js +24 -22
  157. package/dist/InputNumber/InputNumber.d.ts +11 -11
  158. package/dist/InputNumber/index.d.ts +1 -1
  159. package/dist/InputNumber/index.js +52 -51
  160. package/dist/InputPassword/InputPassword.d.ts +12 -12
  161. package/dist/InputPassword/index.d.ts +1 -1
  162. package/dist/InputPassword/index.js +28 -27
  163. package/dist/InputText/InputText.d.ts +29 -29
  164. package/dist/InputText/index.d.ts +1 -1
  165. package/dist/InputText/index.js +15 -95
  166. package/dist/InputText-cb3be15c.js +91 -0
  167. package/dist/InputTime/InputTime.d.ts +2 -2
  168. package/dist/InputTime/InputTimeProps.d.ts +18 -18
  169. package/dist/InputTime/InputTimeSafari.d.ts +2 -2
  170. package/dist/InputTime/civilTimeConversions.d.ts +3 -3
  171. package/dist/InputTime/index.d.ts +1 -1
  172. package/dist/InputTime/index.js +402 -257
  173. package/dist/InputValidation/InputValidation.d.ts +8 -8
  174. package/dist/InputValidation/index.d.ts +1 -1
  175. package/dist/InputValidation/index.js +8 -24
  176. package/dist/InputValidation-24d3621a.js +28 -0
  177. package/dist/LightBox/LightBox.d.ts +37 -37
  178. package/dist/LightBox/index.d.ts +1 -1
  179. package/dist/LightBox/index.js +6 -34
  180. package/dist/LightBox-b893b656.js +42 -0
  181. package/dist/List/List.d.ts +11 -11
  182. package/dist/List/ListItem.d.ts +54 -54
  183. package/dist/List/index.d.ts +1 -1
  184. package/dist/List/index.js +76 -74
  185. package/dist/Markdown/Markdown.d.ts +17 -17
  186. package/dist/Markdown/index.d.ts +1 -1
  187. package/dist/Markdown/index.js +12 -64
  188. package/dist/Markdown-69986c49.js +68 -0
  189. package/dist/Menu/Menu.d.ts +46 -46
  190. package/dist/Menu/index.d.ts +1 -1
  191. package/dist/Menu/index.js +13 -128
  192. package/dist/Menu-6a392af6.js +134 -0
  193. package/dist/Modal/Modal.d.ts +22 -22
  194. package/dist/Modal/index.d.ts +1 -1
  195. package/dist/Modal/index.js +14 -127
  196. package/dist/Modal/useFocusTrap.d.ts +10 -10
  197. package/dist/Modal-aaaaf2df.js +132 -0
  198. package/dist/Page/Page.d.ts +59 -59
  199. package/dist/Page/index.d.ts +1 -1
  200. package/dist/Page/index.js +63 -61
  201. package/dist/Popover/Popover.d.ts +26 -26
  202. package/dist/Popover/index.d.ts +1 -1
  203. package/dist/Popover/index.js +49 -48
  204. package/dist/ProgressBar/ProgressBar.d.ts +18 -18
  205. package/dist/ProgressBar/index.d.ts +1 -1
  206. package/dist/ProgressBar/index.js +5 -22
  207. package/dist/ProgressBar-e9a49129.js +29 -0
  208. package/dist/RadioGroup/RadioGroup.d.ts +27 -27
  209. package/dist/RadioGroup/RadioOption.d.ts +34 -34
  210. package/dist/RadioGroup/index.d.ts +2 -2
  211. package/dist/RadioGroup/index.js +38 -37
  212. package/dist/RecurringSelect/CurrentRecurrenceComponent.d.ts +8 -8
  213. package/dist/RecurringSelect/RecurringSelect.d.ts +8 -8
  214. package/dist/RecurringSelect/components/DayOfMonthSelect.d.ts +8 -8
  215. package/dist/RecurringSelect/components/MonthlyDayOfWeekSelect.d.ts +8 -8
  216. package/dist/RecurringSelect/components/MonthlySelect.d.ts +8 -8
  217. package/dist/RecurringSelect/components/WeeklySelect.d.ts +8 -8
  218. package/dist/RecurringSelect/components/index.d.ts +4 -4
  219. package/dist/RecurringSelect/index.d.ts +2 -2
  220. package/dist/RecurringSelect/types.d.ts +65 -65
  221. package/dist/Select/Option.d.ts +17 -17
  222. package/dist/Select/Select.d.ts +10 -10
  223. package/dist/Select/index.d.ts +2 -2
  224. package/dist/Select/index.js +20 -19
  225. package/dist/Spinner/Spinner.d.ts +15 -15
  226. package/dist/Spinner/index.d.ts +1 -1
  227. package/dist/Spinner/index.js +5 -19
  228. package/dist/Spinner-18d3dee6.js +26 -0
  229. package/dist/StatusLabel/StatusLabel.d.ts +25 -25
  230. package/dist/StatusLabel/index.d.ts +1 -1
  231. package/dist/StatusLabel/index.js +21 -19
  232. package/dist/Switch/Switch.d.ts +14 -14
  233. package/dist/Switch/index.d.ts +1 -1
  234. package/dist/Switch/index.js +7 -53
  235. package/dist/Switch-d2bec677.js +60 -0
  236. package/dist/Table/Body.d.ts +6 -6
  237. package/dist/Table/Cells/Cell.d.ts +7 -7
  238. package/dist/Table/Cells/CellCurrency.d.ts +8 -8
  239. package/dist/Table/Cells/CellNumeric.d.ts +4 -4
  240. package/dist/Table/Footer.d.ts +6 -6
  241. package/dist/Table/Header.d.ts +6 -6
  242. package/dist/Table/Row.d.ts +6 -6
  243. package/dist/Table/Table.d.ts +6 -6
  244. package/dist/Table/index.d.ts +8 -8
  245. package/dist/Table/index.js +41 -39
  246. package/dist/Tabs/Tabs.d.ts +19 -19
  247. package/dist/Tabs/index.d.ts +1 -1
  248. package/dist/Tabs/index.js +69 -67
  249. package/dist/Text/Text.d.ts +9 -9
  250. package/dist/Text/index.d.ts +1 -1
  251. package/dist/Text/index.js +7 -29
  252. package/dist/Text-9bc093e9.js +32 -0
  253. package/dist/Toast/Toast.d.ts +17 -17
  254. package/dist/Toast/index.d.ts +1 -1
  255. package/dist/Toast/index.js +93 -93
  256. package/dist/Toast/showToast.d.ts +2 -2
  257. package/dist/Tooltip/Tooltip.d.ts +10 -10
  258. package/dist/Tooltip/index.d.ts +1 -1
  259. package/dist/Tooltip/index.js +11 -110
  260. package/dist/Tooltip/useTooltipPositioning.d.ts +18 -18
  261. package/dist/Tooltip-4396164d.js +116 -0
  262. package/dist/Typography/Typography.d.ts +38 -38
  263. package/dist/Typography/index.d.ts +1 -1
  264. package/dist/Typography/index.js +6 -57
  265. package/dist/Typography-7e542a72.js +64 -0
  266. package/dist/{chunk-17e02351.js → style-inject.es-dcee06b6.js} +0 -0
  267. package/dist/{chunk-b67af3cb.js → tslib.es6-5b50eb8e.js} +0 -0
  268. package/package.json +6 -8
  269. package/rollup.config.js +28 -3
@@ -1,160 +1,160 @@
1
- import { ChangeEvent, ReactNode, RefObject } from "react";
2
- import { ValidationRules } from "react-hook-form";
3
- import { XOR } from "ts-xor";
4
- import { IconNames } from "../Icon";
5
- export declare type FormFieldTypes = "text" | "password" | "number" | "time" | "textarea" | "select" | "email";
6
- export declare type AutocompleteTypes = "one-time-code" | "address-line1" | "address-line2";
7
- export interface FieldActionsRef {
8
- setValue(value: string | number): void;
9
- }
10
- export interface Affix {
11
- readonly label?: string;
12
- readonly icon?: IconNames;
13
- }
14
- interface BaseSuffix extends Affix {
15
- readonly icon: IconNames;
16
- onClick?(): void;
17
- }
18
- export interface Suffix extends BaseSuffix {
19
- onClick(): void;
20
- readonly ariaLabel: string;
21
- }
22
- export interface CommonFormFieldProps {
23
- /**
24
- * Determines the alignment of the text inside the input.
25
- */
26
- readonly align?: "center" | "right";
27
- /**
28
- * Further description of the input, can be used for a hint.
29
- */
30
- readonly description?: string;
31
- /**
32
- * Disable the input
33
- */
34
- readonly disabled?: boolean;
35
- /**
36
- * Highlights the field red to indicate an error.
37
- */
38
- readonly invalid?: boolean;
39
- /**
40
- * Adjusts the form field to go inline with a content. This also silences the
41
- * given `validations` prop. You'd have to used the `onValidate` prop to
42
- * capture the message and render it somewhere else using the
43
- * `InputValidation` component.
44
- */
45
- readonly inline?: boolean;
46
- /**
47
- * Show a spinner to indicate loading
48
- */
49
- loading?: boolean;
50
- /**
51
- * Name of the input.
52
- */
53
- readonly name?: string;
54
- /**
55
- * onChange handler that provides the new value (or event)
56
- * @param newValue
57
- * @param event
58
- */
59
- onChange?(newValue: string | number | boolean | Date, event?: ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>): void;
60
- /**
61
- * Callback to get the the status and message when validating a field
62
- * @param message
63
- */
64
- onValidation?(message: string): void;
65
- /**
66
- * Hint text that goes above the value once the form is filled out.
67
- */
68
- readonly placeholder?: string;
69
- /**
70
- * Adjusts the interface to either have small or large spacing.
71
- */
72
- readonly size?: "small" | "large";
73
- /**
74
- * Set the component to the given value.
75
- */
76
- readonly value?: string | number | Date;
77
- }
78
- export interface FormFieldProps extends CommonFormFieldProps {
79
- actionsRef?: RefObject<FieldActionsRef>;
80
- /**
81
- * Determines if browser form autocomplete is enabled.
82
- * Note that "one-time-code" is experimental and should not be used without
83
- * consultation. "address-line1" and "address-line2" are
84
- * used for billing address information.
85
- */
86
- readonly autocomplete?: boolean | AutocompleteTypes;
87
- /**
88
- * If you need to pass in a children. For example, `<options>` inside
89
- * `<select>`.
90
- */
91
- readonly children?: ReactNode;
92
- inputRef?: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>;
93
- /**
94
- * Initial value of the input. Only use this when you need to pre-populate
95
- * the field with a data that is not controlled by the components state. If a
96
- * state is controlling the value, use the `value` prop instead.
97
- */
98
- readonly defaultValue?: string | Date;
99
- /**
100
- * Determines what kind of keyboard appears on mobile web.
101
- */
102
- readonly keyboard?: "numeric";
103
- /**
104
- * Specifies the maximum numerical or date value that a user can type
105
- */
106
- readonly max?: number;
107
- /**
108
- * Maximum character length for an input. This also changes the width to
109
- * roughly the same size as the max length. This is to communicate that the
110
- * user that on certain cases, they can only type a limited amount of
111
- * characters.
112
- */
113
- readonly maxLength?: number;
114
- /**
115
- * Adds a prefix label and icon to the field
116
- */
117
- readonly prefix?: Affix;
118
- /**
119
- * Adds a suffix label and icon with an optional action to the field
120
- */
121
- readonly suffix?: XOR<Affix, Suffix>;
122
- /**
123
- * Simplified onChange handler that only provides the new value.
124
- * @param newValue
125
- * Specifies the minimum numerical or date value that a user can type
126
- */
127
- readonly min?: number;
128
- /**
129
- * A callback to handle "Enter" keypress. This will only run
130
- * if Enter is the only key. Will not run if Shift or Control
131
- * are being held.
132
- */
133
- onEnter?(event: React.KeyboardEvent): void;
134
- /**
135
- * Focus callback.
136
- */
137
- onFocus?(): void;
138
- /**
139
- * Blur callback.
140
- */
141
- onBlur?(): void;
142
- /**
143
- * Exclusively for textareas. Specifies the visible height of a textarea.
144
- */
145
- readonly rows?: number;
146
- /**
147
- * Prevents users from editing the value.
148
- */
149
- readonly readonly?: boolean;
150
- /**
151
- * Determines what kind of form field should the component give you.
152
- */
153
- readonly type?: FormFieldTypes;
154
- /**
155
- * Show an error message above the field. This also
156
- * highlights the the field red if an error message shows up.
157
- */
158
- readonly validations?: ValidationRules;
159
- }
160
- export {};
1
+ import { ChangeEvent, ReactNode, RefObject } from "react";
2
+ import { ValidationRules } from "react-hook-form";
3
+ import { XOR } from "ts-xor";
4
+ import { IconNames } from "../Icon";
5
+ export declare type FormFieldTypes = "text" | "password" | "number" | "time" | "textarea" | "select" | "email";
6
+ export declare type AutocompleteTypes = "one-time-code" | "address-line1" | "address-line2";
7
+ export interface FieldActionsRef {
8
+ setValue(value: string | number): void;
9
+ }
10
+ export interface Affix {
11
+ readonly label?: string;
12
+ readonly icon?: IconNames;
13
+ }
14
+ interface BaseSuffix extends Affix {
15
+ readonly icon: IconNames;
16
+ onClick?(): void;
17
+ }
18
+ export interface Suffix extends BaseSuffix {
19
+ onClick(): void;
20
+ readonly ariaLabel: string;
21
+ }
22
+ export interface CommonFormFieldProps {
23
+ /**
24
+ * Determines the alignment of the text inside the input.
25
+ */
26
+ readonly align?: "center" | "right";
27
+ /**
28
+ * Further description of the input, can be used for a hint.
29
+ */
30
+ readonly description?: string;
31
+ /**
32
+ * Disable the input
33
+ */
34
+ readonly disabled?: boolean;
35
+ /**
36
+ * Highlights the field red to indicate an error.
37
+ */
38
+ readonly invalid?: boolean;
39
+ /**
40
+ * Adjusts the form field to go inline with a content. This also silences the
41
+ * given `validations` prop. You'd have to used the `onValidate` prop to
42
+ * capture the message and render it somewhere else using the
43
+ * `InputValidation` component.
44
+ */
45
+ readonly inline?: boolean;
46
+ /**
47
+ * Show a spinner to indicate loading
48
+ */
49
+ loading?: boolean;
50
+ /**
51
+ * Name of the input.
52
+ */
53
+ readonly name?: string;
54
+ /**
55
+ * onChange handler that provides the new value (or event)
56
+ * @param newValue
57
+ * @param event
58
+ */
59
+ onChange?(newValue: string | number | boolean | Date, event?: ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>): void;
60
+ /**
61
+ * Callback to get the the status and message when validating a field
62
+ * @param message
63
+ */
64
+ onValidation?(message: string): void;
65
+ /**
66
+ * Hint text that goes above the value once the form is filled out.
67
+ */
68
+ readonly placeholder?: string;
69
+ /**
70
+ * Adjusts the interface to either have small or large spacing.
71
+ */
72
+ readonly size?: "small" | "large";
73
+ /**
74
+ * Set the component to the given value.
75
+ */
76
+ readonly value?: string | number | Date;
77
+ }
78
+ export interface FormFieldProps extends CommonFormFieldProps {
79
+ actionsRef?: RefObject<FieldActionsRef>;
80
+ /**
81
+ * Determines if browser form autocomplete is enabled.
82
+ * Note that "one-time-code" is experimental and should not be used without
83
+ * consultation. "address-line1" and "address-line2" are
84
+ * used for billing address information.
85
+ */
86
+ readonly autocomplete?: boolean | AutocompleteTypes;
87
+ /**
88
+ * If you need to pass in a children. For example, `<options>` inside
89
+ * `<select>`.
90
+ */
91
+ readonly children?: ReactNode;
92
+ inputRef?: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>;
93
+ /**
94
+ * Initial value of the input. Only use this when you need to pre-populate
95
+ * the field with a data that is not controlled by the components state. If a
96
+ * state is controlling the value, use the `value` prop instead.
97
+ */
98
+ readonly defaultValue?: string | Date;
99
+ /**
100
+ * Determines what kind of keyboard appears on mobile web.
101
+ */
102
+ readonly keyboard?: "numeric";
103
+ /**
104
+ * Specifies the maximum numerical or date value that a user can type
105
+ */
106
+ readonly max?: number;
107
+ /**
108
+ * Maximum character length for an input. This also changes the width to
109
+ * roughly the same size as the max length. This is to communicate that the
110
+ * user that on certain cases, they can only type a limited amount of
111
+ * characters.
112
+ */
113
+ readonly maxLength?: number;
114
+ /**
115
+ * Adds a prefix label and icon to the field
116
+ */
117
+ readonly prefix?: Affix;
118
+ /**
119
+ * Adds a suffix label and icon with an optional action to the field
120
+ */
121
+ readonly suffix?: XOR<Affix, Suffix>;
122
+ /**
123
+ * Simplified onChange handler that only provides the new value.
124
+ * @param newValue
125
+ * Specifies the minimum numerical or date value that a user can type
126
+ */
127
+ readonly min?: number;
128
+ /**
129
+ * A callback to handle "Enter" keypress. This will only run
130
+ * if Enter is the only key. Will not run if Shift or Control
131
+ * are being held.
132
+ */
133
+ onEnter?(event: React.KeyboardEvent): void;
134
+ /**
135
+ * Focus callback.
136
+ */
137
+ onFocus?(): void;
138
+ /**
139
+ * Blur callback.
140
+ */
141
+ onBlur?(): void;
142
+ /**
143
+ * Exclusively for textareas. Specifies the visible height of a textarea.
144
+ */
145
+ readonly rows?: number;
146
+ /**
147
+ * Prevents users from editing the value.
148
+ */
149
+ readonly readonly?: boolean;
150
+ /**
151
+ * Determines what kind of form field should the component give you.
152
+ */
153
+ readonly type?: FormFieldTypes;
154
+ /**
155
+ * Show an error message above the field. This also
156
+ * highlights the the field red if an error message shows up.
157
+ */
158
+ readonly validations?: ValidationRules;
159
+ }
160
+ export {};
@@ -1,9 +1,9 @@
1
- import { PropsWithChildren } from "react";
2
- import { FormFieldProps } from "./FormFieldTypes";
3
- interface FormFieldWrapperProps extends FormFieldProps {
4
- error: string;
5
- identifier: string;
6
- descriptionIdentifier: string;
7
- }
8
- export declare function FormFieldWrapper({ align, description, descriptionIdentifier, placeholder, value, children, invalid, error, size, prefix, suffix, max, maxLength, type, disabled, inline, identifier, }: PropsWithChildren<FormFieldWrapperProps>): JSX.Element;
9
- export {};
1
+ import { PropsWithChildren } from "react";
2
+ import { FormFieldProps } from "./FormFieldTypes";
3
+ interface FormFieldWrapperProps extends FormFieldProps {
4
+ error: string;
5
+ identifier: string;
6
+ descriptionIdentifier: string;
7
+ }
8
+ export declare function FormFieldWrapper({ align, description, descriptionIdentifier, placeholder, value, children, invalid, error, size, prefix, suffix, max, maxLength, type, disabled, inline, identifier, }: PropsWithChildren<FormFieldWrapperProps>): JSX.Element;
9
+ export {};
@@ -1,2 +1,2 @@
1
- export * from "./FormField";
2
- export * from "./FormFieldTypes";
1
+ export * from "./FormField";
2
+ export * from "./FormFieldTypes";
@@ -2,216 +2,23 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var __chunk_1 = require('../chunk-b67af3cb.js');
8
- var React = require('react');
9
- var React__default = _interopDefault(React);
10
- var __chunk_2 = require('../chunk-17e02351.js');
11
- var classnames = _interopDefault(require('classnames'));
12
- require('../Typography/index.js');
13
- var index$1 = require('../Text/index.js');
14
- require('@jobber/design');
15
- var index$2 = require('../Icon/index.js');
16
- var uuid = require('uuid');
17
- var reactHookForm = require('react-hook-form');
5
+ var FormField = require('../FormField-a92c7bac.js');
6
+ require('../tslib.es6-5b50eb8e.js');
7
+ require('react');
8
+ require('uuid');
9
+ require('react-hook-form');
10
+ require('../style-inject.es-dcee06b6.js');
11
+ require('classnames');
12
+ require('../Button-5b2f1636.js');
18
13
  require('react-router-dom');
19
- var index$5 = require('../Button/index.js');
14
+ require('../Icon-d5ad1a6d.js');
15
+ require('@jobber/design');
16
+ require('../Typography-7e542a72.js');
17
+ require('../Text-9bc093e9.js');
18
+ require('../InputValidation-24d3621a.js');
20
19
  require('framer-motion');
21
- var index$6 = require('../InputValidation/index.js');
22
- var index$7 = require('../Spinner/index.js');
23
-
24
- var css = ":root {\n /**\n * These `--public-field` properties are used in other components such\n * as InputGroup, therefore they must stay on :root\n **/\n --public-field--top-left-radius: var(--radius-base);\n --public-field--top-right-radius: var(--radius-base);\n --public-field--bottom-left-radius: var(--radius-base);\n --public-field--bottom-right-radius: var(--radius-base);\n}\n\n/**\n * Wrapper\n **/\n\n._2bOj_Hpd2VvA3mi9t4RcZO {\n --field--placeholder-color: var(--color-greyBlue--light);\n --field--placeholder-offset: 50%;\n --field--placeholder-transform: -50%;\n\n --field--textAlign: left;\n\n --field--height: var(--space-largest);\n\n --field--padding-top: calc(var(--space-base) - var(--space-smallest));\n --field--padding-bottom: calc(var(--space-base) - var(--space-smallest));\n --field--padding-left: var(--space-base);\n --field--padding-right: var(--space-base);\n\n --field--value-color: var(--color-heading);\n\n --field--border-color: var(--color-border);\n --field--background-color: var(--color-surface);\n\n --field--base-elevation: var(--elevation-base);\n --field--label-elevation: calc(var(--field--base-elevation) + 1);\n --field--postfix-elevation: calc(var(--field--base-elevation) - 1);\n --field--postfix-action-elevation: calc(var(--field--base-elevation) + 2);\n\n display: -ms-flexbox;\n\n display: flex;\n width: 100%;\n height: var(--field--height);\n border: var(--border-base) solid var(--field--border-color);\n border-radius: var(--radius-base);\n border-top-right-radius: var(--radius-base);\n border-top-right-radius: var(--radius-base);\n border-top-right-radius: var(--public-field--top-right-radius);\n border-bottom-right-radius: var(--radius-base);\n border-bottom-right-radius: var(--radius-base);\n border-bottom-right-radius: var(--public-field--bottom-right-radius);\n border-bottom-left-radius: var(--radius-base);\n border-bottom-left-radius: var(--radius-base);\n border-bottom-left-radius: var(--public-field--bottom-left-radius);\n border-top-left-radius: var(--radius-base);\n border-top-left-radius: var(--radius-base);\n border-top-left-radius: var(--public-field--top-left-radius);\n color: var(--field--value-color);\n font-size: var(--base-unit);\n background-color: var(--field--background-color);\n}\n\n._2bOj_Hpd2VvA3mi9t4RcZO * {\n box-sizing: border-box;\n}\n\n._2bOj_Hpd2VvA3mi9t4RcZO[focus-within] {\n position: relative;\n z-index: var(--field--base-elevation);\n box-shadow: var(--shadow-focus);\n}\n\n._2bOj_Hpd2VvA3mi9t4RcZO[focus-within] {\n position: relative;\n z-index: var(--field--base-elevation);\n box-shadow: var(--shadow-focus);\n}\n\n._2bOj_Hpd2VvA3mi9t4RcZO:focus-within {\n position: relative;\n z-index: var(--field--base-elevation);\n box-shadow: var(--shadow-focus);\n}\n\n.IVFKQabHAwX8Kn2aNj8gM {\n --field--label-elevation: calc(var(--field--base-elevation) - 1);\n --field--placeholder-color: var(--color-text--secondary);\n --field--placeholder-offset: var(--space-smallest);\n --field--placeholder-transform: 0;\n}\n\n._2bOj_Hpd2VvA3mi9t4RcZO._1hfSn_RRn6Enf7teCHrbV8 {\n height: auto;\n min-height: auto;\n}\n\n._3H2M7GlXG4Qh417lRbpzS7,\n._3H2M7GlXG4Qh417lRbpzS7[focus-within] {\n --field--border-color: var(--color-critical);\n}\n\n._3H2M7GlXG4Qh417lRbpzS7,\n._3H2M7GlXG4Qh417lRbpzS7[focus-within] {\n --field--border-color: var(--color-critical);\n}\n\n._3H2M7GlXG4Qh417lRbpzS7,\n._3H2M7GlXG4Qh417lRbpzS7:focus-within {\n --field--border-color: var(--color-critical);\n}\n\n._2xkImc45YUzsUp6bZ3Ik_4 {\n --field--placeholder-color: var(--color-disabled);\n --field--value-color: var(--color-disabled);\n --field--background-color: var(--color-surface--background);\n --field--border-color: var(--color-disabled--secondary);\n}\n\n._2N7Ipv_CbNRzrdEGCrptrV {\n --field--padding-left: calc(var(--space-base) - var(--space-smaller));\n --field--padding-right: calc(var(--space-base) - var(--space-smaller));\n --field--height: calc(var(--space-larger) + var(--space-smaller));\n}\n\n._2RtHPlAJG3Hp2QD9Q9cfD_ {\n --field--padding-left: var(--space-large);\n --field--padding-right: var(--space-large);\n --field--height: calc(var(--space-extravagant));\n}\n\n._3AHR56Sam4H_gp9JyzxRLl {\n display: -ms-inline-flexbox;\n display: inline-flex;\n width: auto;\n}\n\n._19KcCv1flBCB9mHUlTLkQL {\n --field--textAlign: center;\n}\n\n._1wVbgkkxLyHZUFsS-xEPlc {\n --field--textAlign: right;\n}\n\n/**\n * The custom property --formField-maxLength is getting defined inside the\n * component.\n */\n\n._1tABQjw4-IkgUE3cbBzs7r {\n width: calc(\n (var(--base-unit) * var(--formField-maxLength)) + var(--field--padding-left) +\n var(--field--padding-right)\n );\n}\n\n/**\n * Input Wrapper\n **/\n\n._1WnxEaBZY0zLsD8oKwh20b {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 1;\n flex: 1;\n position: relative;\n}\n\n/**\n * Input\n **/\n\n._3koQsrzZZXPVxXmmESjSG_ {\n position: relative;\n z-index: var(--field--base-elevation);\n width: 100%;\n padding-top: var(--field--padding-top);\n padding-bottom: var(--field--padding-bottom);\n padding-left: var(--field--padding-left);\n padding-right: var(--field--padding-right);\n border: none;\n border-radius: 0;\n color: inherit;\n font-family: inherit;\n font-size: inherit;\n line-height: calc(var(--base-unit) * 1.25);\n text-align: var(--field--textAlign);\n background: transparent;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n._3koQsrzZZXPVxXmmESjSG_:focus {\n outline: none;\n}\n\n.IVFKQabHAwX8Kn2aNj8gM ._3koQsrzZZXPVxXmmESjSG_ {\n --field--padding-top: calc(var(--space-base) + var(--space-smaller));\n --field--padding-bottom: var(--space-small);\n}\n\n._1hfSn_RRn6Enf7teCHrbV8 ._3koQsrzZZXPVxXmmESjSG_ {\n resize: vertical;\n}\n\n._2N7Ipv_CbNRzrdEGCrptrV ._3koQsrzZZXPVxXmmESjSG_ {\n --field--padding-top: var(--space-small);\n --field--padding-bottom: var(--space-small);\n}\n\n.Ntcl388Qhhu4uLJc2d1Ll ._3koQsrzZZXPVxXmmESjSG_ {\n --field--padding-top: 0;\n --field--padding-bottom: 0;\n}\n\n.IVFKQabHAwX8Kn2aNj8gM.Ntcl388Qhhu4uLJc2d1Ll:not(._2N7Ipv_CbNRzrdEGCrptrV) ._3koQsrzZZXPVxXmmESjSG_ {\n --field--padding-top: var(--space-small);\n}\n\n/**\n * Label\n **/\n\n.ktPFw5_r1v4MB-Ts5rPTG {\n position: absolute;\n top: var(--field--placeholder-offset);\n z-index: var(--field--label-elevation);\n width: 100%;\n padding-left: var(--field--padding-left);\n padding-right: var(--field--padding-right);\n overflow: hidden;\n color: var(--field--placeholder-color);\n line-height: calc(var(--base-unit) * 1.25);\n text-align: var(--field--textAlign);\n text-overflow: ellipsis;\n white-space: nowrap;\n -webkit-transform: translateY(var(--field--placeholder-transform));\n transform: translateY(var(--field--placeholder-transform));\n transition: all var(--timing-quick);\n}\n\n.IVFKQabHAwX8Kn2aNj8gM .ktPFw5_r1v4MB-Ts5rPTG {\n font-size: calc(var(--base-unit) * 0.875);\n}\n\n._1hfSn_RRn6Enf7teCHrbV8 .ktPFw5_r1v4MB-Ts5rPTG {\n top: var(--field--padding-top);\n -webkit-transform: translateY(0);\n transform: translateY(0);\n}\n\n._1hfSn_RRn6Enf7teCHrbV8.IVFKQabHAwX8Kn2aNj8gM .ktPFw5_r1v4MB-Ts5rPTG {\n top: var(--space-smallest);\n}\n\n._2N7Ipv_CbNRzrdEGCrptrV.IVFKQabHAwX8Kn2aNj8gM .ktPFw5_r1v4MB-Ts5rPTG {\n display: none;\n}\n\n._2RtHPlAJG3Hp2QD9Q9cfD_.IVFKQabHAwX8Kn2aNj8gM .ktPFw5_r1v4MB-Ts5rPTG {\n top: var(--space-small);\n}\n\n/**\n * Postfix\n **/\n\n._1yJbSG5N0hfPjPkrih4Q99 {\n position: absolute;\n top: 50%;\n right: var(--space-base);\n z-index: var(--field--postfix-elevation);\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n}\n\n/**\n * Affix\n **/\n\n._1EBMzQ2qM74AhLWsJH_VD7 {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-align: center;\n align-items: center;\n -ms-flex-pack: center;\n justify-content: center;\n margin: 0 calc(var(--field--padding-left) * -1) 0 0;\n padding: 0 var(--field--padding-right) 0 var(--field--padding-left);\n}\n\n@supports (aspect-ratio: 1/1) {\n ._1EBMzQ2qM74AhLWsJH_VD7 {\n /*\n * disabling property-no-unknown here as this is a real property\n * that stylelint just doesn't know about. We may be able to remove\n * this when we update our stylelint to not care about IE11.\n */\n /* stylelint-disable-next-line property-no-unknown */\n aspect-ratio: 1/1;\n padding: 0;\n }\n}\n\n._1EBMzQ2qM74AhLWsJH_VD7._2k-tb4HuwDpSggx3JEm4Rp {\n margin: 0 0 0 calc(var(--field--padding-right) * -1);\n}\n\n._1EBMzQ2qM74AhLWsJH_VD7._1Pm2Qo4Aw45IfKYq1qX4CW {\n position: relative;\n z-index: var(--field--postfix-action-elevation);\n}\n\n._2PE8Igv1VLxZ4mpQc6iiR4 {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-align: center;\n align-items: center;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n margin: 0 calc((var(--field--padding-left) - var(--space-smallest)) * -1) 0 0;\n padding: 0 0 0 var(--field--padding-left);\n}\n\n._2PE8Igv1VLxZ4mpQc6iiR4._2k-tb4HuwDpSggx3JEm4Rp {\n margin: 0 0 0 calc((var(--field--padding-left) - var(--space-smallest)) * -1);\n padding: 0 var(--field--padding-left) 0 0;\n}\n\n.IVFKQabHAwX8Kn2aNj8gM:not(._2N7Ipv_CbNRzrdEGCrptrV) ._2PE8Igv1VLxZ4mpQc6iiR4 {\n padding-top: calc(var(--field--padding-top) - 2px);\n}\n\n._1iN0xB6nTG687YOOopowf {\n margin-top: var(--space-smaller);\n}\n";
25
- var styles = {"wrapper":"_2bOj_Hpd2VvA3mi9t4RcZO","miniLabel":"IVFKQabHAwX8Kn2aNj8gM","textarea":"_1hfSn_RRn6Enf7teCHrbV8","invalid":"_3H2M7GlXG4Qh417lRbpzS7","disabled":"_2xkImc45YUzsUp6bZ3Ik_4","small":"_2N7Ipv_CbNRzrdEGCrptrV","large":"_2RtHPlAJG3Hp2QD9Q9cfD_","inline-left":"_3AHR56Sam4H_gp9JyzxRLl","inline-right":"_3AHR56Sam4H_gp9JyzxRLl","inline":"_3AHR56Sam4H_gp9JyzxRLl","center":"_19KcCv1flBCB9mHUlTLkQL","right":"_1wVbgkkxLyHZUFsS-xEPlc","maxLength":"_1tABQjw4-IkgUE3cbBzs7r","inputWrapper":"_1WnxEaBZY0zLsD8oKwh20b","input":"_3koQsrzZZXPVxXmmESjSG_","select":"Ntcl388Qhhu4uLJc2d1Ll","label":"ktPFw5_r1v4MB-Ts5rPTG","postfix":"_1yJbSG5N0hfPjPkrih4Q99","affixIcon":"_1EBMzQ2qM74AhLWsJH_VD7","suffix":"_2k-tb4HuwDpSggx3JEm4Rp","hasAction":"_1Pm2Qo4Aw45IfKYq1qX4CW","affixLabel":"_2PE8Igv1VLxZ4mpQc6iiR4","description":"_1iN0xB6nTG687YOOopowf"};
26
- __chunk_2.styleInject(css);
27
-
28
- function AffixLabel(_a) {
29
- var _b;
30
- var label = _a.label, _c = _a.variation, variation = _c === void 0 ? "prefix" : _c, labelRef = _a.labelRef;
31
- var affixLabelClass = classnames(styles.affixLabel, (_b = {},
32
- _b[styles.suffix] = variation === "suffix",
33
- _b));
34
- return (React__default.createElement("div", { ref: labelRef, className: affixLabelClass }, label));
35
- }
36
- function AffixIcon(_a) {
37
- var _b;
38
- var icon = _a.icon, onClick = _a.onClick, ariaLabel = _a.ariaLabel, _c = _a.variation, variation = _c === void 0 ? "prefix" : _c, size = _a.size;
39
- var affixIconClass = classnames(styles.affixIcon, (_b = {},
40
- _b[styles.suffix] = variation === "suffix",
41
- _b[styles.hasAction] = onClick,
42
- _b));
43
- var iconSize = size === "small" ? "small" : "base";
44
- if (!icon)
45
- return React__default.createElement(React__default.Fragment, null);
46
- return (React__default.createElement("div", { className: affixIconClass }, onClick ? (React__default.createElement(index$5.Button
47
- /**
48
- * We can cast the ariaLabel here as a `Suffix`
49
- * requires an ariaLabel if there is an action
50
- */
51
- , {
52
- /**
53
- * We can cast the ariaLabel here as a `Suffix`
54
- * requires an ariaLabel if there is an action
55
- */
56
- ariaLabel: ariaLabel, icon: icon, onClick: onClick, variation: "subtle", type: "tertiary", size: iconSize })) : (React__default.createElement(index$2.Icon, { name: icon, size: iconSize, color: "greyBlue" }))));
57
- }
58
-
59
- function FormFieldDescription(_a) {
60
- var id = _a.id, description = _a.description;
61
- return (React__default.createElement("div", { id: id, className: styles.description },
62
- React__default.createElement(index$1.Text, { variation: "subdued" }, description)));
63
- }
64
-
65
- function FormFieldWrapper(_a) {
66
- var _b, _c;
67
- var align = _a.align, description = _a.description, descriptionIdentifier = _a.descriptionIdentifier, placeholder = _a.placeholder, value = _a.value, children = _a.children, invalid = _a.invalid, error = _a.error, size = _a.size, prefix = _a.prefix, suffix = _a.suffix, max = _a.max, maxLength = _a.maxLength, type = _a.type, disabled = _a.disabled, inline = _a.inline, identifier = _a.identifier;
68
- var wrapperClasses = classnames(styles.wrapper, size && styles[size], align && styles[align], (_b = {},
69
- _b[styles.miniLabel] = (placeholder && value !== "") ||
70
- (placeholder && type === "select") ||
71
- (placeholder && type === "time"),
72
- _b[styles.textarea] = type === "textarea",
73
- _b[styles.invalid] = invalid !== null && invalid !== void 0 ? invalid : error,
74
- _b[styles.disabled] = disabled,
75
- _b[styles.inline] = inline,
76
- _b[styles.maxLength] = maxLength,
77
- _b[styles.select] = type === "select",
78
- _b));
79
- var wrapperInlineStyle = (_c = {},
80
- _c["--formField-maxLength"] = maxLength || max,
81
- _c);
82
- var prefixRef = React.useRef();
83
- var suffixRef = React.useRef();
84
- var _d = __chunk_1.__read(React.useState({
85
- paddingLeft: undefined,
86
- paddingRight: undefined,
87
- }), 2), labelStyle = _d[0], setLabelStyle = _d[1];
88
- React.useEffect(function () {
89
- setLabelStyle(getAffixPaddding);
90
- }, [value]);
91
- return (React__default.createElement(React__default.Fragment, null,
92
- React__default.createElement("div", { className: wrapperClasses, style: wrapperInlineStyle },
93
- (prefix === null || prefix === void 0 ? void 0 : prefix.icon) && React__default.createElement(AffixIcon, __chunk_1.__assign({}, prefix, { size: size })),
94
- React__default.createElement("div", { className: styles.inputWrapper },
95
- React__default.createElement("label", { className: styles.label, htmlFor: identifier, style: (prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) || (suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) ? labelStyle : undefined }, placeholder),
96
- (prefix === null || prefix === void 0 ? void 0 : prefix.label) && React__default.createElement(AffixLabel, __chunk_1.__assign({}, prefix, { labelRef: prefixRef })),
97
- children,
98
- (suffix === null || suffix === void 0 ? void 0 : suffix.label) && (React__default.createElement(AffixLabel, __chunk_1.__assign({}, suffix, { labelRef: suffixRef, variation: "suffix" })))),
99
- (suffix === null || suffix === void 0 ? void 0 : suffix.icon) && (React__default.createElement(AffixIcon, __chunk_1.__assign({}, suffix, { variation: "suffix", size: size })))),
100
- description && !inline && (React__default.createElement(FormFieldDescription, { id: descriptionIdentifier, description: description })),
101
- error && !inline && React__default.createElement(index$6.InputValidation, { message: error })));
102
- function getAffixPaddding() {
103
- var hasValue = value !== "";
104
- var newPadding = {
105
- paddingLeft: undefined,
106
- paddingRight: undefined,
107
- };
108
- if ((prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) && !hasValue) {
109
- var offsetWidth = (prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current).offsetWidth;
110
- newPadding.paddingLeft = offset(offsetWidth);
111
- }
112
- if ((suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) && !hasValue) {
113
- var offsetWidth = (suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current).offsetWidth;
114
- newPadding.paddingRight = offset(offsetWidth);
115
- }
116
- function offset(width) {
117
- return "calc(" + width + "px + var(--space-smallest)";
118
- }
119
- return newPadding;
120
- }
121
- }
20
+ require('../Spinner-18d3dee6.js');
122
21
 
123
- function FormFieldPostFix(_a) {
124
- var variation = _a.variation;
125
- return (React__default.createElement("span", { className: styles.postfix }, variation === "select" ? (React__default.createElement(index$2.Icon, { name: "arrowDown" })) : (React__default.createElement(index$7.Spinner, { size: "small" }))));
126
- }
127
22
 
128
- function FormField(props) {
129
- var _a;
130
- var actionsRef = props.actionsRef, _b = props.autocomplete, autocomplete = _b === void 0 ? true : _b, children = props.children, defaultValue = props.defaultValue, description = props.description, disabled = props.disabled, inputRef = props.inputRef, inline = props.inline, keyboard = props.keyboard, max = props.max, maxLength = props.maxLength, min = props.min, name = props.name, readonly = props.readonly, rows = props.rows, loading = props.loading, _c = props.type, type = _c === void 0 ? "text" : _c, validations = props.validations, value = props.value, onChange = props.onChange, onEnter = props.onEnter, onFocus = props.onFocus, onBlur = props.onBlur, onValidation = props.onValidation;
131
- var _d = reactHookForm.useFormContext() != undefined
132
- ? reactHookForm.useFormContext()
133
- : reactHookForm.useForm({ mode: "onTouched" }), control = _d.control, errors = _d.errors, setValue = _d.setValue, watch = _d.watch;
134
- var _e = __chunk_1.__read(React.useState(uuid.v1()), 1), identifier = _e[0];
135
- var _f = __chunk_1.__read(React.useState("descriptionUUID--" + uuid.v1()), 1), descriptionIdentifier = _f[0];
136
- /**
137
- * Generate a name if one is not supplied, this is the name
138
- * that will be used for react-hook-form and not neccessarily
139
- * attached to the DOM
140
- */
141
- var _g = __chunk_1.__read(React.useState(name ? name : "generatedName--" + identifier), 1), controlledName = _g[0];
142
- React.useEffect(function () {
143
- if (value != undefined) {
144
- setValue(controlledName, value);
145
- }
146
- }, [value, watch(controlledName)]);
147
- React.useImperativeHandle(actionsRef, function () { return ({
148
- setValue: function (newValue) {
149
- setValue(controlledName, newValue);
150
- },
151
- }); });
152
- var error = errors[controlledName] && errors[controlledName].message;
153
- React.useEffect(function () { return handleValidation(); }, [error]);
154
- return (React__default.createElement(reactHookForm.Controller, { control: control, name: controlledName, rules: __chunk_1.__assign({}, validations), defaultValue: (_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : "", render: function (_a) {
155
- var onControllerChange = _a.onChange, onControllerBlur = _a.onBlur, controllerName = _a.name, rest = __chunk_1.__rest(_a, ["onChange", "onBlur", "name"]);
156
- var fieldProps = __chunk_1.__assign(__chunk_1.__assign(__chunk_1.__assign({}, rest), { id: identifier, className: styles.input, name: (validations || name) && controllerName, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange }), (description &&
157
- !inline && { "aria-describedby": descriptionIdentifier }));
158
- var textFieldProps = __chunk_1.__assign(__chunk_1.__assign({}, fieldProps), { onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown });
159
- return (React__default.createElement(FormFieldWrapper, __chunk_1.__assign({}, props, { value: rest.value, error: error, identifier: identifier, descriptionIdentifier: descriptionIdentifier }), renderField()));
160
- function renderField() {
161
- switch (type) {
162
- case "select":
163
- return (React__default.createElement(React__default.Fragment, null,
164
- React__default.createElement("select", __chunk_1.__assign({}, fieldProps), children),
165
- React__default.createElement(FormFieldPostFix, { variation: "select" })));
166
- case "textarea":
167
- return (React__default.createElement("textarea", __chunk_1.__assign({}, textFieldProps, { rows: rows, ref: inputRef })));
168
- default:
169
- return (React__default.createElement(React__default.Fragment, null,
170
- React__default.createElement("input", __chunk_1.__assign({}, textFieldProps, { autoComplete: setAutocomplete(autocomplete), type: type, maxLength: maxLength, max: max, min: min, ref: inputRef })),
171
- loading && React__default.createElement(FormFieldPostFix, { variation: "spinner" })));
172
- }
173
- }
174
- function handleChange(event) {
175
- var newValue;
176
- newValue = event.currentTarget.value;
177
- if (type === "number" && newValue.length > 0) {
178
- newValue = parseFloat(newValue);
179
- }
180
- onChange && onChange(newValue, event);
181
- onControllerChange(event);
182
- }
183
- function handleKeyDown(event) {
184
- if (!onEnter)
185
- return;
186
- if (event.key !== "Enter")
187
- return;
188
- if (event.shiftKey || event.ctrlKey)
189
- return;
190
- event.preventDefault();
191
- onEnter && onEnter(event);
192
- }
193
- function handleFocus(event) {
194
- var target = event.currentTarget;
195
- setTimeout(function () { return readonly && target.select(); });
196
- onFocus && onFocus();
197
- }
198
- function handleBlur() {
199
- onBlur && onBlur();
200
- onControllerBlur();
201
- }
202
- } }));
203
- function handleValidation() {
204
- onValidation && onValidation(error);
205
- }
206
- }
207
- function setAutocomplete(autocompleteSetting) {
208
- if (autocompleteSetting === true) {
209
- return undefined;
210
- }
211
- else if (autocompleteSetting === false) {
212
- return "autocomplete-off";
213
- }
214
- return autocompleteSetting;
215
- }
216
23
 
217
- exports.FormField = FormField;
24
+ exports.FormField = FormField.FormField;