@aiaiai-pt/design-system 0.29.0 → 0.31.0

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.
@@ -130,10 +130,22 @@
130
130
  let fileUploads = $state<Record<string, Array<{ key: string; name: string }>>>({});
131
131
  let fileBusy = $state<Record<string, boolean>>({});
132
132
  let fileError = $state<Record<string, string>>({});
133
- // Platform caps mirror the public upload surface (3 × 5MB, web image types).
133
+ // Platform caps mirror the public upload surface. The per-action tier
134
+ // (allowed content types + max bytes) is DATA on the action's
135
+ // `submission_contract.attachments`; the render projects it onto the `file`
136
+ // parameter (`accept` / `max_bytes`). When a parameter carries no tier we
137
+ // fall back to the conservative web-image defaults (3 × 5MB, image types).
134
138
  const FILE_MAX_COUNT = 3;
135
- const FILE_MAX_BYTES = 5 * 1024 * 1024;
136
- const FILE_ACCEPT = "image/jpeg,image/png,image/webp";
139
+ const DEFAULT_FILE_MAX_BYTES = 5 * 1024 * 1024;
140
+ const DEFAULT_FILE_ACCEPT = "image/jpeg,image/png,image/webp";
141
+ function fileAccept(parameter: Entity): string {
142
+ const accept = (parameter as Record<string, unknown>).accept;
143
+ return typeof accept === "string" && accept.trim() ? accept : DEFAULT_FILE_ACCEPT;
144
+ }
145
+ function fileMaxBytes(parameter: Entity): number {
146
+ const max = Number((parameter as Record<string, unknown>).max_bytes);
147
+ return Number.isFinite(max) && max > 0 ? max : DEFAULT_FILE_MAX_BYTES;
148
+ }
137
149
 
138
150
  // Submit state (apply seam). Only meaningful in submit modes with an onApply.
139
151
  let submitting = $state(false);
@@ -437,6 +449,12 @@
437
449
  "required" on the field — not just the disconnected visual hint below.
438
450
  Passed through the DS field components' `{...rest}` onto the input. -->
439
451
  {@const ariaRequired = parameter.required ? "true" : undefined}
452
+ <!-- #252 — a parameter with `editable: false` (visibility.editable === false)
453
+ renders READ-ONLY: its value (e.g. a logged-in citizen's prefilled
454
+ identity — name/email) is shown but not editable. The value still rides
455
+ the payload; the field just can't be changed. Default (undefined/true) is
456
+ editable, so this is purely additive. -->
457
+ {@const editable = parameter.editable !== false}
440
458
  {#if type === "enum" || type === "select" || enumOptions(parameter).length}
441
459
  <Select
442
460
  label={String(parameter.label ?? key)}
@@ -453,6 +471,7 @@
453
471
  name={key}
454
472
  type="number"
455
473
  value={String(values[key] ?? "")}
474
+ readonly={!editable}
456
475
  oninput={(event: Event) => {
457
476
  const value = (event.target as HTMLInputElement).value;
458
477
  setValue(key, value === "" ? "" : Number(value));
@@ -491,13 +510,16 @@
491
510
  {/each}
492
511
  {#if (fileUploads[key] ?? []).length < FILE_MAX_COUNT}
493
512
  <FileUpload
494
- accept={FILE_ACCEPT}
495
- maxSize={FILE_MAX_BYTES}
513
+ accept={fileAccept(parameter)}
514
+ maxSize={fileMaxBytes(parameter)}
496
515
  multiple
497
516
  disabled={!uploadFile || fileBusy[key]}
498
517
  onfiles={(files: File[]) => handleFiles(key, files)}
499
518
  onreject={() => {
500
- fileError = { ...fileError, [key]: "JPEG, PNG or WebP up to 5MB" };
519
+ fileError = {
520
+ ...fileError,
521
+ [key]: `File type not allowed or too large (max ${Math.round(fileMaxBytes(parameter) / (1024 * 1024))}MB).`,
522
+ };
501
523
  }}
502
524
  />
503
525
  {/if}
@@ -539,7 +561,8 @@
539
561
  <Input
540
562
  label={String(parameter.label ?? key)}
541
563
  name={key}
542
- value={String(values[key] ?? "")}
564
+ value={String(values[key] ?? initialValue(parameter) ?? "")}
565
+ readonly={!editable}
543
566
  oninput={(event: Event) => setValue(key, (event.target as HTMLInputElement).value)}
544
567
  aria-required={ariaRequired}
545
568
  />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiaiai-pt/design-system",
3
- "version": "0.29.0",
3
+ "version": "0.31.0",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",