fuma 2.5.0 → 2.5.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.
@@ -2,6 +2,7 @@
2
2
  import type { RemoteFormField } from '@sveltejs/kit'
3
3
  import { type Options, parseOptions } from '../utils/index.js'
4
4
  import Issues from './Issues.svelte'
5
+ import type { InputProps } from './type.js'
5
6
  import type { Snippet } from 'svelte'
6
7
 
7
8
  let {
@@ -9,15 +10,20 @@
9
10
  label,
10
11
  value = $bindable(),
11
12
  options: optionsProp,
12
- labelAppend
13
+ labelAppend,
14
+ ...props
13
15
  }: {
14
16
  field?: RemoteFormField<string>
15
17
  label: string
18
+ /**
19
+ * Sans `field`, la valeur liée. Avec, la valeur initiale: `as('radio', …)` prend la
20
+ * valeur de l'option et ne sait donc pas amorcer la sélection.
21
+ */
16
22
  value?: string
17
23
  options: Options
18
24
  /** Rendu à droite du libellé. */
19
25
  labelAppend?: Snippet
20
- } = $props()
26
+ } & InputProps = $props()
21
27
 
22
28
  const options = $derived(parseOptions(optionsProp))
23
29
  </script>
@@ -29,8 +35,14 @@
29
35
  </span>
30
36
  <div class="join join-vertical">
31
37
  {#each options as option (option.value)}
32
- {@const { class: klass, ...props } = option}
33
- {@const checked = field?.value() === option.value || value === option.value}
38
+ {@const {
39
+ class: klass,
40
+ value: optionValue,
41
+ label: optionLabel,
42
+ icon: Icon,
43
+ ...optionProps
44
+ } = option}
45
+ {@const checked = (field ? (field.value() ?? value) : value) === optionValue}
34
46
  <label
35
47
  class={[
36
48
  'input join-item not-disabled:cursor-pointer not-disabled:hover:bg-base-200',
@@ -38,21 +50,22 @@
38
50
  ]}
39
51
  >
40
52
  <div class="flex h-(--size) grow items-center gap-2">
41
- {#if option.icon}
42
- <option.icon size={18} opacity={0.8} />
43
- {/if}
44
- <span class="grow">{option.label}</span>
45
- {#if field}
46
- <input {...field.as('radio', option.value)} class={['w-0']} {...props} />
47
- {:else}
48
- <input
49
- type="radio"
50
- {checked}
51
- onchange={() => (value = option.value)}
52
- class={['w-0']}
53
- {...props}
54
- />
53
+ {#if Icon}
54
+ <Icon size={18} opacity={0.8} />
55
55
  {/if}
56
+ <span class="grow">{optionLabel}</span>
57
+ <!-- Le `checked` explicite prime sur celui de `as()`, qui lit `field.value()`:
58
+ sans lui la valeur initiale ne cocherait rien, et un groupe décoché ne
59
+ part pas dans le `FormData`. -->
60
+ <input
61
+ {...field?.as('radio', optionValue)}
62
+ type="radio"
63
+ {checked}
64
+ onchange={() => (value = optionValue)}
65
+ class={['w-0']}
66
+ {...props}
67
+ {...optionProps}
68
+ />
56
69
  <div
57
70
  class={[
58
71
  'ml-auto h-5 w-5 rounded-full outline',
@@ -1,14 +1,19 @@
1
1
  import type { RemoteFormField } from '@sveltejs/kit';
2
2
  import { type Options } from '../utils/index.js';
3
+ import type { InputProps } from './type.js';
3
4
  import type { Snippet } from 'svelte';
4
5
  type $$ComponentProps = {
5
6
  field?: RemoteFormField<string>;
6
7
  label: string;
8
+ /**
9
+ * Sans `field`, la valeur liée. Avec, la valeur initiale: `as('radio', …)` prend la
10
+ * valeur de l'option et ne sait donc pas amorcer la sélection.
11
+ */
7
12
  value?: string;
8
13
  options: Options;
9
14
  /** Rendu à droite du libellé. */
10
15
  labelAppend?: Snippet;
11
- };
16
+ } & InputProps;
12
17
  declare const InputRadio: import("svelte").Component<$$ComponentProps, {}, "value">;
13
18
  type InputRadio = ReturnType<typeof InputRadio>;
14
19
  export default InputRadio;
@@ -120,7 +120,7 @@
120
120
  "
121
121
  class={[
122
122
  'fixed top-0 right-0 bottom-0 z-10 flex',
123
- 'w-full flex-col overflow-y-scroll overscroll-contain bg-base-100',
123
+ 'w-full flex-col overflow-y-auto overscroll-contain bg-base-100',
124
124
  'transition-transform',
125
125
  klass
126
126
  ]}
@@ -15,8 +15,8 @@ export const zodCoerceJson = z.string().transform((str, ctx) => {
15
15
  try {
16
16
  return JSON.parse(str);
17
17
  }
18
- catch (e) {
19
- console.error(e);
18
+ catch (err) {
19
+ void err;
20
20
  ctx.addIssue({ code: 'custom', message: 'Invalid JSON' });
21
21
  return z.NEVER;
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "2.5.0",
3
+ "version": "2.5.3",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",