vanilla-jui 1.5.4 → 1.5.6

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.
@@ -14,7 +14,12 @@ import {
14
14
  import { icon } from '../primitives/icons.ts';
15
15
  import { createLoading } from '../primitives/loading.ts';
16
16
  import { joinClasses } from '../utilities/class-name.ts';
17
- import { all, q, type RenderableContent } from '../utilities/dom.ts';
17
+ import {
18
+ all,
19
+ asRenderable,
20
+ q,
21
+ type RenderableContent,
22
+ } from '../utilities/dom.ts';
18
23
  import { createEventManager } from '../utilities/events.ts';
19
24
  import { randomId } from '../utilities/id.ts';
20
25
  import { createScheduledTask } from '../core/scheduler.ts';
@@ -706,51 +711,52 @@ export function createSwiper(input: SwiperProps = {}): Swiper {
706
711
  };
707
712
 
708
713
  const slideView = (itemAccessor: () => TrackItem): HTMLElement => {
709
- const initial = itemAccessor();
710
- const tag = initial.item.url ? 'a' : 'div';
711
- return jsx(tag, {
714
+ const slideContent = () => {
715
+ const { item, index } = itemAccessor();
716
+ const context = { swiper, item, index };
717
+ if (item.children != null) {
718
+ return asRenderable(
719
+ typeof item.children === 'function'
720
+ ? item.children(context)
721
+ : item.children
722
+ );
723
+ }
724
+ return [
725
+ item.image
726
+ ? jsx('img', {
727
+ className: props.className.image,
728
+ alt: item.title || '',
729
+ loading: 'lazy',
730
+ ...(props.lazyload
731
+ ? { 'data-lazy': item.image }
732
+ : { src: item.image }),
733
+ })
734
+ : null,
735
+ item.title
736
+ ? jsx('span', {
737
+ className: props.className.title,
738
+ children: item.title,
739
+ })
740
+ : null,
741
+ ];
742
+ };
743
+ const commonProps = {
712
744
  className: props.className.slide,
713
- href: () => itemAccessor().item.url || undefined,
714
- target: () =>
715
- itemAccessor().item.url
716
- ? itemAccessor().item.blank
717
- ? '_blank'
718
- : '_self'
719
- : undefined,
720
745
  'data-swiper-slide': () => String(itemAccessor().index),
721
746
  'data-swiper-index': () =>
722
747
  itemAccessor().clone ? null : String(itemAccessor().index),
723
748
  'data-clone': () => itemAccessor().clone,
724
749
  role: 'group',
725
750
  'aria-label': () => `Slide ${itemAccessor().index + 1}`,
726
- children: () => {
727
- const { item, index } = itemAccessor();
728
- const context = { swiper, item, index };
729
- if (item.children != null) {
730
- return typeof item.children === 'function'
731
- ? item.children(context)
732
- : item.children;
733
- }
734
- return [
735
- item.image
736
- ? jsx('img', {
737
- className: props.className.image,
738
- alt: item.title || '',
739
- loading: 'lazy',
740
- ...(props.lazyload
741
- ? { 'data-lazy': item.image }
742
- : { src: item.image }),
743
- })
744
- : null,
745
- item.title
746
- ? jsx('span', {
747
- className: props.className.title,
748
- children: item.title,
749
- })
750
- : null,
751
- ];
752
- },
753
- }) as HTMLElement;
751
+ children: slideContent,
752
+ };
753
+ return itemAccessor().item.url
754
+ ? jsx('a', {
755
+ ...commonProps,
756
+ href: () => itemAccessor().item.url || '',
757
+ target: () => (itemAccessor().item.blank ? '_blank' : '_self'),
758
+ })
759
+ : jsx('div', commonProps);
754
760
  };
755
761
 
756
762
  swiper = defineComponent<
@@ -15,7 +15,7 @@ import {
15
15
  } from '../core/component.ts';
16
16
  import { createLoading } from '../primitives/loading.ts';
17
17
  import { joinClasses } from '../utilities/class-name.ts';
18
- import { type RenderableContent } from '../utilities/dom.ts';
18
+ import { asRenderable, type RenderableContent } from '../utilities/dom.ts';
19
19
  import { createEventManager } from '../utilities/events.ts';
20
20
  import { randomId } from '../utilities/id.ts';
21
21
  import { createElementRef, createKeyedElementRefs } from '../utilities/refs.ts';
@@ -515,7 +515,7 @@ export function createTabs(input: TabsProps = {}): Tabs {
515
515
  'aria-busy': () => String(loading()),
516
516
  hidden: () => !isActive(name),
517
517
  ref: panels.bind(name),
518
- children: panelContent,
518
+ children: () => asRenderable(panelContent()),
519
519
  }) as HTMLElement;
520
520
  };
521
521
 
@@ -528,7 +528,7 @@ export function createTabs(input: TabsProps = {}): Tabs {
528
528
  'aria-selected': () => (isActive(name) ? 'true' : 'false'),
529
529
  'aria-disabled': () => (isDisabled(name) ? 'true' : 'false'),
530
530
  ref: tabs.bind(name),
531
- children: item().title,
531
+ children: () => asRenderable(item().title),
532
532
  }) as HTMLElement;
533
533
  };
534
534
 
@@ -296,6 +296,10 @@
296
296
  /* ============================================
297
297
  Code - 代码
298
298
  ============================================ */
299
+ code {
300
+ box-decoration-break: clone;
301
+ }
302
+
299
303
  .j-content code:not([class*='language-']) {
300
304
  font-family:
301
305
  'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
@@ -331,7 +335,6 @@
331
335
  background: none;
332
336
  color: inherit;
333
337
  font-size: inherit;
334
- white-space: pre;
335
338
  }
336
339
 
337
340
  .j-content pre.j-code-editor {
@@ -345,7 +348,6 @@
345
348
  .j-content pre.j-code-editor.hljs {
346
349
  color: var(--ui-fg);
347
350
  background: var(--content-bg-subtle);
348
- white-space: break-spaces;
349
351
  }
350
352
 
351
353
  html.j-radius-round .j-content pre.j-code-editor {
@@ -389,8 +391,11 @@
389
391
 
390
392
  .j-content pre code[class*='language-'] {
391
393
  display: block;
392
- overflow-x: auto;
393
394
  padding: 1.25em 1.5em;
395
+ overflow-x: auto;
396
+ scrollbar-width: thin;
397
+ scrollbar-color: var(--ui-border) transparent;
398
+ white-space: pre-wrap;
394
399
  }
395
400
 
396
401
  .j-content pre.j-code-editor .code-header + code[class*='language-'] {
@@ -43,5 +43,7 @@ export default {
43
43
  Confirm: '确认',
44
44
  Upgrade: '升级',
45
45
  wn: '您的浏览器版本过低,存在安全风险。请升级浏览器后再访问本站。',
46
+ Submit: '提交',
47
+ Reset: '重置',
46
48
  },
47
49
  };
@@ -1,6 +1,7 @@
1
1
  import { createRoot, createSignal, insert, jsx } from 'vanilla-signal';
2
2
 
3
3
  import {
4
+ asRenderable,
4
5
  type DOMReference,
5
6
  type RenderableContent,
6
7
  resolveElement,
@@ -245,7 +246,7 @@ export function createDrop(
245
246
  'aria-live': () =>
246
247
  typeof props.content === 'function' ? 'polite' : null,
247
248
  'aria-busy': () => String(loading()),
248
- children: renderContent,
249
+ children: () => asRenderable(renderContent()),
249
250
  });
250
251
  return {
251
252
  root: jsx('div', {
@@ -1,6 +1,6 @@
1
- import { jsx } from 'vanilla-signal';
1
+ import { type ElementProps, jsx } from 'vanilla-signal';
2
2
 
3
- import { type RenderableContent } from '../utilities/dom.ts';
3
+ import { asRenderable, type RenderableContent } from '../utilities/dom.ts';
4
4
  import { type ResolveSchema, resolveProps } from '../utilities/types.ts';
5
5
 
6
6
  export interface PopupProps extends Record<string, unknown> {
@@ -45,10 +45,10 @@ function normalizeProps(input: PopupProps): ResolvedPopupProps {
45
45
  export function createPopup(props: PopupProps = {}): HTMLElement {
46
46
  const { className, position, component, labelledby, content } =
47
47
  normalizeProps(props);
48
- const attrs: Record<string, unknown> = {
48
+ const attrs: ElementProps<HTMLDivElement> = {
49
49
  className: `${className} is-${position}`,
50
50
  role: 'dialog',
51
- children: content,
51
+ children: asRenderable(content),
52
52
  };
53
53
 
54
54
  if (component) {
@@ -1,3 +1,4 @@
1
+ import { type Renderable } from 'vanilla-signal';
1
2
  import {
2
3
  isDomElementValue,
3
4
  isDomNodeValue,
@@ -32,6 +33,12 @@ export type RenderableContent<TContext = unknown> =
32
33
  | readonly RenderableContent<TContext>[]
33
34
  | ((context: TContext) => RenderableContent<TContext>);
34
35
 
36
+ export function asRenderable<TContext>(
37
+ value: RenderableContent<TContext>
38
+ ): Renderable {
39
+ return value as Renderable;
40
+ }
41
+
35
42
  export interface LazyRenderOptions {
36
43
  threshold?: number | number[];
37
44
  rootMargin?: string;