@makeswift/runtime 0.0.22 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/Box.cjs.js +502 -0
  2. package/dist/Box.cjs.js.map +1 -0
  3. package/dist/Box.es.js +496 -0
  4. package/dist/Box.es.js.map +1 -0
  5. package/dist/Button.cjs.js +308 -0
  6. package/dist/Button.cjs.js.map +1 -0
  7. package/dist/Button.es.js +301 -0
  8. package/dist/Button.es.js.map +1 -0
  9. package/dist/Carousel.cjs.js +487 -0
  10. package/dist/Carousel.cjs.js.map +1 -0
  11. package/dist/Carousel.es.js +481 -0
  12. package/dist/Carousel.es.js.map +1 -0
  13. package/dist/Countdown.cjs.js +340 -0
  14. package/dist/Countdown.cjs.js.map +1 -0
  15. package/dist/Countdown.es.js +334 -0
  16. package/dist/Countdown.es.js.map +1 -0
  17. package/dist/Divider.cjs.js +115 -0
  18. package/dist/Divider.cjs.js.map +1 -0
  19. package/dist/Divider.es.js +109 -0
  20. package/dist/Divider.es.js.map +1 -0
  21. package/dist/Embed.cjs.js +129 -0
  22. package/dist/Embed.cjs.js.map +1 -0
  23. package/dist/Embed.es.js +123 -0
  24. package/dist/Embed.es.js.map +1 -0
  25. package/dist/Form.cjs.js +1724 -0
  26. package/dist/Form.cjs.js.map +1 -0
  27. package/dist/Form.es.js +1697 -0
  28. package/dist/Form.es.js.map +1 -0
  29. package/dist/Image.cjs2.js +148 -0
  30. package/dist/Image.cjs2.js.map +1 -0
  31. package/dist/Image.es2.js +141 -0
  32. package/dist/Image.es2.js.map +1 -0
  33. package/dist/Navigation.cjs.js +736 -0
  34. package/dist/Navigation.cjs.js.map +1 -0
  35. package/dist/Navigation.es.js +710 -0
  36. package/dist/Navigation.es.js.map +1 -0
  37. package/dist/Root.cjs.js +143 -0
  38. package/dist/Root.cjs.js.map +1 -0
  39. package/dist/Root.es.js +137 -0
  40. package/dist/Root.es.js.map +1 -0
  41. package/dist/SocialLinks.cjs.js +900 -0
  42. package/dist/SocialLinks.cjs.js.map +1 -0
  43. package/dist/SocialLinks.es.js +874 -0
  44. package/dist/SocialLinks.es.js.map +1 -0
  45. package/dist/Text.cjs.js +475 -0
  46. package/dist/Text.cjs.js.map +1 -0
  47. package/dist/Text.es.js +467 -0
  48. package/dist/Text.es.js.map +1 -0
  49. package/dist/Video.cjs.js +121 -0
  50. package/dist/Video.cjs.js.map +1 -0
  51. package/dist/Video.es.js +114 -0
  52. package/dist/Video.es.js.map +1 -0
  53. package/dist/components.cjs.js +79 -58
  54. package/dist/components.cjs.js.map +1 -1
  55. package/dist/components.es.js +41 -18
  56. package/dist/components.es.js.map +1 -1
  57. package/dist/cssMediaRules.cjs.js +222 -0
  58. package/dist/cssMediaRules.cjs.js.map +1 -0
  59. package/dist/cssMediaRules.es.js +213 -0
  60. package/dist/cssMediaRules.es.js.map +1 -0
  61. package/dist/descriptors.es.js +1 -1
  62. package/dist/index.cjs.js +1408 -7741
  63. package/dist/index.cjs.js.map +1 -1
  64. package/dist/index.cjs2.js +522 -0
  65. package/dist/index.cjs2.js.map +1 -0
  66. package/dist/index.cjs3.js +141 -0
  67. package/dist/index.cjs3.js.map +1 -0
  68. package/dist/index.cjs4.js +18 -0
  69. package/dist/index.cjs4.js.map +1 -0
  70. package/dist/index.es.js +1339 -7697
  71. package/dist/index.es.js.map +1 -1
  72. package/dist/index.es2.js +514 -0
  73. package/dist/index.es2.js.map +1 -0
  74. package/dist/index.es3.js +134 -0
  75. package/dist/index.es3.js.map +1 -0
  76. package/dist/index.es4.js +13 -0
  77. package/dist/index.es4.js.map +1 -0
  78. package/dist/next.cjs.js +19 -201
  79. package/dist/next.cjs.js.map +1 -1
  80. package/dist/next.es.js +12 -192
  81. package/dist/next.es.js.map +1 -1
  82. package/dist/placeholders.cjs.js +13 -0
  83. package/dist/placeholders.cjs.js.map +1 -0
  84. package/dist/placeholders.es.js +12 -0
  85. package/dist/placeholders.es.js.map +1 -0
  86. package/dist/react-builder-preview.cjs.js +23 -33
  87. package/dist/react-builder-preview.cjs.js.map +1 -1
  88. package/dist/react-builder-preview.es.js +13 -23
  89. package/dist/react-builder-preview.es.js.map +1 -1
  90. package/dist/react-page.es.js +1 -1
  91. package/dist/react.cjs.js +16 -28
  92. package/dist/react.cjs.js.map +1 -1
  93. package/dist/react.es.js +8 -20
  94. package/dist/react.es.js.map +1 -1
  95. package/dist/types/components/builtin/Box/Box.d.ts +1 -4
  96. package/dist/types/components/builtin/Box/Box.d.ts.map +1 -1
  97. package/dist/types/components/builtin/Box/animations.d.ts +1 -8
  98. package/dist/types/components/builtin/Box/animations.d.ts.map +1 -1
  99. package/dist/types/components/builtin/Box/constants.d.ts +9 -0
  100. package/dist/types/components/builtin/Box/constants.d.ts.map +1 -0
  101. package/dist/types/components/builtin/Box/index.d.ts +2 -2
  102. package/dist/types/components/builtin/Box/index.d.ts.map +1 -1
  103. package/dist/types/components/builtin/Box/register.d.ts +3 -0
  104. package/dist/types/components/builtin/Box/register.d.ts.map +1 -0
  105. package/dist/types/components/builtin/Button/Button.d.ts +1 -4
  106. package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
  107. package/dist/types/components/builtin/Button/contants.d.ts +2 -0
  108. package/dist/types/components/builtin/Button/contants.d.ts.map +1 -0
  109. package/dist/types/components/builtin/Button/index.d.ts +1 -1
  110. package/dist/types/components/builtin/Button/index.d.ts.map +1 -1
  111. package/dist/types/components/builtin/Button/register.d.ts +3 -0
  112. package/dist/types/components/builtin/Button/register.d.ts.map +1 -0
  113. package/dist/types/components/builtin/Carousel/Carousel.d.ts +0 -3
  114. package/dist/types/components/builtin/Carousel/Carousel.d.ts.map +1 -1
  115. package/dist/types/components/builtin/Carousel/index.d.ts +1 -1
  116. package/dist/types/components/builtin/Carousel/index.d.ts.map +1 -1
  117. package/dist/types/components/builtin/Carousel/register.d.ts +3 -0
  118. package/dist/types/components/builtin/Carousel/register.d.ts.map +1 -0
  119. package/dist/types/components/builtin/Countdown/Countdown.d.ts +0 -3
  120. package/dist/types/components/builtin/Countdown/Countdown.d.ts.map +1 -1
  121. package/dist/types/components/builtin/Countdown/index.d.ts +1 -1
  122. package/dist/types/components/builtin/Countdown/index.d.ts.map +1 -1
  123. package/dist/types/components/builtin/Countdown/register.d.ts +3 -0
  124. package/dist/types/components/builtin/Countdown/register.d.ts.map +1 -0
  125. package/dist/types/components/builtin/Divider/Divider.d.ts +0 -3
  126. package/dist/types/components/builtin/Divider/Divider.d.ts.map +1 -1
  127. package/dist/types/components/builtin/Divider/index.d.ts +1 -1
  128. package/dist/types/components/builtin/Divider/index.d.ts.map +1 -1
  129. package/dist/types/components/builtin/Divider/register.d.ts +3 -0
  130. package/dist/types/components/builtin/Divider/register.d.ts.map +1 -0
  131. package/dist/types/components/builtin/Embed/Embed.d.ts +0 -3
  132. package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
  133. package/dist/types/components/builtin/Embed/index.d.ts +1 -1
  134. package/dist/types/components/builtin/Embed/index.d.ts.map +1 -1
  135. package/dist/types/components/builtin/Embed/register.d.ts +3 -0
  136. package/dist/types/components/builtin/Embed/register.d.ts.map +1 -0
  137. package/dist/types/components/builtin/Form/Form.d.ts +1 -10
  138. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -1
  139. package/dist/types/components/builtin/Form/components/Field/index.d.ts +1 -1
  140. package/dist/types/components/builtin/Form/components/Field/index.d.ts.map +1 -1
  141. package/dist/types/components/builtin/Form/context/FormContext.d.ts +6 -0
  142. package/dist/types/components/builtin/Form/context/FormContext.d.ts.map +1 -1
  143. package/dist/types/components/builtin/Form/index.d.ts +1 -1
  144. package/dist/types/components/builtin/Form/index.d.ts.map +1 -1
  145. package/dist/types/components/builtin/Form/register.d.ts +3 -0
  146. package/dist/types/components/builtin/Form/register.d.ts.map +1 -0
  147. package/dist/types/components/{hooks/useTable.d.ts → builtin/Form/types.d.ts} +2 -6
  148. package/dist/types/components/builtin/Form/types.d.ts.map +1 -0
  149. package/dist/types/components/builtin/Image/Image.d.ts +0 -3
  150. package/dist/types/components/builtin/Image/Image.d.ts.map +1 -1
  151. package/dist/types/components/builtin/Image/index.d.ts +1 -1
  152. package/dist/types/components/builtin/Image/index.d.ts.map +1 -1
  153. package/dist/types/components/builtin/Image/register.d.ts +3 -0
  154. package/dist/types/components/builtin/Image/register.d.ts.map +1 -0
  155. package/dist/types/components/builtin/Navigation/Navigation.d.ts +0 -3
  156. package/dist/types/components/builtin/Navigation/Navigation.d.ts.map +1 -1
  157. package/dist/types/components/builtin/Navigation/index.d.ts +1 -1
  158. package/dist/types/components/builtin/Navigation/index.d.ts.map +1 -1
  159. package/dist/types/components/builtin/Navigation/register.d.ts +3 -0
  160. package/dist/types/components/builtin/Navigation/register.d.ts.map +1 -0
  161. package/dist/types/components/builtin/Root/Root.d.ts +0 -2
  162. package/dist/types/components/builtin/Root/Root.d.ts.map +1 -1
  163. package/dist/types/components/builtin/Root/index.d.ts +1 -1
  164. package/dist/types/components/builtin/Root/index.d.ts.map +1 -1
  165. package/dist/types/components/builtin/Root/register.d.ts +3 -0
  166. package/dist/types/components/builtin/Root/register.d.ts.map +1 -0
  167. package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts +0 -3
  168. package/dist/types/components/builtin/SocialLinks/SocialLinks.d.ts.map +1 -1
  169. package/dist/types/components/builtin/SocialLinks/index.d.ts +1 -1
  170. package/dist/types/components/builtin/SocialLinks/index.d.ts.map +1 -1
  171. package/dist/types/components/builtin/SocialLinks/register.d.ts +3 -0
  172. package/dist/types/components/builtin/SocialLinks/register.d.ts.map +1 -0
  173. package/dist/types/components/builtin/Text/Text.d.ts +0 -3
  174. package/dist/types/components/builtin/Text/Text.d.ts.map +1 -1
  175. package/dist/types/components/builtin/Text/index.d.ts +1 -1
  176. package/dist/types/components/builtin/Text/index.d.ts.map +1 -1
  177. package/dist/types/components/builtin/Text/register.d.ts +3 -0
  178. package/dist/types/components/builtin/Text/register.d.ts.map +1 -0
  179. package/dist/types/components/builtin/Video/Video.d.ts +0 -3
  180. package/dist/types/components/builtin/Video/Video.d.ts.map +1 -1
  181. package/dist/types/components/builtin/Video/index.d.ts +1 -1
  182. package/dist/types/components/builtin/Video/index.d.ts.map +1 -1
  183. package/dist/types/components/builtin/Video/register.d.ts +3 -0
  184. package/dist/types/components/builtin/Video/register.d.ts.map +1 -0
  185. package/dist/types/components/builtin/index.d.ts +1 -2
  186. package/dist/types/components/builtin/index.d.ts.map +1 -1
  187. package/dist/types/components/builtin/register.d.ts +3 -0
  188. package/dist/types/components/builtin/register.d.ts.map +1 -0
  189. package/dist/types/components/hooks/index.d.ts +0 -1
  190. package/dist/types/components/hooks/index.d.ts.map +1 -1
  191. package/dist/types/next.d.ts +12 -2
  192. package/dist/types/next.d.ts.map +1 -1
  193. package/dist/useBoxShadow.cjs.js +78 -0
  194. package/dist/useBoxShadow.cjs.js.map +1 -0
  195. package/dist/useBoxShadow.es.js +77 -0
  196. package/dist/useBoxShadow.es.js.map +1 -0
  197. package/dist/useMediaQuery.cjs.js +26 -0
  198. package/dist/useMediaQuery.cjs.js.map +1 -0
  199. package/dist/useMediaQuery.es.js +25 -0
  200. package/dist/useMediaQuery.es.js.map +1 -0
  201. package/next/plugin.js +1 -0
  202. package/package.json +4 -1
  203. package/dist/types/components/hooks/useTable.d.ts.map +0 -1
@@ -0,0 +1,1697 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import * as React from "react";
33
+ import { forwardRef, useRef, useImperativeHandle, useState, useEffect, useMemo } from "react";
34
+ import styled, { css, keyframes } from "styled-components";
35
+ import { Field as Field$1, getIn, Formik } from "formik";
36
+ import { cx } from "@emotion/css";
37
+ import { c as cssMediaRules, b as cssMargin, i as cssTextStyle, h as cssGridItem } from "./cssMediaRules.es.js";
38
+ import { q as Shapes, s as Sizes, C as Contrasts, o as colorToString, t as useFormContext, u as useIsInBuilder, v as useQuery, T as TABLE_BY_ID, w as useMutation, x as Provider, A as Alignments } from "./index.es.js";
39
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
40
+ import ColorHelper from "color";
41
+ import Button$1 from "./Button.es.js";
42
+ import { L as Link } from "./index.es3.js";
43
+ import { g as getBox } from "./box-models.es.js";
44
+ import { gql } from "@apollo/client";
45
+ import "use-sync-external-store/shim/with-selector";
46
+ import "./react-page.es.js";
47
+ import "redux";
48
+ import "redux-thunk";
49
+ import "./actions.es.js";
50
+ import "./descriptors.es.js";
51
+ import "./style.es.js";
52
+ import "./color.es.js";
53
+ import "./image.es.js";
54
+ import "next/dynamic";
55
+ import "next/document";
56
+ import "slate";
57
+ import "@emotion/server/create-instance";
58
+ import "@apollo/client/link/batch-http";
59
+ import "./graphql.es.js";
60
+ import "./text-input.es.js";
61
+ import "./shape.es.js";
62
+ import "react-dom";
63
+ import "html-react-parser";
64
+ import "next/head";
65
+ import "uuid/v4";
66
+ import "corporate-ipsum";
67
+ import "scroll-into-view-if-needed";
68
+ import "next/link";
69
+ import "css-box-model";
70
+ var _path;
71
+ function _extends$1() {
72
+ _extends$1 = Object.assign || function(target) {
73
+ for (var i = 1; i < arguments.length; i++) {
74
+ var source = arguments[i];
75
+ for (var key in source) {
76
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
77
+ target[key] = source[key];
78
+ }
79
+ }
80
+ }
81
+ return target;
82
+ };
83
+ return _extends$1.apply(this, arguments);
84
+ }
85
+ var SvgCheck12 = function SvgCheck122(props) {
86
+ return /* @__PURE__ */ React.createElement("svg", _extends$1({
87
+ width: 12,
88
+ height: 12,
89
+ viewBox: "0 0 12 12",
90
+ xmlns: "http://www.w3.org/2000/svg"
91
+ }, props), _path || (_path = /* @__PURE__ */ React.createElement("path", {
92
+ fillRule: "evenodd",
93
+ clipRule: "evenodd",
94
+ d: "M11.7071 1.79289C12.0976 2.18342 12.0976 2.81658 11.7071 3.20711L4.70711 10.2071C4.31658 10.5976 3.68342 10.5976 3.29289 10.2071L0.292893 7.20711C-0.0976311 6.81658 -0.0976311 6.18342 0.292893 5.79289C0.683417 5.40237 1.31658 5.40237 1.70711 5.79289L4 8.08579L10.2929 1.79289C10.6834 1.40237 11.3166 1.40237 11.7071 1.79289Z"
95
+ })));
96
+ };
97
+ function getSizeHeight$2(size) {
98
+ switch (size) {
99
+ case Sizes.SMALL:
100
+ return 30;
101
+ case Sizes.MEDIUM:
102
+ return 38;
103
+ case Sizes.LARGE:
104
+ return 48;
105
+ default:
106
+ throw new Error(`Invalid form size "${size}"`);
107
+ }
108
+ }
109
+ function getSizeHorizontalPadding(size) {
110
+ switch (size) {
111
+ case Sizes.SMALL:
112
+ return 8;
113
+ case Sizes.MEDIUM:
114
+ return 12;
115
+ case Sizes.LARGE:
116
+ return 16;
117
+ default:
118
+ throw new Error(`Invalid form size "${size}"`);
119
+ }
120
+ }
121
+ function getSizeVerticalPadding(size) {
122
+ switch (size) {
123
+ case Sizes.SMALL:
124
+ return 3;
125
+ case Sizes.MEDIUM:
126
+ return 7;
127
+ case Sizes.LARGE:
128
+ return 11;
129
+ default:
130
+ throw new Error(`Invalid form size "${size}"`);
131
+ }
132
+ }
133
+ function getShapeBorderRadius(shape) {
134
+ switch (shape) {
135
+ case Shapes.SQUARE:
136
+ return 0;
137
+ case Shapes.ROUNDED:
138
+ return 4;
139
+ case Shapes.PILL:
140
+ return 500;
141
+ default:
142
+ throw new Error(`Invalid form shape "${shape}"`);
143
+ }
144
+ }
145
+ function getContrastBorderColor(contrast, error) {
146
+ switch (contrast) {
147
+ case Contrasts.LIGHT:
148
+ return error ? "rgba(255, 0, 0, 0.7)" : "rgba(0, 0, 0, 0.25)";
149
+ case Contrasts.DARK:
150
+ return error ? "rgba(255, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.6)";
151
+ default:
152
+ throw new Error(`Invalid form contrast "${contrast}"`);
153
+ }
154
+ }
155
+ function getContrastBackgroundColor(contrast) {
156
+ switch (contrast) {
157
+ case Contrasts.LIGHT:
158
+ return "white";
159
+ case Contrasts.DARK:
160
+ return "rgba(0, 0, 0, 0.7)";
161
+ default:
162
+ throw new Error(`Invalid form contrast "${contrast}"`);
163
+ }
164
+ }
165
+ function getContrastColor$1(contrast) {
166
+ switch (contrast) {
167
+ case Contrasts.LIGHT:
168
+ return "rgba(0, 0, 0, 0.95)";
169
+ case Contrasts.DARK:
170
+ return "white";
171
+ default:
172
+ throw new Error(`Invalid form contrast "${contrast}"`);
173
+ }
174
+ }
175
+ function getContrastPlaceholderColor(contrast) {
176
+ switch (contrast) {
177
+ case Contrasts.LIGHT:
178
+ return "rgba(0, 0, 0, 0.3)";
179
+ case Contrasts.DARK:
180
+ return "rgba(255,255,255,0.3)";
181
+ default:
182
+ throw new Error(`Invalid form contrast "${contrast}"`);
183
+ }
184
+ }
185
+ function cssField() {
186
+ return css`
187
+ display: block;
188
+ width: 100%;
189
+ outline: none;
190
+ border-width: 1px;
191
+ border-style: solid;
192
+ transition: border-color 200ms;
193
+ ${(props) => cssMediaRules([props.shape, props.size, props.contrast, props.brandColor], ([
194
+ shape = Shapes.ROUNDED,
195
+ size = Sizes.MEDIUM,
196
+ contrast = Contrasts.LIGHT,
197
+ brandColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 }
198
+ ]) => css`
199
+ padding: ${getSizeVerticalPadding(size)}px ${getSizeHorizontalPadding(size)}px;
200
+ border-radius: ${getShapeBorderRadius(shape)}px;
201
+ border-color: ${getContrastBorderColor(contrast, props.error)};
202
+ color: ${getContrastColor$1(contrast)};
203
+ background-color: ${getContrastBackgroundColor(contrast)};
204
+
205
+ :focus,
206
+ :focus-within {
207
+ border-color: ${colorToString(brandColor)};
208
+ }
209
+
210
+ ::placeholder {
211
+ color: ${getContrastPlaceholderColor(contrast)};
212
+ }
213
+ `)}
214
+ `;
215
+ }
216
+ function getSizeHeight$1(size) {
217
+ switch (size) {
218
+ case Sizes.SMALL:
219
+ return 36;
220
+ case Sizes.MEDIUM:
221
+ return 42;
222
+ case Sizes.LARGE:
223
+ return 48;
224
+ default:
225
+ throw new Error(`Invalid form size "${size}"`);
226
+ }
227
+ }
228
+ const Base$2 = styled.input.withConfig({
229
+ shouldForwardProp: (prop, defaultValidator) => !["shape", "size", "contrast", "brandColor", "error"].includes(prop.toString()) && defaultValidator(prop)
230
+ })`
231
+ ${cssField()}
232
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
233
+ min-height: ${getSizeHeight$1(size)}px;
234
+ max-height: ${getSizeHeight$1(size)}px;
235
+ `)}
236
+ `;
237
+ var Input$2 = forwardRef(function Input(_a, ref) {
238
+ var _b = _a, {
239
+ error = false,
240
+ form
241
+ } = _b, restOfProps = __objRest(_b, [
242
+ "error",
243
+ "form"
244
+ ]);
245
+ const {
246
+ shape,
247
+ size,
248
+ contrast,
249
+ brandColor
250
+ } = useFormContext();
251
+ return /* @__PURE__ */ jsx(Base$2, __spreadProps(__spreadValues({}, restOfProps), {
252
+ ref,
253
+ error,
254
+ shape,
255
+ size,
256
+ contrast,
257
+ brandColor
258
+ }));
259
+ });
260
+ const Container$3 = styled.div.withConfig({
261
+ shouldForwardProp: (prop) => !["width", "margin"].includes(prop.toString())
262
+ })`
263
+ display: flex;
264
+ flex-direction: column;
265
+ ${cssMargin()};
266
+ `;
267
+ const Label$2 = styled.div`
268
+ max-width: 120px;
269
+ min-width: 60px;
270
+ height: 8px;
271
+ border-radius: 2px;
272
+ background-color: #a1a8c2;
273
+ opacity: 0.4;
274
+ margin-bottom: 8px;
275
+ `;
276
+ const Input$1 = styled.div`
277
+ min-width: 80px;
278
+ height: 32px;
279
+ border-radius: 4px;
280
+ border-width: 2px;
281
+ border-style: solid;
282
+ border-color: #a1a8c2;
283
+ opacity: 0.4;
284
+ `;
285
+ const Button = styled.div`
286
+ min-width: 140px;
287
+ height: 32px;
288
+ border-radius: 4px;
289
+ background-color: #a1a8c2;
290
+ opacity: 0.4;
291
+ `;
292
+ var Placeholder = forwardRef(function Placeholder2({
293
+ className,
294
+ margin
295
+ }, ref) {
296
+ return /* @__PURE__ */ jsxs(Container$3, {
297
+ ref,
298
+ className,
299
+ margin,
300
+ children: [/* @__PURE__ */ jsxs("div", {
301
+ style: {
302
+ display: "flex",
303
+ flexDirection: "column",
304
+ marginBottom: 16
305
+ },
306
+ children: [/* @__PURE__ */ jsx(Label$2, {}), /* @__PURE__ */ jsx(Input$1, {})]
307
+ }), /* @__PURE__ */ jsxs("div", {
308
+ style: {
309
+ display: "flex",
310
+ flexDirection: "column",
311
+ marginBottom: 16
312
+ },
313
+ children: [/* @__PURE__ */ jsx(Label$2, {}), /* @__PURE__ */ jsx(Input$1, {})]
314
+ }), /* @__PURE__ */ jsx("div", {
315
+ style: {
316
+ display: "flex",
317
+ flexDirection: "column",
318
+ justifyContent: "flex-end"
319
+ },
320
+ children: /* @__PURE__ */ jsx(Button, {})
321
+ })]
322
+ });
323
+ });
324
+ function getSizeHeight(size) {
325
+ switch (size) {
326
+ case Sizes.SMALL:
327
+ return 14;
328
+ case Sizes.MEDIUM:
329
+ return 18;
330
+ case Sizes.LARGE:
331
+ return 22;
332
+ default:
333
+ throw new Error(`Invalid form size "${size}"`);
334
+ }
335
+ }
336
+ function getContrastColor(contrast) {
337
+ switch (contrast) {
338
+ case Contrasts.LIGHT:
339
+ return "rgba(0, 0, 0, 0.8)";
340
+ case Contrasts.DARK:
341
+ return "rgba(255, 255, 255, 0.95)";
342
+ default:
343
+ throw new Error(`Invalid form contrast "${contrast}"`);
344
+ }
345
+ }
346
+ const Base$1 = styled.label.withConfig({
347
+ shouldForwardProp: (prop, defaultValidator) => !["contrast", "size", "textStyle", "textColor"].includes(prop.toString()) && defaultValidator(prop)
348
+ })`
349
+ display: block;
350
+ margin: 0 0 0.25em 0;
351
+ ${cssTextStyle()}
352
+ ${(props) => cssMediaRules([props.size, props.contrast, props.textColor], ([size = Sizes.MEDIUM, contrast = Contrasts.LIGHT, textColor]) => css`
353
+ min-height: ${getSizeHeight(size)}px;
354
+ color: ${textColor == null ? getContrastColor(contrast) : colorToString(textColor)};
355
+ `)}
356
+ `;
357
+ function Label$1(props) {
358
+ const {
359
+ contrast,
360
+ size,
361
+ labelTextStyle,
362
+ labelTextColor
363
+ } = useFormContext();
364
+ return /* @__PURE__ */ jsx(Base$1, __spreadProps(__spreadValues({}, props), {
365
+ contrast,
366
+ size,
367
+ textStyle: labelTextStyle,
368
+ textColor: labelTextColor
369
+ }));
370
+ }
371
+ var SingleLineTextTableField = forwardRef(function SingleLineTextTableField2(_c, ref) {
372
+ var _d = _c, {
373
+ id,
374
+ label = "",
375
+ name,
376
+ error,
377
+ hideLabel = false
378
+ } = _d, restOfProps = __objRest(_d, [
379
+ "id",
380
+ "label",
381
+ "name",
382
+ "error",
383
+ "hideLabel"
384
+ ]);
385
+ return /* @__PURE__ */ jsxs(Fragment, {
386
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
387
+ htmlFor: id,
388
+ children: label
389
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
390
+ "aria-label": label,
391
+ ref,
392
+ id,
393
+ name,
394
+ type: "text",
395
+ error: error != null
396
+ }))]
397
+ });
398
+ });
399
+ const Base = styled.textarea.withConfig({
400
+ shouldForwardProp: (prop, defaultValidator) => !["error", "shape", "size", "contrast", "brandColor"].includes(prop.toString()) && defaultValidator(prop)
401
+ })`
402
+ resize: vertical;
403
+ ${cssField()}
404
+ `;
405
+ var TextArea = forwardRef(function TextArea2(_e, ref) {
406
+ var _f = _e, {
407
+ error = false,
408
+ form
409
+ } = _f, restOfProps = __objRest(_f, [
410
+ "error",
411
+ "form"
412
+ ]);
413
+ const {
414
+ shape,
415
+ size,
416
+ contrast,
417
+ brandColor
418
+ } = useFormContext();
419
+ return /* @__PURE__ */ jsx(Base, __spreadProps(__spreadValues({}, restOfProps), {
420
+ ref,
421
+ rows: 4,
422
+ error,
423
+ shape,
424
+ size,
425
+ contrast,
426
+ brandColor
427
+ }));
428
+ });
429
+ var LongTextTableField = forwardRef(function LongTextTableField2(_g2, ref) {
430
+ var _h = _g2, {
431
+ id,
432
+ label = "",
433
+ error,
434
+ hideLabel = false
435
+ } = _h, restOfProps = __objRest(_h, [
436
+ "id",
437
+ "label",
438
+ "error",
439
+ "hideLabel"
440
+ ]);
441
+ return /* @__PURE__ */ jsxs(Fragment, {
442
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
443
+ htmlFor: id,
444
+ children: label
445
+ }), /* @__PURE__ */ jsx(TextArea, __spreadProps(__spreadValues({}, restOfProps), {
446
+ "aria-label": label,
447
+ ref,
448
+ id,
449
+ error: error != null
450
+ }))]
451
+ });
452
+ });
453
+ function getCheckmarkColor$1({
454
+ swatch: {
455
+ hue: h,
456
+ saturation: s,
457
+ lightness: l
458
+ },
459
+ alpha: a
460
+ }) {
461
+ return ColorHelper({
462
+ h,
463
+ s,
464
+ l
465
+ }).alpha(a).isLight() ? "rgba(0, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.95)";
466
+ }
467
+ const Container$2 = styled.div.withConfig({
468
+ shouldForwardProp: (prop) => !["size"].includes(prop)
469
+ })`
470
+ position: relative;
471
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
472
+ height: ${getSizeHeight(size)}px;
473
+ width: ${getSizeHeight(size)}px;
474
+ `)}
475
+ `;
476
+ const FakeCheckbox = styled.div.withConfig({
477
+ shouldForwardProp: (prop) => !["contrast", "error"].includes(prop)
478
+ })`
479
+ position: absolute;
480
+ width: 100%;
481
+ height: 100%;
482
+ border-style: solid;
483
+ border-radius: 4px;
484
+ pointer-events: none;
485
+ border-width: 1px;
486
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
487
+ border-color: ${getContrastBorderColor(contrast, props.error)};
488
+ background-color: ${getContrastBackgroundColor(contrast)};
489
+ `)}
490
+ `;
491
+ const HiddenCheckbox = styled.input.withConfig({
492
+ shouldForwardProp: (prop, defaultValidator) => !["size", "brandColor", "contrast", "error"].includes(prop) && defaultValidator(prop)
493
+ })`
494
+ position: absolute;
495
+ opacity: 0;
496
+ width: 100%;
497
+ height: 100%;
498
+ cursor: pointer;
499
+
500
+ &:disabled {
501
+ cursor: no-drop;
502
+
503
+ & ~ ${FakeCheckbox} {
504
+ opacity: 0.5;
505
+ }
506
+ }
507
+
508
+ &:checked ~ ${FakeCheckbox} {
509
+ ${(props) => cssMediaRules([props.brandColor], ([{
510
+ swatch = {
511
+ hue: 0,
512
+ saturation: 0,
513
+ lightness: 0
514
+ },
515
+ alpha = 1
516
+ } = {}]) => css`
517
+ background-color: ${colorToString({
518
+ swatch,
519
+ alpha
520
+ })};
521
+ `)}
522
+ border-color: transparent;
523
+
524
+ &::after {
525
+ content: '';
526
+ position: absolute;
527
+ box-sizing: content-box;
528
+ width: 25%;
529
+ height: 50%;
530
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
531
+ border-width: ${getSizeHeight(size) * 0.1}px;
532
+ border-left: 0;
533
+ border-top: 0;
534
+ `)}
535
+ border-style: solid;
536
+ ${(props) => cssMediaRules([props.brandColor], ([{
537
+ swatch = {
538
+ hue: 0,
539
+ saturation: 0,
540
+ lightness: 0
541
+ },
542
+ alpha = 1
543
+ } = {}]) => css`
544
+ border-color: ${getCheckmarkColor$1({
545
+ swatch,
546
+ alpha
547
+ })};
548
+ `)}
549
+ transform: rotate(45deg) translate3d(91%, -23%, 0);
550
+ }
551
+ }
552
+
553
+ &:not(:disabled) {
554
+ &:focus ~ ${FakeCheckbox} {
555
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
556
+ swatch: {
557
+ hue: 0,
558
+ saturation: 0,
559
+ lightness: 0
560
+ },
561
+ alpha: 1
562
+ }]) => css`
563
+ border-color: ${colorToString(brandColor)};
564
+ `)}
565
+ }
566
+ }
567
+
568
+ &:not(:disabled):checked {
569
+ &:focus ~ ${FakeCheckbox} {
570
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
571
+ border-color: ${getContrastBorderColor(contrast, props.error)};
572
+ `)}
573
+ }
574
+ }
575
+ `;
576
+ var Checkbox = forwardRef(function Checkbox2(_i, ref) {
577
+ var _j = _i, {
578
+ error,
579
+ className,
580
+ style,
581
+ form
582
+ } = _j, restOfProps = __objRest(_j, [
583
+ "error",
584
+ "className",
585
+ "style",
586
+ "form"
587
+ ]);
588
+ const {
589
+ size,
590
+ contrast,
591
+ brandColor
592
+ } = useFormContext();
593
+ return /* @__PURE__ */ jsxs(Container$2, {
594
+ size,
595
+ children: [/* @__PURE__ */ jsx(HiddenCheckbox, __spreadProps(__spreadValues({}, restOfProps), {
596
+ type: "checkbox",
597
+ ref,
598
+ error,
599
+ size,
600
+ contrast,
601
+ brandColor
602
+ })), /* @__PURE__ */ jsx(FakeCheckbox, {
603
+ className,
604
+ error,
605
+ contrast,
606
+ style
607
+ })]
608
+ });
609
+ });
610
+ const StyledLabel$2 = styled(Label$1)`
611
+ display: flex;
612
+ align-items: center;
613
+ margin: 0;
614
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
615
+ min-height: ${getSizeHeight$1(size)}px;
616
+ max-height: ${getSizeHeight$1(size)}px;
617
+ `)}
618
+ `;
619
+ const CheckboxContainer$1 = styled.span`
620
+ margin-right: 8px;
621
+ `;
622
+ var CheckboxTableField = forwardRef(function CheckboxTableField2(_k, ref) {
623
+ var _l = _k, {
624
+ form,
625
+ id,
626
+ name,
627
+ label = "",
628
+ value = false,
629
+ error
630
+ } = _l, restOfProps = __objRest(_l, [
631
+ "form",
632
+ "id",
633
+ "name",
634
+ "label",
635
+ "value",
636
+ "error"
637
+ ]);
638
+ const {
639
+ size
640
+ } = useFormContext();
641
+ function handleChange(event) {
642
+ form.setFieldValue(name, event.currentTarget.checked);
643
+ }
644
+ return /* @__PURE__ */ jsxs(StyledLabel$2, {
645
+ htmlFor: id,
646
+ size,
647
+ children: [/* @__PURE__ */ jsx(CheckboxContainer$1, {
648
+ children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, restOfProps), {
649
+ "aria-label": label,
650
+ checked: value,
651
+ onChange: handleChange,
652
+ ref,
653
+ id,
654
+ error: error != null
655
+ }))
656
+ }), label]
657
+ });
658
+ });
659
+ const MainLabel = styled(Label$1)`
660
+ margin: 0 0 4px 0;
661
+ `;
662
+ const StyledLabel$1 = styled(Label$1)`
663
+ display: flex;
664
+ align-items: center;
665
+ margin: 8px 0;
666
+
667
+ &:last-of-type {
668
+ margin-bottom: 0;
669
+ }
670
+ `;
671
+ const CheckboxContainer = styled.span`
672
+ margin-right: 8px;
673
+ `;
674
+ var MultipleSelectTableField = forwardRef(function MultipleSelectTableField2(_m, ref) {
675
+ var _n = _m, {
676
+ tableColumn,
677
+ label = "",
678
+ required,
679
+ value = [],
680
+ onChange,
681
+ hideLabel = false
682
+ } = _n, restOfProps = __objRest(_n, [
683
+ "tableColumn",
684
+ "label",
685
+ "required",
686
+ "value",
687
+ "onChange",
688
+ "hideLabel"
689
+ ]);
690
+ const handle = useRef({
691
+ validity: {
692
+ valueMissing: required === true && value.length === 0,
693
+ typeMismatch: false
694
+ }
695
+ });
696
+ useImperativeHandle(ref, () => handle.current, []);
697
+ function handleChange(event) {
698
+ handle.current.validity.valueMissing = required === true && !event.currentTarget.checked && value.filter((v) => v !== event.currentTarget.value).length === 0;
699
+ onChange(event);
700
+ }
701
+ return /* @__PURE__ */ jsxs("div", {
702
+ children: [!hideLabel && /* @__PURE__ */ jsx(MainLabel, {
703
+ children: label
704
+ }), tableColumn.options.map((option) => /* @__PURE__ */ jsxs(StyledLabel$1, {
705
+ htmlFor: option.id,
706
+ children: [/* @__PURE__ */ jsx(CheckboxContainer, {
707
+ children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, restOfProps), {
708
+ "aria-label": label,
709
+ onChange: handleChange,
710
+ checked: value.includes(option.name),
711
+ id: option.id,
712
+ value: option.name
713
+ }))
714
+ }), option.name]
715
+ }, option.id))]
716
+ });
717
+ });
718
+ function getCheckmarkColor({
719
+ swatch: {
720
+ hue: h,
721
+ saturation: s,
722
+ lightness: l
723
+ } = {
724
+ hue: 0,
725
+ saturation: 0,
726
+ lightness: 0
727
+ },
728
+ alpha: a
729
+ }) {
730
+ return ColorHelper({
731
+ h,
732
+ s,
733
+ l
734
+ }).alpha(a).isLight() ? "rgba(0, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.95)";
735
+ }
736
+ const Container$1 = styled.div.withConfig({
737
+ shouldForwardProp: (prop) => !["size"].includes(prop.toString())
738
+ })`
739
+ position: relative;
740
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
741
+ height: ${getSizeHeight(size)}px;
742
+ width: ${getSizeHeight(size)}px;
743
+ `)}
744
+ `;
745
+ const FakeRadioButton = styled.div.withConfig({
746
+ shouldForwardProp: (prop) => !["contrast", "error"].includes(prop.toString())
747
+ })`
748
+ position: absolute;
749
+ width: 100%;
750
+ height: 100%;
751
+ border-style: solid;
752
+ border-radius: 50%;
753
+ pointer-events: none;
754
+ border-width: 1px;
755
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
756
+ border-color: ${getContrastBorderColor(contrast, props.error)};
757
+ background-color: ${getContrastBackgroundColor(contrast)};
758
+ `)}
759
+ `;
760
+ const HiddenRadioButton = styled.input.withConfig({
761
+ shouldForwardProp: (prop) => !["brandColor", "contrast", "error"].includes(prop.toString())
762
+ }).attrs({
763
+ type: "radio"
764
+ })`
765
+ position: absolute;
766
+ opacity: 0;
767
+ width: 100%;
768
+ height: 100%;
769
+ cursor: pointer;
770
+
771
+ &:disabled {
772
+ cursor: no-drop;
773
+
774
+ & ~ ${FakeRadioButton} {
775
+ opacity: 0.5;
776
+ }
777
+ }
778
+
779
+ &:checked ~ ${FakeRadioButton} {
780
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
781
+ swatch: {
782
+ hue: 0,
783
+ saturation: 0,
784
+ lightness: 0
785
+ },
786
+ alpha: 1
787
+ }]) => css`
788
+ background-color: ${colorToString(brandColor)};
789
+ `)}
790
+ border-color: transparent;
791
+
792
+ &::after {
793
+ content: '';
794
+ position: absolute;
795
+ box-sizing: content-box;
796
+ top: 50%;
797
+ left: 50%;
798
+ width: 50%;
799
+ height: 50%;
800
+ border-radius: 50%;
801
+ transform: translate(-50%, -50%);
802
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
803
+ swatch: {
804
+ hue: 0,
805
+ saturation: 0,
806
+ lightness: 0
807
+ },
808
+ alpha: 1
809
+ }]) => css`
810
+ background-color: ${getCheckmarkColor(brandColor)};
811
+ `)}
812
+ }
813
+ }
814
+
815
+ &:not(:disabled) {
816
+ &:focus ~ ${FakeRadioButton} {
817
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
818
+ swatch: {
819
+ hue: 0,
820
+ saturation: 0,
821
+ lightness: 0
822
+ },
823
+ alpha: 1
824
+ }]) => css`
825
+ border-color: ${colorToString(brandColor)};
826
+ `)}
827
+ }
828
+ }
829
+
830
+ &:not(:disabled):checked {
831
+ &:focus ~ ${FakeRadioButton} {
832
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
833
+ border-color: ${getContrastBorderColor(contrast, props.error)};
834
+ `)}
835
+ }
836
+ }
837
+ `;
838
+ var RadioButton = forwardRef(function RadioButton2(_o, ref) {
839
+ var _p = _o, {
840
+ error,
841
+ className,
842
+ style,
843
+ form
844
+ } = _p, restOfProps = __objRest(_p, [
845
+ "error",
846
+ "className",
847
+ "style",
848
+ "form"
849
+ ]);
850
+ const {
851
+ size,
852
+ contrast,
853
+ brandColor
854
+ } = useFormContext();
855
+ return /* @__PURE__ */ jsxs(Container$1, {
856
+ size,
857
+ children: [/* @__PURE__ */ jsx(HiddenRadioButton, __spreadProps(__spreadValues({}, restOfProps), {
858
+ ref,
859
+ error,
860
+ contrast,
861
+ brandColor
862
+ })), /* @__PURE__ */ jsx(FakeRadioButton, {
863
+ className,
864
+ error,
865
+ contrast,
866
+ style
867
+ })]
868
+ });
869
+ });
870
+ const StyledLabel = styled(Label$1)`
871
+ display: flex;
872
+ align-items: center;
873
+ margin: 8px 0;
874
+
875
+ &:last-of-type {
876
+ margin-bottom: 0;
877
+ }
878
+ `;
879
+ const RadioButtonContainer = styled.span`
880
+ margin-right: 8px;
881
+ `;
882
+ var TableColumnRadioButtonGroup = forwardRef(function TableColumnRadioButtonGroup2(_q, ref) {
883
+ var _r = _q, {
884
+ tableColumn,
885
+ label = "",
886
+ value = "",
887
+ required = false,
888
+ hideLabel = false,
889
+ onChange
890
+ } = _r, restOfProps = __objRest(_r, [
891
+ "tableColumn",
892
+ "label",
893
+ "value",
894
+ "required",
895
+ "hideLabel",
896
+ "onChange"
897
+ ]);
898
+ const handle = useRef({
899
+ validity: {
900
+ valueMissing: required === true && value === "",
901
+ typeMismatch: false
902
+ }
903
+ });
904
+ useImperativeHandle(ref, () => handle.current, []);
905
+ function handleChange(event) {
906
+ handle.current.validity.valueMissing = required === true && !event.currentTarget.checked;
907
+ onChange(event);
908
+ }
909
+ return /* @__PURE__ */ jsxs("div", {
910
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
911
+ as: "p",
912
+ children: label
913
+ }), tableColumn.options.map((option) => /* @__PURE__ */ jsxs(StyledLabel, {
914
+ htmlFor: option.id,
915
+ "aria-label": label,
916
+ children: [/* @__PURE__ */ jsx(RadioButtonContainer, {
917
+ children: /* @__PURE__ */ jsx(RadioButton, __spreadProps(__spreadValues({}, restOfProps), {
918
+ onChange: handleChange,
919
+ checked: value === option.name,
920
+ id: option.id,
921
+ value: option.name
922
+ }))
923
+ }), option.name]
924
+ }, option.id))]
925
+ });
926
+ });
927
+ const Container = styled.div.withConfig({
928
+ shouldForwardProp: (prop) => !["error", "shape", "size", "contrast", "brandColor"].includes(prop.toString())
929
+ })`
930
+ ${cssField()}
931
+ display: flex;
932
+ align-items: center;
933
+ position: relative;
934
+ user-select: none;
935
+ border-color: #f19eb9;
936
+
937
+ &:focus,
938
+ &:focus-within {
939
+ border-color: #e54e7f;
940
+ }
941
+
942
+ ${(props) => cssMediaRules([props.size, props.contrast], ([size = Sizes.MEDIUM, contrast = Contrasts.LIGHT]) => css`
943
+ min-height: ${getSizeHeight$2(size)}px;
944
+ max-height: ${getSizeHeight$2(size)}px;
945
+
946
+ &::after {
947
+ content: '';
948
+ position: absolute;
949
+ right: ${getSizeHorizontalPadding(size)}px;
950
+ top: 50%;
951
+ transform: translate3d(0, -25%, 0);
952
+ border: solid 0.35em transparent;
953
+ border-top-color: ${getContrastColor$1(contrast)};
954
+ }
955
+ `)}
956
+ `;
957
+ const Select = styled.select`
958
+ appearance: none;
959
+ position: absolute;
960
+ top: 0;
961
+ left: 0;
962
+ opacity: 0;
963
+ width: 100%;
964
+ height: 100%;
965
+ `;
966
+ var TableColumnSingleSelect = forwardRef(function TableColumnSingleSelect2(_s, ref) {
967
+ var _t = _s, {
968
+ id,
969
+ tableColumn,
970
+ value = "",
971
+ label = "",
972
+ error = false,
973
+ hideLabel = false,
974
+ form
975
+ } = _t, restOfProps = __objRest(_t, [
976
+ "id",
977
+ "tableColumn",
978
+ "value",
979
+ "label",
980
+ "error",
981
+ "hideLabel",
982
+ "form"
983
+ ]);
984
+ const {
985
+ shape,
986
+ size,
987
+ contrast,
988
+ brandColor
989
+ } = useFormContext();
990
+ return /* @__PURE__ */ jsxs(Fragment, {
991
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
992
+ htmlFor: id,
993
+ children: label
994
+ }), /* @__PURE__ */ jsxs(Container, {
995
+ error,
996
+ shape,
997
+ size,
998
+ contrast,
999
+ brandColor,
1000
+ children: [/* @__PURE__ */ jsx("span", {
1001
+ children: value === "" ? "-" : value
1002
+ }), /* @__PURE__ */ jsxs(Select, __spreadProps(__spreadValues({}, restOfProps), {
1003
+ "aria-label": label,
1004
+ ref,
1005
+ id,
1006
+ value,
1007
+ children: [/* @__PURE__ */ jsx("option", {
1008
+ value: "",
1009
+ children: "-"
1010
+ }), tableColumn.options.map((option) => /* @__PURE__ */ jsx("option", {
1011
+ value: option.name,
1012
+ children: option.name
1013
+ }, option.id))]
1014
+ }))]
1015
+ })]
1016
+ });
1017
+ });
1018
+ var SingleSelectTableField = forwardRef(function SingleSelectTableField2(_u, ref) {
1019
+ var _v = _u, {
1020
+ type
1021
+ } = _v, restOfProps = __objRest(_v, [
1022
+ "type"
1023
+ ]);
1024
+ return type === "select" ? /* @__PURE__ */ jsx(TableColumnSingleSelect, __spreadProps(__spreadValues({}, restOfProps), {
1025
+ ref
1026
+ })) : /* @__PURE__ */ jsx(TableColumnRadioButtonGroup, __spreadProps(__spreadValues({}, restOfProps), {
1027
+ ref
1028
+ }));
1029
+ });
1030
+ var PhoneNumberTableField = forwardRef(function PhoneNumberTableField2(_w, ref) {
1031
+ var _x = _w, {
1032
+ id,
1033
+ label = "",
1034
+ name,
1035
+ error,
1036
+ hideLabel = false
1037
+ } = _x, restOfProps = __objRest(_x, [
1038
+ "id",
1039
+ "label",
1040
+ "name",
1041
+ "error",
1042
+ "hideLabel"
1043
+ ]);
1044
+ return /* @__PURE__ */ jsxs(Fragment, {
1045
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
1046
+ htmlFor: id,
1047
+ children: label
1048
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
1049
+ "aria-label": label,
1050
+ ref,
1051
+ id,
1052
+ name,
1053
+ type: "tel",
1054
+ error: error != null
1055
+ }))]
1056
+ });
1057
+ });
1058
+ var EmailTableField = forwardRef(function EmailTableField2(_y, ref) {
1059
+ var _z = _y, {
1060
+ id,
1061
+ label = "",
1062
+ name,
1063
+ error,
1064
+ hideLabel = false
1065
+ } = _z, restOfProps = __objRest(_z, [
1066
+ "id",
1067
+ "label",
1068
+ "name",
1069
+ "error",
1070
+ "hideLabel"
1071
+ ]);
1072
+ return /* @__PURE__ */ jsxs(Fragment, {
1073
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
1074
+ htmlFor: id,
1075
+ children: label
1076
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
1077
+ "aria-label": label,
1078
+ ref,
1079
+ id,
1080
+ name,
1081
+ type: "email",
1082
+ error: error != null
1083
+ }))]
1084
+ });
1085
+ });
1086
+ var URLTableField = forwardRef(function URLTableField2(_A, ref) {
1087
+ var _B = _A, {
1088
+ id,
1089
+ label = "",
1090
+ name,
1091
+ error,
1092
+ hideLabel = false
1093
+ } = _B, restOfProps = __objRest(_B, [
1094
+ "id",
1095
+ "label",
1096
+ "name",
1097
+ "error",
1098
+ "hideLabel"
1099
+ ]);
1100
+ return /* @__PURE__ */ jsxs(Fragment, {
1101
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
1102
+ htmlFor: id,
1103
+ children: label
1104
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
1105
+ "aria-label": label,
1106
+ ref,
1107
+ id,
1108
+ name,
1109
+ type: "url",
1110
+ error: error != null
1111
+ }))]
1112
+ });
1113
+ });
1114
+ var NumberTableField = forwardRef(function NumberTableField2(_C, ref) {
1115
+ var _D = _C, {
1116
+ id,
1117
+ label = "",
1118
+ name,
1119
+ error,
1120
+ hideLabel = false
1121
+ } = _D, restOfProps = __objRest(_D, [
1122
+ "id",
1123
+ "label",
1124
+ "name",
1125
+ "error",
1126
+ "hideLabel"
1127
+ ]);
1128
+ return /* @__PURE__ */ jsxs(Fragment, {
1129
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
1130
+ htmlFor: id,
1131
+ children: label
1132
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
1133
+ "aria-label": label,
1134
+ ref,
1135
+ id,
1136
+ name,
1137
+ type: "number",
1138
+ error: error != null
1139
+ }))]
1140
+ });
1141
+ });
1142
+ const Label = styled.div.withConfig({
1143
+ shouldForwardProp: (prop) => !["size"].includes(prop.toString())
1144
+ })`
1145
+ display: block;
1146
+ max-width: 120px;
1147
+ min-width: 60px;
1148
+ border-radius: 2px;
1149
+ background-color: #5f49f4;
1150
+ opacity: 0.4;
1151
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
1152
+ margin: calc(0.25 * ${getSizeHeight(size)}px + 2px) 0;
1153
+ min-height: ${0.5 * getSizeHeight(size)}px;
1154
+ max-height: ${0.5 * getSizeHeight(size)}px;
1155
+ `)}
1156
+ `;
1157
+ const Input2 = styled.div.withConfig({
1158
+ shouldForwardProp: (prop) => !["shape", "size"].includes(prop.toString())
1159
+ })`
1160
+ display: block;
1161
+ width: 100%;
1162
+ border-width: 2px;
1163
+ border-style: solid;
1164
+ border-color: #5f49f4;
1165
+ opacity: 0.4;
1166
+ ${(props) => cssMediaRules([props.shape, props.size], ([shape = Shapes.ROUNDED, size = Sizes.MEDIUM]) => css`
1167
+ min-height: ${getSizeHeight$1(size)}px;
1168
+ max-height: ${getSizeHeight$1(size)}px;
1169
+ border-radius: ${getShapeBorderRadius(shape)}px;
1170
+ `)}
1171
+ `;
1172
+ function PlaceholderTableField() {
1173
+ const {
1174
+ size,
1175
+ shape
1176
+ } = useFormContext();
1177
+ return /* @__PURE__ */ jsxs(Fragment, {
1178
+ children: [/* @__PURE__ */ jsx(Label, {
1179
+ size
1180
+ }), /* @__PURE__ */ jsx(Input2, {
1181
+ shape,
1182
+ size
1183
+ })]
1184
+ });
1185
+ }
1186
+ function getTypeMismatchErrorMessage(tableColumn, label) {
1187
+ switch ((tableColumn || {}).__typename) {
1188
+ case "PhoneNumberTableColumn":
1189
+ return `${label} field must be a valid phone number.`;
1190
+ case "EmailTableColumn":
1191
+ return `${label} field must be a valid email.`;
1192
+ case "URLTableColumn":
1193
+ return `${label} field must be a valid URL.`;
1194
+ case "NumberTableColumn":
1195
+ return `${label} field must be a valid number.`;
1196
+ case "SingleLineTextTableColumn":
1197
+ case "LongTextTableColumn":
1198
+ case "CheckboxTableColumn":
1199
+ default:
1200
+ return `${label} field is invalid.`;
1201
+ }
1202
+ }
1203
+ function getTableColumnField(tableColumn) {
1204
+ switch ((tableColumn || {}).__typename) {
1205
+ case "SingleLineTextTableColumn":
1206
+ return SingleLineTextTableField;
1207
+ case "LongTextTableColumn":
1208
+ return LongTextTableField;
1209
+ case "CheckboxTableColumn":
1210
+ return CheckboxTableField;
1211
+ case "MultipleSelectTableColumn":
1212
+ return MultipleSelectTableField;
1213
+ case "SingleSelectTableColumn":
1214
+ return SingleSelectTableField;
1215
+ case "PhoneNumberTableColumn":
1216
+ return PhoneNumberTableField;
1217
+ case "EmailTableColumn":
1218
+ return EmailTableField;
1219
+ case "URLTableColumn":
1220
+ return URLTableField;
1221
+ case "NumberTableColumn":
1222
+ return NumberTableField;
1223
+ default:
1224
+ return SingleLineTextTableField;
1225
+ }
1226
+ }
1227
+ function Field({
1228
+ tableColumn,
1229
+ tableFormField: {
1230
+ id,
1231
+ label = "",
1232
+ placeholder,
1233
+ required = false,
1234
+ hidden = false,
1235
+ type = "radio",
1236
+ hideLabel = false
1237
+ }
1238
+ }) {
1239
+ const TableColumnField = getTableColumnField(tableColumn);
1240
+ const input = useRef(null);
1241
+ if (!tableColumn)
1242
+ return /* @__PURE__ */ jsx(PlaceholderTableField, {});
1243
+ function validate() {
1244
+ let errorMessage;
1245
+ if (input.current) {
1246
+ const {
1247
+ validity = {}
1248
+ } = input.current;
1249
+ if (validity.valueMissing)
1250
+ errorMessage = `${label} is required.`;
1251
+ if (validity.typeMismatch)
1252
+ errorMessage = getTypeMismatchErrorMessage(tableColumn, label);
1253
+ }
1254
+ return errorMessage;
1255
+ }
1256
+ return /* @__PURE__ */ jsx(Field$1, {
1257
+ name: tableColumn.name,
1258
+ validate,
1259
+ children: ({
1260
+ field,
1261
+ form
1262
+ }) => hidden ? /* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({}, field), {
1263
+ ref: input,
1264
+ type: "hidden"
1265
+ })) : /* @__PURE__ */ jsx(TableColumnField, __spreadProps(__spreadValues({}, field), {
1266
+ type,
1267
+ form,
1268
+ tableColumn,
1269
+ ref: input,
1270
+ id,
1271
+ error: getIn(form.touched, field.name) && getIn(form.errors, field.name),
1272
+ label,
1273
+ placeholder,
1274
+ required,
1275
+ hideLabel
1276
+ }))
1277
+ });
1278
+ }
1279
+ var _g;
1280
+ function _extends() {
1281
+ _extends = Object.assign || function(target) {
1282
+ for (var i = 1; i < arguments.length; i++) {
1283
+ var source = arguments[i];
1284
+ for (var key in source) {
1285
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1286
+ target[key] = source[key];
1287
+ }
1288
+ }
1289
+ }
1290
+ return target;
1291
+ };
1292
+ return _extends.apply(this, arguments);
1293
+ }
1294
+ var SvgSpinner20 = function SvgSpinner202(props) {
1295
+ return /* @__PURE__ */ React.createElement("svg", _extends({
1296
+ xmlns: "http://www.w3.org/2000/svg",
1297
+ width: 20,
1298
+ height: 20
1299
+ }, props), _g || (_g = /* @__PURE__ */ React.createElement("g", {
1300
+ fill: "none",
1301
+ strokeWidth: 2,
1302
+ transform: "translate(1 1)"
1303
+ }, /* @__PURE__ */ React.createElement("circle", {
1304
+ stroke: "currentColor",
1305
+ cx: 9,
1306
+ cy: 9,
1307
+ r: 9,
1308
+ strokeOpacity: 0.4
1309
+ }), /* @__PURE__ */ React.createElement("path", {
1310
+ strokeLinecap: "round",
1311
+ d: "M9 18A9 9 0 0 0 9 0"
1312
+ }))));
1313
+ };
1314
+ const spin = keyframes`
1315
+ from {
1316
+ transform: rotate(0deg);
1317
+ }
1318
+ to {
1319
+ transform: rotate(360deg);
1320
+ }
1321
+ `;
1322
+ const Icon = styled(SvgSpinner20)`
1323
+ display: inline-flex;
1324
+ animation: ${spin} 1s linear infinite;
1325
+ stroke: currentColor;
1326
+ `;
1327
+ function Spinner() {
1328
+ return /* @__PURE__ */ jsx(Icon, {});
1329
+ }
1330
+ function useTableFormFieldRefs(propController, { fieldsCount }) {
1331
+ const [container, setContainer] = useState(null);
1332
+ const [items, setItems] = useState(Array(fieldsCount + 1).fill(null));
1333
+ const isInBuilder = useIsInBuilder();
1334
+ useEffect(() => {
1335
+ if (!isInBuilder)
1336
+ return;
1337
+ let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
1338
+ return () => {
1339
+ cancelAnimationFrame(animationFrameHandle);
1340
+ };
1341
+ function handleAnimationFrameRequest() {
1342
+ if (propController == null)
1343
+ return;
1344
+ if (container != null)
1345
+ propController.tableFormLayoutChange({ layout: getBox(container) });
1346
+ items.map((item, index) => {
1347
+ if (item == null)
1348
+ return;
1349
+ propController.tableFormFieldLayoutChange({ index, layout: getBox(item) });
1350
+ });
1351
+ animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
1352
+ }
1353
+ }, [propController, container, items, isInBuilder]);
1354
+ const itemRefs = useMemo(() => Array.from({ length: fieldsCount + 1 }).map((_, index) => (item) => {
1355
+ setItems((is) => [...is.slice(0, index), item, ...is.slice(index + 1)]);
1356
+ }), [fieldsCount, setItems]);
1357
+ return { container: setContainer, items: itemRefs };
1358
+ }
1359
+ const LOCAL_STORAGE_NAMESPACE = "@@makeswift/components/form";
1360
+ function getSizeFontSize(size) {
1361
+ switch (size) {
1362
+ case Sizes.SMALL:
1363
+ return 12;
1364
+ case Sizes.MEDIUM:
1365
+ return 14;
1366
+ case Sizes.LARGE:
1367
+ return 18;
1368
+ default:
1369
+ throw new Error(`Invalid form size "${size}"`);
1370
+ }
1371
+ }
1372
+ const GridForm = styled.form.withConfig({
1373
+ shouldForwardProp: (prop) => !["size", "width", "margin"].includes(prop)
1374
+ })`
1375
+ display: flex;
1376
+ flex-wrap: wrap;
1377
+ width: 100%;
1378
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
1379
+ font-size: ${getSizeFontSize(size)}px;
1380
+ `)}
1381
+ ${cssMargin()}
1382
+ `;
1383
+ const GridItem = styled.div.withConfig({
1384
+ shouldForwardProp: (prop) => !["grid", "index", "rowGap", "columnGap"].includes(prop)
1385
+ })`
1386
+ align-self: flex-end;
1387
+ flex-direction: column;
1388
+ ${cssGridItem()}
1389
+ `;
1390
+ function getAlignmentMargin(alignment) {
1391
+ switch (alignment) {
1392
+ case Alignments.LEFT:
1393
+ return "0 auto 0 0";
1394
+ case Alignments.RIGHT:
1395
+ return "0 0 0 auto";
1396
+ default:
1397
+ return "0 auto";
1398
+ }
1399
+ }
1400
+ const StyledButton = styled((props) => /* @__PURE__ */ jsx(Button$1, __spreadProps(__spreadValues({}, props), {
1401
+ as: "button"
1402
+ }))).withConfig({
1403
+ shouldForwardProp: (prop) => !["alignment"].includes(prop.toString())
1404
+ })`
1405
+ display: flex;
1406
+ align-items: center;
1407
+ justify-content: center;
1408
+ ${(props) => cssMediaRules([props.size, props.alignment], ([size = Sizes.MEDIUM, alignment = Alignments.CENTER]) => css`
1409
+ min-height: ${getSizeHeight$1(size)}px;
1410
+ max-height: ${getSizeHeight$1(size)}px;
1411
+ margin: ${getAlignmentMargin(alignment)};
1412
+ padding-top: 0;
1413
+ padding-bottom: 0;
1414
+ `)}
1415
+ `;
1416
+ const ErrorContainer = styled.div`
1417
+ padding: 8px 16px;
1418
+ background-color: #f19eb9;
1419
+ border-radius: 4px;
1420
+ margin-top: 16px;
1421
+ `;
1422
+ const IconContainer = styled.div`
1423
+ fill: currentColor;
1424
+ `;
1425
+ const ErrorMessage = styled.p`
1426
+ font-size: 12px;
1427
+ margin: 8px 0;
1428
+ color: rgba(127, 0, 0, 0.95);
1429
+ `;
1430
+ function getTableColumnDefaultValue(tableColumn) {
1431
+ switch (tableColumn.__typename) {
1432
+ case "CheckboxTableColumn":
1433
+ return false;
1434
+ case "MultipleSelectTableColumn":
1435
+ return [];
1436
+ case "SingleLineTextTableColumn":
1437
+ case "LongTextTableColumn":
1438
+ case "SingleSelectTableColumn":
1439
+ case "PhoneNumberTableColumn":
1440
+ case "EmailTableColumn":
1441
+ case "URLTableColumn":
1442
+ case "NumberTableColumn":
1443
+ default:
1444
+ return "";
1445
+ }
1446
+ }
1447
+ const CREATE_TABLE_RECORD = gql`
1448
+ mutation CreateTableRecord($input: CreateTableRecordInput!) {
1449
+ createTableRecord(input: $input) {
1450
+ tableRecord {
1451
+ id
1452
+ }
1453
+ }
1454
+ }
1455
+ `;
1456
+ const Form = forwardRef(function Form2({
1457
+ id,
1458
+ tableId,
1459
+ fields: fieldsProp,
1460
+ submitLabel = "Submit",
1461
+ submitLink,
1462
+ shape,
1463
+ size,
1464
+ contrast,
1465
+ brandColor,
1466
+ gap,
1467
+ width,
1468
+ margin,
1469
+ submitTextStyle,
1470
+ submitVariant,
1471
+ submitTextColor,
1472
+ submitWidth,
1473
+ submitAlignment,
1474
+ labelTextStyle,
1475
+ labelTextColor
1476
+ }, ref) {
1477
+ const fields = useMemo(() => {
1478
+ var _a;
1479
+ return (_a = fieldsProp == null ? void 0 : fieldsProp.fields) != null ? _a : [];
1480
+ }, [fieldsProp]);
1481
+ const grid = useMemo(() => {
1482
+ var _a;
1483
+ return (_a = fieldsProp == null ? void 0 : fieldsProp.grid) != null ? _a : [];
1484
+ }, [fieldsProp]);
1485
+ const {
1486
+ data: {
1487
+ table
1488
+ } = {}
1489
+ } = useQuery(TABLE_BY_ID, {
1490
+ skip: tableId == null,
1491
+ variables: {
1492
+ id: tableId
1493
+ }
1494
+ });
1495
+ const [createTableRecord] = useMutation(CREATE_TABLE_RECORD);
1496
+ const [refEl, setRefEl] = useState(null);
1497
+ const [propControllers, setPropControllers] = useState(null);
1498
+ const [initialValues, setInitialValues] = useState(() => fields.reduce((acc, formField) => {
1499
+ const tableColumn = table && table.columns.find((field) => field.id === formField.tableColumnId);
1500
+ const defaultValue = formField ? formField.defaultValue : null;
1501
+ if (tableColumn) {
1502
+ acc[tableColumn.name] = defaultValue == null ? getTableColumnDefaultValue(tableColumn) : defaultValue;
1503
+ }
1504
+ return acc;
1505
+ }, {}));
1506
+ const controller = propControllers == null ? void 0 : propControllers.fields;
1507
+ const {
1508
+ container,
1509
+ items
1510
+ } = useTableFormFieldRefs(controller, {
1511
+ fieldsCount: fields.length
1512
+ });
1513
+ const [isDone, setIsDone] = useState(false);
1514
+ const linkRef = useRef(null);
1515
+ useImperativeHandle(ref, () => ({
1516
+ getBoxModel() {
1517
+ return refEl instanceof Element ? getBox(refEl) : null;
1518
+ },
1519
+ setPropControllers
1520
+ }), [refEl, setPropControllers]);
1521
+ useEffect(() => {
1522
+ container(refEl);
1523
+ }, [container, refEl]);
1524
+ useEffect(() => {
1525
+ if (!isDone)
1526
+ return;
1527
+ let timeoutId = setTimeout(() => setIsDone(false), 2500);
1528
+ return () => clearTimeout(timeoutId);
1529
+ }, [isDone]);
1530
+ function getTableColumn({
1531
+ tableColumnId
1532
+ }) {
1533
+ return table && table.columns.find((field) => tableColumnId === field.id);
1534
+ }
1535
+ async function handleSubmit(values, {
1536
+ setSubmitting,
1537
+ resetForm,
1538
+ setStatus
1539
+ }) {
1540
+ if (table) {
1541
+ const columns = [];
1542
+ fields.forEach((field) => {
1543
+ const tableColumn = getTableColumn(field);
1544
+ if (tableColumn) {
1545
+ const data = values[tableColumn.name];
1546
+ if (data) {
1547
+ columns.push({
1548
+ columnId: field.tableColumnId,
1549
+ data
1550
+ });
1551
+ if (field.autofill) {
1552
+ localStorage.setItem(`${LOCAL_STORAGE_NAMESPACE}/${tableColumn.name}`, JSON.stringify(data));
1553
+ }
1554
+ }
1555
+ }
1556
+ });
1557
+ try {
1558
+ await createTableRecord({
1559
+ variables: {
1560
+ input: {
1561
+ data: {
1562
+ tableId: table.id,
1563
+ columns
1564
+ }
1565
+ }
1566
+ }
1567
+ });
1568
+ setIsDone(true);
1569
+ setInitialValues((prev) => fields.reduce((acc, field) => {
1570
+ const tableColumn = getTableColumn(field);
1571
+ if (tableColumn) {
1572
+ const data = values[tableColumn.name];
1573
+ if (data && field.autofill)
1574
+ return __spreadProps(__spreadValues({}, acc), {
1575
+ [tableColumn.name]: data
1576
+ });
1577
+ }
1578
+ return acc;
1579
+ }, __spreadValues({}, prev)));
1580
+ resetForm();
1581
+ if (linkRef.current != null)
1582
+ linkRef.current.click();
1583
+ } catch (error) {
1584
+ setStatus({
1585
+ error: "An unexpected error has occurred, please try again later"
1586
+ });
1587
+ } finally {
1588
+ setSubmitting(false);
1589
+ }
1590
+ }
1591
+ }
1592
+ useEffect(() => {
1593
+ setInitialValues((prev) => fields.reduce((acc, formField) => {
1594
+ const tableColumn = table && table.columns.find((field) => field.id === formField.tableColumnId);
1595
+ if (tableColumn && formField.autofill) {
1596
+ const storedValue = localStorage.getItem(`${LOCAL_STORAGE_NAMESPACE}/${tableColumn.name}`);
1597
+ if (storedValue) {
1598
+ try {
1599
+ acc[tableColumn.name] = JSON.parse(storedValue);
1600
+ } catch (e) {
1601
+ }
1602
+ }
1603
+ }
1604
+ return acc;
1605
+ }, __spreadValues({}, prev)));
1606
+ }, [fields, table]);
1607
+ return /* @__PURE__ */ jsx(Provider, {
1608
+ value: {
1609
+ shape,
1610
+ size,
1611
+ contrast,
1612
+ brandColor,
1613
+ labelTextStyle,
1614
+ labelTextColor
1615
+ },
1616
+ children: tableId == null ? /* @__PURE__ */ jsx(Placeholder, {
1617
+ ref: setRefEl,
1618
+ className: cx(width),
1619
+ margin
1620
+ }) : /* @__PURE__ */ jsx(Fragment, {
1621
+ children: /* @__PURE__ */ jsx(Formik, {
1622
+ onSubmit: handleSubmit,
1623
+ initialValues,
1624
+ initialStatus: {
1625
+ error: null
1626
+ },
1627
+ enableReinitialize: true,
1628
+ children: (formik) => {
1629
+ const error = formik.status && formik.status.error;
1630
+ const errors = fields.map((field) => {
1631
+ const tableColumn = getTableColumn(field);
1632
+ return tableColumn && getIn(formik.touched, tableColumn.name) && getIn(formik.errors, tableColumn.name);
1633
+ }).filter((message) => typeof message === "string");
1634
+ return /* @__PURE__ */ jsxs(Fragment, {
1635
+ children: [/* @__PURE__ */ jsxs(GridForm, {
1636
+ ref: setRefEl,
1637
+ id,
1638
+ className: cx(width),
1639
+ margin,
1640
+ size,
1641
+ onSubmit: formik.handleSubmit,
1642
+ onReset: formik.handleReset,
1643
+ noValidate: true,
1644
+ children: [fields.map((field, index) => {
1645
+ const tableColumn = getTableColumn(field);
1646
+ return /* @__PURE__ */ jsx(GridItem, {
1647
+ ref: items[index],
1648
+ grid,
1649
+ index,
1650
+ rowGap: gap,
1651
+ columnGap: gap,
1652
+ children: /* @__PURE__ */ jsx(Field, {
1653
+ tableColumn,
1654
+ tableFormField: field
1655
+ })
1656
+ }, field.id);
1657
+ }), /* @__PURE__ */ jsxs(GridItem, {
1658
+ ref: items[fields.length],
1659
+ grid,
1660
+ index: fields.length,
1661
+ rowGap: gap,
1662
+ columnGap: gap,
1663
+ children: [/* @__PURE__ */ jsx(StyledButton, {
1664
+ type: "submit",
1665
+ disabled: formik.isSubmitting || isDone,
1666
+ shape,
1667
+ size,
1668
+ color: brandColor,
1669
+ variant: submitVariant,
1670
+ textColor: submitTextColor,
1671
+ width: submitWidth,
1672
+ alignment: submitAlignment,
1673
+ textStyle: submitTextStyle,
1674
+ children: formik.isSubmitting ? /* @__PURE__ */ jsx(Spinner, {}) : isDone ? /* @__PURE__ */ jsx(IconContainer, {
1675
+ children: /* @__PURE__ */ jsx(SvgCheck12, {})
1676
+ }) : submitLabel
1677
+ }), (errors.length > 0 || error) && /* @__PURE__ */ jsxs(ErrorContainer, {
1678
+ children: [errors.map((message) => /* @__PURE__ */ jsx(ErrorMessage, {
1679
+ children: message
1680
+ }, message)), error != null && /* @__PURE__ */ jsx(ErrorMessage, {
1681
+ children: error
1682
+ })]
1683
+ })]
1684
+ })]
1685
+ }), submitLink != null && /* @__PURE__ */ jsx(Link, {
1686
+ ref: linkRef,
1687
+ hidden: true,
1688
+ link: submitLink
1689
+ })]
1690
+ });
1691
+ }
1692
+ })
1693
+ })
1694
+ });
1695
+ });
1696
+ export { Form as default };
1697
+ //# sourceMappingURL=Form.es.js.map