@svadmin/lite 0.6.0 → 0.8.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.
Files changed (104) hide show
  1. package/README.md +85 -9
  2. package/dist/components/LiteActivityFeed.svelte +98 -0
  3. package/dist/components/LiteActivityFeed.svelte.d.ts +19 -0
  4. package/dist/components/LiteApprovalActionCard.svelte +75 -0
  5. package/dist/components/LiteApprovalActionCard.svelte.d.ts +10 -0
  6. package/dist/components/LiteCanvasAnnotation.svelte +136 -0
  7. package/dist/components/LiteCanvasAnnotation.svelte.d.ts +16 -0
  8. package/dist/components/LiteColumnHeaderFilter.svelte +38 -0
  9. package/dist/components/LiteColumnHeaderFilter.svelte.d.ts +8 -0
  10. package/dist/components/LiteColumnSettings.svelte +82 -0
  11. package/dist/components/LiteColumnSettings.svelte.d.ts +15 -0
  12. package/dist/components/LiteDecisionTable.svelte +178 -0
  13. package/dist/components/LiteDecisionTable.svelte.d.ts +21 -0
  14. package/dist/components/LiteDraggableRowTable.svelte +70 -0
  15. package/dist/components/LiteDraggableRowTable.svelte.d.ts +14 -0
  16. package/dist/components/LiteDrawerForm.svelte +85 -0
  17. package/dist/components/LiteDrawerForm.svelte.d.ts +13 -0
  18. package/dist/components/LiteDynamicFormList.svelte +169 -0
  19. package/dist/components/LiteDynamicFormList.svelte.d.ts +45 -0
  20. package/dist/components/LiteEditableTable.svelte +84 -0
  21. package/dist/components/LiteEditableTable.svelte.d.ts +19 -0
  22. package/dist/components/LiteFilterBuilder.svelte +205 -0
  23. package/dist/components/LiteFilterBuilder.svelte.d.ts +19 -0
  24. package/dist/components/LiteGanttChart.svelte +144 -0
  25. package/dist/components/LiteGanttChart.svelte.d.ts +17 -0
  26. package/dist/components/LiteImageCropper.svelte +81 -0
  27. package/dist/components/LiteImageCropper.svelte.d.ts +9 -0
  28. package/dist/components/LiteImportWizard.svelte +99 -0
  29. package/dist/components/LiteImportWizard.svelte.d.ts +11 -0
  30. package/dist/components/LiteJsonSchemaForm.svelte +102 -0
  31. package/dist/components/LiteJsonSchemaForm.svelte.d.ts +10 -0
  32. package/dist/components/LiteKanbanBoard.svelte +169 -0
  33. package/dist/components/LiteKanbanBoard.svelte.d.ts +21 -0
  34. package/dist/components/LiteMasterDetailView.svelte +113 -0
  35. package/dist/components/LiteMasterDetailView.svelte.d.ts +11 -0
  36. package/dist/components/LiteMediaLibraryModal.svelte +110 -0
  37. package/dist/components/LiteMediaLibraryModal.svelte.d.ts +17 -0
  38. package/dist/components/LiteMentionsInput.svelte +98 -0
  39. package/dist/components/LiteMentionsInput.svelte.d.ts +19 -0
  40. package/dist/components/LiteModalForm.svelte +84 -0
  41. package/dist/components/LiteModalForm.svelte.d.ts +13 -0
  42. package/dist/components/LiteMultiTabKeepAlive.svelte +79 -0
  43. package/dist/components/LiteMultiTabKeepAlive.svelte.d.ts +15 -0
  44. package/dist/components/LiteOfflineSyncBanner.svelte +75 -0
  45. package/dist/components/LiteOfflineSyncBanner.svelte.d.ts +15 -0
  46. package/dist/components/LitePdfDocumentViewer.svelte +138 -0
  47. package/dist/components/LitePdfDocumentViewer.svelte.d.ts +17 -0
  48. package/dist/components/LitePivotTable.svelte +163 -0
  49. package/dist/components/LitePivotTable.svelte.d.ts +15 -0
  50. package/dist/components/LitePresenceAvatarGroup.svelte +52 -0
  51. package/dist/components/LitePresenceAvatarGroup.svelte.d.ts +12 -0
  52. package/dist/components/LitePrintableBill.svelte +119 -0
  53. package/dist/components/LitePrintableBill.svelte.d.ts +19 -0
  54. package/dist/components/LiteSensitiveDataMask.svelte +35 -0
  55. package/dist/components/LiteSensitiveDataMask.svelte.d.ts +7 -0
  56. package/dist/components/LiteShowField.svelte +22 -0
  57. package/dist/components/LiteSignaturePad.svelte +99 -0
  58. package/dist/components/LiteSignaturePad.svelte.d.ts +11 -0
  59. package/dist/components/LiteSplitPaneLayout.svelte +66 -0
  60. package/dist/components/LiteSplitPaneLayout.svelte.d.ts +9 -0
  61. package/dist/components/LiteSpreadsheetView.svelte +148 -0
  62. package/dist/components/LiteSpreadsheetView.svelte.d.ts +16 -0
  63. package/dist/components/LiteStepForm.svelte +144 -0
  64. package/dist/components/LiteStepForm.svelte.d.ts +18 -0
  65. package/dist/components/LiteTableSummary.svelte +93 -0
  66. package/dist/components/LiteTableSummary.svelte.d.ts +17 -0
  67. package/dist/components/LiteTransfer.svelte +185 -0
  68. package/dist/components/LiteTransfer.svelte.d.ts +18 -0
  69. package/dist/components/LiteTreeTable.svelte +85 -0
  70. package/dist/components/LiteTreeTable.svelte.d.ts +13 -0
  71. package/dist/components/LiteVersionDiffViewer.svelte +129 -0
  72. package/dist/components/LiteVersionDiffViewer.svelte.d.ts +10 -0
  73. package/dist/components/LiteVirtualTable.svelte +52 -0
  74. package/dist/components/LiteVirtualTable.svelte.d.ts +14 -0
  75. package/dist/components/LiteWatermark.svelte +35 -0
  76. package/dist/components/LiteWatermark.svelte.d.ts +11 -0
  77. package/dist/components/fields/LiteAvatarField.svelte +127 -0
  78. package/dist/components/fields/LiteAvatarField.svelte.d.ts +21 -0
  79. package/dist/components/fields/LiteCascader.svelte +119 -0
  80. package/dist/components/fields/LiteCascader.svelte.d.ts +24 -0
  81. package/dist/components/fields/LiteCodeField.svelte +71 -0
  82. package/dist/components/fields/LiteCodeField.svelte.d.ts +16 -0
  83. package/dist/components/fields/LiteCopyField.svelte +74 -0
  84. package/dist/components/fields/LiteCopyField.svelte.d.ts +18 -0
  85. package/dist/components/fields/LiteCurrencyField.svelte +126 -0
  86. package/dist/components/fields/LiteCurrencyField.svelte.d.ts +21 -0
  87. package/dist/components/fields/LiteDateRangeField.svelte +147 -0
  88. package/dist/components/fields/LiteDateRangeField.svelte.d.ts +26 -0
  89. package/dist/components/fields/LitePercentField.svelte +124 -0
  90. package/dist/components/fields/LitePercentField.svelte.d.ts +17 -0
  91. package/dist/components/fields/LitePhoneField.svelte +81 -0
  92. package/dist/components/fields/LitePhoneField.svelte.d.ts +17 -0
  93. package/dist/components/fields/LiteRatingField.svelte +105 -0
  94. package/dist/components/fields/LiteRatingField.svelte.d.ts +16 -0
  95. package/dist/components/fields/LiteTreeSelect.svelte +143 -0
  96. package/dist/components/fields/LiteTreeSelect.svelte.d.ts +23 -0
  97. package/dist/components/fields/index.d.ts +12 -0
  98. package/dist/components/fields/index.js +10 -0
  99. package/dist/components/pages/LiteListPage.svelte +14 -12
  100. package/dist/index.d.ts +40 -0
  101. package/dist/index.js +37 -0
  102. package/dist/lite.css +205 -0
  103. package/dist/schema-generator.js +15 -4
  104. package/package.json +4 -3
@@ -0,0 +1,10 @@
1
+ interface Props {
2
+ oldValue?: Record<string, unknown>;
3
+ newValue?: Record<string, unknown>;
4
+ oldTitle?: string;
5
+ newTitle?: string;
6
+ fieldLabels?: Record<string, string>;
7
+ }
8
+ declare const LiteVersionDiffViewer: import("svelte").Component<Props, {}, "">;
9
+ type LiteVersionDiffViewer = ReturnType<typeof LiteVersionDiffViewer>;
10
+ export default LiteVersionDiffViewer;
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ interface LiteVirtualTableColumn {
3
+ key: string;
4
+ label: string;
5
+ width?: string;
6
+ align?: 'left' | 'center' | 'right';
7
+ }
8
+
9
+ interface Props {
10
+ items?: Record<string, unknown>[];
11
+ columns: LiteVirtualTableColumn[];
12
+ rowKey?: string;
13
+ }
14
+
15
+ let {
16
+ items = [],
17
+ columns,
18
+ rowKey = 'id',
19
+ }: Props = $props();
20
+ </script>
21
+
22
+ <div class="lite-table-scroll">
23
+ <table class="lite-table">
24
+ <thead>
25
+ <tr>
26
+ {#each columns as col (col.key)}
27
+ <th style={col.width ? `width: ${col.width}; text-align: ${col.align || 'left'};` : `text-align: ${col.align || 'left'};`}>
28
+ {col.label}
29
+ </th>
30
+ {/each}
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ {#each items as item, index (item[rowKey] ?? index)}
35
+ <tr>
36
+ {#each columns as col (col.key)}
37
+ <td style="text-align: {col.align || 'left'};">
38
+ {item[col.key] ?? '—'}
39
+ </td>
40
+ {/each}
41
+ </tr>
42
+ {/each}
43
+ {#if items.length === 0}
44
+ <tr>
45
+ <td colspan={columns.length} style="text-align: center; color: #94a3b8; padding: 24px;">
46
+ No records to display
47
+ </td>
48
+ </tr>
49
+ {/if}
50
+ </tbody>
51
+ </table>
52
+ </div>
@@ -0,0 +1,14 @@
1
+ interface LiteVirtualTableColumn {
2
+ key: string;
3
+ label: string;
4
+ width?: string;
5
+ align?: 'left' | 'center' | 'right';
6
+ }
7
+ interface Props {
8
+ items?: Record<string, unknown>[];
9
+ columns: LiteVirtualTableColumn[];
10
+ rowKey?: string;
11
+ }
12
+ declare const LiteVirtualTable: import("svelte").Component<Props, {}, "">;
13
+ type LiteVirtualTable = ReturnType<typeof LiteVirtualTable>;
14
+ export default LiteVirtualTable;
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ interface Props {
5
+ content?: string | string[];
6
+ opacity?: number;
7
+ rotate?: number;
8
+ class?: string;
9
+ children?: Snippet;
10
+ }
11
+
12
+ let {
13
+ content = 'CONFIDENTIAL',
14
+ opacity = 0.1,
15
+ rotate = -22,
16
+ class: className = '',
17
+ children,
18
+ }: Props = $props();
19
+
20
+ const text = $derived(Array.isArray(content) ? content.join(' ') : content);
21
+ const svgEncoded = $derived(
22
+ encodeURIComponent(
23
+ `<svg xmlns="http://www.w3.org/2000/svg" width="240" height="160"><text x="50%" y="50%" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="14" fill="#888888" fill-opacity="${opacity}" transform="rotate(${rotate} 120 80)">${text}</text></svg>`
24
+ )
25
+ );
26
+ </script>
27
+
28
+ <div
29
+ class="lite-watermark-wrapper {className}"
30
+ style="position: relative; overflow: hidden; background-image: url('data:image/svg+xml;utf8,{svgEncoded}'); background-repeat: repeat;"
31
+ >
32
+ {#if children}
33
+ {@render children()}
34
+ {/if}
35
+ </div>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ content?: string | string[];
4
+ opacity?: number;
5
+ rotate?: number;
6
+ class?: string;
7
+ children?: Snippet;
8
+ }
9
+ declare const LiteWatermark: import("svelte").Component<Props, {}, "">;
10
+ type LiteWatermark = ReturnType<typeof LiteWatermark>;
11
+ export default LiteWatermark;
@@ -0,0 +1,127 @@
1
+ <script module lang="ts">
2
+ export type LiteAvatarStatus = 'online' | 'offline' | 'busy' | 'away' | 'success' | 'warning' | 'error' | 'neutral';
3
+ export type LiteAvatarSize = 'xs' | 'sm' | 'default' | 'lg';
4
+ </script>
5
+
6
+ <script lang="ts">
7
+ import type { FieldDefinition } from '@svadmin/core';
8
+
9
+ interface Props {
10
+ field?: FieldDefinition;
11
+ value?: unknown;
12
+ error?: string[];
13
+ mode?: 'show' | 'edit' | 'create';
14
+ src?: string | null;
15
+ name?: string | null;
16
+ subtitle?: string | null;
17
+ status?: LiteAvatarStatus;
18
+ size?: LiteAvatarSize;
19
+ shape?: 'circle' | 'square';
20
+ showName?: boolean;
21
+ nullLabel?: string;
22
+ class?: string;
23
+ }
24
+
25
+ let {
26
+ field,
27
+ value,
28
+ error = [],
29
+ mode = 'show',
30
+ src,
31
+ name,
32
+ subtitle,
33
+ status,
34
+ size = 'sm',
35
+ shape = 'circle',
36
+ showName = false,
37
+ nullLabel = '—',
38
+ class: className = '',
39
+ }: Props = $props();
40
+
41
+ const resolvedSrc = $derived.by(() => {
42
+ if (src !== undefined) return src;
43
+ if (typeof value === 'string' && (value.startsWith('http://') || value.startsWith('https://') || value.startsWith('/'))) {
44
+ return value;
45
+ }
46
+ if (value && typeof value === 'object' && 'src' in (value as Record<string, unknown>)) {
47
+ return String((value as Record<string, unknown>).src ?? '');
48
+ }
49
+ return null;
50
+ });
51
+
52
+ const resolvedName = $derived.by(() => {
53
+ if (name !== undefined) return name;
54
+ if (typeof value === 'string' && !value.startsWith('http://') && !value.startsWith('https://') && !value.startsWith('/')) {
55
+ return value;
56
+ }
57
+ if (value && typeof value === 'object' && 'name' in (value as Record<string, unknown>)) {
58
+ return String((value as Record<string, unknown>).name ?? '');
59
+ }
60
+ return null;
61
+ });
62
+
63
+ function getInitials(text?: string | null): string {
64
+ const trimmed = text?.trim();
65
+ if (!trimmed) return '?';
66
+ const parts = trimmed.split(/\s+/);
67
+ if (parts.length >= 2) {
68
+ return `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase();
69
+ }
70
+ return trimmed.slice(0, 2).toUpperCase();
71
+ }
72
+
73
+ const initials = $derived(getInitials(resolvedName));
74
+ const hasContent = $derived(Boolean(resolvedSrc || resolvedName?.trim()));
75
+ const hasError = $derived(error.length > 0);
76
+ </script>
77
+
78
+ {#if mode === 'show'}
79
+ {#if !hasContent}
80
+ <span class="lite-text-muted lite-text-sm {className}">{nullLabel}</span>
81
+ {:else}
82
+ <span class="lite-avatar-wrapper {className}">
83
+ <span class="lite-avatar-container">
84
+ <span class="lite-avatar lite-avatar-{size} lite-avatar-{shape}">
85
+ {#if resolvedSrc}
86
+ <img src={resolvedSrc} alt={resolvedName?.trim() || 'Avatar'} class="lite-avatar-img" />
87
+ {:else}
88
+ <span class="lite-avatar-initials">{initials}</span>
89
+ {/if}
90
+ </span>
91
+ {#if status}
92
+ <span
93
+ class="lite-avatar-dot lite-avatar-dot-{size} lite-avatar-status-{status}"
94
+ title={`Status: ${status}`}
95
+ ></span>
96
+ {/if}
97
+ </span>
98
+ {#if showName && (resolvedName || subtitle)}
99
+ <span class="lite-avatar-text-block">
100
+ {#if resolvedName}
101
+ <span class="lite-avatar-name">{resolvedName}</span>
102
+ {/if}
103
+ {#if subtitle}
104
+ <span class="lite-avatar-subtitle">{subtitle}</span>
105
+ {/if}
106
+ </span>
107
+ {/if}
108
+ </span>
109
+ {/if}
110
+ {:else}
111
+ <div>
112
+ <input
113
+ type="text"
114
+ name={field?.key ?? 'avatar'}
115
+ id={field?.key ?? 'avatar'}
116
+ value={String(resolvedSrc ?? resolvedName ?? value ?? '')}
117
+ class="lite-input {hasError ? 'lite-input-error' : ''}"
118
+ placeholder={field?.label ?? 'Avatar URL or name'}
119
+ {...field?.required ? { required: true } : {}}
120
+ />
121
+ {#if hasError}
122
+ {#each error as err, _i (_i)}
123
+ <div class="lite-error-text">{err}</div>
124
+ {/each}
125
+ {/if}
126
+ </div>
127
+ {/if}
@@ -0,0 +1,21 @@
1
+ export type LiteAvatarStatus = 'online' | 'offline' | 'busy' | 'away' | 'success' | 'warning' | 'error' | 'neutral';
2
+ export type LiteAvatarSize = 'xs' | 'sm' | 'default' | 'lg';
3
+ import type { FieldDefinition } from '@svadmin/core';
4
+ interface Props {
5
+ field?: FieldDefinition;
6
+ value?: unknown;
7
+ error?: string[];
8
+ mode?: 'show' | 'edit' | 'create';
9
+ src?: string | null;
10
+ name?: string | null;
11
+ subtitle?: string | null;
12
+ status?: LiteAvatarStatus;
13
+ size?: LiteAvatarSize;
14
+ shape?: 'circle' | 'square';
15
+ showName?: boolean;
16
+ nullLabel?: string;
17
+ class?: string;
18
+ }
19
+ declare const LiteAvatarField: import("svelte").Component<Props, {}, "">;
20
+ type LiteAvatarField = ReturnType<typeof LiteAvatarField>;
21
+ export default LiteAvatarField;
@@ -0,0 +1,119 @@
1
+ <script lang="ts">
2
+ import type { FieldDefinition } from '@svadmin/core';
3
+ import { t } from '@svadmin/core/i18n';
4
+
5
+ export interface CascaderOption {
6
+ value: string | number;
7
+ label: string;
8
+ children?: CascaderOption[];
9
+ disabled?: boolean;
10
+ isLeaf?: boolean;
11
+ }
12
+
13
+ interface Props {
14
+ field?: FieldDefinition;
15
+ name?: string;
16
+ label?: string;
17
+ value?: (string | number)[];
18
+ options?: CascaderOption[];
19
+ separator?: string;
20
+ placeholder?: string;
21
+ disabled?: boolean;
22
+ required?: boolean;
23
+ error?: string[];
24
+ mode?: 'show' | 'edit' | 'create';
25
+ }
26
+
27
+ let {
28
+ field,
29
+ name = field?.key ?? 'cascader',
30
+ label = field?.label,
31
+ value = [],
32
+ options = [],
33
+ separator = ' / ',
34
+ placeholder,
35
+ disabled = false,
36
+ required = field?.required ?? false,
37
+ error = [],
38
+ mode = 'show',
39
+ }: Props = $props();
40
+
41
+ const hasError = $derived(error.length > 0);
42
+
43
+ interface FlatPathOption {
44
+ pathValue: string;
45
+ pathLabels: string[];
46
+ disabled?: boolean;
47
+ }
48
+
49
+ function generatePaths(
50
+ nodes: CascaderOption[],
51
+ currentValues: (string | number)[] = [],
52
+ currentLabels: string[] = []
53
+ ): FlatPathOption[] {
54
+ const paths: FlatPathOption[] = [];
55
+ for (const node of nodes) {
56
+ const nextValues = [...currentValues, node.value];
57
+ const nextLabels = [...currentLabels, node.label];
58
+
59
+ if (node.children && node.children.length > 0) {
60
+ paths.push(...generatePaths(node.children, nextValues, nextLabels));
61
+ } else {
62
+ paths.push({
63
+ pathValue: nextValues.join('/'),
64
+ pathLabels: nextLabels,
65
+ disabled: node.disabled,
66
+ });
67
+ }
68
+ }
69
+ return paths;
70
+ }
71
+
72
+ const allPaths = $derived(generatePaths(options));
73
+ const currentPathString = $derived(Array.isArray(value) ? value.join('/') : String(value ?? ''));
74
+
75
+ function formatDisplay(v: (string | number)[]): string {
76
+ if (!v || v.length === 0) return '—';
77
+ const str = v.join('/');
78
+ const matched = allPaths.find((p) => p.pathValue === str);
79
+ if (matched) return matched.pathLabels.join(separator);
80
+ return v.join(separator);
81
+ }
82
+ </script>
83
+
84
+ {#if mode === 'show'}
85
+ <span class="lite-badge">{formatDisplay(value)}</span>
86
+ {:else}
87
+ <div class="lite-form-group">
88
+ {#if label}
89
+ <label class="lite-label" for={name}>
90
+ {label}
91
+ {#if required}<span class="required">*</span>{/if}
92
+ </label>
93
+ {/if}
94
+ <select
95
+ id={name}
96
+ {name}
97
+ class="lite-select {hasError ? 'lite-input-error' : ''}"
98
+ {disabled}
99
+ {required}
100
+ value={currentPathString}
101
+ >
102
+ <option value="">-- {placeholder || t('common.select') || 'Select Path'} --</option>
103
+ {#each allPaths as p (p.pathValue)}
104
+ <option
105
+ value={p.pathValue}
106
+ disabled={p.disabled}
107
+ selected={p.pathValue === currentPathString}
108
+ >
109
+ {p.pathLabels.join(separator)}
110
+ </option>
111
+ {/each}
112
+ </select>
113
+ {#if hasError}
114
+ {#each error as err, i (i)}
115
+ <div class="lite-error-text">{err}</div>
116
+ {/each}
117
+ {/if}
118
+ </div>
119
+ {/if}
@@ -0,0 +1,24 @@
1
+ import type { FieldDefinition } from '@svadmin/core';
2
+ export interface CascaderOption {
3
+ value: string | number;
4
+ label: string;
5
+ children?: CascaderOption[];
6
+ disabled?: boolean;
7
+ isLeaf?: boolean;
8
+ }
9
+ interface Props {
10
+ field?: FieldDefinition;
11
+ name?: string;
12
+ label?: string;
13
+ value?: (string | number)[];
14
+ options?: CascaderOption[];
15
+ separator?: string;
16
+ placeholder?: string;
17
+ disabled?: boolean;
18
+ required?: boolean;
19
+ error?: string[];
20
+ mode?: 'show' | 'edit' | 'create';
21
+ }
22
+ declare const LiteCascader: import("svelte").Component<Props, {}, "">;
23
+ type LiteCascader = ReturnType<typeof LiteCascader>;
24
+ export default LiteCascader;
@@ -0,0 +1,71 @@
1
+ <script lang="ts">
2
+ import type { FieldDefinition } from '@svadmin/core';
3
+
4
+ interface Props {
5
+ field?: FieldDefinition;
6
+ value?: string | number | Record<string, unknown> | unknown[] | null;
7
+ language?: string;
8
+ copyable?: boolean;
9
+ title?: string;
10
+ nullLabel?: string;
11
+ maxHeight?: string;
12
+ class?: string;
13
+ error?: string[];
14
+ mode?: 'show' | 'edit' | 'create';
15
+ }
16
+
17
+ let {
18
+ field,
19
+ value,
20
+ language,
21
+ nullLabel = '—',
22
+ maxHeight = '200px',
23
+ class: className = '',
24
+ error = [],
25
+ mode = 'show',
26
+ }: Props = $props();
27
+
28
+ const formattedCode = $derived.by(() => {
29
+ if (value == null || value === '') return '';
30
+ if (typeof value === 'string') return value;
31
+ if (typeof value === 'number' || typeof value === 'boolean') return String(value);
32
+ try {
33
+ return JSON.stringify(value, null, 2);
34
+ } catch {
35
+ return String(value);
36
+ }
37
+ });
38
+
39
+ const hasError = $derived(error.length > 0);
40
+ </script>
41
+
42
+ {#if mode === 'show'}
43
+ {#if !formattedCode}
44
+ <span class="lite-text-muted lite-text-sm {className}">{nullLabel}</span>
45
+ {:else}
46
+ <div class="lite-code-block {className}">
47
+ {#if language}
48
+ <div class="lite-code-header">
49
+ <span class="lite-badge">{language.toUpperCase()}</span>
50
+ </div>
51
+ {/if}
52
+ <pre class="lite-code-pre" style="max-height: {maxHeight};"><code>{formattedCode}</code></pre>
53
+ </div>
54
+ {/if}
55
+ {:else}
56
+ <div>
57
+ <textarea
58
+ name={field?.key ?? 'code'}
59
+ id={field?.key ?? 'code'}
60
+ class="lite-input {hasError ? 'lite-input-error' : ''}"
61
+ style="min-height: 120px; font-family: monospace; font-size: 12px;"
62
+ placeholder={field?.label ?? 'Code / content'}
63
+ {...field?.required ? { required: true } : {}}
64
+ >{formattedCode}</textarea>
65
+ {#if hasError}
66
+ {#each error as err, _i (_i)}
67
+ <div class="lite-error-text">{err}</div>
68
+ {/each}
69
+ {/if}
70
+ </div>
71
+ {/if}
@@ -0,0 +1,16 @@
1
+ import type { FieldDefinition } from '@svadmin/core';
2
+ interface Props {
3
+ field?: FieldDefinition;
4
+ value?: string | number | Record<string, unknown> | unknown[] | null;
5
+ language?: string;
6
+ copyable?: boolean;
7
+ title?: string;
8
+ nullLabel?: string;
9
+ maxHeight?: string;
10
+ class?: string;
11
+ error?: string[];
12
+ mode?: 'show' | 'edit' | 'create';
13
+ }
14
+ declare const LiteCodeField: import("svelte").Component<Props, {}, "">;
15
+ type LiteCodeField = ReturnType<typeof LiteCodeField>;
16
+ export default LiteCodeField;
@@ -0,0 +1,74 @@
1
+ <script lang="ts">
2
+ import type { FieldDefinition } from '@svadmin/core';
3
+
4
+ interface Props {
5
+ field?: FieldDefinition;
6
+ value?: string | number | null;
7
+ displayValue?: string;
8
+ masked?: boolean;
9
+ monospace?: boolean;
10
+ copyable?: boolean;
11
+ title?: string;
12
+ nullLabel?: string;
13
+ oncopy?: (value: string) => void;
14
+ class?: string;
15
+ error?: string[];
16
+ mode?: 'show' | 'edit' | 'create';
17
+ }
18
+
19
+ let {
20
+ field,
21
+ value,
22
+ displayValue,
23
+ masked = false,
24
+ monospace = true,
25
+ nullLabel = '—',
26
+ class: className = '',
27
+ error = [],
28
+ mode = 'show',
29
+ }: Props = $props();
30
+
31
+ function maskText(str: string): string {
32
+ if (str.length <= 8) return '****';
33
+ return `${str.slice(0, 4)}...${str.slice(-4)}`;
34
+ }
35
+
36
+ const rawString = $derived(value != null && value !== '' ? String(value) : '');
37
+ const displayText = $derived.by(() => {
38
+ if (!rawString) return nullLabel;
39
+ if (displayValue) return displayValue;
40
+ if (masked) return maskText(rawString);
41
+ return rawString;
42
+ });
43
+
44
+ const hasError = $derived(error.length > 0);
45
+ </script>
46
+
47
+ {#if mode === 'show'}
48
+ {#if !rawString}
49
+ <span class="lite-text-muted lite-text-sm {className}">{nullLabel}</span>
50
+ {:else}
51
+ <span class="lite-copy-field {className}">
52
+ <span class="lite-copy-text {monospace ? 'lite-font-mono' : ''}">
53
+ {displayText}
54
+ </span>
55
+ </span>
56
+ {/if}
57
+ {:else}
58
+ <div>
59
+ <input
60
+ type="text"
61
+ name={field?.key ?? 'copy_text'}
62
+ id={field?.key ?? 'copy_text'}
63
+ value={rawString}
64
+ class="lite-input {hasError ? 'lite-input-error' : ''}"
65
+ placeholder={field?.label ?? 'Value'}
66
+ {...field?.required ? { required: true } : {}}
67
+ />
68
+ {#if hasError}
69
+ {#each error as err, _i (_i)}
70
+ <div class="lite-error-text">{err}</div>
71
+ {/each}
72
+ {/if}
73
+ </div>
74
+ {/if}
@@ -0,0 +1,18 @@
1
+ import type { FieldDefinition } from '@svadmin/core';
2
+ interface Props {
3
+ field?: FieldDefinition;
4
+ value?: string | number | null;
5
+ displayValue?: string;
6
+ masked?: boolean;
7
+ monospace?: boolean;
8
+ copyable?: boolean;
9
+ title?: string;
10
+ nullLabel?: string;
11
+ oncopy?: (value: string) => void;
12
+ class?: string;
13
+ error?: string[];
14
+ mode?: 'show' | 'edit' | 'create';
15
+ }
16
+ declare const LiteCopyField: import("svelte").Component<Props, {}, "">;
17
+ type LiteCopyField = ReturnType<typeof LiteCopyField>;
18
+ export default LiteCopyField;