noph-ui 0.12.9 → 0.12.10

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/README.md CHANGED
@@ -64,6 +64,7 @@ Beta (No breaking changes expected)
64
64
  - Radio
65
65
  - Ripple
66
66
  - Segmented buttons
67
+ - Select
67
68
  - Snackbar
68
69
  - Text fields
69
70
 
@@ -75,7 +76,6 @@ In progress (Breaking changes expected)
75
76
  - Navigation Drawer (Docs missing)
76
77
  - Navigation Rail (Badge is missing + Docs missing)
77
78
  - Tooltips (Positioning missing)
78
- - Select (Docs missing)
79
79
 
80
80
  Pending
81
81
 
@@ -15,6 +15,7 @@
15
15
  disabled = false,
16
16
  loading = false,
17
17
  keepTooltipOnClick,
18
+ loadingAriaLabel,
18
19
  ...attributes
19
20
  }: ButtonProps = $props()
20
21
 
@@ -34,7 +35,7 @@
34
35
  {/if}
35
36
  {#if loading}
36
37
  <div class="circular-progress">
37
- <CircularProgress indeterminate />
38
+ <CircularProgress aria-label={loadingAriaLabel} indeterminate />
38
39
  </div>
39
40
  {/if}
40
41
  <div class="button-icon">
@@ -7,6 +7,7 @@ interface ButtonButtonProps extends HTMLButtonAttributes {
7
7
  element?: HTMLElement;
8
8
  disabled?: boolean;
9
9
  loading?: boolean;
10
+ loadingAriaLabel?: string;
10
11
  keepTooltipOnClick?: boolean;
11
12
  }
12
13
  interface ButtonAnchorProps extends HTMLAnchorAttributes {
@@ -17,6 +18,7 @@ interface ButtonAnchorProps extends HTMLAnchorAttributes {
17
18
  keepTooltipOnClick?: boolean;
18
19
  disabled?: boolean;
19
20
  loading?: boolean;
21
+ loadingAriaLabel?: string;
20
22
  }
21
23
  interface IconButtonButtonProps extends HTMLButtonAttributes {
22
24
  variant?: 'text' | 'filled' | 'outlined' | 'tonal';
@@ -36,7 +36,7 @@
36
36
  maxHeight > innerHeight - anchorRect.height
37
37
  ? `${innerHeight - anchorRect.height - 4}px`
38
38
  : `${maxHeight - 4}px`
39
- if (!('anchorName' in document.documentElement.style)) {
39
+ if (!('positionArea' in document.documentElement.style)) {
40
40
  const docClientWidth = document.documentElement.clientWidth
41
41
  if (anchorRect.bottom + clientHeight > innerHeight && anchorRect.top - clientHeight > 0) {
42
42
  element.style.top = `${anchorRect.top - clientHeight - 2}px`
@@ -101,6 +101,7 @@
101
101
 
102
102
  <svelte:window bind:innerHeight onresize={refreshValues} />
103
103
  <div
104
+ role="menu"
104
105
  {...attributes}
105
106
  bind:this={element}
106
107
  bind:clientWidth
@@ -108,10 +109,10 @@
108
109
  ontoggle={(event) => {
109
110
  let { newState } = event
110
111
  menuOpen = newState === 'open'
112
+ attributes.ontoggle?.(event)
111
113
  }}
112
114
  popover="auto"
113
115
  class={['np-menu-container', attributes.class]}
114
- role="menu"
115
116
  >
116
117
  <div class="np-menu">
117
118
  {@render children()}
@@ -142,7 +143,7 @@
142
143
  opacity: 0;
143
144
  justify-self: var(--np-menu-justify-self, anchor-center);
144
145
  position-area: var(--np-menu-position-area, bottom center);
145
- position-try: most-height flip-block;
146
+ position-try: normal flip-block;
146
147
  }
147
148
 
148
149
  .np-menu-container:popover-open {
@@ -33,6 +33,7 @@
33
33
  let errorRaw = $state(error)
34
34
  let selectElement: HTMLSelectElement | undefined = $state()
35
35
  let menuElement: HTMLDivElement | undefined = $state()
36
+ let anchorElement: HTMLDivElement | undefined = $state()
36
37
  let field: HTMLDivElement | undefined = $state()
37
38
  let clientWidth = $state(0)
38
39
  let menuId = $state(`--select-${crypto.randomUUID()}`)
@@ -87,6 +88,7 @@
87
88
  aria-controls="listbox"
88
89
  aria-expanded={menuOpen}
89
90
  aria-label={attributes['aria-label'] || label}
91
+ aria-disabled={disabled}
90
92
  data-testid={attributes['data-testid']}
91
93
  bind:this={field}
92
94
  bind:clientWidth
@@ -102,7 +104,7 @@
102
104
  event.preventDefault()
103
105
  if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {
104
106
  menuElement?.showPopover()
105
- ;(menuElement?.firstElementChild as HTMLElement)?.focus()
107
+ ;(menuElement?.firstElementChild?.firstElementChild as HTMLElement)?.focus()
106
108
  }
107
109
  }
108
110
  }}
@@ -129,7 +131,7 @@
129
131
  <div class="outline-end"></div>
130
132
  </div>
131
133
  {/if}
132
- <div class="np-container" style="anchor-name:{menuId};">
134
+ <div class="np-container" bind:this={anchorElement} style="anchor-name:{menuId};">
133
135
  {#if start}
134
136
  <div class="start">
135
137
  <span class="icon leading">{@render start()}</span>
@@ -175,8 +177,6 @@
175
177
  <div class="input">
176
178
  {#if selectedLabel}
177
179
  {selectedLabel}
178
- {:else}
179
- &nbsp;
180
180
  {/if}
181
181
  </div>
182
182
  </div>
@@ -201,13 +201,14 @@
201
201
  <Menu
202
202
  style="position-anchor:{menuId};min-width:{clientWidth}px;"
203
203
  popover="manual"
204
+ role="listbox"
204
205
  --np-menu-justify-self="none"
205
206
  --np-menu-position-area="bottom span-right"
206
207
  --np-menu-margin="2px 0"
207
208
  --np-menu-container-shape={variant === 'outlined'
208
209
  ? 'var(--np-outlined-select-text-field-container-shape)'
209
210
  : 'var(--np-filled-select-text-field-container-shape)'}
210
- anchor={element}
211
+ anchor={anchorElement}
211
212
  ontoggle={({ newState }) => {
212
213
  if (newState === 'open') {
213
214
  menuOpen = true
@@ -321,6 +322,7 @@
321
322
  min-height: 100%;
322
323
  min-width: min-content;
323
324
  position: relative;
325
+ user-select: none;
324
326
  }
325
327
  .outlined .container-overflow {
326
328
  border-start-start-radius: var(
@@ -431,6 +433,7 @@
431
433
  overflow-x: hidden;
432
434
  text-align: inherit;
433
435
  width: 100%;
436
+ height: 1.5rem;
434
437
 
435
438
  &::placeholder {
436
439
  color: currentColor;
@@ -599,6 +602,7 @@
599
602
  }
600
603
 
601
604
  .with-start.menu-open .label,
605
+ .with-start:focus .label,
602
606
  .with-start:has(select:focus-visible option:checked:not([value=''])) .label,
603
607
  .with-start:has(select option:checked:not([value=''])) .label,
604
608
  .with-start:has(select:focus-visible) .label {
@@ -7,7 +7,6 @@ export interface SelectProps extends Omit<HTMLSelectAttributes, 'multiple' | 'si
7
7
  errorText?: string;
8
8
  variant?: 'outlined' | 'filled';
9
9
  start?: Snippet;
10
- end?: Snippet;
11
10
  noAsterisk?: boolean;
12
11
  element?: HTMLSpanElement;
13
12
  options: {
@@ -14,7 +14,7 @@
14
14
  let anchor: HTMLElement | undefined = $state()
15
15
 
16
16
  const refreshValues = () => {
17
- if (element && anchor && !('anchorName' in document.documentElement.style)) {
17
+ if (element && anchor && !('positionArea' in document.documentElement.style)) {
18
18
  const docClientWidth = document.documentElement.clientWidth
19
19
  const anchorRect = anchor.getBoundingClientRect()
20
20
  if (anchorRect.bottom + clientHeight > innerHeight && anchorRect.top - clientHeight > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.12.9",
3
+ "version": "0.12.10",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {