@betterstore/react 0.6.8 → 0.6.10
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/components/checkout-embed/checkout-form.d.ts.map +1 -1
- package/dist/components/checkout-embed/checkout-schema.d.ts +48 -48
- package/dist/components/checkout-embed/steps/shipping/form.d.ts +2 -2
- package/dist/components/checkout-embed/steps/shipping/form.d.ts.map +1 -1
- package/dist/components/ui/form.d.ts.map +1 -1
- package/dist/index.cjs.js +687 -355
- package/dist/index.mjs +693 -361
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -3348,7 +3348,8 @@ const CheckoutEmbed$2 = {
|
|
|
3348
3348
|
},
|
|
3349
3349
|
shipment: {
|
|
3350
3350
|
title: "Zásilka č."
|
|
3351
|
-
}
|
|
3351
|
+
},
|
|
3352
|
+
errorNoShippingRates: "Dopravu se nepodařilo načíst. Zkuste stránku obnovit. Pokud problém přetrvává, kontaktujte prodejce."
|
|
3352
3353
|
}
|
|
3353
3354
|
};
|
|
3354
3355
|
const Errors$1 = {
|
|
@@ -3409,6 +3410,7 @@ const CheckoutEmbed$1 = {
|
|
|
3409
3410
|
},
|
|
3410
3411
|
loading: "Loading...",
|
|
3411
3412
|
Shipping: {
|
|
3413
|
+
errorNoShippingRates: "Failed to load shipping rates. Try to refresh the page. Contact the seller if the problem persists.",
|
|
3412
3414
|
title: "Shipping",
|
|
3413
3415
|
change: "Change",
|
|
3414
3416
|
address: "Address:",
|
|
@@ -3474,6 +3476,13 @@ const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, functio
|
|
|
3474
3476
|
return instance;
|
|
3475
3477
|
});
|
|
3476
3478
|
|
|
3479
|
+
/**
|
|
3480
|
+
* Create a bound version of a function with a specified `this` context
|
|
3481
|
+
*
|
|
3482
|
+
* @param {Function} fn - The function to bind
|
|
3483
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
3484
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
3485
|
+
*/
|
|
3477
3486
|
function bind(fn, thisArg) {
|
|
3478
3487
|
return function wrap() {
|
|
3479
3488
|
return fn.apply(thisArg, arguments);
|
|
@@ -4726,7 +4735,7 @@ class InterceptorManager {
|
|
|
4726
4735
|
*
|
|
4727
4736
|
* @param {Number} id The ID that was returned by `use`
|
|
4728
4737
|
*
|
|
4729
|
-
* @returns {
|
|
4738
|
+
* @returns {void}
|
|
4730
4739
|
*/
|
|
4731
4740
|
eject(id) {
|
|
4732
4741
|
if (this.handlers[id]) {
|
|
@@ -5686,27 +5695,38 @@ var cookies = platform$1.hasStandardBrowserEnv ?
|
|
|
5686
5695
|
|
|
5687
5696
|
// Standard browser envs support document.cookie
|
|
5688
5697
|
{
|
|
5689
|
-
write(name, value, expires, path, domain, secure) {
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
5693
|
-
|
|
5694
|
-
utils$1.isString(path) && cookie.push('path=' + path);
|
|
5698
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
5699
|
+
if (typeof document === 'undefined') return;
|
|
5695
5700
|
|
|
5696
|
-
|
|
5701
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
5697
5702
|
|
|
5698
|
-
|
|
5703
|
+
if (utils$1.isNumber(expires)) {
|
|
5704
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
5705
|
+
}
|
|
5706
|
+
if (utils$1.isString(path)) {
|
|
5707
|
+
cookie.push(`path=${path}`);
|
|
5708
|
+
}
|
|
5709
|
+
if (utils$1.isString(domain)) {
|
|
5710
|
+
cookie.push(`domain=${domain}`);
|
|
5711
|
+
}
|
|
5712
|
+
if (secure === true) {
|
|
5713
|
+
cookie.push('secure');
|
|
5714
|
+
}
|
|
5715
|
+
if (utils$1.isString(sameSite)) {
|
|
5716
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
5717
|
+
}
|
|
5699
5718
|
|
|
5700
5719
|
document.cookie = cookie.join('; ');
|
|
5701
5720
|
},
|
|
5702
5721
|
|
|
5703
5722
|
read(name) {
|
|
5704
|
-
|
|
5705
|
-
|
|
5723
|
+
if (typeof document === 'undefined') return null;
|
|
5724
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
5725
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
5706
5726
|
},
|
|
5707
5727
|
|
|
5708
5728
|
remove(name) {
|
|
5709
|
-
this.write(name, '', Date.now() - 86400000);
|
|
5729
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
5710
5730
|
}
|
|
5711
5731
|
}
|
|
5712
5732
|
|
|
@@ -5795,11 +5815,11 @@ function mergeConfig$1(config1, config2) {
|
|
|
5795
5815
|
}
|
|
5796
5816
|
|
|
5797
5817
|
// eslint-disable-next-line consistent-return
|
|
5798
|
-
function mergeDeepProperties(a, b, prop
|
|
5818
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
5799
5819
|
if (!utils$1.isUndefined(b)) {
|
|
5800
|
-
return getMergedValue(a, b, prop
|
|
5820
|
+
return getMergedValue(a, b, prop, caseless);
|
|
5801
5821
|
} else if (!utils$1.isUndefined(a)) {
|
|
5802
|
-
return getMergedValue(undefined, a, prop
|
|
5822
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
5803
5823
|
}
|
|
5804
5824
|
}
|
|
5805
5825
|
|
|
@@ -5857,7 +5877,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
5857
5877
|
socketPath: defaultToConfig2,
|
|
5858
5878
|
responseEncoding: defaultToConfig2,
|
|
5859
5879
|
validateStatus: mergeDirectKeys,
|
|
5860
|
-
headers: (a, b
|
|
5880
|
+
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
5861
5881
|
};
|
|
5862
5882
|
|
|
5863
5883
|
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
@@ -6495,7 +6515,7 @@ const factory = (env) => {
|
|
|
6495
6515
|
const seedCache = new Map();
|
|
6496
6516
|
|
|
6497
6517
|
const getFetch = (config) => {
|
|
6498
|
-
let env = config
|
|
6518
|
+
let env = (config && config.env) || {};
|
|
6499
6519
|
const {fetch, Request, Response} = env;
|
|
6500
6520
|
const seeds = [
|
|
6501
6521
|
Request, Response, fetch
|
|
@@ -6518,6 +6538,15 @@ const getFetch = (config) => {
|
|
|
6518
6538
|
|
|
6519
6539
|
getFetch();
|
|
6520
6540
|
|
|
6541
|
+
/**
|
|
6542
|
+
* Known adapters mapping.
|
|
6543
|
+
* Provides environment-specific adapters for Axios:
|
|
6544
|
+
* - `http` for Node.js
|
|
6545
|
+
* - `xhr` for browsers
|
|
6546
|
+
* - `fetch` for fetch API-based requests
|
|
6547
|
+
*
|
|
6548
|
+
* @type {Object<string, Function|Object>}
|
|
6549
|
+
*/
|
|
6521
6550
|
const knownAdapters = {
|
|
6522
6551
|
http: httpAdapter,
|
|
6523
6552
|
xhr: xhrAdapter,
|
|
@@ -6526,71 +6555,107 @@ const knownAdapters = {
|
|
|
6526
6555
|
}
|
|
6527
6556
|
};
|
|
6528
6557
|
|
|
6558
|
+
// Assign adapter names for easier debugging and identification
|
|
6529
6559
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
6530
6560
|
if (fn) {
|
|
6531
6561
|
try {
|
|
6532
|
-
Object.defineProperty(fn, 'name', {value});
|
|
6562
|
+
Object.defineProperty(fn, 'name', { value });
|
|
6533
6563
|
} catch (e) {
|
|
6534
6564
|
// eslint-disable-next-line no-empty
|
|
6535
6565
|
}
|
|
6536
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
6566
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
6537
6567
|
}
|
|
6538
6568
|
});
|
|
6539
6569
|
|
|
6570
|
+
/**
|
|
6571
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
6572
|
+
*
|
|
6573
|
+
* @param {string} reason
|
|
6574
|
+
* @returns {string}
|
|
6575
|
+
*/
|
|
6540
6576
|
const renderReason = (reason) => `- ${reason}`;
|
|
6541
6577
|
|
|
6578
|
+
/**
|
|
6579
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
6580
|
+
*
|
|
6581
|
+
* @param {Function|null|false} adapter
|
|
6582
|
+
* @returns {boolean}
|
|
6583
|
+
*/
|
|
6542
6584
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
6543
6585
|
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6586
|
+
/**
|
|
6587
|
+
* Get the first suitable adapter from the provided list.
|
|
6588
|
+
* Tries each adapter in order until a supported one is found.
|
|
6589
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
6590
|
+
*
|
|
6591
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
6592
|
+
* @param {Object} config - Axios request configuration
|
|
6593
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
6594
|
+
* @returns {Function} The resolved adapter function
|
|
6595
|
+
*/
|
|
6596
|
+
function getAdapter$1(adapters, config) {
|
|
6597
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
6547
6598
|
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6599
|
+
const { length } = adapters;
|
|
6600
|
+
let nameOrAdapter;
|
|
6601
|
+
let adapter;
|
|
6551
6602
|
|
|
6552
|
-
|
|
6603
|
+
const rejectedReasons = {};
|
|
6553
6604
|
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6605
|
+
for (let i = 0; i < length; i++) {
|
|
6606
|
+
nameOrAdapter = adapters[i];
|
|
6607
|
+
let id;
|
|
6557
6608
|
|
|
6558
|
-
|
|
6609
|
+
adapter = nameOrAdapter;
|
|
6559
6610
|
|
|
6560
|
-
|
|
6561
|
-
|
|
6611
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
6612
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
6562
6613
|
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
}
|
|
6566
|
-
}
|
|
6567
|
-
|
|
6568
|
-
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
6569
|
-
break;
|
|
6614
|
+
if (adapter === undefined) {
|
|
6615
|
+
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
6570
6616
|
}
|
|
6617
|
+
}
|
|
6571
6618
|
|
|
6572
|
-
|
|
6619
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
6620
|
+
break;
|
|
6573
6621
|
}
|
|
6574
6622
|
|
|
6575
|
-
|
|
6623
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
6624
|
+
}
|
|
6576
6625
|
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
)
|
|
6626
|
+
if (!adapter) {
|
|
6627
|
+
const reasons = Object.entries(rejectedReasons)
|
|
6628
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
6629
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
6630
|
+
);
|
|
6581
6631
|
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6632
|
+
let s = length ?
|
|
6633
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
6634
|
+
'as no adapter specified';
|
|
6585
6635
|
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6636
|
+
throw new AxiosError$1(
|
|
6637
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
6638
|
+
'ERR_NOT_SUPPORT'
|
|
6639
|
+
);
|
|
6640
|
+
}
|
|
6591
6641
|
|
|
6592
|
-
|
|
6593
|
-
|
|
6642
|
+
return adapter;
|
|
6643
|
+
}
|
|
6644
|
+
|
|
6645
|
+
/**
|
|
6646
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
6647
|
+
*/
|
|
6648
|
+
var adapters = {
|
|
6649
|
+
/**
|
|
6650
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
6651
|
+
* @type {Function}
|
|
6652
|
+
*/
|
|
6653
|
+
getAdapter: getAdapter$1,
|
|
6654
|
+
|
|
6655
|
+
/**
|
|
6656
|
+
* Exposes all known adapters
|
|
6657
|
+
* @type {Object<string, Function|Object>}
|
|
6658
|
+
*/
|
|
6594
6659
|
adapters: knownAdapters
|
|
6595
6660
|
};
|
|
6596
6661
|
|
|
@@ -6667,7 +6732,7 @@ function dispatchRequest(config) {
|
|
|
6667
6732
|
});
|
|
6668
6733
|
}
|
|
6669
6734
|
|
|
6670
|
-
const VERSION$1 = "1.
|
|
6735
|
+
const VERSION$1 = "1.13.2";
|
|
6671
6736
|
|
|
6672
6737
|
const validators$1 = {};
|
|
6673
6738
|
|
|
@@ -7222,6 +7287,12 @@ const HttpStatusCode$1 = {
|
|
|
7222
7287
|
LoopDetected: 508,
|
|
7223
7288
|
NotExtended: 510,
|
|
7224
7289
|
NetworkAuthenticationRequired: 511,
|
|
7290
|
+
WebServerIsDown: 521,
|
|
7291
|
+
ConnectionTimedOut: 522,
|
|
7292
|
+
OriginIsUnreachable: 523,
|
|
7293
|
+
TimeoutOccurred: 524,
|
|
7294
|
+
SslHandshakeFailed: 525,
|
|
7295
|
+
InvalidSslCertificate: 526,
|
|
7225
7296
|
};
|
|
7226
7297
|
|
|
7227
7298
|
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
|
@@ -12242,7 +12313,7 @@ var createApiClient = (apiKey, proxy) => {
|
|
|
12242
12313
|
apiError.code = "REQUEST_SETUP_ERROR";
|
|
12243
12314
|
apiError.details = error;
|
|
12244
12315
|
}
|
|
12245
|
-
console.error(apiError);
|
|
12316
|
+
console.error("API ERROR: ", apiError);
|
|
12246
12317
|
if (apiError.code === "REQUEST_SETUP_ERROR" || apiError.code === "SERVICE_UNAVAILABLE") {
|
|
12247
12318
|
throw apiError;
|
|
12248
12319
|
}
|
|
@@ -12307,7 +12378,7 @@ var Client = class {
|
|
|
12307
12378
|
async removeDiscount(clientSecret, checkoutId, discountId) {
|
|
12308
12379
|
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
12309
12380
|
const data = await apiClient.delete(
|
|
12310
|
-
`/checkout/${checkoutId}/discounts/${discountId}`
|
|
12381
|
+
`/checkout/${checkoutId}/discounts/remove/${discountId}`
|
|
12311
12382
|
);
|
|
12312
12383
|
if ("isError" in data && data.isError || !data || !("id" in data)) {
|
|
12313
12384
|
throw new Error("Failed to remove discount code");
|
|
@@ -12336,7 +12407,9 @@ var Client = class {
|
|
|
12336
12407
|
const data = await apiClient.get(
|
|
12337
12408
|
`/checkout/${checkoutId}/shipping/rates`
|
|
12338
12409
|
);
|
|
12339
|
-
|
|
12410
|
+
console.log("SHIPPING RATES DATA: ", data);
|
|
12411
|
+
if ("isError" in data && data.isError || !data) {
|
|
12412
|
+
console.error("Failed to get shipping rates: ", data);
|
|
12340
12413
|
return {};
|
|
12341
12414
|
}
|
|
12342
12415
|
return data;
|
|
@@ -12346,7 +12419,7 @@ var Client = class {
|
|
|
12346
12419
|
*/
|
|
12347
12420
|
async generateCheckoutPaymentSecret(clientSecret, checkoutId) {
|
|
12348
12421
|
const apiClient = createApiClient(clientSecret, this.proxy);
|
|
12349
|
-
const data = await apiClient.post(`/checkout
|
|
12422
|
+
const data = await apiClient.post(`/checkout/${checkoutId}/payment`);
|
|
12350
12423
|
if ("isError" in data && data.isError || !data || !("paymentSecret" in data)) {
|
|
12351
12424
|
throw new Error("Failed to generate payment secret");
|
|
12352
12425
|
}
|
|
@@ -13588,14 +13661,14 @@ const customerSchema = objectType({
|
|
|
13588
13661
|
lastName: stringType().min(1, "required_error"),
|
|
13589
13662
|
address: objectType({
|
|
13590
13663
|
line1: stringType().min(1, "required_error"),
|
|
13591
|
-
line2: stringType().nullable(),
|
|
13664
|
+
line2: stringType().nullable().optional(),
|
|
13592
13665
|
city: stringType().min(1, "required_error"),
|
|
13593
|
-
province: stringType().nullable(),
|
|
13594
|
-
provinceCode: stringType().nullable(),
|
|
13666
|
+
province: stringType().nullable().optional(),
|
|
13667
|
+
provinceCode: stringType().nullable().optional(),
|
|
13595
13668
|
zipCode: stringType().min(5, "invalid_zipCode"),
|
|
13596
13669
|
country: stringType().min(1, "required_error"),
|
|
13597
13670
|
countryCode: stringType().min(1, "required_error"),
|
|
13598
|
-
company: stringType().nullable(),
|
|
13671
|
+
company: stringType().nullable().optional(),
|
|
13599
13672
|
}),
|
|
13600
13673
|
phone: stringType().regex(phoneRegex, "invalid_phone"),
|
|
13601
13674
|
isEmailSubscribed: booleanType().optional(),
|
|
@@ -13672,13 +13745,24 @@ function useComposedRefs(...refs) {
|
|
|
13672
13745
|
}
|
|
13673
13746
|
|
|
13674
13747
|
// src/slot.tsx
|
|
13748
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
13749
|
+
var use = React__namespace[" use ".trim().toString()];
|
|
13750
|
+
function isPromiseLike(value) {
|
|
13751
|
+
return typeof value === "object" && value !== null && "then" in value;
|
|
13752
|
+
}
|
|
13753
|
+
function isLazyComponent(element) {
|
|
13754
|
+
return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
|
|
13755
|
+
}
|
|
13675
13756
|
// @__NO_SIDE_EFFECTS__
|
|
13676
|
-
function createSlot(ownerName) {
|
|
13677
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
13757
|
+
function createSlot$1(ownerName) {
|
|
13758
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
|
|
13678
13759
|
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
13679
|
-
|
|
13760
|
+
let { children, ...slotProps } = props;
|
|
13761
|
+
if (isLazyComponent(children) && typeof use === "function") {
|
|
13762
|
+
children = use(children._payload);
|
|
13763
|
+
}
|
|
13680
13764
|
const childrenArray = React__namespace.Children.toArray(children);
|
|
13681
|
-
const slottable = childrenArray.find(isSlottable);
|
|
13765
|
+
const slottable = childrenArray.find(isSlottable$1);
|
|
13682
13766
|
if (slottable) {
|
|
13683
13767
|
const newElement = slottable.props.children;
|
|
13684
13768
|
const newChildren = childrenArray.map((child) => {
|
|
@@ -13696,14 +13780,17 @@ function createSlot(ownerName) {
|
|
|
13696
13780
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
13697
13781
|
return Slot2;
|
|
13698
13782
|
}
|
|
13699
|
-
var Slot$2 = /* @__PURE__ */ createSlot("Slot");
|
|
13783
|
+
var Slot$2 = /* @__PURE__ */ createSlot$1("Slot");
|
|
13700
13784
|
// @__NO_SIDE_EFFECTS__
|
|
13701
|
-
function createSlotClone(ownerName) {
|
|
13785
|
+
function createSlotClone$1(ownerName) {
|
|
13702
13786
|
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
13703
|
-
|
|
13787
|
+
let { children, ...slotProps } = props;
|
|
13788
|
+
if (isLazyComponent(children) && typeof use === "function") {
|
|
13789
|
+
children = use(children._payload);
|
|
13790
|
+
}
|
|
13704
13791
|
if (React__namespace.isValidElement(children)) {
|
|
13705
|
-
const childrenRef = getElementRef$
|
|
13706
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
13792
|
+
const childrenRef = getElementRef$2(children);
|
|
13793
|
+
const props2 = mergeProps$1(slotProps, children.props);
|
|
13707
13794
|
if (children.type !== React__namespace.Fragment) {
|
|
13708
13795
|
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
13709
13796
|
}
|
|
@@ -13714,11 +13801,11 @@ function createSlotClone(ownerName) {
|
|
|
13714
13801
|
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
13715
13802
|
return SlotClone;
|
|
13716
13803
|
}
|
|
13717
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
13718
|
-
function isSlottable(child) {
|
|
13719
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
13804
|
+
var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
|
|
13805
|
+
function isSlottable$1(child) {
|
|
13806
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
|
|
13720
13807
|
}
|
|
13721
|
-
function mergeProps(slotProps, childProps) {
|
|
13808
|
+
function mergeProps$1(slotProps, childProps) {
|
|
13722
13809
|
const overrideProps = { ...childProps };
|
|
13723
13810
|
for (const propName in childProps) {
|
|
13724
13811
|
const slotPropValue = slotProps[propName];
|
|
@@ -13742,7 +13829,7 @@ function mergeProps(slotProps, childProps) {
|
|
|
13742
13829
|
}
|
|
13743
13830
|
return { ...slotProps, ...overrideProps };
|
|
13744
13831
|
}
|
|
13745
|
-
function getElementRef$
|
|
13832
|
+
function getElementRef$2(element) {
|
|
13746
13833
|
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
13747
13834
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13748
13835
|
if (mayWarn) {
|
|
@@ -13917,7 +14004,7 @@ HookFormContext.displayName = 'HookFormContext';
|
|
|
13917
14004
|
*/
|
|
13918
14005
|
const useFormContext = () => React.useContext(HookFormContext);
|
|
13919
14006
|
/**
|
|
13920
|
-
* A provider component that propagates the `useForm` methods to all children components via [React Context](https://
|
|
14007
|
+
* A provider component that propagates the `useForm` methods to all children components via [React Context](https://react.dev/reference/react/useContext) API. To be used with {@link useFormContext}.
|
|
13921
14008
|
*
|
|
13922
14009
|
* @remarks
|
|
13923
14010
|
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
|
@@ -14053,7 +14140,7 @@ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
|
|
|
14053
14140
|
|
|
14054
14141
|
function deepEqual$1(object1, object2, _internal_visited = new WeakSet()) {
|
|
14055
14142
|
if (isPrimitive(object1) || isPrimitive(object2)) {
|
|
14056
|
-
return object1
|
|
14143
|
+
return Object.is(object1, object2);
|
|
14057
14144
|
}
|
|
14058
14145
|
if (isDateObject(object1) && isDateObject(object2)) {
|
|
14059
14146
|
return object1.getTime() === object2.getTime();
|
|
@@ -14079,7 +14166,7 @@ function deepEqual$1(object1, object2, _internal_visited = new WeakSet()) {
|
|
|
14079
14166
|
(isObject(val1) && isObject(val2)) ||
|
|
14080
14167
|
(Array.isArray(val1) && Array.isArray(val2))
|
|
14081
14168
|
? !deepEqual$1(val1, val2, _internal_visited)
|
|
14082
|
-
: val1
|
|
14169
|
+
: !Object.is(val1, val2)) {
|
|
14083
14170
|
return false;
|
|
14084
14171
|
}
|
|
14085
14172
|
}
|
|
@@ -14109,33 +14196,68 @@ function useWatch(props) {
|
|
|
14109
14196
|
const _defaultValue = React.useRef(defaultValue);
|
|
14110
14197
|
const _compute = React.useRef(compute);
|
|
14111
14198
|
const _computeFormValues = React.useRef(undefined);
|
|
14199
|
+
const _prevControl = React.useRef(control);
|
|
14200
|
+
const _prevName = React.useRef(name);
|
|
14112
14201
|
_compute.current = compute;
|
|
14113
|
-
const
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
}
|
|
14130
|
-
}
|
|
14131
|
-
else {
|
|
14132
|
-
updateValue(formValues);
|
|
14202
|
+
const [value, updateValue] = React.useState(() => {
|
|
14203
|
+
const defaultValue = control._getWatch(name, _defaultValue.current);
|
|
14204
|
+
return _compute.current ? _compute.current(defaultValue) : defaultValue;
|
|
14205
|
+
});
|
|
14206
|
+
const getCurrentOutput = React.useCallback((values) => {
|
|
14207
|
+
const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
|
|
14208
|
+
return _compute.current ? _compute.current(formValues) : formValues;
|
|
14209
|
+
}, [control._formValues, control._names, name]);
|
|
14210
|
+
const refreshValue = React.useCallback((values) => {
|
|
14211
|
+
if (!disabled) {
|
|
14212
|
+
const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
|
|
14213
|
+
if (_compute.current) {
|
|
14214
|
+
const computedFormValues = _compute.current(formValues);
|
|
14215
|
+
if (!deepEqual$1(computedFormValues, _computeFormValues.current)) {
|
|
14216
|
+
updateValue(computedFormValues);
|
|
14217
|
+
_computeFormValues.current = computedFormValues;
|
|
14133
14218
|
}
|
|
14134
14219
|
}
|
|
14135
|
-
|
|
14136
|
-
|
|
14220
|
+
else {
|
|
14221
|
+
updateValue(formValues);
|
|
14222
|
+
}
|
|
14223
|
+
}
|
|
14224
|
+
}, [control._formValues, control._names, disabled, name]);
|
|
14225
|
+
useIsomorphicLayoutEffect$1(() => {
|
|
14226
|
+
if (_prevControl.current !== control ||
|
|
14227
|
+
!deepEqual$1(_prevName.current, name)) {
|
|
14228
|
+
_prevControl.current = control;
|
|
14229
|
+
_prevName.current = name;
|
|
14230
|
+
refreshValue();
|
|
14231
|
+
}
|
|
14232
|
+
return control._subscribe({
|
|
14233
|
+
name,
|
|
14234
|
+
formState: {
|
|
14235
|
+
values: true,
|
|
14236
|
+
},
|
|
14237
|
+
exact,
|
|
14238
|
+
callback: (formState) => {
|
|
14239
|
+
refreshValue(formState.values);
|
|
14240
|
+
},
|
|
14241
|
+
});
|
|
14242
|
+
}, [control, exact, name, refreshValue]);
|
|
14137
14243
|
React.useEffect(() => control._removeUnmounted());
|
|
14138
|
-
|
|
14244
|
+
// If name or control changed for this render, synchronously reflect the
|
|
14245
|
+
// latest value so callers (like useController) see the correct value
|
|
14246
|
+
// immediately on the same render.
|
|
14247
|
+
// Optimize: Check control reference first before expensive deepEqual
|
|
14248
|
+
const controlChanged = _prevControl.current !== control;
|
|
14249
|
+
const prevName = _prevName.current;
|
|
14250
|
+
// Cache the computed output to avoid duplicate calls within the same render
|
|
14251
|
+
// We include shouldReturnImmediate in deps to ensure proper recomputation
|
|
14252
|
+
const computedOutput = React.useMemo(() => {
|
|
14253
|
+
if (disabled) {
|
|
14254
|
+
return null;
|
|
14255
|
+
}
|
|
14256
|
+
const nameChanged = !controlChanged && !deepEqual$1(prevName, name);
|
|
14257
|
+
const shouldReturnImmediate = controlChanged || nameChanged;
|
|
14258
|
+
return shouldReturnImmediate ? getCurrentOutput() : null;
|
|
14259
|
+
}, [disabled, controlChanged, name, prevName, getCurrentOutput]);
|
|
14260
|
+
return computedOutput !== null ? computedOutput : value;
|
|
14139
14261
|
}
|
|
14140
14262
|
|
|
14141
14263
|
/**
|
|
@@ -14469,11 +14591,12 @@ function isTraversable(value) {
|
|
|
14469
14591
|
}
|
|
14470
14592
|
function markFieldsDirty(data, fields = {}) {
|
|
14471
14593
|
for (const key in data) {
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14594
|
+
const value = data[key];
|
|
14595
|
+
if (isTraversable(value)) {
|
|
14596
|
+
fields[key] = Array.isArray(value) ? [] : {};
|
|
14597
|
+
markFieldsDirty(value, fields[key]);
|
|
14475
14598
|
}
|
|
14476
|
-
else if (!
|
|
14599
|
+
else if (!isUndefined(value)) {
|
|
14477
14600
|
fields[key] = true;
|
|
14478
14601
|
}
|
|
14479
14602
|
}
|
|
@@ -14484,16 +14607,18 @@ function getDirtyFields(data, formValues, dirtyFieldsFromValues) {
|
|
|
14484
14607
|
dirtyFieldsFromValues = markFieldsDirty(formValues);
|
|
14485
14608
|
}
|
|
14486
14609
|
for (const key in data) {
|
|
14487
|
-
|
|
14610
|
+
const value = data[key];
|
|
14611
|
+
if (isTraversable(value)) {
|
|
14488
14612
|
if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {
|
|
14489
|
-
dirtyFieldsFromValues[key] = markFieldsDirty(
|
|
14613
|
+
dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
|
|
14490
14614
|
}
|
|
14491
14615
|
else {
|
|
14492
|
-
getDirtyFields(
|
|
14616
|
+
getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
|
|
14493
14617
|
}
|
|
14494
14618
|
}
|
|
14495
14619
|
else {
|
|
14496
|
-
|
|
14620
|
+
const formValue = formValues[key];
|
|
14621
|
+
dirtyFieldsFromValues[key] = !deepEqual$1(value, formValue);
|
|
14497
14622
|
}
|
|
14498
14623
|
}
|
|
14499
14624
|
return dirtyFieldsFromValues;
|
|
@@ -15088,7 +15213,7 @@ function createFormControl(props = {}) {
|
|
|
15088
15213
|
shouldSkipSetValueAs
|
|
15089
15214
|
? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
|
|
15090
15215
|
: setFieldValue(name, defaultValue);
|
|
15091
|
-
_state.mount && _setValid();
|
|
15216
|
+
_state.mount && !_state.action && _setValid();
|
|
15092
15217
|
}
|
|
15093
15218
|
};
|
|
15094
15219
|
const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
|
|
@@ -15842,7 +15967,8 @@ function createFormControl(props = {}) {
|
|
|
15842
15967
|
_state.mount =
|
|
15843
15968
|
!_proxyFormState.isValid ||
|
|
15844
15969
|
!!keepStateOptions.keepIsValid ||
|
|
15845
|
-
!!keepStateOptions.keepDirtyValues
|
|
15970
|
+
!!keepStateOptions.keepDirtyValues ||
|
|
15971
|
+
(!_options.shouldUnregister && !isEmptyObject(values));
|
|
15846
15972
|
_state.watch = !!_options.shouldUnregister;
|
|
15847
15973
|
_subjects.state.next({
|
|
15848
15974
|
submitCount: keepStateOptions.keepSubmitCount
|
|
@@ -16104,11 +16230,15 @@ function useForm(props = {}) {
|
|
|
16104
16230
|
}
|
|
16105
16231
|
}, [control, formState.isDirty]);
|
|
16106
16232
|
React.useEffect(() => {
|
|
16233
|
+
var _a;
|
|
16107
16234
|
if (props.values && !deepEqual$1(props.values, _values.current)) {
|
|
16108
16235
|
control._reset(props.values, {
|
|
16109
16236
|
keepFieldsRef: true,
|
|
16110
16237
|
...control._options.resetOptions,
|
|
16111
16238
|
});
|
|
16239
|
+
if (!((_a = control._options.resetOptions) === null || _a === void 0 ? void 0 : _a.keepIsValid)) {
|
|
16240
|
+
control._setValid();
|
|
16241
|
+
}
|
|
16112
16242
|
_values.current = props.values;
|
|
16113
16243
|
updateFormState((state) => ({ ...state }));
|
|
16114
16244
|
}
|
|
@@ -16132,7 +16262,7 @@ function useForm(props = {}) {
|
|
|
16132
16262
|
}
|
|
16133
16263
|
|
|
16134
16264
|
// src/primitive.tsx
|
|
16135
|
-
var NODES = [
|
|
16265
|
+
var NODES$1 = [
|
|
16136
16266
|
"a",
|
|
16137
16267
|
"button",
|
|
16138
16268
|
"div",
|
|
@@ -16151,8 +16281,8 @@ var NODES = [
|
|
|
16151
16281
|
"svg",
|
|
16152
16282
|
"ul"
|
|
16153
16283
|
];
|
|
16154
|
-
var Primitive = NODES.reduce((primitive, node) => {
|
|
16155
|
-
const Slot = createSlot(`Primitive.${node}`);
|
|
16284
|
+
var Primitive$1 = NODES$1.reduce((primitive, node) => {
|
|
16285
|
+
const Slot = createSlot$1(`Primitive.${node}`);
|
|
16156
16286
|
const Node = React__namespace.forwardRef((props, forwardedRef) => {
|
|
16157
16287
|
const { asChild, ...primitiveProps } = props;
|
|
16158
16288
|
const Comp = asChild ? Slot : node;
|
|
@@ -16164,14 +16294,11 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
16164
16294
|
Node.displayName = `Primitive.${node}`;
|
|
16165
16295
|
return { ...primitive, [node]: Node };
|
|
16166
16296
|
}, {});
|
|
16167
|
-
function dispatchDiscreteCustomEvent(target, event) {
|
|
16168
|
-
if (target) ReactDOM__namespace.flushSync(() => target.dispatchEvent(event));
|
|
16169
|
-
}
|
|
16170
16297
|
|
|
16171
16298
|
var NAME$1 = "Label";
|
|
16172
16299
|
var Label$1 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
16173
16300
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16174
|
-
Primitive.label,
|
|
16301
|
+
Primitive$1.label,
|
|
16175
16302
|
{
|
|
16176
16303
|
...props,
|
|
16177
16304
|
ref: forwardedRef,
|
|
@@ -16189,7 +16316,36 @@ var Root$2 = Label$1;
|
|
|
16189
16316
|
|
|
16190
16317
|
function r$2(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r$2(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r$2(e))&&(n&&(n+=" "),n+=t);return n}
|
|
16191
16318
|
|
|
16319
|
+
/**
|
|
16320
|
+
* Concatenates two arrays faster than the array spread operator.
|
|
16321
|
+
*/
|
|
16322
|
+
const concatArrays = (array1, array2) => {
|
|
16323
|
+
// Pre-allocate for better V8 optimization
|
|
16324
|
+
const combinedArray = new Array(array1.length + array2.length);
|
|
16325
|
+
for (let i = 0; i < array1.length; i++) {
|
|
16326
|
+
combinedArray[i] = array1[i];
|
|
16327
|
+
}
|
|
16328
|
+
for (let i = 0; i < array2.length; i++) {
|
|
16329
|
+
combinedArray[array1.length + i] = array2[i];
|
|
16330
|
+
}
|
|
16331
|
+
return combinedArray;
|
|
16332
|
+
};
|
|
16333
|
+
|
|
16334
|
+
// Factory function ensures consistent object shapes
|
|
16335
|
+
const createClassValidatorObject = (classGroupId, validator) => ({
|
|
16336
|
+
classGroupId,
|
|
16337
|
+
validator
|
|
16338
|
+
});
|
|
16339
|
+
// Factory ensures consistent ClassPartObject shape
|
|
16340
|
+
const createClassPartObject = (nextPart = new Map(), validators = null, classGroupId) => ({
|
|
16341
|
+
nextPart,
|
|
16342
|
+
validators,
|
|
16343
|
+
classGroupId
|
|
16344
|
+
});
|
|
16192
16345
|
const CLASS_PART_SEPARATOR = '-';
|
|
16346
|
+
const EMPTY_CONFLICTS = [];
|
|
16347
|
+
// I use two dots here because one dot is used as prefix for class groups in plugins
|
|
16348
|
+
const ARBITRARY_PROPERTY_PREFIX = 'arbitrary..';
|
|
16193
16349
|
const createClassGroupUtils = config => {
|
|
16194
16350
|
const classMap = createClassMap(config);
|
|
16195
16351
|
const {
|
|
@@ -16197,54 +16353,73 @@ const createClassGroupUtils = config => {
|
|
|
16197
16353
|
conflictingClassGroupModifiers
|
|
16198
16354
|
} = config;
|
|
16199
16355
|
const getClassGroupId = className => {
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
if (classParts[0] === '' && classParts.length !== 1) {
|
|
16203
|
-
classParts.shift();
|
|
16356
|
+
if (className.startsWith('[') && className.endsWith(']')) {
|
|
16357
|
+
return getGroupIdForArbitraryProperty(className);
|
|
16204
16358
|
}
|
|
16205
|
-
|
|
16359
|
+
const classParts = className.split(CLASS_PART_SEPARATOR);
|
|
16360
|
+
// Classes like `-inset-1` produce an empty string as first classPart. We assume that classes for negative values are used correctly and skip it.
|
|
16361
|
+
const startIndex = classParts[0] === '' && classParts.length > 1 ? 1 : 0;
|
|
16362
|
+
return getGroupRecursive(classParts, startIndex, classMap);
|
|
16206
16363
|
};
|
|
16207
16364
|
const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16365
|
+
if (hasPostfixModifier) {
|
|
16366
|
+
const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
|
|
16367
|
+
const baseConflicts = conflictingClassGroups[classGroupId];
|
|
16368
|
+
if (modifierConflicts) {
|
|
16369
|
+
if (baseConflicts) {
|
|
16370
|
+
// Merge base conflicts with modifier conflicts
|
|
16371
|
+
return concatArrays(baseConflicts, modifierConflicts);
|
|
16372
|
+
}
|
|
16373
|
+
// Only modifier conflicts
|
|
16374
|
+
return modifierConflicts;
|
|
16375
|
+
}
|
|
16376
|
+
// Fall back to without postfix if no modifier conflicts
|
|
16377
|
+
return baseConflicts || EMPTY_CONFLICTS;
|
|
16211
16378
|
}
|
|
16212
|
-
return
|
|
16379
|
+
return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
|
|
16213
16380
|
};
|
|
16214
16381
|
return {
|
|
16215
16382
|
getClassGroupId,
|
|
16216
16383
|
getConflictingClassGroupIds
|
|
16217
16384
|
};
|
|
16218
16385
|
};
|
|
16219
|
-
const getGroupRecursive = (classParts, classPartObject) => {
|
|
16220
|
-
|
|
16386
|
+
const getGroupRecursive = (classParts, startIndex, classPartObject) => {
|
|
16387
|
+
const classPathsLength = classParts.length - startIndex;
|
|
16388
|
+
if (classPathsLength === 0) {
|
|
16221
16389
|
return classPartObject.classGroupId;
|
|
16222
16390
|
}
|
|
16223
|
-
const currentClassPart = classParts[
|
|
16391
|
+
const currentClassPart = classParts[startIndex];
|
|
16224
16392
|
const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
|
|
16225
|
-
|
|
16226
|
-
|
|
16227
|
-
return
|
|
16393
|
+
if (nextClassPartObject) {
|
|
16394
|
+
const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
|
|
16395
|
+
if (result) return result;
|
|
16228
16396
|
}
|
|
16229
|
-
|
|
16397
|
+
const validators = classPartObject.validators;
|
|
16398
|
+
if (validators === null) {
|
|
16230
16399
|
return undefined;
|
|
16231
16400
|
}
|
|
16232
|
-
|
|
16233
|
-
|
|
16234
|
-
|
|
16235
|
-
|
|
16236
|
-
|
|
16237
|
-
|
|
16238
|
-
|
|
16239
|
-
if (arbitraryPropertyRegex.test(className)) {
|
|
16240
|
-
const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
|
|
16241
|
-
const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(':'));
|
|
16242
|
-
if (property) {
|
|
16243
|
-
// I use two dots here because one dot is used as prefix for class groups in plugins
|
|
16244
|
-
return 'arbitrary..' + property;
|
|
16401
|
+
// Build classRest string efficiently by joining from startIndex onwards
|
|
16402
|
+
const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
|
|
16403
|
+
const validatorsLength = validators.length;
|
|
16404
|
+
for (let i = 0; i < validatorsLength; i++) {
|
|
16405
|
+
const validatorObj = validators[i];
|
|
16406
|
+
if (validatorObj.validator(classRest)) {
|
|
16407
|
+
return validatorObj.classGroupId;
|
|
16245
16408
|
}
|
|
16246
16409
|
}
|
|
16410
|
+
return undefined;
|
|
16247
16411
|
};
|
|
16412
|
+
/**
|
|
16413
|
+
* Get the class group ID for an arbitrary property.
|
|
16414
|
+
*
|
|
16415
|
+
* @param className - The class name to get the group ID for. Is expected to be string starting with `[` and ending with `]`.
|
|
16416
|
+
*/
|
|
16417
|
+
const getGroupIdForArbitraryProperty = className => className.slice(1, -1).indexOf(':') === -1 ? undefined : (() => {
|
|
16418
|
+
const content = className.slice(1, -1);
|
|
16419
|
+
const colonIndex = content.indexOf(':');
|
|
16420
|
+
const property = content.slice(0, colonIndex);
|
|
16421
|
+
return property ? ARBITRARY_PROPERTY_PREFIX + property : undefined;
|
|
16422
|
+
})();
|
|
16248
16423
|
/**
|
|
16249
16424
|
* Exported for testing only
|
|
16250
16425
|
*/
|
|
@@ -16253,54 +16428,77 @@ const createClassMap = config => {
|
|
|
16253
16428
|
theme,
|
|
16254
16429
|
classGroups
|
|
16255
16430
|
} = config;
|
|
16256
|
-
|
|
16257
|
-
|
|
16258
|
-
|
|
16259
|
-
|
|
16431
|
+
return processClassGroups(classGroups, theme);
|
|
16432
|
+
};
|
|
16433
|
+
// Split into separate functions to maintain monomorphic call sites
|
|
16434
|
+
const processClassGroups = (classGroups, theme) => {
|
|
16435
|
+
const classMap = createClassPartObject();
|
|
16260
16436
|
for (const classGroupId in classGroups) {
|
|
16261
|
-
|
|
16437
|
+
const group = classGroups[classGroupId];
|
|
16438
|
+
processClassesRecursively(group, classMap, classGroupId, theme);
|
|
16262
16439
|
}
|
|
16263
16440
|
return classMap;
|
|
16264
16441
|
};
|
|
16265
16442
|
const processClassesRecursively = (classGroup, classPartObject, classGroupId, theme) => {
|
|
16266
|
-
classGroup.
|
|
16267
|
-
|
|
16268
|
-
|
|
16269
|
-
|
|
16270
|
-
|
|
16271
|
-
|
|
16272
|
-
|
|
16273
|
-
|
|
16274
|
-
|
|
16275
|
-
|
|
16276
|
-
|
|
16277
|
-
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
16443
|
+
const len = classGroup.length;
|
|
16444
|
+
for (let i = 0; i < len; i++) {
|
|
16445
|
+
const classDefinition = classGroup[i];
|
|
16446
|
+
processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
16447
|
+
}
|
|
16448
|
+
};
|
|
16449
|
+
// Split into separate functions for each type to maintain monomorphic call sites
|
|
16450
|
+
const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
16451
|
+
if (typeof classDefinition === 'string') {
|
|
16452
|
+
processStringDefinition(classDefinition, classPartObject, classGroupId);
|
|
16453
|
+
return;
|
|
16454
|
+
}
|
|
16455
|
+
if (typeof classDefinition === 'function') {
|
|
16456
|
+
processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
16457
|
+
return;
|
|
16458
|
+
}
|
|
16459
|
+
processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
|
|
16460
|
+
};
|
|
16461
|
+
const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
|
|
16462
|
+
const classPartObjectToEdit = classDefinition === '' ? classPartObject : getPart(classPartObject, classDefinition);
|
|
16463
|
+
classPartObjectToEdit.classGroupId = classGroupId;
|
|
16464
|
+
};
|
|
16465
|
+
const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
16466
|
+
if (isThemeGetter(classDefinition)) {
|
|
16467
|
+
processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
|
|
16468
|
+
return;
|
|
16469
|
+
}
|
|
16470
|
+
if (classPartObject.validators === null) {
|
|
16471
|
+
classPartObject.validators = [];
|
|
16472
|
+
}
|
|
16473
|
+
classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
|
|
16474
|
+
};
|
|
16475
|
+
const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
|
|
16476
|
+
const entries = Object.entries(classDefinition);
|
|
16477
|
+
const len = entries.length;
|
|
16478
|
+
for (let i = 0; i < len; i++) {
|
|
16479
|
+
const [key, value] = entries[i];
|
|
16480
|
+
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
16481
|
+
}
|
|
16287
16482
|
};
|
|
16288
16483
|
const getPart = (classPartObject, path) => {
|
|
16289
|
-
let
|
|
16290
|
-
path.split(CLASS_PART_SEPARATOR)
|
|
16291
|
-
|
|
16292
|
-
|
|
16293
|
-
|
|
16294
|
-
|
|
16295
|
-
|
|
16484
|
+
let current = classPartObject;
|
|
16485
|
+
const parts = path.split(CLASS_PART_SEPARATOR);
|
|
16486
|
+
const len = parts.length;
|
|
16487
|
+
for (let i = 0; i < len; i++) {
|
|
16488
|
+
const part = parts[i];
|
|
16489
|
+
let next = current.nextPart.get(part);
|
|
16490
|
+
if (!next) {
|
|
16491
|
+
next = createClassPartObject();
|
|
16492
|
+
current.nextPart.set(part, next);
|
|
16296
16493
|
}
|
|
16297
|
-
|
|
16298
|
-
}
|
|
16299
|
-
return
|
|
16494
|
+
current = next;
|
|
16495
|
+
}
|
|
16496
|
+
return current;
|
|
16300
16497
|
};
|
|
16301
|
-
|
|
16498
|
+
// Type guard maintains monomorphic check
|
|
16499
|
+
const isThemeGetter = func => 'isThemeGetter' in func && func.isThemeGetter === true;
|
|
16302
16500
|
|
|
16303
|
-
// LRU cache
|
|
16501
|
+
// LRU cache implementation using plain objects for simplicity
|
|
16304
16502
|
const createLruCache = maxCacheSize => {
|
|
16305
16503
|
if (maxCacheSize < 1) {
|
|
16306
16504
|
return {
|
|
@@ -16309,31 +16507,31 @@ const createLruCache = maxCacheSize => {
|
|
|
16309
16507
|
};
|
|
16310
16508
|
}
|
|
16311
16509
|
let cacheSize = 0;
|
|
16312
|
-
let cache =
|
|
16313
|
-
let previousCache =
|
|
16510
|
+
let cache = Object.create(null);
|
|
16511
|
+
let previousCache = Object.create(null);
|
|
16314
16512
|
const update = (key, value) => {
|
|
16315
|
-
cache
|
|
16513
|
+
cache[key] = value;
|
|
16316
16514
|
cacheSize++;
|
|
16317
16515
|
if (cacheSize > maxCacheSize) {
|
|
16318
16516
|
cacheSize = 0;
|
|
16319
16517
|
previousCache = cache;
|
|
16320
|
-
cache =
|
|
16518
|
+
cache = Object.create(null);
|
|
16321
16519
|
}
|
|
16322
16520
|
};
|
|
16323
16521
|
return {
|
|
16324
16522
|
get(key) {
|
|
16325
|
-
let value = cache
|
|
16523
|
+
let value = cache[key];
|
|
16326
16524
|
if (value !== undefined) {
|
|
16327
16525
|
return value;
|
|
16328
16526
|
}
|
|
16329
|
-
if ((value = previousCache
|
|
16527
|
+
if ((value = previousCache[key]) !== undefined) {
|
|
16330
16528
|
update(key, value);
|
|
16331
16529
|
return value;
|
|
16332
16530
|
}
|
|
16333
16531
|
},
|
|
16334
16532
|
set(key, value) {
|
|
16335
|
-
if (cache
|
|
16336
|
-
cache
|
|
16533
|
+
if (key in cache) {
|
|
16534
|
+
cache[key] = value;
|
|
16337
16535
|
} else {
|
|
16338
16536
|
update(key, value);
|
|
16339
16537
|
}
|
|
@@ -16342,7 +16540,15 @@ const createLruCache = maxCacheSize => {
|
|
|
16342
16540
|
};
|
|
16343
16541
|
const IMPORTANT_MODIFIER = '!';
|
|
16344
16542
|
const MODIFIER_SEPARATOR = ':';
|
|
16345
|
-
const
|
|
16543
|
+
const EMPTY_MODIFIERS = [];
|
|
16544
|
+
// Pre-allocated result object shape for consistency
|
|
16545
|
+
const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
|
|
16546
|
+
modifiers,
|
|
16547
|
+
hasImportantModifier,
|
|
16548
|
+
baseClassName,
|
|
16549
|
+
maybePostfixModifierPosition,
|
|
16550
|
+
isExternal
|
|
16551
|
+
});
|
|
16346
16552
|
const createParseClassName = config => {
|
|
16347
16553
|
const {
|
|
16348
16554
|
prefix,
|
|
@@ -16355,17 +16561,19 @@ const createParseClassName = config => {
|
|
|
16355
16561
|
* @see https://github.com/tailwindlabs/tailwindcss/blob/v3.2.2/src/util/splitAtTopLevelOnly.js
|
|
16356
16562
|
*/
|
|
16357
16563
|
let parseClassName = className => {
|
|
16564
|
+
// Use simple array with push for better performance
|
|
16358
16565
|
const modifiers = [];
|
|
16359
16566
|
let bracketDepth = 0;
|
|
16360
16567
|
let parenDepth = 0;
|
|
16361
16568
|
let modifierStart = 0;
|
|
16362
16569
|
let postfixModifierPosition;
|
|
16363
|
-
|
|
16364
|
-
|
|
16570
|
+
const len = className.length;
|
|
16571
|
+
for (let index = 0; index < len; index++) {
|
|
16572
|
+
const currentCharacter = className[index];
|
|
16365
16573
|
if (bracketDepth === 0 && parenDepth === 0) {
|
|
16366
16574
|
if (currentCharacter === MODIFIER_SEPARATOR) {
|
|
16367
16575
|
modifiers.push(className.slice(modifierStart, index));
|
|
16368
|
-
modifierStart = index +
|
|
16576
|
+
modifierStart = index + 1;
|
|
16369
16577
|
continue;
|
|
16370
16578
|
}
|
|
16371
16579
|
if (currentCharacter === '/') {
|
|
@@ -16373,37 +16581,31 @@ const createParseClassName = config => {
|
|
|
16373
16581
|
continue;
|
|
16374
16582
|
}
|
|
16375
16583
|
}
|
|
16376
|
-
if (currentCharacter === '[')
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
|
|
16383
|
-
|
|
16384
|
-
|
|
16584
|
+
if (currentCharacter === '[') bracketDepth++;else if (currentCharacter === ']') bracketDepth--;else if (currentCharacter === '(') parenDepth++;else if (currentCharacter === ')') parenDepth--;
|
|
16585
|
+
}
|
|
16586
|
+
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
|
|
16587
|
+
// Inline important modifier check
|
|
16588
|
+
let baseClassName = baseClassNameWithImportantModifier;
|
|
16589
|
+
let hasImportantModifier = false;
|
|
16590
|
+
if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
|
|
16591
|
+
baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
|
|
16592
|
+
hasImportantModifier = true;
|
|
16593
|
+
} else if (
|
|
16594
|
+
/**
|
|
16595
|
+
* In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
|
|
16596
|
+
* @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
|
|
16597
|
+
*/
|
|
16598
|
+
baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)) {
|
|
16599
|
+
baseClassName = baseClassNameWithImportantModifier.slice(1);
|
|
16600
|
+
hasImportantModifier = true;
|
|
16385
16601
|
}
|
|
16386
|
-
const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
|
|
16387
|
-
const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
|
|
16388
|
-
const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
|
|
16389
16602
|
const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : undefined;
|
|
16390
|
-
return
|
|
16391
|
-
modifiers,
|
|
16392
|
-
hasImportantModifier,
|
|
16393
|
-
baseClassName,
|
|
16394
|
-
maybePostfixModifierPosition
|
|
16395
|
-
};
|
|
16603
|
+
return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
|
|
16396
16604
|
};
|
|
16397
16605
|
if (prefix) {
|
|
16398
16606
|
const fullPrefix = prefix + MODIFIER_SEPARATOR;
|
|
16399
16607
|
const parseClassNameOriginal = parseClassName;
|
|
16400
|
-
parseClassName = className => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.
|
|
16401
|
-
isExternal: true,
|
|
16402
|
-
modifiers: [],
|
|
16403
|
-
hasImportantModifier: false,
|
|
16404
|
-
baseClassName: className,
|
|
16405
|
-
maybePostfixModifierPosition: undefined
|
|
16406
|
-
};
|
|
16608
|
+
parseClassName = className => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, undefined, true);
|
|
16407
16609
|
}
|
|
16408
16610
|
if (experimentalParseClassName) {
|
|
16409
16611
|
const parseClassNameOriginal = parseClassName;
|
|
@@ -16414,19 +16616,6 @@ const createParseClassName = config => {
|
|
|
16414
16616
|
}
|
|
16415
16617
|
return parseClassName;
|
|
16416
16618
|
};
|
|
16417
|
-
const stripImportantModifier = baseClassName => {
|
|
16418
|
-
if (baseClassName.endsWith(IMPORTANT_MODIFIER)) {
|
|
16419
|
-
return baseClassName.substring(0, baseClassName.length - 1);
|
|
16420
|
-
}
|
|
16421
|
-
/**
|
|
16422
|
-
* In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
|
|
16423
|
-
* @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
|
|
16424
|
-
*/
|
|
16425
|
-
if (baseClassName.startsWith(IMPORTANT_MODIFIER)) {
|
|
16426
|
-
return baseClassName.substring(1);
|
|
16427
|
-
}
|
|
16428
|
-
return baseClassName;
|
|
16429
|
-
};
|
|
16430
16619
|
|
|
16431
16620
|
/**
|
|
16432
16621
|
* Sorts modifiers according to following schema:
|
|
@@ -16434,26 +16623,41 @@ const stripImportantModifier = baseClassName => {
|
|
|
16434
16623
|
* - When an arbitrary variant appears, it must be preserved which modifiers are before and after it
|
|
16435
16624
|
*/
|
|
16436
16625
|
const createSortModifiers = config => {
|
|
16437
|
-
|
|
16438
|
-
const
|
|
16439
|
-
|
|
16440
|
-
|
|
16441
|
-
|
|
16442
|
-
|
|
16443
|
-
|
|
16444
|
-
|
|
16445
|
-
|
|
16446
|
-
|
|
16447
|
-
|
|
16448
|
-
|
|
16626
|
+
// Pre-compute weights for all known modifiers for O(1) comparison
|
|
16627
|
+
const modifierWeights = new Map();
|
|
16628
|
+
// Assign weights to sensitive modifiers (highest priority, but preserve order)
|
|
16629
|
+
config.orderSensitiveModifiers.forEach((mod, index) => {
|
|
16630
|
+
modifierWeights.set(mod, 1000000 + index); // High weights for sensitive mods
|
|
16631
|
+
});
|
|
16632
|
+
return modifiers => {
|
|
16633
|
+
const result = [];
|
|
16634
|
+
let currentSegment = [];
|
|
16635
|
+
// Process modifiers in one pass
|
|
16636
|
+
for (let i = 0; i < modifiers.length; i++) {
|
|
16637
|
+
const modifier = modifiers[i];
|
|
16638
|
+
// Check if modifier is sensitive (starts with '[' or in orderSensitiveModifiers)
|
|
16639
|
+
const isArbitrary = modifier[0] === '[';
|
|
16640
|
+
const isOrderSensitive = modifierWeights.has(modifier);
|
|
16641
|
+
if (isArbitrary || isOrderSensitive) {
|
|
16642
|
+
// Sort and flush current segment alphabetically
|
|
16643
|
+
if (currentSegment.length > 0) {
|
|
16644
|
+
currentSegment.sort();
|
|
16645
|
+
result.push(...currentSegment);
|
|
16646
|
+
currentSegment = [];
|
|
16647
|
+
}
|
|
16648
|
+
result.push(modifier);
|
|
16449
16649
|
} else {
|
|
16450
|
-
|
|
16650
|
+
// Regular modifier - add to current segment for batch sorting
|
|
16651
|
+
currentSegment.push(modifier);
|
|
16451
16652
|
}
|
|
16452
|
-
}
|
|
16453
|
-
|
|
16454
|
-
|
|
16653
|
+
}
|
|
16654
|
+
// Sort and add any remaining segment items
|
|
16655
|
+
if (currentSegment.length > 0) {
|
|
16656
|
+
currentSegment.sort();
|
|
16657
|
+
result.push(...currentSegment);
|
|
16658
|
+
}
|
|
16659
|
+
return result;
|
|
16455
16660
|
};
|
|
16456
|
-
return sortModifiers;
|
|
16457
16661
|
};
|
|
16458
16662
|
const createConfigUtils = config => ({
|
|
16459
16663
|
cache: createLruCache(config.cacheSize),
|
|
@@ -16508,10 +16712,11 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
16508
16712
|
}
|
|
16509
16713
|
hasPostfixModifier = false;
|
|
16510
16714
|
}
|
|
16511
|
-
|
|
16715
|
+
// Fast path: skip sorting for empty or single modifier
|
|
16716
|
+
const variantModifier = modifiers.length === 0 ? '' : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(':');
|
|
16512
16717
|
const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
|
|
16513
16718
|
const classId = modifierId + classGroupId;
|
|
16514
|
-
if (classGroupsInConflict.
|
|
16719
|
+
if (classGroupsInConflict.indexOf(classId) > -1) {
|
|
16515
16720
|
// Tailwind class omitted due to conflict
|
|
16516
16721
|
continue;
|
|
16517
16722
|
}
|
|
@@ -16536,13 +16741,13 @@ const mergeClassList = (classList, configUtils) => {
|
|
|
16536
16741
|
*
|
|
16537
16742
|
* Original code has MIT license: Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
|
|
16538
16743
|
*/
|
|
16539
|
-
|
|
16744
|
+
const twJoin = (...classLists) => {
|
|
16540
16745
|
let index = 0;
|
|
16541
16746
|
let argument;
|
|
16542
16747
|
let resolvedValue;
|
|
16543
16748
|
let string = '';
|
|
16544
|
-
while (index <
|
|
16545
|
-
if (argument =
|
|
16749
|
+
while (index < classLists.length) {
|
|
16750
|
+
if (argument = classLists[index++]) {
|
|
16546
16751
|
if (resolvedValue = toValue(argument)) {
|
|
16547
16752
|
string && (string += ' ');
|
|
16548
16753
|
string += resolvedValue;
|
|
@@ -16550,8 +16755,9 @@ function twJoin() {
|
|
|
16550
16755
|
}
|
|
16551
16756
|
}
|
|
16552
16757
|
return string;
|
|
16553
|
-
}
|
|
16758
|
+
};
|
|
16554
16759
|
const toValue = mix => {
|
|
16760
|
+
// Fast path for strings
|
|
16555
16761
|
if (typeof mix === 'string') {
|
|
16556
16762
|
return mix;
|
|
16557
16763
|
}
|
|
@@ -16567,20 +16773,20 @@ const toValue = mix => {
|
|
|
16567
16773
|
}
|
|
16568
16774
|
return string;
|
|
16569
16775
|
};
|
|
16570
|
-
|
|
16776
|
+
const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
|
|
16571
16777
|
let configUtils;
|
|
16572
16778
|
let cacheGet;
|
|
16573
16779
|
let cacheSet;
|
|
16574
|
-
let functionToCall
|
|
16575
|
-
|
|
16780
|
+
let functionToCall;
|
|
16781
|
+
const initTailwindMerge = classList => {
|
|
16576
16782
|
const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
|
|
16577
16783
|
configUtils = createConfigUtils(config);
|
|
16578
16784
|
cacheGet = configUtils.cache.get;
|
|
16579
16785
|
cacheSet = configUtils.cache.set;
|
|
16580
16786
|
functionToCall = tailwindMerge;
|
|
16581
16787
|
return tailwindMerge(classList);
|
|
16582
|
-
}
|
|
16583
|
-
|
|
16788
|
+
};
|
|
16789
|
+
const tailwindMerge = classList => {
|
|
16584
16790
|
const cachedResult = cacheGet(classList);
|
|
16585
16791
|
if (cachedResult) {
|
|
16586
16792
|
return cachedResult;
|
|
@@ -16588,13 +16794,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
|
|
|
16588
16794
|
const result = mergeClassList(classList, configUtils);
|
|
16589
16795
|
cacheSet(classList, result);
|
|
16590
16796
|
return result;
|
|
16591
|
-
}
|
|
16592
|
-
return function callTailwindMerge() {
|
|
16593
|
-
return functionToCall(twJoin.apply(null, arguments));
|
|
16594
16797
|
};
|
|
16595
|
-
|
|
16798
|
+
functionToCall = initTailwindMerge;
|
|
16799
|
+
return (...args) => functionToCall(twJoin(...args));
|
|
16800
|
+
};
|
|
16801
|
+
const fallbackThemeArr = [];
|
|
16596
16802
|
const fromTheme = key => {
|
|
16597
|
-
const themeGetter = theme => theme[key] ||
|
|
16803
|
+
const themeGetter = theme => theme[key] || fallbackThemeArr;
|
|
16598
16804
|
themeGetter.isThemeGetter = true;
|
|
16599
16805
|
return themeGetter;
|
|
16600
16806
|
};
|
|
@@ -19217,7 +19423,7 @@ const FloatingLabel = React__namespace.forwardRef((_a, ref) => {
|
|
|
19217
19423
|
const LabelComponent = isFormLabel ? FormLabel : Label;
|
|
19218
19424
|
const isEmpty = !value || value.length === 0;
|
|
19219
19425
|
const isFloating = isFocused || !isEmpty;
|
|
19220
|
-
return (jsxRuntime.jsxs("div", { className: cn("pointer-events-none absolute translate-x-2", "z-10 block", "duration-200 ease-in-out", isFloating ? "top-0 -translate-y-1/2" : "top-1/2 -translate-y-1/2", className), children: [jsxRuntime.jsx("div", { className: "bg-background absolute left-0 right-0 top-1/2 z-
|
|
19426
|
+
return (jsxRuntime.jsxs("div", { className: cn("pointer-events-none absolute translate-x-2", "z-10 block", "duration-200 ease-in-out", isFloating ? "top-0 -translate-y-1/2" : "top-1/2 -translate-y-1/2", className), children: [jsxRuntime.jsx("div", { className: "bg-background absolute left-0 right-0 top-1/2 z-10 h-[5px] -translate-x-0 -translate-y-[calc(50%+2px)]" }), jsxRuntime.jsxs(LabelComponent, Object.assign({ ref: ref, className: cn("relative z-20 block",
|
|
19221
19427
|
// "after:bg-background after:absolute after:left-0 after:right-0 after:top-1/2 after:z-0 after:h-px after:-translate-y-1/2 after:content-['']",
|
|
19222
19428
|
"m-0 p-0 px-1 leading-none", "duration-200 ease-in-out", isFloating
|
|
19223
19429
|
? "text-xs font-medium"
|
|
@@ -19468,6 +19674,127 @@ function isFunction(value) {
|
|
|
19468
19674
|
return typeof value === "function";
|
|
19469
19675
|
}
|
|
19470
19676
|
|
|
19677
|
+
// src/slot.tsx
|
|
19678
|
+
// @__NO_SIDE_EFFECTS__
|
|
19679
|
+
function createSlot(ownerName) {
|
|
19680
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
19681
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
19682
|
+
const { children, ...slotProps } = props;
|
|
19683
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
19684
|
+
const slottable = childrenArray.find(isSlottable);
|
|
19685
|
+
if (slottable) {
|
|
19686
|
+
const newElement = slottable.props.children;
|
|
19687
|
+
const newChildren = childrenArray.map((child) => {
|
|
19688
|
+
if (child === slottable) {
|
|
19689
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
19690
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
19691
|
+
} else {
|
|
19692
|
+
return child;
|
|
19693
|
+
}
|
|
19694
|
+
});
|
|
19695
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
19696
|
+
}
|
|
19697
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
19698
|
+
});
|
|
19699
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
19700
|
+
return Slot2;
|
|
19701
|
+
}
|
|
19702
|
+
// @__NO_SIDE_EFFECTS__
|
|
19703
|
+
function createSlotClone(ownerName) {
|
|
19704
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
19705
|
+
const { children, ...slotProps } = props;
|
|
19706
|
+
if (React__namespace.isValidElement(children)) {
|
|
19707
|
+
const childrenRef = getElementRef$1(children);
|
|
19708
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
19709
|
+
if (children.type !== React__namespace.Fragment) {
|
|
19710
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
19711
|
+
}
|
|
19712
|
+
return React__namespace.cloneElement(children, props2);
|
|
19713
|
+
}
|
|
19714
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
19715
|
+
});
|
|
19716
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
19717
|
+
return SlotClone;
|
|
19718
|
+
}
|
|
19719
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
19720
|
+
function isSlottable(child) {
|
|
19721
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
19722
|
+
}
|
|
19723
|
+
function mergeProps(slotProps, childProps) {
|
|
19724
|
+
const overrideProps = { ...childProps };
|
|
19725
|
+
for (const propName in childProps) {
|
|
19726
|
+
const slotPropValue = slotProps[propName];
|
|
19727
|
+
const childPropValue = childProps[propName];
|
|
19728
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
19729
|
+
if (isHandler) {
|
|
19730
|
+
if (slotPropValue && childPropValue) {
|
|
19731
|
+
overrideProps[propName] = (...args) => {
|
|
19732
|
+
const result = childPropValue(...args);
|
|
19733
|
+
slotPropValue(...args);
|
|
19734
|
+
return result;
|
|
19735
|
+
};
|
|
19736
|
+
} else if (slotPropValue) {
|
|
19737
|
+
overrideProps[propName] = slotPropValue;
|
|
19738
|
+
}
|
|
19739
|
+
} else if (propName === "style") {
|
|
19740
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
19741
|
+
} else if (propName === "className") {
|
|
19742
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
19743
|
+
}
|
|
19744
|
+
}
|
|
19745
|
+
return { ...slotProps, ...overrideProps };
|
|
19746
|
+
}
|
|
19747
|
+
function getElementRef$1(element) {
|
|
19748
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
19749
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
19750
|
+
if (mayWarn) {
|
|
19751
|
+
return element.ref;
|
|
19752
|
+
}
|
|
19753
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
19754
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
19755
|
+
if (mayWarn) {
|
|
19756
|
+
return element.props.ref;
|
|
19757
|
+
}
|
|
19758
|
+
return element.props.ref || element.ref;
|
|
19759
|
+
}
|
|
19760
|
+
|
|
19761
|
+
// src/primitive.tsx
|
|
19762
|
+
var NODES = [
|
|
19763
|
+
"a",
|
|
19764
|
+
"button",
|
|
19765
|
+
"div",
|
|
19766
|
+
"form",
|
|
19767
|
+
"h2",
|
|
19768
|
+
"h3",
|
|
19769
|
+
"img",
|
|
19770
|
+
"input",
|
|
19771
|
+
"label",
|
|
19772
|
+
"li",
|
|
19773
|
+
"nav",
|
|
19774
|
+
"ol",
|
|
19775
|
+
"p",
|
|
19776
|
+
"select",
|
|
19777
|
+
"span",
|
|
19778
|
+
"svg",
|
|
19779
|
+
"ul"
|
|
19780
|
+
];
|
|
19781
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
19782
|
+
const Slot = createSlot(`Primitive.${node}`);
|
|
19783
|
+
const Node = React__namespace.forwardRef((props, forwardedRef) => {
|
|
19784
|
+
const { asChild, ...primitiveProps } = props;
|
|
19785
|
+
const Comp = asChild ? Slot : node;
|
|
19786
|
+
if (typeof window !== "undefined") {
|
|
19787
|
+
window[Symbol.for("radix-ui")] = true;
|
|
19788
|
+
}
|
|
19789
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
19790
|
+
});
|
|
19791
|
+
Node.displayName = `Primitive.${node}`;
|
|
19792
|
+
return { ...primitive, [node]: Node };
|
|
19793
|
+
}, {});
|
|
19794
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
19795
|
+
if (target) ReactDOM__namespace.flushSync(() => target.dispatchEvent(event));
|
|
19796
|
+
}
|
|
19797
|
+
|
|
19471
19798
|
// packages/react/use-callback-ref/src/use-callback-ref.tsx
|
|
19472
19799
|
function useCallbackRef$1(callback) {
|
|
19473
19800
|
const callbackRef = React__namespace.useRef(callback);
|
|
@@ -21185,7 +21512,7 @@ var Portal = DialogPortal;
|
|
|
21185
21512
|
var Overlay = DialogOverlay;
|
|
21186
21513
|
var Content$1 = DialogContent;
|
|
21187
21514
|
|
|
21188
|
-
var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(r,o,n)=>W(r,o,n),ue=React__namespace.createContext(void 0),K=()=>React__namespace.useContext(ue),de=React__namespace.createContext(void 0),ee=()=>React__namespace.useContext(de),fe=React__namespace.createContext(void 0),me=React__namespace.forwardRef((r,o)=>{let n=L(()=>{var e,a;return {search:"",value:(a=(e=r.value)!=null?e:r.defaultValue)!=null?a:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),u=L(()=>new Set),c=L(()=>new Map),d=L(()=>new Map),f=L(()=>new Set),p=pe(r),{label:b,children:m,value:R,onValueChange:x,filter:C,shouldFilter:S,loop:A,disablePointerSelection:ge=false,vimBindings:j=true,...O}=r,$=useId(),q=useId(),_=useId(),I=React__namespace.useRef(null),v=ke();k$2(()=>{if(R!==void 0){let e=R.trim();n.current.value=e,E.emit();}},[R]),k$2(()=>{v(6,ne);},[]);let E=React__namespace.useMemo(()=>({subscribe:e=>(f.current.add(e),()=>f.current.delete(e)),snapshot:()=>n.current,setState:(e,a,s)=>{var i,l,g,y;if(!Object.is(n.current[e],a)){if(n.current[e]=a,e==="search")J(),z(),v(1,W);else if(e==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let h=document.getElementById(_);h?h.focus():(i=document.getElementById($))==null||i.focus();}if(v(7,()=>{var h;n.current.selectedItemId=(h=M())==null?void 0:h.id,E.emit();}),s||v(5,ne),((l=p.current)==null?void 0:l.value)!==void 0){let h=a!=null?a:"";(y=(g=p.current).onValueChange)==null||y.call(g,h);return}}E.emit();}},emit:()=>{f.current.forEach(e=>e());}}),[]),U=React__namespace.useMemo(()=>({value:(e,a,s)=>{var i;a!==((i=d.current.get(e))==null?void 0:i.value)&&(d.current.set(e,{value:a,keywords:s}),n.current.filtered.items.set(e,te(a,s)),v(2,()=>{z(),E.emit();}));},item:(e,a)=>(u.current.add(e),a&&(c.current.has(a)?c.current.get(a).add(e):c.current.set(a,new Set([e]))),v(3,()=>{J(),z(),n.current.value||W(),E.emit();}),()=>{d.current.delete(e),u.current.delete(e),n.current.filtered.items.delete(e);let s=M();v(4,()=>{J(),(s==null?void 0:s.getAttribute("id"))===e&&W(),E.emit();});}),group:e=>(c.current.has(e)||c.current.set(e,new Set),()=>{d.current.delete(e),c.current.delete(e);}),filter:()=>p.current.shouldFilter,label:b||r["aria-label"],getDisablePointerSelection:()=>p.current.disablePointerSelection,listId:$,inputId:_,labelId:q,listInnerRef:I}),[]);function te(e,a){var i,l;let s=(l=(i=p.current)==null?void 0:i.filter)!=null?l:Re;return e?s(e,n.current.search,a):0}function z(){if(!n.current.search||p.current.shouldFilter===false)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach(i=>{let l=c.current.get(i),g=0;l.forEach(y=>{let h=e.get(y);g=Math.max(h,g);}),a.push([i,g]);});let s=I.current;V().sort((i,l)=>{var h,F;let g=i.getAttribute("id"),y=l.getAttribute("id");return ((h=e.get(y))!=null?h:0)-((F=e.get(g))!=null?F:0)}).forEach(i=>{let l=i.closest(Y);l?l.appendChild(i.parentElement===l?i:i.closest(`${Y} > *`)):s.appendChild(i.parentElement===s?i:i.closest(`${Y} > *`));}),a.sort((i,l)=>l[1]-i[1]).forEach(i=>{var g;let l=(g=I.current)==null?void 0:g.querySelector(`${N}[${T}="${encodeURIComponent(i[0])}"]`);l==null||l.parentElement.appendChild(l);});}function W(){let e=V().find(s=>s.getAttribute("aria-disabled")!=="true"),a=e==null?void 0:e.getAttribute(T);E.setState("value",a||void 0);}function J(){var a,s,i,l;if(!n.current.search||p.current.shouldFilter===false){n.current.filtered.count=u.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let g of u.current){let y=(s=(a=d.current.get(g))==null?void 0:a.value)!=null?s:"",h=(l=(i=d.current.get(g))==null?void 0:i.keywords)!=null?l:[],F=te(y,h);n.current.filtered.items.set(g,F),F>0&&e++;}for(let[g,y]of c.current)for(let h of y)if(n.current.filtered.items.get(h)>0){n.current.filtered.groups.add(g);break}n.current.filtered.count=e;}function ne(){var a,s,i;let e=M();e&&(((a=e.parentElement)==null?void 0:a.firstChild)===e&&((i=(s=e.closest(N))==null?void 0:s.querySelector(be))==null||i.scrollIntoView({block:"nearest"})),e.scrollIntoView({block:"nearest"}));}function M(){var e;return (e=I.current)==null?void 0:e.querySelector(`${le}[aria-selected="true"]`)}function V(){var e;return Array.from(((e=I.current)==null?void 0:e.querySelectorAll(ce))||[])}function X(e){let s=V()[e];s&&E.setState("value",s.getAttribute(T));}function Q(e){var g;let a=M(),s=V(),i=s.findIndex(y=>y===a),l=s[i+e];(g=p.current)!=null&&g.loop&&(l=i+e<0?s[s.length-1]:i+e===s.length?s[0]:s[i+e]),l&&E.setState("value",l.getAttribute(T));}function re(e){let a=M(),s=a==null?void 0:a.closest(N),i;for(;s&&!i;)s=e>0?we(s,N):De(s,N),i=s==null?void 0:s.querySelector(ce);i?E.setState("value",i.getAttribute(T)):Q(e);}let oe=()=>X(V().length-1),ie=e=>{e.preventDefault(),e.metaKey?oe():e.altKey?re(1):Q(1);},se=e=>{e.preventDefault(),e.metaKey?X(0):e.altKey?re(-1):Q(-1);};return React__namespace.createElement(Primitive.div,{ref:o,tabIndex:-1,...O,"cmdk-root":"",onKeyDown:e=>{var s;(s=O.onKeyDown)==null||s.call(O,e);let a=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||a))switch(e.key){case "n":case "j":{j&&e.ctrlKey&&ie(e);break}case "ArrowDown":{ie(e);break}case "p":case "k":{j&&e.ctrlKey&&se(e);break}case "ArrowUp":{se(e);break}case "Home":{e.preventDefault(),X(0);break}case "End":{e.preventDefault(),oe();break}case "Enter":{e.preventDefault();let i=M();if(i){let l=new Event(Z);i.dispatchEvent(l);}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:Te},b),B(r,e=>React__namespace.createElement(de.Provider,{value:E},React__namespace.createElement(ue.Provider,{value:U},e))))}),he=React__namespace.forwardRef((r,o)=>{var _,I;let n=useId(),u=React__namespace.useRef(null),c=React__namespace.useContext(fe),d=K(),f=pe(r),p=(I=(_=f.current)==null?void 0:_.forceMount)!=null?I:c==null?void 0:c.forceMount;k$2(()=>{if(!p)return d.item(n,c==null?void 0:c.id)},[p]);let b=ve(n,u,[r.value,r.children,u],r.keywords),m=ee(),R=P(v=>v.value&&v.value===b.current),x=P(v=>p||d.filter()===false?true:v.search?v.filtered.items.get(n)>0:true);React__namespace.useEffect(()=>{let v=u.current;if(!(!v||r.disabled))return v.addEventListener(Z,C),()=>v.removeEventListener(Z,C)},[x,r.onSelect,r.disabled]);function C(){var v,E;S(),(E=(v=f.current).onSelect)==null||E.call(v,b.current);}function S(){m.setState("value",b.current,true);}if(!x)return null;let{disabled:A,value:ge,onSelect:j,forceMount:O,keywords:$,...q}=r;return React__namespace.createElement(Primitive.div,{ref:composeRefs(u,o),...q,id:n,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!R,"data-disabled":!!A,"data-selected":!!R,onPointerMove:A||d.getDisablePointerSelection()?void 0:S,onClick:A?void 0:C},r.children)}),Ee=React__namespace.forwardRef((r,o)=>{let{heading:n,children:u,forceMount:c,...d}=r,f=useId(),p=React__namespace.useRef(null),b=React__namespace.useRef(null),m=useId(),R=K(),x=P(S=>c||R.filter()===false?true:S.search?S.filtered.groups.has(f):true);k$2(()=>R.group(f),[]),ve(f,p,[r.value,r.heading,b]);let C=React__namespace.useMemo(()=>({id:f,forceMount:c}),[c]);return React__namespace.createElement(Primitive.div,{ref:composeRefs(p,o),...d,"cmdk-group":"",role:"presentation",hidden:x?void 0:true},n&&React__namespace.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":true,id:m},n),B(r,S=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},React__namespace.createElement(fe.Provider,{value:C},S))))}),ye=React__namespace.forwardRef((r,o)=>{let{alwaysRender:n,...u}=r,c=React__namespace.useRef(null),d=P(f=>!f.search);return !n&&!d?null:React__namespace.createElement(Primitive.div,{ref:composeRefs(c,o),...u,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((r,o)=>{let{onValueChange:n,...u}=r,c=r.value!=null,d=ee(),f=P(m=>m.search),p=P(m=>m.selectedItemId),b=K();return React__namespace.useEffect(()=>{r.value!=null&&d.setState("search",r.value);},[r.value]),React__namespace.createElement(Primitive.input,{ref:o,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:false,"aria-autocomplete":"list",role:"combobox","aria-expanded":true,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":p,id:b.inputId,type:"text",value:c?r.value:f,onChange:m=>{c||d.setState("search",m.target.value),n==null||n(m.target.value);}})}),Ce=React__namespace.forwardRef((r,o)=>{let{children:n,label:u="Suggestions",...c}=r,d=React__namespace.useRef(null),f=React__namespace.useRef(null),p=P(m=>m.selectedItemId),b=K();return React__namespace.useEffect(()=>{if(f.current&&d.current){let m=f.current,R=d.current,x,C=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let S=m.offsetHeight;R.style.setProperty("--cmdk-list-height",S.toFixed(1)+"px");});});return C.observe(m),()=>{cancelAnimationFrame(x),C.unobserve(m);}}},[]),React__namespace.createElement(Primitive.div,{ref:composeRefs(d,o),...c,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":p,"aria-label":u,id:b.listId},B(r,m=>React__namespace.createElement("div",{ref:composeRefs(f,b.listInnerRef),"cmdk-list-sizer":""},m)))}),xe=React__namespace.forwardRef((r,o)=>{let{open:n,onOpenChange:u,overlayClassName:c,contentClassName:d,container:f,...p}=r;return React__namespace.createElement(Root$1,{open:n,onOpenChange:u},React__namespace.createElement(Portal,{container:f},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:c}),React__namespace.createElement(Content$1,{"aria-label":r.label,"cmdk-dialog":"",className:d},React__namespace.createElement(me,{ref:o,...p}))))}),Ie=React__namespace.forwardRef((r,o)=>P(u=>u.filtered.count===0)?React__namespace.createElement(Primitive.div,{ref:o,...r,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((r,o)=>{let{progress:n,children:u,label:c="Loading...",...d}=r;return React__namespace.createElement(Primitive.div,{ref:o,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":c},B(r,f=>React__namespace.createElement("div",{"aria-hidden":true},f)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(r,o){let n=r.nextElementSibling;for(;n;){if(n.matches(o))return n;n=n.nextElementSibling;}}function De(r,o){let n=r.previousElementSibling;for(;n;){if(n.matches(o))return n;n=n.previousElementSibling;}}function pe(r){let o=React__namespace.useRef(r);return k$2(()=>{o.current=r;}),o}var k$2=typeof window=="undefined"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(r){let o=React__namespace.useRef();return o.current===void 0&&(o.current=r()),o}function P(r){let o=ee(),n=()=>r(o.snapshot());return React__namespace.useSyncExternalStore(o.subscribe,n,n)}function ve(r,o,n,u=[]){let c=React__namespace.useRef(),d=K();return k$2(()=>{var b;let f=(()=>{var m;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(m=R.current.textContent)==null?void 0:m.trim():c.current}})(),p=u.map(m=>m.trim());d.value(r,f,p),(b=o.current)==null||b.setAttribute(T,f),c.current=f;}),c}var ke=()=>{let[r,o]=React__namespace.useState(),n=L(()=>new Map);return k$2(()=>{n.current.forEach(u=>u()),n.current=new Map;},[r]),(u,c)=>{n.current.set(u,c),o({});}};function Me(r){let o=r.type;return typeof o=="function"?o(r.props):"render"in o?o.render(r.props):r}function B({asChild:r,children:o},n){return r&&React__namespace.isValidElement(o)?React__namespace.cloneElement(Me(o),{ref:o.ref},n(o.props.children)):n(o)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};
|
|
21515
|
+
var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(r,o,n)=>W(r,o,n),ue=React__namespace.createContext(void 0),K=()=>React__namespace.useContext(ue),de=React__namespace.createContext(void 0),ee=()=>React__namespace.useContext(de),fe=React__namespace.createContext(void 0),me=React__namespace.forwardRef((r,o)=>{let n=L(()=>{var e,a;return {search:"",value:(a=(e=r.value)!=null?e:r.defaultValue)!=null?a:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),u=L(()=>new Set),c=L(()=>new Map),d=L(()=>new Map),f=L(()=>new Set),p=pe(r),{label:b,children:m,value:R,onValueChange:x,filter:C,shouldFilter:S,loop:A,disablePointerSelection:ge=false,vimBindings:j=true,...O}=r,$=useId(),q=useId(),_=useId(),I=React__namespace.useRef(null),v=ke();k$2(()=>{if(R!==void 0){let e=R.trim();n.current.value=e,E.emit();}},[R]),k$2(()=>{v(6,ne);},[]);let E=React__namespace.useMemo(()=>({subscribe:e=>(f.current.add(e),()=>f.current.delete(e)),snapshot:()=>n.current,setState:(e,a,s)=>{var i,l,g,y;if(!Object.is(n.current[e],a)){if(n.current[e]=a,e==="search")J(),z(),v(1,W);else if(e==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let h=document.getElementById(_);h?h.focus():(i=document.getElementById($))==null||i.focus();}if(v(7,()=>{var h;n.current.selectedItemId=(h=M())==null?void 0:h.id,E.emit();}),s||v(5,ne),((l=p.current)==null?void 0:l.value)!==void 0){let h=a!=null?a:"";(y=(g=p.current).onValueChange)==null||y.call(g,h);return}}E.emit();}},emit:()=>{f.current.forEach(e=>e());}}),[]),U=React__namespace.useMemo(()=>({value:(e,a,s)=>{var i;a!==((i=d.current.get(e))==null?void 0:i.value)&&(d.current.set(e,{value:a,keywords:s}),n.current.filtered.items.set(e,te(a,s)),v(2,()=>{z(),E.emit();}));},item:(e,a)=>(u.current.add(e),a&&(c.current.has(a)?c.current.get(a).add(e):c.current.set(a,new Set([e]))),v(3,()=>{J(),z(),n.current.value||W(),E.emit();}),()=>{d.current.delete(e),u.current.delete(e),n.current.filtered.items.delete(e);let s=M();v(4,()=>{J(),(s==null?void 0:s.getAttribute("id"))===e&&W(),E.emit();});}),group:e=>(c.current.has(e)||c.current.set(e,new Set),()=>{d.current.delete(e),c.current.delete(e);}),filter:()=>p.current.shouldFilter,label:b||r["aria-label"],getDisablePointerSelection:()=>p.current.disablePointerSelection,listId:$,inputId:_,labelId:q,listInnerRef:I}),[]);function te(e,a){var i,l;let s=(l=(i=p.current)==null?void 0:i.filter)!=null?l:Re;return e?s(e,n.current.search,a):0}function z(){if(!n.current.search||p.current.shouldFilter===false)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach(i=>{let l=c.current.get(i),g=0;l.forEach(y=>{let h=e.get(y);g=Math.max(h,g);}),a.push([i,g]);});let s=I.current;V().sort((i,l)=>{var h,F;let g=i.getAttribute("id"),y=l.getAttribute("id");return ((h=e.get(y))!=null?h:0)-((F=e.get(g))!=null?F:0)}).forEach(i=>{let l=i.closest(Y);l?l.appendChild(i.parentElement===l?i:i.closest(`${Y} > *`)):s.appendChild(i.parentElement===s?i:i.closest(`${Y} > *`));}),a.sort((i,l)=>l[1]-i[1]).forEach(i=>{var g;let l=(g=I.current)==null?void 0:g.querySelector(`${N}[${T}="${encodeURIComponent(i[0])}"]`);l==null||l.parentElement.appendChild(l);});}function W(){let e=V().find(s=>s.getAttribute("aria-disabled")!=="true"),a=e==null?void 0:e.getAttribute(T);E.setState("value",a||void 0);}function J(){var a,s,i,l;if(!n.current.search||p.current.shouldFilter===false){n.current.filtered.count=u.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let g of u.current){let y=(s=(a=d.current.get(g))==null?void 0:a.value)!=null?s:"",h=(l=(i=d.current.get(g))==null?void 0:i.keywords)!=null?l:[],F=te(y,h);n.current.filtered.items.set(g,F),F>0&&e++;}for(let[g,y]of c.current)for(let h of y)if(n.current.filtered.items.get(h)>0){n.current.filtered.groups.add(g);break}n.current.filtered.count=e;}function ne(){var a,s,i;let e=M();e&&(((a=e.parentElement)==null?void 0:a.firstChild)===e&&((i=(s=e.closest(N))==null?void 0:s.querySelector(be))==null||i.scrollIntoView({block:"nearest"})),e.scrollIntoView({block:"nearest"}));}function M(){var e;return (e=I.current)==null?void 0:e.querySelector(`${le}[aria-selected="true"]`)}function V(){var e;return Array.from(((e=I.current)==null?void 0:e.querySelectorAll(ce))||[])}function X(e){let s=V()[e];s&&E.setState("value",s.getAttribute(T));}function Q(e){var g;let a=M(),s=V(),i=s.findIndex(y=>y===a),l=s[i+e];(g=p.current)!=null&&g.loop&&(l=i+e<0?s[s.length-1]:i+e===s.length?s[0]:s[i+e]),l&&E.setState("value",l.getAttribute(T));}function re(e){let a=M(),s=a==null?void 0:a.closest(N),i;for(;s&&!i;)s=e>0?we(s,N):De(s,N),i=s==null?void 0:s.querySelector(ce);i?E.setState("value",i.getAttribute(T)):Q(e);}let oe=()=>X(V().length-1),ie=e=>{e.preventDefault(),e.metaKey?oe():e.altKey?re(1):Q(1);},se=e=>{e.preventDefault(),e.metaKey?X(0):e.altKey?re(-1):Q(-1);};return React__namespace.createElement(Primitive$1.div,{ref:o,tabIndex:-1,...O,"cmdk-root":"",onKeyDown:e=>{var s;(s=O.onKeyDown)==null||s.call(O,e);let a=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||a))switch(e.key){case "n":case "j":{j&&e.ctrlKey&&ie(e);break}case "ArrowDown":{ie(e);break}case "p":case "k":{j&&e.ctrlKey&&se(e);break}case "ArrowUp":{se(e);break}case "Home":{e.preventDefault(),X(0);break}case "End":{e.preventDefault(),oe();break}case "Enter":{e.preventDefault();let i=M();if(i){let l=new Event(Z);i.dispatchEvent(l);}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:Te},b),B(r,e=>React__namespace.createElement(de.Provider,{value:E},React__namespace.createElement(ue.Provider,{value:U},e))))}),he=React__namespace.forwardRef((r,o)=>{var _,I;let n=useId(),u=React__namespace.useRef(null),c=React__namespace.useContext(fe),d=K(),f=pe(r),p=(I=(_=f.current)==null?void 0:_.forceMount)!=null?I:c==null?void 0:c.forceMount;k$2(()=>{if(!p)return d.item(n,c==null?void 0:c.id)},[p]);let b=ve(n,u,[r.value,r.children,u],r.keywords),m=ee(),R=P(v=>v.value&&v.value===b.current),x=P(v=>p||d.filter()===false?true:v.search?v.filtered.items.get(n)>0:true);React__namespace.useEffect(()=>{let v=u.current;if(!(!v||r.disabled))return v.addEventListener(Z,C),()=>v.removeEventListener(Z,C)},[x,r.onSelect,r.disabled]);function C(){var v,E;S(),(E=(v=f.current).onSelect)==null||E.call(v,b.current);}function S(){m.setState("value",b.current,true);}if(!x)return null;let{disabled:A,value:ge,onSelect:j,forceMount:O,keywords:$,...q}=r;return React__namespace.createElement(Primitive$1.div,{ref:composeRefs(u,o),...q,id:n,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!R,"data-disabled":!!A,"data-selected":!!R,onPointerMove:A||d.getDisablePointerSelection()?void 0:S,onClick:A?void 0:C},r.children)}),Ee=React__namespace.forwardRef((r,o)=>{let{heading:n,children:u,forceMount:c,...d}=r,f=useId(),p=React__namespace.useRef(null),b=React__namespace.useRef(null),m=useId(),R=K(),x=P(S=>c||R.filter()===false?true:S.search?S.filtered.groups.has(f):true);k$2(()=>R.group(f),[]),ve(f,p,[r.value,r.heading,b]);let C=React__namespace.useMemo(()=>({id:f,forceMount:c}),[c]);return React__namespace.createElement(Primitive$1.div,{ref:composeRefs(p,o),...d,"cmdk-group":"",role:"presentation",hidden:x?void 0:true},n&&React__namespace.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":true,id:m},n),B(r,S=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},React__namespace.createElement(fe.Provider,{value:C},S))))}),ye=React__namespace.forwardRef((r,o)=>{let{alwaysRender:n,...u}=r,c=React__namespace.useRef(null),d=P(f=>!f.search);return !n&&!d?null:React__namespace.createElement(Primitive$1.div,{ref:composeRefs(c,o),...u,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((r,o)=>{let{onValueChange:n,...u}=r,c=r.value!=null,d=ee(),f=P(m=>m.search),p=P(m=>m.selectedItemId),b=K();return React__namespace.useEffect(()=>{r.value!=null&&d.setState("search",r.value);},[r.value]),React__namespace.createElement(Primitive$1.input,{ref:o,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:false,"aria-autocomplete":"list",role:"combobox","aria-expanded":true,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":p,id:b.inputId,type:"text",value:c?r.value:f,onChange:m=>{c||d.setState("search",m.target.value),n==null||n(m.target.value);}})}),Ce=React__namespace.forwardRef((r,o)=>{let{children:n,label:u="Suggestions",...c}=r,d=React__namespace.useRef(null),f=React__namespace.useRef(null),p=P(m=>m.selectedItemId),b=K();return React__namespace.useEffect(()=>{if(f.current&&d.current){let m=f.current,R=d.current,x,C=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let S=m.offsetHeight;R.style.setProperty("--cmdk-list-height",S.toFixed(1)+"px");});});return C.observe(m),()=>{cancelAnimationFrame(x),C.unobserve(m);}}},[]),React__namespace.createElement(Primitive$1.div,{ref:composeRefs(d,o),...c,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":p,"aria-label":u,id:b.listId},B(r,m=>React__namespace.createElement("div",{ref:composeRefs(f,b.listInnerRef),"cmdk-list-sizer":""},m)))}),xe=React__namespace.forwardRef((r,o)=>{let{open:n,onOpenChange:u,overlayClassName:c,contentClassName:d,container:f,...p}=r;return React__namespace.createElement(Root$1,{open:n,onOpenChange:u},React__namespace.createElement(Portal,{container:f},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:c}),React__namespace.createElement(Content$1,{"aria-label":r.label,"cmdk-dialog":"",className:d},React__namespace.createElement(me,{ref:o,...p}))))}),Ie=React__namespace.forwardRef((r,o)=>P(u=>u.filtered.count===0)?React__namespace.createElement(Primitive$1.div,{ref:o,...r,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((r,o)=>{let{progress:n,children:u,label:c="Loading...",...d}=r;return React__namespace.createElement(Primitive$1.div,{ref:o,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":c},B(r,f=>React__namespace.createElement("div",{"aria-hidden":true},f)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(r,o){let n=r.nextElementSibling;for(;n;){if(n.matches(o))return n;n=n.nextElementSibling;}}function De(r,o){let n=r.previousElementSibling;for(;n;){if(n.matches(o))return n;n=n.previousElementSibling;}}function pe(r){let o=React__namespace.useRef(r);return k$2(()=>{o.current=r;}),o}var k$2=typeof window=="undefined"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(r){let o=React__namespace.useRef();return o.current===void 0&&(o.current=r()),o}function P(r){let o=ee(),n=()=>r(o.snapshot());return React__namespace.useSyncExternalStore(o.subscribe,n,n)}function ve(r,o,n,u=[]){let c=React__namespace.useRef(),d=K();return k$2(()=>{var b;let f=(()=>{var m;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(m=R.current.textContent)==null?void 0:m.trim():c.current}})(),p=u.map(m=>m.trim());d.value(r,f,p),(b=o.current)==null||b.setAttribute(T,f),c.current=f;}),c}var ke=()=>{let[r,o]=React__namespace.useState(),n=L(()=>new Map);return k$2(()=>{n.current.forEach(u=>u()),n.current=new Map;},[r]),(u,c)=>{n.current.set(u,c),o({});}};function Me(r){let o=r.type;return typeof o=="function"?o(r.props):"render"in o?o.render(r.props):r}function B({asChild:r,children:o},n){return r&&React__namespace.isValidElement(o)?React__namespace.cloneElement(Me(o),{ref:o.ref},n(o.props.children)):n(o)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};
|
|
21189
21516
|
|
|
21190
21517
|
/**
|
|
21191
21518
|
* @license lucide-react v0.479.0 - ISC
|
|
@@ -30036,7 +30363,7 @@ var frRawCountries = [
|
|
|
30036
30363
|
id: 704,
|
|
30037
30364
|
alpha2: "vn",
|
|
30038
30365
|
alpha3: "vnm",
|
|
30039
|
-
name: "
|
|
30366
|
+
name: "Vietnam"
|
|
30040
30367
|
},
|
|
30041
30368
|
{
|
|
30042
30369
|
id: 887,
|
|
@@ -36128,7 +36455,7 @@ function CustomerForm({ initialData, onSubmit, clientProxy, clientSecret, latitu
|
|
|
36128
36455
|
phone: "",
|
|
36129
36456
|
},
|
|
36130
36457
|
});
|
|
36131
|
-
return (jsxRuntime.jsx(Form, Object.assign({}, form, { children: jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsxRuntime.jsx("div", { className: "md:col-span-2", children: jsxRuntime.jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsxRuntime.jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsxRuntime.jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsxRuntime.jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsxRuntime.jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsxRuntime.jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsxRuntime.jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsxRuntime.jsx(SubmitButton, { isValid: form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
|
|
36458
|
+
return (jsxRuntime.jsx(Form, Object.assign({}, form, { children: jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsxRuntime.jsx("div", { className: "md:col-span-2", children: jsxRuntime.jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsxRuntime.jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsxRuntime.jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsxRuntime.jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsxRuntime.jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsxRuntime.jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsxRuntime.jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsxRuntime.jsx(SubmitButton, { isValid: form.formState.isDirty || form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
|
|
36132
36459
|
}
|
|
36133
36460
|
|
|
36134
36461
|
var reactStripe_umd$1 = {exports: {}};
|
|
@@ -36140,10 +36467,10 @@ var hasRequiredReactStripe_umd;
|
|
|
36140
36467
|
function requireReactStripe_umd () {
|
|
36141
36468
|
if (hasRequiredReactStripe_umd) return reactStripe_umd$1.exports;
|
|
36142
36469
|
hasRequiredReactStripe_umd = 1;
|
|
36143
|
-
(function (module, exports) {
|
|
36470
|
+
(function (module, exports$1) {
|
|
36144
36471
|
(function (global, factory) {
|
|
36145
|
-
factory(exports, React) ;
|
|
36146
|
-
})(reactStripe_umd, (function (exports, React) {
|
|
36472
|
+
factory(exports$1, React) ;
|
|
36473
|
+
})(reactStripe_umd, (function (exports$1, React) {
|
|
36147
36474
|
function ownKeys(object, enumerableOnly) {
|
|
36148
36475
|
var keys = Object.keys(object);
|
|
36149
36476
|
|
|
@@ -37412,35 +37739,35 @@ function requireReactStripe_umd () {
|
|
|
37412
37739
|
|
|
37413
37740
|
var TaxIdElement = createElementComponent('taxId', isServer);
|
|
37414
37741
|
|
|
37415
|
-
exports.AddressElement = AddressElement;
|
|
37416
|
-
exports.AffirmMessageElement = AffirmMessageElement;
|
|
37417
|
-
exports.AfterpayClearpayMessageElement = AfterpayClearpayMessageElement;
|
|
37418
|
-
exports.AuBankAccountElement = AuBankAccountElement;
|
|
37419
|
-
exports.CardCvcElement = CardCvcElement;
|
|
37420
|
-
exports.CardElement = CardElement;
|
|
37421
|
-
exports.CardExpiryElement = CardExpiryElement;
|
|
37422
|
-
exports.CardNumberElement = CardNumberElement;
|
|
37423
|
-
exports.CheckoutProvider = CheckoutProvider;
|
|
37424
|
-
exports.CurrencySelectorElement = CurrencySelectorElement;
|
|
37425
|
-
exports.Elements = Elements;
|
|
37426
|
-
exports.ElementsConsumer = ElementsConsumer;
|
|
37427
|
-
exports.EmbeddedCheckout = EmbeddedCheckout;
|
|
37428
|
-
exports.EmbeddedCheckoutProvider = EmbeddedCheckoutProvider;
|
|
37429
|
-
exports.EpsBankElement = EpsBankElement;
|
|
37430
|
-
exports.ExpressCheckoutElement = ExpressCheckoutElement;
|
|
37431
|
-
exports.FpxBankElement = FpxBankElement;
|
|
37432
|
-
exports.IbanElement = IbanElement;
|
|
37433
|
-
exports.IdealBankElement = IdealBankElement;
|
|
37434
|
-
exports.LinkAuthenticationElement = LinkAuthenticationElement;
|
|
37435
|
-
exports.P24BankElement = P24BankElement;
|
|
37436
|
-
exports.PaymentElement = PaymentElement;
|
|
37437
|
-
exports.PaymentMethodMessagingElement = PaymentMethodMessagingElement;
|
|
37438
|
-
exports.PaymentRequestButtonElement = PaymentRequestButtonElement;
|
|
37439
|
-
exports.ShippingAddressElement = ShippingAddressElement;
|
|
37440
|
-
exports.TaxIdElement = TaxIdElement;
|
|
37441
|
-
exports.useCheckout = useCheckout;
|
|
37442
|
-
exports.useElements = useElements;
|
|
37443
|
-
exports.useStripe = useStripe;
|
|
37742
|
+
exports$1.AddressElement = AddressElement;
|
|
37743
|
+
exports$1.AffirmMessageElement = AffirmMessageElement;
|
|
37744
|
+
exports$1.AfterpayClearpayMessageElement = AfterpayClearpayMessageElement;
|
|
37745
|
+
exports$1.AuBankAccountElement = AuBankAccountElement;
|
|
37746
|
+
exports$1.CardCvcElement = CardCvcElement;
|
|
37747
|
+
exports$1.CardElement = CardElement;
|
|
37748
|
+
exports$1.CardExpiryElement = CardExpiryElement;
|
|
37749
|
+
exports$1.CardNumberElement = CardNumberElement;
|
|
37750
|
+
exports$1.CheckoutProvider = CheckoutProvider;
|
|
37751
|
+
exports$1.CurrencySelectorElement = CurrencySelectorElement;
|
|
37752
|
+
exports$1.Elements = Elements;
|
|
37753
|
+
exports$1.ElementsConsumer = ElementsConsumer;
|
|
37754
|
+
exports$1.EmbeddedCheckout = EmbeddedCheckout;
|
|
37755
|
+
exports$1.EmbeddedCheckoutProvider = EmbeddedCheckoutProvider;
|
|
37756
|
+
exports$1.EpsBankElement = EpsBankElement;
|
|
37757
|
+
exports$1.ExpressCheckoutElement = ExpressCheckoutElement;
|
|
37758
|
+
exports$1.FpxBankElement = FpxBankElement;
|
|
37759
|
+
exports$1.IbanElement = IbanElement;
|
|
37760
|
+
exports$1.IdealBankElement = IdealBankElement;
|
|
37761
|
+
exports$1.LinkAuthenticationElement = LinkAuthenticationElement;
|
|
37762
|
+
exports$1.P24BankElement = P24BankElement;
|
|
37763
|
+
exports$1.PaymentElement = PaymentElement;
|
|
37764
|
+
exports$1.PaymentMethodMessagingElement = PaymentMethodMessagingElement;
|
|
37765
|
+
exports$1.PaymentRequestButtonElement = PaymentRequestButtonElement;
|
|
37766
|
+
exports$1.ShippingAddressElement = ShippingAddressElement;
|
|
37767
|
+
exports$1.TaxIdElement = TaxIdElement;
|
|
37768
|
+
exports$1.useCheckout = useCheckout;
|
|
37769
|
+
exports$1.useElements = useElements;
|
|
37770
|
+
exports$1.useStripe = useStripe;
|
|
37444
37771
|
|
|
37445
37772
|
}));
|
|
37446
37773
|
} (reactStripe_umd$1, reactStripe_umd$1.exports));
|
|
@@ -42403,7 +42730,7 @@ function ShippingOptionWrapper({ rate, children, onPickupPointSelected, locale,
|
|
|
42403
42730
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
42404
42731
|
}
|
|
42405
42732
|
|
|
42406
|
-
function
|
|
42733
|
+
function ShipmentsShippingMethodForm({ shippingRates, initialData, onSubmit, onBack, contactEmail, shippingAddress, currency, exchangeRate, locale, countryCode, setFormData, formData, shipments, }) {
|
|
42407
42734
|
var _a;
|
|
42408
42735
|
const { t } = useTranslation();
|
|
42409
42736
|
const form = useForm({
|
|
@@ -42421,53 +42748,55 @@ function ShipmentsForm({ shippingRates, initialData, onSubmit, onBack, contactEm
|
|
|
42421
42748
|
])),
|
|
42422
42749
|
});
|
|
42423
42750
|
const isButtonEnabled = Object.values(form.getValues()).every((value) => { var _a; return ((_a = value.rateId) === null || _a === void 0 ? void 0 : _a.length) > 0; });
|
|
42424
|
-
|
|
42425
|
-
|
|
42426
|
-
|
|
42427
|
-
|
|
42751
|
+
const shippingRatesAreLoadingOrDefined = shippingRates === undefined || Object.keys(shippingRates).length > 0;
|
|
42752
|
+
return (jsxRuntime.jsxs("div", { className: "space-y-6", children: [jsxRuntime.jsx("h2", { children: t("CheckoutEmbed.Shipping.title") }), jsxRuntime.jsxs("div", { className: "space-y-2 pb-2", children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxRuntime.jsxs("p", { children: [jsxRuntime.jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.contact") }), " ", jsxRuntime.jsx("span", { className: "text-muted-foreground", children: contactEmail })] }), jsxRuntime.jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxRuntime.jsxs("p", { children: [jsxRuntime.jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.address") }), " ", jsxRuntime.jsx("span", { className: "text-muted-foreground", children: shippingAddress })] }), jsxRuntime.jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] })] }), jsxRuntime.jsx(Form, Object.assign({}, form, { children: jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "space-y-4", children: [!shippingRatesAreLoadingOrDefined && (jsxRuntime.jsx("p", { className: "text-destructive py-2 text-base font-medium", children: t("CheckoutEmbed.Shipping.errorNoShippingRates") })), shippingRatesAreLoadingOrDefined &&
|
|
42753
|
+
shipments.map((shipment, index) => {
|
|
42754
|
+
var _a;
|
|
42755
|
+
return (jsxRuntime.jsx(SingleShipmentSection, { shipment: shipment, shippingRates: (_a = shippingRates === null || shippingRates === void 0 ? void 0 : shippingRates[shipment.id]) !== null && _a !== void 0 ? _a : [], form: form, setFormData: setFormData, formData: formData, currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: countryCode, multipleShipments: shipments.length > 1, index: index }, shipment.id));
|
|
42756
|
+
}), jsxRuntime.jsx(FormMessage, { children: (_a = form.formState.errors.root) === null || _a === void 0 ? void 0 : _a.message }), jsxRuntime.jsxs("div", { className: "flex items-center justify-between pt-4", children: [jsxRuntime.jsxs(Button, { type: "button", variant: "ghost", onClick: onBack, children: [jsxRuntime.jsx(ChevronLeft, {}), t("CheckoutEmbed.Shipping.back")] }), jsxRuntime.jsx(SubmitButton, { isSubmitting: form.formState.isSubmitting, isValid: isButtonEnabled, children: t("CheckoutEmbed.Shipping.button") })] })] }) }))] }));
|
|
42428
42757
|
}
|
|
42429
42758
|
const SingleShipmentSection = ({ shippingRates, form, currency, exchangeRate, locale, countryCode, setFormData, formData, multipleShipments, shipment, index, }) => {
|
|
42430
42759
|
const { t } = useTranslation();
|
|
42431
42760
|
const shipmentId = shipment.id;
|
|
42432
42761
|
const currentRateId = form.watch(`${shipmentId}.rateId`);
|
|
42433
42762
|
// TODO: construct the headline
|
|
42434
|
-
return (jsxRuntime.jsxs("div", { children: [multipleShipments && (jsxRuntime.jsxs("h3", { className: "text-lg font-medium", children: [t("CheckoutEmbed.Shipping.Shipment.title"), index + 1] })), shippingRates.length === 0 &&
|
|
42435
|
-
|
|
42436
|
-
|
|
42437
|
-
|
|
42438
|
-
|
|
42439
|
-
|
|
42440
|
-
|
|
42441
|
-
|
|
42442
|
-
|
|
42443
|
-
|
|
42444
|
-
|
|
42445
|
-
|
|
42446
|
-
|
|
42447
|
-
|
|
42448
|
-
|
|
42449
|
-
|
|
42450
|
-
|
|
42451
|
-
|
|
42452
|
-
|
|
42453
|
-
|
|
42454
|
-
|
|
42455
|
-
|
|
42456
|
-
|
|
42457
|
-
|
|
42458
|
-
|
|
42459
|
-
|
|
42460
|
-
|
|
42461
|
-
|
|
42462
|
-
|
|
42463
|
-
|
|
42464
|
-
|
|
42465
|
-
|
|
42466
|
-
|
|
42467
|
-
|
|
42468
|
-
|
|
42469
|
-
|
|
42470
|
-
|
|
42763
|
+
return (jsxRuntime.jsxs("div", { children: [multipleShipments && (jsxRuntime.jsxs("h3", { className: "text-lg font-medium", children: [t("CheckoutEmbed.Shipping.Shipment.title"), index + 1] })), jsxRuntime.jsxs("div", { className: "space-y-2", children: [shippingRates.length === 0 &&
|
|
42764
|
+
Array.from({ length: 3 }).map((_, index) => (jsxRuntime.jsx(ShippingRateLoading, {}, index))), shippingRates.map((rate) => {
|
|
42765
|
+
var _a, _b;
|
|
42766
|
+
const pickupPointDisplayName = form.watch(`${shipmentId}.pickupPointDisplayName`);
|
|
42767
|
+
const intPrice = Math.ceil(Number(rate.priceInCents));
|
|
42768
|
+
const displayPrice = formatPrice(intPrice, currency, exchangeRate);
|
|
42769
|
+
const isFixedRate = rate.type === "FIXED";
|
|
42770
|
+
const isAutoRate = rate.type === "CUSTOM_SHIPPING_VENDOR" ||
|
|
42771
|
+
rate.type === "PLATFORM_CARRIER";
|
|
42772
|
+
const isZasilkovna = isAutoRate && rate.providerId === "zasilkovna";
|
|
42773
|
+
const name = isFixedRate
|
|
42774
|
+
? rate.name
|
|
42775
|
+
: ((_a = t(`CheckoutEmbed.Shipping.Shipment.perIdTitles.${rate.id}`)) !== null && _a !== void 0 ? _a : rate.id);
|
|
42776
|
+
const fallbackDescription = t(`CheckoutEmbed.Shipping.Shipment.perIdDescriptions.fallback`);
|
|
42777
|
+
const description = (_b = (isFixedRate
|
|
42778
|
+
? rate.description
|
|
42779
|
+
: t(`CheckoutEmbed.Shipping.Shipment.perIdDescriptions.${rate.id}`))) !== null && _b !== void 0 ? _b : fallbackDescription;
|
|
42780
|
+
return (jsxRuntime.jsx(ShippingOptionWrapper, { rate: rate, onPickupPointSelected: (pickupPointId, pickupPointName) => {
|
|
42781
|
+
const newData = {
|
|
42782
|
+
rateId: rate.id,
|
|
42783
|
+
providerId: isAutoRate ? rate.providerId : undefined,
|
|
42784
|
+
priceInCents: intPrice,
|
|
42785
|
+
displayName: name,
|
|
42786
|
+
pickupPointId: isZasilkovna ? pickupPointId : "",
|
|
42787
|
+
pickupPointDisplayName: isZasilkovna ? pickupPointName : "",
|
|
42788
|
+
};
|
|
42789
|
+
form.setValue(`${shipmentId}.rateId`, newData.rateId);
|
|
42790
|
+
form.setValue(`${shipmentId}.providerId`, newData.providerId);
|
|
42791
|
+
form.setValue(`${shipmentId}.displayName`, newData.displayName);
|
|
42792
|
+
form.setValue(`${shipmentId}.priceInCents`, newData.priceInCents);
|
|
42793
|
+
form.setValue(`${shipmentId}.pickupPointId`, newData.pickupPointId);
|
|
42794
|
+
form.setValue(`${shipmentId}.pickupPointDisplayName`, newData.pickupPointDisplayName);
|
|
42795
|
+
setFormData(Object.assign(Object.assign({}, formData), { shipping: Object.assign(Object.assign({}, formData.shipping), { [shipmentId]: newData }) }));
|
|
42796
|
+
}, locale: locale, countryCode: countryCode, children: jsxRuntime.jsxs("div", { className: clsx("bg-background cursor-pointer rounded-md border p-4", {
|
|
42797
|
+
"bg-muted border-primary": currentRateId === rate.id,
|
|
42798
|
+
}), children: [jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-between", children: [jsxRuntime.jsx("p", { children: name }), jsxRuntime.jsx("p", { children: displayPrice })] }), jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: description }), pickupPointDisplayName && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("hr", { className: "my-2" }), jsxRuntime.jsxs("p", { className: "text-muted-foreground text-sm", children: [t("CheckoutEmbed.Shipping.description.shippedTo"), " ", jsxRuntime.jsx("span", { className: "text-foreground", children: pickupPointDisplayName })] })] }))] }) }, rate.id));
|
|
42799
|
+
})] })] }));
|
|
42471
42800
|
};
|
|
42472
42801
|
function ShippingRateLoading() {
|
|
42473
42802
|
return (jsxRuntime.jsxs("div", { className: clsx("bg-background grid cursor-pointer gap-[10px] rounded-md border p-4"), children: [jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-between", children: [jsxRuntime.jsx(Skeleton, { className: "h-5 w-12" }), jsxRuntime.jsx(Skeleton, { className: "h-5 w-16" })] }), jsxRuntime.jsx(Skeleton, { className: "h-3.5 w-40" })] }));
|
|
@@ -42488,7 +42817,7 @@ const resetFormStore = (formData) => {
|
|
|
42488
42817
|
|
|
42489
42818
|
function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }) {
|
|
42490
42819
|
const { formData, setFormData, step, setStep, checkoutId: storedCheckoutId, setCheckoutId, } = useFormStore();
|
|
42491
|
-
const [shippingRates, setShippingRates] = React.useState(
|
|
42820
|
+
const [shippingRates, setShippingRates] = React.useState(undefined);
|
|
42492
42821
|
const validateStep = React.useCallback(() => {
|
|
42493
42822
|
if (step === "customer")
|
|
42494
42823
|
return;
|
|
@@ -42579,11 +42908,12 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
42579
42908
|
React.useEffect(() => {
|
|
42580
42909
|
if (step !== "shipping")
|
|
42581
42910
|
return;
|
|
42582
|
-
if (Object.keys(shippingRates).length > 0)
|
|
42911
|
+
if (Object.keys(shippingRates !== null && shippingRates !== void 0 ? shippingRates : {}).length > 0)
|
|
42583
42912
|
return;
|
|
42584
42913
|
const getShippingRates = () => __awaiter(this, void 0, void 0, function* () {
|
|
42585
42914
|
try {
|
|
42586
42915
|
const shippingRates = yield storeClient.getCheckoutShippingRates(clientSecret, checkoutId);
|
|
42916
|
+
console.log("FETCHED SHIPPING RATES: ", shippingRates);
|
|
42587
42917
|
setShippingRates(shippingRates);
|
|
42588
42918
|
}
|
|
42589
42919
|
catch (error) {
|
|
@@ -42596,6 +42926,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
42596
42926
|
}, [step, clientSecret, checkoutId]);
|
|
42597
42927
|
// Handle address form submission
|
|
42598
42928
|
const handleCustomerSubmit = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
42929
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
42599
42930
|
setFormData(Object.assign(Object.assign({}, formData), { customer: data }));
|
|
42600
42931
|
let newCustomerId = formData.customerId;
|
|
42601
42932
|
if (!newCustomerId) {
|
|
@@ -42604,7 +42935,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
42604
42935
|
phone: data.phone,
|
|
42605
42936
|
firstName: data.firstName,
|
|
42606
42937
|
lastName: data.lastName,
|
|
42607
|
-
address: Object.assign(Object.assign({}, data.address), { phone: data.phone, name: data.firstName + " " + data.lastName }),
|
|
42938
|
+
address: Object.assign(Object.assign({}, data.address), { company: (_a = data.address.company) !== null && _a !== void 0 ? _a : null, line2: (_b = data.address.line2) !== null && _b !== void 0 ? _b : null, province: (_c = data.address.province) !== null && _c !== void 0 ? _c : null, provinceCode: (_d = data.address.provinceCode) !== null && _d !== void 0 ? _d : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
|
|
42608
42939
|
});
|
|
42609
42940
|
yield storeClient.updateCheckout(clientSecret, checkoutId, {
|
|
42610
42941
|
customerId: newCustomer.id,
|
|
@@ -42617,9 +42948,10 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
42617
42948
|
phone: data.phone,
|
|
42618
42949
|
firstName: data.firstName,
|
|
42619
42950
|
lastName: data.lastName,
|
|
42620
|
-
address: Object.assign(Object.assign({}, data.address), { phone: data.phone, name: data.firstName + " " + data.lastName }),
|
|
42951
|
+
address: Object.assign(Object.assign({}, data.address), { company: (_e = data.address.company) !== null && _e !== void 0 ? _e : null, line2: (_f = data.address.line2) !== null && _f !== void 0 ? _f : null, province: (_g = data.address.province) !== null && _g !== void 0 ? _g : null, provinceCode: (_h = data.address.provinceCode) !== null && _h !== void 0 ? _h : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
|
|
42621
42952
|
});
|
|
42622
42953
|
}
|
|
42954
|
+
console.log("FETCHING SHIPPING RATES");
|
|
42623
42955
|
const shippingRates = yield storeClient.getCheckoutShippingRates(clientSecret, checkoutId);
|
|
42624
42956
|
setShippingRates(shippingRates);
|
|
42625
42957
|
setFormData(Object.assign(Object.assign({}, formData), { customer: data, customerId: newCustomerId }));
|
|
@@ -42662,7 +42994,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
42662
42994
|
return (jsxRuntime.jsx(PaymentForm, { paymentComponentKey: paymentComponentKey, locale: locale, fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, address: formatAddress(formData.customer.address), shippingFormData: formData.shipping, publicKey: publicKey }));
|
|
42663
42995
|
}
|
|
42664
42996
|
if (step === "shipping" && formData.customer) {
|
|
42665
|
-
return (jsxRuntime.jsx(
|
|
42997
|
+
return (jsxRuntime.jsx(ShipmentsShippingMethodForm, { setFormData: setFormData, formData: formData, shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: formData.customer.address.countryCode, shipments: shipments }));
|
|
42666
42998
|
}
|
|
42667
42999
|
return (jsxRuntime.jsx(CustomerForm, { initialData: formData.customer, onSubmit: handleCustomerSubmit, clientProxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }));
|
|
42668
43000
|
};
|