@01.software/sdk 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __defProps = Object.defineProperties;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
9
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
10
  var __pow = Math.pow;
@@ -47,14 +45,6 @@ var __copyProps = (to, from, except, desc) => {
47
45
  }
48
46
  return to;
49
47
  };
50
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
51
- // If the importer is in node compatibility mode or this is not an ESM
52
- // file that has been converted to a CommonJS file using a Babel-
53
- // compatible transform (i.e. "__esModule" has not been set), then set
54
- // "default" to the CommonJS "module.exports" for node compatibility.
55
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
- mod
57
- ));
58
48
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
59
49
  var __async = (__this, __arguments, generator) => {
60
50
  return new Promise((resolve, reject) => {
@@ -88,14 +78,11 @@ __export(src_exports, {
88
78
  CollectionQueryBuilder: () => CollectionQueryBuilder,
89
79
  ConfigError: () => ConfigError,
90
80
  CustomerAuth: () => CustomerAuth,
91
- FormRenderer: () => FormRenderer,
92
81
  IMAGE_SIZES: () => IMAGE_SIZES,
93
- Image: () => Image,
94
82
  NetworkError: () => NetworkError,
95
83
  OrderApi: () => OrderApi,
96
84
  ProductApi: () => ProductApi,
97
85
  QueryHooks: () => QueryHooks,
98
- RichTextContent: () => RichTextContent,
99
86
  ServerClient: () => ServerClient,
100
87
  TimeoutError: () => TimeoutError,
101
88
  UsageLimitError: () => UsageLimitError,
@@ -128,7 +115,6 @@ __export(src_exports, {
128
115
  objectFor: () => objectFor,
129
116
  parseApiKey: () => parseApiKey,
130
117
  resolveRelation: () => resolveRelation,
131
- toSubmissionData: () => toSubmissionData,
132
118
  verifyServerToken: () => verifyServerToken
133
119
  });
134
120
  module.exports = __toCommonJS(src_exports);
@@ -1976,649 +1962,4 @@ var formatOrderName = (options) => {
1976
1962
  const firstTitle = ((_b = resolveRelation((_a = options[0]) == null ? void 0 : _a.product)) == null ? void 0 : _b.title) || "";
1977
1963
  return options.length === 1 ? firstTitle : `${firstTitle} \uC678 ${options.length - 1}\uAC74`;
1978
1964
  };
1979
-
1980
- // src/components/RichTextContent/index.tsx
1981
- var import_react = __toESM(require("react"), 1);
1982
- var import_react2 = require("@payloadcms/richtext-lexical/react");
1983
- function RichTextContent({
1984
- data,
1985
- className,
1986
- internalDocToHref,
1987
- blocks
1988
- }) {
1989
- return /* @__PURE__ */ import_react.default.createElement(
1990
- import_react2.RichText,
1991
- {
1992
- data,
1993
- className,
1994
- converters: __spreadProps(__spreadValues(__spreadValues({}, import_react2.defaultJSXConverters), (0, import_react2.LinkJSXConverter)({
1995
- internalDocToHref
1996
- })), {
1997
- blocks: blocks ? blocks : void 0
1998
- })
1999
- }
2000
- );
2001
- }
2002
-
2003
- // src/components/FormRenderer/index.tsx
2004
- var import_react3 = __toESM(require("react"), 1);
2005
-
2006
- // src/components/FormRenderer/countries.ts
2007
- var COUNTRIES = [
2008
- { value: "AF", label: "Afghanistan" },
2009
- { value: "AX", label: "\xC5land Islands" },
2010
- { value: "AL", label: "Albania" },
2011
- { value: "DZ", label: "Algeria" },
2012
- { value: "AS", label: "American Samoa" },
2013
- { value: "AD", label: "Andorra" },
2014
- { value: "AO", label: "Angola" },
2015
- { value: "AI", label: "Anguilla" },
2016
- { value: "AQ", label: "Antarctica" },
2017
- { value: "AG", label: "Antigua and Barbuda" },
2018
- { value: "AR", label: "Argentina" },
2019
- { value: "AM", label: "Armenia" },
2020
- { value: "AW", label: "Aruba" },
2021
- { value: "AU", label: "Australia" },
2022
- { value: "AT", label: "Austria" },
2023
- { value: "AZ", label: "Azerbaijan" },
2024
- { value: "BS", label: "Bahamas" },
2025
- { value: "BH", label: "Bahrain" },
2026
- { value: "BD", label: "Bangladesh" },
2027
- { value: "BB", label: "Barbados" },
2028
- { value: "BY", label: "Belarus" },
2029
- { value: "BE", label: "Belgium" },
2030
- { value: "BZ", label: "Belize" },
2031
- { value: "BJ", label: "Benin" },
2032
- { value: "BM", label: "Bermuda" },
2033
- { value: "BT", label: "Bhutan" },
2034
- { value: "BO", label: "Bolivia" },
2035
- { value: "BA", label: "Bosnia and Herzegovina" },
2036
- { value: "BW", label: "Botswana" },
2037
- { value: "BV", label: "Bouvet Island" },
2038
- { value: "BR", label: "Brazil" },
2039
- { value: "IO", label: "British Indian Ocean Territory" },
2040
- { value: "BN", label: "Brunei Darussalam" },
2041
- { value: "BG", label: "Bulgaria" },
2042
- { value: "BF", label: "Burkina Faso" },
2043
- { value: "BI", label: "Burundi" },
2044
- { value: "KH", label: "Cambodia" },
2045
- { value: "CM", label: "Cameroon" },
2046
- { value: "CA", label: "Canada" },
2047
- { value: "CV", label: "Cape Verde" },
2048
- { value: "KY", label: "Cayman Islands" },
2049
- { value: "CF", label: "Central African Republic" },
2050
- { value: "TD", label: "Chad" },
2051
- { value: "CL", label: "Chile" },
2052
- { value: "CN", label: "China" },
2053
- { value: "CX", label: "Christmas Island" },
2054
- { value: "CC", label: "Cocos (Keeling) Islands" },
2055
- { value: "CO", label: "Colombia" },
2056
- { value: "KM", label: "Comoros" },
2057
- { value: "CG", label: "Congo" },
2058
- { value: "CD", label: "Congo, Democratic Republic" },
2059
- { value: "CK", label: "Cook Islands" },
2060
- { value: "CR", label: "Costa Rica" },
2061
- { value: "CI", label: "C\xF4te d'Ivoire" },
2062
- { value: "HR", label: "Croatia" },
2063
- { value: "CU", label: "Cuba" },
2064
- { value: "CY", label: "Cyprus" },
2065
- { value: "CZ", label: "Czech Republic" },
2066
- { value: "DK", label: "Denmark" },
2067
- { value: "DJ", label: "Djibouti" },
2068
- { value: "DM", label: "Dominica" },
2069
- { value: "DO", label: "Dominican Republic" },
2070
- { value: "EC", label: "Ecuador" },
2071
- { value: "EG", label: "Egypt" },
2072
- { value: "SV", label: "El Salvador" },
2073
- { value: "GQ", label: "Equatorial Guinea" },
2074
- { value: "ER", label: "Eritrea" },
2075
- { value: "EE", label: "Estonia" },
2076
- { value: "ET", label: "Ethiopia" },
2077
- { value: "FK", label: "Falkland Islands" },
2078
- { value: "FO", label: "Faroe Islands" },
2079
- { value: "FJ", label: "Fiji" },
2080
- { value: "FI", label: "Finland" },
2081
- { value: "FR", label: "France" },
2082
- { value: "GF", label: "French Guiana" },
2083
- { value: "PF", label: "French Polynesia" },
2084
- { value: "TF", label: "French Southern Territories" },
2085
- { value: "GA", label: "Gabon" },
2086
- { value: "GM", label: "Gambia" },
2087
- { value: "GE", label: "Georgia" },
2088
- { value: "DE", label: "Germany" },
2089
- { value: "GH", label: "Ghana" },
2090
- { value: "GI", label: "Gibraltar" },
2091
- { value: "GR", label: "Greece" },
2092
- { value: "GL", label: "Greenland" },
2093
- { value: "GD", label: "Grenada" },
2094
- { value: "GP", label: "Guadeloupe" },
2095
- { value: "GU", label: "Guam" },
2096
- { value: "GT", label: "Guatemala" },
2097
- { value: "GG", label: "Guernsey" },
2098
- { value: "GN", label: "Guinea" },
2099
- { value: "GW", label: "Guinea-Bissau" },
2100
- { value: "GY", label: "Guyana" },
2101
- { value: "HT", label: "Haiti" },
2102
- { value: "VA", label: "Holy See (Vatican)" },
2103
- { value: "HN", label: "Honduras" },
2104
- { value: "HK", label: "Hong Kong" },
2105
- { value: "HU", label: "Hungary" },
2106
- { value: "IS", label: "Iceland" },
2107
- { value: "IN", label: "India" },
2108
- { value: "ID", label: "Indonesia" },
2109
- { value: "IR", label: "Iran" },
2110
- { value: "IQ", label: "Iraq" },
2111
- { value: "IE", label: "Ireland" },
2112
- { value: "IM", label: "Isle of Man" },
2113
- { value: "IL", label: "Israel" },
2114
- { value: "IT", label: "Italy" },
2115
- { value: "JM", label: "Jamaica" },
2116
- { value: "JP", label: "Japan" },
2117
- { value: "JE", label: "Jersey" },
2118
- { value: "JO", label: "Jordan" },
2119
- { value: "KZ", label: "Kazakhstan" },
2120
- { value: "KE", label: "Kenya" },
2121
- { value: "KI", label: "Kiribati" },
2122
- { value: "KP", label: "Korea, North" },
2123
- { value: "KR", label: "Korea, South" },
2124
- { value: "KW", label: "Kuwait" },
2125
- { value: "KG", label: "Kyrgyzstan" },
2126
- { value: "LA", label: "Laos" },
2127
- { value: "LV", label: "Latvia" },
2128
- { value: "LB", label: "Lebanon" },
2129
- { value: "LS", label: "Lesotho" },
2130
- { value: "LR", label: "Liberia" },
2131
- { value: "LY", label: "Libya" },
2132
- { value: "LI", label: "Liechtenstein" },
2133
- { value: "LT", label: "Lithuania" },
2134
- { value: "LU", label: "Luxembourg" },
2135
- { value: "MO", label: "Macao" },
2136
- { value: "MK", label: "North Macedonia" },
2137
- { value: "MG", label: "Madagascar" },
2138
- { value: "MW", label: "Malawi" },
2139
- { value: "MY", label: "Malaysia" },
2140
- { value: "MV", label: "Maldives" },
2141
- { value: "ML", label: "Mali" },
2142
- { value: "MT", label: "Malta" },
2143
- { value: "MH", label: "Marshall Islands" },
2144
- { value: "MQ", label: "Martinique" },
2145
- { value: "MR", label: "Mauritania" },
2146
- { value: "MU", label: "Mauritius" },
2147
- { value: "YT", label: "Mayotte" },
2148
- { value: "MX", label: "Mexico" },
2149
- { value: "FM", label: "Micronesia" },
2150
- { value: "MD", label: "Moldova" },
2151
- { value: "MC", label: "Monaco" },
2152
- { value: "MN", label: "Mongolia" },
2153
- { value: "ME", label: "Montenegro" },
2154
- { value: "MS", label: "Montserrat" },
2155
- { value: "MA", label: "Morocco" },
2156
- { value: "MZ", label: "Mozambique" },
2157
- { value: "MM", label: "Myanmar" },
2158
- { value: "NA", label: "Namibia" },
2159
- { value: "NR", label: "Nauru" },
2160
- { value: "NP", label: "Nepal" },
2161
- { value: "NL", label: "Netherlands" },
2162
- { value: "NC", label: "New Caledonia" },
2163
- { value: "NZ", label: "New Zealand" },
2164
- { value: "NI", label: "Nicaragua" },
2165
- { value: "NE", label: "Niger" },
2166
- { value: "NG", label: "Nigeria" },
2167
- { value: "NU", label: "Niue" },
2168
- { value: "NF", label: "Norfolk Island" },
2169
- { value: "MP", label: "Northern Mariana Islands" },
2170
- { value: "NO", label: "Norway" },
2171
- { value: "OM", label: "Oman" },
2172
- { value: "PK", label: "Pakistan" },
2173
- { value: "PW", label: "Palau" },
2174
- { value: "PS", label: "Palestine" },
2175
- { value: "PA", label: "Panama" },
2176
- { value: "PG", label: "Papua New Guinea" },
2177
- { value: "PY", label: "Paraguay" },
2178
- { value: "PE", label: "Peru" },
2179
- { value: "PH", label: "Philippines" },
2180
- { value: "PN", label: "Pitcairn" },
2181
- { value: "PL", label: "Poland" },
2182
- { value: "PT", label: "Portugal" },
2183
- { value: "PR", label: "Puerto Rico" },
2184
- { value: "QA", label: "Qatar" },
2185
- { value: "RE", label: "R\xE9union" },
2186
- { value: "RO", label: "Romania" },
2187
- { value: "RU", label: "Russian Federation" },
2188
- { value: "RW", label: "Rwanda" },
2189
- { value: "BL", label: "Saint Barth\xE9lemy" },
2190
- { value: "SH", label: "Saint Helena" },
2191
- { value: "KN", label: "Saint Kitts and Nevis" },
2192
- { value: "LC", label: "Saint Lucia" },
2193
- { value: "MF", label: "Saint Martin" },
2194
- { value: "PM", label: "Saint Pierre and Miquelon" },
2195
- { value: "VC", label: "Saint Vincent and the Grenadines" },
2196
- { value: "WS", label: "Samoa" },
2197
- { value: "SM", label: "San Marino" },
2198
- { value: "ST", label: "Sao Tome and Principe" },
2199
- { value: "SA", label: "Saudi Arabia" },
2200
- { value: "SN", label: "Senegal" },
2201
- { value: "RS", label: "Serbia" },
2202
- { value: "SC", label: "Seychelles" },
2203
- { value: "SL", label: "Sierra Leone" },
2204
- { value: "SG", label: "Singapore" },
2205
- { value: "SX", label: "Sint Maarten" },
2206
- { value: "SK", label: "Slovakia" },
2207
- { value: "SI", label: "Slovenia" },
2208
- { value: "SB", label: "Solomon Islands" },
2209
- { value: "SO", label: "Somalia" },
2210
- { value: "ZA", label: "South Africa" },
2211
- { value: "GS", label: "South Georgia" },
2212
- { value: "SS", label: "South Sudan" },
2213
- { value: "ES", label: "Spain" },
2214
- { value: "LK", label: "Sri Lanka" },
2215
- { value: "SD", label: "Sudan" },
2216
- { value: "SR", label: "Suriname" },
2217
- { value: "SJ", label: "Svalbard and Jan Mayen" },
2218
- { value: "SZ", label: "Eswatini" },
2219
- { value: "SE", label: "Sweden" },
2220
- { value: "CH", label: "Switzerland" },
2221
- { value: "SY", label: "Syria" },
2222
- { value: "TW", label: "Taiwan" },
2223
- { value: "TJ", label: "Tajikistan" },
2224
- { value: "TZ", label: "Tanzania" },
2225
- { value: "TH", label: "Thailand" },
2226
- { value: "TL", label: "Timor-Leste" },
2227
- { value: "TG", label: "Togo" },
2228
- { value: "TK", label: "Tokelau" },
2229
- { value: "TO", label: "Tonga" },
2230
- { value: "TT", label: "Trinidad and Tobago" },
2231
- { value: "TN", label: "Tunisia" },
2232
- { value: "TR", label: "Turkey" },
2233
- { value: "TM", label: "Turkmenistan" },
2234
- { value: "TC", label: "Turks and Caicos Islands" },
2235
- { value: "TV", label: "Tuvalu" },
2236
- { value: "UG", label: "Uganda" },
2237
- { value: "UA", label: "Ukraine" },
2238
- { value: "AE", label: "United Arab Emirates" },
2239
- { value: "GB", label: "United Kingdom" },
2240
- { value: "US", label: "United States" },
2241
- { value: "UM", label: "U.S. Minor Outlying Islands" },
2242
- { value: "UY", label: "Uruguay" },
2243
- { value: "UZ", label: "Uzbekistan" },
2244
- { value: "VU", label: "Vanuatu" },
2245
- { value: "VE", label: "Venezuela" },
2246
- { value: "VN", label: "Vietnam" },
2247
- { value: "VG", label: "Virgin Islands, British" },
2248
- { value: "VI", label: "Virgin Islands, U.S." },
2249
- { value: "WF", label: "Wallis and Futuna" },
2250
- { value: "EH", label: "Western Sahara" },
2251
- { value: "YE", label: "Yemen" },
2252
- { value: "ZM", label: "Zambia" },
2253
- { value: "ZW", label: "Zimbabwe" }
2254
- ];
2255
- var US_STATES = [
2256
- { value: "AL", label: "Alabama" },
2257
- { value: "AK", label: "Alaska" },
2258
- { value: "AZ", label: "Arizona" },
2259
- { value: "AR", label: "Arkansas" },
2260
- { value: "CA", label: "California" },
2261
- { value: "CO", label: "Colorado" },
2262
- { value: "CT", label: "Connecticut" },
2263
- { value: "DE", label: "Delaware" },
2264
- { value: "FL", label: "Florida" },
2265
- { value: "GA", label: "Georgia" },
2266
- { value: "HI", label: "Hawaii" },
2267
- { value: "ID", label: "Idaho" },
2268
- { value: "IL", label: "Illinois" },
2269
- { value: "IN", label: "Indiana" },
2270
- { value: "IA", label: "Iowa" },
2271
- { value: "KS", label: "Kansas" },
2272
- { value: "KY", label: "Kentucky" },
2273
- { value: "LA", label: "Louisiana" },
2274
- { value: "ME", label: "Maine" },
2275
- { value: "MD", label: "Maryland" },
2276
- { value: "MA", label: "Massachusetts" },
2277
- { value: "MI", label: "Michigan" },
2278
- { value: "MN", label: "Minnesota" },
2279
- { value: "MS", label: "Mississippi" },
2280
- { value: "MO", label: "Missouri" },
2281
- { value: "MT", label: "Montana" },
2282
- { value: "NE", label: "Nebraska" },
2283
- { value: "NV", label: "Nevada" },
2284
- { value: "NH", label: "New Hampshire" },
2285
- { value: "NJ", label: "New Jersey" },
2286
- { value: "NM", label: "New Mexico" },
2287
- { value: "NY", label: "New York" },
2288
- { value: "NC", label: "North Carolina" },
2289
- { value: "ND", label: "North Dakota" },
2290
- { value: "OH", label: "Ohio" },
2291
- { value: "OK", label: "Oklahoma" },
2292
- { value: "OR", label: "Oregon" },
2293
- { value: "PA", label: "Pennsylvania" },
2294
- { value: "RI", label: "Rhode Island" },
2295
- { value: "SC", label: "South Carolina" },
2296
- { value: "SD", label: "South Dakota" },
2297
- { value: "TN", label: "Tennessee" },
2298
- { value: "TX", label: "Texas" },
2299
- { value: "UT", label: "Utah" },
2300
- { value: "VT", label: "Vermont" },
2301
- { value: "VA", label: "Virginia" },
2302
- { value: "WA", label: "Washington" },
2303
- { value: "WV", label: "West Virginia" },
2304
- { value: "WI", label: "Wisconsin" },
2305
- { value: "WY", label: "Wyoming" },
2306
- { value: "DC", label: "District of Columbia" }
2307
- ];
2308
-
2309
- // src/components/FormRenderer/index.tsx
2310
- function toSubmissionData(values) {
2311
- return Object.entries(values).map(([field, value]) => ({
2312
- field,
2313
- value: String(value)
2314
- }));
2315
- }
2316
- function getInitialValues(fields) {
2317
- var _a, _b;
2318
- const values = {};
2319
- if (!fields) return values;
2320
- for (const field of fields) {
2321
- if (field.blockType === "message") continue;
2322
- if (field.blockType === "checkbox") {
2323
- values[field.name] = (_a = field.defaultValue) != null ? _a : false;
2324
- } else if (field.blockType === "number" || field.blockType === "text" || field.blockType === "textarea" || field.blockType === "select") {
2325
- values[field.name] = (_b = field.defaultValue) != null ? _b : "";
2326
- } else {
2327
- values[field.name] = "";
2328
- }
2329
- }
2330
- return values;
2331
- }
2332
- function FormRenderer({
2333
- form,
2334
- onSubmit,
2335
- className,
2336
- fieldClassName,
2337
- buttonClassName,
2338
- renderField,
2339
- renderMessage,
2340
- renderButton
2341
- }) {
2342
- var _a;
2343
- const [values, setValues] = (0, import_react3.useState)(
2344
- () => getInitialValues(form.fields)
2345
- );
2346
- const [isSubmitting, setIsSubmitting] = (0, import_react3.useState)(false);
2347
- const submittingRef = (0, import_react3.useRef)(false);
2348
- (0, import_react3.useEffect)(() => {
2349
- setValues(getInitialValues(form.fields));
2350
- }, [form.id]);
2351
- const handleChange = (0, import_react3.useCallback)(
2352
- (name, value) => {
2353
- setValues((prev) => __spreadProps(__spreadValues({}, prev), { [name]: value }));
2354
- },
2355
- []
2356
- );
2357
- const handleSubmit = (e) => __async(null, null, function* () {
2358
- e.preventDefault();
2359
- if (submittingRef.current) return;
2360
- submittingRef.current = true;
2361
- setIsSubmitting(true);
2362
- try {
2363
- yield onSubmit(values);
2364
- } finally {
2365
- submittingRef.current = false;
2366
- setIsSubmitting(false);
2367
- }
2368
- });
2369
- const wrapField = (field, style, input) => {
2370
- var _a2, _b;
2371
- const context = {
2372
- value: (_a2 = values[field.name]) != null ? _a2 : "",
2373
- onChange: (v) => handleChange(field.name, v)
2374
- };
2375
- const el = /* @__PURE__ */ import_react3.default.createElement(
2376
- "div",
2377
- {
2378
- key: (_b = field.id) != null ? _b : field.name,
2379
- className: fieldClassName,
2380
- style
2381
- },
2382
- field.label && /* @__PURE__ */ import_react3.default.createElement("label", { htmlFor: field.name }, field.label),
2383
- input
2384
- );
2385
- return renderField ? renderField(field, context, el) : el;
2386
- };
2387
- const renderSelectField = (field, style, options, placeholder) => {
2388
- var _a2, _b;
2389
- return wrapField(
2390
- field,
2391
- style,
2392
- /* @__PURE__ */ import_react3.default.createElement(
2393
- "select",
2394
- {
2395
- id: field.name,
2396
- name: field.name,
2397
- value: String((_a2 = values[field.name]) != null ? _a2 : ""),
2398
- required: (_b = field.required) != null ? _b : false,
2399
- onChange: (e) => handleChange(field.name, e.target.value)
2400
- },
2401
- /* @__PURE__ */ import_react3.default.createElement("option", { value: "" }, placeholder || "Select\u2026"),
2402
- options.map((opt) => /* @__PURE__ */ import_react3.default.createElement("option", { key: opt.value, value: opt.value }, opt.label))
2403
- )
2404
- );
2405
- };
2406
- const renderFieldElement = (field) => {
2407
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
2408
- const style = field.blockType !== "message" && field.width ? { width: `${field.width}%` } : void 0;
2409
- switch (field.blockType) {
2410
- case "text":
2411
- return wrapField(
2412
- field,
2413
- style,
2414
- /* @__PURE__ */ import_react3.default.createElement(
2415
- "input",
2416
- {
2417
- type: "text",
2418
- id: field.name,
2419
- name: field.name,
2420
- value: String((_a2 = values[field.name]) != null ? _a2 : ""),
2421
- placeholder: (_b = field.placeholder) != null ? _b : void 0,
2422
- required: (_c = field.required) != null ? _c : false,
2423
- onChange: (e) => handleChange(field.name, e.target.value)
2424
- }
2425
- )
2426
- );
2427
- case "email":
2428
- return wrapField(
2429
- field,
2430
- style,
2431
- /* @__PURE__ */ import_react3.default.createElement(
2432
- "input",
2433
- {
2434
- type: "email",
2435
- id: field.name,
2436
- name: field.name,
2437
- value: String((_d = values[field.name]) != null ? _d : ""),
2438
- required: (_e = field.required) != null ? _e : false,
2439
- onChange: (e) => handleChange(field.name, e.target.value)
2440
- }
2441
- )
2442
- );
2443
- case "number":
2444
- return wrapField(
2445
- field,
2446
- style,
2447
- /* @__PURE__ */ import_react3.default.createElement(
2448
- "input",
2449
- {
2450
- type: "number",
2451
- id: field.name,
2452
- name: field.name,
2453
- value: String((_f = values[field.name]) != null ? _f : ""),
2454
- required: (_g = field.required) != null ? _g : false,
2455
- onChange: (e) => {
2456
- const v = e.target.value;
2457
- if (v === "") return handleChange(field.name, "");
2458
- const n = Number(v);
2459
- if (Number.isFinite(n)) handleChange(field.name, n);
2460
- }
2461
- }
2462
- )
2463
- );
2464
- case "textarea":
2465
- return wrapField(
2466
- field,
2467
- style,
2468
- /* @__PURE__ */ import_react3.default.createElement(
2469
- "textarea",
2470
- {
2471
- id: field.name,
2472
- name: field.name,
2473
- value: String((_h = values[field.name]) != null ? _h : ""),
2474
- required: (_i = field.required) != null ? _i : false,
2475
- onChange: (e) => handleChange(field.name, e.target.value)
2476
- }
2477
- )
2478
- );
2479
- case "checkbox": {
2480
- const context = {
2481
- value: (_j = values[field.name]) != null ? _j : false,
2482
- onChange: (v) => handleChange(field.name, v)
2483
- };
2484
- const el = /* @__PURE__ */ import_react3.default.createElement(
2485
- "div",
2486
- {
2487
- key: (_k = field.id) != null ? _k : field.name,
2488
- className: fieldClassName,
2489
- style
2490
- },
2491
- /* @__PURE__ */ import_react3.default.createElement("label", { htmlFor: field.name }, /* @__PURE__ */ import_react3.default.createElement(
2492
- "input",
2493
- {
2494
- type: "checkbox",
2495
- id: field.name,
2496
- name: field.name,
2497
- checked: Boolean(values[field.name]),
2498
- required: (_l = field.required) != null ? _l : false,
2499
- onChange: (e) => handleChange(field.name, e.target.checked)
2500
- }
2501
- ), field.label && /* @__PURE__ */ import_react3.default.createElement("span", null, field.label))
2502
- );
2503
- return renderField ? renderField(field, context, el) : el;
2504
- }
2505
- case "select":
2506
- return renderSelectField(
2507
- field,
2508
- style,
2509
- (_m = field.options) != null ? _m : [],
2510
- (_n = field.placeholder) != null ? _n : void 0
2511
- );
2512
- case "country":
2513
- return renderSelectField(field, style, COUNTRIES);
2514
- case "state":
2515
- return renderSelectField(field, style, US_STATES);
2516
- case "message":
2517
- if (renderMessage && field.message) {
2518
- return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, { key: (_p = (_o = field.id) != null ? _o : field.blockName) != null ? _p : "message" }, renderMessage(field.message));
2519
- }
2520
- return null;
2521
- default:
2522
- return null;
2523
- }
2524
- };
2525
- const buttonLabel = form.submitButtonLabel || "Submit";
2526
- return /* @__PURE__ */ import_react3.default.createElement("form", { onSubmit: handleSubmit, className }, (_a = form.fields) == null ? void 0 : _a.map((field) => renderFieldElement(field)), renderButton ? renderButton({ isSubmitting, label: buttonLabel }) : /* @__PURE__ */ import_react3.default.createElement(
2527
- "button",
2528
- {
2529
- type: "submit",
2530
- disabled: isSubmitting,
2531
- className: buttonClassName
2532
- },
2533
- buttonLabel
2534
- ));
2535
- }
2536
-
2537
- // src/components/Image/index.tsx
2538
- var import_react4 = require("react");
2539
- function Image({
2540
- image,
2541
- width,
2542
- dpr = 1,
2543
- placeholder = "blur",
2544
- className,
2545
- style,
2546
- imgClassName,
2547
- imgStyle,
2548
- sizes,
2549
- loading = "lazy",
2550
- onLoad,
2551
- objectFit = "cover"
2552
- }) {
2553
- var _a, _b;
2554
- const [loaded, setLoaded] = (0, import_react4.useState)(false);
2555
- const aspectRatio = image.width && image.height ? `${image.width} / ${image.height}` : void 0;
2556
- const srcSet = getImageSrcSet(image);
2557
- const src = (_a = image.url) != null ? _a : void 0;
2558
- const placeholderStyle = getImagePlaceholderStyle(image, {
2559
- type: placeholder
2560
- });
2561
- const hasLqip = placeholder === "blur" && !!image.lqip;
2562
- const hasColorPlaceholder = !hasLqip && Object.keys(placeholderStyle).length > 0;
2563
- const imgRef = (0, import_react4.useCallback)(
2564
- (node) => {
2565
- if (node && node.complete && node.naturalWidth > 0) {
2566
- setLoaded(true);
2567
- onLoad == null ? void 0 : onLoad();
2568
- }
2569
- },
2570
- [onLoad]
2571
- );
2572
- const handleLoad = (0, import_react4.useCallback)(() => {
2573
- setLoaded(true);
2574
- onLoad == null ? void 0 : onLoad();
2575
- }, [onLoad]);
2576
- const containerStyle = __spreadValues(__spreadValues(__spreadValues({
2577
- position: "relative",
2578
- overflow: "hidden"
2579
- }, aspectRatio ? { aspectRatio } : {}), hasColorPlaceholder ? placeholderStyle : {}), style);
2580
- const imgBase = {
2581
- display: "block",
2582
- width: "100%",
2583
- height: "100%",
2584
- objectFit
2585
- };
2586
- const mainImgStyle = __spreadValues(__spreadProps(__spreadValues({}, imgBase), {
2587
- opacity: loaded ? 1 : 0,
2588
- transition: "opacity 0.3s ease"
2589
- }), imgStyle);
2590
- const lqipStyle = __spreadProps(__spreadValues({}, imgBase), {
2591
- position: "absolute",
2592
- top: 0,
2593
- left: 0,
2594
- filter: "blur(20px)",
2595
- transform: "scale(1.1)",
2596
- opacity: loaded ? 0 : 1,
2597
- transition: "opacity 0.3s ease",
2598
- pointerEvents: "none"
2599
- });
2600
- return /* @__PURE__ */ React.createElement("div", { className, style: containerStyle }, hasLqip && /* @__PURE__ */ React.createElement(
2601
- "img",
2602
- {
2603
- "aria-hidden": true,
2604
- alt: "",
2605
- src: image.lqip,
2606
- style: lqipStyle
2607
- }
2608
- ), /* @__PURE__ */ React.createElement(
2609
- "img",
2610
- {
2611
- ref: imgRef,
2612
- alt: (_b = image.alt) != null ? _b : "",
2613
- src,
2614
- srcSet: srcSet || void 0,
2615
- sizes,
2616
- width: width ? width * dpr : void 0,
2617
- loading,
2618
- onLoad: handleLoad,
2619
- className: imgClassName,
2620
- style: mainImgStyle
2621
- }
2622
- ));
2623
- }
2624
1965
  //# sourceMappingURL=index.cjs.map