@makeswift/runtime 0.0.22 → 0.1.0-next.0

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