vanilla-jui 1.7.22 → 1.7.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/components/swiper.ts +16 -4
- package/src/index.ts +1 -0
- package/src/utilities/string.ts +3 -0
- package/src/utilities/validator.ts +4 -3
package/package.json
CHANGED
package/src/components/swiper.ts
CHANGED
|
@@ -259,6 +259,18 @@ function cloneData(data: SwiperDataItem[] | undefined): SwiperDataItem[] {
|
|
|
259
259
|
return Array.isArray(data) ? data.map((item) => ({ ...item })) : [];
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
function cloneRenderableContent<TContext>(
|
|
263
|
+
content: RenderableContent<TContext>
|
|
264
|
+
): RenderableContent<TContext> {
|
|
265
|
+
if (typeof Node !== 'undefined' && content instanceof Node) {
|
|
266
|
+
return content.cloneNode(true);
|
|
267
|
+
}
|
|
268
|
+
if (Array.isArray(content)) {
|
|
269
|
+
return content.map((item) => cloneRenderableContent(item));
|
|
270
|
+
}
|
|
271
|
+
return content;
|
|
272
|
+
}
|
|
273
|
+
|
|
262
274
|
function cloneDataSource(source: SwiperDataSource): SwiperDataSource {
|
|
263
275
|
return Array.isArray(source) ? cloneData(source) : source;
|
|
264
276
|
}
|
|
@@ -774,7 +786,7 @@ export function createSwiper(input: SwiperProps = {}): Swiper {
|
|
|
774
786
|
const realIndex = (): number =>
|
|
775
787
|
toRealIndexFromTrackPosition(trackIndexAccessor());
|
|
776
788
|
const slideContent = () => {
|
|
777
|
-
const { item } = itemAccessor();
|
|
789
|
+
const { item, clone } = itemAccessor();
|
|
778
790
|
if (item.children != null) {
|
|
779
791
|
const context = {
|
|
780
792
|
swiper,
|
|
@@ -783,11 +795,11 @@ export function createSwiper(input: SwiperProps = {}): Swiper {
|
|
|
783
795
|
return realIndex();
|
|
784
796
|
},
|
|
785
797
|
} as SwiperSlideContext;
|
|
786
|
-
|
|
798
|
+
const content =
|
|
787
799
|
typeof item.children === 'function'
|
|
788
800
|
? item.children(context)
|
|
789
|
-
: item.children
|
|
790
|
-
);
|
|
801
|
+
: item.children;
|
|
802
|
+
return asRenderable(clone ? cloneRenderableContent(content) : content);
|
|
791
803
|
}
|
|
792
804
|
return [
|
|
793
805
|
item.image
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './utilities/http.ts';
|
|
|
11
11
|
// export * from './utilities/locale.ts';
|
|
12
12
|
export * from './utilities/object.ts';
|
|
13
13
|
export * from './utilities/timer.ts';
|
|
14
|
+
export * from './utilities/string.ts';
|
|
14
15
|
export * from './utilities/types.ts';
|
|
15
16
|
export * from './utilities/merge.ts';
|
|
16
17
|
export * from './utilities/config.ts';
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '../utilities/dom.ts';
|
|
9
9
|
import { createEventManager } from '../utilities/events.ts';
|
|
10
10
|
import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
|
|
11
|
+
import { removeSpaces } from '../utilities/string.ts';
|
|
11
12
|
import { validateParam } from '../utilities/types.ts';
|
|
12
13
|
|
|
13
14
|
type ValidatorElement =
|
|
@@ -181,7 +182,7 @@ function validateMinLength(
|
|
|
181
182
|
minLength: unknown
|
|
182
183
|
): boolean {
|
|
183
184
|
if (typeof minLength !== 'number') return true;
|
|
184
|
-
return element.value.length >= minLength;
|
|
185
|
+
return removeSpaces(element.value).length >= minLength;
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
function validateMaxLength(
|
|
@@ -189,12 +190,12 @@ function validateMaxLength(
|
|
|
189
190
|
maxLength: unknown
|
|
190
191
|
): boolean {
|
|
191
192
|
if (typeof maxLength !== 'number') return true;
|
|
192
|
-
return element.value.length <= maxLength;
|
|
193
|
+
return removeSpaces(element.value).length <= maxLength;
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
function validateEmail(element: ValidatorElement): boolean {
|
|
196
197
|
const emailPattern = /^([\w-.]+@([\w-]+\.)+[\w-]{2,4})?$/;
|
|
197
|
-
return emailPattern.test(element.value);
|
|
198
|
+
return emailPattern.test(removeSpaces(element.value));
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
function validateEqualTo(
|