noph-ui 0.48.1 → 0.50.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.
Files changed (103) hide show
  1. package/dist/app-bar/AppBar.svelte +4 -4
  2. package/dist/autocomplete/AutoComplete.svelte +6 -8
  3. package/dist/autocomplete/types.d.ts +3 -6
  4. package/dist/badge/Badge.svelte +1 -1
  5. package/dist/button/Button.svelte +3 -3
  6. package/dist/button/ButtonGroup.svelte +2 -2
  7. package/dist/button/IconButton.svelte +3 -3
  8. package/dist/button/SegmentedButton.svelte +6 -5
  9. package/dist/button/SplitButton.svelte +1 -1
  10. package/dist/button/types.d.ts +13 -11
  11. package/dist/card/Card.svelte +16 -7
  12. package/dist/card/types.d.ts +4 -4
  13. package/dist/carousel/Carousel.svelte +11 -11
  14. package/dist/carousel/CarouselItem.svelte +24 -15
  15. package/dist/carousel/carouselMorph.js +1 -1
  16. package/dist/carousel/types.d.ts +5 -4
  17. package/dist/checkbox/Checkbox.svelte +1 -1
  18. package/dist/checkbox/types.d.ts +2 -3
  19. package/dist/chip/AssistChip.svelte +1 -1
  20. package/dist/chip/ChipSet.svelte +1 -1
  21. package/dist/chip/FilterChip.svelte +1 -1
  22. package/dist/chip/InputChip.svelte +1 -1
  23. package/dist/chip/SuggestionChip.svelte +1 -1
  24. package/dist/chip/types.d.ts +5 -8
  25. package/dist/date-picker/Calendar.svelte +8 -7
  26. package/dist/date-picker/DatePickerDialog.svelte +1 -1
  27. package/dist/date-picker/DateRangePicker.svelte +1 -1
  28. package/dist/date-picker/DockedDatePicker.svelte +1 -1
  29. package/dist/date-picker/DockedDateTimePicker.svelte +1 -1
  30. package/dist/date-picker/SelectionList.svelte +2 -2
  31. package/dist/date-picker/SelectionList.svelte.d.ts +1 -1
  32. package/dist/date-picker/TimeColumn.svelte +2 -2
  33. package/dist/date-picker/TimeColumn.svelte.d.ts +1 -1
  34. package/dist/date-picker/YearGrid.svelte +1 -1
  35. package/dist/date-picker/internalTypes.d.ts +7 -0
  36. package/dist/date-picker/internalTypes.js +1 -0
  37. package/dist/date-picker/types.d.ts +10 -44
  38. package/dist/dialog/Dialog.svelte +1 -1
  39. package/dist/divider/Divider.svelte +1 -1
  40. package/dist/fab/ExtendedFab.svelte +4 -4
  41. package/dist/fab/Fab.svelte +4 -4
  42. package/dist/fab/FabMenu.svelte +2 -2
  43. package/dist/icons/Icon.svelte +1 -1
  44. package/dist/internal/elementTag.d.ts +26 -0
  45. package/dist/internal/elementTag.js +23 -0
  46. package/dist/internal/fieldTypes.d.ts +24 -0
  47. package/dist/internal/fieldTypes.js +1 -0
  48. package/dist/list/Item.svelte +19 -7
  49. package/dist/list/List.svelte +1 -1
  50. package/dist/list/ListItem.svelte +1 -1
  51. package/dist/list/types.d.ts +8 -7
  52. package/dist/loading-indicator/LoadingIndicator.svelte +2 -2
  53. package/dist/menu/Menu.svelte +1 -1
  54. package/dist/menu/MenuItem.svelte +8 -4
  55. package/dist/navigation-bar/NavigationBar.svelte +1 -1
  56. package/dist/navigation-bar/NavigationBarItem.svelte +3 -3
  57. package/dist/navigation-drawer/NavigationDrawer.svelte +9 -7
  58. package/dist/navigation-drawer/NavigationDrawerItem.svelte +2 -2
  59. package/dist/navigation-drawer/types.d.ts +6 -2
  60. package/dist/navigation-rail/NavigationRail.svelte +1 -1
  61. package/dist/navigation-rail/NavigationRailItem.svelte +2 -2
  62. package/dist/progress/CircularProgress.svelte +1 -1
  63. package/dist/progress/LinearProgress.svelte +1 -1
  64. package/dist/radio/Radio.svelte +1 -1
  65. package/dist/radio/types.d.ts +2 -3
  66. package/dist/ripple/Ripple.svelte +1 -1
  67. package/dist/search/Search.svelte +2 -2
  68. package/dist/select/NativeSelect.svelte +2 -2
  69. package/dist/select/Option.svelte +1 -1
  70. package/dist/select/Select.svelte +7 -4
  71. package/dist/select/types.d.ts +4 -8
  72. package/dist/shared/types.d.ts +9 -0
  73. package/dist/shared/types.js +1 -0
  74. package/dist/sheet/Sheet.svelte +1 -1
  75. package/dist/slider/Slider.svelte +1 -1
  76. package/dist/slider/types.d.ts +2 -4
  77. package/dist/snackbar/Snackbar.svelte +1 -1
  78. package/dist/switch/Switch.svelte +1 -1
  79. package/dist/switch/types.d.ts +2 -4
  80. package/dist/tabs/Tab.svelte +1 -1
  81. package/dist/tabs/Tabs.svelte +2 -2
  82. package/dist/text-field/TextField.svelte +1 -1
  83. package/dist/text-field/types.d.ts +1 -21
  84. package/dist/time-picker/ClockDial.svelte +3 -3
  85. package/dist/time-picker/DockedTimePicker.svelte +1 -1
  86. package/dist/time-picker/PeriodSelector.svelte +2 -2
  87. package/dist/time-picker/PeriodSelector.svelte.d.ts +1 -1
  88. package/dist/time-picker/TimeInputs.svelte +1 -1
  89. package/dist/time-picker/TimeInputs.svelte.d.ts +1 -1
  90. package/dist/time-picker/TimePickerDialog.svelte +1 -1
  91. package/dist/time-picker/TimePickerPanel.svelte +1 -1
  92. package/dist/time-picker/TimePickerPanel.svelte.d.ts +1 -1
  93. package/dist/time-picker/TimeSelectors.svelte +2 -2
  94. package/dist/time-picker/TimeSelectors.svelte.d.ts +1 -1
  95. package/dist/time-picker/internalTypes.d.ts +76 -0
  96. package/dist/time-picker/internalTypes.js +1 -0
  97. package/dist/time-picker/types.d.ts +7 -95
  98. package/dist/toolbar/Toolbar.svelte +2 -2
  99. package/dist/tooltip/RichTooltip.svelte +1 -1
  100. package/dist/tooltip/Tooltip.svelte +1 -1
  101. package/dist/types.d.ts +1 -0
  102. package/dist/types.js +34 -33
  103. package/package.json +49 -49
@@ -21,7 +21,7 @@
21
21
  today as getToday,
22
22
  } from './dateUtils.js'
23
23
  import { afterTwoFrames } from '../animation.js'
24
- import type { CalendarProps } from './types.js'
24
+ import type { CalendarProps } from './types.ts'
25
25
 
26
26
  let {
27
27
  month,
@@ -212,13 +212,14 @@
212
212
  {#if !inMonth && !adjacentMonthDays}
213
213
  <td role="gridcell" class="np-calendar-cell"></td>
214
214
  {:else}
215
- {@const isSelected =
215
+ {let isSelected = $derived(
216
216
  isSameDay(date, selected) ||
217
- isSameDay(date, rangeStart) ||
218
- isSameDay(date, rangeEnd)}
219
- {@const isToday = isSameDay(date, todayValue)}
220
- {@const enabled = isEnabled(date)}
221
- {@const between = inRange(date)}
217
+ isSameDay(date, rangeStart) ||
218
+ isSameDay(date, rangeEnd),
219
+ )}
220
+ {let isToday = $derived(isSameDay(date, todayValue))}
221
+ {let enabled = $derived(isEnabled(date))}
222
+ {let between = $derived(inRange(date))}
222
223
  <td
223
224
  role="gridcell"
224
225
  aria-selected={isSelected}
@@ -32,7 +32,7 @@
32
32
  toISODate,
33
33
  today as getToday,
34
34
  } from './dateUtils.js'
35
- import type { DatePickerDialogProps, ISODate } from './types.js'
35
+ import type { DatePickerDialogProps, ISODate } from './types.ts'
36
36
 
37
37
  let {
38
38
  value = $bindable(),
@@ -22,7 +22,7 @@
22
22
  toISODate,
23
23
  today as getToday,
24
24
  } from './dateUtils.js'
25
- import type { DateRange, DateRangePickerProps } from './types.js'
25
+ import type { DateRange, DateRangePickerProps } from './types.ts'
26
26
 
27
27
  let {
28
28
  value = $bindable({}),
@@ -30,7 +30,7 @@
30
30
  toISODate,
31
31
  today as getToday,
32
32
  } from './dateUtils.js'
33
- import type { DockedDatePickerProps, ISODate } from './types.js'
33
+ import type { DockedDatePickerProps, ISODate } from './types.ts'
34
34
 
35
35
  let {
36
36
  value = $bindable(),
@@ -44,7 +44,7 @@
44
44
  uses12HourClock,
45
45
  withMinutes,
46
46
  } from './dateUtils.js'
47
- import type { DockedDateTimePickerProps, ISODate } from './types.js'
47
+ import type { DockedDateTimePickerProps, ISODate } from './types.ts'
48
48
 
49
49
  let {
50
50
  value = $bindable(),
@@ -3,7 +3,7 @@
3
3
  import { arrowKeyNav } from '../keyboard-nav.js'
4
4
  import Ripple from '../ripple/Ripple.svelte'
5
5
  import { revealSelected, tabStop } from './optionList.js'
6
- import type { TimeColumnProps } from './types.js'
6
+ import type { TimeColumnProps } from './internalTypes.ts'
7
7
 
8
8
  let { options, value, onselect, ...attributes }: TimeColumnProps = $props()
9
9
 
@@ -21,7 +21,7 @@
21
21
  onkeydown={handleKeydown}
22
22
  >
23
23
  {#each options as option (option.value)}
24
- {@const selected = option.value === value}
24
+ {let selected = $derived(option.value === value)}
25
25
  <button
26
26
  {@attach selected && reveal}
27
27
  type="button"
@@ -1,4 +1,4 @@
1
- import type { TimeColumnProps } from './types.ts';
1
+ import type { TimeColumnProps } from './internalTypes.ts';
2
2
  declare const SelectionList: import("svelte").Component<TimeColumnProps, {}, "">;
3
3
  type SelectionList = ReturnType<typeof SelectionList>;
4
4
  export default SelectionList;
@@ -2,7 +2,7 @@
2
2
  import { arrowKeyNav } from '../keyboard-nav.js'
3
3
  import Ripple from '../ripple/Ripple.svelte'
4
4
  import { revealSelected, tabStop } from './optionList.js'
5
- import type { TimeColumnProps } from './types.js'
5
+ import type { TimeColumnProps } from './internalTypes.ts'
6
6
 
7
7
  let { options, value, onselect, ...attributes }: TimeColumnProps = $props()
8
8
 
@@ -20,7 +20,7 @@
20
20
  onkeydown={handleKeydown}
21
21
  >
22
22
  {#each options as option (option.value)}
23
- {@const selected = option.value === value}
23
+ {let selected = $derived(option.value === value)}
24
24
  <button
25
25
  {@attach selected && reveal}
26
26
  type="button"
@@ -1,4 +1,4 @@
1
- import type { TimeColumnProps } from './types.ts';
1
+ import type { TimeColumnProps } from './internalTypes.ts';
2
2
  declare const TimeColumn: import("svelte").Component<TimeColumnProps, {}, "">;
3
3
  type TimeColumn = ReturnType<typeof TimeColumn>;
4
4
  export default TimeColumn;
@@ -84,7 +84,7 @@
84
84
  onkeydown={handleKeydown}
85
85
  >
86
86
  {#each years as { year, disabled } (year)}
87
- {@const selected = year === value}
87
+ {let selected = $derived(year === value)}
88
88
  <button
89
89
  {@attach selected && scrollIntoGrid}
90
90
  type="button"
@@ -0,0 +1,7 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { TimeOption } from './types.ts';
3
+ export interface TimeColumnProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onselect'> {
4
+ options: TimeOption[];
5
+ value?: number;
6
+ onselect?: (value: number) => void;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,8 @@
1
+ import type { Issue } from '../shared/types.js';
1
2
  import type { Snippet } from 'svelte';
3
+ import type { DockedFieldProps } from '../internal/fieldTypes.js';
2
4
  import type { TextFieldElement } from '../text-field/types.js';
3
- import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
5
+ import type { HTMLAttributes } from 'svelte/elements';
4
6
  export type ISODate = string;
5
7
  export type ISODateTime = string;
6
8
  export interface DateRange {
@@ -27,26 +29,13 @@ interface MonthStepperLabelProps {
27
29
  nextMonthLabel?: string;
28
30
  previousMonthLabel?: string;
29
31
  }
30
- export interface DockedDatePickerProps extends Omit<HTMLAttributes<TextFieldElement>, 'onchange'>, DatePickerLocaleProps, DatePickerRangeProps, DatePickerCommonLabelProps, MonthStepperLabelProps {
31
- value?: ISODate | number | null;
32
+ interface DockedDateFieldProps extends DockedFieldProps {
32
33
  displayMonth?: ISODate;
33
- open?: boolean;
34
- element?: HTMLSpanElement;
35
- name?: string;
36
- form?: string;
37
- required?: boolean;
38
- disabled?: boolean;
39
- readonly?: boolean;
40
- variant?: 'outlined' | 'filled';
41
- issues?: {
42
- message: string;
43
- }[];
34
+ }
35
+ export interface DockedDatePickerProps extends Omit<HTMLAttributes<TextFieldElement>, 'onchange'>, DatePickerLocaleProps, DatePickerRangeProps, DatePickerCommonLabelProps, MonthStepperLabelProps, DockedDateFieldProps {
36
+ value?: ISODate | number | null;
44
37
  defaultValue?: ISODate | number | null;
45
38
  type?: 'date';
46
- noAsterisk?: boolean;
47
- autocomplete?: HTMLInputAttributes['autocomplete'];
48
- label?: string;
49
- supportingText?: string;
50
39
  nextYearLabel?: string;
51
40
  previousYearLabel?: string;
52
41
  selectMonthLabel?: string;
@@ -55,28 +44,12 @@ export interface DockedDatePickerProps extends Omit<HTMLAttributes<TextFieldElem
55
44
  invalidDateMessage?: string;
56
45
  onchange?: (value: ISODate | undefined) => void;
57
46
  }
58
- export interface DockedDateTimePickerProps extends Omit<HTMLAttributes<TextFieldElement>, 'onchange'>, DatePickerLocaleProps, Omit<DatePickerRangeProps, 'min' | 'max'>, DatePickerCommonLabelProps, MonthStepperLabelProps {
47
+ export interface DockedDateTimePickerProps extends Omit<HTMLAttributes<TextFieldElement>, 'onchange'>, DatePickerLocaleProps, Omit<DatePickerRangeProps, 'min' | 'max'>, DatePickerCommonLabelProps, MonthStepperLabelProps, DockedDateFieldProps {
59
48
  value?: ISODateTime | number | null;
60
- displayMonth?: ISODate;
61
- open?: boolean;
62
- element?: HTMLSpanElement;
49
+ defaultValue?: ISODateTime | number | null;
63
50
  min?: ISODate | ISODateTime;
64
51
  max?: ISODate | ISODateTime;
65
- name?: string;
66
- form?: string;
67
- required?: boolean;
68
- disabled?: boolean;
69
- readonly?: boolean;
70
- variant?: 'outlined' | 'filled';
71
- issues?: {
72
- message: string;
73
- }[];
74
- defaultValue?: ISODateTime | number | null;
75
52
  type?: 'datetime-local';
76
- noAsterisk?: boolean;
77
- autocomplete?: HTMLInputAttributes['autocomplete'];
78
- label?: string;
79
- supportingText?: string;
80
53
  minuteStep?: number;
81
54
  hour12?: boolean;
82
55
  defaultTime?: string;
@@ -96,11 +69,6 @@ export interface TimeOption {
96
69
  label: string;
97
70
  disabled?: boolean;
98
71
  }
99
- export interface TimeColumnProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onselect'> {
100
- options: TimeOption[];
101
- value?: number;
102
- onselect?: (value: number) => void;
103
- }
104
72
  export interface DatePickerDialogProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'onchange'>, DatePickerLocaleProps, DatePickerRangeProps, DatePickerCommonLabelProps, MonthStepperLabelProps {
105
73
  value?: ISODate | null;
106
74
  displayMonth?: ISODate;
@@ -113,9 +81,7 @@ export interface DatePickerDialogProps extends Omit<HTMLAttributes<HTMLDialogEle
113
81
  modeToggle?: boolean;
114
82
  label?: string;
115
83
  supportingText?: string;
116
- issues?: {
117
- message: string;
118
- }[];
84
+ issues?: Issue[];
119
85
  selectYearLabel?: string;
120
86
  calendarModeLabel?: string;
121
87
  inputModeLabel?: string;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import Divider from '../divider/Divider.svelte'
3
3
  import { syncOpenEffect } from '../popover.svelte.js'
4
- import type { DialogProps } from './types.js'
4
+ import type { DialogProps } from './types.ts'
5
5
 
6
6
  let {
7
7
  element = $bindable(),
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { DividerProps } from './types.js'
2
+ import type { DividerProps } from './types.ts'
3
3
 
4
4
  let { variant = 'full', element = $bindable(), ...attributes }: DividerProps = $props()
5
5
  </script>
@@ -4,7 +4,7 @@
4
4
  import Ripple from '../ripple/Ripple.svelte'
5
5
  import Tooltip from '../tooltip/Tooltip.svelte'
6
6
  import type { HTMLButtonAttributes } from 'svelte/elements'
7
- import type { ExtendedFabProps } from './types.js'
7
+ import type { ExtendedFabProps } from './types.ts'
8
8
 
9
9
  let {
10
10
  variant = 'primary-container',
@@ -21,8 +21,8 @@
21
21
 
22
22
  const uid = $props.id()
23
23
 
24
- const isLink = $derived(attributes.href != null && !disabled)
25
- const tooltipId = $derived(collapsed && label && !disabled ? uid : undefined)
24
+ let isLink = $derived(attributes.href != null && !disabled)
25
+ let tooltipId = $derived(collapsed && label && !disabled ? uid : undefined)
26
26
 
27
27
  const morph = pressMorph()
28
28
  morph.supersededBy(() => shape)
@@ -32,7 +32,7 @@
32
32
  morph.press()
33
33
  }
34
34
 
35
- const classes = $derived([
35
+ let classes = $derived([
36
36
  'np-extended-fab',
37
37
  'np-focus-ring',
38
38
  `np-fab-${variant}`,
@@ -4,7 +4,7 @@
4
4
  import Ripple from '../ripple/Ripple.svelte'
5
5
  import Tooltip from '../tooltip/Tooltip.svelte'
6
6
  import type { HTMLButtonAttributes } from 'svelte/elements'
7
- import type { FabProps } from './types.js'
7
+ import type { FabProps } from './types.ts'
8
8
 
9
9
  let {
10
10
  variant = 'primary-container',
@@ -20,8 +20,8 @@
20
20
 
21
21
  const uid = $props.id()
22
22
 
23
- const isLink = $derived(attributes.href != null && !disabled)
24
- const tooltipId = $derived(label && !disabled ? uid : undefined)
23
+ let isLink = $derived(attributes.href != null && !disabled)
24
+ let tooltipId = $derived(label && !disabled ? uid : undefined)
25
25
 
26
26
  const morph = pressMorph()
27
27
  morph.supersededBy(() => shape)
@@ -31,7 +31,7 @@
31
31
  morph.press()
32
32
  }
33
33
 
34
- const classes = $derived([
34
+ let classes = $derived([
35
35
  'np-fab',
36
36
  'np-focus-ring',
37
37
  `np-fab-${variant}`,
@@ -6,7 +6,7 @@
6
6
  import { PRESS_DURATION } from '../press.svelte.js'
7
7
  import { onMount } from 'svelte'
8
8
  import Fab from './Fab.svelte'
9
- import type { FabMenuProps } from './types.js'
9
+ import type { FabMenuProps } from './types.ts'
10
10
 
11
11
  let {
12
12
  label = 'Actions',
@@ -30,7 +30,7 @@
30
30
 
31
31
  const ITEMS = 'button, a[href], [role="menuitem"]'
32
32
  const attach = rovingTabindex(ITEMS)
33
- const arrowHandler = $derived(
33
+ let arrowHandler = $derived(
34
34
  arrowKeyNav(ITEMS, placement.startsWith('inline') ? 'horizontal' : 'vertical'),
35
35
  )
36
36
 
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { IconProps } from './types.js'
2
+ import type { IconProps } from './types.ts'
3
3
 
4
4
  let { children, element = $bindable(), ...attributes }: IconProps = $props()
5
5
  </script>
@@ -0,0 +1,26 @@
1
+ import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
2
+ type ElementTag = 'a' | 'button' | 'div';
3
+ export type ElementKind = 'text' | 'link' | 'button' | 'submit' | 'reset';
4
+ /** The props of a component that renders static content, a link or a button, see `elementTag`. */
5
+ export interface ElementKindProps<E extends EventTarget> extends HTMLAttributes<E>, Omit<HTMLButtonAttributes, keyof HTMLAttributes<HTMLButtonElement> | 'type'>, Omit<HTMLAnchorAttributes, keyof HTMLAttributes<HTMLAnchorElement> | 'type'> {
6
+ /**
7
+ * The element to render. Leave it out to follow `href` and `onclick`. `text` renders static
8
+ * content, `link` a link, and `button`, `submit` or `reset` a button of that type.
9
+ */
10
+ type?: ElementKind | null;
11
+ }
12
+ interface TagAttributes {
13
+ href?: string | null;
14
+ onclick?: unknown;
15
+ command?: unknown;
16
+ popovertarget?: unknown;
17
+ }
18
+ /**
19
+ * Picks the element for a component that can be static content, a link or a button. An explicit
20
+ * kind wins: `text`, `link`, or a native button type. Without one, `href` makes a link and a click
21
+ * handler, `command` or `popovertarget` makes a button.
22
+ */
23
+ export declare const elementTag: (attributes: TagAttributes, kind?: ElementKind | null) => ElementTag;
24
+ /** The native `type` for the button branch. Anything that is not a native button type becomes `button`. */
25
+ export declare const buttonType: (kind?: ElementKind | null) => "reset" | "submit" | "button";
26
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Picks the element for a component that can be static content, a link or a button. An explicit
3
+ * kind wins: `text`, `link`, or a native button type. Without one, `href` makes a link and a click
4
+ * handler, `command` or `popovertarget` makes a button.
5
+ */
6
+ export const elementTag = (attributes, kind) => {
7
+ if (kind === 'text')
8
+ return 'div';
9
+ if (kind === 'link')
10
+ return 'a';
11
+ if (kind === 'button' || kind === 'submit' || kind === 'reset')
12
+ return 'button';
13
+ if (attributes.href != null)
14
+ return 'a';
15
+ if (attributes.onclick != null ||
16
+ attributes.command != null ||
17
+ attributes.popovertarget != null) {
18
+ return 'button';
19
+ }
20
+ return 'div';
21
+ };
22
+ /** The native `type` for the button branch. Anything that is not a native button type becomes `button`. */
23
+ export const buttonType = (kind) => kind === 'submit' || kind === 'reset' ? kind : 'button';
@@ -0,0 +1,24 @@
1
+ import type { Issue } from '../shared/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLInputAttributes } from 'svelte/elements';
4
+ export interface FieldProps {
5
+ label?: string;
6
+ supportingText?: string;
7
+ issues?: Issue[];
8
+ prefixText?: string;
9
+ suffixText?: string;
10
+ variant?: 'outlined' | 'filled';
11
+ start?: Snippet;
12
+ end?: Snippet;
13
+ noAsterisk?: boolean;
14
+ element?: HTMLSpanElement;
15
+ inputElement?: HTMLInputElement | HTMLTextAreaElement;
16
+ populated?: boolean;
17
+ clientWidth?: number;
18
+ clientHeight?: number;
19
+ focused?: boolean;
20
+ }
21
+ /** The text field props the docked date and time pickers forward to their field. */
22
+ export interface DockedFieldProps extends Pick<FieldProps, 'label' | 'supportingText' | 'issues' | 'variant' | 'noAsterisk' | 'start' | 'element'>, Pick<HTMLInputAttributes, 'name' | 'form' | 'required' | 'disabled' | 'readonly' | 'autocomplete'> {
23
+ open?: boolean;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,8 @@
1
1
  <script lang="ts">
2
2
  import '../internal/focus-ring.css'
3
+ import { buttonType, elementTag } from '../internal/elementTag.js'
3
4
  import Ripple from '../ripple/Ripple.svelte'
4
- import type { ItemProps } from './types.js'
5
+ import type { ItemProps } from './types.ts'
5
6
 
6
7
  let {
7
8
  selected = false,
@@ -13,9 +14,12 @@
13
14
  softFocus = false,
14
15
  lazy = false,
15
16
  variant,
17
+ type,
16
18
  element = $bindable(),
17
19
  ...attributes
18
20
  }: ItemProps = $props()
21
+
22
+ let tag = $derived(elementTag(attributes, type ?? variant))
19
23
  </script>
20
24
 
21
25
  {#snippet content()}
@@ -32,14 +36,22 @@
32
36
  </div>
33
37
  {#if supportingText}
34
38
  <div class="np-item-supporting-text">
35
- {@render supportingText()}
39
+ {#if typeof supportingText === 'string'}
40
+ {supportingText}
41
+ {:else}
42
+ {@render supportingText()}
43
+ {/if}
36
44
  </div>
37
45
  {/if}
38
46
  </div>
39
47
 
40
48
  {#if end}
41
49
  <div class={['np-item-end', selected && 'selected', disabled && 'disabled']}>
42
- {@render end()}
50
+ {#if typeof end === 'string'}
51
+ {end}
52
+ {:else}
53
+ {@render end()}
54
+ {/if}
43
55
  </div>
44
56
  {/if}
45
57
  {/snippet}
@@ -53,7 +65,7 @@
53
65
  >
54
66
  {@render content()}
55
67
  </div>
56
- {:else if variant === 'text' || variant === undefined}
68
+ {:else if tag === 'div'}
57
69
  <div
58
70
  {...attributes}
59
71
  bind:this={element}
@@ -61,17 +73,17 @@
61
73
  >
62
74
  {@render content()}
63
75
  </div>
64
- {:else if variant === 'button'}
76
+ {:else if tag === 'button'}
65
77
  <button
66
78
  {...attributes}
67
79
  bind:this={element}
68
- type={attributes.type ?? 'button'}
80
+ type={buttonType(type)}
69
81
  class={['np-item', selected && 'selected', lazy && 'np-item-lazy', attributes.class]}
70
82
  >
71
83
  {@render content()}
72
84
  <Ripple forceHover={softFocus} />
73
85
  </button>
74
- {:else if variant === 'link'}
86
+ {:else}
75
87
  <a
76
88
  {...attributes}
77
89
  bind:this={element}
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { ListProps } from './types.js'
2
+ import type { ListProps } from './types.ts'
3
3
 
4
4
  let { element = $bindable(), children, ...attributes }: ListProps = $props()
5
5
  </script>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import Item from './Item.svelte'
3
- import type { ListItemProps } from './types.js'
3
+ import type { ListItemProps } from './types.ts'
4
4
 
5
5
  let { element = $bindable(), ...attributes }: ListItemProps = $props()
6
6
  </script>
@@ -1,16 +1,17 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
2
+ import type { ElementKindProps } from '../internal/elementTag.js';
3
+ import type { HTMLAttributes } from 'svelte/elements';
3
4
  export type ItemElement = HTMLButtonElement | HTMLAnchorElement | HTMLDivElement;
4
- export interface ItemProps extends HTMLAttributes<ItemElement>, Omit<HTMLButtonAttributes, keyof HTMLAttributes<HTMLButtonElement> | 'type'>, Omit<HTMLAnchorAttributes, keyof HTMLAttributes<HTMLAnchorElement> | 'type'> {
5
+ export interface ItemProps extends ElementKindProps<ItemElement> {
5
6
  selected?: boolean;
6
7
  start?: Snippet;
7
- end?: Snippet;
8
- disabled?: boolean;
9
- variant?: 'button' | 'link' | 'text';
10
- supportingText?: Snippet;
8
+ /** Trailing content, such as an icon or short supporting text like a count. */
9
+ end?: string | Snippet;
10
+ supportingText?: string | Snippet;
11
11
  softFocus?: boolean;
12
12
  lazy?: boolean;
13
- type?: 'submit' | 'reset' | 'button' | null;
13
+ /** @deprecated Use `type`, like on `Card`. */
14
+ variant?: 'button' | 'link' | 'text';
14
15
  element?: ItemElement;
15
16
  }
16
17
  export type ListItemProps = ItemProps;
@@ -1,6 +1,6 @@
1
1
  <script module lang="ts">
2
- import { SCALE, SHAPES, VIEWBOX, outlinePath } from './shapes.js'
3
- import type { LoadingIndicatorProps } from './types.js'
2
+ import { SCALE, SHAPES, VIEWBOX, outlinePath } from './shapes.ts'
3
+ import type { LoadingIndicatorProps } from './types.ts'
4
4
 
5
5
  const MORPH_DURATION = 650
6
6
  const QUARTER_TURN = 90
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { arrowKeyNav, rovingTabindex } from '../keyboard-nav.js'
3
3
  import { popoverController, syncOpenEffect } from '../popover.svelte.js'
4
- import type { MenuProps } from './types.js'
4
+ import type { MenuProps } from './types.ts'
5
5
 
6
6
  const MENU_ITEM_SELECTOR = '[role="menuitem"]'
7
7
  const attach = rovingTabindex(MENU_ITEM_SELECTOR)
@@ -1,14 +1,18 @@
1
1
  <script lang="ts">
2
2
  import Item from '../list/Item.svelte'
3
- import type { MenuItemProps } from './types.js'
3
+ import type { MenuItemProps } from './types.ts'
4
4
 
5
5
  let { element = $bindable(), ...attributes }: MenuItemProps = $props()
6
-
7
- const isLink = $derived(attributes.href != null)
8
6
  </script>
9
7
 
10
8
  <div class="np-menu-item" role="none">
11
- <Item role="menuitem" bind:element {...attributes} variant={isLink ? 'link' : 'button'} />
9
+ <!-- Without a link to follow, a menu item is still a button. -->
10
+ <Item
11
+ role="menuitem"
12
+ bind:element
13
+ {...attributes}
14
+ type={attributes.type ?? (attributes.href == null ? 'button' : undefined)}
15
+ />
12
16
  </div>
13
17
 
14
18
  <style>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { arrowKeyNav, rovingTabindex } from '../keyboard-nav.js'
3
- import type { NavigationBarProps } from './types.js'
3
+ import type { NavigationBarProps } from './types.ts'
4
4
 
5
5
  let {
6
6
  children,
@@ -3,7 +3,7 @@
3
3
  import Badge from '../badge/Badge.svelte'
4
4
  import Ripple from '../ripple/Ripple.svelte'
5
5
  import type { HTMLButtonAttributes } from 'svelte/elements'
6
- import type { NavigationBarItemProps } from './types.js'
6
+ import type { NavigationBarItemProps } from './types.ts'
7
7
 
8
8
  let {
9
9
  selected = false,
@@ -20,8 +20,8 @@
20
20
 
21
21
  let touchEl: HTMLSpanElement | undefined = $state()
22
22
 
23
- const isLink = $derived(attributes.href != null)
24
- const classes = $derived([
23
+ let isLink = $derived(attributes.href != null)
24
+ let classes = $derived([
25
25
  'np-navigation-bar-item',
26
26
  selected && 'np-navigation-bar-item-selected',
27
27
  labelBehavior === 'selected' && 'np-navigation-bar-item-label-selected',