@bizapps/ui 1.5.1 → 1.7.0
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/editor.cjs +1483 -0
- package/dist/editor.cjs.map +1 -0
- package/dist/editor.d.cts +428 -0
- package/dist/editor.d.ts +428 -0
- package/dist/editor.js +1466 -0
- package/dist/editor.js.map +1 -0
- package/dist/main.cjs +112 -62
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts +52 -2
- package/dist/main.d.ts +52 -2
- package/dist/main.js +90 -64
- package/dist/main.js.map +1 -1
- package/dist/phone.cjs +18 -0
- package/dist/phone.cjs.map +1 -0
- package/dist/phone.d.cts +28 -0
- package/dist/phone.d.ts +28 -0
- package/dist/phone.js +16 -0
- package/dist/phone.js.map +1 -0
- package/package.json +228 -175
package/dist/main.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var dateFns = require('date-fns');
|
|
|
12
12
|
var useEmblaCarousel = require('embla-carousel-react');
|
|
13
13
|
var libphonenumberJs = require('libphonenumber-js');
|
|
14
14
|
var cmdk = require('cmdk');
|
|
15
|
-
var
|
|
15
|
+
var countryFlags = require('country-flag-icons/react/3x2');
|
|
16
16
|
var react$1 = require('motion/react');
|
|
17
17
|
var reactDropzone = require('react-dropzone');
|
|
18
18
|
var Color = require('color');
|
|
@@ -26,12 +26,33 @@ require('temporal-polyfill/global');
|
|
|
26
26
|
var temporalPolyfill = require('temporal-polyfill');
|
|
27
27
|
var reactHookForm = require('react-hook-form');
|
|
28
28
|
var zod = require('@hookform/resolvers/zod');
|
|
29
|
+
var confetti = require('canvas-confetti');
|
|
29
30
|
var reactTable = require('@tanstack/react-table');
|
|
30
31
|
|
|
31
32
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
32
33
|
|
|
34
|
+
function _interopNamespace(e) {
|
|
35
|
+
if (e && e.__esModule) return e;
|
|
36
|
+
var n = Object.create(null);
|
|
37
|
+
if (e) {
|
|
38
|
+
Object.keys(e).forEach(function (k) {
|
|
39
|
+
if (k !== 'default') {
|
|
40
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
41
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return e[k]; }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
n.default = e;
|
|
49
|
+
return Object.freeze(n);
|
|
50
|
+
}
|
|
51
|
+
|
|
33
52
|
var useEmblaCarousel__default = /*#__PURE__*/_interopDefault(useEmblaCarousel);
|
|
53
|
+
var countryFlags__namespace = /*#__PURE__*/_interopNamespace(countryFlags);
|
|
34
54
|
var Color__default = /*#__PURE__*/_interopDefault(Color);
|
|
55
|
+
var confetti__default = /*#__PURE__*/_interopDefault(confetti);
|
|
35
56
|
|
|
36
57
|
// src/components/ui/Alert/alert.tsx
|
|
37
58
|
function cn(...inputs) {
|
|
@@ -1054,6 +1075,15 @@ function Link({
|
|
|
1054
1075
|
}
|
|
1055
1076
|
);
|
|
1056
1077
|
}
|
|
1078
|
+
function validatePhone(value) {
|
|
1079
|
+
if (!value) {
|
|
1080
|
+
return { isValid: false };
|
|
1081
|
+
}
|
|
1082
|
+
if (libphonenumberJs.isValidPhoneNumber(value)) {
|
|
1083
|
+
return { isValid: true };
|
|
1084
|
+
}
|
|
1085
|
+
return { isValid: false, problem: libphonenumberJs.validatePhoneNumberLength(value) ?? "INVALID" };
|
|
1086
|
+
}
|
|
1057
1087
|
function Popover({ ...props }) {
|
|
1058
1088
|
return /* @__PURE__ */ jsxRuntime.jsx(radixUi.Popover.Root, { "data-slot": "popover", ...props });
|
|
1059
1089
|
}
|
|
@@ -1126,68 +1156,36 @@ function stripLeadingDialCode(raw, dialCode) {
|
|
|
1126
1156
|
const code = dialCode.replace(/\D/g, "");
|
|
1127
1157
|
return code && digits.startsWith(code) ? digits.length > code.length ? digits.slice(code.length) : "" : digits;
|
|
1128
1158
|
}
|
|
1129
|
-
var flagByCode =
|
|
1130
|
-
AR: _3x2.AR,
|
|
1131
|
-
BO: _3x2.BO,
|
|
1132
|
-
BR: _3x2.BR,
|
|
1133
|
-
CA: _3x2.CA,
|
|
1134
|
-
CL: _3x2.CL,
|
|
1135
|
-
CO: _3x2.CO,
|
|
1136
|
-
CR: _3x2.CR,
|
|
1137
|
-
CU: _3x2.CU,
|
|
1138
|
-
DE: _3x2.DE,
|
|
1139
|
-
DO: _3x2.DO,
|
|
1140
|
-
EC: _3x2.EC,
|
|
1141
|
-
ES: _3x2.ES,
|
|
1142
|
-
FR: _3x2.FR,
|
|
1143
|
-
GB: _3x2.GB,
|
|
1144
|
-
GT: _3x2.GT,
|
|
1145
|
-
HN: _3x2.HN,
|
|
1146
|
-
IN: _3x2.IN,
|
|
1147
|
-
IT: _3x2.IT,
|
|
1148
|
-
MX: _3x2.MX,
|
|
1149
|
-
NI: _3x2.NI,
|
|
1150
|
-
PA: _3x2.PA,
|
|
1151
|
-
PE: _3x2.PE,
|
|
1152
|
-
PT: _3x2.PT,
|
|
1153
|
-
PY: _3x2.PY,
|
|
1154
|
-
SV: _3x2.SV,
|
|
1155
|
-
US: _3x2.US,
|
|
1156
|
-
UY: _3x2.UY,
|
|
1157
|
-
VE: _3x2.VE
|
|
1158
|
-
};
|
|
1159
|
+
var flagByCode = countryFlags__namespace;
|
|
1159
1160
|
function CountryFlag({
|
|
1160
1161
|
code,
|
|
1161
1162
|
flagUrl,
|
|
1162
1163
|
className
|
|
1163
1164
|
}) {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
}
|
|
1183
|
-
);
|
|
1184
|
-
}
|
|
1185
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: cn("bg-muted size-4 shrink-0 rounded-full", className) });
|
|
1165
|
+
const isoCode = (code || "").toUpperCase();
|
|
1166
|
+
const FlagComponent = flagByCode[isoCode];
|
|
1167
|
+
const flag = flagUrl ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: flagUrl, alt: "", "aria-hidden": "true", className: "size-full object-cover" }) : FlagComponent ? /* @__PURE__ */ jsxRuntime.jsx(FlagComponent, { "aria-hidden": "true", className: "size-full" }) : null;
|
|
1168
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1169
|
+
"span",
|
|
1170
|
+
{
|
|
1171
|
+
"data-slot": "phone-field-country-flag",
|
|
1172
|
+
"data-country": isoCode || void 0,
|
|
1173
|
+
"data-fallback": flag ? void 0 : "true",
|
|
1174
|
+
"aria-hidden": "true",
|
|
1175
|
+
className: cn(
|
|
1176
|
+
"size-4 shrink-0 overflow-hidden rounded-[2px]",
|
|
1177
|
+
!flag && "bg-muted rounded-full",
|
|
1178
|
+
className
|
|
1179
|
+
),
|
|
1180
|
+
children: flag
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1186
1183
|
}
|
|
1187
1184
|
function PhoneField({
|
|
1188
1185
|
countries,
|
|
1189
1186
|
value,
|
|
1190
1187
|
onValueChange,
|
|
1188
|
+
onValidityChange,
|
|
1191
1189
|
defaultCountry,
|
|
1192
1190
|
placeholder = "Phone number",
|
|
1193
1191
|
disabled = false,
|
|
@@ -1204,6 +1202,7 @@ function PhoneField({
|
|
|
1204
1202
|
const listRef = react.useRef(null);
|
|
1205
1203
|
const inputRef = react.useRef(null);
|
|
1206
1204
|
const caretRef = react.useRef(null);
|
|
1205
|
+
const lastValidityRef = react.useRef(null);
|
|
1207
1206
|
const listId = `${react.useId()}-countries-list`;
|
|
1208
1207
|
const isControlled = value !== void 0;
|
|
1209
1208
|
const currentValue = isControlled ? value : internalValue;
|
|
@@ -1214,7 +1213,9 @@ function PhoneField({
|
|
|
1214
1213
|
const callingCodeInList = parsedCallingCode !== void 0 && countries.some(
|
|
1215
1214
|
(country) => country.dialCode.replace(/\D/g, "") === parsedCallingCode
|
|
1216
1215
|
);
|
|
1217
|
-
const
|
|
1216
|
+
const pickedCountry = pickedCode ? countries.find((country) => country.code.toUpperCase() === pickedCode.toUpperCase()) : void 0;
|
|
1217
|
+
const pickMatchesValue = pickedCountry !== void 0 && pickedCountry.dialCode.replace(/\D/g, "") === parsedCallingCode;
|
|
1218
|
+
const representedCode = countryInList ? parsedCountry : pickMatchesValue ? pickedCountry.code : callingCodeInList ? countries.find(
|
|
1218
1219
|
(country) => country.dialCode.replace(/\D/g, "") === parsedCallingCode
|
|
1219
1220
|
)?.code : void 0;
|
|
1220
1221
|
const selectedCode = representedCode ?? pickedCode ?? defaultCountry ?? countries[0]?.code;
|
|
@@ -1229,6 +1230,15 @@ function PhoneField({
|
|
|
1229
1230
|
nationalDigits
|
|
1230
1231
|
) : nationalDigits;
|
|
1231
1232
|
const isInvalid = inputProps["aria-invalid"] === true || inputProps["aria-invalid"] === "true";
|
|
1233
|
+
const { isValid, problem } = validatePhone(currentValue);
|
|
1234
|
+
react.useEffect(() => {
|
|
1235
|
+
const last = lastValidityRef.current;
|
|
1236
|
+
if (last && last.isValid === isValid && last.problem === problem) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
lastValidityRef.current = { isValid, problem };
|
|
1240
|
+
onValidityChange?.({ isValid, problem });
|
|
1241
|
+
}, [isValid, problem, onValidityChange]);
|
|
1232
1242
|
react.useLayoutEffect(() => {
|
|
1233
1243
|
const input = inputRef.current;
|
|
1234
1244
|
const caret = caretRef.current;
|
|
@@ -1321,17 +1331,21 @@ function PhoneField({
|
|
|
1321
1331
|
}
|
|
1322
1332
|
}
|
|
1323
1333
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
if (!
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1334
|
+
const next = national ? `+${emitCode}${national}` : "";
|
|
1335
|
+
const grew = national.replace(/\D/g, "").length > nationalDigits.length;
|
|
1336
|
+
const isPaste = nativeEvent?.inputType === "insertFromPaste";
|
|
1337
|
+
if (grew && !isPaste && libphonenumberJs.validatePhoneNumberLength(next) === "TOO_LONG") {
|
|
1338
|
+
if (input) {
|
|
1339
|
+
const caret = Math.max(0, (input.selectionStart ?? inputValue.length) - 1);
|
|
1340
|
+
input.value = inputValue;
|
|
1341
|
+
input.setSelectionRange(caret, caret);
|
|
1331
1342
|
}
|
|
1343
|
+
caretRef.current = null;
|
|
1332
1344
|
return;
|
|
1333
1345
|
}
|
|
1334
|
-
|
|
1346
|
+
if (nextPickedCode) {
|
|
1347
|
+
setPickedCode(nextPickedCode);
|
|
1348
|
+
}
|
|
1335
1349
|
onValueChange?.(next);
|
|
1336
1350
|
if (!isControlled) {
|
|
1337
1351
|
setInternalValue(next);
|
|
@@ -7100,6 +7114,38 @@ var logos = {
|
|
|
7100
7114
|
monochBlack: `${CDN_BASE}/logos/Logo_Total_monochB.webp`,
|
|
7101
7115
|
monochOrange: `${CDN_BASE}/logos/Logo_Total_monochO.webp`
|
|
7102
7116
|
};
|
|
7117
|
+
var CONFETTI_COLORS = [
|
|
7118
|
+
"#22205f",
|
|
7119
|
+
// --color-main-blue-primary
|
|
7120
|
+
"#f66a24",
|
|
7121
|
+
// --color-main-orange-primary
|
|
7122
|
+
"#faca4a",
|
|
7123
|
+
// --color-main-yellow-primary
|
|
7124
|
+
"#01d42f",
|
|
7125
|
+
// --color-main-positive-state
|
|
7126
|
+
"#d93235"
|
|
7127
|
+
// --color-main-warning-state
|
|
7128
|
+
];
|
|
7129
|
+
function fireConfetti({
|
|
7130
|
+
particleCount = 60,
|
|
7131
|
+
originY = 0.7,
|
|
7132
|
+
colors = [...CONFETTI_COLORS]
|
|
7133
|
+
} = {}) {
|
|
7134
|
+
const shared = {
|
|
7135
|
+
particleCount,
|
|
7136
|
+
colors,
|
|
7137
|
+
spread: 70,
|
|
7138
|
+
startVelocity: 55,
|
|
7139
|
+
disableForReducedMotion: true
|
|
7140
|
+
};
|
|
7141
|
+
return Promise.all([
|
|
7142
|
+
confetti__default.default({ ...shared, angle: 60, origin: { x: 0, y: originY } }),
|
|
7143
|
+
confetti__default.default({ ...shared, angle: 120, origin: { x: 1, y: originY } })
|
|
7144
|
+
]).then(() => void 0);
|
|
7145
|
+
}
|
|
7146
|
+
function resetConfetti() {
|
|
7147
|
+
confetti__default.default.reset();
|
|
7148
|
+
}
|
|
7103
7149
|
function Table({
|
|
7104
7150
|
className,
|
|
7105
7151
|
containerClassName = "overflow-x-auto",
|
|
@@ -9431,6 +9477,7 @@ exports.BreadcrumbList = BreadcrumbList;
|
|
|
9431
9477
|
exports.BreadcrumbPage = BreadcrumbPage;
|
|
9432
9478
|
exports.BreadcrumbSeparator = BreadcrumbSeparator;
|
|
9433
9479
|
exports.Button = Button;
|
|
9480
|
+
exports.CONFETTI_COLORS = CONFETTI_COLORS;
|
|
9434
9481
|
exports.Can = Can;
|
|
9435
9482
|
exports.CanNot = CanNot;
|
|
9436
9483
|
exports.Card = Card;
|
|
@@ -9658,6 +9705,7 @@ exports.createBackendParamsWithFilters = createBackendParamsWithFilters;
|
|
|
9658
9705
|
exports.duration = duration;
|
|
9659
9706
|
exports.ease = ease;
|
|
9660
9707
|
exports.fadeIn = fadeIn;
|
|
9708
|
+
exports.fireConfetti = fireConfetti;
|
|
9661
9709
|
exports.getActiveFilterCount = getActiveFilterCount;
|
|
9662
9710
|
exports.getActiveFilterValues = getActiveFilterValues;
|
|
9663
9711
|
exports.getColumnValueCounts = getColumnValueCounts;
|
|
@@ -9673,6 +9721,7 @@ exports.parseJsonToFilters = parseJsonToFilters;
|
|
|
9673
9721
|
exports.parseQueryParamsToFilters = parseQueryParamsToFilters;
|
|
9674
9722
|
exports.progressIndicatorVariants = progressIndicatorVariants;
|
|
9675
9723
|
exports.progressVariants = progressVariants;
|
|
9724
|
+
exports.resetConfetti = resetConfetti;
|
|
9676
9725
|
exports.scaleIn = scaleIn;
|
|
9677
9726
|
exports.searchInArray = searchInArray;
|
|
9678
9727
|
exports.skeletonVariants = skeletonVariants;
|
|
@@ -9705,5 +9754,6 @@ exports.useTableSizing = useTableSizing;
|
|
|
9705
9754
|
exports.useTableSorting = useTableSorting;
|
|
9706
9755
|
exports.useTableVisibility = useTableVisibility;
|
|
9707
9756
|
exports.useToast = useToast;
|
|
9757
|
+
exports.validatePhone = validatePhone;
|
|
9708
9758
|
//# sourceMappingURL=main.cjs.map
|
|
9709
9759
|
//# sourceMappingURL=main.cjs.map
|