@r2digisolutions/components 0.21.8 → 0.21.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.
@@ -26,6 +26,9 @@
26
26
  min?: number;
27
27
  max?: number;
28
28
  step?: number;
29
+ maxLength?: number;
30
+ /** Show `n/max` counter (defaults on when `maxLength` is set). */
31
+ showCount?: boolean;
29
32
  oninput?: (e: Event) => void;
30
33
  onchange?: (e: Event) => void;
31
34
  onfocus?: (e: FocusEvent) => void;
@@ -53,6 +56,8 @@
53
56
  min,
54
57
  max,
55
58
  step,
59
+ maxLength,
60
+ showCount = maxLength != null,
56
61
  size = 'md',
57
62
  leadIcon,
58
63
  trailIcon,
@@ -157,6 +162,7 @@
157
162
  {min}
158
163
  {max}
159
164
  {step}
165
+ maxlength={maxLength}
160
166
  {autocomplete}
161
167
  aria-describedby={helperText ? helperId : undefined}
162
168
  aria-invalid={status === 'error'}
@@ -184,6 +190,7 @@
184
190
  {min}
185
191
  {max}
186
192
  {step}
193
+ maxlength={maxLength}
187
194
  {autocomplete}
188
195
  bind:value
189
196
  aria-describedby={helperText ? helperId : undefined}
@@ -246,9 +253,25 @@
246
253
  {/if}
247
254
  </div>
248
255
 
249
- {#if helperText}
250
- <p id={helperId} class={['text-xs leading-relaxed', statusTextClasses[status]]}>
251
- {helperText}
252
- </p>
256
+ {#if helperText || (showCount && maxLength != null)}
257
+ <div class="flex items-center justify-between gap-2 text-xs">
258
+ {#if helperText}
259
+ <p id={helperId} class={['leading-relaxed', statusTextClasses[status]]}>
260
+ {helperText}
261
+ </p>
262
+ {:else}
263
+ <span></span>
264
+ {/if}
265
+ {#if showCount && maxLength != null}
266
+ <span
267
+ class={[
268
+ 'font-mono shrink-0 ml-auto tabular-nums',
269
+ value.length >= maxLength ? 'font-semibold text-amber-600 dark:text-amber-400' : 'text-muted'
270
+ ]}
271
+ >
272
+ {value.length}/{maxLength}
273
+ </span>
274
+ {/if}
275
+ </div>
253
276
  {/if}
254
277
  </div>
@@ -22,6 +22,9 @@ interface InputProps {
22
22
  min?: number;
23
23
  max?: number;
24
24
  step?: number;
25
+ maxLength?: number;
26
+ /** Show `n/max` counter (defaults on when `maxLength` is set). */
27
+ showCount?: boolean;
25
28
  oninput?: (e: Event) => void;
26
29
  onchange?: (e: Event) => void;
27
30
  onfocus?: (e: FocusEvent) => void;
@@ -52,6 +52,8 @@
52
52
  required?: boolean;
53
53
  clearable?: boolean;
54
54
  size?: 'sm' | 'md' | 'lg';
55
+ maxLength?: number;
56
+ showCount?: boolean;
55
57
  /**
56
58
  * When true and inside `<Form>`, keep `value` in sync with `form.data[name]`.
57
59
  * Uses the logical field name (strips Kit `/formId` when present).
@@ -90,6 +92,8 @@
90
92
  required = false,
91
93
  clearable = false,
92
94
  size = 'md',
95
+ maxLength,
96
+ showCount = maxLength != null,
93
97
  bindData = false,
94
98
  inputName,
95
99
  leadIcon,
@@ -184,6 +188,8 @@
184
188
  {required}
185
189
  {clearable}
186
190
  {size}
191
+ {maxLength}
192
+ {showCount}
187
193
  {leadIcon}
188
194
  {trailIcon}
189
195
  oninput={handleInput}
@@ -41,6 +41,8 @@ interface FormFieldProps {
41
41
  required?: boolean;
42
42
  clearable?: boolean;
43
43
  size?: 'sm' | 'md' | 'lg';
44
+ maxLength?: number;
45
+ showCount?: boolean;
44
46
  /**
45
47
  * When true and inside `<Form>`, keep `value` in sync with `form.data[name]`.
46
48
  * Uses the logical field name (strips Kit `/formId` when present).
@@ -3,6 +3,8 @@
3
3
  import {
4
4
  getFormContext,
5
5
  resolveFormFieldState,
6
+ resolveRemoteInputProps,
7
+ parseRemoteFieldName,
6
8
  applyFormDataSync
7
9
  } from '../../../utils/formContext.js';
8
10
 
@@ -43,14 +45,27 @@
43
45
  }: FormNumberInputProps = $props();
44
46
 
45
47
  const form = getFormContext();
48
+ const parsed = $derived(parseRemoteFieldName(name));
49
+ const logicalName = $derived(parsed.logicalName);
50
+ const htmlName = $derived.by(() => {
51
+ if (parsed.isEncoded) return parsed.htmlName;
52
+ return resolveRemoteInputProps(form?.remoteFormId, name, 'number').name;
53
+ });
46
54
  const resolved = $derived(
47
- resolveFormFieldState({ name, errorMessage, helperText, status, disabled, form })
55
+ resolveFormFieldState({
56
+ name: logicalName,
57
+ errorMessage,
58
+ helperText,
59
+ status,
60
+ disabled,
61
+ form
62
+ })
48
63
  );
49
64
 
50
65
  $effect(() => {
51
- if (!bindData || !name || !form) return;
66
+ if (!bindData || !logicalName || !form) return;
52
67
  applyFormDataSync({
53
- fromCtx: form.data[name],
68
+ fromCtx: form.data[logicalName],
54
69
  getLocal: () => value,
55
70
  setLocal: (v) => {
56
71
  value = v;
@@ -61,9 +76,9 @@
61
76
 
62
77
  function handleChange(next: number) {
63
78
  value = next;
64
- if (bindData && name && form) {
65
- form.setData(name, next);
66
- form.clearError(name);
79
+ if (bindData && logicalName && form) {
80
+ form.setData(logicalName, next);
81
+ form.clearError(logicalName);
67
82
  }
68
83
  onchange?.(next);
69
84
  }
@@ -71,7 +86,7 @@
71
86
 
72
87
  <div class={['w-full', className]}>
73
88
  <NumberInput
74
- {name}
89
+ name={htmlName}
75
90
  {label}
76
91
  {min}
77
92
  {max}
@@ -5,6 +5,8 @@
5
5
  import {
6
6
  getFormContext,
7
7
  resolveFormFieldState,
8
+ resolveRemoteInputProps,
9
+ parseRemoteFieldName,
8
10
  applyFormDataSync
9
11
  } from '../../../utils/formContext.js';
10
12
 
@@ -48,14 +50,27 @@
48
50
  }: FormSelectProps = $props();
49
51
 
50
52
  const form = getFormContext();
53
+ const parsed = $derived(parseRemoteFieldName(name));
54
+ const logicalName = $derived(parsed.logicalName);
55
+ const htmlName = $derived.by(() => {
56
+ if (parsed.isEncoded) return parsed.htmlName;
57
+ return resolveRemoteInputProps(form?.remoteFormId, name, 'text').name;
58
+ });
51
59
  const resolved = $derived(
52
- resolveFormFieldState({ name, errorMessage, helperText, status, disabled, form })
60
+ resolveFormFieldState({
61
+ name: logicalName,
62
+ errorMessage,
63
+ helperText,
64
+ status,
65
+ disabled,
66
+ form
67
+ })
53
68
  );
54
69
 
55
70
  $effect(() => {
56
- if (!bindData || !name || !form) return;
71
+ if (!bindData || !logicalName || !form) return;
57
72
  applyFormDataSync({
58
- fromCtx: form.data[name],
73
+ fromCtx: form.data[logicalName],
59
74
  getLocal: () => value,
60
75
  setLocal: (v) => {
61
76
  value = v;
@@ -66,9 +81,9 @@
66
81
 
67
82
  function handleChange(next: string) {
68
83
  value = next;
69
- if (bindData && name && form) {
70
- form.setData(name, next);
71
- form.clearError(name);
84
+ if (bindData && logicalName && form) {
85
+ form.setData(logicalName, next);
86
+ form.clearError(logicalName);
72
87
  }
73
88
  onchange?.(next);
74
89
  }
@@ -77,7 +92,7 @@
77
92
  <div class={['w-full', className]}>
78
93
  <Select
79
94
  {id}
80
- {name}
95
+ name={htmlName}
81
96
  {label}
82
97
  {placeholder}
83
98
  {options}
@@ -3,6 +3,8 @@
3
3
  import {
4
4
  getFormContext,
5
5
  resolveFormFieldState,
6
+ resolveRemoteInputProps,
7
+ parseRemoteFieldName,
6
8
  applyFormDataSync
7
9
  } from '../../../utils/formContext.js';
8
10
 
@@ -43,7 +45,7 @@
43
45
  required = false,
44
46
  rows = 3,
45
47
  maxLength,
46
- showCount = false,
48
+ showCount = maxLength != null,
47
49
  autoResize = false,
48
50
  bindData = false,
49
51
  class: className = '',
@@ -52,14 +54,27 @@
52
54
  }: FormTextareaProps = $props();
53
55
 
54
56
  const form = getFormContext();
57
+ const parsed = $derived(parseRemoteFieldName(name));
58
+ const logicalName = $derived(parsed.logicalName);
59
+ const htmlName = $derived.by(() => {
60
+ if (parsed.isEncoded) return parsed.htmlName;
61
+ return resolveRemoteInputProps(form?.remoteFormId, name, 'text').name;
62
+ });
55
63
  const resolved = $derived(
56
- resolveFormFieldState({ name, errorMessage, helperText, status, disabled, form })
64
+ resolveFormFieldState({
65
+ name: logicalName,
66
+ errorMessage,
67
+ helperText,
68
+ status,
69
+ disabled,
70
+ form
71
+ })
57
72
  );
58
73
 
59
74
  $effect(() => {
60
- if (!bindData || !name || !form) return;
75
+ if (!bindData || !logicalName || !form) return;
61
76
  applyFormDataSync({
62
- fromCtx: form.data[name],
77
+ fromCtx: form.data[logicalName],
63
78
  getLocal: () => value,
64
79
  setLocal: (v) => {
65
80
  value = v;
@@ -69,9 +84,9 @@
69
84
  });
70
85
 
71
86
  function handleInput(e: Event) {
72
- if (bindData && name && form) {
73
- form.setData(name, (e.currentTarget as HTMLTextAreaElement).value);
74
- form.clearError(name);
87
+ if (bindData && logicalName && form) {
88
+ form.setData(logicalName, (e.currentTarget as HTMLTextAreaElement).value);
89
+ form.clearError(logicalName);
75
90
  }
76
91
  oninput?.(e);
77
92
  }
@@ -80,7 +95,7 @@
80
95
  <div class={['w-full', className]}>
81
96
  <Textarea
82
97
  {id}
83
- {name}
98
+ name={htmlName}
84
99
  {label}
85
100
  {placeholder}
86
101
  disabled={resolved.disabled}
@@ -63,7 +63,7 @@
63
63
  </script>
64
64
 
65
65
  <div
66
- class={['w-full', className]}
66
+ class={[fullWidth || variant === 'underline' ? 'w-full' : 'w-auto', className]}
67
67
  role="tablist"
68
68
  aria-orientation="horizontal"
69
69
  >
@@ -6,7 +6,7 @@ const meta = {
6
6
  argTypes: {
7
7
  title: { control: 'text' },
8
8
  description: { control: 'text' },
9
- size: { control: 'select', options: ['xs', 'sm', 'md', 'lg', 'xl', 'full'] },
9
+ size: { control: 'select', options: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', 'full'] },
10
10
  tone: { control: 'select', options: ['default', 'info', 'success', 'warning', 'danger'] },
11
11
  position: { control: 'select', options: ['center', 'top'] },
12
12
  closeOnBackdrop: { control: 'boolean' },
@@ -6,7 +6,7 @@
6
6
  import type { Snippet } from 'svelte';
7
7
  import Button from '../../atoms/Button/Button.svelte';
8
8
 
9
- type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
9
+ type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full';
10
10
  type DialogTone = 'default' | 'info' | 'success' | 'warning' | 'danger';
11
11
  type FooterAlign = 'start' | 'center' | 'end' | 'between';
12
12
  type DialogPosition = 'center' | 'top';
@@ -87,6 +87,8 @@
87
87
  md: 'max-w-md',
88
88
  lg: 'max-w-lg',
89
89
  xl: 'max-w-2xl',
90
+ '2xl': 'max-w-4xl',
91
+ '3xl': 'max-w-5xl',
90
92
  full: ''
91
93
  };
92
94
 
@@ -284,9 +286,11 @@
284
286
  scrollable &&
285
287
  (size === 'full'
286
288
  ? 'overflow-auto'
287
- : size === 'xl'
288
- ? 'max-h-[min(70vh,36rem)] overflow-y-auto'
289
- : 'max-h-[min(60vh,28rem)] overflow-y-auto')
289
+ : size === '3xl' || size === '2xl'
290
+ ? 'max-h-[min(75vh,40rem)] overflow-y-auto'
291
+ : size === 'xl'
292
+ ? 'max-h-[min(70vh,36rem)] overflow-y-auto'
293
+ : 'max-h-[min(60vh,28rem)] overflow-y-auto')
290
294
  ]}
291
295
  >
292
296
  {@render children()}
@@ -1,5 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
- type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
2
+ type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full';
3
3
  type DialogTone = 'default' | 'info' | 'success' | 'warning' | 'danger';
4
4
  type FooterAlign = 'start' | 'center' | 'end' | 'between';
5
5
  type DialogPosition = 'center' | 'top';
@@ -60,11 +60,10 @@ export declare function getRemoteFormId(action: string | undefined | null): stri
60
60
  * Resolve HTML input props for a field inside a Kit remote form.
61
61
  * Prefer a precomputed `formId` string so fields never touch Kit proxies.
62
62
  *
63
- * Kit’s `fields.x.as(type)` uses plain names (`email`, `n:age`). Do **not** append
64
- * `/formId` — remote ids look like `hash/name` and would produce invalid paths
65
- * (`email/dp12ax/login_remote`) that break `convert_formdata`.
63
+ * Kit requires names that end with `/${formId}` (from `.as()`), e.g.
64
+ * `email/1p9kxmo/login_user` or `n:age/1p9kxmo/login_user`.
66
65
  */
67
- export declare function resolveRemoteInputProps(_formId: string | null | undefined, logicalName: string | undefined, type?: string): ResolvedRemoteInputProps;
66
+ export declare function resolveRemoteInputProps(formId: string | null | undefined, logicalName: string | undefined, type?: string): ResolvedRemoteInputProps;
68
67
  export type ParsedRemoteFieldName = {
69
68
  /** Field path for errors / `form.data` (`email`, `items[0].name`) */
70
69
  logicalName: string | undefined;
@@ -81,8 +80,8 @@ export type ParsedRemoteFieldName = {
81
80
  * Otherwise treats the first `/` after an optional `n:`/`b:` prefix as the form-id boundary
82
81
  * (logical paths use `.` / `[n]`, never `/`).
83
82
  *
84
- * Note: current Kit `.as()` emits plain names without `/formId`. Encoding with the
85
- * full remote id (`hash/name`) must not be reintroduced — it breaks convert_formdata.
83
+ * Note: Kit `.as()` emits names ending with `/${formId}` (e.g. `email/hash/login`).
84
+ * `resolveRemoteInputProps` must append the same suffix when given a logical name.
86
85
  */
87
86
  export declare function parseRemoteFieldName(name: string | undefined, formId?: string | null): ParsedRemoteFieldName;
88
87
  /**
@@ -21,19 +21,25 @@ export function getRemoteFormId(action) {
21
21
  * Resolve HTML input props for a field inside a Kit remote form.
22
22
  * Prefer a precomputed `formId` string so fields never touch Kit proxies.
23
23
  *
24
- * Kit’s `fields.x.as(type)` uses plain names (`email`, `n:age`). Do **not** append
25
- * `/formId` — remote ids look like `hash/name` and would produce invalid paths
26
- * (`email/dp12ax/login_remote`) that break `convert_formdata`.
24
+ * Kit requires names that end with `/${formId}` (from `.as()`), e.g.
25
+ * `email/1p9kxmo/login_user` or `n:age/1p9kxmo/login_user`.
27
26
  */
28
- export function resolveRemoteInputProps(_formId, logicalName, type = 'text') {
27
+ export function resolveRemoteInputProps(formId, logicalName, type = 'text') {
29
28
  if (!logicalName)
30
29
  return {};
30
+ // Already Kit-encoded (contains `/formId` or was passed from `.as()`).
31
+ if (logicalName.includes('/')) {
32
+ return { name: logicalName };
33
+ }
31
34
  let prefix = '';
32
35
  if (type === 'number' || type === 'range')
33
36
  prefix = 'n:';
34
37
  else if (type === 'checkbox' || type === 'boolean')
35
38
  prefix = 'b:';
36
- return { name: `${prefix}${logicalName}` };
39
+ const base = `${prefix}${logicalName}`;
40
+ if (!formId)
41
+ return { name: base };
42
+ return { name: `${base}/${formId}` };
37
43
  }
38
44
  /**
39
45
  * Split a Kit-encoded HTML `name` (`email/1p9kxmo/login_user`, `n:age/...`)
@@ -43,8 +49,8 @@ export function resolveRemoteInputProps(_formId, logicalName, type = 'text') {
43
49
  * Otherwise treats the first `/` after an optional `n:`/`b:` prefix as the form-id boundary
44
50
  * (logical paths use `.` / `[n]`, never `/`).
45
51
  *
46
- * Note: current Kit `.as()` emits plain names without `/formId`. Encoding with the
47
- * full remote id (`hash/name`) must not be reintroduced — it breaks convert_formdata.
52
+ * Note: Kit `.as()` emits names ending with `/${formId}` (e.g. `email/hash/login`).
53
+ * `resolveRemoteInputProps` must append the same suffix when given a logical name.
48
54
  */
49
55
  export function parseRemoteFieldName(name, formId) {
50
56
  if (!name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.21.8",
3
+ "version": "0.21.10",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",