@bonlineza/luxity-lib 2.39.6 → 2.39.7

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 (92) hide show
  1. package/Accordion.js +352 -342
  2. package/AddInterest.js +3141 -3135
  3. package/AddProductInterest.js +7584 -1011
  4. package/BrandSelector.js +861 -854
  5. package/Checkbox.js +250 -240
  6. package/CheckboxButton.js +236 -229
  7. package/CommunicationPreferenceOptionsRenderer.js +568 -560
  8. package/CommunicationPreferenceSection.js +659 -651
  9. package/CommunicationPreferences.js +2402 -2394
  10. package/ConditionSelector.js +859 -852
  11. package/CountryCodeSelect.js +6650 -79
  12. package/CurrencyInputFormatter.js +96 -86
  13. package/CurrencySelect.js +227 -219
  14. package/DropdownSelector.js +6820 -211
  15. package/GALink.js +51 -43
  16. package/GenderSelector.js +362 -355
  17. package/GraphQLDropdownSelector.js +11878 -5308
  18. package/GraphQLMultiSelector.js +601 -593
  19. package/IconHeader.js +126 -118
  20. package/IconWrapper.js +25 -17
  21. package/InterestCatSelector.js +432 -424
  22. package/InterestItem.js +470 -462
  23. package/Interests.js +11286 -4716
  24. package/InterestsSubheading.js +41 -33
  25. package/InvertedTextButton.js +175 -167
  26. package/LuxityAppSideNav.js +189 -181
  27. package/LuxityDesktopHeader.js +1363 -1355
  28. package/LuxityFooter.js +2236 -2228
  29. package/LuxityGraphQLDropdownSelector.js +11963 -5393
  30. package/LuxityGraphQLMultiselector.js +785 -778
  31. package/LuxityMobileHeader.js +1794 -1786
  32. package/LuxityPageReady.js +209 -199
  33. package/LuxityProductInterestItem.js +367 -359
  34. package/LuxitySideNav.js +673 -665
  35. package/MaterialSelector.js +11993 -5423
  36. package/ModelSelector.js +11993 -5423
  37. package/NotificationDropDown.js +7029 -459
  38. package/Notify.js +32 -20
  39. package/OutlinePrimaryButton.js +142 -134
  40. package/PriceRangeSelector.js +1270 -1264
  41. package/PrimaryButton.js +137 -129
  42. package/RadioButtons.js +318 -308
  43. package/RangeSlider.js +1039 -1033
  44. package/RareStepFooter.js +264 -257
  45. package/RareStepHeader.js +808 -801
  46. package/ReactSelectWrapper.js +6604 -33
  47. package/SecondaryButton.js +152 -144
  48. package/ShoeSizeRangeSelector.js +1153 -1147
  49. package/ShoeSizeSelector.js +1154 -1146
  50. package/SimpleErrorBoundary.js +138 -130
  51. package/StyleSelector.js +861 -854
  52. package/TextButton.js +143 -135
  53. package/Tooltip.js +184 -176
  54. package/Tracking.js +25 -15
  55. package/WrapperButton.js +58 -50
  56. package/build/bundle.css +1 -1
  57. package/build/bundle.js +17236 -10632
  58. package/build/constants.js +45 -32
  59. package/package.json +2 -2
  60. package/svg/Accessories.js +42 -34
  61. package/svg/Account.js +38 -30
  62. package/svg/Add.js +39 -31
  63. package/svg/ArrowRight.js +36 -28
  64. package/svg/Bags.js +48 -40
  65. package/svg/BurgerMenu.js +32 -24
  66. package/svg/Calendar.js +106 -98
  67. package/svg/CalendarCircled.js +108 -100
  68. package/svg/CheckCircled.js +40 -32
  69. package/svg/Close.js +37 -29
  70. package/svg/Clothing.js +44 -36
  71. package/svg/Dot.js +40 -32
  72. package/svg/Edit.js +35 -27
  73. package/svg/Eye.js +36 -28
  74. package/svg/FileAttach.js +36 -28
  75. package/svg/FileAttachCircled.js +38 -30
  76. package/svg/Jewellery.js +57 -49
  77. package/svg/LightBulb.js +66 -58
  78. package/svg/Logo.js +140 -132
  79. package/svg/LuxityMenu.js +36 -28
  80. package/svg/Minus.js +37 -29
  81. package/svg/MobileAvatar.js +36 -28
  82. package/svg/MyOrder.js +44 -36
  83. package/svg/MyPayment.js +44 -36
  84. package/svg/MyProfile.js +52 -44
  85. package/svg/MySale.js +39 -31
  86. package/svg/Notification.js +38 -30
  87. package/svg/PointerDown.js +36 -28
  88. package/svg/Search.js +35 -27
  89. package/svg/Shoes.js +45 -37
  90. package/svg/SvgWrapper.js +21 -13
  91. package/svg/Trash.js +40 -32
  92. package/svg/Watches.js +55 -47
@@ -1,684 +1,692 @@
1
- import React, { forwardRef, useEffect } from 'react';
2
- import styled, { ThemeProvider } from 'styled-components';
3
-
4
- function _extends() {
5
- _extends = Object.assign ? Object.assign.bind() : function (target) {
6
- for (var i = 1; i < arguments.length; i++) {
7
- var source = arguments[i];
8
-
9
- for (var key in source) {
10
- if (Object.prototype.hasOwnProperty.call(source, key)) {
11
- target[key] = source[key];
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('styled-components')) :
3
+ typeof define === 'function' && define.amd ? define(['react', 'styled-components'], factory) :
4
+ (global = global || self, global.CommunicationPreferenceSection = factory(global.React, global.styled));
5
+ }(this, (function (React, styled) { 'use strict';
6
+
7
+ var React__default = 'default' in React ? React['default'] : React;
8
+ var styled__default = 'default' in styled ? styled['default'] : styled;
9
+
10
+ function _extends() {
11
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
12
+ for (var i = 1; i < arguments.length; i++) {
13
+ var source = arguments[i];
14
+
15
+ for (var key in source) {
16
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
17
+ target[key] = source[key];
18
+ }
12
19
  }
13
20
  }
21
+
22
+ return target;
23
+ };
24
+ return _extends.apply(this, arguments);
25
+ }
26
+
27
+ function _objectWithoutPropertiesLoose(source, excluded) {
28
+ if (source == null) return {};
29
+ var target = {};
30
+ var sourceKeys = Object.keys(source);
31
+ var key, i;
32
+
33
+ for (i = 0; i < sourceKeys.length; i++) {
34
+ key = sourceKeys[i];
35
+ if (excluded.indexOf(key) >= 0) continue;
36
+ target[key] = source[key];
14
37
  }
15
38
 
16
39
  return target;
17
- };
18
- return _extends.apply(this, arguments);
19
- }
20
-
21
- function _objectWithoutPropertiesLoose(source, excluded) {
22
- if (source == null) return {};
23
- var target = {};
24
- var sourceKeys = Object.keys(source);
25
- var key, i;
26
-
27
- for (i = 0; i < sourceKeys.length; i++) {
28
- key = sourceKeys[i];
29
- if (excluded.indexOf(key) >= 0) continue;
30
- target[key] = source[key];
31
40
  }
32
41
 
33
- return target;
34
- }
42
+ function _objectWithoutProperties(source, excluded) {
43
+ if (source == null) return {};
35
44
 
36
- function _objectWithoutProperties(source, excluded) {
37
- if (source == null) return {};
45
+ var target = _objectWithoutPropertiesLoose(source, excluded);
38
46
 
39
- var target = _objectWithoutPropertiesLoose(source, excluded);
47
+ var key, i;
40
48
 
41
- var key, i;
49
+ if (Object.getOwnPropertySymbols) {
50
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
42
51
 
43
- if (Object.getOwnPropertySymbols) {
44
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
45
-
46
- for (i = 0; i < sourceSymbolKeys.length; i++) {
47
- key = sourceSymbolKeys[i];
48
- if (excluded.indexOf(key) >= 0) continue;
49
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
50
- target[key] = source[key];
52
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
53
+ key = sourceSymbolKeys[i];
54
+ if (excluded.indexOf(key) >= 0) continue;
55
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
56
+ target[key] = source[key];
57
+ }
51
58
  }
59
+
60
+ return target;
52
61
  }
53
62
 
54
- return target;
55
- }
63
+ function _taggedTemplateLiteral(strings, raw) {
64
+ if (!raw) {
65
+ raw = strings.slice(0);
66
+ }
56
67
 
57
- function _taggedTemplateLiteral(strings, raw) {
58
- if (!raw) {
59
- raw = strings.slice(0);
68
+ return Object.freeze(Object.defineProperties(strings, {
69
+ raw: {
70
+ value: Object.freeze(raw)
71
+ }
72
+ }));
60
73
  }
61
74
 
62
- return Object.freeze(Object.defineProperties(strings, {
63
- raw: {
64
- value: Object.freeze(raw)
75
+ var theme = {
76
+ breakpoints: ['40em', '52em', '64em'],
77
+ space: ['0px', '4px', '8px', '16px', '32px', '64px', '128px', '256px', '512px'],
78
+ fontSizes: ['12px', '14px', '16px', '20px', '24px', '32px', '48px', '64px', '72px'],
79
+ marginPaddings: ['0.5rem', '1rem', '1.5rem', '2rem', '2.5rem', '3rem', '3.5rem', '4rem', '4.5rem', '5rem', '5.5rem', '6rem'],
80
+ letterSpacings: ['-0.5px', '0px', '+0.5px'],
81
+ radii: ['0px', '2px', '4px', '8px'],
82
+ borderRadius: '6px',
83
+ colors: {
84
+ primary: '#000',
85
+ base: '#4e4949',
86
+ baseLt: '#817c7c',
87
+ borderColor: '#d8d8d8',
88
+ ntrlMin: '#fff',
89
+ ntrlMinTen: '#e6e6e6',
90
+ gray: '#efefef',
91
+ darkerGray: '#454141'
92
+ },
93
+ rareStepColors: {
94
+ primary: '#202b58',
95
+ secondary: '#ef5c2d',
96
+ ntrlMin: '#ffffff',
97
+ ntrl40: '#f4f4f4',
98
+ ntrl50: '#808080',
99
+ ntrl60: '#e8e8e8',
100
+ ntrl70: '#252525',
101
+ ntrlMax: '#000000'
102
+ },
103
+ rareStepFontWeights: {
104
+ normal: 400,
105
+ medium: 500,
106
+ semiBold: 600,
107
+ bold: 700
108
+ },
109
+ rareStepFontSize: {
110
+ h1: '36px',
111
+ h2: '30px',
112
+ h3: '24px',
113
+ h4: '20px',
114
+ h5: '16px',
115
+ h6: '14px',
116
+ footerTitle: '16px'
117
+ },
118
+ rareStepPageSizes: {
119
+ mobile: '500px',
120
+ tablet: '768px',
121
+ desktop: '992px',
122
+ screenl: '1280px',
123
+ screenxl: '1680px',
124
+ screenxxl: '1920px',
125
+ container: '1600px'
65
126
  }
66
- }));
67
- }
68
-
69
- var theme = {
70
- breakpoints: ['40em', '52em', '64em'],
71
- space: ['0px', '4px', '8px', '16px', '32px', '64px', '128px', '256px', '512px'],
72
- fontSizes: ['12px', '14px', '16px', '20px', '24px', '32px', '48px', '64px', '72px'],
73
- marginPaddings: ['0.5rem', '1rem', '1.5rem', '2rem', '2.5rem', '3rem', '3.5rem', '4rem', '4.5rem', '5rem', '5.5rem', '6rem'],
74
- letterSpacings: ['-0.5px', '0px', '+0.5px'],
75
- radii: ['0px', '2px', '4px', '8px'],
76
- borderRadius: '6px',
77
- colors: {
78
- primary: '#000',
79
- base: '#4e4949',
80
- baseLt: '#817c7c',
81
- borderColor: '#d8d8d8',
82
- ntrlMin: '#fff',
83
- ntrlMinTen: '#e6e6e6',
84
- gray: '#efefef',
85
- darkerGray: '#454141'
86
- },
87
- rareStepColors: {
88
- primary: '#202b58',
89
- secondary: '#ef5c2d',
90
- ntrlMin: '#ffffff',
91
- ntrl40: '#f4f4f4',
92
- ntrl50: '#808080',
93
- ntrl60: '#e8e8e8',
94
- ntrl70: '#252525',
95
- ntrlMax: '#000000'
96
- },
97
- rareStepFontWeights: {
98
- normal: 400,
99
- medium: 500,
100
- semiBold: 600,
101
- bold: 700
102
- },
103
- rareStepFontSize: {
104
- h1: '36px',
105
- h2: '30px',
106
- h3: '24px',
107
- h4: '20px',
108
- h5: '16px',
109
- h6: '14px',
110
- footerTitle: '16px'
111
- },
112
- rareStepPageSizes: {
113
- mobile: '500px',
114
- tablet: '768px',
115
- desktop: '992px',
116
- screenl: '1280px',
117
- screenxl: '1680px',
118
- screenxxl: '1920px',
119
- container: '1600px'
120
- }
121
- };
122
-
123
- var themed = (function (Component) {
124
- return /*#__PURE__*/forwardRef(function (props, ref) {
125
- return /*#__PURE__*/React.createElement(ThemeProvider, {
126
- theme: theme
127
- }, /*#__PURE__*/React.createElement(Component, _extends({}, props, {
128
- ref: ref
129
- })));
127
+ };
128
+
129
+ var themed = (function (Component) {
130
+ return /*#__PURE__*/React.forwardRef(function (props, ref) {
131
+ return /*#__PURE__*/React__default.createElement(styled.ThemeProvider, {
132
+ theme: theme
133
+ }, /*#__PURE__*/React__default.createElement(Component, _extends({}, props, {
134
+ ref: ref
135
+ })));
136
+ });
130
137
  });
131
- });
132
138
 
133
- var isCheckBoxInput = (element) => element.type === 'checkbox';
139
+ var isCheckBoxInput = (element) => element.type === 'checkbox';
134
140
 
135
- var isDateObject = (value) => value instanceof Date;
141
+ var isDateObject = (value) => value instanceof Date;
136
142
 
137
- var isNullOrUndefined = (value) => value == null;
143
+ var isNullOrUndefined = (value) => value == null;
138
144
 
139
- const isObjectType = (value) => typeof value === 'object';
140
- var isObject = (value) => !isNullOrUndefined(value) &&
141
- !Array.isArray(value) &&
142
- isObjectType(value) &&
143
- !isDateObject(value);
145
+ const isObjectType = (value) => typeof value === 'object';
146
+ var isObject = (value) => !isNullOrUndefined(value) &&
147
+ !Array.isArray(value) &&
148
+ isObjectType(value) &&
149
+ !isDateObject(value);
144
150
 
145
- var getEventValue = (event) => isObject(event) && event.target
146
- ? isCheckBoxInput(event.target)
147
- ? event.target.checked
148
- : event.target.value
149
- : event;
151
+ var getEventValue = (event) => isObject(event) && event.target
152
+ ? isCheckBoxInput(event.target)
153
+ ? event.target.checked
154
+ : event.target.value
155
+ : event;
150
156
 
151
- var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
157
+ var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
152
158
 
153
- var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
159
+ var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
154
160
 
155
- var isPlainObject = (tempObject) => {
156
- const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
157
- return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
158
- };
161
+ var isPlainObject = (tempObject) => {
162
+ const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
163
+ return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
164
+ };
159
165
 
160
- var isWeb = typeof window !== 'undefined' &&
161
- typeof window.HTMLElement !== 'undefined' &&
162
- typeof document !== 'undefined';
166
+ var isWeb = typeof window !== 'undefined' &&
167
+ typeof window.HTMLElement !== 'undefined' &&
168
+ typeof document !== 'undefined';
163
169
 
164
- function cloneObject(data) {
165
- let copy;
166
- const isArray = Array.isArray(data);
167
- if (data instanceof Date) {
168
- copy = new Date(data);
169
- }
170
- else if (data instanceof Set) {
171
- copy = new Set(data);
172
- }
173
- else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
174
- (isArray || isObject(data))) {
175
- copy = isArray ? [] : {};
176
- if (!isArray && !isPlainObject(data)) {
177
- copy = data;
178
- }
179
- else {
180
- for (const key in data) {
181
- if (data.hasOwnProperty(key)) {
182
- copy[key] = cloneObject(data[key]);
183
- }
184
- }
185
- }
186
- }
187
- else {
188
- return data;
189
- }
190
- return copy;
191
- }
170
+ function cloneObject(data) {
171
+ let copy;
172
+ const isArray = Array.isArray(data);
173
+ if (data instanceof Date) {
174
+ copy = new Date(data);
175
+ }
176
+ else if (data instanceof Set) {
177
+ copy = new Set(data);
178
+ }
179
+ else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
180
+ (isArray || isObject(data))) {
181
+ copy = isArray ? [] : {};
182
+ if (!isArray && !isPlainObject(data)) {
183
+ copy = data;
184
+ }
185
+ else {
186
+ for (const key in data) {
187
+ if (data.hasOwnProperty(key)) {
188
+ copy[key] = cloneObject(data[key]);
189
+ }
190
+ }
191
+ }
192
+ }
193
+ else {
194
+ return data;
195
+ }
196
+ return copy;
197
+ }
192
198
 
193
- var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
199
+ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
194
200
 
195
- var isUndefined = (val) => val === undefined;
201
+ var isUndefined = (val) => val === undefined;
196
202
 
197
- var get = (obj, path, defaultValue) => {
198
- if (!path || !isObject(obj)) {
199
- return defaultValue;
200
- }
201
- const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);
202
- return isUndefined(result) || result === obj
203
- ? isUndefined(obj[path])
204
- ? defaultValue
205
- : obj[path]
206
- : result;
207
- };
208
-
209
- const EVENTS = {
210
- BLUR: 'blur',
211
- FOCUS_OUT: 'focusout',
212
- CHANGE: 'change',
213
- };
214
- const VALIDATION_MODE = {
215
- onBlur: 'onBlur',
216
- onChange: 'onChange',
217
- onSubmit: 'onSubmit',
218
- onTouched: 'onTouched',
219
- all: 'all',
220
- };
221
-
222
- const HookFormContext = React.createContext(null);
223
- /**
224
- * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
225
- *
226
- * @remarks
227
- * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
228
- *
229
- * @returns return all useForm methods
230
- *
231
- * @example
232
- * ```tsx
233
- * function App() {
234
- * const methods = useForm();
235
- * const onSubmit = data => console.log(data);
236
- *
237
- * return (
238
- * <FormProvider {...methods} >
239
- * <form onSubmit={methods.handleSubmit(onSubmit)}>
240
- * <NestedInput />
241
- * <input type="submit" />
242
- * </form>
243
- * </FormProvider>
244
- * );
245
- * }
246
- *
247
- * function NestedInput() {
248
- * const { register } = useFormContext(); // retrieve all hook methods
249
- * return <input {...register("test")} />;
250
- * }
251
- * ```
252
- */
253
- const useFormContext = () => React.useContext(HookFormContext);
254
-
255
- var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
256
- const result = {
257
- defaultValues: control._defaultValues,
258
- };
259
- for (const key in formState) {
260
- Object.defineProperty(result, key, {
261
- get: () => {
262
- const _key = key;
263
- if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
264
- control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
265
- }
266
- localProxyFormState && (localProxyFormState[_key] = true);
267
- return formState[_key];
268
- },
269
- });
270
- }
271
- return result;
272
- };
273
-
274
- var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
275
-
276
- var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
277
- updateFormState(formStateData);
278
- const { name, ...formState } = formStateData;
279
- return (isEmptyObject(formState) ||
280
- Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
281
- Object.keys(formState).find((key) => _proxyFormState[key] ===
282
- (!isRoot || VALIDATION_MODE.all)));
283
- };
284
-
285
- var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
286
-
287
- var shouldSubscribeByName = (name, signalName, exact) => exact && signalName
288
- ? name === signalName ||
289
- (Array.isArray(name) &&
290
- name.some((currentName) => currentName && exact && currentName === signalName))
291
- : !name ||
292
- !signalName ||
293
- name === signalName ||
294
- convertToArrayPayload(name).some((currentName) => currentName &&
295
- (currentName.startsWith(signalName) ||
296
- signalName.startsWith(currentName)));
297
-
298
- function useSubscribe(props) {
299
- const _props = React.useRef(props);
300
- _props.current = props;
301
- React.useEffect(() => {
302
- const subscription = !props.disabled &&
303
- _props.current.subject &&
304
- _props.current.subject.subscribe({
305
- next: _props.current.next,
306
- });
307
- return () => {
308
- subscription && subscription.unsubscribe();
309
- };
310
- }, [props.disabled]);
311
- }
312
-
313
- /**
314
- * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
315
- *
316
- * @remarks
317
- * [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
318
- *
319
- * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
320
- *
321
- * @example
322
- * ```tsx
323
- * function App() {
324
- * const { register, handleSubmit, control } = useForm({
325
- * defaultValues: {
326
- * firstName: "firstName"
327
- * }});
328
- * const { dirtyFields } = useFormState({
329
- * control
330
- * });
331
- * const onSubmit = (data) => console.log(data);
332
- *
333
- * return (
334
- * <form onSubmit={handleSubmit(onSubmit)}>
335
- * <input {...register("firstName")} placeholder="First Name" />
336
- * {dirtyFields.firstName && <p>Field is dirty.</p>}
337
- * <input type="submit" />
338
- * </form>
339
- * );
340
- * }
341
- * ```
342
- */
343
- function useFormState(props) {
344
- const methods = useFormContext();
345
- const { control = methods.control, disabled, name, exact } = props || {};
346
- const [formState, updateFormState] = React.useState(control._formState);
347
- const _mounted = React.useRef(true);
348
- const _localProxyFormState = React.useRef({
349
- isDirty: false,
350
- isLoading: false,
351
- dirtyFields: false,
352
- touchedFields: false,
353
- isValidating: false,
354
- isValid: false,
355
- errors: false,
356
- });
357
- const _name = React.useRef(name);
358
- _name.current = name;
359
- useSubscribe({
360
- disabled,
361
- next: (value) => _mounted.current &&
362
- shouldSubscribeByName(_name.current, value.name, exact) &&
363
- shouldRenderFormState(value, _localProxyFormState.current, control._updateFormState) &&
364
- updateFormState({
365
- ...control._formState,
366
- ...value,
367
- }),
368
- subject: control._subjects.state,
369
- });
370
- React.useEffect(() => {
371
- _mounted.current = true;
372
- _localProxyFormState.current.isValid && control._updateValid(true);
373
- return () => {
374
- _mounted.current = false;
375
- };
376
- }, [control]);
377
- return getProxyFormState(formState, control, _localProxyFormState.current, false);
378
- }
379
-
380
- var isString = (value) => typeof value === 'string';
381
-
382
- var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
383
- if (isString(names)) {
384
- isGlobal && _names.watch.add(names);
385
- return get(formValues, names, defaultValue);
386
- }
387
- if (Array.isArray(names)) {
388
- return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
389
- }
390
- isGlobal && (_names.watchAll = true);
391
- return formValues;
392
- };
393
-
394
- /**
395
- * Custom hook to subscribe to field change and isolate re-rendering at the component level.
396
- *
397
- * @remarks
398
- *
399
- * [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
400
- *
401
- * @example
402
- * ```tsx
403
- * const { watch } = useForm();
404
- * const values = useWatch({
405
- * name: "fieldName"
406
- * control,
407
- * })
408
- * ```
409
- */
410
- function useWatch(props) {
411
- const methods = useFormContext();
412
- const { control = methods.control, name, defaultValue, disabled, exact, } = props || {};
413
- const _name = React.useRef(name);
414
- _name.current = name;
415
- useSubscribe({
416
- disabled,
417
- subject: control._subjects.values,
418
- next: (formState) => {
419
- if (shouldSubscribeByName(_name.current, formState.name, exact)) {
420
- updateValue(cloneObject(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false, defaultValue)));
421
- }
422
- },
423
- });
424
- const [value, updateValue] = React.useState(control._getWatch(name, defaultValue));
425
- React.useEffect(() => control._removeUnmounted());
426
- return value;
427
- }
428
-
429
- var isKey = (value) => /^\w*$/.test(value);
430
-
431
- var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
432
-
433
- function set(object, path, value) {
434
- let index = -1;
435
- const tempPath = isKey(path) ? [path] : stringToPath(path);
436
- const length = tempPath.length;
437
- const lastIndex = length - 1;
438
- while (++index < length) {
439
- const key = tempPath[index];
440
- let newValue = value;
441
- if (index !== lastIndex) {
442
- const objValue = object[key];
443
- newValue =
444
- isObject(objValue) || Array.isArray(objValue)
445
- ? objValue
446
- : !isNaN(+tempPath[index + 1])
447
- ? []
448
- : {};
449
- }
450
- object[key] = newValue;
451
- object = object[key];
452
- }
453
- return object;
454
- }
455
-
456
- /**
457
- * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
458
- *
459
- * @remarks
460
- * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
461
- *
462
- * @param props - the path name to the form field value, and validation rules.
463
- *
464
- * @returns field properties, field and form state. {@link UseControllerReturn}
465
- *
466
- * @example
467
- * ```tsx
468
- * function Input(props) {
469
- * const { field, fieldState, formState } = useController(props);
470
- * return (
471
- * <div>
472
- * <input {...field} placeholder={props.name} />
473
- * <p>{fieldState.isTouched && "Touched"}</p>
474
- * <p>{formState.isSubmitted ? "submitted" : ""}</p>
475
- * </div>
476
- * );
477
- * }
478
- * ```
479
- */
480
- function useController(props) {
481
- const methods = useFormContext();
482
- const { name, disabled, control = methods.control, shouldUnregister } = props;
483
- const isArrayField = isNameInFieldArray(control._names.array, name);
484
- const value = useWatch({
485
- control,
486
- name,
487
- defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),
488
- exact: true,
489
- });
490
- const formState = useFormState({
491
- control,
492
- name,
493
- });
494
- const _registerProps = React.useRef(control.register(name, {
495
- ...props.rules,
496
- value,
497
- }));
498
- _registerProps.current = control.register(name, props.rules);
499
- React.useEffect(() => {
500
- const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
501
- const updateMounted = (name, value) => {
502
- const field = get(control._fields, name);
503
- if (field) {
504
- field._f.mount = value;
505
- }
506
- };
507
- updateMounted(name, true);
508
- if (_shouldUnregisterField) {
509
- const value = cloneObject(get(control._options.defaultValues, name));
510
- set(control._defaultValues, name, value);
511
- if (isUndefined(get(control._formValues, name))) {
512
- set(control._formValues, name, value);
513
- }
514
- }
515
- return () => {
516
- (isArrayField
517
- ? _shouldUnregisterField && !control._state.action
518
- : _shouldUnregisterField)
519
- ? control.unregister(name)
520
- : updateMounted(name, false);
521
- };
522
- }, [name, control, isArrayField, shouldUnregister]);
523
- React.useEffect(() => {
524
- control._updateDisabledField({
525
- disabled,
526
- fields: control._fields,
527
- name,
528
- });
529
- }, [disabled, name, control]);
530
- return {
531
- field: {
532
- name,
533
- value,
534
- disabled,
535
- onChange: React.useCallback((event) => _registerProps.current.onChange({
536
- target: {
537
- value: getEventValue(event),
538
- name: name,
539
- },
540
- type: EVENTS.CHANGE,
541
- }), [name]),
542
- onBlur: React.useCallback(() => _registerProps.current.onBlur({
543
- target: {
544
- value: get(control._formValues, name),
545
- name: name,
546
- },
547
- type: EVENTS.BLUR,
548
- }), [name, control]),
549
- ref: (elm) => {
550
- const field = get(control._fields, name);
551
- if (field && elm) {
552
- field._f.ref = {
553
- focus: () => elm.focus(),
554
- select: () => elm.select(),
555
- setCustomValidity: (message) => elm.setCustomValidity(message),
556
- reportValidity: () => elm.reportValidity(),
557
- };
558
- }
559
- },
560
- },
561
- formState,
562
- fieldState: Object.defineProperties({}, {
563
- invalid: {
564
- enumerable: true,
565
- get: () => !!get(formState.errors, name),
566
- },
567
- isDirty: {
568
- enumerable: true,
569
- get: () => !!get(formState.dirtyFields, name),
570
- },
571
- isTouched: {
572
- enumerable: true,
573
- get: () => !!get(formState.touchedFields, name),
574
- },
575
- error: {
576
- enumerable: true,
577
- get: () => get(formState.errors, name),
578
- },
579
- }),
580
- };
581
- }
582
-
583
- var _templateObject;
584
- var RadioButtonLabel = styled.label(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n margin-bottom: ", ";\n margin-right: ", ";\n"])), function (props) {
585
- return props.theme.marginPaddings[0];
586
- }, function (props) {
587
- return props.theme.marginPaddings[0];
588
- });
589
-
590
- var _templateObject$1;
591
- var RadioButtonText = styled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n"])));
592
-
593
- var _templateObject$2;
594
- var RadioButtonCircle = styled.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n height: 20px;\n width: 20px;\n border-radius: 50%;\n margin-right: 5px;\n border: 1px solid ", ";\n display: flex;\n"])), function (props) {
595
- return props.theme.colors.base;
596
- });
597
-
598
- var _templateObject$3;
599
- var RadioButtonCircleInner = styled.div(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n height: 8px;\n width: 8px;\n border-radius: 50%;\n margin: auto;\n"])));
600
-
601
- var _templateObject$4;
602
- var RadioButtonInput = styled.input(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n display: none;\n :checked ~ ", " {\n ", " {\n background-color: ", ";\n }\n }\n"])), RadioButtonCircle, RadioButtonCircleInner, function (props) {
603
- return props.theme.colors.base;
604
- });
605
-
606
- var _excluded = ["ref"];
607
-
608
- var _templateObject$5, _templateObject2;
609
- var OptionsRow = styled.div(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: nowrap;\n flex-direction: row;\n"])));
610
- var Options = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: nowrap;\n flex-direction: row;\n flex-basis: 60%;\n"])));
611
-
612
- var CommunicationPreferenceOptionsRenderer = function CommunicationPreferenceOptionsRenderer(_ref) {
613
- var control = _ref.control,
614
- name = _ref.name,
615
- isDisabled = _ref.isDisabled,
616
- options = _ref.options,
617
- defaultValue = _ref.defaultValue,
618
- setValue = _ref.setValue;
619
-
620
- var _useController = useController({
621
- name: name,
622
- control: control,
623
- defaultValue: defaultValue
624
- }),
625
- _useController$field = _useController.field,
626
- ref = _useController$field.ref,
627
- inputProps = _objectWithoutProperties(_useController$field, _excluded),
628
- _useController$fieldS = _useController.fieldState,
629
- invalid = _useController$fieldS.invalid,
630
- error = _useController$fieldS.error;
631
-
632
- useEffect(function () {
633
- if (defaultValue) {
634
- setValue(name, defaultValue);
635
- }
636
- }, [defaultValue, name, setValue]);
637
- return /*#__PURE__*/React.createElement(OptionsRow, null, /*#__PURE__*/React.createElement(Options, null, options.map(function (option) {
638
- return /*#__PURE__*/React.createElement(RadioButtonLabel, {
639
- key: option.value,
640
- htmlFor: option.value
641
- }, /*#__PURE__*/React.createElement(RadioButtonInput, _extends({
642
- id: option.value,
643
- ref: ref,
644
- type: "radio",
203
+ var get = (obj, path, defaultValue) => {
204
+ if (!path || !isObject(obj)) {
205
+ return defaultValue;
206
+ }
207
+ const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], obj);
208
+ return isUndefined(result) || result === obj
209
+ ? isUndefined(obj[path])
210
+ ? defaultValue
211
+ : obj[path]
212
+ : result;
213
+ };
214
+
215
+ const EVENTS = {
216
+ BLUR: 'blur',
217
+ FOCUS_OUT: 'focusout',
218
+ CHANGE: 'change',
219
+ };
220
+ const VALIDATION_MODE = {
221
+ onBlur: 'onBlur',
222
+ onChange: 'onChange',
223
+ onSubmit: 'onSubmit',
224
+ onTouched: 'onTouched',
225
+ all: 'all',
226
+ };
227
+
228
+ const HookFormContext = React__default.createContext(null);
229
+ /**
230
+ * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
231
+ *
232
+ * @remarks
233
+ * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
234
+ *
235
+ * @returns return all useForm methods
236
+ *
237
+ * @example
238
+ * ```tsx
239
+ * function App() {
240
+ * const methods = useForm();
241
+ * const onSubmit = data => console.log(data);
242
+ *
243
+ * return (
244
+ * <FormProvider {...methods} >
245
+ * <form onSubmit={methods.handleSubmit(onSubmit)}>
246
+ * <NestedInput />
247
+ * <input type="submit" />
248
+ * </form>
249
+ * </FormProvider>
250
+ * );
251
+ * }
252
+ *
253
+ * function NestedInput() {
254
+ * const { register } = useFormContext(); // retrieve all hook methods
255
+ * return <input {...register("test")} />;
256
+ * }
257
+ * ```
258
+ */
259
+ const useFormContext = () => React__default.useContext(HookFormContext);
260
+
261
+ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
262
+ const result = {
263
+ defaultValues: control._defaultValues,
264
+ };
265
+ for (const key in formState) {
266
+ Object.defineProperty(result, key, {
267
+ get: () => {
268
+ const _key = key;
269
+ if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
270
+ control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
271
+ }
272
+ localProxyFormState && (localProxyFormState[_key] = true);
273
+ return formState[_key];
274
+ },
275
+ });
276
+ }
277
+ return result;
278
+ };
279
+
280
+ var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
281
+
282
+ var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
283
+ updateFormState(formStateData);
284
+ const { name, ...formState } = formStateData;
285
+ return (isEmptyObject(formState) ||
286
+ Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
287
+ Object.keys(formState).find((key) => _proxyFormState[key] ===
288
+ (!isRoot || VALIDATION_MODE.all)));
289
+ };
290
+
291
+ var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
292
+
293
+ var shouldSubscribeByName = (name, signalName, exact) => exact && signalName
294
+ ? name === signalName ||
295
+ (Array.isArray(name) &&
296
+ name.some((currentName) => currentName && exact && currentName === signalName))
297
+ : !name ||
298
+ !signalName ||
299
+ name === signalName ||
300
+ convertToArrayPayload(name).some((currentName) => currentName &&
301
+ (currentName.startsWith(signalName) ||
302
+ signalName.startsWith(currentName)));
303
+
304
+ function useSubscribe(props) {
305
+ const _props = React__default.useRef(props);
306
+ _props.current = props;
307
+ React__default.useEffect(() => {
308
+ const subscription = !props.disabled &&
309
+ _props.current.subject &&
310
+ _props.current.subject.subscribe({
311
+ next: _props.current.next,
312
+ });
313
+ return () => {
314
+ subscription && subscription.unsubscribe();
315
+ };
316
+ }, [props.disabled]);
317
+ }
318
+
319
+ /**
320
+ * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
321
+ *
322
+ * @remarks
323
+ * [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
324
+ *
325
+ * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
326
+ *
327
+ * @example
328
+ * ```tsx
329
+ * function App() {
330
+ * const { register, handleSubmit, control } = useForm({
331
+ * defaultValues: {
332
+ * firstName: "firstName"
333
+ * }});
334
+ * const { dirtyFields } = useFormState({
335
+ * control
336
+ * });
337
+ * const onSubmit = (data) => console.log(data);
338
+ *
339
+ * return (
340
+ * <form onSubmit={handleSubmit(onSubmit)}>
341
+ * <input {...register("firstName")} placeholder="First Name" />
342
+ * {dirtyFields.firstName && <p>Field is dirty.</p>}
343
+ * <input type="submit" />
344
+ * </form>
345
+ * );
346
+ * }
347
+ * ```
348
+ */
349
+ function useFormState(props) {
350
+ const methods = useFormContext();
351
+ const { control = methods.control, disabled, name, exact } = props || {};
352
+ const [formState, updateFormState] = React__default.useState(control._formState);
353
+ const _mounted = React__default.useRef(true);
354
+ const _localProxyFormState = React__default.useRef({
355
+ isDirty: false,
356
+ isLoading: false,
357
+ dirtyFields: false,
358
+ touchedFields: false,
359
+ isValidating: false,
360
+ isValid: false,
361
+ errors: false,
362
+ });
363
+ const _name = React__default.useRef(name);
364
+ _name.current = name;
365
+ useSubscribe({
366
+ disabled,
367
+ next: (value) => _mounted.current &&
368
+ shouldSubscribeByName(_name.current, value.name, exact) &&
369
+ shouldRenderFormState(value, _localProxyFormState.current, control._updateFormState) &&
370
+ updateFormState({
371
+ ...control._formState,
372
+ ...value,
373
+ }),
374
+ subject: control._subjects.state,
375
+ });
376
+ React__default.useEffect(() => {
377
+ _mounted.current = true;
378
+ _localProxyFormState.current.isValid && control._updateValid(true);
379
+ return () => {
380
+ _mounted.current = false;
381
+ };
382
+ }, [control]);
383
+ return getProxyFormState(formState, control, _localProxyFormState.current, false);
384
+ }
385
+
386
+ var isString = (value) => typeof value === 'string';
387
+
388
+ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
389
+ if (isString(names)) {
390
+ isGlobal && _names.watch.add(names);
391
+ return get(formValues, names, defaultValue);
392
+ }
393
+ if (Array.isArray(names)) {
394
+ return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
395
+ }
396
+ isGlobal && (_names.watchAll = true);
397
+ return formValues;
398
+ };
399
+
400
+ /**
401
+ * Custom hook to subscribe to field change and isolate re-rendering at the component level.
402
+ *
403
+ * @remarks
404
+ *
405
+ * [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
406
+ *
407
+ * @example
408
+ * ```tsx
409
+ * const { watch } = useForm();
410
+ * const values = useWatch({
411
+ * name: "fieldName"
412
+ * control,
413
+ * })
414
+ * ```
415
+ */
416
+ function useWatch(props) {
417
+ const methods = useFormContext();
418
+ const { control = methods.control, name, defaultValue, disabled, exact, } = props || {};
419
+ const _name = React__default.useRef(name);
420
+ _name.current = name;
421
+ useSubscribe({
422
+ disabled,
423
+ subject: control._subjects.values,
424
+ next: (formState) => {
425
+ if (shouldSubscribeByName(_name.current, formState.name, exact)) {
426
+ updateValue(cloneObject(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false, defaultValue)));
427
+ }
428
+ },
429
+ });
430
+ const [value, updateValue] = React__default.useState(control._getWatch(name, defaultValue));
431
+ React__default.useEffect(() => control._removeUnmounted());
432
+ return value;
433
+ }
434
+
435
+ var isKey = (value) => /^\w*$/.test(value);
436
+
437
+ var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
438
+
439
+ function set(object, path, value) {
440
+ let index = -1;
441
+ const tempPath = isKey(path) ? [path] : stringToPath(path);
442
+ const length = tempPath.length;
443
+ const lastIndex = length - 1;
444
+ while (++index < length) {
445
+ const key = tempPath[index];
446
+ let newValue = value;
447
+ if (index !== lastIndex) {
448
+ const objValue = object[key];
449
+ newValue =
450
+ isObject(objValue) || Array.isArray(objValue)
451
+ ? objValue
452
+ : !isNaN(+tempPath[index + 1])
453
+ ? []
454
+ : {};
455
+ }
456
+ object[key] = newValue;
457
+ object = object[key];
458
+ }
459
+ return object;
460
+ }
461
+
462
+ /**
463
+ * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
464
+ *
465
+ * @remarks
466
+ * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
467
+ *
468
+ * @param props - the path name to the form field value, and validation rules.
469
+ *
470
+ * @returns field properties, field and form state. {@link UseControllerReturn}
471
+ *
472
+ * @example
473
+ * ```tsx
474
+ * function Input(props) {
475
+ * const { field, fieldState, formState } = useController(props);
476
+ * return (
477
+ * <div>
478
+ * <input {...field} placeholder={props.name} />
479
+ * <p>{fieldState.isTouched && "Touched"}</p>
480
+ * <p>{formState.isSubmitted ? "submitted" : ""}</p>
481
+ * </div>
482
+ * );
483
+ * }
484
+ * ```
485
+ */
486
+ function useController(props) {
487
+ const methods = useFormContext();
488
+ const { name, disabled, control = methods.control, shouldUnregister } = props;
489
+ const isArrayField = isNameInFieldArray(control._names.array, name);
490
+ const value = useWatch({
491
+ control,
492
+ name,
493
+ defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),
494
+ exact: true,
495
+ });
496
+ const formState = useFormState({
497
+ control,
498
+ name,
499
+ });
500
+ const _registerProps = React__default.useRef(control.register(name, {
501
+ ...props.rules,
502
+ value,
503
+ }));
504
+ _registerProps.current = control.register(name, props.rules);
505
+ React__default.useEffect(() => {
506
+ const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
507
+ const updateMounted = (name, value) => {
508
+ const field = get(control._fields, name);
509
+ if (field) {
510
+ field._f.mount = value;
511
+ }
512
+ };
513
+ updateMounted(name, true);
514
+ if (_shouldUnregisterField) {
515
+ const value = cloneObject(get(control._options.defaultValues, name));
516
+ set(control._defaultValues, name, value);
517
+ if (isUndefined(get(control._formValues, name))) {
518
+ set(control._formValues, name, value);
519
+ }
520
+ }
521
+ return () => {
522
+ (isArrayField
523
+ ? _shouldUnregisterField && !control._state.action
524
+ : _shouldUnregisterField)
525
+ ? control.unregister(name)
526
+ : updateMounted(name, false);
527
+ };
528
+ }, [name, control, isArrayField, shouldUnregister]);
529
+ React__default.useEffect(() => {
530
+ control._updateDisabledField({
531
+ disabled,
532
+ fields: control._fields,
533
+ name,
534
+ });
535
+ }, [disabled, name, control]);
536
+ return {
537
+ field: {
538
+ name,
539
+ value,
540
+ disabled,
541
+ onChange: React__default.useCallback((event) => _registerProps.current.onChange({
542
+ target: {
543
+ value: getEventValue(event),
544
+ name: name,
545
+ },
546
+ type: EVENTS.CHANGE,
547
+ }), [name]),
548
+ onBlur: React__default.useCallback(() => _registerProps.current.onBlur({
549
+ target: {
550
+ value: get(control._formValues, name),
551
+ name: name,
552
+ },
553
+ type: EVENTS.BLUR,
554
+ }), [name, control]),
555
+ ref: (elm) => {
556
+ const field = get(control._fields, name);
557
+ if (field && elm) {
558
+ field._f.ref = {
559
+ focus: () => elm.focus(),
560
+ select: () => elm.select(),
561
+ setCustomValidity: (message) => elm.setCustomValidity(message),
562
+ reportValidity: () => elm.reportValidity(),
563
+ };
564
+ }
565
+ },
566
+ },
567
+ formState,
568
+ fieldState: Object.defineProperties({}, {
569
+ invalid: {
570
+ enumerable: true,
571
+ get: () => !!get(formState.errors, name),
572
+ },
573
+ isDirty: {
574
+ enumerable: true,
575
+ get: () => !!get(formState.dirtyFields, name),
576
+ },
577
+ isTouched: {
578
+ enumerable: true,
579
+ get: () => !!get(formState.touchedFields, name),
580
+ },
581
+ error: {
582
+ enumerable: true,
583
+ get: () => get(formState.errors, name),
584
+ },
585
+ }),
586
+ };
587
+ }
588
+
589
+ var _templateObject;
590
+ var RadioButtonLabel = styled__default.label(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n margin-bottom: ", ";\n margin-right: ", ";\n"])), function (props) {
591
+ return props.theme.marginPaddings[0];
592
+ }, function (props) {
593
+ return props.theme.marginPaddings[0];
594
+ });
595
+
596
+ var _templateObject$1;
597
+ var RadioButtonText = styled__default.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n"])));
598
+
599
+ var _templateObject$2;
600
+ var RadioButtonCircle = styled__default.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n height: 20px;\n width: 20px;\n border-radius: 50%;\n margin-right: 5px;\n border: 1px solid ", ";\n display: flex;\n"])), function (props) {
601
+ return props.theme.colors.base;
602
+ });
603
+
604
+ var _templateObject$3;
605
+ var RadioButtonCircleInner = styled__default.div(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n height: 8px;\n width: 8px;\n border-radius: 50%;\n margin: auto;\n"])));
606
+
607
+ var _templateObject$4;
608
+ var RadioButtonInput = styled__default.input(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n display: none;\n :checked ~ ", " {\n ", " {\n background-color: ", ";\n }\n }\n"])), RadioButtonCircle, RadioButtonCircleInner, function (props) {
609
+ return props.theme.colors.base;
610
+ });
611
+
612
+ var _excluded = ["ref"];
613
+
614
+ var _templateObject$5, _templateObject2;
615
+ var OptionsRow = styled__default.div(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: nowrap;\n flex-direction: row;\n"])));
616
+ var Options = styled__default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: nowrap;\n flex-direction: row;\n flex-basis: 60%;\n"])));
617
+
618
+ var CommunicationPreferenceOptionsRenderer = function CommunicationPreferenceOptionsRenderer(_ref) {
619
+ var control = _ref.control,
620
+ name = _ref.name,
621
+ isDisabled = _ref.isDisabled,
622
+ options = _ref.options,
623
+ defaultValue = _ref.defaultValue,
624
+ setValue = _ref.setValue;
625
+
626
+ var _useController = useController({
627
+ name: name,
628
+ control: control,
629
+ defaultValue: defaultValue
630
+ }),
631
+ _useController$field = _useController.field,
632
+ ref = _useController$field.ref,
633
+ inputProps = _objectWithoutProperties(_useController$field, _excluded),
634
+ _useController$fieldS = _useController.fieldState,
635
+ invalid = _useController$fieldS.invalid,
636
+ error = _useController$fieldS.error;
637
+
638
+ React.useEffect(function () {
639
+ if (defaultValue) {
640
+ setValue(name, defaultValue);
641
+ }
642
+ }, [defaultValue, name, setValue]);
643
+ return /*#__PURE__*/React__default.createElement(OptionsRow, null, /*#__PURE__*/React__default.createElement(Options, null, options.map(function (option) {
644
+ return /*#__PURE__*/React__default.createElement(RadioButtonLabel, {
645
+ key: option.value,
646
+ htmlFor: option.value
647
+ }, /*#__PURE__*/React__default.createElement(RadioButtonInput, _extends({
648
+ id: option.value,
649
+ ref: ref,
650
+ type: "radio",
651
+ name: name,
652
+ defaultChecked: inputProps.value === option.value.toString()
653
+ }, inputProps, {
654
+ disabled: isDisabled,
655
+ value: option.value
656
+ })), /*#__PURE__*/React__default.createElement(RadioButtonCircle, null, /*#__PURE__*/React__default.createElement(RadioButtonCircleInner, null)), /*#__PURE__*/React__default.createElement(RadioButtonText, null, option.label));
657
+ })), invalid && /*#__PURE__*/React__default.createElement("span", {
658
+ className: "form__error"
659
+ }, error === null || error === void 0 ? void 0 : error.message));
660
+ };
661
+
662
+ var _templateObject$6, _templateObject2$1;
663
+ var SectionContainer = styled__default.div(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n border-top: flex 1px solid ", ";\n border-top-width: calc(100% - 50px);\n padding: 5px 10px;\n"])), function (props) {
664
+ return props.theme.colors.primary;
665
+ });
666
+ var SectionHeading = styled__default.div(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n padding: 5px 10px;\n"])));
667
+
668
+ var CommunicationPreferenceSection = function CommunicationPreferenceSection(_ref) {
669
+ var section_heading = _ref.section_heading,
670
+ description = _ref.description,
671
+ control = _ref.control,
672
+ name = _ref.name,
673
+ isDisabled = _ref.isDisabled,
674
+ options = _ref.options,
675
+ defaultValue = _ref.defaultValue,
676
+ setValue = _ref.setValue;
677
+ return /*#__PURE__*/React__default.createElement(SectionContainer, null, /*#__PURE__*/React__default.createElement(SectionHeading, null, section_heading), /*#__PURE__*/React__default.createElement(CommunicationPreferenceOptionsRenderer, {
678
+ description: description,
679
+ control: control,
645
680
  name: name,
646
- defaultChecked: inputProps.value === option.value.toString()
647
- }, inputProps, {
648
- disabled: isDisabled,
649
- value: option.value
650
- })), /*#__PURE__*/React.createElement(RadioButtonCircle, null, /*#__PURE__*/React.createElement(RadioButtonCircleInner, null)), /*#__PURE__*/React.createElement(RadioButtonText, null, option.label));
651
- })), invalid && /*#__PURE__*/React.createElement("span", {
652
- className: "form__error"
653
- }, error === null || error === void 0 ? void 0 : error.message));
654
- };
655
-
656
- var _templateObject$6, _templateObject2$1;
657
- var SectionContainer = styled.div(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n border-top: flex 1px solid ", ";\n border-top-width: calc(100% - 50px);\n padding: 5px 10px;\n"])), function (props) {
658
- return props.theme.colors.primary;
659
- });
660
- var SectionHeading = styled.div(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n padding: 5px 10px;\n"])));
661
-
662
- var CommunicationPreferenceSection = function CommunicationPreferenceSection(_ref) {
663
- var section_heading = _ref.section_heading,
664
- description = _ref.description,
665
- control = _ref.control,
666
- name = _ref.name,
667
- isDisabled = _ref.isDisabled,
668
- options = _ref.options,
669
- defaultValue = _ref.defaultValue,
670
- setValue = _ref.setValue;
671
- return /*#__PURE__*/React.createElement(SectionContainer, null, /*#__PURE__*/React.createElement(SectionHeading, null, section_heading), /*#__PURE__*/React.createElement(CommunicationPreferenceOptionsRenderer, {
672
- description: description,
673
- control: control,
674
- name: name,
675
- isDisabled: isDisabled,
676
- options: options,
677
- defaultValue: defaultValue,
678
- setValue: setValue
679
- }));
680
- };
681
-
682
- var index = themed(CommunicationPreferenceSection);
683
-
684
- export default index;
681
+ isDisabled: isDisabled,
682
+ options: options,
683
+ defaultValue: defaultValue,
684
+ setValue: setValue
685
+ }));
686
+ };
687
+
688
+ var index = themed(CommunicationPreferenceSection);
689
+
690
+ return index;
691
+
692
+ })));