noph-ui 0.9.7 → 0.9.8

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.
@@ -19,6 +19,12 @@
19
19
  noAsterisk = false,
20
20
  variant = 'filled',
21
21
  element = $bindable(),
22
+ required,
23
+ disabled,
24
+ name,
25
+ id,
26
+ form,
27
+ autofocus,
22
28
  ...attributes
23
29
  }: SelectProps = $props()
24
30
 
@@ -34,7 +40,6 @@
34
40
  let selectedLabel = $derived.by<string>(() => {
35
41
  return options.find((option) => option.value === value)?.label || ''
36
42
  })
37
- let clientWidth = $state(0)
38
43
  $effect(() => {
39
44
  if (value !== '') {
40
45
  error = false
@@ -89,22 +94,25 @@
89
94
  class={['text-field', attributes.class]}
90
95
  bind:this={element}
91
96
  >
97
+ <!-- svelte-ignore a11y_autofocus -->
92
98
  <div
99
+ {id}
93
100
  class="field"
94
101
  class:error
95
102
  class:no-label={!label?.length}
96
103
  class:with-start={start}
97
104
  class:menu-open={menuOpen}
98
105
  class:with-end={true}
99
- class:disabled={attributes.disabled}
106
+ class:disabled
100
107
  class:outlined={variant === 'outlined'}
101
108
  role="combobox"
102
- tabindex={attributes.disabled ? -1 : tabindex}
109
+ tabindex={disabled ? -1 : tabindex}
103
110
  aria-controls="listbox"
104
111
  aria-expanded={menuOpen}
105
112
  aria-label={attributes['aria-label'] || label}
113
+ data-test-id={attributes['data-test-id']}
106
114
  bind:this={field}
107
- bind:clientWidth
115
+ autofocus={disabled ? false : autofocus}
108
116
  onclick={(event) => {
109
117
  event.preventDefault()
110
118
  menuElement?.showPopover()
@@ -132,11 +140,11 @@
132
140
  <div class="outline-start"></div>
133
141
  {#if label?.length}
134
142
  <div class="label-wrapper">
135
- <span class="label">{label}{noAsterisk || !attributes.required ? '' : '*'} </span>
143
+ <span class="label">{label}{noAsterisk || !required ? '' : '*'} </span>
136
144
  </div>
137
145
  <div class="outline-notch">
138
146
  <span class="notch np-hidden" aria-hidden="true"
139
- >{label}{noAsterisk || !attributes.required ? '' : '*'}</span
147
+ >{label}{noAsterisk || !required ? '' : '*'}</span
140
148
  >
141
149
  </div>
142
150
  {/if}
@@ -153,16 +161,18 @@
153
161
  {#if variant === 'filled'}
154
162
  <div class="label-wrapper">
155
163
  {#if label?.length}
156
- <span class="label">{label}{noAsterisk || !attributes.required ? '' : '*'} </span>
164
+ <span class="label">{label}{noAsterisk || !required ? '' : '*'} </span>
157
165
  {/if}
158
166
  </div>
159
167
  {/if}
160
168
  <div class="content">
161
169
  <select
162
170
  tabindex="-1"
163
- aria-label={label}
164
- {...attributes}
165
- class={[]}
171
+ aria-label={attributes['aria-label'] || label}
172
+ {disabled}
173
+ {required}
174
+ {name}
175
+ {form}
166
176
  bind:value
167
177
  bind:this={selectElement}
168
178
  >
@@ -457,12 +467,10 @@
457
467
  .disabled .content {
458
468
  color: var(--np-color-on-surface);
459
469
  }
460
- .field:not(.with-end) .content .input-wrapper,
461
470
  .field:not(.with-end) .content .input {
462
471
  padding-inline-end: 16px;
463
472
  }
464
473
  .outline-start,
465
- .field:not(.with-start) .content .input-wrapper,
466
474
  .field:not(.with-start) .content .input {
467
475
  padding-inline-start: 16px;
468
476
  }
@@ -472,20 +480,6 @@
472
480
  padding-bottom: var(--bottom-space, 0.5rem);
473
481
  }
474
482
 
475
- .input-wrapper {
476
- display: flex;
477
- }
478
-
479
- .input-wrapper > * {
480
- all: inherit;
481
- padding: 0;
482
- }
483
-
484
- .content .input-wrapper {
485
- padding-top: var(--top-space, 1.5rem);
486
- padding-bottom: var(--bottom-space, 0.5rem);
487
- }
488
-
489
483
  .start {
490
484
  color: var(--np-color-on-surface-variant);
491
485
  margin-left: 0.75rem;
@@ -1,6 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLSelectAttributes } from 'svelte/elements';
3
- export interface SelectProps extends HTMLSelectAttributes {
3
+ export interface SelectProps extends Omit<HTMLSelectAttributes, 'multiple' | 'size' | 'autocomplete'> {
4
4
  label?: string;
5
5
  supportingText?: string;
6
6
  error?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {