@aiaiai-pt/design-system 0.29.0 → 0.30.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);
@@ -491,13 +503,16 @@
491
503
  {/each}
492
504
  {#if (fileUploads[key] ?? []).length < FILE_MAX_COUNT}
493
505
  <FileUpload
494
- accept={FILE_ACCEPT}
495
- maxSize={FILE_MAX_BYTES}
506
+ accept={fileAccept(parameter)}
507
+ maxSize={fileMaxBytes(parameter)}
496
508
  multiple
497
509
  disabled={!uploadFile || fileBusy[key]}
498
510
  onfiles={(files: File[]) => handleFiles(key, files)}
499
511
  onreject={() => {
500
- fileError = { ...fileError, [key]: "JPEG, PNG or WebP up to 5MB" };
512
+ fileError = {
513
+ ...fileError,
514
+ [key]: `File type not allowed or too large (max ${Math.round(fileMaxBytes(parameter) / (1024 * 1024))}MB).`,
515
+ };
501
516
  }}
502
517
  />
503
518
  {/if}
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.30.0",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",