@poirazis/supercomponents-shared 1.2.12 → 1.2.13
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/dist/index.js +11250 -11204
- package/dist/index.umd.cjs +15 -15
- package/package.json +1 -1
- package/src/lib/SuperForm/InnerForm.svelte +68 -19
- package/src/lib/SuperForm/SuperForm.svelte +13 -3
- package/src/lib/SuperTable/SuperTable.css +9 -6
- package/src/lib/SuperTable/SuperTable.svelte +207 -193
- package/src/lib/SuperTable/controls/ColumnsSection.svelte +11 -19
- package/src/lib/SuperTable/controls/RowButtonsColumn.svelte +4 -4
- package/src/lib/SuperTable/controls/SelectionColumn.svelte +9 -10
- package/src/lib/SuperTable/overlays/AddNewRowOverlay.svelte +1 -1
- package/src/lib/SuperTableCells/CellBoolean.svelte +0 -1
- package/src/lib/SuperTableCells/CellCommon.css +59 -88
- package/src/lib/SuperTableCells/CellDateRange.svelte +3 -4
- package/src/lib/SuperTableCells/CellDatetime.svelte +3 -4
- package/src/lib/SuperTableCells/CellJSON.svelte +1 -4
- package/src/lib/SuperTableCells/CellLink.svelte +20 -25
- package/src/lib/SuperTableCells/CellLinkAdvanced.svelte +3 -7
- package/src/lib/SuperTableCells/CellLinkPickerSelect.svelte +7 -4
- package/src/lib/SuperTableCells/CellNumber.svelte +18 -23
- package/src/lib/SuperTableCells/CellOptions.svelte +34 -31
- package/src/lib/SuperTableCells/CellSQLLink.svelte +84 -64
- package/src/lib/SuperTableCells/CellSQLLinkPicker.svelte +66 -36
- package/src/lib/SuperTableCells/CellString.svelte +9 -25
- package/src/lib/SuperTableCells/CellStringMask.svelte +0 -4
- package/src/lib/SuperTableCells/CellStringSimple.svelte +6 -8
- package/src/lib/SuperTableColumn/SuperTableColumn.svelte +10 -10
- package/src/lib/SuperTableColumn/parts/SuperColumnHeader.svelte +4 -1
- package/src/lib/SuperTableColumn/parts/SuperColumnRow.svelte +25 -21
- package/src/lib/SuperTabs/SuperTabs.svelte +7 -12
- package/src/lib/SuperTable/controls/SuperTableWelcome.svelte +0 -58
package/package.json
CHANGED
|
@@ -47,11 +47,18 @@
|
|
|
47
47
|
export let disableSchemaValidation: boolean = false;
|
|
48
48
|
export let editAutoColumns: boolean = false;
|
|
49
49
|
export let provideContext: boolean = true;
|
|
50
|
+
export let provideContextScope: "local" | "global" = "global";
|
|
50
51
|
export let currentStep: Writable<number>;
|
|
51
52
|
export let formValue: Record<string, any> = {};
|
|
53
|
+
export let labelPosition: string | boolean = "above";
|
|
54
|
+
export let columns: number = 1;
|
|
52
55
|
|
|
53
|
-
const {
|
|
54
|
-
|
|
56
|
+
const {
|
|
57
|
+
Provider,
|
|
58
|
+
ActionTypes,
|
|
59
|
+
createValidatorFromConstraints,
|
|
60
|
+
ContextScopes,
|
|
61
|
+
} = getContext("sdk");
|
|
55
62
|
|
|
56
63
|
let fields: Writable<FieldInfo>[] = [];
|
|
57
64
|
export const formState = writable({
|
|
@@ -76,7 +83,7 @@
|
|
|
76
83
|
return !fieldsValue
|
|
77
84
|
.filter((f) => f.step === currentStepValue)
|
|
78
85
|
.some((f) => f.fieldState.error != null);
|
|
79
|
-
}
|
|
86
|
+
},
|
|
80
87
|
);
|
|
81
88
|
|
|
82
89
|
// Offer the form as a bindable property so it can be puppeteered by parent components
|
|
@@ -111,19 +118,19 @@
|
|
|
111
118
|
|
|
112
119
|
const deriveFieldProperty = (
|
|
113
120
|
fieldStores: Readable<FieldInfo>[],
|
|
114
|
-
getProp: (_field: FieldInfo) => any
|
|
121
|
+
getProp: (_field: FieldInfo) => any,
|
|
115
122
|
) => {
|
|
116
123
|
return derived(fieldStores, (fieldValues) => {
|
|
117
124
|
return fieldValues.reduce(
|
|
118
125
|
(map, field) => ({ ...map, [field.name]: getProp(field) }),
|
|
119
|
-
{}
|
|
126
|
+
{},
|
|
120
127
|
);
|
|
121
128
|
});
|
|
122
129
|
};
|
|
123
130
|
|
|
124
131
|
const deriveDirtyStatus = (
|
|
125
132
|
fieldStores: Readable<FieldInfo>[],
|
|
126
|
-
initialValues: Record<string, any> | undefined
|
|
133
|
+
initialValues: Record<string, any> | undefined,
|
|
127
134
|
) => {
|
|
128
135
|
return derived(fieldStores, (fieldValues) => {
|
|
129
136
|
return fieldValues.some((field) => {
|
|
@@ -154,7 +161,7 @@
|
|
|
154
161
|
const deriveFormValue = (
|
|
155
162
|
initialValues: Record<string, any> | undefined,
|
|
156
163
|
values: Record<string, any>,
|
|
157
|
-
enrichments: Record<string, string
|
|
164
|
+
enrichments: Record<string, string>,
|
|
158
165
|
) => {
|
|
159
166
|
let formValue = cloneDeep(initialValues || {});
|
|
160
167
|
const sortedFields = Object.entries(values || {})
|
|
@@ -186,7 +193,7 @@
|
|
|
186
193
|
const sanitiseValue = (
|
|
187
194
|
value: any,
|
|
188
195
|
schema: FieldSchema | undefined,
|
|
189
|
-
type: `${FieldType}
|
|
196
|
+
type: `${FieldType}`,
|
|
190
197
|
) => {
|
|
191
198
|
if (Array.isArray(value) && type === "array" && schema) {
|
|
192
199
|
const options = schema?.constraints?.inclusion || [];
|
|
@@ -205,7 +212,7 @@
|
|
|
205
212
|
fieldDisabled: boolean = false,
|
|
206
213
|
fieldReadOnly: boolean = false,
|
|
207
214
|
validationRules: UIFieldValidationRule[],
|
|
208
|
-
step: number = 1
|
|
215
|
+
step: number = 1,
|
|
209
216
|
) => {
|
|
210
217
|
if (!field) {
|
|
211
218
|
return;
|
|
@@ -217,7 +224,7 @@
|
|
|
217
224
|
schemaConstraints,
|
|
218
225
|
validationRules,
|
|
219
226
|
field,
|
|
220
|
-
definition
|
|
227
|
+
definition,
|
|
221
228
|
);
|
|
222
229
|
|
|
223
230
|
defaultValue = sanitiseValue(defaultValue, schema?.[field], type);
|
|
@@ -272,7 +279,7 @@
|
|
|
272
279
|
},
|
|
273
280
|
validate: () => {
|
|
274
281
|
const stepFields = fields.filter(
|
|
275
|
-
(field) => get(field).step === get(currentStep)
|
|
282
|
+
(field) => get(field).step === get(currentStep),
|
|
276
283
|
);
|
|
277
284
|
|
|
278
285
|
let valid = true;
|
|
@@ -418,6 +425,8 @@
|
|
|
418
425
|
});
|
|
419
426
|
|
|
420
427
|
setContext("form-step", writable(1));
|
|
428
|
+
$: setContext("field-group", labelPosition);
|
|
429
|
+
$: setContext("field-group-columns", columns);
|
|
421
430
|
|
|
422
431
|
const handleUpdateFieldValue = ({
|
|
423
432
|
type,
|
|
@@ -443,7 +452,7 @@
|
|
|
443
452
|
// Special case: update multiple fields from the value object
|
|
444
453
|
Object.keys(parsedValue).forEach((key) => {
|
|
445
454
|
const fieldStore = fields.find(
|
|
446
|
-
(field) => get(field).name.toLowerCase() === key.toLowerCase()
|
|
455
|
+
(field) => get(field).name.toLowerCase() === key.toLowerCase(),
|
|
447
456
|
);
|
|
448
457
|
if (fieldStore) {
|
|
449
458
|
const actualFieldName = get(fieldStore).name;
|
|
@@ -475,7 +484,7 @@
|
|
|
475
484
|
fieldElement.focus({ preventScroll: true });
|
|
476
485
|
}
|
|
477
486
|
const label = document.querySelector<HTMLElement>(
|
|
478
|
-
`label[for="${fieldId}"]
|
|
487
|
+
`label[for="${fieldId}"]`,
|
|
479
488
|
);
|
|
480
489
|
if (label) {
|
|
481
490
|
label.style.scrollMargin = "100px";
|
|
@@ -571,10 +580,50 @@
|
|
|
571
580
|
};
|
|
572
581
|
</script>
|
|
573
582
|
|
|
574
|
-
{#
|
|
575
|
-
|
|
583
|
+
{#key labelPosition}
|
|
584
|
+
{#if provideContext}
|
|
585
|
+
<Provider
|
|
586
|
+
{actions}
|
|
587
|
+
data={dataContext}
|
|
588
|
+
scope={provideContextScope === "local"
|
|
589
|
+
? ContextScopes.Local
|
|
590
|
+
: ContextScopes.Global}
|
|
591
|
+
>
|
|
592
|
+
<div
|
|
593
|
+
class="super-form-inner-form"
|
|
594
|
+
class:labels-left={labelPosition === "left"}
|
|
595
|
+
class:no-labels={labelPosition === false || labelPosition === "none"}
|
|
596
|
+
class:field-group={columns > 1}
|
|
597
|
+
style:grid-template-columns={`repeat(${columns * 6}, 1fr)`}
|
|
598
|
+
>
|
|
599
|
+
<slot />
|
|
600
|
+
</div>
|
|
601
|
+
</Provider>
|
|
602
|
+
{:else}
|
|
576
603
|
<slot />
|
|
577
|
-
|
|
578
|
-
{
|
|
579
|
-
|
|
580
|
-
|
|
604
|
+
{/if}
|
|
605
|
+
{/key}
|
|
606
|
+
|
|
607
|
+
<style>
|
|
608
|
+
.super-form-inner-form {
|
|
609
|
+
flex: auto;
|
|
610
|
+
display: flex;
|
|
611
|
+
flex-direction: column;
|
|
612
|
+
}
|
|
613
|
+
.super-form-inner-form.field-group {
|
|
614
|
+
flex: auto;
|
|
615
|
+
display: grid;
|
|
616
|
+
column-gap: 0.5rem;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
:global(.super-form-inner-form.field-group > .component > *) {
|
|
620
|
+
grid-column: span 6;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.super-form-inner-form.labels-left {
|
|
624
|
+
row-gap: 0.25rem;
|
|
625
|
+
}
|
|
626
|
+
.super-form-inner-form.no-labels {
|
|
627
|
+
row-gap: 0.25rem;
|
|
628
|
+
}
|
|
629
|
+
</style>
|
|
@@ -28,12 +28,15 @@
|
|
|
28
28
|
export let disableSchemaValidation: boolean = false;
|
|
29
29
|
export let editAutoColumns: boolean = false;
|
|
30
30
|
export let provideContext: boolean = true;
|
|
31
|
+
export let provideContextScope: "local" | "global" = "global";
|
|
32
|
+
export let labelPosition: "above" | "left" | false;
|
|
31
33
|
|
|
32
34
|
// Export the full form API to be used by parents
|
|
33
35
|
export let form;
|
|
34
36
|
export let formState;
|
|
35
37
|
export let formValue: Record<string, any> = {};
|
|
36
38
|
export let row;
|
|
39
|
+
export let columns: number = 1;
|
|
37
40
|
|
|
38
41
|
const context = getContext("context");
|
|
39
42
|
const component = getContext("component");
|
|
@@ -61,17 +64,21 @@
|
|
|
61
64
|
dataSource,
|
|
62
65
|
$component.path,
|
|
63
66
|
$context,
|
|
64
|
-
row
|
|
67
|
+
row,
|
|
65
68
|
);
|
|
66
69
|
$: resetKey = hashString(
|
|
67
|
-
schemaKey +
|
|
70
|
+
schemaKey +
|
|
71
|
+
JSON.stringify(initialValues) +
|
|
72
|
+
actionType +
|
|
73
|
+
readonly +
|
|
74
|
+
disabled,
|
|
68
75
|
);
|
|
69
76
|
|
|
70
77
|
const getInitialValues = (
|
|
71
78
|
type: string,
|
|
72
79
|
dataSource: DataFetchDatasource,
|
|
73
80
|
path: string[],
|
|
74
|
-
context: Record<string, any
|
|
81
|
+
context: Record<string, any>,
|
|
75
82
|
) => {
|
|
76
83
|
if (type !== "Update" && type !== "View") {
|
|
77
84
|
return {};
|
|
@@ -141,7 +148,10 @@
|
|
|
141
148
|
{disableSchemaValidation}
|
|
142
149
|
{editAutoColumns}
|
|
143
150
|
{currentStep}
|
|
151
|
+
{columns}
|
|
144
152
|
{provideContext}
|
|
153
|
+
{provideContextScope}
|
|
154
|
+
{labelPosition}
|
|
145
155
|
on:change
|
|
146
156
|
on:reset
|
|
147
157
|
>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
border: 1px solid var(--spectrum-global-color-gray-300);
|
|
6
6
|
background: var(--spectrum-global-color-gray-50);
|
|
7
7
|
color: var(--spectrum-global-color-gray-800);
|
|
8
|
+
border-radius: 0.25rem;
|
|
8
9
|
overflow: hidden;
|
|
9
10
|
height: 360px;
|
|
10
11
|
--row-selection-color: rgba(75, 117, 255, 0.15);
|
|
@@ -144,7 +145,7 @@
|
|
|
144
145
|
height: var(--super-table-header-height);
|
|
145
146
|
padding: unset;
|
|
146
147
|
flex: none;
|
|
147
|
-
z-index:
|
|
148
|
+
z-index: 2;
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
.super-column-header {
|
|
@@ -178,6 +179,7 @@
|
|
|
178
179
|
min-height: var(--super-table-header-height);
|
|
179
180
|
padding: 0 0.75rem;
|
|
180
181
|
gap: 1rem;
|
|
182
|
+
z-index: 2;
|
|
181
183
|
|
|
182
184
|
.row-number {
|
|
183
185
|
min-width: 1.25rem;
|
|
@@ -231,7 +233,7 @@
|
|
|
231
233
|
border-bottom-color: var(--spectrum-global-color-green-400);
|
|
232
234
|
}
|
|
233
235
|
|
|
234
|
-
&.
|
|
236
|
+
&.hovered {
|
|
235
237
|
color: var(--spectrum-global-color-gray-900);
|
|
236
238
|
background: var(
|
|
237
239
|
--row-hover-color,
|
|
@@ -243,12 +245,12 @@
|
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
&.
|
|
248
|
+
&.selected {
|
|
247
249
|
color: var(--spectrum-global-color-gray-900);
|
|
248
250
|
background-color: var(--row-selection-color) !important;
|
|
249
251
|
}
|
|
250
252
|
|
|
251
|
-
&.
|
|
253
|
+
&.disabled {
|
|
252
254
|
color: var(--spectrum-global-color-gray-500) !important;
|
|
253
255
|
font-style: italic;
|
|
254
256
|
}
|
|
@@ -266,8 +268,9 @@
|
|
|
266
268
|
.row-number {
|
|
267
269
|
min-width: 1.25rem;
|
|
268
270
|
text-align: right;
|
|
269
|
-
color: var(--spectrum-global-color-gray-
|
|
270
|
-
font-size:
|
|
271
|
+
color: var(--spectrum-global-color-gray-600);
|
|
272
|
+
font-size: 12px;
|
|
273
|
+
font-family: monospace;
|
|
271
274
|
}
|
|
272
275
|
|
|
273
276
|
.contents-wrapper {
|