@bricks-toolkit/toolkit 0.1.16 → 0.1.18
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.
|
@@ -202,12 +202,19 @@ var Phone = react.forwardRef(
|
|
|
202
202
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
203
203
|
const [searchTerm, setSearchTerm] = react.useState("");
|
|
204
204
|
const dropdownRef = react.useRef(null);
|
|
205
|
-
const [internalPhone, setInternalPhone] = react.useState(
|
|
206
|
-
defaultValue
|
|
207
|
-
|
|
205
|
+
const [internalPhone, setInternalPhone] = react.useState(() => {
|
|
206
|
+
if (defaultValue) {
|
|
207
|
+
return {
|
|
208
|
+
countryCode: defaultValue.countryCode || defaultCountryCode,
|
|
209
|
+
phoneNumber: defaultValue.phoneNumber || ""
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
return { countryCode: defaultCountryCode, phoneNumber: "" };
|
|
213
|
+
});
|
|
208
214
|
const isControlled = value !== void 0;
|
|
209
215
|
const currentPhone = isControlled ? value : internalPhone;
|
|
210
|
-
const
|
|
216
|
+
const effectiveCountryCode = currentPhone.countryCode || defaultCountryCode;
|
|
217
|
+
const activeCountry = COUNTRIES.find((c) => c.dialCode === effectiveCountryCode) ?? COUNTRIES[0];
|
|
211
218
|
const mergedState = errorMessage || internalError ? "error" : stateProp;
|
|
212
219
|
const currentMessage = errorMessage || internalError || successMessage || warningMessage || helperText;
|
|
213
220
|
const triggerChange = (newValue) => {
|
|
@@ -303,7 +310,7 @@ var Phone = react.forwardRef(
|
|
|
303
310
|
),
|
|
304
311
|
children: [
|
|
305
312
|
showFlag && activeCountry && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-1.5 text-base sm:text-lg opacity-90", children: activeCountry.flag }),
|
|
306
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: activeCountry?.dialCode
|
|
313
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: activeCountry?.dialCode || defaultCountryCode }),
|
|
307
314
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
308
315
|
solid.ChevronDownIcon,
|
|
309
316
|
{
|
|
@@ -200,12 +200,19 @@ var Phone = forwardRef(
|
|
|
200
200
|
const [isOpen, setIsOpen] = useState(false);
|
|
201
201
|
const [searchTerm, setSearchTerm] = useState("");
|
|
202
202
|
const dropdownRef = useRef(null);
|
|
203
|
-
const [internalPhone, setInternalPhone] = useState(
|
|
204
|
-
defaultValue
|
|
205
|
-
|
|
203
|
+
const [internalPhone, setInternalPhone] = useState(() => {
|
|
204
|
+
if (defaultValue) {
|
|
205
|
+
return {
|
|
206
|
+
countryCode: defaultValue.countryCode || defaultCountryCode,
|
|
207
|
+
phoneNumber: defaultValue.phoneNumber || ""
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return { countryCode: defaultCountryCode, phoneNumber: "" };
|
|
211
|
+
});
|
|
206
212
|
const isControlled = value !== void 0;
|
|
207
213
|
const currentPhone = isControlled ? value : internalPhone;
|
|
208
|
-
const
|
|
214
|
+
const effectiveCountryCode = currentPhone.countryCode || defaultCountryCode;
|
|
215
|
+
const activeCountry = COUNTRIES.find((c) => c.dialCode === effectiveCountryCode) ?? COUNTRIES[0];
|
|
209
216
|
const mergedState = errorMessage || internalError ? "error" : stateProp;
|
|
210
217
|
const currentMessage = errorMessage || internalError || successMessage || warningMessage || helperText;
|
|
211
218
|
const triggerChange = (newValue) => {
|
|
@@ -301,7 +308,7 @@ var Phone = forwardRef(
|
|
|
301
308
|
),
|
|
302
309
|
children: [
|
|
303
310
|
showFlag && activeCountry && /* @__PURE__ */ jsx("span", { className: "mr-1.5 text-base sm:text-lg opacity-90", children: activeCountry.flag }),
|
|
304
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: activeCountry?.dialCode
|
|
311
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: activeCountry?.dialCode || defaultCountryCode }),
|
|
305
312
|
/* @__PURE__ */ jsx(
|
|
306
313
|
ChevronDownIcon,
|
|
307
314
|
{
|
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var chunkS7VEND5Z_cjs = require('./chunk-S7VEND5Z.cjs');
|
|
|
16
16
|
var chunk56ILK7Y4_cjs = require('./chunk-56ILK7Y4.cjs');
|
|
17
17
|
var chunkNRZIXK35_cjs = require('./chunk-NRZIXK35.cjs');
|
|
18
18
|
var chunk5RKET2JO_cjs = require('./chunk-5RKET2JO.cjs');
|
|
19
|
-
var
|
|
19
|
+
var chunkDOKSG7AW_cjs = require('./chunk-DOKSG7AW.cjs');
|
|
20
20
|
var chunkVRZFAKSV_cjs = require('./chunk-VRZFAKSV.cjs');
|
|
21
21
|
var chunk7R5JRJ2W_cjs = require('./chunk-7R5JRJ2W.cjs');
|
|
22
22
|
var chunkOEU5VG3D_cjs = require('./chunk-OEU5VG3D.cjs');
|
|
@@ -697,7 +697,7 @@ Object.defineProperty(exports, "PasswordInput", {
|
|
|
697
697
|
});
|
|
698
698
|
Object.defineProperty(exports, "Phone", {
|
|
699
699
|
enumerable: true,
|
|
700
|
-
get: function () { return
|
|
700
|
+
get: function () { return chunkDOKSG7AW_cjs.Phone; }
|
|
701
701
|
});
|
|
702
702
|
Object.defineProperty(exports, "RadioButton", {
|
|
703
703
|
enumerable: true,
|
package/dist/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ export { Skeleton, SkeletonAvatar, SkeletonCard, SkeletonTable, SkeletonText } f
|
|
|
14
14
|
export { MultiSelect } from './chunk-JKPNJ4PZ.mjs';
|
|
15
15
|
export { OtpInput } from './chunk-RYWDZHKG.mjs';
|
|
16
16
|
export { PasswordInput } from './chunk-446OJWC6.mjs';
|
|
17
|
-
export { Phone } from './chunk-
|
|
17
|
+
export { Phone } from './chunk-ZCLNSMIW.mjs';
|
|
18
18
|
export { RadioButton } from './chunk-DN2GFJF4.mjs';
|
|
19
19
|
export { Select } from './chunk-TIVSMCXZ.mjs';
|
|
20
20
|
export { Pagination, Table } from './chunk-7364SUK6.mjs';
|
package/dist/phone/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDOKSG7AW_cjs = require('../chunk-DOKSG7AW.cjs');
|
|
4
4
|
require('../chunk-L5VQZZVR.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "Phone", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkDOKSG7AW_cjs.Phone; }
|
|
11
11
|
});
|
package/dist/phone/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Phone } from '../chunk-
|
|
1
|
+
export { Phone } from '../chunk-ZCLNSMIW.mjs';
|
|
2
2
|
import '../chunk-OCPFOFJ4.mjs';
|