@helsenorge/designsystem-react 1.0.0-beta121 → 1.0.0-beta124
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.
- package/{Badge-2d8d73dd.js → Badge-32ba89d5.js} +2 -2
- package/Badge-32ba89d5.js.map +1 -0
- package/{Button-19ee3464.js → Button-9f2ce63d.js} +2 -2
- package/Button-9f2ce63d.js.map +1 -0
- package/Checkbox-1e2c2047.js +2 -0
- package/Checkbox-1e2c2047.js.map +1 -0
- package/{Close-476c50c6.js → Close-f197bf98.js} +2 -2
- package/Close-f197bf98.js.map +1 -0
- package/{FormGroup-a776b535.js → FormGroup-9c5e238e.js} +2 -2
- package/FormGroup-9c5e238e.js.map +1 -0
- package/FormLayout-26368f0a.js +2 -0
- package/FormLayout-26368f0a.js.map +1 -0
- package/{Input-cd941f2f.js → Input-5bb47387.js} +2 -2
- package/Input-5bb47387.js.map +1 -0
- package/{Loader-2f304e4f.js → Loader-670979af.js} +2 -2
- package/Loader-670979af.js.map +1 -0
- package/{Modal-d0213453.js → Modal-10c837a4.js} +2 -2
- package/Modal-10c837a4.js.map +1 -0
- package/{Panel-33611d84.js → Panel-3ada0789.js} +2 -2
- package/Panel-3ada0789.js.map +1 -0
- package/{RadioButton-6a868eb3.js → RadioButton-71099f5c.js} +2 -2
- package/RadioButton-71099f5c.js.map +1 -0
- package/{Textarea-1c857a8a.js → Textarea-e1e649cf.js} +2 -2
- package/Textarea-e1e649cf.js.map +1 -0
- package/{Title-2522b5b9.js → Title-3a6d4597.js} +2 -2
- package/Title-3a6d4597.js.map +1 -0
- package/Validation-e36cb0d8.js +2 -0
- package/Validation-e36cb0d8.js.map +1 -0
- package/__mocks__/ResizeObserver.d.ts +6 -0
- package/__mocks__/ResizeObserver.d.ts.map +1 -0
- package/__mocks__/ResizeObserver.js +2 -0
- package/__mocks__/ResizeObserver.js.map +1 -0
- package/__mocks__/uuid.d.ts +2 -0
- package/__mocks__/uuid.d.ts.map +1 -0
- package/__mocks__/uuid.js +2 -0
- package/__mocks__/uuid.js.map +1 -0
- package/components/AnchorLink/index.js +1 -1
- package/components/Avatar/index.js +1 -1
- package/components/Badge/index.js +1 -1
- package/components/Button/index.js +1 -1
- package/components/Button/styles.module.scss +3 -1
- package/components/ButtonWithModal/index.js +1 -1
- package/components/Checkbox/index.js +1 -1
- package/components/Close/index.js +1 -1
- package/components/Dropdown/Dropdown.d.ts +36 -0
- package/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/components/Dropdown/componentdata.json +254 -0
- package/components/Dropdown/index.d.ts +4 -0
- package/components/Dropdown/index.d.ts.map +1 -0
- package/components/Dropdown/index.js +2 -0
- package/components/Dropdown/index.js.map +1 -0
- package/components/Dropdown/styles.module.scss +196 -0
- package/components/Expander/index.js +1 -1
- package/components/ExpanderList/index.js +1 -1
- package/components/FormExample/index.js +1 -1
- package/components/FormGroup/index.js +1 -1
- package/components/FormLayout/FormLayout.d.ts.map +1 -1
- package/components/FormLayout/index.js +1 -1
- package/components/FormLayout/styles.module.scss +16 -11
- package/components/FormLayout/styles.module.scss.d.ts +5 -4
- package/components/HighlightBox/index.js +1 -1
- package/components/Icons/AcupunctureBack.js +1 -1
- package/components/Icons/AlarmClock.js +1 -1
- package/components/Icons/AlertSignFill.js +1 -1
- package/components/Icons/AlertSignStroke.js +1 -1
- package/components/Icons/Archive.js +1 -1
- package/components/Icons/ArrowLeft.js +1 -1
- package/components/Icons/ArrowRight.js +1 -1
- package/components/Icons/ArrowUpRight.js +1 -1
- package/components/Icons/Attachment.js +1 -1
- package/components/Icons/Avatar.js +1 -1
- package/components/Icons/Bus.js +1 -1
- package/components/Icons/Calendar.js +1 -1
- package/components/Icons/CalendarChange.js +1 -1
- package/components/Icons/CalendarCheck.js +1 -1
- package/components/Icons/CalendarSave.js +1 -1
- package/components/Icons/Change.js +1 -1
- package/components/Icons/Check.js +1 -1
- package/components/Icons/CheckFill.js +1 -1
- package/components/Icons/ChevronDown.js +1 -1
- package/components/Icons/ChevronLeft.js +1 -1
- package/components/Icons/ChevronRight.js +1 -1
- package/components/Icons/ChevronUp.js +1 -1
- package/components/Icons/ChevronsDown.js +1 -1
- package/components/Icons/ChevronsUp.js +1 -1
- package/components/Icons/Contacts.js +1 -1
- package/components/Icons/Copy.js +1 -1
- package/components/Icons/Download.js +1 -1
- package/components/Icons/EChat.js +1 -1
- package/components/Icons/EnterFullScreen.js +1 -1
- package/components/Icons/Envelope.js +1 -1
- package/components/Icons/Eraser.js +1 -1
- package/components/Icons/ErrorSignFill.js +1 -1
- package/components/Icons/ErrorSignStroke.js +1 -1
- package/components/Icons/ExitFullScreen.js +1 -1
- package/components/Icons/Eye.js +1 -1
- package/components/Icons/Form.js +1 -1
- package/components/Icons/Forward.js +1 -1
- package/components/Icons/Gallery.js +1 -1
- package/components/Icons/Globe.js +1 -1
- package/components/Icons/Group.js +1 -1
- package/components/Icons/Heart.js +1 -1
- package/components/Icons/HelpSign.js +1 -1
- package/components/Icons/History.js +1 -1
- package/components/Icons/Home.js +1 -1
- package/components/Icons/Hospital.js +1 -1
- package/components/Icons/Hourglass.js +1 -1
- package/components/Icons/Icon.js +1 -1
- package/components/Icons/InfoSignFill.js +1 -1
- package/components/Icons/InfoSignStroke.js +1 -1
- package/components/Icons/Journal.js +1 -1
- package/components/Icons/List.js +1 -1
- package/components/Icons/Location.js +1 -1
- package/components/Icons/Lock.js +1 -1
- package/components/Icons/Medicine.js +1 -1
- package/components/Icons/Menu.js +1 -1
- package/components/Icons/Minus.js +1 -1
- package/components/Icons/MobilePhone.js +1 -1
- package/components/Icons/NoEye.js +1 -1
- package/components/Icons/NoFilter.js +1 -1
- package/components/Icons/PaperPlane.js +1 -1
- package/components/Icons/Pause.js +1 -1
- package/components/Icons/Pencil.js +1 -1
- package/components/Icons/Play.js +1 -1
- package/components/Icons/PlusLarge.js +1 -1
- package/components/Icons/PlusSmall.js +1 -1
- package/components/Icons/Printer.js +1 -1
- package/components/Icons/QrCode.js +1 -1
- package/components/Icons/Receptionist.js +1 -1
- package/components/Icons/Referral.js +1 -1
- package/components/Icons/Refresh.js +1 -1
- package/components/Icons/Reply.js +1 -1
- package/components/Icons/Save.js +1 -1
- package/components/Icons/Search.js +1 -1
- package/components/Icons/SectionSign.js +1 -1
- package/components/Icons/Settings.js +1 -1
- package/components/Icons/Share.js +1 -1
- package/components/Icons/SpeechBubble.js +1 -1
- package/components/Icons/Stopwatch.js +1 -1
- package/components/Icons/SupportingPerson.js +1 -1
- package/components/Icons/Syringe.js +1 -1
- package/components/Icons/TimePassing.js +1 -1
- package/components/Icons/Toolbox.js +1 -1
- package/components/Icons/TrashCan.js +1 -1
- package/components/Icons/Undo.js +1 -1
- package/components/Icons/Upload.js +1 -1
- package/components/Icons/Vaccine.js +1 -1
- package/components/Icons/VerticalDots.js +1 -1
- package/components/Icons/VideoCamera.js +1 -1
- package/components/Icons/VideoChat.js +1 -1
- package/components/Icons/Wallet.js +1 -1
- package/components/Icons/Watch.js +1 -1
- package/components/Icons/X.js +1 -1
- package/components/Icons/Zoom.js +1 -1
- package/components/Icons/index.js +1 -1
- package/components/Input/index.js +1 -1
- package/components/LinkList/index.js +1 -1
- package/components/List/index.js +1 -1
- package/components/Loader/index.js +1 -1
- package/components/Logo/index.js +1 -1
- package/components/Modal/index.js +1 -1
- package/components/NotificationPanel/index.js +1 -1
- package/components/Panel/index.js +1 -1
- package/components/PanelList/index.js +1 -1
- package/components/Portal/index.js +1 -1
- package/components/RadioButton/index.js +1 -1
- package/components/Slider/index.js +1 -1
- package/components/Spacer/index.js +1 -1
- package/components/StatusDot/index.js +1 -1
- package/components/Textarea/index.js +1 -1
- package/components/Tile/index.js +1 -1
- package/components/Title/index.js +1 -1
- package/components/Validation/index.js +1 -1
- package/constants-9528513d.js +2 -0
- package/constants-9528513d.js.map +1 -0
- package/constants.d.ts +9 -0
- package/constants.d.ts.map +1 -1
- package/hooks/useKeyboardEvent.d.ts +3 -0
- package/hooks/useKeyboardEvent.d.ts.map +1 -0
- package/hooks/useOutsideEvent.d.ts +9 -0
- package/hooks/useOutsideEvent.d.ts.map +1 -0
- package/hooks/useResizeObserver.d.ts +9 -0
- package/hooks/useResizeObserver.d.ts.map +1 -0
- package/hooks/useToggle.d.ts +12 -0
- package/hooks/useToggle.d.ts.map +1 -0
- package/hooks/useUuid.d.ts +7 -0
- package/hooks/useUuid.d.ts.map +1 -0
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/scss/_print.scss +2 -2
- package/useUuid-1ecdf8e8.js +2 -0
- package/useUuid-1ecdf8e8.js.map +1 -0
- package/uuid-11037462.js +2 -0
- package/uuid-11037462.js.map +1 -0
- package/Badge-2d8d73dd.js.map +0 -1
- package/Button-19ee3464.js.map +0 -1
- package/Checkbox-ca6c635d.js +0 -2
- package/Checkbox-ca6c635d.js.map +0 -1
- package/Close-476c50c6.js.map +0 -1
- package/FormGroup-a776b535.js.map +0 -1
- package/FormLayout-8d6d4552.js +0 -2
- package/FormLayout-8d6d4552.js.map +0 -1
- package/Input-cd941f2f.js.map +0 -1
- package/Loader-2f304e4f.js.map +0 -1
- package/Modal-d0213453.js.map +0 -1
- package/Panel-33611d84.js.map +0 -1
- package/RadioButton-6a868eb3.js.map +0 -1
- package/Textarea-1c857a8a.js.map +0 -1
- package/Title-2522b5b9.js.map +0 -1
- package/Validation-fa8b28c3.js +0 -2
- package/Validation-fa8b28c3.js.map +0 -1
- package/constants-4fe8c7ff.js +0 -2
- package/constants-4fe8c7ff.js.map +0 -1
- package/uuid-fe7442b7.js +0 -2
- package/uuid-fe7442b7.js.map +0 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
{
|
|
2
|
+
"props": {
|
|
3
|
+
"label": {
|
|
4
|
+
"defaultValue": null,
|
|
5
|
+
"description": "Label for dropdown. Synlig for skjermlesere.",
|
|
6
|
+
"name": "label",
|
|
7
|
+
"parent": {
|
|
8
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
9
|
+
"name": "DropdownProps"
|
|
10
|
+
},
|
|
11
|
+
"declarations": [
|
|
12
|
+
{
|
|
13
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
14
|
+
"name": "DropdownProps"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"required": true,
|
|
18
|
+
"type": {
|
|
19
|
+
"name": "string"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"toggleLabel": {
|
|
23
|
+
"defaultValue": null,
|
|
24
|
+
"description": "Tekst på knappen som åpner dropdownen",
|
|
25
|
+
"name": "toggleLabel",
|
|
26
|
+
"parent": {
|
|
27
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
28
|
+
"name": "DropdownProps"
|
|
29
|
+
},
|
|
30
|
+
"declarations": [
|
|
31
|
+
{
|
|
32
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
33
|
+
"name": "DropdownProps"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"required": true,
|
|
37
|
+
"type": {
|
|
38
|
+
"name": "string"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"children": {
|
|
42
|
+
"defaultValue": null,
|
|
43
|
+
"description": "Sets the dropdown content",
|
|
44
|
+
"name": "children",
|
|
45
|
+
"parent": {
|
|
46
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
47
|
+
"name": "DropdownProps"
|
|
48
|
+
},
|
|
49
|
+
"declarations": [
|
|
50
|
+
{
|
|
51
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
52
|
+
"name": "DropdownProps"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"fileName": "designsystem/node_modules/@types/react/index.d.ts",
|
|
56
|
+
"name": "TypeLiteral"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"required": false,
|
|
60
|
+
"type": {
|
|
61
|
+
"name": "ReactNode"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"closeText": {
|
|
65
|
+
"defaultValue": null,
|
|
66
|
+
"description": "Close button text",
|
|
67
|
+
"name": "closeText",
|
|
68
|
+
"parent": {
|
|
69
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
70
|
+
"name": "DropdownProps"
|
|
71
|
+
},
|
|
72
|
+
"declarations": [
|
|
73
|
+
{
|
|
74
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
75
|
+
"name": "DropdownProps"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"required": false,
|
|
79
|
+
"type": {
|
|
80
|
+
"name": "string"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"noCloseButton": {
|
|
84
|
+
"defaultValue": null,
|
|
85
|
+
"description": "No close button",
|
|
86
|
+
"name": "noCloseButton",
|
|
87
|
+
"parent": {
|
|
88
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
89
|
+
"name": "DropdownProps"
|
|
90
|
+
},
|
|
91
|
+
"declarations": [
|
|
92
|
+
{
|
|
93
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
94
|
+
"name": "DropdownProps"
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"required": false,
|
|
98
|
+
"type": {
|
|
99
|
+
"name": "boolean"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"onToggle": {
|
|
103
|
+
"defaultValue": null,
|
|
104
|
+
"description": "Called when dropdown is open/closed.",
|
|
105
|
+
"name": "onToggle",
|
|
106
|
+
"parent": {
|
|
107
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
108
|
+
"name": "DropdownProps"
|
|
109
|
+
},
|
|
110
|
+
"declarations": [
|
|
111
|
+
{
|
|
112
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
113
|
+
"name": "DropdownProps"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"required": false,
|
|
117
|
+
"type": {
|
|
118
|
+
"name": "((isOpen: boolean) => void)"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"open": {
|
|
122
|
+
"defaultValue": null,
|
|
123
|
+
"description": "Om dropdown er åpen",
|
|
124
|
+
"name": "open",
|
|
125
|
+
"parent": {
|
|
126
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
127
|
+
"name": "DropdownProps"
|
|
128
|
+
},
|
|
129
|
+
"declarations": [
|
|
130
|
+
{
|
|
131
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
132
|
+
"name": "DropdownProps"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"required": false,
|
|
136
|
+
"type": {
|
|
137
|
+
"name": "boolean"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"mode": {
|
|
141
|
+
"defaultValue": null,
|
|
142
|
+
"description": "Changes the visuals of the dropdown",
|
|
143
|
+
"name": "mode",
|
|
144
|
+
"parent": {
|
|
145
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
146
|
+
"name": "DropdownProps"
|
|
147
|
+
},
|
|
148
|
+
"declarations": [
|
|
149
|
+
{
|
|
150
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
151
|
+
"name": "DropdownProps"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"required": false,
|
|
155
|
+
"type": {
|
|
156
|
+
"name": "enum",
|
|
157
|
+
"raw": "\"onwhite\" | \"ongrey\" | \"onblueberry\" | \"oncherry\" | undefined",
|
|
158
|
+
"value": [
|
|
159
|
+
{
|
|
160
|
+
"value": "undefined"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"value": "\"onwhite\""
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"value": "\"ongrey\""
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"value": "\"onblueberry\""
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"value": "\"oncherry\""
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"transparent": {
|
|
178
|
+
"defaultValue": null,
|
|
179
|
+
"description": "Makes the background transparent",
|
|
180
|
+
"name": "transparent",
|
|
181
|
+
"parent": {
|
|
182
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
183
|
+
"name": "DropdownProps"
|
|
184
|
+
},
|
|
185
|
+
"declarations": [
|
|
186
|
+
{
|
|
187
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
188
|
+
"name": "DropdownProps"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"required": false,
|
|
192
|
+
"type": {
|
|
193
|
+
"name": "boolean"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"fluid": {
|
|
197
|
+
"defaultValue": null,
|
|
198
|
+
"description": "Makes the background transparent",
|
|
199
|
+
"name": "fluid",
|
|
200
|
+
"parent": {
|
|
201
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
202
|
+
"name": "DropdownProps"
|
|
203
|
+
},
|
|
204
|
+
"declarations": [
|
|
205
|
+
{
|
|
206
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
207
|
+
"name": "DropdownProps"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"required": false,
|
|
211
|
+
"type": {
|
|
212
|
+
"name": "boolean"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"disabled": {
|
|
216
|
+
"defaultValue": null,
|
|
217
|
+
"description": "Makes the dropdown disabled",
|
|
218
|
+
"name": "disabled",
|
|
219
|
+
"parent": {
|
|
220
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
221
|
+
"name": "DropdownProps"
|
|
222
|
+
},
|
|
223
|
+
"declarations": [
|
|
224
|
+
{
|
|
225
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
226
|
+
"name": "DropdownProps"
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
"required": false,
|
|
230
|
+
"type": {
|
|
231
|
+
"name": "boolean"
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"testId": {
|
|
235
|
+
"defaultValue": null,
|
|
236
|
+
"description": "Sets the data-testid attribute on the dropdown button.",
|
|
237
|
+
"name": "testId",
|
|
238
|
+
"parent": {
|
|
239
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
240
|
+
"name": "DropdownProps"
|
|
241
|
+
},
|
|
242
|
+
"declarations": [
|
|
243
|
+
{
|
|
244
|
+
"fileName": "src/components/Dropdown/Dropdown.tsx",
|
|
245
|
+
"name": "DropdownProps"
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
"required": false,
|
|
249
|
+
"type": {
|
|
250
|
+
"name": "string"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Dropdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,d as o}from"../../_rollupPluginBabelHelpers-4f206abf.js";import r,{useRef as t,useState as n}from"react";import{c as a}from"../../index-9b84fabc.js";import{Icon as l}from"../Icons/Icon.js";import{K as d,A as s,I as i}from"../../constants-9528513d.js";import c from"./styles.module.scss";import u from"../Icons/PlusSmall.js";import{B as p}from"../../Button-9f2ce63d.js";import{u as m}from"../../useHover-026f72c1.js";import{a as f,u as _,d as g,b as v,c as w}from"../../useUuid-1ecdf8e8.js";import{t as b}from"../../index-d1c9177a.js";import"../../_tslib-51c8a283.js";import"../../color-e7d082c1.js";import"../../Loader-670979af.js";import"../../uuid-11037462.js";import"../Loader/styles.module.scss";import"../../useWindowSize-5cc481da.js";import"../../grid-c105cad1.js";import"../Button/styles.module.scss";import"../../usePrevious-ae293b10.js";import"../../palette-f206f488.js";var y;!function(e){e.onwhite="onwhite",e.ongrey="ongrey",e.onblueberry="onblueberry",e.oncherry="oncherry"}(y||(y={}));export default function(h){var j,E=h.label,x=h.toggleLabel,k=h.closeText,N=void 0===k?"Lukk":k,I=h.noCloseButton,H=void 0!==I&&I,A=h.onToggle,B=h.open,C=void 0!==B&&B,D=h.children,L=h.mode,P=void 0===L?y.onwhite:L,S=h.transparent,U=void 0!==S&&S,z=h.fluid,R=void 0!==z&&z,T=h.testId,K=h.disabled,V=t(null),W=t(null),X=m(),q=X.hoverRef,F=X.isHovered,G=f(!K&&C,A),J=G.value,M=G.toggleValue,O=t(r.Children.map(D,(function(){return r.createRef()}))),Q=n(),Y=e(Q,2),Z=Y[0],$=Y[1],ee=(_(q)||{}).width,oe=g(),re=g(),te=g(),ne=function(){var e;M(),null===(e=W.current)||void 0===e||e.focus()},ae=function(){var e;M(),null===(e=q.current)||void 0===e||e.focus()};v("keydown",V,[d.ArrowDown,d.ArrowUp,d.End,d.Enter,d.Escape,d.Home],(function(e){var o;if(e.preventDefault(),O.current)if(J)if(e.key===d.Escape&&J)ae();else{var r=O.current.findIndex((function(o){return o.current===e.target})),t=r;e.key===d.Home?t=0:e.key===d.End?t=O.current.length-1:e.key===d.ArrowDown&&r<O.current.length-1?t=r+1:e.key===d.ArrowUp&&r>0?t=r-1:e.key===d.Enter&&-1!==r&&(t=r),-1!==t&&(null===(o=O.current[t].current)||void 0===o||o.focus(),$(t))}else ne()})),w(V,(function(){return J&&ae()}));var le=a(c.dropdown__toggle,!K&&(o(j={},c["dropdown__toggle--on-white"],P===y.onwhite),o(j,c["dropdown__toggle--on-grey"],P===y.ongrey),o(j,c["dropdown__toggle--on-blueberry"],P===y.onblueberry),o(j,c["dropdown__toggle--on-cherry"],P===y.oncherry),o(j,c["dropdown__toggle--transparent"],U),o(j,c["dropdown__toggle--fluid"],R),o(j,c["dropdown__toggle--open"],J),j)),de=a(c.dropdown__content,J&&c["dropdown__content--open"]);return r.createElement("div",{className:c.dropdown,ref:V},r.createElement("span",{id:oe,className:c.dropdown__label},E),r.createElement("button",{type:"button",onClick:function(){return!J&&ne()},className:le,ref:q,"data-testid":T,"data-analyticsid":s.Dropdown,disabled:K,"aria-labelledby":re,"aria-haspopup":"listbox","aria-expanded":J},r.createElement("span",{id:re,className:c.dropdown__toggle__label},x),r.createElement(l,{color:K?b.palette.neutral500:b.palette.blueberry600,svgIcon:u,className:c.dropdown__icon,isHovered:F,size:i.XSmall})),r.createElement("div",{className:de,style:{width:R?"100%":"".concat(ee,"px")}},r.createElement("ul",{className:c.dropdown__options,role:"listbox","aria-labelledby":oe,tabIndex:-1,"aria-activedescendant":void 0!==Z?"".concat(te,"-").concat(Z):void 0,ref:W},r.Children.map(D,(function(e,o){var t;return r.createElement("li",{className:c.dropdown__input,role:"option",id:"".concat(te,"-").concat(o)},r.cloneElement(e,{ref:null===(t=O.current)||void 0===t?void 0:t[o]}))}))),!H&&r.createElement("div",{className:c.dropdown__close},r.createElement(p,{onClick:ae,fluid:!0,"aria-expanded":J},N))))}export{y as DropdownMode};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
@import '../../scss/_spacers.scss';
|
|
2
|
+
@import '../../scss/_breakpoints.scss';
|
|
3
|
+
@import '../../scss/_palette.scss';
|
|
4
|
+
@import '../../scss/_font-settings.scss';
|
|
5
|
+
@import 'bootstrap/scss/mixins/_screen-reader.scss';
|
|
6
|
+
|
|
7
|
+
.dropdown {
|
|
8
|
+
position: relative;
|
|
9
|
+
|
|
10
|
+
&__label {
|
|
11
|
+
@include sr-only();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&__toggle {
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
align-items: center;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
border-radius: 0;
|
|
20
|
+
border-width: 2px;
|
|
21
|
+
border-style: solid;
|
|
22
|
+
padding: 0 getSpacer(3xs) 0 getSpacer(s);
|
|
23
|
+
font-size: $font-size-sm;
|
|
24
|
+
line-height: 1.3rem; // Custom fordi teksten skal henge bedre sammen om den går over to linjer
|
|
25
|
+
|
|
26
|
+
@media (min-width: map-get($grid-breakpoints, md)) {
|
|
27
|
+
padding: getSpacer(3xs) getSpacer(3xs) getSpacer(3xs) getSpacer(s);
|
|
28
|
+
font-size: $font-size-md;
|
|
29
|
+
line-height: 1.5rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:focus {
|
|
33
|
+
outline: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:disabled {
|
|
37
|
+
background-color: $neutral50;
|
|
38
|
+
border-color: $neutral500;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&--on-white,
|
|
42
|
+
&--on-grey {
|
|
43
|
+
border-color: $neutral700;
|
|
44
|
+
background-color: $white;
|
|
45
|
+
&:hover {
|
|
46
|
+
background-color: $neutral50;
|
|
47
|
+
box-shadow: 0 0 0 1px $neutral700;
|
|
48
|
+
}
|
|
49
|
+
&:focus {
|
|
50
|
+
border-color: $black;
|
|
51
|
+
box-shadow: 0 0 0 1px $black;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&--on-blueberry {
|
|
56
|
+
border-color: $blueberry500;
|
|
57
|
+
background-color: $white;
|
|
58
|
+
&:hover {
|
|
59
|
+
background-color: $blueberry50;
|
|
60
|
+
box-shadow: 0 0 0 1px $blueberry500;
|
|
61
|
+
}
|
|
62
|
+
&:focus {
|
|
63
|
+
border-color: $black;
|
|
64
|
+
box-shadow: 0 0 0 1px $black;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&--on-cherry {
|
|
69
|
+
border-color: $cherry500;
|
|
70
|
+
background-color: $white;
|
|
71
|
+
&:hover {
|
|
72
|
+
background-color: $cherry50;
|
|
73
|
+
box-shadow: 0 0 0 1px $cherry500;
|
|
74
|
+
}
|
|
75
|
+
&:focus {
|
|
76
|
+
border-color: $black;
|
|
77
|
+
box-shadow: 0 0 0 1px $black;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&--open#{&}--on-white,
|
|
82
|
+
&--open#{&}--on-grey {
|
|
83
|
+
background-color: $neutral50;
|
|
84
|
+
&:hover {
|
|
85
|
+
background-color: $white;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&--open#{&}--on-blueberry {
|
|
90
|
+
background-color: $blueberry50;
|
|
91
|
+
&:hover {
|
|
92
|
+
background-color: $white;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&--open#{&}--on-cherry {
|
|
97
|
+
background-color: $cherry50;
|
|
98
|
+
&:hover {
|
|
99
|
+
background-color: $white;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&--transparent {
|
|
104
|
+
background-color: transparent;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&--transparent#{&}--on-grey {
|
|
108
|
+
&:hover {
|
|
109
|
+
background-color: $neutral100;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&--transparent#{&}--on-blueberry {
|
|
114
|
+
&:hover {
|
|
115
|
+
background-color: $blueberry100;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&--transparent#{&}--on-cherry {
|
|
120
|
+
&:hover {
|
|
121
|
+
background-color: $cherry100;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&--transparent#{&}--open#{&}--on-grey {
|
|
126
|
+
background-color: $neutral100;
|
|
127
|
+
&:hover {
|
|
128
|
+
background-color: transparent;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&--transparent#{&}--open#{&}--on-blueberry {
|
|
133
|
+
background-color: $blueberry100;
|
|
134
|
+
&:hover {
|
|
135
|
+
background-color: transparent;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&--transparent#{&}--open#{&}--on-cherry {
|
|
140
|
+
background-color: $cherry100;
|
|
141
|
+
&:hover {
|
|
142
|
+
background-color: transparent;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&--fluid {
|
|
147
|
+
width: 100%;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&__label {
|
|
151
|
+
padding: getSpacer(3xs) 0;
|
|
152
|
+
@media (min-width: map-get($grid-breakpoints, md)) {
|
|
153
|
+
padding: getSpacer(2xs) 0;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&__icon {
|
|
159
|
+
margin-left: getSpacer(2xs);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&__content {
|
|
163
|
+
display: none;
|
|
164
|
+
position: absolute;
|
|
165
|
+
background-color: $white;
|
|
166
|
+
margin-top: getSpacer(2xs);
|
|
167
|
+
box-shadow: 0 0 0 2px $blueberry500;
|
|
168
|
+
&--open {
|
|
169
|
+
display: block;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
&__options {
|
|
173
|
+
overflow-x: hidden;
|
|
174
|
+
overflow-y: auto;
|
|
175
|
+
max-height: 384px;
|
|
176
|
+
list-style: none;
|
|
177
|
+
padding: 0;
|
|
178
|
+
margin: 0;
|
|
179
|
+
@media (min-width: map-get($grid-breakpoints, md)) {
|
|
180
|
+
max-height: 464px;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
&__close {
|
|
184
|
+
padding: getSpacer(s);
|
|
185
|
+
}
|
|
186
|
+
&__input {
|
|
187
|
+
border-bottom: 1px solid $neutral300;
|
|
188
|
+
padding: getSpacer(2xs) getSpacer(s) getSpacer(2xs) getSpacer(s);
|
|
189
|
+
@media (min-width: map-get($grid-breakpoints, md)) {
|
|
190
|
+
padding: getSpacer(s);
|
|
191
|
+
}
|
|
192
|
+
&:last-child {
|
|
193
|
+
border-bottom: none;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-4f206abf.js";import t,{useState as n,useRef as r,useEffect as a}from"react";import{Icon as o}from"../Icons/Icon.js";import{Z as s,A as i,I as d}from"../../constants-
|
|
1
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-4f206abf.js";import t,{useState as n,useRef as r,useEffect as a}from"react";import{Icon as o}from"../Icons/Icon.js";import{Z as s,A as i,I as d}from"../../constants-9528513d.js";import{u as c}from"../../useHover-026f72c1.js";import{u as l}from"../../usePrevious-ae293b10.js";import p from"./styles.module.scss";import{c as m}from"../../index-9b84fabc.js";import _ from"../Icons/ChevronDown.js";import u from"../Icons/ChevronUp.js";import{B as x}from"../../Button-9f2ce63d.js";import{u as f}from"../../useSticky-807e5dde.js";import"../../_tslib-51c8a283.js";import"../../color-e7d082c1.js";import"../../index-d1c9177a.js";import"../../palette-f206f488.js";import"../../grid-c105cad1.js";import"../../Loader-670979af.js";import"../../uuid-11037462.js";import"../Loader/styles.module.scss";import"../../useWindowSize-5cc481da.js";import"../Button/styles.module.scss";var g;!function(e){e.small="small",e.large="large"}(g||(g={}));export default function(v){var j=v.title,b=v.children,E=v.size,I=void 0===E?g.small:E,y=v.color,h=v.svgIcon,N=v.expanded,k=void 0!==N&&N,z=v.noNestedLine,H=void 0!==z&&z,w=v.sticky,S=void 0!==w&&w,B=v.testId,C=v.onExpand,L=n(k),W=e(L,2),X=W[0],P=W[1],T=l(X),A=r(null),D=r(null),O=r(null),U=c(D).isHovered,Z=f(A,D),q=Z.isOutsideWindow,F=Z.isLeavingWindow,G=Z.offsetHeight,J=Z.contentWidth,K=S&&X&&q;a((function(){k!==X&&P(k)}),[k]),a((function(){C&&X!==!!T&&C(X)}),[X,C]);var M=function(e){return t.createElement("span",{className:m(p.expander__icon,p["expander__icon--".concat(e)])},t.createElement(o,{svgIcon:X?u:_,size:d.XSmall,isHovered:U}))},Q=m(p.expander__trigger,p["expander__trigger--".concat(I)],I===g.large&&p["expander__trigger--".concat(y||"neutral")],I===g.large&&h&&p["expander__trigger--icon"],X&&p["expander__trigger--expanded"],K&&!F&&p["expander__trigger--sticky"],K&&F&&p["expander__trigger--absolute"]),R=m(p.expander__button,X&&p["expander__button--expanded"],K&&!F&&p["expander__button--sticky"],K&&F&&p["expander__button--absolute"]),V=m(p.expander__content,p["expander__content--".concat(I)],I===g.large&&p["expander__content--".concat(y||"neutral")],I===g.large&&h&&p["expander__content--icon"],X&&p["expander__content--expanded"],I===g.small&&!H&&p["expander__content--nested-line"]);return t.createElement("div",{className:p.expander,ref:A,style:{paddingTop:K&&G?"".concat(G,"px"):void 0}},I===g.large?t.createElement("button",{className:Q,style:{zIndex:U||K?s.ExpanderTrigger:void 0,width:K&&J?"".concat(J,"px"):void 0},"aria-expanded":X,ref:D,onClick:function(){return P(!X)},"data-testid":B,"data-analyticsid":i.Expander},I===g.small&&M("left"),h&&t.createElement("span",{className:m(p.expander__icon,p["expander__icon--left"])},t.createElement(o,{svgIcon:h,size:d.XSmall,isHovered:U})),j,I===g.large&&M("right")):t.createElement(x,{variant:"borderless",className:R,"aria-expanded":X,ref:D,onClick:function(){return P(!X)},testId:B,"data-analyticsid":i.Expander},t.createElement(o,{svgIcon:X?u:_,size:d.XSmall}),j),t.createElement("div",{className:V,ref:O},b))}export{g as ExpanderSize};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,d as n}from"../../_rollupPluginBabelHelpers-4f206abf.js";import t,{useState as a,useEffect as i}from"react";import{Icon as r}from"../Icons/Icon.js";import{A as o,I as d}from"../../constants-
|
|
1
|
+
import{_ as e,d as n}from"../../_rollupPluginBabelHelpers-4f206abf.js";import t,{useState as a,useEffect as i}from"react";import{Icon as r}from"../Icons/Icon.js";import{A as o,I as d}from"../../constants-9528513d.js";import s from"../Icons/ChevronUp.js";import l from"../Icons/ChevronDown.js";import{u as c}from"../../useHover-026f72c1.js";import{u as m}from"../../usePrevious-ae293b10.js";import{u as p,B as u}from"../../useBreakpoint-6eb418f7.js";import{c as f}from"../../index-9b84fabc.js";import x from"./styles.module.scss";import"../../_tslib-51c8a283.js";import"../../grid-c105cad1.js";var v=t.forwardRef((function(v,g){var E,_=v.id,h=v.children,b=v.padding,j=void 0===b||b,k=v.color,N=void 0===k?"neutral":k,I=v.className,w=void 0===I?"":I,C=v.icon,H=v.large,y=void 0!==H&&H,B=v.title,O=v.expanded,R=void 0!==O&&O,L=v.testId,P=v.handleExpanderClick,S=v.onExpand,z=a(R),W=e(z,2),X=W[0],A=W[1],D=m(X),T=c(),U=T.hoverRef,V=T.isHovered,q=p(),F=f(x["expander-list-link"],x["expander-list-link--".concat(N)],(n(E={},x["expander-list-link--closed"],!X),n(E,x["expander-list-link--large"],y),E)),G=f(x["expander-list-link__main-content"],X&&x["expander-list-link__main-content--expanded"],j?x["expander-list-link__main-content--padding"]:"");return i((function(){R!==X&&A(R)}),[R]),i((function(){S&&X!==!!D&&S(X)}),[X,S]),t.createElement("li",{className:w,ref:g},t.createElement("button",{id:_,onClick:P,"data-testid":L,"data-analyticsid":o.ExpanderListExpander,className:F,ref:U,"aria-expanded":X},C&&t.createElement("span",{className:x["expander-list-link__icon"]},t.cloneElement(C,{size:q===u.xs?d.XSmall:d.Small,isHovered:V})),t.createElement("span",{className:x["expander-list-link__title"]},B),t.createElement("span",{className:x["expander-list-link__chevron"]},t.createElement(r,{size:d.XSmall,svgIcon:X?s:l,isHovered:V}))),t.createElement("div",{className:G},h))})),g=t.forwardRef((function(r,d){var s=r.children,l=r.childPadding,c=void 0===l||l,m=r.large,p=r.isOpen,u=void 0!==p&&p,g=r.color,E=r.className,_=void 0===E?"":E,h=r.accordion,b=void 0!==h&&h,j=r.topBorder,k=void 0===j||j,N=r.bottomBorder,I=void 0===N||N,w=r.testId,C=a({}),H=e(C,2),y=H[0],B=H[1],O=a(),R=e(O,2),L=R[0],P=R[1],S=t.Children.count(s),z=f(x["expander-list"],_);return i((function(){var e,n,t,a,i;!b||!L||(e=L.getBoundingClientRect(),n=e.top,t=e.left,a=e.bottom,i=e.right,n>=0&&t>=0&&a<=(window.innerHeight||document.documentElement.clientHeight)&&i<=(window.innerWidth||document.documentElement.clientWidth))||L.scrollIntoView()}),[b,L]),i((function(){if(u){var e="expander-0";B((function(t){return b?n({},e,!t[e]):Object.assign(Object.assign({},t),n({},e,!t[e]))}))}}),[u]),t.createElement("ul",{className:z,ref:d,"data-testid":w,"data-analyticsid":o.ExpanderList},t.Children.map(s,(function(e,a){if(e.type===v){var i=y["expander-".concat(a)],r=function(e){var t;return f(x["expander-list__item"],(n(t={},x["expander-list__item--top"],0===e&&k),n(t,x["expander-list__item--no-bottom"],e===S-1&&!I),t))}(a);return t.cloneElement(e,{id:"expander-".concat(a),key:"expander-".concat(a),expanded:i,padding:c,color:g,large:m,"aria-expanded":i,className:r,handleExpanderClick:function(e){return function(e,t){B((function(e){return b?n({},t,!e[t]):Object.assign(Object.assign({},e),n({},t,!e[t]))})),P(e.currentTarget)}(e,"expander-".concat(a))}})}return e})))}));g.Expander=v,v.displayName="ExpanderList.Expander";export default g;export{g as ExpanderList};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import r,{createContext as e,useCallback as t,useRef as n,useState as i,useEffect as a,useMemo as u,isValidElement as o}from"react";import{V as s}from"../../Validation-fa8b28c3.js";import{F as c}from"../../FormGroup-a776b535.js";import{C as f}from"../../Checkbox-ca6c635d.js";import{B as l}from"../../Button-19ee3464.js";import{R as d}from"../../RadioButton-6a868eb3.js";import{T as m}from"../../Textarea-1c857a8a.js";import{I as v}from"../../Input-cd941f2f.js";import g from"../Icons/Hospital.js";import{F as p,a as b}from"../../FormLayout-8d6d4552.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../constants-4fe8c7ff.js";import"../../_rollupPluginBabelHelpers-4f206abf.js";import"../FormGroup/styles.module.scss";import"../../Title-2522b5b9.js";import"../Title/styles.module.scss";import"../../uuid-fe7442b7.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../_tslib-51c8a283.js";import"../../color-e7d082c1.js";import"../../index-d1c9177a.js";import"../../palette-f206f488.js";import"../../grid-c105cad1.js";import"../Checkbox/styles.module.scss";import"../../Loader-2f304e4f.js";import"../Loader/styles.module.scss";import"../../useHover-026f72c1.js";import"../../useWindowSize-5cc481da.js";import"../Button/styles.module.scss";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../useBreakpoint-6eb418f7.js";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";var h=function(r){return r instanceof HTMLElement},y="blur",j="change",O="input",k="onBlur",V="onChange",E="onSubmit",A="onTouched",x="all",w="max",S="min",D="maxLength",F="minLength",R="pattern",C="required",I="validate";var N=function(r){return null==r},B=function(r){return"object"==typeof r},L=function(r){return!N(r)&&!Array.isArray(r)&&B(r)&&!(r instanceof Date)},T=function(r){return/^\w*$/.test(r)},q=function(r){return r.filter(Boolean)},M=function(r){return q(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function W(r,e,t){for(var n=-1,i=T(e)?[e]:M(e),a=i.length,u=a-1;++n<a;){var o=i[n],s=t;if(n!==u){var c=r[o];s=L(c)||Array.isArray(c)?c:isNaN(+i[n+1])?{}:[]}r[o]=s,r=r[o]}return r}var H=function(r,e){for(var t in void 0===e&&(e={}),r)T(t)?e[t]=r[t]:W(e,t,r[t]);return e},_=function(r){return void 0===r},P=function(r,e,t){void 0===r&&(r={});var n=q(e.split(/[,[\].]+?/)).reduce((function(r,e){return N(r)?r:r[e]}),r);return _(n)||n===r?_(r[e])?t:r[e]:n},z=function(r,e){h(r)&&r.removeEventListener&&(r.removeEventListener(O,e),r.removeEventListener(j,e),r.removeEventListener(y,e))},U={isValid:!1,value:null},$=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),U):U},G=function(r){return"radio"===r.type},J=function(r){return"file"===r.type},K=function(r){return"checkbox"===r.type},Q=function(r){return"select-multiple"===r.type},X={value:!1,isValid:!1},Y={value:!0,isValid:!0},Z=function(r){if(Array.isArray(r)){if(r.length>1){var e=r.filter((function(r){return r&&r.ref.checked})).map((function(r){return r.ref.value}));return{value:e,isValid:!!e.length}}var t=r[0].ref,n=t.checked,i=t.value,a=t.attributes;return n?a&&!_(a.value)?_(i)||""===i?Y:{value:i,isValid:!0}:Y:X}return X};function rr(r,e,t,n,i){var a,u=r.current[e];if(u){var o=u.ref,s=o.value,c=o.disabled,f=u.ref,l=u.valueAsNumber,d=u.valueAsDate,m=u.setValueAs;if(c&&n)return;return J(f)?f.files:G(f)?$(u.options).value:Q(f)?(a=f.options,[].concat(a).filter((function(r){return r.selected})).map((function(r){return r.value}))):K(f)?Z(u.options).value:i?s:l?""===s?NaN:+s:d?f.valueAsDate:m?m(s):s}if(t)return P(t.current,e)}function er(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&er(r.parentNode)}var tr=function(r){return L(r)&&!Object.keys(r).length},nr=function(r){return"boolean"==typeof r};function ir(r,e){var t,n=T(e)?[e]:M(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=_(r)?n++:r[e[n++]];return r}(r,n),a=n[n.length-1];i&&delete i[a];for(var u=0;u<n.slice(0,-1).length;u++){var o=-1,s=void 0,c=n.slice(0,-(u+1)),f=c.length-1;for(u>0&&(t=r);++o<c.length;){var l=c[o];s=s?s[l]:r[l],f===o&&(L(s)&&tr(s)||Array.isArray(s)&&!s.filter((function(r){return L(r)&&!tr(r)||nr(r)})).length)&&(t?delete t[l]:delete r[l]),t=s}}return r}var ar=function(r,e){return r&&r.ref===e};var ur=function(r){return N(r)||!B(r)};function or(r,e){if(ur(r)||ur(e))return e;for(var t in e){var n=r[t],i=e[t];try{r[t]=L(n)&&L(i)||Array.isArray(n)&&Array.isArray(i)?or(n,i):i}catch(r){}}return r}function sr(r,e,t){if(ur(r)||ur(e)||r instanceof Date||e instanceof Date)return r===e;if(!o(r)){var n=Object.keys(r),i=Object.keys(e);if(n.length!==i.length)return!1;for(var a=0,u=n;a<u.length;a+=1){var s=u[a],c=r[s];if(!t||"ref"!==s){var f=e[s];if((L(c)||Array.isArray(c))&&(L(f)||Array.isArray(f))?!sr(c,f,t):c!==f)return!1}}}return!0}function cr(r,e,t,n,i){for(var a,u=-1;++u<r.length;){for(var o in r[u])Array.isArray(r[u][o])?(!t[u]&&(t[u]={}),t[u][o]=[],cr(r[u][o],P(e[u]||{},o,[]),t[u][o],t[u],o)):sr(P(e[u]||{},o),r[u][o])?W(t[u]||{},o):t[u]=Object.assign(Object.assign({},t[u]),((a={})[o]=!0,a));n&&!t.length&&delete n[i]}return t}var fr=function(r){return"string"==typeof r},lr=function(r,e,t,n,i){var a={},u=function(e){(_(i)||(fr(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(a[e]=rr(r,e,void 0,n))};for(var o in r.current)u(o);return t?H(a):or(e,H(a))},dr=function(r){return r instanceof RegExp},mr=function(r){return L(r)&&!dr(r)?r:{value:r,message:""}},vr=function(r){return"function"==typeof r},gr=function(r){return fr(r)||o(r)};function pr(r,e,t){if(void 0===t&&(t="validate"),gr(r)||nr(r)&&!r)return{type:t,message:gr(r)?r:"",ref:e}}var br=function(r,e,t,n,i){var a;return e?Object.assign(Object.assign({},t[r]),{types:Object.assign(Object.assign({},t[r]&&t[r].types?t[r].types:{}),(a={},a[n]=i||!0,a))}):{}},hr=async function(r,e,t,n){var i=t.ref,a=t.ref.value,u=t.options,o=t.required,s=t.maxLength,c=t.minLength,f=t.min,l=t.max,d=t.pattern,m=t.validate,v=i.name,g={},p=G(i),b=K(i),h=p||b,y=""===a,j=br.bind(null,v,e,g),O=function(r,e,t,n,a){void 0===n&&(n=D),void 0===a&&(a=F);var u=r?e:t;g[v]=Object.assign({type:r?n:a,message:u,ref:i},j(r?n:a,u))};if(o&&(!p&&!b&&(y||N(a))||nr(a)&&!a||b&&!Z(u).isValid||p&&!$(u).isValid)){var k=gr(o)?{value:!!o,message:o}:mr(o),V=k.value,E=k.message;if(V&&(g[v]=Object.assign({type:C,message:E,ref:h?((r.current[v].options||[])[0]||{}).ref:i},j(C,E)),!e))return g}if(!(N(f)&&N(l)||""===a)){var A,x,B=mr(l),T=mr(f);if(isNaN(a)){var q=i.valueAsDate||new Date(a);fr(B.value)&&(A=q>new Date(B.value)),fr(T.value)&&(x=q<new Date(T.value))}else{var M=i.valueAsNumber||parseFloat(a);N(B.value)||(A=M>B.value),N(T.value)||(x=M<T.value)}if((A||x)&&(O(!!A,B.message,T.message,w,S),!e))return g}if(fr(a)&&!y&&(s||c)){var W=mr(s),H=mr(c),_=!N(W.value)&&a.length>W.value,P=!N(H.value)&&a.length<H.value;if((_||P)&&(O(_,W.message,H.message),!e))return g}if(fr(a)&&d&&!y){var z=mr(d),U=z.value,J=z.message;if(dr(U)&&!U.test(a)&&(g[v]=Object.assign({type:R,message:J,ref:i},j(R,J)),!e))return g}if(m){var Q=rr(r,v,n,!1,!0),X=h&&u?u[0].ref:i;if(vr(m)){var Y=pr(await m(Q),X);if(Y&&(g[v]=Object.assign(Object.assign({},Y),j(I,Y.message)),!e))return g}else if(L(m)){for(var er={},ir=0,ar=Object.entries(m);ir<ar.length;ir+=1){var ur=ar[ir],or=ur[0],sr=ur[1];if(!tr(er)&&!e)break;var cr=pr(await sr(Q),X,or);cr&&(er=Object.assign(Object.assign({},cr),j(or,cr.message)),e&&(g[v]=er))}if(!tr(er)&&(g[v]=Object.assign({ref:X},er),!e))return g}}return g},yr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(L(e)?"."+n:"["+n+"]");ur(e[n])?t.push(i):yr(i,e[n],t)}return t},jr=function(r,e,t,n,i){var a=void 0;return t.add(e),tr(r)||(a=P(r,e),(L(a)||Array.isArray(a))&&yr(e,a).forEach((function(r){return t.add(r)}))),_(a)?i?n:P(n,e):a},Or=function(r){return r.substring(0,r.indexOf("["))},kr=function(r,e){return[].concat(r).some((function(r){return function(r,e){return RegExp(("^"+e+"([|.)\\d+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r)}(e,r)}))};var Vr="undefined"!=typeof window&&"undefined"!=typeof document;function Er(r){var e,t;if(ur(r)||Vr&&(r instanceof File||h(r)))return r;if(!["Set","Map","Object","Date","Array"].includes(null===(e=r.constructor)||void 0===e?void 0:e.name))return r;if(r instanceof Date)return t=new Date(r.getTime());if(r instanceof Set){t=new Set;for(var n=0,i=r;n<i.length;n+=1){var a=i[n];t.add(a)}return t}if(r instanceof Map){t=new Map;for(var u=0,o=r.keys();u<o.length;u+=1){var s=o[u];t.set(s,Er(r.get(s)))}return t}for(var c in t=Array.isArray(r)?[]:{},r)t[c]=Er(r[c]);return t}var Ar,xr=function(r){return{isOnSubmit:!r||r===E,isOnBlur:r===k,isOnChange:r===V,isOnAll:r===x,isOnTouch:r===A}},wr=function(r){return G(r)||K(r)},Sr="undefined"==typeof window,Dr=Vr?"Proxy"in window:"undefined"!=typeof Proxy;function Fr(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=E);var o=r.reValidateMode;void 0===o&&(o=V);var s=r.resolver,c=r.context,f=r.defaultValues;void 0===f&&(f={});var l=r.shouldFocusError;void 0===l&&(l=!0);var d=r.shouldUnregister;void 0===d&&(d=!0);var m=r.criteriaMode,v=n({}),g=n({}),p=n({}),b=n(new Set),k=n({}),A=n({}),w=n({}),S=n({}),D=n(f),F=n(!1),R=n(!1),C=n(),I=n({}),B=n({}),M=n(c),U=n(s),$=n(new Set),X=n(xr(e)),Y=X.current,Z=Y.isOnSubmit,nr=Y.isOnTouch,dr=m===x,mr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Z,errors:{}}),gr=mr[0],pr=mr[1],br=n({isDirty:!Dr,dirtyFields:!Dr,touched:!Dr||nr,isValidating:!Dr,isSubmitting:!Dr,isValid:!Dr}),Ar=n(gr),Fr=n(),Rr=n(xr(o)).current,Cr=Rr.isOnBlur,Ir=Rr.isOnChange;M.current=c,U.current=s,Ar.current=gr,I.current=d?{}:tr(I.current)?Er(f):I.current;var Nr=t((function(r){void 0===r&&(r={}),F.current||(Ar.current=Object.assign(Object.assign({},Ar.current),r),pr(Ar.current))}),[]),Br=function(){return br.current.isValidating&&Nr({isValidating:!0})},Lr=t((function(r,e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n={});var a=t||function(r){var e=r.errors,t=r.name,n=r.error,i=r.validFields,a=r.fieldsWithValidation,u=_(n),o=P(e,t);return u&&!!o||!u&&!sr(o,n,!0)||u&&P(a,t)&&!P(i,t)}({errors:Ar.current.errors,error:e,name:r,validFields:S.current,fieldsWithValidation:w.current}),u=P(Ar.current.errors,r);e?(ir(S.current,r),a=a||!u||!sr(u,e,!0),W(Ar.current.errors,r,e)):((P(w.current,r)||U.current)&&(W(S.current,r,!0),a=a||u),ir(Ar.current.errors,r)),(a&&!N(t)||!tr(n)||br.current.isValidating)&&Nr(Object.assign(Object.assign(Object.assign({},n),U.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Tr=t((function(r,e){var t=v.current[r],n=t.ref,i=t.options,a=Vr&&h(n)&&N(e)?"":e;G(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===a})):J(n)&&!fr(a)?n.files=a:Q(n)?[].concat(n.options).forEach((function(r){return r.selected=a.includes(r.value)})):K(n)&&i?i.length>1?i.forEach((function(r){var e=r.ref;return e.checked=Array.isArray(a)?!!a.find((function(r){return r===e.value})):a===e.value})):i[0].ref.checked=!!a:n.value=a}),[]),qr=t((function(r,e){if(br.current.isDirty){var t=Jr();return r&&e&&W(t,r,e),!sr(t,D.current)}return!1}),[]),Mr=t((function(r,e){if(void 0===e&&(e=!0),br.current.isDirty||br.current.dirtyFields){var t=!sr(P(D.current,r),rr(v,r,I)),n=P(Ar.current.dirtyFields,r),i=Ar.current.isDirty;t?W(Ar.current.dirtyFields,r,!0):ir(Ar.current.dirtyFields,r);var a={isDirty:qr(),dirtyFields:Ar.current.dirtyFields},u=br.current.isDirty&&i!==a.isDirty||br.current.dirtyFields&&n!==P(Ar.current.dirtyFields,r);return u&&e&&Nr(a),u?a:{}}return{}}),[]),Wr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!v.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await hr(v,dr,v.current[r],I))[r];return Lr(r,t,e),_(t)}),[Lr,dr]),Hr=t((async function(r){var e=(await U.current(Jr(),M.current,dr)).errors,t=Ar.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=P(e,r);return t?W(Ar.current.errors,r,t):ir(Ar.current.errors,r),!t})).every(Boolean);return Nr({isValid:tr(e),isValidating:!1}),n}var i=P(e,r);return Lr(r,i,t!==tr(e),{},tr(e)),!i}),[Lr,dr]),_r=t((async function(r){var e=r||Object.keys(v.current);if(Br(),U.current)return Hr(e);if(Array.isArray(e)){!r&&(Ar.current.errors={});var t=await Promise.all(e.map((async function(r){return await Wr(r,null)})));return Nr({isValidating:!1}),t.every(Boolean)}return await Wr(e)}),[Hr,Wr]),Pr=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};W(a,r,e);for(var u=0,o=yr(r,e);u<o.length;u+=1){var s=o[u];v.current[s]&&(Tr(s,P(a,s)),n&&Mr(s),i&&_r(s))}}),[_r,Tr,Mr]),zr=t((function(r,e,t){var n,i;if(!d&&!ur(e)&&W(I.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),v.current[r])Tr(r,e),t.shouldDirty&&Mr(r),t.shouldValidate&&_r(r);else if(!ur(e)&&(Pr(r,e,t),$.current.has(r))){var a=Or(r)||r;W(g.current,r,e),B.current[a](((n={})[a]=P(g.current,a),n)),(br.current.isDirty||br.current.dirtyFields)&&t.shouldDirty&&(W(Ar.current.dirtyFields,r,function(r,e,t){return or(cr(r,e,t.slice(0,r.length)),cr(e,r,t.slice(0,r.length)))}(e,P(D.current,r,[]),P(Ar.current.dirtyFields,r,[]))),Nr({isDirty:!sr(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),D.current)}))}!d&&W(I.current,r,e)}),[Mr,Tr,Pr]),Ur=function(r){return R.current||b.current.has(r)||b.current.has((r.match(/\w+/)||[])[0])},$r=function(r){var e=!0;if(!tr(k.current))for(var t in k.current)r&&k.current[t].size&&!k.current[t].has(r)&&!k.current[t].has(Or(r))||(A.current[t](),e=!1);return e};function Gr(r){var e;if(!d){for(var t=Er(r),n=0,i=$.current;n<i.length;n+=1){var a=i[n];T(a)&&!t[a]&&(t=Object.assign(Object.assign({},t),((e={})[a]=[],e)))}return t}return r}function Jr(r){if(fr(r))return rr(v,r,I);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];W(e,i,rr(v,i,I))}return e}return Gr(lr(v,Er(I.current),d))}C.current=C.current?C.current:async function(r){var e,t,n=r.type,i=r.target,a=i.name,u=v.current[a];if(u){var o=n===y,s=function(r){var e=r.isOnBlur,t=r.isOnChange,n=r.isOnTouch,i=r.isTouched,a=r.isReValidateOnBlur,u=r.isReValidateOnChange,o=r.isBlurEvent,s=r.isSubmitted;return!r.isOnAll&&(!s&&n?!(i||o):(s?a:e)?!o:!(s?u:t)||o)}(Object.assign({isBlurEvent:o,isReValidateOnChange:Ir,isReValidateOnBlur:Cr,isTouched:!!P(Ar.current.touched,a),isSubmitted:Ar.current.isSubmitted},X.current)),c=Mr(a,!1),f=!tr(c)||!o&&Ur(a);if(o&&!P(Ar.current.touched,a)&&br.current.touched&&(W(Ar.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:Ar.current.touched})),!d&&K(i)&&W(I.current,a,rr(v,a)),s)return!o&&$r(a),(!tr(c)||f&&tr(c))&&Nr(c);if(Br(),U.current){var l=(await U.current(Jr(),M.current,dr)).errors,m=Ar.current.isValid;if(e=P(l,a),K(i)&&!e&&U.current){var g=Or(a),p=P(l,g,{});p.type&&p.message&&(e=p),g&&(p||P(Ar.current.errors,g))&&(a=g)}m!==(t=tr(l))&&(f=!0)}else e=(await hr(v,dr,u,I))[a];!o&&$r(a),Lr(a,e,f,c,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=tr(v.current)?D.current:{},t=(await U.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),M.current,dr)||{}).errors,n=tr(t);Ar.current.isValid!==n&&Nr({isValid:n})}),[dr]),Qr=t((function(r,e){!function(r,e,t,n,i,a){var u=t.ref,o=t.ref.name,s=r.current[o];if(!i){var c=rr(r,o,n);!_(c)&&W(n.current,o,c)}u.type&&s?G(u)||K(u)?Array.isArray(s.options)&&s.options.length?(q(s.options).forEach((function(r,t){void 0===r&&(r={}),(er(r.ref)&&ar(r,r.ref)||a)&&(z(r.ref,e),ir(s.options,"["+t+"]"))})),s.options&&!q(s.options).length&&delete r.current[o]):delete r.current[o]:(er(u)&&ar(s,u)||a)&&(z(u,e),delete r.current[o]):delete r.current[o]}(v,C.current,r,I,d,e),d&&(ir(S.current,r.ref.name),ir(w.current,r.ref.name))}),[d]),Xr=t((function(r){if(R.current)Nr();else{for(var e=0,t=b.current;e<t.length;e+=1){if(t[e].startsWith(r)){Nr();break}}$r(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),d&&!q(r.options||[]).length&&(ir(Ar.current.errors,r.ref.name),W(Ar.current.dirtyFields,r.ref.name,!0),Nr({isDirty:qr()}),br.current.isValid&&U.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?k.current[t]:b.current,i=lr(v,Er(I.current),d,!1,r);if(fr(r)){var a=Or(r)||r;return $.current.has(a)&&(i=Object.assign(Object.assign({},p.current),i)),jr(i,r,n,_(P(D.current,r))?e:P(D.current,r),!0)}var u=_(e)?D.current:e;return Array.isArray(r)?r.reduce((function(r,e){var t;return Object.assign(Object.assign({},r),((t={})[e]=jr(i,e,n,u),t))}),{}):(R.current=_(t),H(!tr(i)&&i||u))}),[]);function re(r,e){if(void 0===e&&(e={}),"production"!==process.env.NODE_ENV){if(!r.name)return console.warn("📋 Field is missing `name` attribute",r,"https://react-hook-form.com/api#useForm");if($.current.has(r.name.split(/\[\d+\]$/)[0])&&!RegExp(("^"+r.name.split(/\[\d+\]$/)[0]+"[\\d+].\\w+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',r,"https://react-hook-form.com/api#useFieldArray")}var t,n=r.name,i=r.type,a=r.value,u=Object.assign({ref:r},e),o=v.current,s=wr(r),c=kr($.current,n),f=function(e){return Vr&&(!h(r)||e===r)},l=o[n],m=!0;if(l&&(s?Array.isArray(l.options)&&q(l.options).find((function(r){return a===r.ref.value&&f(r.ref)})):f(l.ref)))o[n]=Object.assign(Object.assign({},l),e);else{l=i?s?Object.assign({options:q(l&&l.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},u):u,o[n]=l;var g=_(P(I.current,n));tr(D.current)&&g||(t=P(g?D.current:I.current,n),(m=_(t))||c||Tr(n,t)),tr(e)||(W(w.current,n,!0),!Z&&br.current.isValid&&hr(v,dr,l,I).then((function(r){var e=Ar.current.isValid;tr(r)?W(S.current,n,!0):ir(S.current,n),e!==tr(r)&&Nr()}))),!d||c&&m||!c&&ir(Ar.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;h(n)&&t&&(n.addEventListener(e?j:O,t),n.addEventListener(y,t))}(s&&l.options?l.options[l.options.length-1]:l,s||"select-one"===r.type,C.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Gr(lr(v,Er(I.current),d,!0));br.current.isSubmitting&&Nr({isSubmitting:!0});try{if(U.current){var a=await U.current(i,M.current,dr),u=a.errors,o=a.values;Ar.current.errors=n=u,i=o}else for(var s=0,c=Object.values(v.current);s<c.length;s+=1){var f=c[s];if(f){var m=f.ref.name,g=await hr(v,dr,f,I);g[m]?(W(n,m,g[m]),ir(S.current,m)):P(w.current,m)&&(ir(Ar.current.errors,m),W(S.current,m,!0))}}tr(n)&&Object.keys(Ar.current.errors).every((function(r){return r in v.current}))?(Nr({errors:{},isSubmitting:!0}),await r(i,t)):(Ar.current.errors=Object.assign(Object.assign({},Ar.current.errors),n),e&&await e(Ar.current.errors,t),l&&function(r,e){for(var t in r)if(P(e,t)){var n=r[t];if(n){if(n.ref.focus&&_(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(v.current,Ar.current.errors))}finally{Ar.current.isSubmitting=!1,Nr({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tr(Ar.current.errors),submitCount:Ar.current.submitCount+1})}}}),[l,dr]);a((function(){s&&br.current.isValid&&Kr(),Fr.current=Fr.current||!Vr?Fr.current:function(r,e){var t=new MutationObserver((function(){for(var t=0,n=Object.values(r.current);t<n.length;t+=1){var i=n[t];if(i&&i.options)for(var a=0,u=i.options;a<u.length;a+=1){var o=u[a];o&&o.ref&&er(o.ref)&&e(i)}else i&&er(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(v,Yr)}),[Yr,D.current]),a((function(){return function(){Fr.current&&Fr.current.disconnect(),F.current=!0,"production"===process.env.NODE_ENV&&Object.values(v.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&br.current.isValid&&(gr.isValid=sr(S.current,w.current)&&tr(Ar.current.errors));var te={trigger:_r,setValue:t((function(r,e,t){zr(r,e,t||{}),Ur(r)&&Nr(),$r(r)}),[zr,_r]),getValues:t(Jr,[]),register:t((function(r,e){if(!Sr)if(fr(r))re({name:r},e);else{if(!L(r)||!("name"in r))return function(e){return e&&re(e,r)};re(r,e)}}),[D.current]),unregister:t((function(r){for(var e=0,t=Array.isArray(r)?r:[r];e<t.length;e+=1){var n=t[e];Yr(v.current[n],!0)}}),[]),formState:Dr?new Proxy(gr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&Z&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return br.current[e]=!0,r[e]}}):gr},ne=u((function(){return Object.assign({isFormDirty:qr,updateWatchedValue:Xr,shouldUnregister:d,updateFormState:Nr,removeFieldEventListener:Qr,watchInternal:Zr,mode:X.current,reValidateMode:{isReValidateOnBlur:Cr,isReValidateOnChange:Ir},validateResolver:s?Kr:void 0,fieldsRef:v,resetFieldArrayFunctionRef:B,useWatchFieldsRef:k,useWatchRenderFunctionsRef:A,fieldArrayDefaultValuesRef:g,validFieldsRef:S,fieldsWithValidationRef:w,fieldArrayNamesRef:$,readFormStateRef:br,formStateRef:Ar,defaultValuesRef:D,shallowFieldsStateRef:I,fieldArrayValuesRef:p},te)}),[D.current,Xr,d,Qr,Zr]);return Object.assign({watch:function(r,e){return Zr(r,e)},control:ne,handleSubmit:ee,reset:t((function(r,e){if(void 0===e&&(e={}),Vr)for(var t=0,n=Object.values(v.current);t<n.length;t+=1){var i=n[t];if(i){var a=i.ref,u=i.options,o=wr(a)&&Array.isArray(u)?u[0].ref:a;if(h(o))try{o.closest("form").reset();break}catch(r){}}}v.current={},D.current=Object.assign({},r||D.current),r&&$r(""),Object.values(B.current).forEach((function(r){return vr(r)&&r()})),I.current=d?{}:Er(r||D.current),function(r){var e=r.errors,t=r.isDirty,n=r.isSubmitted,i=r.touched,a=r.isValid,u=r.submitCount,o=r.dirtyFields;a||(S.current={},w.current={}),g.current={},b.current=new Set,R.current=!1,Nr({submitCount:u?Ar.current.submitCount:0,isDirty:!!t&&Ar.current.isDirty,isSubmitted:!!n&&Ar.current.isSubmitted,isValid:!!a&&Ar.current.isValid,dirtyFields:o?Ar.current.dirtyFields:{},touched:i?Ar.current.touched:{},errors:e?Ar.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return v.current[r]&&T(r)?delete Ar.current.errors[r]:ir(Ar.current.errors,r)})),Nr({errors:r?Ar.current.errors:{}})}),[]),setError:t((function(r,e){var t=(v.current[r]||{}).ref;W(Ar.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Nr({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:gr.errors},te)}e(null).displayName="RHFContext",function(r){r.formgroup="formgroup",r.checkbox="checkbox",r.radiobutton="radiobutton",r.textarea="textarea",r.input="input"}(Ar||(Ar={}));var Rr=function(e){var t=e.exampleType,n=void 0===t?Ar.formgroup:t,i=Fr(),a=i.register,u=i.handleSubmit,o=i.errors,h=o.formgroup1||o.formgroup2||o.formgroup3||o.formgroup4||o.formgroup5,y="Du må velge et alternativ",j=[r.createElement(f,{key:0,inputId:"checkbox1",label:"Checkbox 1",ref:a({required:y})}),r.createElement(f,{key:1,inputId:"checkbox2",label:"Checkbox 2",ref:a({required:y})}),r.createElement(f,{key:2,inputId:"checkbox3",label:"Checkbox 3",ref:a({required:y})})],O=function(r){return r.length>=2||"Du må velge to alternativ"};return r.createElement("form",{onSubmit:u((function(r){console.log(r)}))},r.createElement(s,{variant:e.variant,errorSummary:h?"Sjekk at alt er riktig utfylt":void 0},n===Ar.formgroup?[r.createElement(c,{key:0,title:"One amazing title",legend:"Check out these checkboxes!",error:o.formgroup1?o.formgroup1.message:void 0,variant:e.variant,name:"formgroup1"},r.createElement(p,{maxColumns:b.two},j.map((function(r){return r})))),r.createElement(c,{key:1,legend:"Select two options!",error:o.formgroup2?o.formgroup2.message:void 0,variant:e.variant,name:"formgroup2"},r.createElement(f,{inputId:"checkbox4",label:"Checkbox 4",ref:a({validate:O})}),r.createElement(f,{inputId:"checkbox5",label:"Checkbox 5",ref:a({validate:O})}),r.createElement(f,{inputId:"checkbox6",label:"Checkbox 6",ref:a({validate:O})})),r.createElement(c,{key:2,legend:"Select two options!",error:o.formgroup3?o.formgroup3.message:void 0,variant:e.variant,name:"formgroup3"},r.createElement(d,{inputId:"radiobutton1",label:"Radiobutton 1",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton2",label:"Radiobutton 2",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton3",label:"Radiobutton 3",ref:a({required:y})})),r.createElement(c,{key:3,error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{defaultValue:"Dette er en test \n\n Hello \n\n test \n\n test test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})),r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(v,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})}))]:n===Ar.checkbox?r.createElement(c,{name:"formgroup1",error:o.formgroup1?o.formgroup1.message:void 0},r.createElement(f,{name:"formgroup1",inputId:"checkbox1",label:"Checkbox 1",error:o.formgroup1,variant:e.variant,ref:a({required:y})})):n===Ar.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(d,{name:"formgroup3",inputId:"radiobutton1",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:y})})):n===Ar.textarea?r.createElement(c,{error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{defaultValue:"Dette er min historie \n\n Hello \n\n test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})):n===Ar.input?r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(v,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})})):void 0),r.createElement(l,{type:"submit"},"Submit"))};export default Rr;export{Rr as FormExample,Ar as FormExampleVariants};
|
|
1
|
+
import r,{createContext as e,useCallback as t,useRef as n,useState as i,useEffect as a,useMemo as u,isValidElement as o}from"react";import{V as s}from"../../Validation-e36cb0d8.js";import{F as c}from"../../FormGroup-9c5e238e.js";import{C as l}from"../../Checkbox-1e2c2047.js";import{B as f}from"../../Button-9f2ce63d.js";import{R as d}from"../../RadioButton-71099f5c.js";import{T as m}from"../../Textarea-e1e649cf.js";import{I as v}from"../../Input-5bb47387.js";import g from"../Icons/Hospital.js";import{F as p,a as b}from"../../FormLayout-26368f0a.js";import"../../index-9b84fabc.js";import"../Validation/styles.module.scss";import"../../constants-9528513d.js";import"../../_rollupPluginBabelHelpers-4f206abf.js";import"../FormGroup/styles.module.scss";import"../../Title-3a6d4597.js";import"../Title/styles.module.scss";import"../../uuid-11037462.js";import"../Icons/Check.js";import"../Icons/Icon.js";import"../../_tslib-51c8a283.js";import"../../color-e7d082c1.js";import"../../index-d1c9177a.js";import"../../palette-f206f488.js";import"../../grid-c105cad1.js";import"../Checkbox/styles.module.scss";import"../../Loader-670979af.js";import"../Loader/styles.module.scss";import"../../useHover-026f72c1.js";import"../../useWindowSize-5cc481da.js";import"../Button/styles.module.scss";import"../RadioButton/styles.module.scss";import"../Textarea/styles.module.scss";import"../../useBreakpoint-6eb418f7.js";import"../Input/styles.module.scss";import"../FormLayout/styles.module.scss";var h=function(r){return r instanceof HTMLElement},y="blur",j="change",O="input",k="onBlur",V="onChange",E="onSubmit",A="onTouched",x="all",w="max",S="min",D="maxLength",F="minLength",R="pattern",C="required",I="validate";var N=function(r){return null==r},B=function(r){return"object"==typeof r},L=function(r){return!N(r)&&!Array.isArray(r)&&B(r)&&!(r instanceof Date)},T=function(r){return/^\w*$/.test(r)},q=function(r){return r.filter(Boolean)},M=function(r){return q(r.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."))};function W(r,e,t){for(var n=-1,i=T(e)?[e]:M(e),a=i.length,u=a-1;++n<a;){var o=i[n],s=t;if(n!==u){var c=r[o];s=L(c)||Array.isArray(c)?c:isNaN(+i[n+1])?{}:[]}r[o]=s,r=r[o]}return r}var H=function(r,e){for(var t in void 0===e&&(e={}),r)T(t)?e[t]=r[t]:W(e,t,r[t]);return e},_=function(r){return void 0===r},P=function(r,e,t){void 0===r&&(r={});var n=q(e.split(/[,[\].]+?/)).reduce((function(r,e){return N(r)?r:r[e]}),r);return _(n)||n===r?_(r[e])?t:r[e]:n},z=function(r,e){h(r)&&r.removeEventListener&&(r.removeEventListener(O,e),r.removeEventListener(j,e),r.removeEventListener(y,e))},U={isValid:!1,value:null},$=function(r){return Array.isArray(r)?r.reduce((function(r,e){return e&&e.ref.checked?{isValid:!0,value:e.ref.value}:r}),U):U},G=function(r){return"radio"===r.type},J=function(r){return"file"===r.type},K=function(r){return"checkbox"===r.type},Q=function(r){return"select-multiple"===r.type},X={value:!1,isValid:!1},Y={value:!0,isValid:!0},Z=function(r){if(Array.isArray(r)){if(r.length>1){var e=r.filter((function(r){return r&&r.ref.checked})).map((function(r){return r.ref.value}));return{value:e,isValid:!!e.length}}var t=r[0].ref,n=t.checked,i=t.value,a=t.attributes;return n?a&&!_(a.value)?_(i)||""===i?Y:{value:i,isValid:!0}:Y:X}return X};function rr(r,e,t,n,i){var a,u=r.current[e];if(u){var o=u.ref,s=o.value,c=o.disabled,l=u.ref,f=u.valueAsNumber,d=u.valueAsDate,m=u.setValueAs;if(c&&n)return;return J(l)?l.files:G(l)?$(u.options).value:Q(l)?(a=l.options,[].concat(a).filter((function(r){return r.selected})).map((function(r){return r.value}))):K(l)?Z(u.options).value:i?s:f?""===s?NaN:+s:d?l.valueAsDate:m?m(s):s}if(t)return P(t.current,e)}function er(r){return!r||r instanceof HTMLElement&&r.nodeType!==Node.DOCUMENT_NODE&&er(r.parentNode)}var tr=function(r){return L(r)&&!Object.keys(r).length},nr=function(r){return"boolean"==typeof r};function ir(r,e){var t,n=T(e)?[e]:M(e),i=1==n.length?r:function(r,e){for(var t=e.slice(0,-1).length,n=0;n<t;)r=_(r)?n++:r[e[n++]];return r}(r,n),a=n[n.length-1];i&&delete i[a];for(var u=0;u<n.slice(0,-1).length;u++){var o=-1,s=void 0,c=n.slice(0,-(u+1)),l=c.length-1;for(u>0&&(t=r);++o<c.length;){var f=c[o];s=s?s[f]:r[f],l===o&&(L(s)&&tr(s)||Array.isArray(s)&&!s.filter((function(r){return L(r)&&!tr(r)||nr(r)})).length)&&(t?delete t[f]:delete r[f]),t=s}}return r}var ar=function(r,e){return r&&r.ref===e};var ur=function(r){return N(r)||!B(r)};function or(r,e){if(ur(r)||ur(e))return e;for(var t in e){var n=r[t],i=e[t];try{r[t]=L(n)&&L(i)||Array.isArray(n)&&Array.isArray(i)?or(n,i):i}catch(r){}}return r}function sr(r,e,t){if(ur(r)||ur(e)||r instanceof Date||e instanceof Date)return r===e;if(!o(r)){var n=Object.keys(r),i=Object.keys(e);if(n.length!==i.length)return!1;for(var a=0,u=n;a<u.length;a+=1){var s=u[a],c=r[s];if(!t||"ref"!==s){var l=e[s];if((L(c)||Array.isArray(c))&&(L(l)||Array.isArray(l))?!sr(c,l,t):c!==l)return!1}}}return!0}function cr(r,e,t,n,i){for(var a,u=-1;++u<r.length;){for(var o in r[u])Array.isArray(r[u][o])?(!t[u]&&(t[u]={}),t[u][o]=[],cr(r[u][o],P(e[u]||{},o,[]),t[u][o],t[u],o)):sr(P(e[u]||{},o),r[u][o])?W(t[u]||{},o):t[u]=Object.assign(Object.assign({},t[u]),((a={})[o]=!0,a));n&&!t.length&&delete n[i]}return t}var lr=function(r){return"string"==typeof r},fr=function(r,e,t,n,i){var a={},u=function(e){(_(i)||(lr(i)?e.startsWith(i):Array.isArray(i)&&i.find((function(r){return e.startsWith(r)}))))&&(a[e]=rr(r,e,void 0,n))};for(var o in r.current)u(o);return t?H(a):or(e,H(a))},dr=function(r){return r instanceof RegExp},mr=function(r){return L(r)&&!dr(r)?r:{value:r,message:""}},vr=function(r){return"function"==typeof r},gr=function(r){return lr(r)||o(r)};function pr(r,e,t){if(void 0===t&&(t="validate"),gr(r)||nr(r)&&!r)return{type:t,message:gr(r)?r:"",ref:e}}var br=function(r,e,t,n,i){var a;return e?Object.assign(Object.assign({},t[r]),{types:Object.assign(Object.assign({},t[r]&&t[r].types?t[r].types:{}),(a={},a[n]=i||!0,a))}):{}},hr=async function(r,e,t,n){var i=t.ref,a=t.ref.value,u=t.options,o=t.required,s=t.maxLength,c=t.minLength,l=t.min,f=t.max,d=t.pattern,m=t.validate,v=i.name,g={},p=G(i),b=K(i),h=p||b,y=""===a,j=br.bind(null,v,e,g),O=function(r,e,t,n,a){void 0===n&&(n=D),void 0===a&&(a=F);var u=r?e:t;g[v]=Object.assign({type:r?n:a,message:u,ref:i},j(r?n:a,u))};if(o&&(!p&&!b&&(y||N(a))||nr(a)&&!a||b&&!Z(u).isValid||p&&!$(u).isValid)){var k=gr(o)?{value:!!o,message:o}:mr(o),V=k.value,E=k.message;if(V&&(g[v]=Object.assign({type:C,message:E,ref:h?((r.current[v].options||[])[0]||{}).ref:i},j(C,E)),!e))return g}if(!(N(l)&&N(f)||""===a)){var A,x,B=mr(f),T=mr(l);if(isNaN(a)){var q=i.valueAsDate||new Date(a);lr(B.value)&&(A=q>new Date(B.value)),lr(T.value)&&(x=q<new Date(T.value))}else{var M=i.valueAsNumber||parseFloat(a);N(B.value)||(A=M>B.value),N(T.value)||(x=M<T.value)}if((A||x)&&(O(!!A,B.message,T.message,w,S),!e))return g}if(lr(a)&&!y&&(s||c)){var W=mr(s),H=mr(c),_=!N(W.value)&&a.length>W.value,P=!N(H.value)&&a.length<H.value;if((_||P)&&(O(_,W.message,H.message),!e))return g}if(lr(a)&&d&&!y){var z=mr(d),U=z.value,J=z.message;if(dr(U)&&!U.test(a)&&(g[v]=Object.assign({type:R,message:J,ref:i},j(R,J)),!e))return g}if(m){var Q=rr(r,v,n,!1,!0),X=h&&u?u[0].ref:i;if(vr(m)){var Y=pr(await m(Q),X);if(Y&&(g[v]=Object.assign(Object.assign({},Y),j(I,Y.message)),!e))return g}else if(L(m)){for(var er={},ir=0,ar=Object.entries(m);ir<ar.length;ir+=1){var ur=ar[ir],or=ur[0],sr=ur[1];if(!tr(er)&&!e)break;var cr=pr(await sr(Q),X,or);cr&&(er=Object.assign(Object.assign({},cr),j(or,cr.message)),e&&(g[v]=er))}if(!tr(er)&&(g[v]=Object.assign({ref:X},er),!e))return g}}return g},yr=function(r,e,t){for(var n in void 0===t&&(t=[]),e){var i=r+(L(e)?"."+n:"["+n+"]");ur(e[n])?t.push(i):yr(i,e[n],t)}return t},jr=function(r,e,t,n,i){var a=void 0;return t.add(e),tr(r)||(a=P(r,e),(L(a)||Array.isArray(a))&&yr(e,a).forEach((function(r){return t.add(r)}))),_(a)?i?n:P(n,e):a},Or=function(r){return r.substring(0,r.indexOf("["))},kr=function(r,e){return[].concat(r).some((function(r){return function(r,e){return RegExp(("^"+e+"([|.)\\d+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r)}(e,r)}))};var Vr="undefined"!=typeof window&&"undefined"!=typeof document;function Er(r){var e,t;if(ur(r)||Vr&&(r instanceof File||h(r)))return r;if(!["Set","Map","Object","Date","Array"].includes(null===(e=r.constructor)||void 0===e?void 0:e.name))return r;if(r instanceof Date)return t=new Date(r.getTime());if(r instanceof Set){t=new Set;for(var n=0,i=r;n<i.length;n+=1){var a=i[n];t.add(a)}return t}if(r instanceof Map){t=new Map;for(var u=0,o=r.keys();u<o.length;u+=1){var s=o[u];t.set(s,Er(r.get(s)))}return t}for(var c in t=Array.isArray(r)?[]:{},r)t[c]=Er(r[c]);return t}var Ar,xr=function(r){return{isOnSubmit:!r||r===E,isOnBlur:r===k,isOnChange:r===V,isOnAll:r===x,isOnTouch:r===A}},wr=function(r){return G(r)||K(r)},Sr="undefined"==typeof window,Dr=Vr?"Proxy"in window:"undefined"!=typeof Proxy;function Fr(r){void 0===r&&(r={});var e=r.mode;void 0===e&&(e=E);var o=r.reValidateMode;void 0===o&&(o=V);var s=r.resolver,c=r.context,l=r.defaultValues;void 0===l&&(l={});var f=r.shouldFocusError;void 0===f&&(f=!0);var d=r.shouldUnregister;void 0===d&&(d=!0);var m=r.criteriaMode,v=n({}),g=n({}),p=n({}),b=n(new Set),k=n({}),A=n({}),w=n({}),S=n({}),D=n(l),F=n(!1),R=n(!1),C=n(),I=n({}),B=n({}),M=n(c),U=n(s),$=n(new Set),X=n(xr(e)),Y=X.current,Z=Y.isOnSubmit,nr=Y.isOnTouch,dr=m===x,mr=i({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Z,errors:{}}),gr=mr[0],pr=mr[1],br=n({isDirty:!Dr,dirtyFields:!Dr,touched:!Dr||nr,isValidating:!Dr,isSubmitting:!Dr,isValid:!Dr}),Ar=n(gr),Fr=n(),Rr=n(xr(o)).current,Cr=Rr.isOnBlur,Ir=Rr.isOnChange;M.current=c,U.current=s,Ar.current=gr,I.current=d?{}:tr(I.current)?Er(l):I.current;var Nr=t((function(r){void 0===r&&(r={}),F.current||(Ar.current=Object.assign(Object.assign({},Ar.current),r),pr(Ar.current))}),[]),Br=function(){return br.current.isValidating&&Nr({isValidating:!0})},Lr=t((function(r,e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n={});var a=t||function(r){var e=r.errors,t=r.name,n=r.error,i=r.validFields,a=r.fieldsWithValidation,u=_(n),o=P(e,t);return u&&!!o||!u&&!sr(o,n,!0)||u&&P(a,t)&&!P(i,t)}({errors:Ar.current.errors,error:e,name:r,validFields:S.current,fieldsWithValidation:w.current}),u=P(Ar.current.errors,r);e?(ir(S.current,r),a=a||!u||!sr(u,e,!0),W(Ar.current.errors,r,e)):((P(w.current,r)||U.current)&&(W(S.current,r,!0),a=a||u),ir(Ar.current.errors,r)),(a&&!N(t)||!tr(n)||br.current.isValidating)&&Nr(Object.assign(Object.assign(Object.assign({},n),U.current?{isValid:!!i}:{}),{isValidating:!1}))}),[]),Tr=t((function(r,e){var t=v.current[r],n=t.ref,i=t.options,a=Vr&&h(n)&&N(e)?"":e;G(n)?(i||[]).forEach((function(r){var e=r.ref;return e.checked=e.value===a})):J(n)&&!lr(a)?n.files=a:Q(n)?[].concat(n.options).forEach((function(r){return r.selected=a.includes(r.value)})):K(n)&&i?i.length>1?i.forEach((function(r){var e=r.ref;return e.checked=Array.isArray(a)?!!a.find((function(r){return r===e.value})):a===e.value})):i[0].ref.checked=!!a:n.value=a}),[]),qr=t((function(r,e){if(br.current.isDirty){var t=Jr();return r&&e&&W(t,r,e),!sr(t,D.current)}return!1}),[]),Mr=t((function(r,e){if(void 0===e&&(e=!0),br.current.isDirty||br.current.dirtyFields){var t=!sr(P(D.current,r),rr(v,r,I)),n=P(Ar.current.dirtyFields,r),i=Ar.current.isDirty;t?W(Ar.current.dirtyFields,r,!0):ir(Ar.current.dirtyFields,r);var a={isDirty:qr(),dirtyFields:Ar.current.dirtyFields},u=br.current.isDirty&&i!==a.isDirty||br.current.dirtyFields&&n!==P(Ar.current.dirtyFields,r);return u&&e&&Nr(a),u?a:{}}return{}}),[]),Wr=t((async function(r,e){if("production"!==process.env.NODE_ENV&&!v.current[r])return console.warn("📋 Field is missing with `name` attribute: ",r),!1;var t=(await hr(v,dr,v.current[r],I))[r];return Lr(r,t,e),_(t)}),[Lr,dr]),Hr=t((async function(r){var e=(await U.current(Jr(),M.current,dr)).errors,t=Ar.current.isValid;if(Array.isArray(r)){var n=r.map((function(r){var t=P(e,r);return t?W(Ar.current.errors,r,t):ir(Ar.current.errors,r),!t})).every(Boolean);return Nr({isValid:tr(e),isValidating:!1}),n}var i=P(e,r);return Lr(r,i,t!==tr(e),{},tr(e)),!i}),[Lr,dr]),_r=t((async function(r){var e=r||Object.keys(v.current);if(Br(),U.current)return Hr(e);if(Array.isArray(e)){!r&&(Ar.current.errors={});var t=await Promise.all(e.map((async function(r){return await Wr(r,null)})));return Nr({isValidating:!1}),t.every(Boolean)}return await Wr(e)}),[Hr,Wr]),Pr=t((function(r,e,t){var n=t.shouldDirty,i=t.shouldValidate,a={};W(a,r,e);for(var u=0,o=yr(r,e);u<o.length;u+=1){var s=o[u];v.current[s]&&(Tr(s,P(a,s)),n&&Mr(s),i&&_r(s))}}),[_r,Tr,Mr]),zr=t((function(r,e,t){var n,i;if(!d&&!ur(e)&&W(I.current,r,Array.isArray(e)?[].concat(e):Object.assign({},e)),v.current[r])Tr(r,e),t.shouldDirty&&Mr(r),t.shouldValidate&&_r(r);else if(!ur(e)&&(Pr(r,e,t),$.current.has(r))){var a=Or(r)||r;W(g.current,r,e),B.current[a](((n={})[a]=P(g.current,a),n)),(br.current.isDirty||br.current.dirtyFields)&&t.shouldDirty&&(W(Ar.current.dirtyFields,r,function(r,e,t){return or(cr(r,e,t.slice(0,r.length)),cr(e,r,t.slice(0,r.length)))}(e,P(D.current,r,[]),P(Ar.current.dirtyFields,r,[]))),Nr({isDirty:!sr(Object.assign(Object.assign({},Jr()),(i={},i[r]=e,i)),D.current)}))}!d&&W(I.current,r,e)}),[Mr,Tr,Pr]),Ur=function(r){return R.current||b.current.has(r)||b.current.has((r.match(/\w+/)||[])[0])},$r=function(r){var e=!0;if(!tr(k.current))for(var t in k.current)r&&k.current[t].size&&!k.current[t].has(r)&&!k.current[t].has(Or(r))||(A.current[t](),e=!1);return e};function Gr(r){var e;if(!d){for(var t=Er(r),n=0,i=$.current;n<i.length;n+=1){var a=i[n];T(a)&&!t[a]&&(t=Object.assign(Object.assign({},t),((e={})[a]=[],e)))}return t}return r}function Jr(r){if(lr(r))return rr(v,r,I);if(Array.isArray(r)){for(var e={},t=0,n=r;t<n.length;t+=1){var i=n[t];W(e,i,rr(v,i,I))}return e}return Gr(fr(v,Er(I.current),d))}C.current=C.current?C.current:async function(r){var e,t,n=r.type,i=r.target,a=i.name,u=v.current[a];if(u){var o=n===y,s=function(r){var e=r.isOnBlur,t=r.isOnChange,n=r.isOnTouch,i=r.isTouched,a=r.isReValidateOnBlur,u=r.isReValidateOnChange,o=r.isBlurEvent,s=r.isSubmitted;return!r.isOnAll&&(!s&&n?!(i||o):(s?a:e)?!o:!(s?u:t)||o)}(Object.assign({isBlurEvent:o,isReValidateOnChange:Ir,isReValidateOnBlur:Cr,isTouched:!!P(Ar.current.touched,a),isSubmitted:Ar.current.isSubmitted},X.current)),c=Mr(a,!1),l=!tr(c)||!o&&Ur(a);if(o&&!P(Ar.current.touched,a)&&br.current.touched&&(W(Ar.current.touched,a,!0),c=Object.assign(Object.assign({},c),{touched:Ar.current.touched})),!d&&K(i)&&W(I.current,a,rr(v,a)),s)return!o&&$r(a),(!tr(c)||l&&tr(c))&&Nr(c);if(Br(),U.current){var f=(await U.current(Jr(),M.current,dr)).errors,m=Ar.current.isValid;if(e=P(f,a),K(i)&&!e&&U.current){var g=Or(a),p=P(f,g,{});p.type&&p.message&&(e=p),g&&(p||P(Ar.current.errors,g))&&(a=g)}m!==(t=tr(f))&&(l=!0)}else e=(await hr(v,dr,u,I))[a];!o&&$r(a),Lr(a,e,l,c,t)}};var Kr=t((async function(r){void 0===r&&(r={});var e=tr(v.current)?D.current:{},t=(await U.current(Object.assign(Object.assign(Object.assign({},e),Jr()),r),M.current,dr)||{}).errors,n=tr(t);Ar.current.isValid!==n&&Nr({isValid:n})}),[dr]),Qr=t((function(r,e){!function(r,e,t,n,i,a){var u=t.ref,o=t.ref.name,s=r.current[o];if(!i){var c=rr(r,o,n);!_(c)&&W(n.current,o,c)}u.type&&s?G(u)||K(u)?Array.isArray(s.options)&&s.options.length?(q(s.options).forEach((function(r,t){void 0===r&&(r={}),(er(r.ref)&&ar(r,r.ref)||a)&&(z(r.ref,e),ir(s.options,"["+t+"]"))})),s.options&&!q(s.options).length&&delete r.current[o]):delete r.current[o]:(er(u)&&ar(s,u)||a)&&(z(u,e),delete r.current[o]):delete r.current[o]}(v,C.current,r,I,d,e),d&&(ir(S.current,r.ref.name),ir(w.current,r.ref.name))}),[d]),Xr=t((function(r){if(R.current)Nr();else{for(var e=0,t=b.current;e<t.length;e+=1){if(t[e].startsWith(r)){Nr();break}}$r(r)}}),[]),Yr=t((function(r,e){r&&(Qr(r,e),d&&!q(r.options||[]).length&&(ir(Ar.current.errors,r.ref.name),W(Ar.current.dirtyFields,r.ref.name,!0),Nr({isDirty:qr()}),br.current.isValid&&U.current&&Kr(),Xr(r.ref.name)))}),[Kr,Qr]);var Zr=t((function(r,e,t){var n=t?k.current[t]:b.current,i=fr(v,Er(I.current),d,!1,r);if(lr(r)){var a=Or(r)||r;return $.current.has(a)&&(i=Object.assign(Object.assign({},p.current),i)),jr(i,r,n,_(P(D.current,r))?e:P(D.current,r),!0)}var u=_(e)?D.current:e;return Array.isArray(r)?r.reduce((function(r,e){var t;return Object.assign(Object.assign({},r),((t={})[e]=jr(i,e,n,u),t))}),{}):(R.current=_(t),H(!tr(i)&&i||u))}),[]);function re(r,e){if(void 0===e&&(e={}),"production"!==process.env.NODE_ENV){if(!r.name)return console.warn("📋 Field is missing `name` attribute",r,"https://react-hook-form.com/api#useForm");if($.current.has(r.name.split(/\[\d+\]$/)[0])&&!RegExp(("^"+r.name.split(/\[\d+\]$/)[0]+"[\\d+].\\w+").replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(r.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',r,"https://react-hook-form.com/api#useFieldArray")}var t,n=r.name,i=r.type,a=r.value,u=Object.assign({ref:r},e),o=v.current,s=wr(r),c=kr($.current,n),l=function(e){return Vr&&(!h(r)||e===r)},f=o[n],m=!0;if(f&&(s?Array.isArray(f.options)&&q(f.options).find((function(r){return a===r.ref.value&&l(r.ref)})):l(f.ref)))o[n]=Object.assign(Object.assign({},f),e);else{f=i?s?Object.assign({options:q(f&&f.options||[]).concat([{ref:r}]),ref:{type:i,name:n}},e):Object.assign({},u):u,o[n]=f;var g=_(P(I.current,n));tr(D.current)&&g||(t=P(g?D.current:I.current,n),(m=_(t))||c||Tr(n,t)),tr(e)||(W(w.current,n,!0),!Z&&br.current.isValid&&hr(v,dr,f,I).then((function(r){var e=Ar.current.isValid;tr(r)?W(S.current,n,!0):ir(S.current,n),e!==tr(r)&&Nr()}))),!d||c&&m||!c&&ir(Ar.current.dirtyFields,n),i&&function(r,e,t){var n=r.ref;h(n)&&t&&(n.addEventListener(e?j:O,t),n.addEventListener(y,t))}(s&&f.options?f.options[f.options.length-1]:f,s||"select-one"===r.type,C.current)}}var ee=t((function(r,e){return async function(t){t&&t.preventDefault&&(t.preventDefault(),t.persist());var n={},i=Gr(fr(v,Er(I.current),d,!0));br.current.isSubmitting&&Nr({isSubmitting:!0});try{if(U.current){var a=await U.current(i,M.current,dr),u=a.errors,o=a.values;Ar.current.errors=n=u,i=o}else for(var s=0,c=Object.values(v.current);s<c.length;s+=1){var l=c[s];if(l){var m=l.ref.name,g=await hr(v,dr,l,I);g[m]?(W(n,m,g[m]),ir(S.current,m)):P(w.current,m)&&(ir(Ar.current.errors,m),W(S.current,m,!0))}}tr(n)&&Object.keys(Ar.current.errors).every((function(r){return r in v.current}))?(Nr({errors:{},isSubmitting:!0}),await r(i,t)):(Ar.current.errors=Object.assign(Object.assign({},Ar.current.errors),n),e&&await e(Ar.current.errors,t),f&&function(r,e){for(var t in r)if(P(e,t)){var n=r[t];if(n){if(n.ref.focus&&_(n.ref.focus()))break;if(n.options){n.options[0].ref.focus();break}}}}(v.current,Ar.current.errors))}finally{Ar.current.isSubmitting=!1,Nr({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tr(Ar.current.errors),submitCount:Ar.current.submitCount+1})}}}),[f,dr]);a((function(){s&&br.current.isValid&&Kr(),Fr.current=Fr.current||!Vr?Fr.current:function(r,e){var t=new MutationObserver((function(){for(var t=0,n=Object.values(r.current);t<n.length;t+=1){var i=n[t];if(i&&i.options)for(var a=0,u=i.options;a<u.length;a+=1){var o=u[a];o&&o.ref&&er(o.ref)&&e(i)}else i&&er(i.ref)&&e(i)}}));return t.observe(window.document,{childList:!0,subtree:!0}),t}(v,Yr)}),[Yr,D.current]),a((function(){return function(){Fr.current&&Fr.current.disconnect(),F.current=!0,"production"===process.env.NODE_ENV&&Object.values(v.current).forEach((function(r){return Yr(r,!0)}))}}),[]),!s&&br.current.isValid&&(gr.isValid=sr(S.current,w.current)&&tr(Ar.current.errors));var te={trigger:_r,setValue:t((function(r,e,t){zr(r,e,t||{}),Ur(r)&&Nr(),$r(r)}),[zr,_r]),getValues:t(Jr,[]),register:t((function(r,e){if(!Sr)if(lr(r))re({name:r},e);else{if(!L(r)||!("name"in r))return function(e){return e&&re(e,r)};re(r,e)}}),[D.current]),unregister:t((function(r){for(var e=0,t=Array.isArray(r)?r:[r];e<t.length;e+=1){var n=t[e];Yr(v.current[n],!0)}}),[]),formState:Dr?new Proxy(gr,{get:function(r,e){if("production"!==process.env.NODE_ENV&&"isValid"===e&&Z&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),e in r)return br.current[e]=!0,r[e]}}):gr},ne=u((function(){return Object.assign({isFormDirty:qr,updateWatchedValue:Xr,shouldUnregister:d,updateFormState:Nr,removeFieldEventListener:Qr,watchInternal:Zr,mode:X.current,reValidateMode:{isReValidateOnBlur:Cr,isReValidateOnChange:Ir},validateResolver:s?Kr:void 0,fieldsRef:v,resetFieldArrayFunctionRef:B,useWatchFieldsRef:k,useWatchRenderFunctionsRef:A,fieldArrayDefaultValuesRef:g,validFieldsRef:S,fieldsWithValidationRef:w,fieldArrayNamesRef:$,readFormStateRef:br,formStateRef:Ar,defaultValuesRef:D,shallowFieldsStateRef:I,fieldArrayValuesRef:p},te)}),[D.current,Xr,d,Qr,Zr]);return Object.assign({watch:function(r,e){return Zr(r,e)},control:ne,handleSubmit:ee,reset:t((function(r,e){if(void 0===e&&(e={}),Vr)for(var t=0,n=Object.values(v.current);t<n.length;t+=1){var i=n[t];if(i){var a=i.ref,u=i.options,o=wr(a)&&Array.isArray(u)?u[0].ref:a;if(h(o))try{o.closest("form").reset();break}catch(r){}}}v.current={},D.current=Object.assign({},r||D.current),r&&$r(""),Object.values(B.current).forEach((function(r){return vr(r)&&r()})),I.current=d?{}:Er(r||D.current),function(r){var e=r.errors,t=r.isDirty,n=r.isSubmitted,i=r.touched,a=r.isValid,u=r.submitCount,o=r.dirtyFields;a||(S.current={},w.current={}),g.current={},b.current=new Set,R.current=!1,Nr({submitCount:u?Ar.current.submitCount:0,isDirty:!!t&&Ar.current.isDirty,isSubmitted:!!n&&Ar.current.isSubmitted,isValid:!!a&&Ar.current.isValid,dirtyFields:o?Ar.current.dirtyFields:{},touched:i?Ar.current.touched:{},errors:e?Ar.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})}(e)}),[]),clearErrors:t((function(r){r&&(Array.isArray(r)?r:[r]).forEach((function(r){return v.current[r]&&T(r)?delete Ar.current.errors[r]:ir(Ar.current.errors,r)})),Nr({errors:r?Ar.current.errors:{}})}),[]),setError:t((function(r,e){var t=(v.current[r]||{}).ref;W(Ar.current.errors,r,Object.assign(Object.assign({},e),{ref:t})),Nr({isValid:!1}),e.shouldFocus&&t&&t.focus&&t.focus()}),[]),errors:gr.errors},te)}e(null).displayName="RHFContext",function(r){r.formgroup="formgroup",r.checkbox="checkbox",r.radiobutton="radiobutton",r.textarea="textarea",r.input="input"}(Ar||(Ar={}));var Rr=function(e){var t=e.exampleType,n=void 0===t?Ar.formgroup:t,i=Fr(),a=i.register,u=i.handleSubmit,o=i.errors,h=o.formgroup1||o.formgroup2||o.formgroup3||o.formgroup4||o.formgroup5,y="Du må velge et alternativ",j=[r.createElement(l,{key:0,inputId:"checkbox1",label:"Checkbox 1",ref:a({required:y})}),r.createElement(l,{key:1,inputId:"checkbox2",label:"Checkbox 2",ref:a({required:y})}),r.createElement(l,{key:2,inputId:"checkbox3",label:"Checkbox 3",ref:a({required:y})})],O=function(r){return r.length>=2||"Du må velge to alternativ"};return r.createElement("form",{onSubmit:u((function(r){console.log(r)}))},r.createElement(s,{variant:e.variant,errorSummary:h?"Sjekk at alt er riktig utfylt":void 0},n===Ar.formgroup?[r.createElement(c,{key:0,title:"One amazing title",legend:"Check out these checkboxes!",error:o.formgroup1?o.formgroup1.message:void 0,variant:e.variant,name:"formgroup1"},r.createElement(p,{maxColumns:b.two},j.map((function(r){return r})))),r.createElement(c,{key:1,legend:"Select two options!",error:o.formgroup2?o.formgroup2.message:void 0,variant:e.variant,name:"formgroup2"},r.createElement(l,{inputId:"checkbox4",label:"Checkbox 4",ref:a({validate:O})}),r.createElement(l,{inputId:"checkbox5",label:"Checkbox 5",ref:a({validate:O})}),r.createElement(l,{inputId:"checkbox6",label:"Checkbox 6",ref:a({validate:O})})),r.createElement(c,{key:2,legend:"Select two options!",error:o.formgroup3?o.formgroup3.message:void 0,variant:e.variant,name:"formgroup3"},r.createElement(d,{inputId:"radiobutton1",label:"Radiobutton 1",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton2",label:"Radiobutton 2",ref:a({required:y})}),r.createElement(d,{inputId:"radiobutton3",label:"Radiobutton 3",ref:a({required:y})})),r.createElement(c,{key:3,error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{defaultValue:"Dette er en test \n\n Hello \n\n test \n\n test test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})),r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(v,{label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})}))]:n===Ar.checkbox?r.createElement(c,{name:"formgroup1",error:o.formgroup1?o.formgroup1.message:void 0},r.createElement(l,{name:"formgroup1",inputId:"checkbox1",label:"Checkbox 1",error:o.formgroup1,variant:e.variant,ref:a({required:y})})):n===Ar.radiobutton?r.createElement(c,{name:"formgroup3",error:o.formgroup3?o.formgroup3.message:void 0},r.createElement(d,{name:"formgroup3",inputId:"radiobutton1",label:"Radiobutton 1",error:o.formgroup3,variant:e.variant,ref:a({required:y})})):n===Ar.textarea?r.createElement(c,{error:o.formgroup4?o.formgroup4.message:void 0},r.createElement(m,{defaultValue:"Dette er min historie \n\n Hello \n\n test",grow:!0,maxCharacters:40,minRows:5,label:"Skriv din historie her",textareaId:"textarea1",name:"formgroup4",ref:a({maxLength:{value:40,message:"Det kan ikke legges inn mer enn 40 tegn"}})})):n===Ar.input?r.createElement(c,{name:"formgroup5",key:4,variant:e.variant,error:o.formgroup5?o.formgroup5.message:void 0},r.createElement(v,{inputId:"input1",label:"Skriv inn din tekst",placeholder:"Skriv noe!",icon:g,ref:a({required:"Du må skrive noe her"})})):void 0),r.createElement(f,{type:"submit"},"Submit"))};export default Rr;export{Rr as FormExample,Ar as FormExampleVariants};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|