@cloudparker/moldex.js 4.1.2 → 4.1.3

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.
@@ -141,123 +141,141 @@
141
141
 
142
142
  let inputRef: HTMLInputElement | HTMLTextAreaElement | null = $state(null);
143
143
 
144
- let sizeClassName = $state('');
145
- let appearanceClassName = $state('');
146
- let floatingLabelClassName = $state('');
147
- let floatingLabelPaddingClassName = $state('');
148
- let floatingLabelTextClassName = $state('');
144
+ let nameDerived = $derived(name || id);
145
+ let idDerived = $derived(id || name);
149
146
 
150
- export function focus() {
151
- inputRef && inputRef.focus();
152
- }
153
-
154
- export function getElement() {
155
- return inputRef;
156
- }
157
-
158
- export function select() {
159
- return inputRef && (inputRef as HTMLInputElement).select();
160
- }
161
-
162
- export function getBoundingClientRect() {
163
- if (inputRef) {
164
- return inputRef.getBoundingClientRect();
147
+ let containerClassNameDerived = $derived.by(() => {
148
+ if (floatingLabel || leftSnippet != null || rightSnippet != null) {
149
+ return (containerClassName || '') + ' relative';
165
150
  }
166
- }
151
+ return containerClassName;
152
+ });
167
153
 
168
- $effect(() => {
169
- if (floatingLabel || leftSnippet != null || rightSnippet != null) {
170
- containerClassName = (containerClassName || '') + ' relative';
154
+ let sizeClassName = $derived.by(() => {
155
+ let sizeClassName = '';
156
+ if (size) {
157
+ switch (size) {
158
+ case 'lg':
159
+ sizeClassName = 'p-4 text-base';
160
+ break;
161
+ case 'md':
162
+ sizeClassName = 'p-2.5 text-sm';
163
+ break;
164
+ case 'sm':
165
+ sizeClassName = 'p-2 text-xs';
166
+ break;
167
+ case 'xs':
168
+ sizeClassName = 'p-1 text-xs';
169
+ break;
170
+ }
171
171
  }
172
+ return sizeClassName;
172
173
  });
173
174
 
174
- $effect(() => {
175
+ let floatingLabelPaddingClassName = $derived.by(() => {
175
176
  if (floatingLabel) {
176
177
  if (size) {
177
- let flpcn = '';
178
+ let floatingClassName = '';
178
179
  switch (size) {
179
180
  case 'lg':
180
- flpcn = ` px-1 peer-focus:px-1 peer-placeholder-shown:px-4 `;
181
- floatingLabelTextClassName = 'text-base';
181
+ floatingClassName = ` px-1 peer-focus:px-1 peer-placeholder-shown:px-4 `;
182
182
  break;
183
183
  case 'md':
184
- flpcn = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2.5 ';
185
- floatingLabelTextClassName = 'text-sm';
184
+ floatingClassName = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2.5 ';
185
+ break;
186
+ case 'sm':
187
+ floatingClassName = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2';
188
+ break;
189
+ case 'xs':
190
+ floatingClassName = ' px-0 peer-focus:px-0 peer-placeholder-shown:px-1 ';
191
+ break;
192
+ }
193
+ return floatingClassName;
194
+ }
195
+ }
196
+ return '';
197
+ });
186
198
 
199
+ let floatingLabelTextClassName = $derived.by(() => {
200
+ let className = '';
201
+ if (floatingLabel) {
202
+ if (size) {
203
+ switch (size) {
204
+ case 'lg':
205
+ className = 'text-base';
206
+ break;
207
+ case 'md':
208
+ className = 'text-sm';
187
209
  break;
188
210
  case 'sm':
189
- flpcn = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2';
190
- floatingLabelTextClassName = 'text-xs';
211
+ className = 'text-xs';
191
212
  break;
192
213
  case 'xs':
193
- flpcn = ' px-0 peer-focus:px-0 peer-placeholder-shown:px-1 ';
194
- floatingLabelTextClassName = 'text-xs';
214
+ className = 'text-xs';
195
215
  break;
196
216
  }
197
- floatingLabelPaddingClassName = flpcn;
198
217
  }
218
+ }
219
+ return className;
220
+ });
199
221
 
200
- floatingLabelClassName = `absolute duration-300 transform top-0 rounded -translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-0 peer-placeholder-shown:start-0 peer-focus:start-1 bg-white peer-focus:bg-white dark:bg-neutral-700 peer-focus:bg-neutral-800 peer-placeholder-shown:bg-transparent start-1 ${floatingLabelPaddingClassName} ${floatingLabelTextClassName}`;
222
+ let floatingLabelClassName = $derived.by(() => {
223
+ if (floatingLabel) {
224
+ return `absolute duration-300 transform top-0 rounded -translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-0 peer-placeholder-shown:start-0 peer-focus:start-1 bg-white peer-focus:bg-white dark:bg-neutral-700 peer-focus:bg-neutral-800 peer-placeholder-shown:bg-transparent start-1 ${floatingLabelPaddingClassName} ${floatingLabelTextClassName}`;
201
225
  }
226
+ return '';
202
227
  });
203
228
 
204
- $effect(() => {
229
+ let appearanceClassName = $derived.by(() => {
230
+ let className = '';
205
231
  if (appearance) {
206
232
  switch (appearance) {
207
233
  case 'normal':
208
- appearanceClassName =
234
+ className =
209
235
  'border rounded-lg bg-neutral-100 dark:bg-neutral-700 border-neutral-300 dark:border-neutral-500 text-neutral-950 dark:text-neutral-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-neutral-50 dark:focus:bg-neutral-800 ';
210
236
  break;
211
237
  case 'box':
212
- appearanceClassName =
238
+ className =
213
239
  'border bg-neutral-100 dark:bg-neutral-700 border-neutral-300 dark:border-neutral-500 text-neutral-950 dark:text-neutral-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-neutral-50 dark:focus:bg-neutral-800 ';
214
240
  break;
215
241
  case 'fill':
216
- appearanceClassName =
242
+ className =
217
243
  ' border-0 appearance-none focus:ring-0 bg-neutral-100 dark:bg-neutral-700 text-neutral-950 dark:text-neutral-50 focus:bg-neutral-50 dark:focus:bg-neutral-800 ';
218
244
  break;
219
245
  case 'underline':
220
- appearanceClassName =
246
+ className =
221
247
  'bg-transparent border-0 border-b-2 appearance-none focus:ring-0 text-neutral-950 dark:text-neutral-50 border-neutral-300 dark:border-neutral-700 focus:border-primary-500 dark:focus:border-primary-500';
222
248
  break;
223
249
  case 'fill-underline':
224
- appearanceClassName =
250
+ className =
225
251
  'border-0 border-b-2 appearance-none ring-0 text-neutral-950 dark:text-neutral-50 bg-neutral-100 dark:bg-neutral-700 border-neutral-300 dark:border-neutral-500 focus:border-primary-500 dark:focus:border-primary-500 ';
226
252
  break;
227
253
  case 'none':
228
- appearanceClassName =
254
+ className =
229
255
  'border-0 focus:ring-0 appearance-none text-neutral-950 dark:text-neutral-50 bg-transparent dark:bg-transparent focus:bg-neutral-100 dark:focus:bg-neutral-800 hover:bg-neutral-100 dark:hover:bg-neutral-800';
230
256
  break;
231
257
  }
232
258
  }
259
+ return className;
233
260
  });
234
261
 
235
- $effect(() => {
236
- if (size) {
237
- switch (size) {
238
- case 'lg':
239
- sizeClassName = 'p-4 text-base';
240
- break;
241
- case 'md':
242
- sizeClassName = 'p-2.5 text-sm';
243
- break;
244
- case 'sm':
245
- sizeClassName = 'p-2 text-xs';
246
- break;
247
- case 'xs':
248
- sizeClassName = 'p-1 text-xs';
249
- break;
250
- }
251
- }
252
- });
262
+ export function focus() {
263
+ inputRef && inputRef.focus();
264
+ }
253
265
 
254
- $effect(() => {
255
- if (name && !id) {
256
- id = name;
257
- } else if (id && !name) {
258
- name = id;
266
+ export function getElement() {
267
+ return inputRef;
268
+ }
269
+
270
+ export function select() {
271
+ return inputRef && (inputRef as HTMLInputElement).select();
272
+ }
273
+
274
+ export function getBoundingClientRect() {
275
+ if (inputRef) {
276
+ return inputRef.getBoundingClientRect();
259
277
  }
260
- });
278
+ }
261
279
 
262
280
  $effect(() => {
263
281
  setTimeout(() => {
@@ -270,9 +288,9 @@
270
288
 
271
289
  {#snippet labelSnippet()}
272
290
  <Label
273
- forName={id}
291
+ forName={idDerived}
274
292
  {label}
275
- className=" {floatingLabel ? '' : 'mb-1 '} {floatingLabelClassName} {labelClassName}"
293
+ className=" {floatingLabel ? '' : 'mb-1 '} {floatingLabelClassName} {labelClassName}"
276
294
  {required}
277
295
  {requiredSymbolColor}
278
296
  {requiredSymbol}
@@ -284,10 +302,10 @@
284
302
  {@render labelSnippet()}
285
303
  {/if}
286
304
 
287
- <div class="w-full {containerClassName}">
305
+ <div class="w-full {containerClassNameDerived}">
288
306
  {#if leftSnippet}
289
307
  <div
290
- class="absolute flex items-center justify-center left-children {leftSnippetContainerClassName}"
308
+ class="left-children absolute flex items-center justify-center {leftSnippetContainerClassName}"
291
309
  >
292
310
  {@render leftSnippet()}
293
311
  </div>
@@ -297,10 +315,10 @@
297
315
  <textarea
298
316
  bind:this={inputRef}
299
317
  bind:value
300
- class="block w-full peer outline-none {appearanceClassName} {sizeClassName} {className}"
318
+ class="peer block w-full outline-none {appearanceClassName} {sizeClassName} {className}"
301
319
  {title}
302
- {id}
303
- {name}
320
+ id={idDerived}
321
+ name={nameDerived}
304
322
  {placeholder}
305
323
  {required}
306
324
  {disabled}
@@ -328,11 +346,11 @@
328
346
  <input
329
347
  bind:this={inputRef}
330
348
  bind:value
331
- class="block w-full peer outline-none {appearanceClassName} {sizeClassName} {className}"
349
+ class="peer block w-full outline-none {appearanceClassName} {sizeClassName} {className}"
332
350
  {title}
333
351
  {type}
334
- {id}
335
- {name}
352
+ id={idDerived}
353
+ name={nameDerived}
336
354
  {placeholder}
337
355
  {required}
338
356
  {disabled}
@@ -365,14 +383,14 @@
365
383
  {/if}
366
384
  {#if contentSnippet}
367
385
  <div
368
- class="absolute inset-0 pointer-events-none block w-full overflow-hidden {appearanceClassName} {sizeClassName} {contentSnippetClassName}"
386
+ class="pointer-events-none absolute inset-0 block w-full overflow-hidden {appearanceClassName} {sizeClassName} {contentSnippetClassName}"
369
387
  >
370
388
  {@render contentSnippet()}
371
389
  </div>
372
390
  {/if}
373
391
  {#if rightSnippet}
374
392
  <div
375
- class="absolute flex items-center justify-center right-children {rightSnippetContainerClassName}"
393
+ class="right-children absolute flex items-center justify-center {rightSnippetContainerClassName}"
376
394
  >
377
395
  {@render rightSnippet()}
378
396
  </div>
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
- import { mdiMagnify } from '../../../icon';
2
+
3
3
  import Icon from '../../../icon/components/icon/icon.svelte';
4
+ import { mdiMagnify } from '../../../icon/index.js';
4
5
  import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
5
6
 
6
7
  let {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudparker/moldex.js",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "keywords": [
5
5
  "svelte"
6
6
  ],