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