@jobber/components 8.6.0 → 8.7.0

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 (75) hide show
  1. package/dist/Autocomplete/index.cjs +1 -2
  2. package/dist/Autocomplete/index.mjs +1 -2
  3. package/dist/Autocomplete-cjs.js +1 -3
  4. package/dist/Autocomplete-es.js +1 -3
  5. package/dist/DataList/components/DataListSearch/index.cjs +1 -2
  6. package/dist/DataList/components/DataListSearch/index.mjs +1 -2
  7. package/dist/DataList/index.cjs +1 -2
  8. package/dist/DataList/index.mjs +1 -2
  9. package/dist/DataTable/index.cjs +1 -2
  10. package/dist/DataTable/index.mjs +1 -2
  11. package/dist/FormField/FormFieldTypes.d.ts +1 -10
  12. package/dist/FormField/index.cjs +4 -13
  13. package/dist/FormField/index.d.ts +0 -4
  14. package/dist/FormField/index.mjs +4 -9
  15. package/dist/InputDate/index.cjs +1 -2
  16. package/dist/InputDate/index.mjs +1 -2
  17. package/dist/InputEmail/index.cjs +0 -1
  18. package/dist/InputEmail/index.mjs +0 -1
  19. package/dist/InputEmail-cjs.js +1 -3
  20. package/dist/InputEmail-es.js +1 -3
  21. package/dist/InputPhoneNumber/InputMask.d.ts +0 -38
  22. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +1 -2
  23. package/dist/InputPhoneNumber/index.cjs +1 -2
  24. package/dist/InputPhoneNumber/index.mjs +1 -2
  25. package/dist/InputPhoneNumber-cjs.js +11 -12
  26. package/dist/InputPhoneNumber-es.js +11 -12
  27. package/dist/InputText/index.cjs +1 -2
  28. package/dist/InputText/index.mjs +1 -2
  29. package/dist/InputText-cjs.js +3 -5
  30. package/dist/InputText-es.js +3 -5
  31. package/dist/InputTime/index.cjs +0 -1
  32. package/dist/InputTime/index.mjs +0 -1
  33. package/dist/InputTime-cjs.js +1 -2
  34. package/dist/InputTime-es.js +1 -2
  35. package/dist/Select/index.cjs +1 -2
  36. package/dist/Select/index.mjs +1 -2
  37. package/dist/Select-cjs.js +3 -5
  38. package/dist/Select-es.js +3 -5
  39. package/dist/docs/Button/Button.md +1 -1
  40. package/dist/docs/errors/errors.md +1 -1
  41. package/dist/docs/index.md +0 -3
  42. package/dist/index.cjs +2 -12
  43. package/dist/index.d.mts +0 -2
  44. package/dist/index.d.ts +0 -2
  45. package/dist/index.mjs +2 -6
  46. package/dist/useAtlantisFormFieldName-cjs.js +3 -3
  47. package/dist/useAtlantisFormFieldName-es.js +3 -3
  48. package/dist/utils/meta/meta.json +0 -3
  49. package/package.json +3 -15
  50. package/rollup.config.mjs +0 -1
  51. package/Form.d.ts +0 -1
  52. package/Form.js +0 -17
  53. package/InputPassword.d.ts +0 -1
  54. package/InputPassword.js +0 -17
  55. package/dist/Form/Form.d.ts +0 -18
  56. package/dist/Form/index.cjs +0 -10
  57. package/dist/Form/index.d.ts +0 -1
  58. package/dist/Form/index.mjs +0 -4
  59. package/dist/Form-cjs.js +0 -43
  60. package/dist/Form-es.js +0 -41
  61. package/dist/FormField/FormField.d.ts +0 -3
  62. package/dist/FormField/hooks/useAtlantisFormField.d.ts +0 -91
  63. package/dist/FormField/hooks/useAtlantisFormFieldActions.d.ts +0 -22
  64. package/dist/FormField/hooks/useAtlantisReactHookForm.d.ts +0 -20
  65. package/dist/FormField-cjs.js +0 -209
  66. package/dist/FormField-es.js +0 -204
  67. package/dist/InputPassword/InputPassword.d.ts +0 -13
  68. package/dist/InputPassword/index.cjs +0 -27
  69. package/dist/InputPassword/index.d.ts +0 -1
  70. package/dist/InputPassword/index.mjs +0 -21
  71. package/dist/InputPassword-cjs.js +0 -28
  72. package/dist/InputPassword-es.js +0 -26
  73. package/dist/docs/Form/Form.md +0 -106
  74. package/dist/docs/FormField/FormField.md +0 -92
  75. package/dist/docs/InputPassword/InputPassword.md +0 -51
@@ -1,20 +0,0 @@
1
- import type { FormFieldProps } from "../FormFieldTypes";
2
- interface useAtlantisReactHookFormProps extends Pick<FormFieldProps, "actionsRef" | "defaultValue" | "value" | "validations" | "inputRef"> {
3
- name: string;
4
- }
5
- /**
6
- * Hook used to manage the form state of a field through react-hook-form
7
- */
8
- export declare function useAtlantisReactHookForm({ actionsRef, name, defaultValue, value, validations, inputRef, }: useAtlantisReactHookFormProps): {
9
- inputRefs: import("react").RefCallback<any>;
10
- useControllerField: {
11
- value: any;
12
- disabled?: boolean;
13
- name: string;
14
- };
15
- setValue: import("react-hook-form").UseFormSetValue<import("react-hook-form").FieldValues>;
16
- errorMessage: string;
17
- onControllerChange: (...event: any[]) => void;
18
- onControllerBlur: import("react-hook-form").Noop;
19
- };
20
- export {};
@@ -1,209 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var FormFieldWrapper = require('./FormFieldWrapper-cjs.js');
5
- var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
6
- var classnames = require('classnames');
7
- var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
8
- var tslib_es6 = require('./tslib.es6-cjs.js');
9
- var reactHookForm = require('react-hook-form');
10
- var mergeRefs = require('./mergeRefs-cjs.js');
11
-
12
- /**
13
- * Combines the actions from the props of the FormField with the actions from react-hook-form. This is used to
14
- * manage the form state of a field through react-hook-form while providing support for additional callbacks
15
- */
16
- function useAtlantisFormFieldActions({ name, onChange, inputRef, onControllerChange, onControllerBlur, onEnter, readonly, type, setValue, onFocus, onBlur, onValidation, }) {
17
- function handleClear() {
18
- var _a;
19
- handleBlur();
20
- setValue(name, "", { shouldValidate: true });
21
- onChange && onChange("");
22
- (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
23
- }
24
- function handleChange(event) {
25
- let newValue;
26
- newValue = event.currentTarget.value;
27
- if (type === "number" && newValue.length > 0) {
28
- newValue = parseFloat(newValue);
29
- }
30
- onChange && onChange(newValue, event);
31
- onControllerChange(event);
32
- }
33
- function handleKeyDown(event) {
34
- if (!onEnter)
35
- return;
36
- if (event.key !== "Enter")
37
- return;
38
- if (event.shiftKey || event.ctrlKey)
39
- return;
40
- event.preventDefault();
41
- onEnter && onEnter(event);
42
- }
43
- function handleFocus(event) {
44
- const target = event.currentTarget;
45
- if (target.select) {
46
- setTimeout(() => readonly && target.select());
47
- }
48
- onFocus && onFocus();
49
- }
50
- function handleBlur() {
51
- onBlur && onBlur();
52
- onControllerBlur();
53
- }
54
- function handleValidation(message) {
55
- onValidation && onValidation(message);
56
- }
57
- return {
58
- handleClear,
59
- handleChange,
60
- handleKeyDown,
61
- handleFocus,
62
- handleBlur,
63
- handleValidation,
64
- };
65
- }
66
-
67
- /**
68
- * Provides the props for the html fields rendered by the FormField component
69
- */
70
- function useAtlantisFormField({ id, nameProp, name, useControllerField: useControllerField, description, disabled, readonly, keyboard, autofocus, pattern, type, value, handleChange, handleBlur, handleFocus, inline, validations, handleKeyDown, handleValidation, errorMessage, }) {
71
- const descriptionIdentifier = `descriptionUUID--${id}`;
72
- const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(FormFieldWrapper.formFieldStyles.input, {
73
- [FormFieldWrapper.formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
74
- }), name: (validations || nameProp) && name, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, autoFocus: autofocus }), (description &&
75
- !inline && { "aria-describedby": descriptionIdentifier }));
76
- const textFieldProps = Object.assign(Object.assign({}, fieldProps), { autoFocus: autofocus, onKeyDown: handleKeyDown });
77
- React.useEffect(() => handleValidation(errorMessage), [errorMessage]);
78
- return { textFieldProps, fieldProps, descriptionIdentifier };
79
- }
80
- function shouldAddPhoneNumberClass(type, value, pattern) {
81
- return type === "tel" && !value && pattern && pattern[0] === "(";
82
- }
83
-
84
- /**
85
- * Hook used to manage the form state of a field through react-hook-form
86
- */
87
- function useAtlantisReactHookForm({ actionsRef, name, defaultValue, value, validations, inputRef, }) {
88
- var _a;
89
- const formContext = reactHookForm.useFormContext();
90
- // If there isn't a Form Context being provided, get a form for this field.
91
- const { control, setValue, watch } = formContext !== null && formContext !== void 0 ? formContext : reactHookForm.useForm({ mode: "onTouched" });
92
- React.useImperativeHandle(actionsRef, () => ({
93
- setValue: newValue => {
94
- setValue(name, newValue, { shouldValidate: true });
95
- },
96
- }));
97
- const { field, fieldState: { error }, } = reactHookForm.useController({
98
- name,
99
- control,
100
- rules: validations,
101
- defaultValue: (_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : "",
102
- });
103
- const { onChange, onBlur, ref: fieldRef } = field, useControllerField = tslib_es6.__rest(field, ["onChange", "onBlur", "ref"]);
104
- React.useEffect(() => {
105
- if (value != undefined) {
106
- setValue(name, value);
107
- }
108
- }, [value, watch(name)]);
109
- const inputRefs = mergeRefs.mergeRefs([inputRef, fieldRef]);
110
- return {
111
- inputRefs,
112
- useControllerField,
113
- setValue,
114
- errorMessage: (error === null || error === void 0 ? void 0 : error.message) || "",
115
- onControllerChange: onChange,
116
- onControllerBlur: onBlur,
117
- };
118
- }
119
-
120
- function FormField(props) {
121
- // Warning: do not move useId into FormFieldInternal. This must be here to avoid
122
- // a problem where useId isn't stable across multiple StrictMode renders.
123
- // https://github.com/facebook/react/issues/27103
124
- const generatedId = React.useId();
125
- const id = props.id || generatedId;
126
- return React.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
127
- }
128
- function FormFieldInternal(props) {
129
- var _a;
130
- const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
131
- const { name } = useAtlantisFormFieldName.useAtlantisFormFieldName({ id, nameProp });
132
- const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
133
- actionsRef,
134
- name,
135
- defaultValue,
136
- value,
137
- validations,
138
- inputRef,
139
- });
140
- const { handleValidation, handleBlur, handleChange, handleClear, handleFocus, handleKeyDown, } = useAtlantisFormFieldActions({
141
- inputRef,
142
- onChange,
143
- onEnter,
144
- readonly,
145
- type,
146
- onFocus,
147
- setValue,
148
- onBlur,
149
- onValidation,
150
- onControllerBlur,
151
- onControllerChange,
152
- name,
153
- });
154
- const { textFieldProps, fieldProps, descriptionIdentifier } = useAtlantisFormField({
155
- id,
156
- useControllerField,
157
- name,
158
- nameProp,
159
- description,
160
- validations: !!validations,
161
- disabled,
162
- readonly,
163
- keyboard,
164
- autofocus,
165
- value,
166
- type,
167
- pattern,
168
- handleChange,
169
- handleBlur,
170
- handleFocus,
171
- inline,
172
- errorMessage,
173
- handleValidation,
174
- handleKeyDown,
175
- });
176
- // Ensure focus tracking works by providing a wrapperRef when none is passed
177
- const internalWrapperRef = React.useRef(null);
178
- const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
179
- return (React.createElement(FormFieldWrapper.FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
180
- function renderField() {
181
- switch (type) {
182
- case "select":
183
- return (React.createElement(React.Fragment, null,
184
- React.createElement("select", Object.assign({}, fieldProps), children),
185
- React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "select" })));
186
- case "textarea":
187
- return React.createElement("textarea", Object.assign({}, textFieldProps, { rows: rows, ref: inputRefs }));
188
- default:
189
- return (React.createElement(React.Fragment, null,
190
- React.createElement("input", Object.assign({}, textFieldProps, { autoComplete: setAutocomplete(autocomplete), type: type, maxLength: maxLength, max: max, min: min, ref: inputRefs, onKeyUp: onKeyUp })),
191
- loading && React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "spinner" }),
192
- children));
193
- }
194
- }
195
- }
196
- function setAutocomplete(autocompleteSetting) {
197
- if (autocompleteSetting === true) {
198
- return undefined;
199
- }
200
- else if (autocompleteSetting === false) {
201
- return "off";
202
- }
203
- return autocompleteSetting;
204
- }
205
-
206
- exports.FormField = FormField;
207
- exports.useAtlantisFormField = useAtlantisFormField;
208
- exports.useAtlantisFormFieldActions = useAtlantisFormFieldActions;
209
- exports.useAtlantisReactHookForm = useAtlantisReactHookForm;
@@ -1,204 +0,0 @@
1
- import React__default, { useEffect, useImperativeHandle, useId, useRef } from 'react';
2
- import { g as formFieldStyles, c as FormFieldWrapper } from './FormFieldWrapper-es.js';
3
- import { F as FormFieldPostFix } from './FormFieldPostFix-es.js';
4
- import classnames from 'classnames';
5
- import { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
6
- import { _ as __rest } from './tslib.es6-es.js';
7
- import { useFormContext, useForm, useController } from 'react-hook-form';
8
- import { m as mergeRefs } from './mergeRefs-es.js';
9
-
10
- /**
11
- * Combines the actions from the props of the FormField with the actions from react-hook-form. This is used to
12
- * manage the form state of a field through react-hook-form while providing support for additional callbacks
13
- */
14
- function useAtlantisFormFieldActions({ name, onChange, inputRef, onControllerChange, onControllerBlur, onEnter, readonly, type, setValue, onFocus, onBlur, onValidation, }) {
15
- function handleClear() {
16
- var _a;
17
- handleBlur();
18
- setValue(name, "", { shouldValidate: true });
19
- onChange && onChange("");
20
- (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
21
- }
22
- function handleChange(event) {
23
- let newValue;
24
- newValue = event.currentTarget.value;
25
- if (type === "number" && newValue.length > 0) {
26
- newValue = parseFloat(newValue);
27
- }
28
- onChange && onChange(newValue, event);
29
- onControllerChange(event);
30
- }
31
- function handleKeyDown(event) {
32
- if (!onEnter)
33
- return;
34
- if (event.key !== "Enter")
35
- return;
36
- if (event.shiftKey || event.ctrlKey)
37
- return;
38
- event.preventDefault();
39
- onEnter && onEnter(event);
40
- }
41
- function handleFocus(event) {
42
- const target = event.currentTarget;
43
- if (target.select) {
44
- setTimeout(() => readonly && target.select());
45
- }
46
- onFocus && onFocus();
47
- }
48
- function handleBlur() {
49
- onBlur && onBlur();
50
- onControllerBlur();
51
- }
52
- function handleValidation(message) {
53
- onValidation && onValidation(message);
54
- }
55
- return {
56
- handleClear,
57
- handleChange,
58
- handleKeyDown,
59
- handleFocus,
60
- handleBlur,
61
- handleValidation,
62
- };
63
- }
64
-
65
- /**
66
- * Provides the props for the html fields rendered by the FormField component
67
- */
68
- function useAtlantisFormField({ id, nameProp, name, useControllerField: useControllerField, description, disabled, readonly, keyboard, autofocus, pattern, type, value, handleChange, handleBlur, handleFocus, inline, validations, handleKeyDown, handleValidation, errorMessage, }) {
69
- const descriptionIdentifier = `descriptionUUID--${id}`;
70
- const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(formFieldStyles.input, {
71
- [formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
72
- }), name: (validations || nameProp) && name, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, autoFocus: autofocus }), (description &&
73
- !inline && { "aria-describedby": descriptionIdentifier }));
74
- const textFieldProps = Object.assign(Object.assign({}, fieldProps), { autoFocus: autofocus, onKeyDown: handleKeyDown });
75
- useEffect(() => handleValidation(errorMessage), [errorMessage]);
76
- return { textFieldProps, fieldProps, descriptionIdentifier };
77
- }
78
- function shouldAddPhoneNumberClass(type, value, pattern) {
79
- return type === "tel" && !value && pattern && pattern[0] === "(";
80
- }
81
-
82
- /**
83
- * Hook used to manage the form state of a field through react-hook-form
84
- */
85
- function useAtlantisReactHookForm({ actionsRef, name, defaultValue, value, validations, inputRef, }) {
86
- var _a;
87
- const formContext = useFormContext();
88
- // If there isn't a Form Context being provided, get a form for this field.
89
- const { control, setValue, watch } = formContext !== null && formContext !== void 0 ? formContext : useForm({ mode: "onTouched" });
90
- useImperativeHandle(actionsRef, () => ({
91
- setValue: newValue => {
92
- setValue(name, newValue, { shouldValidate: true });
93
- },
94
- }));
95
- const { field, fieldState: { error }, } = useController({
96
- name,
97
- control,
98
- rules: validations,
99
- defaultValue: (_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : "",
100
- });
101
- const { onChange, onBlur, ref: fieldRef } = field, useControllerField = __rest(field, ["onChange", "onBlur", "ref"]);
102
- useEffect(() => {
103
- if (value != undefined) {
104
- setValue(name, value);
105
- }
106
- }, [value, watch(name)]);
107
- const inputRefs = mergeRefs([inputRef, fieldRef]);
108
- return {
109
- inputRefs,
110
- useControllerField,
111
- setValue,
112
- errorMessage: (error === null || error === void 0 ? void 0 : error.message) || "",
113
- onControllerChange: onChange,
114
- onControllerBlur: onBlur,
115
- };
116
- }
117
-
118
- function FormField(props) {
119
- // Warning: do not move useId into FormFieldInternal. This must be here to avoid
120
- // a problem where useId isn't stable across multiple StrictMode renders.
121
- // https://github.com/facebook/react/issues/27103
122
- const generatedId = useId();
123
- const id = props.id || generatedId;
124
- return React__default.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
125
- }
126
- function FormFieldInternal(props) {
127
- var _a;
128
- const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
129
- const { name } = useAtlantisFormFieldName({ id, nameProp });
130
- const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
131
- actionsRef,
132
- name,
133
- defaultValue,
134
- value,
135
- validations,
136
- inputRef,
137
- });
138
- const { handleValidation, handleBlur, handleChange, handleClear, handleFocus, handleKeyDown, } = useAtlantisFormFieldActions({
139
- inputRef,
140
- onChange,
141
- onEnter,
142
- readonly,
143
- type,
144
- onFocus,
145
- setValue,
146
- onBlur,
147
- onValidation,
148
- onControllerBlur,
149
- onControllerChange,
150
- name,
151
- });
152
- const { textFieldProps, fieldProps, descriptionIdentifier } = useAtlantisFormField({
153
- id,
154
- useControllerField,
155
- name,
156
- nameProp,
157
- description,
158
- validations: !!validations,
159
- disabled,
160
- readonly,
161
- keyboard,
162
- autofocus,
163
- value,
164
- type,
165
- pattern,
166
- handleChange,
167
- handleBlur,
168
- handleFocus,
169
- inline,
170
- errorMessage,
171
- handleValidation,
172
- handleKeyDown,
173
- });
174
- // Ensure focus tracking works by providing a wrapperRef when none is passed
175
- const internalWrapperRef = useRef(null);
176
- const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
177
- return (React__default.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
178
- function renderField() {
179
- switch (type) {
180
- case "select":
181
- return (React__default.createElement(React__default.Fragment, null,
182
- React__default.createElement("select", Object.assign({}, fieldProps), children),
183
- React__default.createElement(FormFieldPostFix, { variation: "select" })));
184
- case "textarea":
185
- return React__default.createElement("textarea", Object.assign({}, textFieldProps, { rows: rows, ref: inputRefs }));
186
- default:
187
- return (React__default.createElement(React__default.Fragment, null,
188
- React__default.createElement("input", Object.assign({}, textFieldProps, { autoComplete: setAutocomplete(autocomplete), type: type, maxLength: maxLength, max: max, min: min, ref: inputRefs, onKeyUp: onKeyUp })),
189
- loading && React__default.createElement(FormFieldPostFix, { variation: "spinner" }),
190
- children));
191
- }
192
- }
193
- }
194
- function setAutocomplete(autocompleteSetting) {
195
- if (autocompleteSetting === true) {
196
- return undefined;
197
- }
198
- else if (autocompleteSetting === false) {
199
- return "off";
200
- }
201
- return autocompleteSetting;
202
- }
203
-
204
- export { FormField as F, useAtlantisFormFieldActions as a, useAtlantisReactHookForm as b, useAtlantisFormField as u };
@@ -1,13 +0,0 @@
1
- import React from "react";
2
- import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
3
- interface InputPasswordProps extends CommonFormFieldProps, Pick<FormFieldProps, "autocomplete" | "onEnter" | "onFocus" | "onBlur" | "inputRef" | "validations" | "defaultValue"> {
4
- readonly value?: string;
5
- onChange?(newValue: string): void;
6
- /**
7
- * Display toggle to change the visibility of the password input
8
- * @default false
9
- */
10
- readonly hasVisibility?: boolean;
11
- }
12
- export declare function InputPassword(props: InputPasswordProps): React.JSX.Element;
13
- export {};
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var InputPassword = require('../InputPassword-cjs.js');
4
- require('react');
5
- require('../FormField-cjs.js');
6
- require('../FormFieldWrapper-cjs.js');
7
- require('@jobber/hooks');
8
- require('framer-motion');
9
- require('@jobber/design');
10
- require('classnames');
11
- require('../Button-cjs.js');
12
- require('../tslib.es6-cjs.js');
13
- require('react-router-dom');
14
- require('../Icon-cjs.js');
15
- require('../Typography-cjs.js');
16
- require('../Text-cjs.js');
17
- require('../useFormFieldFocus-cjs.js');
18
- require('../InputValidation-cjs.js');
19
- require('../FormFieldPostFix-cjs.js');
20
- require('../Spinner-cjs.js');
21
- require('../useAtlantisFormFieldName-cjs.js');
22
- require('react-hook-form');
23
- require('../mergeRefs-cjs.js');
24
-
25
-
26
-
27
- exports.InputPassword = InputPassword.InputPassword;
@@ -1 +0,0 @@
1
- export { InputPassword } from "./InputPassword";
@@ -1,21 +0,0 @@
1
- export { I as InputPassword } from '../InputPassword-es.js';
2
- import 'react';
3
- import '../FormField-es.js';
4
- import '../FormFieldWrapper-es.js';
5
- import '@jobber/hooks';
6
- import 'framer-motion';
7
- import '@jobber/design';
8
- import 'classnames';
9
- import '../Button-es.js';
10
- import '../tslib.es6-es.js';
11
- import 'react-router-dom';
12
- import '../Icon-es.js';
13
- import '../Typography-es.js';
14
- import '../Text-es.js';
15
- import '../useFormFieldFocus-es.js';
16
- import '../InputValidation-es.js';
17
- import '../FormFieldPostFix-es.js';
18
- import '../Spinner-es.js';
19
- import '../useAtlantisFormFieldName-es.js';
20
- import 'react-hook-form';
21
- import '../mergeRefs-es.js';
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var FormField = require('./FormField-cjs.js');
5
- require('classnames');
6
- require('./tslib.es6-cjs.js');
7
- require('react-hook-form');
8
- require('@jobber/hooks');
9
- require('framer-motion');
10
- require('@jobber/design');
11
- require('./Button-cjs.js');
12
-
13
- function InputPassword(props) {
14
- const { hasVisibility = false } = props;
15
- const [visible, setVisibility] = React.useState(false);
16
- return (React.createElement(FormField.FormField, Object.assign({}, props, (hasVisibility && {
17
- suffix: {
18
- ariaLabel: visible ? "Hide password" : "Show password",
19
- icon: visible ? "eye" : "eyeCrossed",
20
- onClick: () => setVisibility(!visible),
21
- },
22
- }), { type: visible ? "text" : "password", onChange: handleChange })));
23
- function handleChange(newValue) {
24
- props.onChange && props.onChange(newValue);
25
- }
26
- }
27
-
28
- exports.InputPassword = InputPassword;
@@ -1,26 +0,0 @@
1
- import React__default, { useState } from 'react';
2
- import { F as FormField } from './FormField-es.js';
3
- import 'classnames';
4
- import './tslib.es6-es.js';
5
- import 'react-hook-form';
6
- import '@jobber/hooks';
7
- import 'framer-motion';
8
- import '@jobber/design';
9
- import './Button-es.js';
10
-
11
- function InputPassword(props) {
12
- const { hasVisibility = false } = props;
13
- const [visible, setVisibility] = useState(false);
14
- return (React__default.createElement(FormField, Object.assign({}, props, (hasVisibility && {
15
- suffix: {
16
- ariaLabel: visible ? "Hide password" : "Show password",
17
- icon: visible ? "eye" : "eyeCrossed",
18
- onClick: () => setVisibility(!visible),
19
- },
20
- }), { type: visible ? "text" : "password", onChange: handleChange })));
21
- function handleChange(newValue) {
22
- props.onChange && props.onChange(newValue);
23
- }
24
- }
25
-
26
- export { InputPassword as I };
@@ -1,106 +0,0 @@
1
- # Form
2
-
3
- The Form component is a wrapper component that handles the submission and
4
- validation of forms.
5
-
6
- For more information about `validations` using any of the Input components, see
7
- the [InputText](../InputText/InputText.md) documentation.
8
-
9
- ## Design & usages guidelines
10
-
11
- The Form component has a lot of built-in features which rely on its internal
12
- state. To take advantage of these features, do not bypass the Form's internal
13
- state — the fields or inputs within the Form must have a `name` prop and **NOT**
14
- have a `value` and `onChange` prop.
15
-
16
- ## Content guidelines
17
-
18
- ### Inputs
19
-
20
- Form can accept various inputs and selection elements such as (but not limited
21
- to) [InputText](../InputText/InputText.md), [Select](../Select/Select.md),
22
- [Switch](../Switch/Switch.md), [Checkbox](../Checkbox/Checkbox.md), and
23
- [Chips](../Chips/Chips.md). They should be placed [Cards](../Card/Card.md) to
24
- indicate grouping when relevant, and groups of Cards can be spaced appropriately
25
- using ContentSection.
26
-
27
- ### Save Button label
28
-
29
- The `saveButtonLabel` property defaults to "Save", but should be made more
30
- verbose to add context for the user. Use the format "Save {object}", such as
31
- "Save Job". This helps clarify to the user that tapping the Save Button is not
32
- saving the single input they are editing, but the entire object.
33
-
34
- ### Form errors
35
-
36
- All error messaging should follow our
37
- [Product Vocabulary.](/content/product-vocabulary)
38
-
39
- ## Setup (mobile)
40
-
41
- Consuming apps using the mobile Form must wrap their app root with
42
- `KeyboardProvider` from `react-native-keyboard-controller`.
43
-
44
- ## Accessibility (mobile)
45
-
46
- The individual inputs are responsible for accessibility concerns such as the
47
- labels, types, values, and error messages of each input.
48
-
49
-
50
- ## Platform considerations
51
-
52
- #### iOS
53
-
54
- On iOS, the save button will be fixed to the bottom of the viewport until the
55
- keyboard is opened.
56
-
57
- Once the keyboard is open, the save button will be inline beneath the Form's
58
- inputs, unless the Form is so short that it does not scroll. In this case, the
59
- save button will remain fixed above the keyboard.
60
-
61
- This prevents the user from accidentally submitting the Form before they have
62
- completed entering all the relevant information for their work, especially since
63
- many data points in Jobber cannot be edited once saved.
64
-
65
- #### Android
66
-
67
- On Android, the save button will always be inline with the contents of the Form.
68
-
69
- ### Error handling
70
-
71
- #### Server-side errors
72
-
73
- Server-side error messages will be displayed in a banner at the top the Form
74
- upon a failed submission attempt. These are errors where something has gone
75
- wrong with the data either on the way to, or on the way back from, our servers.
76
- If the user can address the errors, inform them how to do so in the banner.
77
- Otherwise, a generic message informing the user that something went wrong is an
78
- appropriate fallback.
79
-
80
- Note: When a server-side error happens, inside the `onSubmit` function, an error
81
- must be thrown. Throwing an error inside the `onSubmit` function will ensure
82
- that your `onSubmitError` function is called instead of your `onSubmitSuccess`.
83
-
84
- #### Client-side errors
85
-
86
- Client-side errors are issues that we can catch and inform the user of before
87
- they attempt to submit the Form, such as a required field left blank or an
88
- incorrect email address format.
89
-
90
- Error messages for individual inputs should appear inline on each impacted
91
- input. Form will automatically scroll to the first invalid (has an error)
92
- element and display the error message.
93
-
94
- When an error occurs, either server-side or client-side, Form will announce the
95
- message to screen-readers and set focus to the impacted portion of the Form.
96
-
97
-
98
- ## Props
99
-
100
- ### Web
101
-
102
- | Prop | Type | Required | Default | Description |
103
- |------|------|----------|---------|-------------|
104
- | `onStateChange` | `(formState: { isDirty: boolean; isValid: boolean; }) => void` | No | — | |
105
- | `onSubmit` | `() => void` | No | — | Callback for when the form has been sucessfully submitted. |
106
- | `ref` | `Ref<FormRef>` | No | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (... |