@makeswift/runtime 0.0.0-ef05bba → 0.0.0-f750971

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 (163) hide show
  1. package/builder.js +1 -0
  2. package/dist/actions.cjs.js +29 -2
  3. package/dist/actions.cjs.js.map +1 -1
  4. package/dist/actions.es.js +25 -2
  5. package/dist/actions.es.js.map +1 -1
  6. package/dist/api.cjs.js +1 -2
  7. package/dist/api.cjs.js.map +1 -1
  8. package/dist/box-model.cjs.js +1 -2
  9. package/dist/box-model.cjs.js.map +1 -1
  10. package/dist/box-models.cjs.js +2 -0
  11. package/dist/box-models.cjs.js.map +1 -1
  12. package/dist/box-models.es.js +2 -0
  13. package/dist/box-models.es.js.map +1 -1
  14. package/dist/builder.cjs.js +9 -0
  15. package/dist/builder.cjs.js.map +1 -0
  16. package/dist/builder.es.js +3 -0
  17. package/dist/builder.es.js.map +1 -0
  18. package/dist/components.cjs.js +4 -2
  19. package/dist/components.cjs.js.map +1 -1
  20. package/dist/components.es.js +3 -1
  21. package/dist/components.es.js.map +1 -1
  22. package/dist/constants.cjs.js +96 -1
  23. package/dist/constants.cjs.js.map +1 -1
  24. package/dist/constants.es.js +96 -1
  25. package/dist/constants.es.js.map +1 -1
  26. package/dist/control-serialization.cjs.js +147 -0
  27. package/dist/control-serialization.cjs.js.map +1 -0
  28. package/dist/control-serialization.es.js +143 -0
  29. package/dist/control-serialization.es.js.map +1 -0
  30. package/dist/descriptors.cjs.js +9 -3
  31. package/dist/descriptors.cjs.js.map +1 -1
  32. package/dist/descriptors.es.js +8 -4
  33. package/dist/descriptors.es.js.map +1 -1
  34. package/dist/instances.cjs.js +17 -0
  35. package/dist/instances.cjs.js.map +1 -1
  36. package/dist/instances.es.js +17 -1
  37. package/dist/instances.es.js.map +1 -1
  38. package/dist/main.cjs.js +9 -2
  39. package/dist/main.cjs.js.map +1 -1
  40. package/dist/main.es.js +5 -1
  41. package/dist/main.es.js.map +1 -1
  42. package/dist/next.cjs.js +11 -8
  43. package/dist/next.cjs.js.map +1 -1
  44. package/dist/next.es.js +11 -7
  45. package/dist/next.es.js.map +1 -1
  46. package/dist/prop-controllers.cjs.js +2 -2
  47. package/dist/prop-controllers.es.js +1 -1
  48. package/dist/react-builder-preview.cjs.js +33 -39
  49. package/dist/react-builder-preview.cjs.js.map +1 -1
  50. package/dist/react-builder-preview.es.js +31 -37
  51. package/dist/react-builder-preview.es.js.map +1 -1
  52. package/dist/react-page.cjs.js +262 -0
  53. package/dist/react-page.cjs.js.map +1 -0
  54. package/dist/react-page.es.js +241 -0
  55. package/dist/react-page.es.js.map +1 -0
  56. package/dist/react.cjs.js +6 -3
  57. package/dist/react.cjs.js.map +1 -1
  58. package/dist/react.cjs2.js +2078 -409
  59. package/dist/react.cjs2.js.map +1 -1
  60. package/dist/react.es.js +3 -1
  61. package/dist/react.es.js.map +1 -1
  62. package/dist/react.es2.js +2077 -401
  63. package/dist/react.es2.js.map +1 -1
  64. package/dist/types/api/constants.d.ts.map +1 -1
  65. package/dist/types/api/generated/graphql.d.ts +59 -0
  66. package/dist/types/api/generated/graphql.d.ts.map +1 -1
  67. package/dist/types/api/react.d.ts +3 -1
  68. package/dist/types/api/react.d.ts.map +1 -1
  69. package/dist/types/api/types.d.ts +2 -2
  70. package/dist/types/api/types.d.ts.map +1 -1
  71. package/dist/types/builder/index.d.ts +2 -0
  72. package/dist/types/builder/index.d.ts.map +1 -0
  73. package/dist/types/builder/serialization/control-serialization.d.ts +78 -0
  74. package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -0
  75. package/dist/types/builder/serialization/function-serialization.d.ts +11 -0
  76. package/dist/types/builder/serialization/function-serialization.d.ts.map +1 -0
  77. package/dist/types/builder/serialization/index.d.ts +3 -0
  78. package/dist/types/builder/serialization/index.d.ts.map +1 -0
  79. package/dist/types/components/builtin/Form/Form.d.ts +41 -0
  80. package/dist/types/components/builtin/Form/Form.d.ts.map +1 -0
  81. package/dist/types/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +15 -0
  82. package/dist/types/components/builtin/Form/components/Field/components/Checkbox/index.d.ts.map +1 -0
  83. package/dist/types/components/builtin/Form/components/Field/components/CheckboxTableField/index.d.ts +15 -0
  84. package/dist/types/components/builtin/Form/components/Field/components/CheckboxTableField/index.d.ts.map +1 -0
  85. package/dist/types/components/builtin/Form/components/Field/components/EmailTableField/index.d.ts +11 -0
  86. package/dist/types/components/builtin/Form/components/Field/components/EmailTableField/index.d.ts.map +1 -0
  87. package/dist/types/components/builtin/Form/components/Field/components/Input/index.d.ts +14 -0
  88. package/dist/types/components/builtin/Form/components/Field/components/Input/index.d.ts.map +1 -0
  89. package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts +16 -0
  90. package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts.map +1 -0
  91. package/dist/types/components/builtin/Form/components/Field/components/LongTextTableField/index.d.ts +10 -0
  92. package/dist/types/components/builtin/Form/components/Field/components/LongTextTableField/index.d.ts.map +1 -0
  93. package/dist/types/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.d.ts +23 -0
  94. package/dist/types/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.d.ts.map +1 -0
  95. package/dist/types/components/builtin/Form/components/Field/components/NumberTableField/index.d.ts +11 -0
  96. package/dist/types/components/builtin/Form/components/Field/components/NumberTableField/index.d.ts.map +1 -0
  97. package/dist/types/components/builtin/Form/components/Field/components/PhoneNumberTableField/index.d.ts +11 -0
  98. package/dist/types/components/builtin/Form/components/Field/components/PhoneNumberTableField/index.d.ts.map +1 -0
  99. package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts +3 -0
  100. package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -0
  101. package/dist/types/components/builtin/Form/components/Field/components/RadioButton/index.d.ts +17 -0
  102. package/dist/types/components/builtin/Form/components/Field/components/RadioButton/index.d.ts.map +1 -0
  103. package/dist/types/components/builtin/Form/components/Field/components/SingleLineTextTableField/index.d.ts +11 -0
  104. package/dist/types/components/builtin/Form/components/Field/components/SingleLineTextTableField/index.d.ts.map +1 -0
  105. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.d.ts +23 -0
  106. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnRadioButtonGroup/index.d.ts.map +1 -0
  107. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.d.ts +19 -0
  108. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/components/TableColumnSingleSelect/index.d.ts.map +1 -0
  109. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/index.d.ts +24 -0
  110. package/dist/types/components/builtin/Form/components/Field/components/SingleSelectTableField/index.d.ts.map +1 -0
  111. package/dist/types/components/builtin/Form/components/Field/components/TextArea/index.d.ts +13 -0
  112. package/dist/types/components/builtin/Form/components/Field/components/TextArea/index.d.ts.map +1 -0
  113. package/dist/types/components/builtin/Form/components/Field/components/URLTableField/index.d.ts +11 -0
  114. package/dist/types/components/builtin/Form/components/Field/components/URLTableField/index.d.ts.map +1 -0
  115. package/dist/types/components/builtin/Form/components/Field/index.d.ts +19 -0
  116. package/dist/types/components/builtin/Form/components/Field/index.d.ts.map +1 -0
  117. package/dist/types/components/builtin/Form/components/Field/services/cssField.d.ts +11 -0
  118. package/dist/types/components/builtin/Form/components/Field/services/cssField.d.ts.map +1 -0
  119. package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts +9 -0
  120. package/dist/types/components/builtin/Form/components/Placeholder/index.d.ts.map +1 -0
  121. package/dist/types/components/builtin/Form/components/Spinner/index.d.ts +3 -0
  122. package/dist/types/components/builtin/Form/components/Spinner/index.d.ts.map +1 -0
  123. package/dist/types/components/builtin/Form/context/FormContext.d.ts +32 -0
  124. package/dist/types/components/builtin/Form/context/FormContext.d.ts.map +1 -0
  125. package/dist/types/components/builtin/Form/index.d.ts +2 -0
  126. package/dist/types/components/builtin/Form/index.d.ts.map +1 -0
  127. package/dist/types/components/builtin/index.d.ts +1 -0
  128. package/dist/types/components/builtin/index.d.ts.map +1 -1
  129. package/dist/types/components/hooks/index.d.ts +1 -0
  130. package/dist/types/components/hooks/index.d.ts.map +1 -1
  131. package/dist/types/components/hooks/useTable.d.ts +66 -0
  132. package/dist/types/components/hooks/useTable.d.ts.map +1 -0
  133. package/dist/types/components/hooks/useTableFormFieldRefs.d.ts +8 -0
  134. package/dist/types/components/hooks/useTableFormFieldRefs.d.ts.map +1 -0
  135. package/dist/types/components/utils/queries.d.ts +1 -0
  136. package/dist/types/components/utils/queries.d.ts.map +1 -1
  137. package/dist/types/components/utils/types.d.ts +1 -2
  138. package/dist/types/components/utils/types.d.ts.map +1 -1
  139. package/dist/types/index.d.ts +2 -1
  140. package/dist/types/index.d.ts.map +1 -1
  141. package/dist/types/next.d.ts +4 -3
  142. package/dist/types/next.d.ts.map +1 -1
  143. package/dist/types/prop-controllers/descriptors.d.ts +31 -12
  144. package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
  145. package/dist/types/prop-controllers/index.d.ts +3 -3
  146. package/dist/types/prop-controllers/index.d.ts.map +1 -1
  147. package/dist/types/prop-controllers/instances.d.ts +36 -4
  148. package/dist/types/prop-controllers/instances.d.ts.map +1 -1
  149. package/dist/types/react.d.ts +1 -1
  150. package/dist/types/react.d.ts.map +1 -1
  151. package/dist/types/runtimes/react.d.ts +12 -5
  152. package/dist/types/runtimes/react.d.ts.map +1 -1
  153. package/dist/types/state/actions.d.ts +47 -1
  154. package/dist/types/state/actions.d.ts.map +1 -1
  155. package/dist/types/state/modules/box-models.d.ts.map +1 -1
  156. package/dist/types/state/modules/read-only-documents.d.ts +8 -4
  157. package/dist/types/state/modules/read-only-documents.d.ts.map +1 -1
  158. package/dist/types/state/modules/read-write-documents.d.ts +1 -1
  159. package/dist/types/state/modules/read-write-documents.d.ts.map +1 -1
  160. package/dist/types/state/react-builder-preview.d.ts.map +1 -1
  161. package/dist/types/state/react-page.d.ts +3 -3
  162. package/dist/types/state/react-page.d.ts.map +1 -1
  163. package/package.json +17 -5
package/dist/react.es2.js CHANGED
@@ -32,236 +32,29 @@ var __objRest = (source, exclude) => {
32
32
  import * as React from "react";
33
33
  import { forwardRef, createContext, useContext, useMemo, useState, useLayoutEffect, useCallback, useEffect, useRef, useImperativeHandle, Children, createElement, Fragment as Fragment$1, memo } from "react";
34
34
  import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
35
- import { gql, useQuery as useQuery$1, ApolloClient, InMemoryCache } from "@apollo/client";
36
- import { combineReducers, createStore, applyMiddleware } from "redux";
37
- import thunk from "redux-thunk";
38
- import { A as ActionTypes, r as registerComponentHandleEffect, e as mountComponentEffect, f as registerComponentEffect, g as registerReactComponentEffect } from "./actions.es.js";
39
- import { T as Types, E as ElementID, B as Backgrounds$1, W as Width, R as ResponsiveIconRadioGroup, M as Margin, P as Padding, a as Border, b as BorderRadius, S as Shadows, G as GapY, c as GapX, e as ResponsiveSelect, f as ResponsiveNumber, C as Checkbox, g as Grid$2, h as TextInput, L as Link$1, i as ResponsiveColor, j as TextStyle, I as Image$1, k as ResponsiveOpacity, l as Images, N as Number$1, D as Date$1, F as Font, m as ResponsiveLength, n as TextArea, o as NavigationLinks, p as SocialLinks$1, q as RichText } from "./descriptors.es.js";
35
+ import { gql, useQuery as useQuery$1, useMutation as useMutation$1, ApolloClient, InMemoryCache } from "@apollo/client";
36
+ import { g as getIsInBuilder, a as configureStore, b as getElementId, d as getReactComponent, e as getDocument, i as isElementReference } from "./react-page.es.js";
37
+ import { f as registerComponentHandleEffect, g as mountComponentEffect, h as registerComponentEffect, j as registerReactComponentEffect } from "./actions.es.js";
40
38
  import styled, { css, keyframes, createGlobalStyle } from "styled-components";
41
39
  import { useReducedMotion, useAnimation, motion } from "framer-motion";
42
40
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
43
41
  import { p as parse, c as createBox, g as getBox } from "./box-models.es.js";
44
42
  import NextImage from "next/image";
45
43
  import ReactPlayer from "react-player";
44
+ import { E as ElementID, B as Backgrounds$1, W as Width, R as ResponsiveIconRadioGroup, M as Margin, P as Padding, a as Border, b as BorderRadius, S as Shadows, G as GapY, c as GapX, e as ResponsiveSelect, f as ResponsiveNumber, C as Checkbox$1, g as Grid$2, h as TextInput, L as Link$1, i as ResponsiveColor, j as TextStyle, I as Image$1, k as ResponsiveOpacity, l as Images, N as Number$1, D as Date$1, F as Font, m as ResponsiveLength, n as TextArea$1, o as Table, p as TableFormFields, q as NavigationLinks, r as SocialLinks$1, s as RichText } from "./descriptors.es.js";
46
45
  import ColorHelper from "color";
47
46
  import scrollIntoView from "scroll-into-view-if-needed";
48
47
  import NextLink from "next/link";
49
48
  import { useGesture } from "react-use-gesture";
50
49
  import { wrap } from "@popmotion/popcorn";
51
50
  import uuid from "uuid/v4";
51
+ import { Field as Field$1, getIn, Formik } from "formik";
52
52
  import { normalize } from "polished";
53
53
  import { Value } from "slate";
54
54
  import Hotkeys from "slate-hotkeys";
55
55
  import ipsum from "corporate-ipsum";
56
56
  import { Editor } from "slate-react";
57
57
  import Lists from "@convertkit/slate-lists";
58
- function isElementReference(element) {
59
- return !("props" in element);
60
- }
61
- function createDocument(rootElement) {
62
- return { rootElement };
63
- }
64
- function getInitialState$3({
65
- rootElements = /* @__PURE__ */ new Map()
66
- } = {}) {
67
- const initialState = /* @__PURE__ */ new Map();
68
- rootElements.forEach((rootElement, elementKey) => {
69
- initialState.set(elementKey, createDocument(rootElement));
70
- });
71
- return initialState;
72
- }
73
- function getDocuments(state) {
74
- return state;
75
- }
76
- function getDocument(state, documentKey) {
77
- var _a;
78
- return (_a = getDocuments(state).get(documentKey)) != null ? _a : null;
79
- }
80
- function getDocumentRootElement$1(state, documentKey) {
81
- var _a, _b;
82
- return (_b = (_a = getDocument(state, documentKey)) == null ? void 0 : _a.rootElement) != null ? _b : null;
83
- }
84
- function reducer$4(state = getInitialState$3(), _action) {
85
- return state;
86
- }
87
- function getInitialState$2({
88
- reactComponents = /* @__PURE__ */ new Map()
89
- } = {}) {
90
- return reactComponents;
91
- }
92
- function getReactComponents(state) {
93
- return state;
94
- }
95
- function getReactComponent$1(state, type) {
96
- var _a;
97
- return (_a = getReactComponents(state).get(type)) != null ? _a : null;
98
- }
99
- function reducer$3(state = getInitialState$2(), action) {
100
- switch (action.type) {
101
- case ActionTypes.REGISTER_REACT_COMPONENT:
102
- return new Map(state).set(action.payload.type, action.payload.component);
103
- case ActionTypes.UNREGISTER_REACT_COMPONENT: {
104
- const nextState = new Map(state);
105
- const deleted = nextState.delete(action.payload.type);
106
- return deleted ? nextState : state;
107
- }
108
- default:
109
- return state;
110
- }
111
- }
112
- function getInitialState$1({
113
- componentsMeta = /* @__PURE__ */ new Map()
114
- } = {}) {
115
- return componentsMeta;
116
- }
117
- function getComponentsMeta(state) {
118
- return state;
119
- }
120
- function reducer$2(state = getInitialState$1(), action) {
121
- switch (action.type) {
122
- case ActionTypes.REGISTER_COMPONENT:
123
- return new Map(state).set(action.payload.type, action.payload.meta);
124
- case ActionTypes.UNREGISTER_COMPONENT: {
125
- const nextState = new Map(state);
126
- const deleted = nextState.delete(action.payload.type);
127
- return deleted ? nextState : state;
128
- }
129
- default:
130
- return state;
131
- }
132
- }
133
- function getInitialState({
134
- propControllerDescriptors = /* @__PURE__ */ new Map()
135
- } = {}) {
136
- return propControllerDescriptors;
137
- }
138
- function getPropControllerDescriptors$1(state) {
139
- return state;
140
- }
141
- function getComponentPropControllerDescriptors$1(state, componentType) {
142
- var _a;
143
- return (_a = getPropControllerDescriptors$1(state).get(componentType)) != null ? _a : null;
144
- }
145
- function reducer$1(state = getInitialState(), action) {
146
- switch (action.type) {
147
- case ActionTypes.REGISTER_COMPONENT:
148
- return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors);
149
- case ActionTypes.UNREGISTER_COMPONENT: {
150
- const nextState = new Map(state);
151
- const deleted = nextState.delete(action.payload.type);
152
- return deleted ? nextState : state;
153
- }
154
- default:
155
- return state;
156
- }
157
- }
158
- function getElementChildren(descriptor, prop) {
159
- if (prop == null)
160
- return [];
161
- switch (descriptor.type) {
162
- case Types.Grid:
163
- return prop.elements;
164
- default:
165
- return [];
166
- }
167
- }
168
- function getElementId$1(descriptor, prop) {
169
- if (prop == null)
170
- return null;
171
- switch (descriptor.type) {
172
- case Types.ElementID:
173
- return prop;
174
- default:
175
- return null;
176
- }
177
- }
178
- const reducer = combineReducers({
179
- documents: reducer$4,
180
- reactComponents: reducer$3,
181
- componentsMeta: reducer$2,
182
- propControllers: reducer$1,
183
- isInBuilder: (_state = false, _action) => false
184
- });
185
- function getDocumentsStateSlice(state) {
186
- return state.documents;
187
- }
188
- function getDocumentRootElement(state, documentKey) {
189
- return getDocumentRootElement$1(getDocumentsStateSlice(state), documentKey);
190
- }
191
- function getReactComponentsStateSlice(state) {
192
- return state.reactComponents;
193
- }
194
- function getReactComponent(state, type) {
195
- return getReactComponent$1(getReactComponentsStateSlice(state), type);
196
- }
197
- function getPropControllersStateSlice(state) {
198
- return state.propControllers;
199
- }
200
- function getPropControllerDescriptors(state) {
201
- return getPropControllerDescriptors$1(getPropControllersStateSlice(state));
202
- }
203
- function getComponentPropControllerDescriptors(state, componentType) {
204
- return getComponentPropControllerDescriptors$1(getPropControllersStateSlice(state), componentType);
205
- }
206
- function normalizeElement(element, descriptors) {
207
- const elements = /* @__PURE__ */ new Map();
208
- const remaining = [element];
209
- let current;
210
- while (current = remaining.pop()) {
211
- elements.set(current.key, current);
212
- if (isElementReference(current))
213
- continue;
214
- const elementDescriptors = descriptors.get(element.type);
215
- if (elementDescriptors == null)
216
- continue;
217
- const parent = current;
218
- const children = Object.entries(elementDescriptors).reduce((acc, [propName, descriptor]) => {
219
- return [...acc, ...getElementChildren(descriptor, parent.props[propName])];
220
- }, []);
221
- remaining.push(...children);
222
- }
223
- return elements;
224
- }
225
- function getDocumentElements(state, documentKey) {
226
- const rootElement = getDocumentRootElement(state, documentKey);
227
- const descriptors = getPropControllerDescriptors(state);
228
- if (rootElement == null)
229
- return /* @__PURE__ */ new Map();
230
- return normalizeElement(rootElement, descriptors);
231
- }
232
- function getElement(state, documentKey, elementKey) {
233
- var _a;
234
- return (_a = getDocumentElements(state, documentKey).get(elementKey)) != null ? _a : null;
235
- }
236
- function getElementPropControllerDescriptors(state, documentKey, elementKey) {
237
- const element = getElement(state, documentKey, elementKey);
238
- if (element == null || isElementReference(element))
239
- return null;
240
- return getComponentPropControllerDescriptors(state, element.type);
241
- }
242
- function getElementId(state, documentKey, elementKey) {
243
- const element = getElement(state, documentKey, elementKey);
244
- if (element == null || isElementReference(element))
245
- return null;
246
- const descriptors = getComponentPropControllerDescriptors(state, element.type);
247
- if (descriptors == null)
248
- return null;
249
- const elementId = Object.entries(descriptors).reduce((acc, [propName, descriptor]) => {
250
- if (acc != null)
251
- return acc;
252
- return getElementId$1(descriptor, element.props[propName]);
253
- }, null);
254
- return elementId;
255
- }
256
- function getIsInBuilder(state) {
257
- return state.isInBuilder;
258
- }
259
- function configureStore({
260
- rootElements,
261
- preloadedState
262
- } = {}) {
263
- return createStore(reducer, __spreadProps(__spreadValues({}, preloadedState), { documents: getInitialState$3({ rootElements }) }), applyMiddleware(thunk));
264
- }
265
58
  const PlaceholderBase$1 = styled.div`
266
59
  width: 100%;
267
60
  background: rgba(161, 168, 194, 0.18);
@@ -271,7 +64,7 @@ const PlaceholderBase$1 = styled.div`
271
64
  hide
272
65
  }) => hide === true ? "hidden" : "initial"};
273
66
  `;
274
- var Placeholder$1 = forwardRef(function Placeholder(_a, ref) {
67
+ var Placeholder$2 = forwardRef(function Placeholder(_a, ref) {
275
68
  var _b = _a, {
276
69
  hide = false
277
70
  } = _b, restOfProps = __objRest(_b, [
@@ -385,21 +178,51 @@ const TYPOGRAPHIES_BY_ID = gql`
385
178
 
386
179
  ${TYPOGRAPHY_FRAGMENT}
387
180
  `;
181
+ const TABLE_BY_ID = gql`
182
+ query TableById($id: ID!) {
183
+ table(id: $id) {
184
+ id
185
+ name
186
+ columns {
187
+ id
188
+ name
189
+ ... on MultipleSelectTableColumn {
190
+ options {
191
+ id
192
+ name
193
+ }
194
+ }
195
+ ... on SingleSelectTableColumn {
196
+ options {
197
+ id
198
+ name
199
+ }
200
+ }
201
+ }
202
+ }
203
+ }
204
+ `;
388
205
  function isNonNullable(value) {
389
206
  return value != null;
390
207
  }
391
- const Context$1 = createContext(void 0);
208
+ const Context$2 = createContext(void 0);
392
209
  function useQuery(query, options) {
393
- const client = useContext(Context$1);
210
+ const client = useContext(Context$2);
394
211
  return useQuery$1(query, __spreadValues({
395
212
  client
396
213
  }, options));
397
214
  }
215
+ function useMutation(mutation, options) {
216
+ const client = useContext(Context$2);
217
+ return useMutation$1(mutation, __spreadValues({
218
+ client
219
+ }, options));
220
+ }
398
221
  function ApolloProvider({
399
222
  client,
400
223
  children
401
224
  }) {
402
- return /* @__PURE__ */ jsx(Context$1.Provider, {
225
+ return /* @__PURE__ */ jsx(Context$2.Provider, {
403
226
  value: client,
404
227
  children
405
228
  });
@@ -612,8 +435,8 @@ function shallowMerge(a, b) {
612
435
  }
613
436
  const DEVICES = [
614
437
  { id: "desktop", minWidth: 769 },
615
- { id: "tablet", minWidth: 476, maxWidth: 768 },
616
- { id: "mobile", maxWidth: 475 }
438
+ { id: "tablet", minWidth: 576, maxWidth: 768 },
439
+ { id: "mobile", maxWidth: 575 }
617
440
  ];
618
441
  const getDevice = (deviceId) => {
619
442
  const device = DEVICES.find(({ id }) => id === deviceId);
@@ -687,6 +510,12 @@ function usePage(pageId) {
687
510
  const { pagePathnamesById: [page] = [] } = data;
688
511
  return page;
689
512
  }
513
+ function useTable(tableId) {
514
+ return useQuery(TABLE_BY_ID, {
515
+ skip: tableId == null,
516
+ variables: { id: tableId }
517
+ });
518
+ }
690
519
  const defaultExitedProps = {
691
520
  opacity: 0,
692
521
  x: 0,
@@ -1157,8 +986,8 @@ function getScrollParent(element) {
1157
986
  return element;
1158
987
  return getScrollParent(parentElement);
1159
988
  }
1160
- function Parallax(_g) {
1161
- var _h = _g, {
989
+ function Parallax(_g2) {
990
+ var _h = _g2, {
1162
991
  strength,
1163
992
  children
1164
993
  } = _h, rest = __objRest(_h, [
@@ -1244,7 +1073,7 @@ function Parallax(_g) {
1244
1073
  children: children(getProps)
1245
1074
  }));
1246
1075
  }
1247
- const Container$8 = styled.div`
1076
+ const Container$c = styled.div`
1248
1077
  position: absolute;
1249
1078
  top: 0;
1250
1079
  left: 0;
@@ -1298,7 +1127,7 @@ function BackgroundVideo({
1298
1127
  }, [aspectRatio, zoom]);
1299
1128
  if (!ReactPlayer.canPlay(url))
1300
1129
  return /* @__PURE__ */ jsx(Fragment, {});
1301
- return /* @__PURE__ */ jsxs(Container$8, {
1130
+ return /* @__PURE__ */ jsxs(Container$c, {
1302
1131
  ref: container,
1303
1132
  children: [container.current && /* @__PURE__ */ jsx(ReactPlayer, {
1304
1133
  url,
@@ -1377,10 +1206,10 @@ const AbsoluteFill = styled.div`
1377
1206
  right: 0;
1378
1207
  bottom: 0;
1379
1208
  `;
1380
- const Container$7 = styled(AbsoluteFill)`
1209
+ const Container$b = styled(AbsoluteFill)`
1381
1210
  border-radius: inherit;
1382
1211
  `;
1383
- const BackgroundsContainer$1 = styled(Container$7)`
1212
+ const BackgroundsContainer$1 = styled(Container$b)`
1384
1213
  overflow: hidden;
1385
1214
  ${(p) => cssMediaRules([p.visibility], ([visibility]) => css`
1386
1215
  display: ${visibility === true ? "block" : "none"};
@@ -1404,7 +1233,7 @@ function Backgrounds({
1404
1233
  visibility,
1405
1234
  children: [...value].reverse().map((bg) => {
1406
1235
  if (bg.type === "color") {
1407
- return /* @__PURE__ */ jsx(Container$7, {
1236
+ return /* @__PURE__ */ jsx(Container$b, {
1408
1237
  style: {
1409
1238
  backgroundColor: getColor(bg.payload)
1410
1239
  }
@@ -1440,7 +1269,7 @@ function Backgrounds({
1440
1269
  }
1441
1270
  return /* @__PURE__ */ jsx(Parallax, {
1442
1271
  strength: parallax,
1443
- children: (getParallaxProps) => /* @__PURE__ */ jsx(Container$7, __spreadValues({}, getParallaxProps({
1272
+ children: (getParallaxProps) => /* @__PURE__ */ jsx(Container$b, __spreadValues({}, getParallaxProps({
1444
1273
  style: {
1445
1274
  backgroundImage: publicUrl != null ? `url('${publicUrl}')` : void 0,
1446
1275
  backgroundPosition,
@@ -1458,7 +1287,7 @@ function Backgrounds({
1458
1287
  isRadial
1459
1288
  } = bg.payload;
1460
1289
  const gradient = `${getStopsStyle(stops)}`;
1461
- return /* @__PURE__ */ jsx(Container$7, {
1290
+ return /* @__PURE__ */ jsx(Container$b, {
1462
1291
  style: {
1463
1292
  background: isRadial ? `radial-gradient(${gradient})` : `linear-gradient(${angle}rad, ${gradient})`
1464
1293
  }
@@ -1475,7 +1304,7 @@ function Backgrounds({
1475
1304
  } = bg.payload;
1476
1305
  return /* @__PURE__ */ jsx(Parallax, {
1477
1306
  strength: parallax,
1478
- children: (getParallaxProps) => /* @__PURE__ */ jsx(Container$7, __spreadProps(__spreadValues({}, getParallaxProps({})), {
1307
+ children: (getParallaxProps) => /* @__PURE__ */ jsx(Container$b, __spreadProps(__spreadValues({}, getParallaxProps({})), {
1479
1308
  children: /* @__PURE__ */ jsx(BackgroundVideo, {
1480
1309
  url,
1481
1310
  zoom,
@@ -1543,7 +1372,7 @@ const Grid$1 = styled(motion.div)`
1543
1372
  alignContent
1544
1373
  }))}
1545
1374
  `;
1546
- const GridItem$1 = styled(motion.div)`
1375
+ const GridItem$2 = styled(motion.div)`
1547
1376
  display: flex;
1548
1377
 
1549
1378
  /* IE11 doesn't recognize space-between and treats it as stretch, so we fall back to flex-start */
@@ -1654,7 +1483,7 @@ const Box = forwardRef(function Box2({
1654
1483
  animate: animate == null ? void 0 : animate.parent,
1655
1484
  initial: initial == null ? void 0 : initial.parent,
1656
1485
  transition: transition == null ? void 0 : transition.parent,
1657
- children: children && children.elements.length > 0 ? children.elements.map((child, index) => /* @__PURE__ */ jsx(GridItem$1, {
1486
+ children: children && children.elements.length > 0 ? children.elements.map((child, index) => /* @__PURE__ */ jsx(GridItem$2, {
1658
1487
  grid: children.columns,
1659
1488
  index,
1660
1489
  columnGap,
@@ -1665,13 +1494,13 @@ const Box = forwardRef(function Box2({
1665
1494
  children: /* @__PURE__ */ jsx(Element$1, {
1666
1495
  element: child
1667
1496
  })
1668
- }, child.key)) : /* @__PURE__ */ jsx(Placeholder$1, {
1497
+ }, child.key)) : /* @__PURE__ */ jsx(Placeholder$2, {
1669
1498
  hide: hidePlaceholder
1670
1499
  })
1671
1500
  })
1672
1501
  }, key == null ? void 0 : key.container);
1673
1502
  });
1674
- function registerComponent$a(runtime) {
1503
+ function registerComponent$b(runtime) {
1675
1504
  return runtime.registerComponent(Box, {
1676
1505
  type: "./components/Box/index.js",
1677
1506
  label: "Box",
@@ -1843,7 +1672,7 @@ function registerComponent$a(runtime) {
1843
1672
  suffix: "s",
1844
1673
  defaultValue: DEFAULT_ITEM_STAGGER_DURATION
1845
1674
  }),
1846
- hidePlaceholder: Checkbox({
1675
+ hidePlaceholder: Checkbox$1({
1847
1676
  label: "Hide placeholder"
1848
1677
  }),
1849
1678
  children: Grid$2()
@@ -1936,7 +1765,7 @@ const Link = forwardRef(function Link2(_k, ref) {
1936
1765
  }))
1937
1766
  });
1938
1767
  });
1939
- const StyledButton = styled(Link)`
1768
+ const StyledButton$1 = styled(Link)`
1940
1769
  display: table;
1941
1770
  border: 0;
1942
1771
  outline: 0;
@@ -2128,7 +1957,7 @@ const StyledButton = styled(Link)`
2128
1957
  })}
2129
1958
  ${cssTextStyle()}
2130
1959
  `;
2131
- const Button = forwardRef(function Button2(_m, ref) {
1960
+ const Button$1 = forwardRef(function Button2(_m, ref) {
2132
1961
  var _n = _m, {
2133
1962
  id,
2134
1963
  children,
@@ -2154,7 +1983,7 @@ const Button = forwardRef(function Button2(_m, ref) {
2154
1983
  "width",
2155
1984
  "margin"
2156
1985
  ]);
2157
- return /* @__PURE__ */ jsx(StyledButton, __spreadProps(__spreadValues({}, restOfProps), {
1986
+ return /* @__PURE__ */ jsx(StyledButton$1, __spreadProps(__spreadValues({}, restOfProps), {
2158
1987
  ref,
2159
1988
  id,
2160
1989
  color: useColor(color),
@@ -2169,8 +1998,8 @@ const Button = forwardRef(function Button2(_m, ref) {
2169
1998
  children: children == null ? "Button Text" : children
2170
1999
  }));
2171
2000
  });
2172
- function registerComponent$9(runtime) {
2173
- return runtime.registerComponent(Button, {
2001
+ function registerComponent$a(runtime) {
2002
+ return runtime.registerComponent(Button$1, {
2174
2003
  type: "./components/Button/index.js",
2175
2004
  label: "Button",
2176
2005
  props: {
@@ -2370,7 +2199,7 @@ const ImageComponent = forwardRef(function Image2({
2370
2199
  })
2371
2200
  });
2372
2201
  });
2373
- function registerComponent$8(runtime) {
2202
+ function registerComponent$9(runtime) {
2374
2203
  return runtime.registerComponent(ImageComponent, {
2375
2204
  type: "./components/Image/index.js",
2376
2205
  label: "Image",
@@ -2419,7 +2248,7 @@ const RightChevron = () => /* @__PURE__ */ jsx("svg", {
2419
2248
  strokeWidth: "2"
2420
2249
  })
2421
2250
  });
2422
- const Container$6 = styled.div`
2251
+ const Container$a = styled.div`
2423
2252
  position: relative;
2424
2253
  height: 100%;
2425
2254
  `;
@@ -2719,7 +2548,7 @@ const Carousel = forwardRef(function Carousel2({
2719
2548
  break;
2720
2549
  }
2721
2550
  },
2722
- children: [/* @__PURE__ */ jsxs(Container$6, {
2551
+ children: [/* @__PURE__ */ jsxs(Container$a, {
2723
2552
  children: [/* @__PURE__ */ jsx(ClipMask, {
2724
2553
  children: /* @__PURE__ */ jsx(Page, __spreadProps(__spreadValues({}, bindPage()), {
2725
2554
  animate: animation,
@@ -2795,7 +2624,7 @@ const Carousel = forwardRef(function Carousel2({
2795
2624
  })]
2796
2625
  });
2797
2626
  });
2798
- function registerComponent$7(runtime) {
2627
+ function registerComponent$8(runtime) {
2799
2628
  return runtime.registerComponent(Carousel, {
2800
2629
  type: "./components/Carousel/index.js",
2801
2630
  label: "Carousel",
@@ -2858,7 +2687,7 @@ function registerComponent$7(runtime) {
2858
2687
  unit: "px"
2859
2688
  }
2860
2689
  }),
2861
- autoplay: Checkbox({
2690
+ autoplay: Checkbox$1({
2862
2691
  label: "Autoplay"
2863
2692
  }),
2864
2693
  delay: Number$1({
@@ -2868,7 +2697,7 @@ function registerComponent$7(runtime) {
2868
2697
  step: 0.1,
2869
2698
  suffix: "seconds"
2870
2699
  }),
2871
- showArrows: Checkbox({
2700
+ showArrows: Checkbox$1({
2872
2701
  preset: true,
2873
2702
  label: "Show arrows"
2874
2703
  }),
@@ -2897,7 +2726,7 @@ function registerComponent$7(runtime) {
2897
2726
  label: "Arrow background",
2898
2727
  placeholder: "white"
2899
2728
  }),
2900
- showDots: Checkbox({
2729
+ showDots: Checkbox$1({
2901
2730
  preset: true,
2902
2731
  label: "Show dots"
2903
2732
  }),
@@ -2915,14 +2744,14 @@ const Block$1 = styled.div`
2915
2744
  padding: 0.5em;
2916
2745
  font-size: 1em;
2917
2746
  `;
2918
- const Label = styled.div`
2747
+ const Label$3 = styled.div`
2919
2748
  margin-top: 0.25em;
2920
2749
  `;
2921
2750
  const Segment = styled.div`
2922
2751
  flex: 1;
2923
2752
  text-align: center;
2924
2753
  `;
2925
- const Container$5 = styled.div`
2754
+ const Container$9 = styled.div`
2926
2755
  display: flex;
2927
2756
  ${cssWidth("560px")}
2928
2757
  ${cssMargin()}
@@ -2932,7 +2761,7 @@ const Container$5 = styled.div`
2932
2761
  return css`
2933
2762
  font-size: 18px;
2934
2763
 
2935
- ${Label} {
2764
+ ${Label$3} {
2936
2765
  font-size: 14px;
2937
2766
  }
2938
2767
  `;
@@ -2940,7 +2769,7 @@ const Container$5 = styled.div`
2940
2769
  return css`
2941
2770
  font-size: 32px;
2942
2771
 
2943
- ${Label} {
2772
+ ${Label$3} {
2944
2773
  font-size: 18px;
2945
2774
  }
2946
2775
  `;
@@ -2948,7 +2777,7 @@ const Container$5 = styled.div`
2948
2777
  return css`
2949
2778
  font-size: 24px;
2950
2779
 
2951
- ${Label} {
2780
+ ${Label$3} {
2952
2781
  font-size: 16px;
2953
2782
  }
2954
2783
  `;
@@ -3085,7 +2914,7 @@ const Container$5 = styled.div`
3085
2914
  })}
3086
2915
  }
3087
2916
 
3088
- ${Label} {
2917
+ ${Label$3} {
3089
2918
  ${(p) => cssMediaRules([p.labelColor, p.labelFont], ([labelColor = {
3090
2919
  swatch: {
3091
2920
  hue: 0,
@@ -3162,7 +2991,7 @@ const Countdown = forwardRef(function Countdown2({
3162
2991
  }, 1e3);
3163
2992
  return () => clearInterval(intervalId);
3164
2993
  }, [date]);
3165
- return /* @__PURE__ */ jsxs(Container$5, {
2994
+ return /* @__PURE__ */ jsxs(Container$9, {
3166
2995
  ref,
3167
2996
  id,
3168
2997
  width,
@@ -3181,7 +3010,7 @@ const Countdown = forwardRef(function Countdown2({
3181
3010
  children: /* @__PURE__ */ jsx("span", {
3182
3011
  children: days
3183
3012
  })
3184
- }), /* @__PURE__ */ jsx(Label, {
3013
+ }), /* @__PURE__ */ jsx(Label$3, {
3185
3014
  children: daysLabel == null ? "Days" : daysLabel
3186
3015
  })]
3187
3016
  }), /* @__PURE__ */ jsxs(Segment, {
@@ -3189,7 +3018,7 @@ const Countdown = forwardRef(function Countdown2({
3189
3018
  children: /* @__PURE__ */ jsx("span", {
3190
3019
  children: hours
3191
3020
  })
3192
- }), /* @__PURE__ */ jsx(Label, {
3021
+ }), /* @__PURE__ */ jsx(Label$3, {
3193
3022
  children: hoursLabel == null ? "Hours" : hoursLabel
3194
3023
  })]
3195
3024
  }), /* @__PURE__ */ jsxs(Segment, {
@@ -3197,7 +3026,7 @@ const Countdown = forwardRef(function Countdown2({
3197
3026
  children: /* @__PURE__ */ jsx("span", {
3198
3027
  children: minutes
3199
3028
  })
3200
- }), /* @__PURE__ */ jsx(Label, {
3029
+ }), /* @__PURE__ */ jsx(Label$3, {
3201
3030
  children: minutesLabel == null ? "Minutes" : minutesLabel
3202
3031
  })]
3203
3032
  }), /* @__PURE__ */ jsxs(Segment, {
@@ -3205,13 +3034,13 @@ const Countdown = forwardRef(function Countdown2({
3205
3034
  children: /* @__PURE__ */ jsx("span", {
3206
3035
  children: seconds
3207
3036
  })
3208
- }), /* @__PURE__ */ jsx(Label, {
3037
+ }), /* @__PURE__ */ jsx(Label$3, {
3209
3038
  children: secondsLabel == null ? "Seconds" : secondsLabel
3210
3039
  })]
3211
3040
  })]
3212
3041
  });
3213
3042
  });
3214
- function registerComponent$6(runtime) {
3043
+ function registerComponent$7(runtime) {
3215
3044
  return runtime.registerComponent(Countdown, {
3216
3045
  type: "./components/Countdown/index.js",
3217
3046
  label: "Countdown",
@@ -3347,7 +3176,7 @@ const IE11MinHeightContainer = styled.div`
3347
3176
  ${cssWidth()}
3348
3177
  ${cssMargin()}
3349
3178
  `;
3350
- const Container$4 = styled.div`
3179
+ const Container$8 = styled.div`
3351
3180
  display: flex;
3352
3181
  flex-direction: column;
3353
3182
  justify-content: center;
@@ -3406,7 +3235,7 @@ const Divider = forwardRef(function Divider2({
3406
3235
  id,
3407
3236
  width,
3408
3237
  margin,
3409
- children: /* @__PURE__ */ jsx(Container$4, {
3238
+ children: /* @__PURE__ */ jsx(Container$8, {
3410
3239
  children: /* @__PURE__ */ jsx(Line, {
3411
3240
  variant,
3412
3241
  thickness,
@@ -3415,7 +3244,7 @@ const Divider = forwardRef(function Divider2({
3415
3244
  })
3416
3245
  });
3417
3246
  });
3418
- function registerComponent$5(runtime) {
3247
+ function registerComponent$6(runtime) {
3419
3248
  return runtime.registerComponent(Divider, {
3420
3249
  type: "./components/Divider/index.js",
3421
3250
  label: "Divider",
@@ -3465,7 +3294,7 @@ function registerComponent$5(runtime) {
3465
3294
  }
3466
3295
  });
3467
3296
  }
3468
- const Container$3 = styled.div`
3297
+ const Container$7 = styled.div`
3469
3298
  min-height: 15px;
3470
3299
  ${cssWidth()}
3471
3300
  ${cssMargin()}
@@ -3545,7 +3374,7 @@ const Embed = forwardRef(function Embed2({
3545
3374
  }, [container, html]);
3546
3375
  if (shouldRender === false)
3547
3376
  return null;
3548
- return /* @__PURE__ */ jsx(Container$3, {
3377
+ return /* @__PURE__ */ jsx(Container$7, {
3549
3378
  ref: setContainer,
3550
3379
  id,
3551
3380
  margin,
@@ -3555,14 +3384,14 @@ const Embed = forwardRef(function Embed2({
3555
3384
  }
3556
3385
  });
3557
3386
  });
3558
- function registerComponent$4(runtime) {
3387
+ function registerComponent$5(runtime) {
3559
3388
  return runtime.registerComponent(Embed, {
3560
3389
  type: "./components/Embed/index.js",
3561
3390
  label: "Embed",
3562
3391
  icon: "Code40",
3563
3392
  props: {
3564
3393
  id: ElementID(),
3565
- html: TextArea({
3394
+ html: TextArea$1({
3566
3395
  label: "Code",
3567
3396
  rows: 20
3568
3397
  }),
@@ -3571,9 +3400,9 @@ function registerComponent$4(runtime) {
3571
3400
  }
3572
3401
  });
3573
3402
  }
3574
- var _path$r;
3575
- function _extends$r() {
3576
- _extends$r = Object.assign || function(target) {
3403
+ var _path$s;
3404
+ function _extends$t() {
3405
+ _extends$t = Object.assign || function(target) {
3577
3406
  for (var i = 1; i < arguments.length; i++) {
3578
3407
  var source = arguments[i];
3579
3408
  for (var key in source) {
@@ -3584,87 +3413,1865 @@ function _extends$r() {
3584
3413
  }
3585
3414
  return target;
3586
3415
  };
3587
- return _extends$r.apply(this, arguments);
3416
+ return _extends$t.apply(this, arguments);
3588
3417
  }
3589
- var SvgMobileMenu28 = function SvgMobileMenu282(props) {
3590
- return /* @__PURE__ */ React.createElement("svg", _extends$r({
3591
- xmlns: "http://www.w3.org/2000/svg",
3592
- width: 28,
3593
- height: 28
3594
- }, props), _path$r || (_path$r = /* @__PURE__ */ React.createElement("path", {
3595
- d: "M27 15H1a1 1 0 0 1-1-1 1 1 0 0 1 1-1h26a1 1 0 0 1 1 1 1 1 0 0 1-1 1zm0-10H1a1 1 0 0 0-1 1 1 1 0 0 0 1 1h26a1 1 0 0 0 1-1 1 1 0 0 0-1-1zm0 16H1a1 1 0 0 0-1 1 1 1 0 0 0 1 1h26a1 1 0 0 0 1-1 1 1 0 0 0-1-1z"
3418
+ var SvgCheck12 = function SvgCheck122(props) {
3419
+ return /* @__PURE__ */ React.createElement("svg", _extends$t({
3420
+ width: 12,
3421
+ height: 12,
3422
+ xmlns: "http://www.w3.org/2000/svg"
3423
+ }, props), _path$s || (_path$s = /* @__PURE__ */ React.createElement("path", {
3424
+ fillRule: "evenodd",
3425
+ clipRule: "evenodd",
3426
+ d: "M11.707 1.793a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414 0l-3-3a1 1 0 0 1 1.414-1.414L4 8.086l6.293-6.293a1 1 0 0 1 1.414 0Z"
3596
3427
  })));
3597
3428
  };
3598
- const GutterContainer = styled.div`
3599
- ${(p) => cssMediaRules([p.gutter], ([gutter = {
3600
- value: 0,
3601
- unit: "px"
3602
- }]) => css`
3603
- padding-left: ${p.first ? "0px" : `${gutter.value / 2}${gutter.unit}`};
3604
- padding-right: ${p.last ? "0px" : `${gutter.value / 2}${gutter.unit}`};
3429
+ const Shapes = Object.freeze({
3430
+ SQUARE: "square",
3431
+ ROUNDED: "rounded",
3432
+ PILL: "pill"
3433
+ });
3434
+ const Sizes = Object.freeze({
3435
+ SMALL: "small",
3436
+ MEDIUM: "medium",
3437
+ LARGE: "large"
3438
+ });
3439
+ const Contrasts = Object.freeze({
3440
+ LIGHT: "light",
3441
+ DARK: "dark"
3442
+ });
3443
+ const Context$1 = createContext({});
3444
+ function useFormContext() {
3445
+ return useContext(Context$1);
3446
+ }
3447
+ const { Provider } = Context$1;
3448
+ function getSizeHeight$2(size) {
3449
+ switch (size) {
3450
+ case Sizes.SMALL:
3451
+ return 30;
3452
+ case Sizes.MEDIUM:
3453
+ return 38;
3454
+ case Sizes.LARGE:
3455
+ return 48;
3456
+ default:
3457
+ throw new Error(`Invalid form size "${size}"`);
3458
+ }
3459
+ }
3460
+ function getSizeHorizontalPadding(size) {
3461
+ switch (size) {
3462
+ case Sizes.SMALL:
3463
+ return 8;
3464
+ case Sizes.MEDIUM:
3465
+ return 12;
3466
+ case Sizes.LARGE:
3467
+ return 16;
3468
+ default:
3469
+ throw new Error(`Invalid form size "${size}"`);
3470
+ }
3471
+ }
3472
+ function getSizeVerticalPadding(size) {
3473
+ switch (size) {
3474
+ case Sizes.SMALL:
3475
+ return 3;
3476
+ case Sizes.MEDIUM:
3477
+ return 7;
3478
+ case Sizes.LARGE:
3479
+ return 11;
3480
+ default:
3481
+ throw new Error(`Invalid form size "${size}"`);
3482
+ }
3483
+ }
3484
+ function getShapeBorderRadius(shape) {
3485
+ switch (shape) {
3486
+ case Shapes.SQUARE:
3487
+ return 0;
3488
+ case Shapes.ROUNDED:
3489
+ return 4;
3490
+ case Shapes.PILL:
3491
+ return 500;
3492
+ default:
3493
+ throw new Error(`Invalid form shape "${shape}"`);
3494
+ }
3495
+ }
3496
+ function getContrastBorderColor(contrast, error) {
3497
+ switch (contrast) {
3498
+ case Contrasts.LIGHT:
3499
+ return error ? "rgba(255, 0, 0, 0.7)" : "rgba(0, 0, 0, 0.25)";
3500
+ case Contrasts.DARK:
3501
+ return error ? "rgba(255, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.6)";
3502
+ default:
3503
+ throw new Error(`Invalid form contrast "${contrast}"`);
3504
+ }
3505
+ }
3506
+ function getContrastBackgroundColor(contrast) {
3507
+ switch (contrast) {
3508
+ case Contrasts.LIGHT:
3509
+ return "white";
3510
+ case Contrasts.DARK:
3511
+ return "rgba(0, 0, 0, 0.7)";
3512
+ default:
3513
+ throw new Error(`Invalid form contrast "${contrast}"`);
3514
+ }
3515
+ }
3516
+ function getContrastColor$1(contrast) {
3517
+ switch (contrast) {
3518
+ case Contrasts.LIGHT:
3519
+ return "rgba(0, 0, 0, 0.95)";
3520
+ case Contrasts.DARK:
3521
+ return "white";
3522
+ default:
3523
+ throw new Error(`Invalid form contrast "${contrast}"`);
3524
+ }
3525
+ }
3526
+ function getContrastPlaceholderColor(contrast) {
3527
+ switch (contrast) {
3528
+ case Contrasts.LIGHT:
3529
+ return "rgba(0, 0, 0, 0.3)";
3530
+ case Contrasts.DARK:
3531
+ return "rgba(255,255,255,0.3)";
3532
+ default:
3533
+ throw new Error(`Invalid form contrast "${contrast}"`);
3534
+ }
3535
+ }
3536
+ function cssField() {
3537
+ return css`
3538
+ display: block;
3539
+ width: 100%;
3540
+ outline: none;
3541
+ border-width: 1px;
3542
+ border-style: solid;
3543
+ transition: border-color 200ms;
3544
+ ${(props) => cssMediaRules([props.shape, props.size, props.contrast, props.brandColor], ([
3545
+ shape = Shapes.ROUNDED,
3546
+ size = Sizes.MEDIUM,
3547
+ contrast = Contrasts.LIGHT,
3548
+ brandColor = { swatch: { hue: 0, saturation: 0, lightness: 0 }, alpha: 1 }
3549
+ ]) => css`
3550
+ padding: ${getSizeVerticalPadding(size)}px ${getSizeHorizontalPadding(size)}px;
3551
+ border-radius: ${getShapeBorderRadius(shape)}px;
3552
+ border-color: ${getContrastBorderColor(contrast, props.error)};
3553
+ color: ${getContrastColor$1(contrast)};
3554
+ background-color: ${getContrastBackgroundColor(contrast)};
3555
+
3556
+ :focus,
3557
+ :focus-within {
3558
+ border-color: ${colorToString(brandColor)};
3559
+ }
3560
+
3561
+ ::placeholder {
3562
+ color: ${getContrastPlaceholderColor(contrast)};
3563
+ }
3564
+ `)}
3565
+ `;
3566
+ }
3567
+ function getSizeHeight$1(size) {
3568
+ switch (size) {
3569
+ case Sizes.SMALL:
3570
+ return 36;
3571
+ case Sizes.MEDIUM:
3572
+ return 42;
3573
+ case Sizes.LARGE:
3574
+ return 48;
3575
+ default:
3576
+ throw new Error(`Invalid form size "${size}"`);
3577
+ }
3578
+ }
3579
+ const Base$2 = styled.input`
3580
+ ${cssField()}
3581
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
3582
+ min-height: ${getSizeHeight$1(size)}px;
3583
+ max-height: ${getSizeHeight$1(size)}px;
3605
3584
  `)}
3606
3585
  `;
3607
- const PlaceholderLink$1 = styled.div`
3608
- width: ${(props) => props.width}px;
3609
- height: ${(props) => props.button === true ? 32 : 8}px;
3586
+ var Input$2 = forwardRef(function Input(_o, ref) {
3587
+ var _p = _o, {
3588
+ error = false,
3589
+ form
3590
+ } = _p, restOfProps = __objRest(_p, [
3591
+ "error",
3592
+ "form"
3593
+ ]);
3594
+ const {
3595
+ shape,
3596
+ size,
3597
+ contrast,
3598
+ brandColor
3599
+ } = useFormContext();
3600
+ return /* @__PURE__ */ jsx(Base$2, __spreadProps(__spreadValues({}, restOfProps), {
3601
+ ref,
3602
+ error,
3603
+ shape,
3604
+ size,
3605
+ contrast,
3606
+ brandColor
3607
+ }));
3608
+ });
3609
+ const Container$6 = styled.div`
3610
+ display: flex;
3611
+ flex-direction: column;
3612
+ ${cssWidth()};
3613
+ ${cssMargin()};
3614
+ `;
3615
+ const Label$2 = styled.div`
3616
+ max-width: 120px;
3617
+ min-width: 60px;
3618
+ height: 8px;
3619
+ border-radius: 2px;
3610
3620
  background-color: #a1a8c2;
3611
- border-radius: ${(props) => props.button === true ? 6 : 2}px;
3612
3621
  opacity: 0.4;
3622
+ margin-bottom: 8px;
3613
3623
  `;
3614
- const links$1 = [{
3615
- width: 50
3616
- }, {
3617
- width: 70
3618
- }, {
3619
- width: 60
3620
- }, {
3621
- width: 80,
3622
- button: true
3623
- }];
3624
- function LinksPlaceholder({
3625
- gutter
3626
- }) {
3627
- return /* @__PURE__ */ jsx(Fragment, {
3628
- children: links$1.map((link, i) => /* @__PURE__ */ jsx(GutterContainer, {
3629
- gutter,
3630
- first: i === 0,
3631
- last: i === links$1.length - 1,
3632
- children: /* @__PURE__ */ jsx(PlaceholderLink$1, __spreadValues({}, link))
3633
- }, i))
3624
+ const Input$1 = styled.div`
3625
+ min-width: 80px;
3626
+ height: 32px;
3627
+ border-radius: 4px;
3628
+ border-width: 2px;
3629
+ border-style: solid;
3630
+ border-color: #a1a8c2;
3631
+ opacity: 0.4;
3632
+ `;
3633
+ const Button = styled.div`
3634
+ min-width: 140px;
3635
+ height: 32px;
3636
+ border-radius: 4px;
3637
+ background-color: #a1a8c2;
3638
+ opacity: 0.4;
3639
+ `;
3640
+ var Placeholder$1 = forwardRef(function Placeholder2({
3641
+ width,
3642
+ margin
3643
+ }, ref) {
3644
+ return /* @__PURE__ */ jsxs(Container$6, {
3645
+ ref,
3646
+ width,
3647
+ margin,
3648
+ children: [/* @__PURE__ */ jsxs("div", {
3649
+ style: {
3650
+ display: "flex",
3651
+ flexDirection: "column",
3652
+ marginBottom: 16
3653
+ },
3654
+ children: [/* @__PURE__ */ jsx(Label$2, {}), /* @__PURE__ */ jsx(Input$1, {})]
3655
+ }), /* @__PURE__ */ jsxs("div", {
3656
+ style: {
3657
+ display: "flex",
3658
+ flexDirection: "column",
3659
+ marginBottom: 16
3660
+ },
3661
+ children: [/* @__PURE__ */ jsx(Label$2, {}), /* @__PURE__ */ jsx(Input$1, {})]
3662
+ }), /* @__PURE__ */ jsx("div", {
3663
+ style: {
3664
+ display: "flex",
3665
+ flexDirection: "column",
3666
+ justifyContent: "flex-end"
3667
+ },
3668
+ children: /* @__PURE__ */ jsx(Button, {})
3669
+ })]
3634
3670
  });
3671
+ });
3672
+ function getSizeHeight(size) {
3673
+ switch (size) {
3674
+ case Sizes.SMALL:
3675
+ return 14;
3676
+ case Sizes.MEDIUM:
3677
+ return 18;
3678
+ case Sizes.LARGE:
3679
+ return 22;
3680
+ default:
3681
+ throw new Error(`Invalid form size "${size}"`);
3682
+ }
3635
3683
  }
3636
- var _path$q;
3637
- function _extends$q() {
3638
- _extends$q = Object.assign || function(target) {
3639
- for (var i = 1; i < arguments.length; i++) {
3640
- var source = arguments[i];
3641
- for (var key in source) {
3642
- if (Object.prototype.hasOwnProperty.call(source, key)) {
3643
- target[key] = source[key];
3644
- }
3645
- }
3646
- }
3647
- return target;
3648
- };
3649
- return _extends$q.apply(this, arguments);
3684
+ function getContrastColor(contrast) {
3685
+ switch (contrast) {
3686
+ case Contrasts.LIGHT:
3687
+ return "rgba(0, 0, 0, 0.8)";
3688
+ case Contrasts.DARK:
3689
+ return "rgba(255, 255, 255, 0.95)";
3690
+ default:
3691
+ throw new Error(`Invalid form contrast "${contrast}"`);
3692
+ }
3650
3693
  }
3651
- var SvgCaretDown8 = function SvgCaretDown82(props) {
3652
- return /* @__PURE__ */ React.createElement("svg", _extends$q({
3653
- width: 8,
3654
- height: 8,
3655
- xmlns: "http://www.w3.org/2000/svg"
3656
- }, props), _path$q || (_path$q = /* @__PURE__ */ React.createElement("path", {
3657
- d: "M1 2a1 1 0 0 0-.707 1.707l3 3a1 1 0 0 0 1.414 0l3-3A1 1 0 0 0 7 2H1z"
3658
- })));
3659
- };
3660
- var _path$p;
3661
- function _extends$p() {
3662
- _extends$p = Object.assign || function(target) {
3663
- for (var i = 1; i < arguments.length; i++) {
3664
- var source = arguments[i];
3665
- for (var key in source) {
3666
- if (Object.prototype.hasOwnProperty.call(source, key)) {
3667
- target[key] = source[key];
3694
+ const Base$1 = styled.label`
3695
+ display: block;
3696
+ margin: 0 0 0.25em 0;
3697
+ ${cssTextStyle()}
3698
+ ${(props) => cssMediaRules([props.size, props.contrast, props.textColor], ([size = Sizes.MEDIUM, contrast = Contrasts.LIGHT, textColor]) => css`
3699
+ min-height: ${getSizeHeight(size)}px;
3700
+ color: ${textColor == null ? getContrastColor(contrast) : colorToString(textColor)};
3701
+ `)}
3702
+ `;
3703
+ function Label$1(props) {
3704
+ const {
3705
+ contrast,
3706
+ size,
3707
+ labelTextStyle,
3708
+ labelTextColor
3709
+ } = useFormContext();
3710
+ return /* @__PURE__ */ jsx(Base$1, __spreadProps(__spreadValues({}, props), {
3711
+ contrast,
3712
+ size,
3713
+ textStyle: labelTextStyle,
3714
+ textColor: useColor(labelTextColor)
3715
+ }));
3716
+ }
3717
+ var SingleLineTextTableField = forwardRef(function SingleLineTextTableField2(_q, ref) {
3718
+ var _r = _q, {
3719
+ id,
3720
+ label = "",
3721
+ name,
3722
+ error,
3723
+ hideLabel = false
3724
+ } = _r, restOfProps = __objRest(_r, [
3725
+ "id",
3726
+ "label",
3727
+ "name",
3728
+ "error",
3729
+ "hideLabel"
3730
+ ]);
3731
+ return /* @__PURE__ */ jsxs(Fragment, {
3732
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
3733
+ htmlFor: id,
3734
+ children: label
3735
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
3736
+ "aria-label": label,
3737
+ ref,
3738
+ id,
3739
+ name,
3740
+ type: "text",
3741
+ error: error != null
3742
+ }))]
3743
+ });
3744
+ });
3745
+ const Base = styled.textarea`
3746
+ resize: vertical;
3747
+ ${cssField()}
3748
+ `;
3749
+ var TextArea = forwardRef(function TextArea2(_s, ref) {
3750
+ var _t = _s, {
3751
+ error = false,
3752
+ form
3753
+ } = _t, restOfProps = __objRest(_t, [
3754
+ "error",
3755
+ "form"
3756
+ ]);
3757
+ const {
3758
+ shape,
3759
+ size,
3760
+ contrast,
3761
+ brandColor
3762
+ } = useFormContext();
3763
+ return /* @__PURE__ */ jsx(Base, __spreadProps(__spreadValues({}, restOfProps), {
3764
+ ref,
3765
+ rows: 4,
3766
+ error,
3767
+ shape,
3768
+ size,
3769
+ contrast,
3770
+ brandColor
3771
+ }));
3772
+ });
3773
+ var LongTextTableField = forwardRef(function LongTextTableField2(_u, ref) {
3774
+ var _v = _u, {
3775
+ id,
3776
+ label = "",
3777
+ error,
3778
+ hideLabel = false
3779
+ } = _v, restOfProps = __objRest(_v, [
3780
+ "id",
3781
+ "label",
3782
+ "error",
3783
+ "hideLabel"
3784
+ ]);
3785
+ return /* @__PURE__ */ jsxs(Fragment, {
3786
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
3787
+ htmlFor: id,
3788
+ children: label
3789
+ }), /* @__PURE__ */ jsx(TextArea, __spreadProps(__spreadValues({}, restOfProps), {
3790
+ "aria-label": label,
3791
+ ref,
3792
+ id,
3793
+ error: error != null
3794
+ }))]
3795
+ });
3796
+ });
3797
+ function getCheckmarkColor$1({
3798
+ swatch: {
3799
+ hue: h,
3800
+ saturation: s,
3801
+ lightness: l
3802
+ },
3803
+ alpha: a
3804
+ }) {
3805
+ return ColorHelper({
3806
+ h,
3807
+ s,
3808
+ l
3809
+ }).alpha(a).isLight() ? "rgba(0, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.95)";
3810
+ }
3811
+ const Container$5 = styled.div`
3812
+ position: relative;
3813
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
3814
+ height: ${getSizeHeight(size)}px;
3815
+ width: ${getSizeHeight(size)}px;
3816
+ `)}
3817
+ `;
3818
+ const FakeCheckbox = styled.div`
3819
+ position: absolute;
3820
+ width: 100%;
3821
+ height: 100%;
3822
+ border-style: solid;
3823
+ border-radius: 4px;
3824
+ pointer-events: none;
3825
+ border-width: 1px;
3826
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
3827
+ border-color: ${getContrastBorderColor(contrast, props.error)};
3828
+ background-color: ${getContrastBackgroundColor(contrast)};
3829
+ `)}
3830
+ `;
3831
+ const HiddenCheckbox = styled.input`
3832
+ position: absolute;
3833
+ opacity: 0;
3834
+ width: 100%;
3835
+ height: 100%;
3836
+ cursor: pointer;
3837
+
3838
+ &:disabled {
3839
+ cursor: no-drop;
3840
+
3841
+ & ~ ${FakeCheckbox} {
3842
+ opacity: 0.5;
3843
+ }
3844
+ }
3845
+
3846
+ &:checked ~ ${FakeCheckbox} {
3847
+ ${(props) => cssMediaRules([props.brandColor], ([{
3848
+ swatch = {
3849
+ hue: 0,
3850
+ saturation: 0,
3851
+ lightness: 0
3852
+ },
3853
+ alpha = 1
3854
+ } = {}]) => css`
3855
+ background-color: ${colorToString({
3856
+ swatch,
3857
+ alpha
3858
+ })};
3859
+ `)}
3860
+ border-color: transparent;
3861
+
3862
+ &::after {
3863
+ content: '';
3864
+ position: absolute;
3865
+ box-sizing: content-box;
3866
+ width: 25%;
3867
+ height: 50%;
3868
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
3869
+ border-width: ${getSizeHeight(size) * 0.1}px;
3870
+ border-left: 0;
3871
+ border-top: 0;
3872
+ `)}
3873
+ border-style: solid;
3874
+ ${(props) => cssMediaRules([props.brandColor], ([{
3875
+ swatch = {
3876
+ hue: 0,
3877
+ saturation: 0,
3878
+ lightness: 0
3879
+ },
3880
+ alpha = 1
3881
+ } = {}]) => css`
3882
+ border-color: ${getCheckmarkColor$1({
3883
+ swatch,
3884
+ alpha
3885
+ })};
3886
+ `)}
3887
+ transform: rotate(45deg) translate3d(91%, -23%, 0);
3888
+ }
3889
+ }
3890
+
3891
+ &:not(:disabled) {
3892
+ &:focus ~ ${FakeCheckbox} {
3893
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
3894
+ swatch: {
3895
+ hue: 0,
3896
+ saturation: 0,
3897
+ lightness: 0
3898
+ },
3899
+ alpha: 1
3900
+ }]) => css`
3901
+ border-color: ${colorToString(brandColor)};
3902
+ `)}
3903
+ }
3904
+ }
3905
+
3906
+ &:not(:disabled):checked {
3907
+ &:focus ~ ${FakeCheckbox} {
3908
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
3909
+ border-color: ${getContrastBorderColor(contrast, props.error)};
3910
+ `)}
3911
+ }
3912
+ }
3913
+ `;
3914
+ var Checkbox = forwardRef(function Checkbox2(_w, ref) {
3915
+ var _x = _w, {
3916
+ error,
3917
+ className,
3918
+ style,
3919
+ form
3920
+ } = _x, restOfProps = __objRest(_x, [
3921
+ "error",
3922
+ "className",
3923
+ "style",
3924
+ "form"
3925
+ ]);
3926
+ const {
3927
+ size,
3928
+ contrast,
3929
+ brandColor
3930
+ } = useFormContext();
3931
+ return /* @__PURE__ */ jsxs(Container$5, {
3932
+ size,
3933
+ children: [/* @__PURE__ */ jsx(HiddenCheckbox, __spreadProps(__spreadValues({}, restOfProps), {
3934
+ type: "checkbox",
3935
+ ref,
3936
+ error,
3937
+ size,
3938
+ contrast,
3939
+ brandColor
3940
+ })), /* @__PURE__ */ jsx(FakeCheckbox, {
3941
+ className,
3942
+ error,
3943
+ contrast,
3944
+ style
3945
+ })]
3946
+ });
3947
+ });
3948
+ const StyledLabel$2 = styled(Label$1)`
3949
+ display: flex;
3950
+ align-items: center;
3951
+ margin: 0;
3952
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
3953
+ min-height: ${getSizeHeight$1(size)}px;
3954
+ max-height: ${getSizeHeight$1(size)}px;
3955
+ `)}
3956
+ `;
3957
+ const CheckboxContainer$1 = styled.span`
3958
+ margin-right: 8px;
3959
+ `;
3960
+ var CheckboxTableField = forwardRef(function CheckboxTableField2(_y, ref) {
3961
+ var _z = _y, {
3962
+ form,
3963
+ id,
3964
+ name,
3965
+ label = "",
3966
+ value = false,
3967
+ error
3968
+ } = _z, restOfProps = __objRest(_z, [
3969
+ "form",
3970
+ "id",
3971
+ "name",
3972
+ "label",
3973
+ "value",
3974
+ "error"
3975
+ ]);
3976
+ const {
3977
+ size
3978
+ } = useFormContext();
3979
+ function handleChange(event) {
3980
+ form.setFieldValue(name, event.currentTarget.checked);
3981
+ }
3982
+ return /* @__PURE__ */ jsxs(StyledLabel$2, {
3983
+ htmlFor: id,
3984
+ size,
3985
+ children: [/* @__PURE__ */ jsx(CheckboxContainer$1, {
3986
+ children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, restOfProps), {
3987
+ "aria-label": label,
3988
+ checked: value,
3989
+ onChange: handleChange,
3990
+ ref,
3991
+ id,
3992
+ error: error != null
3993
+ }))
3994
+ }), label]
3995
+ });
3996
+ });
3997
+ const MainLabel = styled(Label$1)`
3998
+ margin: 0 0 4px 0;
3999
+ `;
4000
+ const StyledLabel$1 = styled(Label$1)`
4001
+ display: flex;
4002
+ align-items: center;
4003
+ margin: 8px 0;
4004
+
4005
+ &:last-of-type {
4006
+ margin-bottom: 0;
4007
+ }
4008
+ `;
4009
+ const CheckboxContainer = styled.span`
4010
+ margin-right: 8px;
4011
+ `;
4012
+ var MultipleSelectTableField = forwardRef(function MultipleSelectTableField2(_A, ref) {
4013
+ var _B = _A, {
4014
+ tableColumn,
4015
+ label = "",
4016
+ required,
4017
+ value = [],
4018
+ onChange,
4019
+ hideLabel = false
4020
+ } = _B, restOfProps = __objRest(_B, [
4021
+ "tableColumn",
4022
+ "label",
4023
+ "required",
4024
+ "value",
4025
+ "onChange",
4026
+ "hideLabel"
4027
+ ]);
4028
+ const handle = useRef({
4029
+ validity: {
4030
+ valueMissing: required === true && value.length === 0,
4031
+ typeMismatch: false
4032
+ }
4033
+ });
4034
+ useImperativeHandle(ref, () => handle.current, []);
4035
+ function handleChange(event) {
4036
+ handle.current.validity.valueMissing = required === true && !event.currentTarget.checked && value.filter((v) => v !== event.currentTarget.value).length === 0;
4037
+ onChange(event);
4038
+ }
4039
+ return /* @__PURE__ */ jsxs("div", {
4040
+ children: [!hideLabel && /* @__PURE__ */ jsx(MainLabel, {
4041
+ children: label
4042
+ }), tableColumn.options.map((option) => /* @__PURE__ */ jsxs(StyledLabel$1, {
4043
+ htmlFor: option.id,
4044
+ children: [/* @__PURE__ */ jsx(CheckboxContainer, {
4045
+ children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, restOfProps), {
4046
+ "aria-label": label,
4047
+ onChange: handleChange,
4048
+ checked: value.includes(option.name),
4049
+ id: option.id,
4050
+ value: option.name
4051
+ }))
4052
+ }), option.name]
4053
+ }, option.id))]
4054
+ });
4055
+ });
4056
+ function getCheckmarkColor({
4057
+ swatch: {
4058
+ hue: h,
4059
+ saturation: s,
4060
+ lightness: l
4061
+ } = {
4062
+ hue: 0,
4063
+ saturation: 0,
4064
+ lightness: 0
4065
+ },
4066
+ alpha: a
4067
+ }) {
4068
+ return ColorHelper({
4069
+ h,
4070
+ s,
4071
+ l
4072
+ }).alpha(a).isLight() ? "rgba(0, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.95)";
4073
+ }
4074
+ const Container$4 = styled.div`
4075
+ position: relative;
4076
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
4077
+ height: ${getSizeHeight(size)}px;
4078
+ width: ${getSizeHeight(size)}px;
4079
+ `)}
4080
+ `;
4081
+ const FakeRadioButton = styled.div`
4082
+ position: absolute;
4083
+ width: 100%;
4084
+ height: 100%;
4085
+ border-style: solid;
4086
+ border-radius: 50%;
4087
+ pointer-events: none;
4088
+ border-width: 1px;
4089
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
4090
+ border-color: ${getContrastBorderColor(contrast, props.error)};
4091
+ background-color: ${getContrastBackgroundColor(contrast)};
4092
+ `)}
4093
+ `;
4094
+ const HiddenRadioButton = styled.input.attrs({
4095
+ type: "radio"
4096
+ })`
4097
+ position: absolute;
4098
+ opacity: 0;
4099
+ width: 100%;
4100
+ height: 100%;
4101
+ cursor: pointer;
4102
+
4103
+ &:disabled {
4104
+ cursor: no-drop;
4105
+
4106
+ & ~ ${FakeRadioButton} {
4107
+ opacity: 0.5;
4108
+ }
4109
+ }
4110
+
4111
+ &:checked ~ ${FakeRadioButton} {
4112
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
4113
+ swatch: {
4114
+ hue: 0,
4115
+ saturation: 0,
4116
+ lightness: 0
4117
+ },
4118
+ alpha: 1
4119
+ }]) => css`
4120
+ background-color: ${colorToString(brandColor)};
4121
+ `)}
4122
+ border-color: transparent;
4123
+
4124
+ &::after {
4125
+ content: '';
4126
+ position: absolute;
4127
+ box-sizing: content-box;
4128
+ top: 50%;
4129
+ left: 50%;
4130
+ width: 50%;
4131
+ height: 50%;
4132
+ border-radius: 50%;
4133
+ transform: translate(-50%, -50%);
4134
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
4135
+ swatch: {
4136
+ hue: 0,
4137
+ saturation: 0,
4138
+ lightness: 0
4139
+ },
4140
+ alpha: 1
4141
+ }]) => css`
4142
+ background-color: ${getCheckmarkColor(brandColor)};
4143
+ `)}
4144
+ }
4145
+ }
4146
+
4147
+ &:not(:disabled) {
4148
+ &:focus ~ ${FakeRadioButton} {
4149
+ ${(props) => cssMediaRules([props.brandColor], ([brandColor = {
4150
+ swatch: {
4151
+ hue: 0,
4152
+ saturation: 0,
4153
+ lightness: 0
4154
+ },
4155
+ alpha: 1
4156
+ }]) => css`
4157
+ border-color: ${colorToString(brandColor)};
4158
+ `)}
4159
+ }
4160
+ }
4161
+
4162
+ &:not(:disabled):checked {
4163
+ &:focus ~ ${FakeRadioButton} {
4164
+ ${(props) => cssMediaRules([props.contrast], ([contrast = Contrasts.LIGHT]) => css`
4165
+ border-color: ${getContrastBorderColor(contrast, props.error)};
4166
+ `)}
4167
+ }
4168
+ }
4169
+ `;
4170
+ var RadioButton = forwardRef(function RadioButton2(_C, ref) {
4171
+ var _D = _C, {
4172
+ error,
4173
+ className,
4174
+ style,
4175
+ form
4176
+ } = _D, restOfProps = __objRest(_D, [
4177
+ "error",
4178
+ "className",
4179
+ "style",
4180
+ "form"
4181
+ ]);
4182
+ const {
4183
+ size,
4184
+ contrast,
4185
+ brandColor
4186
+ } = useFormContext();
4187
+ return /* @__PURE__ */ jsxs(Container$4, {
4188
+ size,
4189
+ children: [/* @__PURE__ */ jsx(HiddenRadioButton, __spreadProps(__spreadValues({}, restOfProps), {
4190
+ ref,
4191
+ error,
4192
+ contrast,
4193
+ brandColor
4194
+ })), /* @__PURE__ */ jsx(FakeRadioButton, {
4195
+ className,
4196
+ error,
4197
+ contrast,
4198
+ style
4199
+ })]
4200
+ });
4201
+ });
4202
+ const StyledLabel = styled(Label$1)`
4203
+ display: flex;
4204
+ align-items: center;
4205
+ margin: 8px 0;
4206
+
4207
+ &:last-of-type {
4208
+ margin-bottom: 0;
4209
+ }
4210
+ `;
4211
+ const RadioButtonContainer = styled.span`
4212
+ margin-right: 8px;
4213
+ `;
4214
+ var TableColumnRadioButtonGroup = forwardRef(function TableColumnRadioButtonGroup2(_E, ref) {
4215
+ var _F = _E, {
4216
+ tableColumn,
4217
+ label = "",
4218
+ value = "",
4219
+ required = false,
4220
+ hideLabel = false,
4221
+ onChange
4222
+ } = _F, restOfProps = __objRest(_F, [
4223
+ "tableColumn",
4224
+ "label",
4225
+ "value",
4226
+ "required",
4227
+ "hideLabel",
4228
+ "onChange"
4229
+ ]);
4230
+ const handle = useRef({
4231
+ validity: {
4232
+ valueMissing: required === true && value === "",
4233
+ typeMismatch: false
4234
+ }
4235
+ });
4236
+ useImperativeHandle(ref, () => handle.current, []);
4237
+ function handleChange(event) {
4238
+ handle.current.validity.valueMissing = required === true && !event.currentTarget.checked;
4239
+ onChange(event);
4240
+ }
4241
+ return /* @__PURE__ */ jsxs("div", {
4242
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
4243
+ as: "p",
4244
+ children: label
4245
+ }), tableColumn.options.map((option) => /* @__PURE__ */ jsxs(StyledLabel, {
4246
+ htmlFor: option.id,
4247
+ "aria-label": label,
4248
+ children: [/* @__PURE__ */ jsx(RadioButtonContainer, {
4249
+ children: /* @__PURE__ */ jsx(RadioButton, __spreadProps(__spreadValues({}, restOfProps), {
4250
+ onChange: handleChange,
4251
+ checked: value === option.name,
4252
+ id: option.id,
4253
+ value: option.name
4254
+ }))
4255
+ }), option.name]
4256
+ }, option.id))]
4257
+ });
4258
+ });
4259
+ const Container$3 = styled.div`
4260
+ ${cssField()}
4261
+ display: flex;
4262
+ align-items: center;
4263
+ position: relative;
4264
+ user-select: none;
4265
+ border-color: #f19eb9;
4266
+
4267
+ &:focus,
4268
+ &:focus-within {
4269
+ border-color: #e54e7f;
4270
+ }
4271
+
4272
+ ${(props) => cssMediaRules([props.size, props.contrast], ([size = Sizes.MEDIUM, contrast = Contrasts.LIGHT]) => css`
4273
+ min-height: ${getSizeHeight$2(size)}px;
4274
+ max-height: ${getSizeHeight$2(size)}px;
4275
+
4276
+ &::after {
4277
+ content: '';
4278
+ position: absolute;
4279
+ right: ${getSizeHorizontalPadding(size)}px;
4280
+ top: 50%;
4281
+ transform: translate3d(0, -25%, 0);
4282
+ border: solid 0.35em transparent;
4283
+ border-top-color: ${getContrastColor$1(contrast)};
4284
+ }
4285
+ `)}
4286
+ `;
4287
+ const Select = styled.select`
4288
+ appearance: none;
4289
+ position: absolute;
4290
+ top: 0;
4291
+ left: 0;
4292
+ opacity: 0;
4293
+ width: 100%;
4294
+ height: 100%;
4295
+ `;
4296
+ var TableColumnSingleSelect = forwardRef(function TableColumnSingleSelect2(_G, ref) {
4297
+ var _H = _G, {
4298
+ id,
4299
+ tableColumn,
4300
+ value = "",
4301
+ label = "",
4302
+ error = false,
4303
+ hideLabel = false,
4304
+ form
4305
+ } = _H, restOfProps = __objRest(_H, [
4306
+ "id",
4307
+ "tableColumn",
4308
+ "value",
4309
+ "label",
4310
+ "error",
4311
+ "hideLabel",
4312
+ "form"
4313
+ ]);
4314
+ const {
4315
+ shape,
4316
+ size,
4317
+ contrast,
4318
+ brandColor
4319
+ } = useFormContext();
4320
+ return /* @__PURE__ */ jsxs(Fragment, {
4321
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
4322
+ htmlFor: id,
4323
+ children: label
4324
+ }), /* @__PURE__ */ jsxs(Container$3, {
4325
+ error,
4326
+ shape,
4327
+ size,
4328
+ contrast,
4329
+ brandColor,
4330
+ children: [/* @__PURE__ */ jsx("span", {
4331
+ children: value === "" ? "-" : value
4332
+ }), /* @__PURE__ */ jsxs(Select, __spreadProps(__spreadValues({}, restOfProps), {
4333
+ "aria-label": label,
4334
+ ref,
4335
+ id,
4336
+ value,
4337
+ children: [/* @__PURE__ */ jsx("option", {
4338
+ value: "",
4339
+ children: "-"
4340
+ }), tableColumn.options.map((option) => /* @__PURE__ */ jsx("option", {
4341
+ value: option.name,
4342
+ children: option.name
4343
+ }, option.id))]
4344
+ }))]
4345
+ })]
4346
+ });
4347
+ });
4348
+ var SingleSelectTableField = forwardRef(function SingleSelectTableField2(_I, ref) {
4349
+ var _J = _I, {
4350
+ type
4351
+ } = _J, restOfProps = __objRest(_J, [
4352
+ "type"
4353
+ ]);
4354
+ return type === "select" ? /* @__PURE__ */ jsx(TableColumnSingleSelect, __spreadProps(__spreadValues({}, restOfProps), {
4355
+ ref
4356
+ })) : /* @__PURE__ */ jsx(TableColumnRadioButtonGroup, __spreadProps(__spreadValues({}, restOfProps), {
4357
+ ref
4358
+ }));
4359
+ });
4360
+ var PhoneNumberTableField = forwardRef(function PhoneNumberTableField2(_K, ref) {
4361
+ var _L = _K, {
4362
+ id,
4363
+ label = "",
4364
+ name,
4365
+ error,
4366
+ hideLabel = false
4367
+ } = _L, restOfProps = __objRest(_L, [
4368
+ "id",
4369
+ "label",
4370
+ "name",
4371
+ "error",
4372
+ "hideLabel"
4373
+ ]);
4374
+ return /* @__PURE__ */ jsxs(Fragment, {
4375
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
4376
+ htmlFor: id,
4377
+ children: label
4378
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
4379
+ "aria-label": label,
4380
+ ref,
4381
+ id,
4382
+ name,
4383
+ type: "tel",
4384
+ error: error != null
4385
+ }))]
4386
+ });
4387
+ });
4388
+ var EmailTableField = forwardRef(function EmailTableField2(_M, ref) {
4389
+ var _N = _M, {
4390
+ id,
4391
+ label = "",
4392
+ name,
4393
+ error,
4394
+ hideLabel = false
4395
+ } = _N, restOfProps = __objRest(_N, [
4396
+ "id",
4397
+ "label",
4398
+ "name",
4399
+ "error",
4400
+ "hideLabel"
4401
+ ]);
4402
+ return /* @__PURE__ */ jsxs(Fragment, {
4403
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
4404
+ htmlFor: id,
4405
+ children: label
4406
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
4407
+ "aria-label": label,
4408
+ ref,
4409
+ id,
4410
+ name,
4411
+ type: "email",
4412
+ error: error != null
4413
+ }))]
4414
+ });
4415
+ });
4416
+ var URLTableField = forwardRef(function URLTableField2(_O, ref) {
4417
+ var _P = _O, {
4418
+ id,
4419
+ label = "",
4420
+ name,
4421
+ error,
4422
+ hideLabel = false
4423
+ } = _P, restOfProps = __objRest(_P, [
4424
+ "id",
4425
+ "label",
4426
+ "name",
4427
+ "error",
4428
+ "hideLabel"
4429
+ ]);
4430
+ return /* @__PURE__ */ jsxs(Fragment, {
4431
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
4432
+ htmlFor: id,
4433
+ children: label
4434
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
4435
+ "aria-label": label,
4436
+ ref,
4437
+ id,
4438
+ name,
4439
+ type: "url",
4440
+ error: error != null
4441
+ }))]
4442
+ });
4443
+ });
4444
+ var NumberTableField = forwardRef(function NumberTableField2(_Q, ref) {
4445
+ var _R = _Q, {
4446
+ id,
4447
+ label = "",
4448
+ name,
4449
+ error,
4450
+ hideLabel = false
4451
+ } = _R, restOfProps = __objRest(_R, [
4452
+ "id",
4453
+ "label",
4454
+ "name",
4455
+ "error",
4456
+ "hideLabel"
4457
+ ]);
4458
+ return /* @__PURE__ */ jsxs(Fragment, {
4459
+ children: [!hideLabel && /* @__PURE__ */ jsx(Label$1, {
4460
+ htmlFor: id,
4461
+ children: label
4462
+ }), /* @__PURE__ */ jsx(Input$2, __spreadProps(__spreadValues({}, restOfProps), {
4463
+ "aria-label": label,
4464
+ ref,
4465
+ id,
4466
+ name,
4467
+ type: "number",
4468
+ error: error != null
4469
+ }))]
4470
+ });
4471
+ });
4472
+ const Label = styled.div`
4473
+ display: block;
4474
+ max-width: 120px;
4475
+ min-width: 60px;
4476
+ border-radius: 2px;
4477
+ background-color: #5f49f4;
4478
+ opacity: 0.4;
4479
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
4480
+ margin: calc(0.25 * ${getSizeHeight(size)}px + 2px) 0;
4481
+ min-height: ${0.5 * getSizeHeight(size)}px;
4482
+ max-height: ${0.5 * getSizeHeight(size)}px;
4483
+ `)}
4484
+ `;
4485
+ const Input2 = styled.div`
4486
+ display: block;
4487
+ width: 100%;
4488
+ border-width: 2px;
4489
+ border-style: solid;
4490
+ border-color: #5f49f4;
4491
+ opacity: 0.4;
4492
+ ${(props) => cssMediaRules([props.shape, props.size], ([shape = Shapes.ROUNDED, size = Sizes.MEDIUM]) => css`
4493
+ min-height: ${getSizeHeight$1(size)}px;
4494
+ max-height: ${getSizeHeight$1(size)}px;
4495
+ border-radius: ${getShapeBorderRadius(shape)}px;
4496
+ `)}
4497
+ `;
4498
+ function PlaceholderTableField() {
4499
+ const {
4500
+ size,
4501
+ shape
4502
+ } = useFormContext();
4503
+ return /* @__PURE__ */ jsxs(Fragment, {
4504
+ children: [/* @__PURE__ */ jsx(Label, {
4505
+ size
4506
+ }), /* @__PURE__ */ jsx(Input2, {
4507
+ shape,
4508
+ size
4509
+ })]
4510
+ });
4511
+ }
4512
+ function getTypeMismatchErrorMessage(tableColumn, label) {
4513
+ switch ((tableColumn || {}).__typename) {
4514
+ case "PhoneNumberTableColumn":
4515
+ return `${label} field must be a valid phone number.`;
4516
+ case "EmailTableColumn":
4517
+ return `${label} field must be a valid email.`;
4518
+ case "URLTableColumn":
4519
+ return `${label} field must be a valid URL.`;
4520
+ case "NumberTableColumn":
4521
+ return `${label} field must be a valid number.`;
4522
+ case "SingleLineTextTableColumn":
4523
+ case "LongTextTableColumn":
4524
+ case "CheckboxTableColumn":
4525
+ default:
4526
+ return `${label} field is invalid.`;
4527
+ }
4528
+ }
4529
+ function getTableColumnField(tableColumn) {
4530
+ switch ((tableColumn || {}).__typename) {
4531
+ case "SingleLineTextTableColumn":
4532
+ return SingleLineTextTableField;
4533
+ case "LongTextTableColumn":
4534
+ return LongTextTableField;
4535
+ case "CheckboxTableColumn":
4536
+ return CheckboxTableField;
4537
+ case "MultipleSelectTableColumn":
4538
+ return MultipleSelectTableField;
4539
+ case "SingleSelectTableColumn":
4540
+ return SingleSelectTableField;
4541
+ case "PhoneNumberTableColumn":
4542
+ return PhoneNumberTableField;
4543
+ case "EmailTableColumn":
4544
+ return EmailTableField;
4545
+ case "URLTableColumn":
4546
+ return URLTableField;
4547
+ case "NumberTableColumn":
4548
+ return NumberTableField;
4549
+ default:
4550
+ return SingleLineTextTableField;
4551
+ }
4552
+ }
4553
+ function Field({
4554
+ tableColumn,
4555
+ tableFormField: {
4556
+ id,
4557
+ label = "",
4558
+ placeholder: placeholder2,
4559
+ required = false,
4560
+ hidden = false,
4561
+ type = "radio",
4562
+ hideLabel = false
4563
+ }
4564
+ }) {
4565
+ const TableColumnField = getTableColumnField(tableColumn);
4566
+ const input = useRef(null);
4567
+ if (!tableColumn)
4568
+ return /* @__PURE__ */ jsx(PlaceholderTableField, {});
4569
+ function validate() {
4570
+ let errorMessage;
4571
+ if (input.current) {
4572
+ const {
4573
+ validity = {}
4574
+ } = input.current;
4575
+ if (validity.valueMissing)
4576
+ errorMessage = `${label} is required.`;
4577
+ if (validity.typeMismatch)
4578
+ errorMessage = getTypeMismatchErrorMessage(tableColumn, label);
4579
+ }
4580
+ return errorMessage;
4581
+ }
4582
+ return /* @__PURE__ */ jsx(Field$1, {
4583
+ name: tableColumn.name,
4584
+ validate,
4585
+ children: ({
4586
+ field,
4587
+ form
4588
+ }) => hidden ? /* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({}, field), {
4589
+ ref: input,
4590
+ type: "hidden"
4591
+ })) : /* @__PURE__ */ jsx(TableColumnField, __spreadProps(__spreadValues({}, field), {
4592
+ type,
4593
+ form,
4594
+ tableColumn,
4595
+ ref: input,
4596
+ id,
4597
+ error: getIn(form.touched, field.name) && getIn(form.errors, field.name),
4598
+ label,
4599
+ placeholder: placeholder2,
4600
+ required,
4601
+ hideLabel
4602
+ }))
4603
+ });
4604
+ }
4605
+ var _g;
4606
+ function _extends$s() {
4607
+ _extends$s = Object.assign || function(target) {
4608
+ for (var i = 1; i < arguments.length; i++) {
4609
+ var source = arguments[i];
4610
+ for (var key in source) {
4611
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
4612
+ target[key] = source[key];
4613
+ }
4614
+ }
4615
+ }
4616
+ return target;
4617
+ };
4618
+ return _extends$s.apply(this, arguments);
4619
+ }
4620
+ var SvgSpinner20 = function SvgSpinner202(props) {
4621
+ return /* @__PURE__ */ React.createElement("svg", _extends$s({
4622
+ xmlns: "http://www.w3.org/2000/svg",
4623
+ width: 20,
4624
+ height: 20
4625
+ }, props), _g || (_g = /* @__PURE__ */ React.createElement("g", {
4626
+ fill: "none",
4627
+ strokeWidth: 2,
4628
+ transform: "translate(1 1)"
4629
+ }, /* @__PURE__ */ React.createElement("circle", {
4630
+ stroke: "currentColor",
4631
+ cx: 9,
4632
+ cy: 9,
4633
+ r: 9,
4634
+ strokeOpacity: 0.4
4635
+ }), /* @__PURE__ */ React.createElement("path", {
4636
+ d: "M9 18A9 9 0 0 0 9 0"
4637
+ }))));
4638
+ };
4639
+ const spin = keyframes`
4640
+ from {
4641
+ transform: rotate(0deg);
4642
+ }
4643
+ to {
4644
+ transform: rotate(360deg);
4645
+ }
4646
+ `;
4647
+ const Icon = styled(SvgSpinner20)`
4648
+ display: inline-flex;
4649
+ animation: ${spin} 1s linear infinite;
4650
+ stroke: currentColor;
4651
+ `;
4652
+ function Spinner() {
4653
+ return /* @__PURE__ */ jsx(Icon, {});
4654
+ }
4655
+ function useTableFormFieldRefs(propController, { fieldsCount }) {
4656
+ const [container, setContainer] = useState(null);
4657
+ const [items, setItems] = useState(Array(fieldsCount + 1).fill(null));
4658
+ const isInBuilder = useIsInBuilder();
4659
+ useEffect(() => {
4660
+ if (!isInBuilder)
4661
+ return;
4662
+ let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
4663
+ return () => {
4664
+ cancelAnimationFrame(animationFrameHandle);
4665
+ };
4666
+ function handleAnimationFrameRequest() {
4667
+ if (propController == null)
4668
+ return;
4669
+ if (container != null)
4670
+ propController.tableFormLayoutChange({ layout: getBox(container) });
4671
+ items.map((item, index) => {
4672
+ if (item == null)
4673
+ return;
4674
+ propController.tableFormFieldLayoutChange({ index, layout: getBox(item) });
4675
+ });
4676
+ animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
4677
+ }
4678
+ }, [propController, container, items, isInBuilder]);
4679
+ const itemRefs = useMemo(() => Array.from({ length: fieldsCount + 1 }).map((_, index) => (item) => {
4680
+ setItems((is) => [...is.slice(0, index), item, ...is.slice(index + 1)]);
4681
+ }), [fieldsCount, setItems]);
4682
+ return { container: setContainer, items: itemRefs };
4683
+ }
4684
+ const LOCAL_STORAGE_NAMESPACE = "@@makeswift/components/form";
4685
+ function getSizeFontSize(size) {
4686
+ switch (size) {
4687
+ case Sizes.SMALL:
4688
+ return 12;
4689
+ case Sizes.MEDIUM:
4690
+ return 14;
4691
+ case Sizes.LARGE:
4692
+ return 18;
4693
+ default:
4694
+ throw new Error(`Invalid form size "${size}"`);
4695
+ }
4696
+ }
4697
+ const Alignments = {
4698
+ LEFT: "left",
4699
+ CENTER: "center",
4700
+ RIGHT: "right"
4701
+ };
4702
+ const GridForm = styled.form`
4703
+ display: flex;
4704
+ flex-wrap: wrap;
4705
+ width: 100%;
4706
+ ${(props) => cssMediaRules([props.size], ([size = Sizes.MEDIUM]) => css`
4707
+ font-size: ${getSizeFontSize(size)}px;
4708
+ `)}
4709
+ ${cssWidth()}
4710
+ ${cssMargin()}
4711
+ `;
4712
+ const GridItem$1 = styled.div`
4713
+ align-self: flex-end;
4714
+ flex-direction: column;
4715
+ ${cssGridItem()}
4716
+ `;
4717
+ function getAlignmentMargin(alignment) {
4718
+ switch (alignment) {
4719
+ case Alignments.LEFT:
4720
+ return "0 auto 0 0";
4721
+ case Alignments.RIGHT:
4722
+ return "0 0 0 auto";
4723
+ default:
4724
+ return "0 auto";
4725
+ }
4726
+ }
4727
+ const StyledButton = styled((props) => /* @__PURE__ */ jsx(Button$1, __spreadProps(__spreadValues({}, props), {
4728
+ as: "button"
4729
+ })))`
4730
+ display: flex;
4731
+ align-items: center;
4732
+ justify-content: center;
4733
+ ${(props) => cssMediaRules([props.size, props.alignment], ([size = Sizes.MEDIUM, alignment = Alignments.CENTER]) => css`
4734
+ min-height: ${getSizeHeight$1(size)}px;
4735
+ max-height: ${getSizeHeight$1(size)}px;
4736
+ margin: ${getAlignmentMargin(alignment)};
4737
+ padding-top: 0;
4738
+ padding-bottom: 0;
4739
+ `)}
4740
+ `;
4741
+ const ErrorContainer = styled.div`
4742
+ padding: 8px 16px;
4743
+ background-color: #f19eb9;
4744
+ border-radius: 4px;
4745
+ margin-top: 16px;
4746
+ `;
4747
+ const IconContainer = styled.div`
4748
+ fill: currentColor;
4749
+ `;
4750
+ const ErrorMessage = styled.p`
4751
+ font-size: 12px;
4752
+ margin: 8px 0;
4753
+ color: rgba(127, 0, 0, 0.95);
4754
+ `;
4755
+ function getTableColumnDefaultValue(tableColumn) {
4756
+ switch (tableColumn.__typename) {
4757
+ case "CheckboxTableColumn":
4758
+ return false;
4759
+ case "MultipleSelectTableColumn":
4760
+ return [];
4761
+ case "SingleLineTextTableColumn":
4762
+ case "LongTextTableColumn":
4763
+ case "SingleSelectTableColumn":
4764
+ case "PhoneNumberTableColumn":
4765
+ case "EmailTableColumn":
4766
+ case "URLTableColumn":
4767
+ case "NumberTableColumn":
4768
+ default:
4769
+ return "";
4770
+ }
4771
+ }
4772
+ const CREATE_TABLE_RECORD = gql`
4773
+ mutation CreateTableRecord($input: CreateTableRecordInput!) {
4774
+ createTableRecord(input: $input) {
4775
+ tableRecord {
4776
+ id
4777
+ }
4778
+ }
4779
+ }
4780
+ `;
4781
+ const Form = forwardRef(function Form2({
4782
+ id,
4783
+ tableId,
4784
+ fields: fieldsProp,
4785
+ submitLabel = "Submit",
4786
+ submitLink,
4787
+ shape,
4788
+ size,
4789
+ contrast,
4790
+ brandColor,
4791
+ gap,
4792
+ width,
4793
+ margin,
4794
+ submitTextStyle,
4795
+ submitVariant,
4796
+ submitTextColor,
4797
+ submitWidth,
4798
+ submitAlignment,
4799
+ labelTextStyle,
4800
+ labelTextColor
4801
+ }, ref) {
4802
+ const fields = useMemo(() => {
4803
+ var _a;
4804
+ return (_a = fieldsProp == null ? void 0 : fieldsProp.fields) != null ? _a : [];
4805
+ }, [fieldsProp]);
4806
+ const grid = useMemo(() => {
4807
+ var _a;
4808
+ return (_a = fieldsProp == null ? void 0 : fieldsProp.grid) != null ? _a : [];
4809
+ }, [fieldsProp]);
4810
+ const {
4811
+ data: {
4812
+ table
4813
+ } = {}
4814
+ } = useTable(tableId);
4815
+ const [createTableRecord] = useMutation(CREATE_TABLE_RECORD);
4816
+ const [refEl, setRefEl] = useState(null);
4817
+ const [propControllers, setPropControllers] = useState(null);
4818
+ const [initialValues, setInitialValues] = useState(() => fields.reduce((acc, formField) => {
4819
+ const tableColumn = table && table.columns.find((field) => field.id === formField.tableColumnId);
4820
+ const defaultValue = formField ? formField.defaultValue : null;
4821
+ if (tableColumn) {
4822
+ acc[tableColumn.name] = defaultValue == null ? getTableColumnDefaultValue(tableColumn) : defaultValue;
4823
+ }
4824
+ return acc;
4825
+ }, {}));
4826
+ const controller = propControllers == null ? void 0 : propControllers.fields;
4827
+ const {
4828
+ container,
4829
+ items
4830
+ } = useTableFormFieldRefs(controller, {
4831
+ fieldsCount: fields.length
4832
+ });
4833
+ const [isDone, setIsDone] = useState(false);
4834
+ const linkRef = useRef(null);
4835
+ useImperativeHandle(ref, () => ({
4836
+ getBoxModel() {
4837
+ return refEl instanceof Element ? getBox(refEl) : null;
4838
+ },
4839
+ setPropControllers
4840
+ }), [refEl, setPropControllers]);
4841
+ useEffect(() => {
4842
+ container(refEl);
4843
+ }, [container, refEl]);
4844
+ useEffect(() => {
4845
+ if (!isDone)
4846
+ return;
4847
+ let timeoutId = setTimeout(() => setIsDone(false), 2500);
4848
+ return () => clearTimeout(timeoutId);
4849
+ }, [isDone]);
4850
+ function getTableColumn({
4851
+ tableColumnId
4852
+ }) {
4853
+ return table && table.columns.find((field) => tableColumnId === field.id);
4854
+ }
4855
+ async function handleSubmit(values, {
4856
+ setSubmitting,
4857
+ resetForm,
4858
+ setStatus
4859
+ }) {
4860
+ if (table) {
4861
+ const columns = [];
4862
+ fields.forEach((field) => {
4863
+ const tableColumn = getTableColumn(field);
4864
+ if (tableColumn) {
4865
+ const data = values[tableColumn.name];
4866
+ if (data) {
4867
+ columns.push({
4868
+ columnId: field.tableColumnId,
4869
+ data
4870
+ });
4871
+ if (field.autofill) {
4872
+ localStorage.setItem(`${LOCAL_STORAGE_NAMESPACE}/${tableColumn.name}`, JSON.stringify(data));
4873
+ }
4874
+ }
4875
+ }
4876
+ });
4877
+ try {
4878
+ await createTableRecord({
4879
+ variables: {
4880
+ input: {
4881
+ data: {
4882
+ tableId: table.id,
4883
+ columns
4884
+ }
4885
+ }
4886
+ }
4887
+ });
4888
+ setIsDone(true);
4889
+ setInitialValues((prev) => fields.reduce((acc, field) => {
4890
+ const tableColumn = getTableColumn(field);
4891
+ if (tableColumn) {
4892
+ const data = values[tableColumn.name];
4893
+ if (data && field.autofill)
4894
+ return __spreadProps(__spreadValues({}, acc), {
4895
+ [tableColumn.name]: data
4896
+ });
4897
+ }
4898
+ return acc;
4899
+ }, __spreadValues({}, prev)));
4900
+ resetForm();
4901
+ if (linkRef.current != null)
4902
+ linkRef.current.click();
4903
+ } catch (error) {
4904
+ setStatus({
4905
+ error: "An unexpected error has occurred, please try again later"
4906
+ });
4907
+ } finally {
4908
+ setSubmitting(false);
4909
+ }
4910
+ }
4911
+ }
4912
+ useEffect(() => {
4913
+ setInitialValues((prev) => fields.reduce((acc, formField) => {
4914
+ const tableColumn = table && table.columns.find((field) => field.id === formField.tableColumnId);
4915
+ if (tableColumn && formField.autofill) {
4916
+ const storedValue = localStorage.getItem(`${LOCAL_STORAGE_NAMESPACE}/${tableColumn.name}`);
4917
+ if (storedValue) {
4918
+ try {
4919
+ acc[tableColumn.name] = JSON.parse(storedValue);
4920
+ } catch (e) {
4921
+ }
4922
+ }
4923
+ }
4924
+ return acc;
4925
+ }, __spreadValues({}, prev)));
4926
+ }, [fields, table]);
4927
+ const brandColorData = useColor(brandColor);
4928
+ return /* @__PURE__ */ jsx(Provider, {
4929
+ value: {
4930
+ shape,
4931
+ size,
4932
+ contrast,
4933
+ brandColor: brandColorData,
4934
+ labelTextStyle,
4935
+ labelTextColor
4936
+ },
4937
+ children: tableId == null ? /* @__PURE__ */ jsx(Placeholder$1, {
4938
+ ref: setRefEl,
4939
+ width,
4940
+ margin
4941
+ }) : /* @__PURE__ */ jsx(Fragment, {
4942
+ children: /* @__PURE__ */ jsx(Formik, {
4943
+ onSubmit: handleSubmit,
4944
+ initialValues,
4945
+ initialStatus: {
4946
+ error: null
4947
+ },
4948
+ enableReinitialize: true,
4949
+ children: (formik) => {
4950
+ const error = formik.status && formik.status.error;
4951
+ const errors = fields.map((field) => {
4952
+ const tableColumn = getTableColumn(field);
4953
+ return tableColumn && getIn(formik.touched, tableColumn.name) && getIn(formik.errors, tableColumn.name);
4954
+ }).filter((message) => typeof message === "string");
4955
+ return /* @__PURE__ */ jsxs(Fragment, {
4956
+ children: [/* @__PURE__ */ jsxs(GridForm, {
4957
+ ref: setRefEl,
4958
+ id,
4959
+ width,
4960
+ margin,
4961
+ size,
4962
+ onSubmit: formik.handleSubmit,
4963
+ onReset: formik.handleReset,
4964
+ noValidate: true,
4965
+ children: [fields.map((field, index) => {
4966
+ const tableColumn = getTableColumn(field);
4967
+ return /* @__PURE__ */ jsx(GridItem$1, {
4968
+ ref: items[index],
4969
+ grid,
4970
+ index,
4971
+ rowGap: gap,
4972
+ columnGap: gap,
4973
+ children: /* @__PURE__ */ jsx(Field, {
4974
+ tableColumn,
4975
+ tableFormField: field
4976
+ })
4977
+ }, field.id);
4978
+ }), /* @__PURE__ */ jsxs(GridItem$1, {
4979
+ ref: items[fields.length],
4980
+ grid,
4981
+ index: fields.length,
4982
+ rowGap: gap,
4983
+ columnGap: gap,
4984
+ children: [/* @__PURE__ */ jsx(StyledButton, {
4985
+ type: "submit",
4986
+ disabled: formik.isSubmitting || isDone,
4987
+ shape,
4988
+ size,
4989
+ color: brandColor,
4990
+ variant: submitVariant,
4991
+ textColor: submitTextColor,
4992
+ width: submitWidth,
4993
+ alignment: submitAlignment,
4994
+ textStyle: submitTextStyle,
4995
+ children: formik.isSubmitting ? /* @__PURE__ */ jsx(Spinner, {}) : isDone ? /* @__PURE__ */ jsx(IconContainer, {
4996
+ children: /* @__PURE__ */ jsx(SvgCheck12, {})
4997
+ }) : submitLabel
4998
+ }), (errors.length > 0 || error) && /* @__PURE__ */ jsxs(ErrorContainer, {
4999
+ children: [errors.map((message) => /* @__PURE__ */ jsx(ErrorMessage, {
5000
+ children: message
5001
+ }, message)), error != null && /* @__PURE__ */ jsx(ErrorMessage, {
5002
+ children: error
5003
+ })]
5004
+ })]
5005
+ })]
5006
+ }), submitLink != null && /* @__PURE__ */ jsx(Link, {
5007
+ ref: linkRef,
5008
+ hidden: true,
5009
+ link: submitLink
5010
+ })]
5011
+ });
5012
+ }
5013
+ })
5014
+ })
5015
+ });
5016
+ });
5017
+ function registerComponent$4(runtime) {
5018
+ return runtime.registerComponent(Form, {
5019
+ type: "./components/Form/index.js",
5020
+ label: "Form",
5021
+ icon: "Form40",
5022
+ props: {
5023
+ id: ElementID(),
5024
+ tableId: Table(),
5025
+ fields: TableFormFields(),
5026
+ submitLink: Link$1({
5027
+ label: "Redirect to",
5028
+ options: [{
5029
+ value: "OPEN_PAGE",
5030
+ label: "Open page"
5031
+ }, {
5032
+ value: "OPEN_URL",
5033
+ label: "Open URL"
5034
+ }]
5035
+ }),
5036
+ gap: GapY({
5037
+ preset: [{
5038
+ deviceId: "desktop",
5039
+ value: {
5040
+ value: 10,
5041
+ unit: "px"
5042
+ }
5043
+ }],
5044
+ label: "Gap",
5045
+ defaultValue: {
5046
+ value: 0,
5047
+ unit: "px"
5048
+ }
5049
+ }),
5050
+ shape: ResponsiveIconRadioGroup({
5051
+ label: "Shape",
5052
+ options: [{
5053
+ label: "Pill",
5054
+ value: Shapes.PILL,
5055
+ icon: "ButtonPill16"
5056
+ }, {
5057
+ label: "Rounded",
5058
+ value: Shapes.ROUNDED,
5059
+ icon: "ButtonRounded16"
5060
+ }, {
5061
+ label: "Square",
5062
+ value: Shapes.SQUARE,
5063
+ icon: "ButtonSquare16"
5064
+ }],
5065
+ defaultValue: Shapes.ROUNDED
5066
+ }),
5067
+ size: ResponsiveIconRadioGroup({
5068
+ label: "Size",
5069
+ options: [{
5070
+ label: "Small",
5071
+ value: Sizes.SMALL,
5072
+ icon: "SizeSmall16"
5073
+ }, {
5074
+ label: "Medium",
5075
+ value: Sizes.MEDIUM,
5076
+ icon: "SizeMedium16"
5077
+ }, {
5078
+ label: "Large",
5079
+ value: Sizes.LARGE,
5080
+ icon: "SizeLarge16"
5081
+ }],
5082
+ defaultValue: Sizes.MEDIUM
5083
+ }),
5084
+ contrast: ResponsiveIconRadioGroup({
5085
+ label: "Color",
5086
+ options: [{
5087
+ label: "Light mode",
5088
+ value: Contrasts.LIGHT,
5089
+ icon: "Sun16"
5090
+ }, {
5091
+ label: "Dark mode",
5092
+ value: Contrasts.DARK,
5093
+ icon: "Moon16"
5094
+ }],
5095
+ defaultValue: Contrasts.LIGHT
5096
+ }),
5097
+ labelTextStyle: TextStyle({
5098
+ label: "Label text style"
5099
+ }),
5100
+ labelTextColor: ResponsiveColor({
5101
+ label: "Label text color"
5102
+ }),
5103
+ submitTextStyle: TextStyle({
5104
+ label: "Button text style"
5105
+ }),
5106
+ brandColor: ResponsiveColor({
5107
+ label: "Button color",
5108
+ placeholder: "black"
5109
+ }),
5110
+ submitTextColor: ResponsiveColor({
5111
+ label: "Button text color",
5112
+ placeholder: "white"
5113
+ }),
5114
+ submitLabel: TextInput({
5115
+ label: "Button label",
5116
+ placeholder: "Submit"
5117
+ }),
5118
+ submitVariant: ResponsiveSelect({
5119
+ label: "Button style",
5120
+ options: [{
5121
+ value: "flat",
5122
+ label: "Flat"
5123
+ }, {
5124
+ value: "outline",
5125
+ label: "Outline"
5126
+ }, {
5127
+ value: "shadow",
5128
+ label: "Floating"
5129
+ }, {
5130
+ value: "clear",
5131
+ label: "Clear"
5132
+ }, {
5133
+ value: "blocky",
5134
+ label: "Blocky"
5135
+ }, {
5136
+ value: "bubbly",
5137
+ label: "Bubbly"
5138
+ }, {
5139
+ value: "skewed",
5140
+ label: "Skewed"
5141
+ }],
5142
+ defaultValue: "flat"
5143
+ }),
5144
+ submitWidth: ResponsiveLength({
5145
+ label: "Button width"
5146
+ }),
5147
+ submitAlignment: ResponsiveIconRadioGroup({
5148
+ label: "Button alignment",
5149
+ options: [{
5150
+ label: "Left",
5151
+ value: Alignments.LEFT,
5152
+ icon: "AlignLeft16"
5153
+ }, {
5154
+ label: "Center",
5155
+ value: Alignments.CENTER,
5156
+ icon: "AlignCenter16"
5157
+ }, {
5158
+ label: "Right",
5159
+ value: Alignments.RIGHT,
5160
+ icon: "AlignRight16"
5161
+ }],
5162
+ defaultValue: Alignments.CENTER
5163
+ }),
5164
+ width: Width({
5165
+ preset: [{
5166
+ deviceId: "desktop",
5167
+ value: {
5168
+ value: 550,
5169
+ unit: "px"
5170
+ }
5171
+ }],
5172
+ defaultValue: {
5173
+ value: 100,
5174
+ unit: "%"
5175
+ }
5176
+ }),
5177
+ margin: Margin()
5178
+ }
5179
+ });
5180
+ }
5181
+ var _path$r;
5182
+ function _extends$r() {
5183
+ _extends$r = Object.assign || function(target) {
5184
+ for (var i = 1; i < arguments.length; i++) {
5185
+ var source = arguments[i];
5186
+ for (var key in source) {
5187
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
5188
+ target[key] = source[key];
5189
+ }
5190
+ }
5191
+ }
5192
+ return target;
5193
+ };
5194
+ return _extends$r.apply(this, arguments);
5195
+ }
5196
+ var SvgMobileMenu28 = function SvgMobileMenu282(props) {
5197
+ return /* @__PURE__ */ React.createElement("svg", _extends$r({
5198
+ xmlns: "http://www.w3.org/2000/svg",
5199
+ width: 28,
5200
+ height: 28
5201
+ }, props), _path$r || (_path$r = /* @__PURE__ */ React.createElement("path", {
5202
+ d: "M27 15H1a1 1 0 0 1-1-1 1 1 0 0 1 1-1h26a1 1 0 0 1 1 1 1 1 0 0 1-1 1zm0-10H1a1 1 0 0 0-1 1 1 1 0 0 0 1 1h26a1 1 0 0 0 1-1 1 1 0 0 0-1-1zm0 16H1a1 1 0 0 0-1 1 1 1 0 0 0 1 1h26a1 1 0 0 0 1-1 1 1 0 0 0-1-1z"
5203
+ })));
5204
+ };
5205
+ const GutterContainer = styled.div`
5206
+ ${(p) => cssMediaRules([p.gutter], ([gutter = {
5207
+ value: 0,
5208
+ unit: "px"
5209
+ }]) => css`
5210
+ padding-left: ${p.first ? "0px" : `${gutter.value / 2}${gutter.unit}`};
5211
+ padding-right: ${p.last ? "0px" : `${gutter.value / 2}${gutter.unit}`};
5212
+ `)}
5213
+ `;
5214
+ const PlaceholderLink$1 = styled.div`
5215
+ width: ${(props) => props.width}px;
5216
+ height: ${(props) => props.button === true ? 32 : 8}px;
5217
+ background-color: #a1a8c2;
5218
+ border-radius: ${(props) => props.button === true ? 6 : 2}px;
5219
+ opacity: 0.4;
5220
+ `;
5221
+ const links$1 = [{
5222
+ width: 50
5223
+ }, {
5224
+ width: 70
5225
+ }, {
5226
+ width: 60
5227
+ }, {
5228
+ width: 80,
5229
+ button: true
5230
+ }];
5231
+ function LinksPlaceholder({
5232
+ gutter
5233
+ }) {
5234
+ return /* @__PURE__ */ jsx(Fragment, {
5235
+ children: links$1.map((link, i) => /* @__PURE__ */ jsx(GutterContainer, {
5236
+ gutter,
5237
+ first: i === 0,
5238
+ last: i === links$1.length - 1,
5239
+ children: /* @__PURE__ */ jsx(PlaceholderLink$1, __spreadValues({}, link))
5240
+ }, i))
5241
+ });
5242
+ }
5243
+ var _path$q;
5244
+ function _extends$q() {
5245
+ _extends$q = Object.assign || function(target) {
5246
+ for (var i = 1; i < arguments.length; i++) {
5247
+ var source = arguments[i];
5248
+ for (var key in source) {
5249
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
5250
+ target[key] = source[key];
5251
+ }
5252
+ }
5253
+ }
5254
+ return target;
5255
+ };
5256
+ return _extends$q.apply(this, arguments);
5257
+ }
5258
+ var SvgCaretDown8 = function SvgCaretDown82(props) {
5259
+ return /* @__PURE__ */ React.createElement("svg", _extends$q({
5260
+ width: 8,
5261
+ height: 8,
5262
+ xmlns: "http://www.w3.org/2000/svg"
5263
+ }, props), _path$q || (_path$q = /* @__PURE__ */ React.createElement("path", {
5264
+ d: "M1 2a1 1 0 0 0-.707 1.707l3 3a1 1 0 0 0 1.414 0l3-3A1 1 0 0 0 7 2H1z"
5265
+ })));
5266
+ };
5267
+ var _path$p;
5268
+ function _extends$p() {
5269
+ _extends$p = Object.assign || function(target) {
5270
+ for (var i = 1; i < arguments.length; i++) {
5271
+ var source = arguments[i];
5272
+ for (var key in source) {
5273
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
5274
+ target[key] = source[key];
3668
5275
  }
3669
5276
  }
3670
5277
  }
@@ -3800,22 +5407,22 @@ const StyledDropDownItem = styled(Link)`
3800
5407
  background-color: rgba(0, 0, 0, 0.04);
3801
5408
  }
3802
5409
  `;
3803
- function DropDownItem$1(_o) {
3804
- var _p = _o, {
5410
+ function DropDownItem$1(_S) {
5411
+ var _T = _S, {
3805
5412
  color
3806
- } = _p, restOfProps = __objRest(_p, [
5413
+ } = _T, restOfProps = __objRest(_T, [
3807
5414
  "color"
3808
5415
  ]);
3809
5416
  return /* @__PURE__ */ jsx(StyledDropDownItem, __spreadProps(__spreadValues({}, restOfProps), {
3810
5417
  color: useColor(color)
3811
5418
  }));
3812
5419
  }
3813
- function DropDownButton(_q) {
3814
- var _r = _q, {
5420
+ function DropDownButton(_U) {
5421
+ var _V = _U, {
3815
5422
  label,
3816
5423
  caret = "caret",
3817
5424
  links: links2 = []
3818
- } = _r, restOfProps = __objRest(_r, [
5425
+ } = _V, restOfProps = __objRest(_V, [
3819
5426
  "label",
3820
5427
  "caret",
3821
5428
  "links"
@@ -3831,7 +5438,7 @@ function DropDownButton(_q) {
3831
5438
  }, [setPosition]);
3832
5439
  return /* @__PURE__ */ jsxs(DropDownContainer, {
3833
5440
  ref: container,
3834
- children: [/* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({}, restOfProps), {
5441
+ children: [/* @__PURE__ */ jsx(Button$1, __spreadProps(__spreadValues({}, restOfProps), {
3835
5442
  children: /* @__PURE__ */ jsxs("div", {
3836
5443
  style: {
3837
5444
  display: "flex",
@@ -3892,7 +5499,7 @@ const DropDownMenu = styled.div`
3892
5499
  flex-direction: column;
3893
5500
  padding: 8px;
3894
5501
  `;
3895
- const ButtonLink$1 = styled(Button)`
5502
+ const ButtonLink$1 = styled(Button$1)`
3896
5503
  margin: 8px 0;
3897
5504
  `;
3898
5505
  const StyledLink$2 = styled(Link)`
@@ -3905,24 +5512,24 @@ const StyledLink$2 = styled(Link)`
3905
5512
  color: ${color == null ? "black" : colorToString(color)};
3906
5513
  `)}
3907
5514
  `;
3908
- function DropDownItem(_s) {
3909
- var _t = _s, {
5515
+ function DropDownItem(_W) {
5516
+ var _X = _W, {
3910
5517
  color
3911
- } = _t, restOfProps = __objRest(_t, [
5518
+ } = _X, restOfProps = __objRest(_X, [
3912
5519
  "color"
3913
5520
  ]);
3914
5521
  return /* @__PURE__ */ jsx(StyledLink$2, __spreadProps(__spreadValues({}, restOfProps), {
3915
5522
  color: useColor(color)
3916
5523
  }));
3917
5524
  }
3918
- function MobileDropDownButton(_u) {
3919
- var _v = _u, {
5525
+ function MobileDropDownButton(_Y) {
5526
+ var _Z = _Y, {
3920
5527
  label,
3921
5528
  caret,
3922
5529
  links: links2 = [],
3923
5530
  onClose = () => {
3924
5531
  }
3925
- } = _v, restOfProps = __objRest(_v, [
5532
+ } = _Z, restOfProps = __objRest(_Z, [
3926
5533
  "label",
3927
5534
  "caret",
3928
5535
  "links",
@@ -3964,7 +5571,7 @@ function MobileDropDownButton(_u) {
3964
5571
  })]
3965
5572
  });
3966
5573
  }
3967
- const ButtonLink = styled(Button)`
5574
+ const ButtonLink = styled(Button$1)`
3968
5575
  margin: 8px 0;
3969
5576
  `;
3970
5577
  const Container$2 = styled.div`
@@ -4129,7 +5736,7 @@ const Navigation = forwardRef(function Navigation2({
4129
5736
  gutter,
4130
5737
  first: i === 0,
4131
5738
  last: i === links2.length - 1,
4132
- children: [link.type === "button" && /* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({}, link.payload), {
5739
+ children: [link.type === "button" && /* @__PURE__ */ jsx(Button$1, __spreadProps(__spreadValues({}, link.payload), {
4133
5740
  children: link.payload.label
4134
5741
  })), link.type === "dropdown" && /* @__PURE__ */ jsx(DropDownButton, __spreadValues({}, link.payload))]
4135
5742
  }, link.id)) : /* @__PURE__ */ jsx(LinksPlaceholder, {
@@ -4163,7 +5770,7 @@ function registerComponent$3(runtime) {
4163
5770
  linkTextStyle: TextStyle({
4164
5771
  label: "Link text style"
4165
5772
  }),
4166
- showLogo: Checkbox({
5773
+ showLogo: Checkbox$1({
4167
5774
  preset: true,
4168
5775
  label: "Show logo"
4169
5776
  }),
@@ -4256,7 +5863,7 @@ const PlaceholderBase = styled.div`
4256
5863
  height: 80px;
4257
5864
  padding: 8px;
4258
5865
  `;
4259
- var Placeholder2 = forwardRef(function Placeholder3(props, ref) {
5866
+ var Placeholder3 = forwardRef(function Placeholder4(props, ref) {
4260
5867
  return /* @__PURE__ */ jsx(PlaceholderBase, __spreadProps(__spreadValues({}, props), {
4261
5868
  ref,
4262
5869
  children: /* @__PURE__ */ jsx("svg", {
@@ -4324,7 +5931,7 @@ const Root = forwardRef(function Page2({
4324
5931
  children: /* @__PURE__ */ jsx(Element$1, {
4325
5932
  element: child
4326
5933
  })
4327
- }, child.key)) : /* @__PURE__ */ jsx(Placeholder2, {})
5934
+ }, child.key)) : /* @__PURE__ */ jsx(Placeholder3, {})
4328
5935
  })
4329
5936
  })]
4330
5937
  });
@@ -5374,10 +6981,10 @@ const Span = styled.span`
5374
6981
  `}
5375
6982
  `, shallowMergeFallbacks)}
5376
6983
  `;
5377
- function Mark(_w) {
5378
- var _x = _w, {
6984
+ function Mark(__) {
6985
+ var _$ = __, {
5379
6986
  value
5380
- } = _x, restOfProps = __objRest(_x, [
6987
+ } = _$, restOfProps = __objRest(_$, [
5381
6988
  "value"
5382
6989
  ]);
5383
6990
  const typographyStyle = useTypographyMark(value);
@@ -5415,10 +7022,10 @@ const StyledBlock = styled.div`
5415
7022
  border-left: 5px solid rgba(0, 0, 0, 0.1);
5416
7023
  ` : ""}
5417
7024
  `;
5418
- var Block = forwardRef(function Block2(_y, ref) {
5419
- var _z = _y, {
7025
+ var Block = forwardRef(function Block2(_aa, ref) {
7026
+ var _ba = _aa, {
5420
7027
  textAlign
5421
- } = _z, restOfProps = __objRest(_z, [
7028
+ } = _ba, restOfProps = __objRest(_ba, [
5422
7029
  "textAlign"
5423
7030
  ]);
5424
7031
  return /* @__PURE__ */ jsx(StyledBlock, __spreadProps(__spreadValues({}, restOfProps), {
@@ -5543,10 +7150,10 @@ function Inlines() {
5543
7150
  }
5544
7151
  };
5545
7152
  }
5546
- const RichTextEditor = styled(forwardRef(function RichTextEditor2(_A, ref) {
5547
- var _B = _A, {
7153
+ const RichTextEditor = styled(forwardRef(function RichTextEditor2(_ca, ref) {
7154
+ var _da = _ca, {
5548
7155
  placeholder: placeholder2 = "Write some text..."
5549
- } = _B, restOfProps = __objRest(_B, [
7156
+ } = _da, restOfProps = __objRest(_da, [
5550
7157
  "placeholder"
5551
7158
  ]);
5552
7159
  const plugins = useMemo(() => [Lists(), LinkPlugin(), Inlines(), DeviceOverridesBlockPlugin(), DeviceOverridesMarksPlugin()], []);
@@ -5742,13 +7349,14 @@ function registerComponent(runtime) {
5742
7349
  });
5743
7350
  }
5744
7351
  function registerBuiltinComponents(runtime) {
5745
- const unregisterBoxComponent = registerComponent$a(runtime);
5746
- const unregisterButtonComponent = registerComponent$9(runtime);
5747
- const unregisterCarouselComponent = registerComponent$7(runtime);
5748
- const unregisterCountdownComponent = registerComponent$6(runtime);
5749
- const unregisterDividerComponent = registerComponent$5(runtime);
5750
- const unregisterEmbedComponent = registerComponent$4(runtime);
5751
- const unregisterImageComponent = registerComponent$8(runtime);
7352
+ const unregisterBoxComponent = registerComponent$b(runtime);
7353
+ const unregisterButtonComponent = registerComponent$a(runtime);
7354
+ const unregisterCarouselComponent = registerComponent$8(runtime);
7355
+ const unregisterCountdownComponent = registerComponent$7(runtime);
7356
+ const unregisterDividerComponent = registerComponent$6(runtime);
7357
+ const unregisterEmbedComponent = registerComponent$5(runtime);
7358
+ const unregisterFormComponent = registerComponent$4(runtime);
7359
+ const unregisterImageComponent = registerComponent$9(runtime);
5752
7360
  const unregisterNavigationComponent = registerComponent$3(runtime);
5753
7361
  const unregisterRootComponent = registerComponent$2(runtime);
5754
7362
  const unregisterSocialLinksComponent = registerComponent$1(runtime);
@@ -5760,6 +7368,7 @@ function registerBuiltinComponents(runtime) {
5760
7368
  unregisterCountdownComponent();
5761
7369
  unregisterDividerComponent();
5762
7370
  unregisterEmbedComponent();
7371
+ unregisterFormComponent();
5763
7372
  unregisterImageComponent();
5764
7373
  unregisterNavigationComponent();
5765
7374
  unregisterRootComponent();
@@ -5867,6 +7476,25 @@ function RuntimeProvider({
5867
7476
  })
5868
7477
  });
5869
7478
  }
7479
+ const PageContext = createContext(null);
7480
+ function usePageIdOrNull() {
7481
+ return useContext(PageContext);
7482
+ }
7483
+ function usePageId() {
7484
+ const pageIdOrNull = usePageIdOrNull();
7485
+ if (pageIdOrNull == null)
7486
+ throw new Error("`usePageId` must be used with `<PageProvider>`");
7487
+ return pageIdOrNull;
7488
+ }
7489
+ function PageProvider({
7490
+ id,
7491
+ children
7492
+ }) {
7493
+ return /* @__PURE__ */ jsx(PageContext.Provider, {
7494
+ value: id,
7495
+ children
7496
+ });
7497
+ }
5870
7498
  const DocumentContext = createContext(null);
5871
7499
  function useDocumentKey() {
5872
7500
  return useContext(DocumentContext);
@@ -5882,8 +7510,8 @@ function useElementId(elementKey) {
5882
7510
  const documentKey = useDocumentKey();
5883
7511
  return useSelector((state) => documentKey == null || elementKey == null ? null : getElementId(state, documentKey, elementKey));
5884
7512
  }
5885
- function useDocumentRootElement(documentKey) {
5886
- return useSelector((state) => getDocumentRootElement(state, documentKey));
7513
+ function useDocument(documentKey) {
7514
+ return useSelector((state) => getDocument(state, documentKey));
5887
7515
  }
5888
7516
  function useIsInBuilder() {
5889
7517
  return useSelector((state) => getIsInBuilder(state));
@@ -5916,24 +7544,64 @@ const ElementData = memo(forwardRef(function ElementData2({
5916
7544
  const ElementReference = memo(forwardRef(function ElementReference2({
5917
7545
  elementReference
5918
7546
  }, ref) {
5919
- return /* @__PURE__ */ jsxs("div", {
5920
- ref,
5921
- children: [/* @__PURE__ */ jsx("p", {
5922
- children: "Not Implemented"
5923
- }), /* @__PURE__ */ jsx("pre", {
5924
- children: /* @__PURE__ */ jsx("code", {
5925
- children: JSON.stringify(elementReference, null, 2)
5926
- })
5927
- })]
7547
+ var _a;
7548
+ const {
7549
+ error,
7550
+ data
7551
+ } = useQuery(gql`
7552
+ query ElementReferenceGlobalElement($id: ID!) {
7553
+ globalElement(id: $id) {
7554
+ id
7555
+ data
7556
+ }
7557
+ }
7558
+ `, {
7559
+ variables: {
7560
+ id: elementReference.value
7561
+ }
7562
+ });
7563
+ const globalElementData = (_a = data == null ? void 0 : data.globalElement) == null ? void 0 : _a.data;
7564
+ const elementReferenceDocument = useDocument(elementReference.key);
7565
+ if (error != null) {
7566
+ return /* @__PURE__ */ jsxs("div", {
7567
+ ref,
7568
+ children: [/* @__PURE__ */ jsx("p", {
7569
+ children: "Something went wrong!"
7570
+ }), /* @__PURE__ */ jsx("pre", {
7571
+ children: /* @__PURE__ */ jsx("code", {
7572
+ children: JSON.stringify(error, null, 2)
7573
+ })
7574
+ })]
7575
+ });
7576
+ }
7577
+ if (globalElementData == null) {
7578
+ return /* @__PURE__ */ jsxs("div", {
7579
+ ref,
7580
+ children: [/* @__PURE__ */ jsx("p", {
7581
+ children: "Not Found"
7582
+ }), /* @__PURE__ */ jsx("pre", {
7583
+ children: /* @__PURE__ */ jsx("code", {
7584
+ children: JSON.stringify(elementReference, null, 2)
7585
+ })
7586
+ })]
7587
+ });
7588
+ }
7589
+ return elementReferenceDocument != null ? /* @__PURE__ */ jsx(Document, {
7590
+ document: elementReferenceDocument,
7591
+ ref
7592
+ }) : /* @__PURE__ */ jsx(ElementData, {
7593
+ elementData: globalElementData,
7594
+ ref
5928
7595
  });
5929
7596
  }));
5930
- const Element$1 = memo(function Element2({
7597
+ const Element$1 = memo(forwardRef(function Element2({
5931
7598
  element
5932
- }) {
7599
+ }, ref) {
5933
7600
  const elementKey = element.key;
5934
7601
  const dispatch = useDispatch();
5935
7602
  const documentKey = useDocumentKey();
5936
7603
  const [handle, setHandle] = useState(null);
7604
+ useImperativeHandle(ref, () => handle, [handle]);
5937
7605
  useEffect(() => {
5938
7606
  if (documentKey == null)
5939
7607
  return;
@@ -5951,30 +7619,38 @@ const Element$1 = memo(function Element2({
5951
7619
  ref: setHandle,
5952
7620
  elementData: element
5953
7621
  }, elementKey);
5954
- });
5955
- const Document = memo(function Document2({
5956
- documentKey
5957
- }) {
5958
- const documentRootElement = useDocumentRootElement(documentKey);
5959
- if (documentRootElement == null) {
7622
+ }));
7623
+ const Document = memo(forwardRef(function Document2({
7624
+ document
7625
+ }, ref) {
7626
+ return /* @__PURE__ */ jsx(DocumentContext.Provider, {
7627
+ value: document.key,
7628
+ children: /* @__PURE__ */ jsx(Element$1, {
7629
+ ref,
7630
+ element: document.rootElement
7631
+ })
7632
+ });
7633
+ }));
7634
+ const DocumentReference = memo(forwardRef(function DocumentReference2({
7635
+ documentReference
7636
+ }, ref) {
7637
+ const document = useDocument(documentReference.key);
7638
+ if (document == null) {
5960
7639
  return /* @__PURE__ */ jsxs("div", {
7640
+ ref,
5961
7641
  children: [/* @__PURE__ */ jsx("p", {
5962
7642
  children: "Document Not Found"
5963
7643
  }), /* @__PURE__ */ jsx("pre", {
5964
7644
  children: /* @__PURE__ */ jsx("code", {
5965
- children: JSON.stringify({
5966
- documentKey
5967
- }, null, 2)
7645
+ children: JSON.stringify(documentReference, null, 2)
5968
7646
  })
5969
7647
  })]
5970
7648
  });
5971
7649
  }
5972
- return /* @__PURE__ */ jsx(DocumentContext.Provider, {
5973
- value: documentKey,
5974
- children: /* @__PURE__ */ jsx(Element$1, {
5975
- element: documentRootElement
5976
- })
7650
+ return /* @__PURE__ */ jsx(Document, {
7651
+ ref,
7652
+ document
5977
7653
  });
5978
- });
5979
- export { getDocumentRootElement$1 as A, Box as B, Carousel as C, Document as D, Element$1 as E, createDocument as F, reducer$3 as G, reducer$2 as H, ImageComponent as I, reducer$1 as J, getComponentsMeta as K, getComponentPropControllerDescriptors$1 as L, getElementPropControllerDescriptors as M, Navigation as N, RuntimeProvider as R, SocialLinks as S, Text as T, ReactRuntime as a, Button as b, Countdown as c, Divider as d, Embed as e, Root as f, registerComponent$a as g, DEFAULT_BOX_ANIMATE_TYPE as h, DEFAULT_BOX_ANIMATE_DELAY as i, DEFAULT_BOX_ANIMATE_DURATION as j, DEFAULT_ITEM_ANIMATE_TYPE as k, DEFAULT_ITEM_ANIMATE_DELAY as l, DEFAULT_ITEM_ANIMATE_DURATION as m, DEFAULT_ITEM_STAGGER_DURATION as n, cssMediaRules as o, cssWidth as p, cssMargin as q, registerBuiltinComponents as r, cssPadding as s, cssBorder as t, useIsInBuilder as u, cssBorderRadius as v, cssBoxShadow as w, cssGridItem as x, cssTextStyle as y, getInitialState$3 as z };
7654
+ }));
7655
+ export { Box as B, Carousel as C, DocumentReference as D, Element$1 as E, Form as F, ImageComponent as I, Navigation as N, PageProvider as P, RuntimeProvider as R, SocialLinks as S, Text as T, ReactRuntime as a, usePageId as b, Button$1 as c, Countdown as d, Divider as e, Embed as f, Root as g, registerComponent$b as h, DEFAULT_BOX_ANIMATE_TYPE as i, DEFAULT_BOX_ANIMATE_DELAY as j, DEFAULT_BOX_ANIMATE_DURATION as k, DEFAULT_ITEM_ANIMATE_TYPE as l, DEFAULT_ITEM_ANIMATE_DELAY as m, DEFAULT_ITEM_ANIMATE_DURATION as n, DEFAULT_ITEM_STAGGER_DURATION as o, cssMediaRules as p, cssWidth as q, registerBuiltinComponents as r, cssMargin as s, cssPadding as t, useIsInBuilder as u, cssBorder as v, cssBorderRadius as w, cssBoxShadow as x, cssGridItem as y, cssTextStyle as z };
5980
7656
  //# sourceMappingURL=react.es2.js.map