@marianmeres/stuic 3.181.0 → 3.183.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.
- package/README.md +1 -1
- package/dist/components/FieldsBuilder/FieldsBuilder.svelte +101 -150
- package/dist/components/FieldsBuilder/FieldsBuilder.svelte.d.ts +10 -1
- package/dist/components/FieldsBuilder/README.md +82 -3
- package/dist/components/FieldsBuilder/_internal/ColumnsEditor.svelte +624 -0
- package/dist/components/FieldsBuilder/_internal/ColumnsEditor.svelte.d.ts +41 -0
- package/dist/components/FieldsBuilder/_internal/ExtrasEditor.svelte +174 -0
- package/dist/components/FieldsBuilder/_internal/ExtrasEditor.svelte.d.ts +20 -0
- package/dist/components/FieldsBuilder/_internal/column-meta.d.ts +27 -0
- package/dist/components/FieldsBuilder/_internal/column-meta.js +15 -0
- package/dist/components/FieldsBuilder/i18n-sk.js +17 -0
- package/dist/components/FieldsBuilder/i18n.d.ts +17 -0
- package/dist/components/FieldsBuilder/i18n.js +17 -0
- package/dist/components/FieldsBuilder/index.css +20 -0
- package/dist/components/FieldsBuilder/index.d.ts +2 -2
- package/dist/components/FieldsBuilder/types.d.ts +39 -0
- package/dist/components/FieldsBuilder/utils.d.ts +36 -1
- package/dist/components/FieldsBuilder/utils.js +180 -55
- package/dist/components/Input/FieldAssets.svelte +9 -132
- package/dist/components/Input/FieldSingleAsset.svelte +876 -0
- package/dist/components/Input/FieldSingleAsset.svelte.d.ts +135 -0
- package/dist/components/Input/FieldTable.svelte +907 -0
- package/dist/components/Input/FieldTable.svelte.d.ts +98 -0
- package/dist/components/Input/README.md +467 -20
- package/dist/components/Input/_internal/asset-helpers.d.ts +16 -0
- package/dist/components/Input/_internal/asset-helpers.js +46 -0
- package/dist/components/Input/_internal/paste-target.d.ts +15 -0
- package/dist/components/Input/_internal/paste-target.js +114 -0
- package/dist/components/Input/field-single-asset-i18n-sk.d.ts +21 -0
- package/dist/components/Input/field-single-asset-i18n-sk.js +49 -0
- package/dist/components/Input/field-single-asset-i18n.d.ts +68 -0
- package/dist/components/Input/field-single-asset-i18n.js +75 -0
- package/dist/components/Input/field-table-i18n-sk.d.ts +21 -0
- package/dist/components/Input/field-table-i18n-sk.js +41 -0
- package/dist/components/Input/field-table-i18n.d.ts +60 -0
- package/dist/components/Input/field-table-i18n.js +66 -0
- package/dist/components/Input/field-table-number.d.ts +48 -0
- package/dist/components/Input/field-table-number.js +86 -0
- package/dist/components/Input/index.css +801 -0
- package/dist/components/Input/index.d.ts +7 -0
- package/dist/components/Input/index.js +7 -0
- package/docs/domains/actions.md +3 -3
- package/docs/domains/components.md +45 -38
- package/package.json +1 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
import { type ValidateOptions, type ValidationResult } from "../../actions/validate.svelte.js";
|
|
3
|
+
import type { TranslateFn } from "../../types.js";
|
|
4
|
+
import { NotificationsStack } from "../Notifications/notifications-stack.svelte.js";
|
|
5
|
+
import { type THC } from "../Thc/Thc.svelte";
|
|
6
|
+
import type { FieldAsset } from "./FieldAssets.svelte";
|
|
7
|
+
import type { InputWrapClassProps } from "./types.js";
|
|
8
|
+
type SnippetWithId = Snippet<[{
|
|
9
|
+
id: string;
|
|
10
|
+
}]>;
|
|
11
|
+
/** What `processAsset` receives besides the optimistic (blob) asset. */
|
|
12
|
+
export interface FieldSingleAssetUploadContext {
|
|
13
|
+
/** The file to upload — already run through `transformFile`, if any. */
|
|
14
|
+
file: File;
|
|
15
|
+
/** Report upload progress (0–100). Rendered when `withOnProgress` is set. */
|
|
16
|
+
onProgress: (progress: number) => void;
|
|
17
|
+
}
|
|
18
|
+
export type FieldSingleAssetShape = "square" | "circle" | "wide";
|
|
19
|
+
export type FieldSingleAssetFit = "cover" | "contain";
|
|
20
|
+
export type FieldSingleAssetSize = "sm" | "md" | "lg";
|
|
21
|
+
/** `validateFile` verdict: a non-empty string rejects the file with that message. */
|
|
22
|
+
export type FieldSingleAssetFileCheck = string | void | null | undefined | false;
|
|
23
|
+
export interface Props extends InputWrapClassProps, Record<string, any> {
|
|
24
|
+
/**
|
|
25
|
+
* The serialized asset: by default the JSON of ONE `FieldAsset` object, or the
|
|
26
|
+
* empty string when the field is empty (see `parseValue` / `serializeValue`).
|
|
27
|
+
* Only ever rewritten when a user action SETTLES — an upload that resolves, a
|
|
28
|
+
* remove, an undo. An in-flight or failed upload never touches it.
|
|
29
|
+
*/
|
|
30
|
+
value: string;
|
|
31
|
+
/** The hidden input's name (what the form submits). */
|
|
32
|
+
name: string;
|
|
33
|
+
label?: SnippetWithId | THC;
|
|
34
|
+
description?: SnippetWithId | THC;
|
|
35
|
+
labelAfter?: SnippetWithId | THC;
|
|
36
|
+
below?: SnippetWithId | THC;
|
|
37
|
+
class?: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
tabindex?: number;
|
|
40
|
+
renderSize?: "sm" | "md" | "lg" | string;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
|
|
44
|
+
labelLeft?: boolean;
|
|
45
|
+
labelLeftWidth?: "normal" | "wide";
|
|
46
|
+
labelLeftBreakpoint?: number;
|
|
47
|
+
/** Classes for the hidden `<input type="file">` */
|
|
48
|
+
classInput?: string;
|
|
49
|
+
/** Classes for the outermost wrapper (the drop zone) */
|
|
50
|
+
classWrap?: string;
|
|
51
|
+
/** Classes for the tile (the preview button) */
|
|
52
|
+
classPreview?: string;
|
|
53
|
+
/** Classes for the tile's action buttons (remove, preview, retry) */
|
|
54
|
+
classControls?: string;
|
|
55
|
+
style?: string;
|
|
56
|
+
t?: TranslateFn;
|
|
57
|
+
notifications?: NotificationsStack;
|
|
58
|
+
/** Initial-fetch state: renders a skeleton in the tile's shape; takes no input. */
|
|
59
|
+
isLoading?: boolean;
|
|
60
|
+
/** `value` -> asset. Default: `JSON.parse`, `null` for an empty/invalid string. */
|
|
61
|
+
parseValue?: (serialized: string) => FieldAsset | null;
|
|
62
|
+
/** asset -> `value`. Default: `JSON.stringify`, `""` for `null`. */
|
|
63
|
+
serializeValue?: (asset: FieldAsset | null) => string;
|
|
64
|
+
/**
|
|
65
|
+
* The upload. Receives the optimistic asset (its `id` and every `url` are one
|
|
66
|
+
* blob URL of the file) and the file itself; resolves with the stored asset,
|
|
67
|
+
* which becomes the new `value`. A rejection keeps the previous `value`, shows
|
|
68
|
+
* an error state on the tile with Retry / Discard, and reports `notifications`.
|
|
69
|
+
* Without it the field is display-only (no picker, no drop, no paste).
|
|
70
|
+
*/
|
|
71
|
+
processAsset?: (asset: FieldAsset, ctx: FieldSingleAssetUploadContext) => Promise<FieldAsset>;
|
|
72
|
+
/** Render a progress ring driven by `ctx.onProgress` instead of a spinner. */
|
|
73
|
+
withOnProgress?: boolean;
|
|
74
|
+
/** Same tokens as the HTML `accept` attribute; also applied to drops and pastes. */
|
|
75
|
+
accept?: string;
|
|
76
|
+
/** Passed to the file input: on phones opens the camera directly. */
|
|
77
|
+
capture?: "user" | "environment";
|
|
78
|
+
/** Reject files larger than this many bytes (checked after `transformFile`). */
|
|
79
|
+
maxSize?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Custom check, run after `transformFile` and `maxSize`. Return a non-empty
|
|
82
|
+
* string to reject the file with that message (may be async — e.g. read image
|
|
83
|
+
* dimensions first).
|
|
84
|
+
*/
|
|
85
|
+
validateFile?: (file: File) => FieldSingleAssetFileCheck | Promise<FieldSingleAssetFileCheck>;
|
|
86
|
+
/**
|
|
87
|
+
* Pre-upload hook, run after the `accept` check: downscale a photo, or open a
|
|
88
|
+
* cropper and resolve with the cropped file. Resolving with `null`/`undefined`
|
|
89
|
+
* cancels silently (the user closed the cropper).
|
|
90
|
+
*/
|
|
91
|
+
transformFile?: (file: File) => File | null | undefined | Promise<File | null | undefined>;
|
|
92
|
+
/** Return `false` (may be async) to keep the asset. */
|
|
93
|
+
onBeforeRemove?: (asset: FieldAsset) => boolean | Promise<boolean>;
|
|
94
|
+
/** Return `false` (may be async) to keep the current asset instead of uploading `file`. */
|
|
95
|
+
onBeforeReplace?: (current: FieldAsset, file: File) => boolean | Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* After a remove, an inline "Undo" stays available this many ms (the removed
|
|
98
|
+
* asset is only unlinked from `value`, never deleted anywhere, so undo is
|
|
99
|
+
* lossless). `0` disables it. Default `6000`.
|
|
100
|
+
*/
|
|
101
|
+
undoTtl?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Opt-in: accept a clipboard paste (Ctrl/Cmd-V). Same routing as `FieldAssets`
|
|
104
|
+
* (one shared document listener: focused field wins; a bare paste with no focus
|
|
105
|
+
* goes to the only pasteable field on the page). A paste replaces. No-op without
|
|
106
|
+
* `processAsset`.
|
|
107
|
+
*/
|
|
108
|
+
pasteable?: boolean;
|
|
109
|
+
/** Tile shape. `circle` for avatars, `wide` (16:9) for banners / logos. Default `square`. */
|
|
110
|
+
shape?: FieldSingleAssetShape;
|
|
111
|
+
/** `cover` crops to fill, `contain` letterboxes on a neutral background (logos). Default `cover`. */
|
|
112
|
+
fit?: FieldSingleAssetFit;
|
|
113
|
+
/** Tile height: a preset (`5rem` / `8rem` / `12rem`) or any CSS length. Default `md`. */
|
|
114
|
+
size?: FieldSingleAssetSize | string;
|
|
115
|
+
/** What the empty tile shows instead of the default icon (e.g. an `Avatar` with initials). */
|
|
116
|
+
placeholder?: THC;
|
|
117
|
+
/** Hide the "Preview" action (the `AssetsPreview` lightbox). */
|
|
118
|
+
noPreview?: boolean;
|
|
119
|
+
/** Hide the lightbox's Download button. */
|
|
120
|
+
noDownload?: boolean;
|
|
121
|
+
/** See `AssetsPreview.onDownload`: replaces the default download of `url.original`. */
|
|
122
|
+
onDownload?: (asset: FieldAsset) => void | Promise<void>;
|
|
123
|
+
/** After every user-driven change of `value` (upload settled, remove, undo). */
|
|
124
|
+
onChange?: (asset: FieldAsset | null) => void;
|
|
125
|
+
}
|
|
126
|
+
declare const FieldSingleAsset: import("svelte").Component<Props, {
|
|
127
|
+
validate: () => ValidationResult | undefined;
|
|
128
|
+
clearValidation: () => void;
|
|
129
|
+
getValidation: () => ValidationResult | undefined;
|
|
130
|
+
focus: () => void;
|
|
131
|
+
scrollIntoView: (opts?: ScrollIntoViewOptions) => void;
|
|
132
|
+
openFilePicker: () => void;
|
|
133
|
+
}, "value">;
|
|
134
|
+
type FieldSingleAsset = ReturnType<typeof FieldSingleAsset>;
|
|
135
|
+
export default FieldSingleAsset;
|