@14ch/svelte-ui 0.0.31 → 0.0.32
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/assets/styles/variables.scss +0 -1
- package/dist/components/Nav.svelte +24 -8
- package/dist/components/Nav.svelte.d.ts +10 -2
- package/dist/components/NavItem.svelte +21 -7
- package/dist/components/NavItem.svelte.d.ts +8 -2
- package/dist/components/Tab.svelte +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -398,7 +398,6 @@
|
|
|
398
398
|
/* Nav: sub-menu */
|
|
399
399
|
--svelte-ui-nav-sub-popup-min-width: 160px;
|
|
400
400
|
--svelte-ui-nav-sub-popup-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
401
|
-
--svelte-ui-nav-sub-bar-min-height: 48px;
|
|
402
401
|
--svelte-ui-nav-item-child-indent: 32px;
|
|
403
402
|
--svelte-ui-nav-bottom-sheet-overlay-bg: rgba(0, 0, 0, 0.4);
|
|
404
403
|
--svelte-ui-nav-bottom-sheet-border-radius: 16px 16px 0 0;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<script lang="ts">
|
|
4
4
|
import NavItem from './NavItem.svelte';
|
|
5
|
-
import type {
|
|
5
|
+
import type { NavItemSelectedVariant } from './NavItem.svelte';
|
|
6
6
|
import type { MenuItem } from '../types/menuItem';
|
|
7
7
|
import type { NavVariant, ChildrenVariant } from '../types/propOptions';
|
|
8
8
|
import { subscribeUrlChange } from '../utils/urlChange';
|
|
@@ -37,12 +37,20 @@
|
|
|
37
37
|
|
|
38
38
|
// スタイル/レイアウト
|
|
39
39
|
/** Visual style for the selected item. */
|
|
40
|
-
|
|
40
|
+
selectedVariant?: NavItemSelectedVariant;
|
|
41
41
|
gap?: number | string;
|
|
42
42
|
/** How child items are displayed. Defaults to `accordion` (vertical), `bar` (horizontal), `bottom-sheet` (mobile). */
|
|
43
43
|
childrenVariant?: ChildrenVariant;
|
|
44
44
|
/** Show chevron icon on parent items. @default true */
|
|
45
45
|
chevron?: boolean;
|
|
46
|
+
/** Inline style applied to the nav container element. */
|
|
47
|
+
customContainerStyle?: string;
|
|
48
|
+
/** Inline style applied to each nav item element. */
|
|
49
|
+
customItemStyle?: string;
|
|
50
|
+
/** Inline style applied to each child nav item element. */
|
|
51
|
+
customChildrenItemStyle?: string;
|
|
52
|
+
/** Inline style applied to the children container (accordion/expanded list, bar row). */
|
|
53
|
+
customChildrenContainerStyle?: string;
|
|
46
54
|
|
|
47
55
|
// ARIA/アクセシビリティ
|
|
48
56
|
ariaLabel?: string;
|
|
@@ -68,10 +76,14 @@
|
|
|
68
76
|
iconVariant = 'outlined',
|
|
69
77
|
|
|
70
78
|
// スタイル/レイアウト
|
|
71
|
-
|
|
79
|
+
selectedVariant,
|
|
72
80
|
gap,
|
|
73
81
|
childrenVariant = variant === 'mobile' ? 'bottom-sheet' : variant === 'vertical' ? 'accordion' : 'bar',
|
|
74
82
|
chevron,
|
|
83
|
+
customContainerStyle,
|
|
84
|
+
customItemStyle,
|
|
85
|
+
customChildrenItemStyle,
|
|
86
|
+
customChildrenContainerStyle,
|
|
75
87
|
|
|
76
88
|
// ARIA/アクセシビリティ
|
|
77
89
|
ariaLabel,
|
|
@@ -253,6 +265,7 @@
|
|
|
253
265
|
aria-label={ariaLabelledby ? undefined : ariaLabel}
|
|
254
266
|
aria-labelledby={ariaLabelledby}
|
|
255
267
|
style:--internal-nav-gap={gap != null ? (typeof gap === 'number' ? `${gap}px` : gap) : undefined}
|
|
268
|
+
style={customContainerStyle}
|
|
256
269
|
{id}
|
|
257
270
|
data-testid="nav"
|
|
258
271
|
bind:this={navEl}
|
|
@@ -270,9 +283,12 @@
|
|
|
270
283
|
{iconGrade}
|
|
271
284
|
{iconOpticalSize}
|
|
272
285
|
{iconVariant}
|
|
273
|
-
{
|
|
286
|
+
{selectedVariant}
|
|
274
287
|
{childrenVariant}
|
|
275
288
|
{chevron}
|
|
289
|
+
customStyle={customItemStyle}
|
|
290
|
+
customChildrenStyle={customChildrenItemStyle}
|
|
291
|
+
{customChildrenContainerStyle}
|
|
276
292
|
{resolvedCurrentPath}
|
|
277
293
|
{customPathMatcher}
|
|
278
294
|
isChildrenVisible={(childrenVariant === 'bar' || childrenVariant === 'accordion') && expandedParent === item}
|
|
@@ -285,7 +301,7 @@
|
|
|
285
301
|
|
|
286
302
|
<!-- bar モード: 選択中の親の子アイテムを横バーとして表示 -->
|
|
287
303
|
{#if showSubBar && expandedParent?.children}
|
|
288
|
-
<div class="
|
|
304
|
+
<div class="nav__children-bar" role="menu" tabindex="-1" style={customChildrenContainerStyle} onkeydown={handleSubBarKeyDown} bind:this={subBarEl}>
|
|
289
305
|
{#each expandedParent.children as child}
|
|
290
306
|
<NavItem
|
|
291
307
|
item={child}
|
|
@@ -296,7 +312,8 @@
|
|
|
296
312
|
{iconGrade}
|
|
297
313
|
{iconOpticalSize}
|
|
298
314
|
{iconVariant}
|
|
299
|
-
{
|
|
315
|
+
{selectedVariant}
|
|
316
|
+
customStyle={customChildrenItemStyle}
|
|
300
317
|
isChild={true}
|
|
301
318
|
{resolvedCurrentPath}
|
|
302
319
|
{customPathMatcher}
|
|
@@ -340,10 +357,9 @@
|
|
|
340
357
|
display: none;
|
|
341
358
|
}
|
|
342
359
|
|
|
343
|
-
.
|
|
360
|
+
.nav__children-bar {
|
|
344
361
|
display: flex;
|
|
345
362
|
flex-direction: row;
|
|
346
363
|
gap: var(--internal-nav-gap, var(--svelte-ui-nav-horizontal-item-gap));
|
|
347
364
|
align-items: center;
|
|
348
|
-
min-height: var(--svelte-ui-nav-sub-bar-min-height);
|
|
349
365
|
}</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NavItemSelectedVariant } from './NavItem.svelte';
|
|
2
2
|
import type { MenuItem } from '../types/menuItem';
|
|
3
3
|
import type { NavVariant, ChildrenVariant } from '../types/propOptions';
|
|
4
4
|
import type { IconVariant, IconWeight, IconGrade, IconOpticalSize } from '../types/icon';
|
|
@@ -20,12 +20,20 @@ export type NavProps = {
|
|
|
20
20
|
iconOpticalSize?: IconOpticalSize;
|
|
21
21
|
iconVariant?: IconVariant;
|
|
22
22
|
/** Visual style for the selected item. */
|
|
23
|
-
|
|
23
|
+
selectedVariant?: NavItemSelectedVariant;
|
|
24
24
|
gap?: number | string;
|
|
25
25
|
/** How child items are displayed. Defaults to `accordion` (vertical), `bar` (horizontal), `bottom-sheet` (mobile). */
|
|
26
26
|
childrenVariant?: ChildrenVariant;
|
|
27
27
|
/** Show chevron icon on parent items. @default true */
|
|
28
28
|
chevron?: boolean;
|
|
29
|
+
/** Inline style applied to the nav container element. */
|
|
30
|
+
customContainerStyle?: string;
|
|
31
|
+
/** Inline style applied to each nav item element. */
|
|
32
|
+
customItemStyle?: string;
|
|
33
|
+
/** Inline style applied to each child nav item element. */
|
|
34
|
+
customChildrenItemStyle?: string;
|
|
35
|
+
/** Inline style applied to the children container (accordion/expanded list, bar row). */
|
|
36
|
+
customChildrenContainerStyle?: string;
|
|
29
37
|
ariaLabel?: string;
|
|
30
38
|
ariaLabelledby?: string;
|
|
31
39
|
};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// =========================================================================
|
|
16
16
|
// Props, States & Constants
|
|
17
17
|
// =========================================================================
|
|
18
|
-
export type
|
|
18
|
+
export type NavItemSelectedVariant = 'color' | 'filled' | 'tonal' | 'underline';
|
|
19
19
|
|
|
20
20
|
export type NavItemProps = {
|
|
21
21
|
// 基本プロパティ
|
|
@@ -37,9 +37,15 @@
|
|
|
37
37
|
// スタイル/レイアウト
|
|
38
38
|
/** Show chevron icon on parent items. @default true */
|
|
39
39
|
chevron?: boolean;
|
|
40
|
-
|
|
40
|
+
selectedVariant?: NavItemSelectedVariant;
|
|
41
41
|
/** How child items are displayed. Defaults to `accordion` (vertical), `bar` (horizontal), `bottom-sheet` (mobile). */
|
|
42
42
|
childrenVariant?: ChildrenVariant;
|
|
43
|
+
/** Inline style applied to this nav item element. */
|
|
44
|
+
customStyle?: string;
|
|
45
|
+
/** Inline style applied to each child nav item element. */
|
|
46
|
+
customChildrenStyle?: string;
|
|
47
|
+
/** Inline style applied to the children container (accordion/expanded list). */
|
|
48
|
+
customChildrenContainerStyle?: string;
|
|
43
49
|
|
|
44
50
|
// 状態/動作
|
|
45
51
|
isSelected?: boolean;
|
|
@@ -73,8 +79,11 @@
|
|
|
73
79
|
|
|
74
80
|
// スタイル/レイアウト
|
|
75
81
|
chevron = true,
|
|
76
|
-
|
|
82
|
+
selectedVariant,
|
|
77
83
|
childrenVariant = variant === 'mobile' ? 'bottom-sheet' : variant === 'vertical' ? 'accordion' : 'bar',
|
|
84
|
+
customStyle,
|
|
85
|
+
customChildrenStyle,
|
|
86
|
+
customChildrenContainerStyle,
|
|
78
87
|
|
|
79
88
|
// 状態/動作
|
|
80
89
|
isSelected = false,
|
|
@@ -99,7 +108,7 @@
|
|
|
99
108
|
const hrefWithPrefix = $derived(item.href ? withPrefix(item.href) : undefined);
|
|
100
109
|
|
|
101
110
|
const resolvedSelectedStyle = $derived(
|
|
102
|
-
|
|
111
|
+
selectedVariant ?? (variant === 'vertical' || variant === 'horizontal' ? 'tonal' : 'color')
|
|
103
112
|
);
|
|
104
113
|
|
|
105
114
|
// isChild=true のアイテムでは children を展開しない(無限再帰防止)
|
|
@@ -232,6 +241,7 @@
|
|
|
232
241
|
class:nav-item--style-filled={isSelected && resolvedSelectedStyle === 'filled'}
|
|
233
242
|
class:nav-item--style-tonal={isSelected && resolvedSelectedStyle === 'tonal'}
|
|
234
243
|
class:nav-item--style-underline={resolvedSelectedStyle === 'underline'}
|
|
244
|
+
style={customStyle}
|
|
235
245
|
aria-disabled="true"
|
|
236
246
|
tabindex="-1"
|
|
237
247
|
data-nav-item={!isChild ? '' : undefined}
|
|
@@ -270,6 +280,7 @@
|
|
|
270
280
|
class:nav-item--style-filled={isSelected && resolvedSelectedStyle === 'filled'}
|
|
271
281
|
class:nav-item--style-tonal={isSelected && resolvedSelectedStyle === 'tonal'}
|
|
272
282
|
class:nav-item--style-underline={resolvedSelectedStyle === 'underline'}
|
|
283
|
+
style={customStyle}
|
|
273
284
|
aria-current={isSelected ? 'page' : undefined}
|
|
274
285
|
aria-expanded={childrenVariant === 'expanded' || isChildrenVisible}
|
|
275
286
|
tabindex={0}
|
|
@@ -326,7 +337,7 @@
|
|
|
326
337
|
|
|
327
338
|
<!-- accordion / expanded サブメニュー -->
|
|
328
339
|
{#if childrenVariant === 'expanded' || (childrenVariant === 'accordion' && isChildrenVisible)}
|
|
329
|
-
<div class="nav-item__children" role="presentation" transition:slide={{ duration: 200 }}>
|
|
340
|
+
<div class="nav-item__children" role="presentation" style={customChildrenContainerStyle} transition:slide={{ duration: 200 }}>
|
|
330
341
|
{#each item.children! as child}
|
|
331
342
|
<NavItem
|
|
332
343
|
item={child}
|
|
@@ -337,7 +348,8 @@
|
|
|
337
348
|
{iconGrade}
|
|
338
349
|
{iconOpticalSize}
|
|
339
350
|
{iconVariant}
|
|
340
|
-
{
|
|
351
|
+
{selectedVariant}
|
|
352
|
+
customStyle={customChildrenStyle}
|
|
341
353
|
isChild={true}
|
|
342
354
|
{resolvedCurrentPath}
|
|
343
355
|
{customPathMatcher}
|
|
@@ -374,7 +386,8 @@
|
|
|
374
386
|
{iconGrade}
|
|
375
387
|
{iconOpticalSize}
|
|
376
388
|
{iconVariant}
|
|
377
|
-
{
|
|
389
|
+
{selectedVariant}
|
|
390
|
+
customStyle={customChildrenStyle}
|
|
378
391
|
isChild={true}
|
|
379
392
|
{resolvedCurrentPath}
|
|
380
393
|
{customPathMatcher}
|
|
@@ -399,6 +412,7 @@
|
|
|
399
412
|
class:nav-item--style-filled={isSelected && resolvedSelectedStyle === 'filled'}
|
|
400
413
|
class:nav-item--style-tonal={isSelected && resolvedSelectedStyle === 'tonal'}
|
|
401
414
|
class:nav-item--style-underline={resolvedSelectedStyle === 'underline'}
|
|
415
|
+
style={customStyle}
|
|
402
416
|
aria-current={isSelected ? 'page' : undefined}
|
|
403
417
|
tabindex={0}
|
|
404
418
|
data-nav-item={!isChild ? '' : undefined}
|
|
@@ -2,7 +2,7 @@ import NavItem from './NavItem.svelte';
|
|
|
2
2
|
import type { MenuItem } from '../types/menuItem';
|
|
3
3
|
import type { NavVariant, ChildrenVariant } from '../types/propOptions';
|
|
4
4
|
import type { IconVariant, IconWeight, IconGrade, IconOpticalSize } from '../types/icon';
|
|
5
|
-
export type
|
|
5
|
+
export type NavItemSelectedVariant = 'color' | 'filled' | 'tonal' | 'underline';
|
|
6
6
|
export type NavItemProps = {
|
|
7
7
|
item: MenuItem;
|
|
8
8
|
variant?: NavVariant;
|
|
@@ -18,9 +18,15 @@ export type NavItemProps = {
|
|
|
18
18
|
iconVariant?: IconVariant;
|
|
19
19
|
/** Show chevron icon on parent items. @default true */
|
|
20
20
|
chevron?: boolean;
|
|
21
|
-
|
|
21
|
+
selectedVariant?: NavItemSelectedVariant;
|
|
22
22
|
/** How child items are displayed. Defaults to `accordion` (vertical), `bar` (horizontal), `bottom-sheet` (mobile). */
|
|
23
23
|
childrenVariant?: ChildrenVariant;
|
|
24
|
+
/** Inline style applied to this nav item element. */
|
|
25
|
+
customStyle?: string;
|
|
26
|
+
/** Inline style applied to each child nav item element. */
|
|
27
|
+
customChildrenStyle?: string;
|
|
28
|
+
/** Inline style applied to the children container (accordion/expanded list). */
|
|
29
|
+
customChildrenContainerStyle?: string;
|
|
24
30
|
isSelected?: boolean;
|
|
25
31
|
isDisabled?: boolean;
|
|
26
32
|
/** When true, this item does not render its own children (prevents infinite recursion). */
|
package/dist/index.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export type { SkeletonHeadingProps } from './components/skeleton/SkeletonHeading
|
|
|
75
75
|
export type { SkeletonMediaProps } from './components/skeleton/SkeletonMedia.svelte';
|
|
76
76
|
export type { SwitchProps } from './components/Switch.svelte';
|
|
77
77
|
export type { NavProps } from './components/Nav.svelte';
|
|
78
|
-
export type { NavItemProps,
|
|
78
|
+
export type { NavItemProps, NavItemSelectedVariant } from './components/NavItem.svelte';
|
|
79
79
|
export type { TabProps } from './components/Tab.svelte';
|
|
80
80
|
export type { TextareaProps } from './components/Textarea.svelte';
|
|
81
81
|
export type { PopupPosition, SnackbarPosition, FabPosition, ButtonVariant, ButtonSize, SnackbarType, SnackbarVariant, BadgeVariant, DatepickerMode, FocusStyle, NavVariant, ChildrenVariant } from './types/propOptions';
|