funuicss 3.8.14 → 3.8.16
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/css/fun.css +215 -130
- package/package.json +1 -1
- package/ui/accordion/Accordion.d.ts +2 -0
- package/ui/accordion/Accordion.js +655 -56
- package/ui/carousel/Carousel.d.ts +2 -0
- package/ui/carousel/Carousel.js +101 -91
- package/ui/form/Form.js +25 -7
- package/ui/sidebar/SideBar.d.ts +2 -1
- package/ui/sidebar/SideBar.js +356 -14
- package/ui/vista/Vista.d.ts +8 -10
- package/ui/vista/Vista.js +62 -120
|
@@ -12,6 +12,8 @@ interface CarouselProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
infiniteScroll?: boolean;
|
|
13
13
|
infiniteScrollSpeed?: number;
|
|
14
14
|
infiniteScrollDirection?: 'left' | 'right' | 'alternate';
|
|
15
|
+
overflowCss?: string;
|
|
16
|
+
overflowPadding?: string;
|
|
15
17
|
}
|
|
16
18
|
declare const Carousel: React.FC<CarouselProps>;
|
|
17
19
|
export default Carousel;
|
package/ui/carousel/Carousel.js
CHANGED
|
@@ -55,27 +55,52 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
55
55
|
}
|
|
56
56
|
return t;
|
|
57
57
|
};
|
|
58
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
-
};
|
|
61
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
59
|
var react_1 = __importStar(require("react"));
|
|
63
60
|
var pi_1 = require("react-icons/pi");
|
|
64
|
-
|
|
65
|
-
var
|
|
66
|
-
|
|
61
|
+
// Helper function to detect touch devices
|
|
62
|
+
var isTouchDevice = function () {
|
|
63
|
+
return (('ontouchstart' in window) ||
|
|
64
|
+
(navigator.maxTouchPoints > 0));
|
|
65
|
+
};
|
|
66
|
+
// Simple Circle component
|
|
67
|
+
var Circle = function (_a) {
|
|
68
|
+
var bordered = _a.bordered, _b = _a.size, size = _b === void 0 ? 2.5 : _b, onClick = _a.onClick, children = _a.children;
|
|
69
|
+
return (react_1.default.createElement("div", { onClick: onClick, style: {
|
|
70
|
+
width: "".concat(size, "rem"),
|
|
71
|
+
height: "".concat(size, "rem"),
|
|
72
|
+
borderRadius: '50%',
|
|
73
|
+
display: 'flex',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
justifyContent: 'center',
|
|
76
|
+
border: bordered ? '1px solid var(--borderColor, #ccc)' : 'none',
|
|
77
|
+
cursor: 'pointer',
|
|
78
|
+
background: 'var(--background, white)',
|
|
79
|
+
transition: 'all 0.2s ease'
|
|
80
|
+
} }, children));
|
|
81
|
+
};
|
|
82
|
+
// Simple RowFlex component
|
|
83
|
+
var RowFlex = function (_a) {
|
|
84
|
+
var _b = _a.gap, gap = _b === void 0 ? 0.5 : _b, _c = _a.justify, justify = _c === void 0 ? 'flex-start' : _c, children = _a.children;
|
|
85
|
+
return (react_1.default.createElement("div", { style: {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
gap: "".concat(gap, "rem"),
|
|
88
|
+
justifyContent: justify
|
|
89
|
+
} }, children));
|
|
90
|
+
};
|
|
67
91
|
var Carousel = function (_a) {
|
|
68
|
-
var _b = _a.scrollNumber, scrollNumber = _b === void 0 ? 320 : _b, _c = _a.gap, gap = _c === void 0 ? 0.5 : _c, _d = _a.funcss, funcss = _d === void 0 ? '' : _d, _e = _a.showDashes, showDashes = _e === void 0 ? true : _e, _f = _a.allowVerticalOverflow, allowVerticalOverflow = _f === void 0 ? false : _f, _g = _a.itemPadding, itemPadding = _g === void 0 ? '
|
|
92
|
+
var _b = _a.scrollNumber, scrollNumber = _b === void 0 ? 320 : _b, _c = _a.gap, gap = _c === void 0 ? 0.5 : _c, _d = _a.funcss, funcss = _d === void 0 ? '' : _d, _e = _a.showDashes, showDashes = _e === void 0 ? true : _e, _f = _a.allowVerticalOverflow, allowVerticalOverflow = _f === void 0 ? false : _f, _g = _a.itemPadding, itemPadding = _g === void 0 ? '' : _g, children = _a.children, _h = _a.controlerSize, controlerSize = _h === void 0 ? 2.5 : _h, _j = _a.controlerIconSize, controlerIconSize = _j === void 0 ? 20 : _j, _k = _a.infiniteScroll, infiniteScroll = _k === void 0 ? false : _k, _l = _a.infiniteScrollSpeed, infiniteScrollSpeed = _l === void 0 ? 50 : _l, _m = _a.infiniteScrollDirection, infiniteScrollDirection = _m === void 0 ? 'left' : _m, _o = _a.overflowPadding, overflowPadding = _o === void 0 ? '' : _o, _p = _a.overflowCss, overflowCss = _p === void 0 ? '' : _p, rest = __rest(_a, ["scrollNumber", "gap", "funcss", "showDashes", "allowVerticalOverflow", "itemPadding", "children", "controlerSize", "controlerIconSize", "infiniteScroll", "infiniteScrollSpeed", "infiniteScrollDirection", "overflowPadding", "overflowCss"]);
|
|
69
93
|
var scrollRef = (0, react_1.useRef)(null);
|
|
70
94
|
var containerRef = (0, react_1.useRef)(null);
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
-
var
|
|
95
|
+
var _q = (0, react_1.useState)('start'), scrollPosition = _q[0], setScrollPosition = _q[1];
|
|
96
|
+
var _r = (0, react_1.useState)(false), isPhone = _r[0], setIsPhone = _r[1];
|
|
97
|
+
var _s = (0, react_1.useState)(false), isScrollable = _s[0], setIsScrollable = _s[1];
|
|
98
|
+
var _t = (0, react_1.useState)(infiniteScrollDirection === 'right' ? 'right' : 'left'), autoScrollDirection = _t[0], setAutoScrollDirection = _t[1];
|
|
99
|
+
var _u = (0, react_1.useState)(false), isPaused = _u[0], setIsPaused = _u[1];
|
|
100
|
+
var _v = (0, react_1.useState)(false), isReady = _v[0], setIsReady = _v[1];
|
|
101
|
+
var animationFrameRef = (0, react_1.useRef)(null);
|
|
102
|
+
var lastTimestampRef = (0, react_1.useRef)(0);
|
|
103
|
+
var startDelayRef = (0, react_1.useRef)(false);
|
|
79
104
|
var checkScrollable = function () {
|
|
80
105
|
var container = scrollRef.current;
|
|
81
106
|
if (container) {
|
|
@@ -87,19 +112,23 @@ var Carousel = function (_a) {
|
|
|
87
112
|
window.addEventListener('resize', checkScrollable);
|
|
88
113
|
return function () { return window.removeEventListener('resize', checkScrollable); };
|
|
89
114
|
}, [children]);
|
|
115
|
+
// Delay start for smooth initialization
|
|
90
116
|
(0, react_1.useEffect)(function () {
|
|
91
|
-
if (
|
|
92
|
-
|
|
117
|
+
if (infiniteScroll && isScrollable) {
|
|
118
|
+
// Wait for layout to settle and then start
|
|
119
|
+
var timer_1 = setTimeout(function () {
|
|
120
|
+
setIsReady(true);
|
|
121
|
+
}, 300);
|
|
122
|
+
return function () { return clearTimeout(timer_1); };
|
|
93
123
|
}
|
|
94
124
|
else {
|
|
95
|
-
|
|
125
|
+
setIsReady(false);
|
|
96
126
|
}
|
|
127
|
+
}, [infiniteScroll, isScrollable]);
|
|
128
|
+
(0, react_1.useEffect)(function () {
|
|
129
|
+
setIsPhone(isTouchDevice());
|
|
97
130
|
}, []);
|
|
98
131
|
var handleScroll = function () {
|
|
99
|
-
if (isProgrammaticScrollRef.current) {
|
|
100
|
-
isProgrammaticScrollRef.current = false;
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
132
|
var container = scrollRef.current;
|
|
104
133
|
if (!container)
|
|
105
134
|
return;
|
|
@@ -114,7 +143,6 @@ var Carousel = function (_a) {
|
|
|
114
143
|
else {
|
|
115
144
|
setScrollPosition('middle');
|
|
116
145
|
}
|
|
117
|
-
lastScrollTimeRef.current = Date.now();
|
|
118
146
|
};
|
|
119
147
|
var scroll = function (direction) {
|
|
120
148
|
var container = scrollRef.current;
|
|
@@ -125,18 +153,31 @@ var Carousel = function (_a) {
|
|
|
125
153
|
behavior: 'smooth',
|
|
126
154
|
});
|
|
127
155
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
156
|
+
// Smooth auto-scroll animation using requestAnimationFrame
|
|
157
|
+
var smoothAutoScroll = function (timestamp) {
|
|
158
|
+
if (!infiniteScroll || !scrollRef.current || isPaused || !isScrollable || !isReady) {
|
|
159
|
+
animationFrameRef.current = null;
|
|
160
|
+
lastTimestampRef.current = 0;
|
|
134
161
|
return;
|
|
135
162
|
}
|
|
136
163
|
var container = scrollRef.current;
|
|
137
164
|
var scrollLeft = container.scrollLeft, scrollWidth = container.scrollWidth, clientWidth = container.clientWidth;
|
|
138
165
|
var maxScrollLeft = scrollWidth - clientWidth;
|
|
166
|
+
// Initialize timestamp on first frame
|
|
167
|
+
if (lastTimestampRef.current === 0) {
|
|
168
|
+
lastTimestampRef.current = timestamp;
|
|
169
|
+
animationFrameRef.current = requestAnimationFrame(smoothAutoScroll);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
// Calculate time delta for smooth animation
|
|
173
|
+
var deltaTime = timestamp - lastTimestampRef.current;
|
|
174
|
+
lastTimestampRef.current = timestamp;
|
|
175
|
+
// Calculate scroll amount based on speed and time (pixels per second)
|
|
176
|
+
// Cap deltaTime to prevent large jumps after tab switches
|
|
177
|
+
var cappedDeltaTime = Math.min(deltaTime, 100);
|
|
178
|
+
var scrollAmount = (infiniteScrollSpeed * cappedDeltaTime) / 1000;
|
|
139
179
|
var newDirection = autoScrollDirection;
|
|
180
|
+
// Handle alternate direction
|
|
140
181
|
if (infiniteScrollDirection === 'alternate') {
|
|
141
182
|
if (scrollLeft <= 0) {
|
|
142
183
|
newDirection = 'right';
|
|
@@ -147,32 +188,42 @@ var Carousel = function (_a) {
|
|
|
147
188
|
setAutoScrollDirection('left');
|
|
148
189
|
}
|
|
149
190
|
}
|
|
150
|
-
|
|
151
|
-
isProgrammaticScrollRef.current = true;
|
|
191
|
+
// Perform the scroll
|
|
152
192
|
if (newDirection === 'left') {
|
|
153
193
|
container.scrollLeft -= scrollAmount;
|
|
194
|
+
// Loop back for infinite scroll (non-alternate)
|
|
154
195
|
if (scrollLeft <= 0 && infiniteScrollDirection !== 'alternate') {
|
|
155
196
|
container.scrollLeft = maxScrollLeft;
|
|
156
197
|
}
|
|
157
198
|
}
|
|
158
199
|
else {
|
|
159
200
|
container.scrollLeft += scrollAmount;
|
|
201
|
+
// Loop back for infinite scroll (non-alternate)
|
|
160
202
|
if (scrollLeft >= maxScrollLeft - 1 && infiniteScrollDirection !== 'alternate') {
|
|
161
203
|
container.scrollLeft = 0;
|
|
162
204
|
}
|
|
163
205
|
}
|
|
164
|
-
|
|
206
|
+
animationFrameRef.current = requestAnimationFrame(smoothAutoScroll);
|
|
165
207
|
};
|
|
208
|
+
// Start/stop auto-scroll based on pause state
|
|
166
209
|
(0, react_1.useEffect)(function () {
|
|
167
|
-
if (infiniteScroll) {
|
|
168
|
-
|
|
210
|
+
if (infiniteScroll && !isPaused && isScrollable && isReady) {
|
|
211
|
+
lastTimestampRef.current = 0;
|
|
212
|
+
animationFrameRef.current = requestAnimationFrame(smoothAutoScroll);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
if (animationFrameRef.current) {
|
|
216
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
217
|
+
animationFrameRef.current = null;
|
|
218
|
+
}
|
|
219
|
+
lastTimestampRef.current = 0;
|
|
169
220
|
}
|
|
170
221
|
return function () {
|
|
171
|
-
if (
|
|
172
|
-
cancelAnimationFrame(
|
|
222
|
+
if (animationFrameRef.current) {
|
|
223
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
173
224
|
}
|
|
174
225
|
};
|
|
175
|
-
}, [infiniteScroll, infiniteScrollSpeed, infiniteScrollDirection,
|
|
226
|
+
}, [infiniteScroll, infiniteScrollSpeed, infiniteScrollDirection, isPaused, isScrollable, autoScrollDirection, isReady]);
|
|
176
227
|
(0, react_1.useEffect)(function () {
|
|
177
228
|
setAutoScrollDirection(infiniteScrollDirection === 'right' ? 'right' : 'left');
|
|
178
229
|
}, [infiniteScrollDirection]);
|
|
@@ -187,53 +238,29 @@ var Carousel = function (_a) {
|
|
|
187
238
|
var childrenArray = react_1.default.Children.toArray(children);
|
|
188
239
|
if (childrenArray.length === 0)
|
|
189
240
|
return children;
|
|
190
|
-
// Clone enough items to create a seamless infinite effect
|
|
191
|
-
// We need enough clones to fill at least 3 times the viewport width
|
|
192
241
|
var container = scrollRef.current;
|
|
193
242
|
var clonesNeeded = container ? Math.ceil(container.clientWidth * 3 / (scrollNumber || 320)) : 3;
|
|
194
243
|
var clonedItems = [];
|
|
195
244
|
for (var i = 0; i < clonesNeeded; i++) {
|
|
196
245
|
clonedItems.push.apply(clonedItems, childrenArray);
|
|
197
246
|
}
|
|
198
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, clonedItems.map(function (child, index) { return (react_1.default.createElement("div", { key: index, className: "carousel-item", style: { flexShrink: 0 } },
|
|
247
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, clonedItems.map(function (child, index) { return (react_1.default.createElement("div", { key: index, className: "carousel-item", style: { flexShrink: 0 }, onMouseEnter: function () { return setIsPaused(true); }, onMouseLeave: function () { return setIsPaused(false); } },
|
|
199
248
|
react_1.default.createElement("div", { className: "carousel-card" }, child))); })));
|
|
200
249
|
};
|
|
201
|
-
var handleMouseEnter = function () {
|
|
202
|
-
setIsHovered(true);
|
|
203
|
-
if (animationRef.current) {
|
|
204
|
-
cancelAnimationFrame(animationRef.current);
|
|
205
|
-
animationRef.current = null;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
var handleMouseLeave = function () {
|
|
209
|
-
setIsHovered(false);
|
|
210
|
-
if (infiniteScroll && !isHovered) {
|
|
211
|
-
infiniteScrollAnimation();
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
// Handle touch events for mobile
|
|
215
250
|
var handleTouchStart = function () {
|
|
216
|
-
|
|
217
|
-
if (animationRef.current) {
|
|
218
|
-
cancelAnimationFrame(animationRef.current);
|
|
219
|
-
animationRef.current = null;
|
|
220
|
-
}
|
|
251
|
+
setIsPaused(true);
|
|
221
252
|
};
|
|
222
253
|
var handleTouchEnd = function () {
|
|
223
|
-
// Wait a bit before resuming to allow user to interact
|
|
224
254
|
setTimeout(function () {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
infiniteScrollAnimation();
|
|
228
|
-
}
|
|
229
|
-
}, 1000); // Resume after 1 second of inactivity
|
|
255
|
+
setIsPaused(false);
|
|
256
|
+
}, 1000);
|
|
230
257
|
};
|
|
231
|
-
return (react_1.default.createElement("div", __assign({ ref: containerRef, className: "carousel-wrapper
|
|
258
|
+
return (react_1.default.createElement("div", __assign({ ref: containerRef, className: "carousel-wrapper", onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd }, rest),
|
|
232
259
|
react_1.default.createElement(react_1.default.Fragment, null,
|
|
233
260
|
!isPhone && isScrollable && !infiniteScroll && (react_1.default.createElement("div", { className: 'carouselLeft' },
|
|
234
|
-
react_1.default.createElement(
|
|
261
|
+
react_1.default.createElement(Circle, { bordered: true, size: controlerSize, onClick: function () { return scroll('left'); } },
|
|
235
262
|
react_1.default.createElement(pi_1.PiCaretLeft, { className: 'text-primary', size: controlerIconSize })))),
|
|
236
|
-
react_1.default.createElement("div", { ref: scrollRef, className: "carousel-container scrollbar-hide w-full", style: {
|
|
263
|
+
react_1.default.createElement("div", { ref: scrollRef, className: "carousel-container scrollbar-hide w-full ".concat(funcss, " ").concat(isScrollable ? overflowCss : ''), style: {
|
|
237
264
|
width: '100%',
|
|
238
265
|
gap: gap + 'rem',
|
|
239
266
|
overflowX: 'auto',
|
|
@@ -242,15 +269,15 @@ var Carousel = function (_a) {
|
|
|
242
269
|
justifyItems: (isScrollable || isPhone) ? 'flex-start' : 'center',
|
|
243
270
|
scrollSnapType: infiniteScroll ? 'none' : 'x mandatory',
|
|
244
271
|
scrollBehavior: 'smooth',
|
|
245
|
-
padding:
|
|
272
|
+
padding: (isScrollable && overflowPadding) ? overflowPadding : itemPadding,
|
|
246
273
|
cursor: infiniteScroll ? 'grab' : 'default'
|
|
247
|
-
},
|
|
274
|
+
}, onScroll: handleScroll }, infiniteScroll ? cloneChildren() : (react_1.default.Children.map(children, function (child, index) { return (react_1.default.createElement("div", { className: "carousel-item", style: { flexShrink: 0 }, onMouseEnter: function () { return !infiniteScroll && setIsPaused(true); }, onMouseLeave: function () { return !infiniteScroll && setIsPaused(false); } },
|
|
248
275
|
react_1.default.createElement("div", { className: "carousel-card" }, child))); }))),
|
|
249
276
|
!isPhone && isScrollable && !infiniteScroll && (react_1.default.createElement("div", { className: 'carouselRight' },
|
|
250
|
-
react_1.default.createElement(
|
|
277
|
+
react_1.default.createElement(Circle, { bordered: true, size: controlerSize, onClick: function () { return scroll('right'); } },
|
|
251
278
|
react_1.default.createElement(pi_1.PiCaretRight, { className: 'text-primary', size: controlerIconSize }))))),
|
|
252
279
|
(showDashes && isScrollable && !infiniteScroll) && (react_1.default.createElement("div", { className: "center padding-top-10" },
|
|
253
|
-
react_1.default.createElement(
|
|
280
|
+
react_1.default.createElement(RowFlex, { gap: 0.5, justify: "center" }, ['start', 'middle', 'end'].map(function (pos) { return (react_1.default.createElement("div", { className: 'pointer', key: pos, onClick: function () {
|
|
254
281
|
var _a, _b;
|
|
255
282
|
if (pos === 'start') {
|
|
256
283
|
scroll('left');
|
|
@@ -267,27 +294,10 @@ var Carousel = function (_a) {
|
|
|
267
294
|
}, style: {
|
|
268
295
|
width: '10px',
|
|
269
296
|
height: '10px',
|
|
270
|
-
background: scrollPosition === pos ? 'var(--primary)' : 'var(--borderColor)',
|
|
297
|
+
background: scrollPosition === pos ? 'var(--primary, #007bff)' : 'var(--borderColor, #ccc)',
|
|
271
298
|
borderRadius: '50%',
|
|
272
299
|
transform: scrollPosition === pos ? 'scale(1.3)' : 'scale(0.9)',
|
|
273
300
|
transition: 'transform 0.3s ease, background 0.3s ease',
|
|
274
|
-
} })); }))))
|
|
275
|
-
infiniteScroll && isHovered && (react_1.default.createElement("div", { style: {
|
|
276
|
-
position: 'absolute',
|
|
277
|
-
top: '50%',
|
|
278
|
-
left: '50%',
|
|
279
|
-
transform: 'translate(-50%, -50%)',
|
|
280
|
-
background: 'rgba(0,0,0,0.7)',
|
|
281
|
-
color: 'white',
|
|
282
|
-
padding: '5px 10px',
|
|
283
|
-
borderRadius: '5px',
|
|
284
|
-
fontSize: '12px',
|
|
285
|
-
zIndex: 10,
|
|
286
|
-
pointerEvents: 'none',
|
|
287
|
-
opacity: 0,
|
|
288
|
-
animation: 'fadeInOut 2s ease'
|
|
289
|
-
} },
|
|
290
|
-
"Scroll paused",
|
|
291
|
-
react_1.default.createElement("style", null, "\n @keyframes fadeInOut {\n 0% { opacity: 0; }\n 10% { opacity: 1; }\n 90% { opacity: 1; }\n 100% { opacity: 0; }\n }\n ")))));
|
|
301
|
+
} })); }))))));
|
|
292
302
|
};
|
|
293
303
|
exports.default = Carousel;
|
package/ui/form/Form.js
CHANGED
|
@@ -384,7 +384,7 @@ var Form = function (props) {
|
|
|
384
384
|
}, [parsedDefaultValues]);
|
|
385
385
|
// Validate a single field
|
|
386
386
|
var validateField = (0, react_1.useCallback)(function (field, value) {
|
|
387
|
-
var _a, _b, _c, _d, _e;
|
|
387
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
388
388
|
// Required validation
|
|
389
389
|
if (field.required) {
|
|
390
390
|
if (value === undefined || value === null || value === '') {
|
|
@@ -431,16 +431,34 @@ var Form = function (props) {
|
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
// Phone validation (basic) - only for strings
|
|
434
|
+
// Phone validation (basic) - only for strings
|
|
434
435
|
if (field.type === 'tel' && typeof value === 'string') {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
// Remove all non-digit characters except + at the beginning
|
|
437
|
+
var cleanedValue = value.replace(/[^\d+]/g, '');
|
|
438
|
+
// Check if the value contains any letters (shouldn't happen after cleaning, but just in case)
|
|
439
|
+
if (/[a-zA-Z]/.test(value)) {
|
|
440
|
+
return 'Phone number cannot contain letters';
|
|
441
|
+
}
|
|
442
|
+
// Allow numbers starting with 0 or with country code (+)
|
|
443
|
+
var phoneRegex = /^[\+]?[0-9]{0,18}$/;
|
|
444
|
+
if (value && !phoneRegex.test(cleanedValue)) {
|
|
445
|
+
return 'Please enter a valid phone number (digits only, can start with 0 or +)';
|
|
446
|
+
}
|
|
447
|
+
// Optional: Add minimum length check
|
|
448
|
+
var minLength = ((_c = field.inputProps) === null || _c === void 0 ? void 0 : _c.minLength) || 10; // Default 10 digits
|
|
449
|
+
if (cleanedValue.length > 0 && cleanedValue.length < minLength) {
|
|
450
|
+
return "Phone number must be at least ".concat(minLength, " digits");
|
|
451
|
+
}
|
|
452
|
+
// Optional: Add maximum length check
|
|
453
|
+
var maxLength = ((_d = field.inputProps) === null || _d === void 0 ? void 0 : _d.maxLength) || 15; // Default 15 digits
|
|
454
|
+
if (cleanedValue.length > maxLength) {
|
|
455
|
+
return "Phone number cannot exceed ".concat(maxLength, " digits");
|
|
438
456
|
}
|
|
439
457
|
}
|
|
440
458
|
// Length validation for strings
|
|
441
459
|
if (typeof value === 'string') {
|
|
442
|
-
var minLength = (
|
|
443
|
-
var maxLength = (
|
|
460
|
+
var minLength = (_e = field.inputProps) === null || _e === void 0 ? void 0 : _e.minLength;
|
|
461
|
+
var maxLength = (_f = field.inputProps) === null || _f === void 0 ? void 0 : _f.maxLength;
|
|
444
462
|
if (minLength && value.length < minLength) {
|
|
445
463
|
return "Minimum ".concat(minLength, " characters required");
|
|
446
464
|
}
|
|
@@ -449,7 +467,7 @@ var Form = function (props) {
|
|
|
449
467
|
}
|
|
450
468
|
}
|
|
451
469
|
// Pattern validation if provided - only for strings
|
|
452
|
-
if (((
|
|
470
|
+
if (((_g = field.inputProps) === null || _g === void 0 ? void 0 : _g.pattern) && typeof value === 'string') {
|
|
453
471
|
try {
|
|
454
472
|
var regex = new RegExp(field.inputProps.pattern);
|
|
455
473
|
if (!regex.test(value)) {
|
package/ui/sidebar/SideBar.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ interface SideBarProps {
|
|
|
26
26
|
children?: ReactNode;
|
|
27
27
|
onClose?: () => void;
|
|
28
28
|
isAccordion?: boolean;
|
|
29
|
+
togglePrefix?: ReactNode;
|
|
29
30
|
}
|
|
30
|
-
export default function SideBar({ funcss, position, open, header, content, footer, top, sidebarWidth, iconCSS, sidebarCss, activeCss, bodyCss, popIcon, dividers, accordionItemCss, links, children, onClose, isAccordion, }: SideBarProps): React.JSX.Element;
|
|
31
|
+
export default function SideBar({ funcss, position, open, header, content, footer, top, sidebarWidth, iconCSS, sidebarCss, activeCss, bodyCss, popIcon, dividers, accordionItemCss, links, children, onClose, togglePrefix, isAccordion, }: SideBarProps): React.JSX.Element;
|
|
31
32
|
export {};
|