@parallelworks/ui 0.12.1 → 0.14.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/dist/chunks/{BareModal-DBa84JZO.js → BareModal-BqroLbZ5.js} +1 -0
- package/dist/chunks/{CodePreviewEditor-hwjZof0M.js → CodePreviewEditor-67A_SKgE.js} +1 -1
- package/dist/chunks/{CreateModal-DLCC8t_x.js → CreateModal-DoA2WsXf.js} +28 -8
- package/dist/chunks/{Monaco-DCwRDrPm.js → Monaco-H56KyEdb.js} +22 -12
- package/dist/chunks/{PageHeader-dyoL44ue.js → PageHeader-CxxbidPp.js} +44 -10
- package/dist/chunks/{Provider-CfFV-vc5.js → Provider-CbFVFB7O.js} +8 -2
- package/dist/chunks/RequiredMark-DfLdYbYZ.js +11 -0
- package/dist/chunks/{StatusBadge-P6C2tv7Z.js → StatusBadge-RRUI78iS.js} +4 -4
- package/dist/chunks/{SwitchToggle-DcPCXkqL.js → SwitchToggle-DbW0Q__L.js} +49 -32
- package/dist/chunks/{Table-ByziK93x.js → Table-CutP1bRt.js} +22 -6
- package/dist/chunks/{Tooltip-WgbiC_nd.js → Tooltip-n9w7Tkt1.js} +28 -3
- package/dist/chunks/{editor-BH81U5-C.js → editor-BZ9Buwi4.js} +34 -23
- package/dist/chunks/lib-DyJvmbzj.js +256 -0
- package/dist/chunks/{list-CWVR3dfZ.js → list-CBZpAYP7.js} +35 -15
- package/dist/components/Breadcrumbs.d.ts +9 -0
- package/dist/components/CollapsiblePanel.d.ts +4 -4
- package/dist/components/CreateModal.d.ts +8 -8
- package/dist/components/Dropdown.d.ts +5 -3
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Listbox.d.ts +7 -4
- package/dist/components/Loader.d.ts +1 -1
- package/dist/components/MultiSelect.d.ts +8 -5
- package/dist/components/PageHeader.d.ts +4 -3
- package/dist/components/Pagination.d.ts +2 -2
- package/dist/components/Provider.d.ts +9 -3
- package/dist/components/RequiredMark.d.ts +1 -0
- package/dist/components/SettingRow.d.ts +1 -1
- package/dist/components/SwitchToggle.d.ts +3 -2
- package/dist/components/Table.d.ts +5 -3
- package/dist/components/Tooltip.d.ts +7 -1
- package/dist/components/dropdownUtils.d.ts +6 -6
- package/dist/editor/FormCodePanel.d.ts +3 -3
- package/dist/editor/Monaco.d.ts +2 -2
- package/dist/editor/index.js +1 -1
- package/dist/file-explorer/FileExplorer.d.ts +2 -2
- package/dist/file-explorer/helpers.d.ts +2 -2
- package/dist/file-explorer/index.js +46 -18
- package/dist/file-explorer/lib/fileExplorer.d.ts +1 -1
- package/dist/file-explorer/lib/types.d.ts +21 -21
- package/dist/form/FieldWrapper.d.ts +6 -1
- package/dist/form/Fields/ResourceOptionIcon.d.ts +1 -1
- package/dist/form/Fields/StepField.d.ts +1 -1
- package/dist/form/Form.d.ts +28 -27
- package/dist/form/SpecialTypes/DropdownWrapper.d.ts +16 -3
- package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +11 -11
- package/dist/form/SpecialTypes/FormikCustomInput.d.ts +12 -10
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.d.ts +1 -1
- package/dist/form/SpecialTypes/FormikNumericInput.d.ts +2 -2
- package/dist/form/Wizard/WizardContainer.d.ts +1 -1
- package/dist/form/Wizard/WizardStepContent.d.ts +2 -2
- package/dist/form/Wizard/types.d.ts +21 -14
- package/dist/form/Wizard/utils.d.ts +1 -1
- package/dist/form/fieldContext.d.ts +19 -0
- package/dist/form/index.d.ts +2 -1
- package/dist/form/index.js +191 -106
- package/dist/form/lib.d.ts +3 -3
- package/dist/form/types/fieldComponentTypes.d.ts +2 -2
- package/dist/form/useParsedOpts.d.ts +1 -1
- package/dist/form/utils/getParentValue.d.ts +3 -1
- package/dist/form/utils/getValueUsingPath.d.ts +1 -1
- package/dist/form/utils/pwResolver.d.ts +4 -4
- package/dist/icons.d.ts +8 -8
- package/dist/icons.js +4 -4
- package/dist/index.d.ts +4 -3
- package/dist/index.js +51 -21
- package/dist/list/ActionToolbar.d.ts +4 -4
- package/dist/list/HoverCard.d.ts +3 -1
- package/dist/list/ListPage.d.ts +3 -3
- package/dist/list/ListTable.d.ts +1 -1
- package/dist/list/RowContextMenu.d.ts +20 -20
- package/dist/list/index.js +2 -2
- package/dist/logviewer/index.js +24 -7
- package/dist/styles/theme.css +6 -6
- package/dist/styles.css +1 -1
- package/dist/theme/index.js +4 -3
- package/dist/workflow/AnnotationBanner.d.ts +2 -1
- package/dist/workflow/DependencyGraph.d.ts +15 -3
- package/dist/workflow/JobSummary.d.ts +2 -25
- package/dist/workflow/MatrixGroup.d.ts +3 -2
- package/dist/workflow/TreeView.d.ts +1 -32
- package/dist/workflow/index.js +235 -138
- package/dist/workflow/types.d.ts +48 -0
- package/package.json +2 -6
- package/dist/chunks/lib-DTgL8klR.js +0 -191
package/dist/form/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AngleRightIcon, EyeIcon, EyeOffIcon, SuccessCheckmark, TrashIcon } from "../icons.js";
|
|
2
|
-
import { c as useStrings, s as useSlots } from "../chunks/Provider-
|
|
3
|
-
import { n as TOOLTIP_ID, r as TooltipInfo } from "../chunks/Tooltip-
|
|
4
|
-
import { n as StatusDot, s as isCategory } from "../chunks/StatusBadge-
|
|
5
|
-
import { a as UncontrolledCollapsiblePanel, c as Dropdown, n as SectionHeader, o as MultiSelectDropdown, r as ControlledCollapsiblePanel, s as CustomListbox, t as SwitchToggle } from "../chunks/SwitchToggle-
|
|
2
|
+
import { c as useStrings, s as useSlots } from "../chunks/Provider-CbFVFB7O.js";
|
|
3
|
+
import { n as TOOLTIP_ID, r as TooltipInfo } from "../chunks/Tooltip-n9w7Tkt1.js";
|
|
4
|
+
import { n as StatusDot, s as isCategory } from "../chunks/StatusBadge-RRUI78iS.js";
|
|
5
|
+
import { a as UncontrolledCollapsiblePanel, c as Dropdown, n as SectionHeader, o as MultiSelectDropdown, r as ControlledCollapsiblePanel, s as CustomListbox, t as SwitchToggle } from "../chunks/SwitchToggle-DbW0Q__L.js";
|
|
6
6
|
import { t as Loader } from "../chunks/Loader-BXoXTZGc.js";
|
|
7
|
-
import { n as Table } from "../chunks/Table-
|
|
8
|
-
import { a as resolvedFlag, c as FieldWrapper, i as initializeValues, n as flattenGroups, o as applySecondaryField, r as impureSetValueFromPath, s as findSecondaryOption, t as enforceOneMustBeTrue } from "../chunks/lib-
|
|
7
|
+
import { n as Table } from "../chunks/Table-CutP1bRt.js";
|
|
8
|
+
import { a as resolvedFlag, c as FieldWrapper, d as useFieldLabelledByProps, f as useFieldRequired, i as initializeValues, l as FieldProvider, n as flattenGroups, o as applySecondaryField, r as impureSetValueFromPath, s as findSecondaryOption, t as enforceOneMustBeTrue, u as useFieldControlProps } from "../chunks/lib-DyJvmbzj.js";
|
|
9
9
|
import cx from "classnames";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import React, { Suspense, createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
11
|
+
import React, { Suspense, createContext, memo, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
12
12
|
import deepEqual from "fast-deep-equal";
|
|
13
13
|
import { Duration } from "luxon";
|
|
14
14
|
import { callWhenParserInitialized, convertToDynamicForm, extractInputDeps, initializeParseStringsOfObj, parseStringsOfObj, parseStringsOfObjReady } from "@parallelworks/workflow-parser";
|
|
@@ -21,14 +21,16 @@ function getValueUsingPath(obj, path) {
|
|
|
21
21
|
let current = obj;
|
|
22
22
|
for (const key of keys) {
|
|
23
23
|
if (!current || typeof current !== "object") return;
|
|
24
|
+
const container = current;
|
|
24
25
|
if (key.includes("[")) {
|
|
25
|
-
const [arrayKey, indexStr] = key.split("[");
|
|
26
|
+
const [arrayKey = "", indexStr = ""] = key.split("[");
|
|
26
27
|
const index = parseInt(indexStr.slice(0, -1), 10);
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const list = container[arrayKey];
|
|
29
|
+
if (!Array.isArray(list) || isNaN(index)) return;
|
|
30
|
+
current = list[index];
|
|
29
31
|
} else {
|
|
30
|
-
if (!(key in
|
|
31
|
-
current =
|
|
32
|
+
if (!(key in container)) return;
|
|
33
|
+
current = container[key];
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
return current;
|
|
@@ -40,7 +42,7 @@ function checkShowIfObject(showIfObject, formValues, index) {
|
|
|
40
42
|
for (let [key, value] of Object.entries(showIfObject)) {
|
|
41
43
|
if (index !== void 0) key = key.replace("[index]", `[${index}]`);
|
|
42
44
|
const dependsOnValue = getValueUsingPath(formValues, key);
|
|
43
|
-
if (typeof value === "boolean" || typeof value === "string" || typeof value === "number") valueList.push(dependsOnValue
|
|
45
|
+
if (typeof value === "boolean" || typeof value === "string" || typeof value === "number") valueList.push(dependsOnValue !== null && dependsOnValue !== void 0 && dependsOnValue.toString() === value.toString());
|
|
44
46
|
else if (Array.isArray(value)) valueList.push(value.includes(dependsOnValue));
|
|
45
47
|
}
|
|
46
48
|
return valueList;
|
|
@@ -49,15 +51,18 @@ function checkShowIfObject(showIfObject, formValues, index) {
|
|
|
49
51
|
//#region src/form/utils/getParentValue.ts
|
|
50
52
|
function getParentValue(index, targetField, values, dependentPath, field) {
|
|
51
53
|
let parentValue;
|
|
52
|
-
if (typeof targetField === "object" && !Array.isArray(targetField)) parentValue = !checkShowIfObject(targetField, values, index).includes(false);
|
|
54
|
+
if (typeof targetField === "object" && targetField !== null && !Array.isArray(targetField)) parentValue = !checkShowIfObject(targetField, values, index).includes(false);
|
|
53
55
|
else if (field.depends_on) {
|
|
54
56
|
dependentPath = field.depends_on;
|
|
55
57
|
if (index !== void 0) dependentPath = field.depends_on.replace("[index]", `[${index}]`);
|
|
56
58
|
const dependsOnValue = getValueUsingPath(values, dependentPath);
|
|
57
|
-
|
|
59
|
+
const dependsOnText = dependsOnValue === null || dependsOnValue === void 0 ? void 0 : String(dependsOnValue);
|
|
60
|
+
if (Array.isArray(targetField)) parentValue = targetField.includes(dependsOnValue) || targetField.includes(dependsOnText);
|
|
61
|
+
else if (typeof targetField === "string") parentValue = dependsOnText !== void 0 && targetField.includes(dependsOnText);
|
|
62
|
+
else parentValue = targetField === dependsOnValue;
|
|
58
63
|
} else {
|
|
59
|
-
dependentPath = targetField;
|
|
60
|
-
if (index !== void 0) dependentPath = targetField.replace("[index]", `[${index}]`);
|
|
64
|
+
dependentPath = typeof targetField === "string" ? targetField : "";
|
|
65
|
+
if (index !== void 0 && typeof targetField === "string") dependentPath = targetField.replace("[index]", `[${index}]`);
|
|
61
66
|
parentValue = getValueUsingPath(values, dependentPath);
|
|
62
67
|
}
|
|
63
68
|
return parentValue;
|
|
@@ -75,7 +80,7 @@ function useParsedOpts(rawOptions, values, organizationVariables, userVars = EMP
|
|
|
75
80
|
orgVars: void 0,
|
|
76
81
|
userVars: null,
|
|
77
82
|
secretKeys: null,
|
|
78
|
-
converted:
|
|
83
|
+
converted: {},
|
|
79
84
|
inputDeps: /* @__PURE__ */ new Set(),
|
|
80
85
|
hasExpressions: false,
|
|
81
86
|
relevantSnapshot: {},
|
|
@@ -107,16 +112,17 @@ function useParsedOpts(rawOptions, values, organizationVariables, userVars = EMP
|
|
|
107
112
|
}
|
|
108
113
|
if (!inputsChanged) return c.result;
|
|
109
114
|
}
|
|
110
|
-
|
|
115
|
+
const parsed = parseStringsOfObj({
|
|
111
116
|
inputs: values,
|
|
112
117
|
obj: c.converted,
|
|
113
118
|
orgVars: organizationVariables,
|
|
114
119
|
userVars,
|
|
115
120
|
secretKeys
|
|
116
121
|
});
|
|
122
|
+
c.result = parsed;
|
|
117
123
|
c.relevantSnapshot = {};
|
|
118
124
|
for (const key of c.inputDeps) c.relevantSnapshot[key] = values[key];
|
|
119
|
-
return
|
|
125
|
+
return parsed;
|
|
120
126
|
}
|
|
121
127
|
//#endregion
|
|
122
128
|
//#region src/form/usePrevious.ts
|
|
@@ -303,6 +309,7 @@ function WizardStepIndicator({ stepOrder, currentStep, steps, visitedSteps, inva
|
|
|
303
309
|
className: cx({ hidden: status === "completed" }),
|
|
304
310
|
children: index + 1
|
|
305
311
|
}), status === "completed" && /* @__PURE__ */ jsx("svg", {
|
|
312
|
+
"aria-hidden": "true",
|
|
306
313
|
className: "w-4 h-4",
|
|
307
314
|
fill: "none",
|
|
308
315
|
stroke: "currentColor",
|
|
@@ -353,7 +360,7 @@ function WizardStepIndicator({ stepOrder, currentStep, steps, visitedSteps, inva
|
|
|
353
360
|
//#endregion
|
|
354
361
|
//#region src/form/Wizard/useWizardState.ts
|
|
355
362
|
function useWizardState({ stepOrder, steps, validateStep, initialStep }) {
|
|
356
|
-
const firstStep = initialStep || stepOrder[0];
|
|
363
|
+
const firstStep = initialStep || stepOrder[0] || "";
|
|
357
364
|
const [currentStep, setCurrentStep] = useState(firstStep);
|
|
358
365
|
const [visitedSteps, setVisitedSteps] = useState(new Set([firstStep]));
|
|
359
366
|
const [invalidSteps, setInvalidSteps] = useState(/* @__PURE__ */ new Set());
|
|
@@ -387,8 +394,8 @@ function useWizardState({ stepOrder, steps, validateStep, initialStep }) {
|
|
|
387
394
|
}
|
|
388
395
|
markStepInvalid(currentStep, false);
|
|
389
396
|
const nextStepKey = stepOrder[currentStepIndex + 1];
|
|
390
|
-
setCurrentStep(nextStepKey);
|
|
391
|
-
markStepVisited(nextStepKey);
|
|
397
|
+
setCurrentStep(nextStepKey ?? "");
|
|
398
|
+
markStepVisited(nextStepKey ?? "");
|
|
392
399
|
return true;
|
|
393
400
|
}, [
|
|
394
401
|
currentStep,
|
|
@@ -403,7 +410,7 @@ function useWizardState({ stepOrder, steps, validateStep, initialStep }) {
|
|
|
403
410
|
const goToPrevious = useCallback(() => {
|
|
404
411
|
if (!canGoBack) return;
|
|
405
412
|
const prevStepKey = stepOrder[currentStepIndex - 1];
|
|
406
|
-
setCurrentStep(prevStepKey);
|
|
413
|
+
setCurrentStep(prevStepKey ?? "");
|
|
407
414
|
}, [
|
|
408
415
|
canGoBack,
|
|
409
416
|
currentStepIndex,
|
|
@@ -468,6 +475,9 @@ function useWizardState({ stepOrder, steps, validateStep, initialStep }) {
|
|
|
468
475
|
}
|
|
469
476
|
//#endregion
|
|
470
477
|
//#region src/form/Wizard/WizardContainer.tsx
|
|
478
|
+
function hasNestedError(stepErrors, fieldName) {
|
|
479
|
+
return typeof stepErrors === "object" && stepErrors !== null && fieldName in stepErrors;
|
|
480
|
+
}
|
|
471
481
|
function WizardContainer({ wizardConfig, values, onChange, onSubmit, className = "", labelPosition = "left", missingFields = [], spaceCompact = false, workflowForm = false, setFieldValue, setFieldTouched }) {
|
|
472
482
|
const { validateForm, setTouched, touched } = useFormikContext();
|
|
473
483
|
const { config, steps, stepOrder } = wizardConfig;
|
|
@@ -480,7 +490,7 @@ function WizardContainer({ wizardConfig, values, onChange, onSubmit, className =
|
|
|
480
490
|
const stepFieldNames = Object.keys(stepConfig.options);
|
|
481
491
|
const shouldFlatten = config.flatten !== false;
|
|
482
492
|
const errors = await validateForm();
|
|
483
|
-
const hasStepErrors = shouldFlatten ? stepFieldNames.some((fieldName) => errors[fieldName]) : stepFieldNames.some((fieldName) => errors[stepKey]
|
|
493
|
+
const hasStepErrors = shouldFlatten ? stepFieldNames.some((fieldName) => errors[fieldName]) : stepFieldNames.some((fieldName) => hasNestedError(errors[stepKey], fieldName));
|
|
484
494
|
if (hasStepErrors) {
|
|
485
495
|
const touchedFields = stepFieldNames.reduce((acc, fieldName) => {
|
|
486
496
|
acc[fieldName] = true;
|
|
@@ -593,17 +603,23 @@ function WizardContainer({ wizardConfig, values, onChange, onSubmit, className =
|
|
|
593
603
|
}
|
|
594
604
|
//#endregion
|
|
595
605
|
//#region src/form/Wizard/utils.ts
|
|
606
|
+
function isWizardMeta(value) {
|
|
607
|
+
return typeof value === "object" && value !== null && "wizard" in value;
|
|
608
|
+
}
|
|
609
|
+
function isStepField(field) {
|
|
610
|
+
return typeof field === "object" && field !== null && "type" in field && field.type === "step";
|
|
611
|
+
}
|
|
596
612
|
function parseWizardConfig(options) {
|
|
597
|
-
const
|
|
613
|
+
const meta = options["$meta"];
|
|
614
|
+
const wizardConfig = isWizardMeta(meta) ? meta.wizard : void 0;
|
|
598
615
|
if (!wizardConfig || wizardConfig.mode !== "wizard") return null;
|
|
599
616
|
const steps = {};
|
|
600
617
|
const stepOrder = [];
|
|
601
618
|
const otherFields = {};
|
|
602
619
|
Object.entries(options).forEach(([key, field]) => {
|
|
603
620
|
if (key === "$meta") return;
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
steps[key] = fieldConfig;
|
|
621
|
+
if (isStepField(field)) {
|
|
622
|
+
steps[key] = field;
|
|
607
623
|
stepOrder.push(key);
|
|
608
624
|
} else otherFields[key] = field;
|
|
609
625
|
});
|
|
@@ -655,6 +671,8 @@ function arePropsEqual(prev, next) {
|
|
|
655
671
|
return true;
|
|
656
672
|
}
|
|
657
673
|
var FormikCustomDropdown_default = memo(function FormikCustomDropdown({ name, ariaLabel, options, setFormDirty, onChange, parentValue, className, secondaryField, disabled = false, loading = false, invalid = false, autoselect, value, allowCustomValue = false, customValueLabel, placeholder, currentValue, setFieldValue, setFieldTouched }) {
|
|
674
|
+
const required = useFieldRequired();
|
|
675
|
+
const controlProps = useFieldControlProps();
|
|
658
676
|
const prevParentRef = useRef(parentValue);
|
|
659
677
|
const handleChange = (val) => {
|
|
660
678
|
if (secondaryField && typeof options[0] !== "string") {
|
|
@@ -716,8 +734,10 @@ var FormikCustomDropdown_default = memo(function FormikCustomDropdown({ name, ar
|
|
|
716
734
|
autoselect
|
|
717
735
|
]);
|
|
718
736
|
return /* @__PURE__ */ jsx(Dropdown, {
|
|
737
|
+
...controlProps,
|
|
719
738
|
textBoxClassName: cx(className, invalid && "invalid"),
|
|
720
739
|
ariaLabel,
|
|
740
|
+
required,
|
|
721
741
|
onChange: (val) => handleChange(val),
|
|
722
742
|
value: options?.length === 0 && !allowCustomValue ? value : currentValue,
|
|
723
743
|
options,
|
|
@@ -733,6 +753,8 @@ var FormikCustomDropdown_default = memo(function FormikCustomDropdown({ name, ar
|
|
|
733
753
|
var DEBOUNCE_MS$2 = 500;
|
|
734
754
|
function FormikCustomInput({ name, type, step, placeholder, onChange, disabled, min, max, sanitize, invalid = false, lowercase = false, minLength, maxLength, defaultValue = "", value }) {
|
|
735
755
|
const [field] = useField(name);
|
|
756
|
+
const required = useFieldRequired();
|
|
757
|
+
const controlProps = useFieldControlProps();
|
|
736
758
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
737
759
|
const [showPassword, setShowPassword] = useState(false);
|
|
738
760
|
const isPassword = type === "password";
|
|
@@ -764,10 +786,10 @@ function FormikCustomInput({ name, type, step, placeholder, onChange, disabled,
|
|
|
764
786
|
setFieldValue
|
|
765
787
|
]);
|
|
766
788
|
const handleChange = (e) => {
|
|
767
|
-
|
|
768
|
-
|
|
789
|
+
const text = sanitize ? sanitizeName(e.target.value) : e.target.value;
|
|
790
|
+
let val = text;
|
|
769
791
|
if (type === "number") {
|
|
770
|
-
const parsed = parseFloat(
|
|
792
|
+
const parsed = parseFloat(text);
|
|
771
793
|
val = isNaN(parsed) ? void 0 : parsed;
|
|
772
794
|
}
|
|
773
795
|
if (type === "password" && val === "") val = defaultValue;
|
|
@@ -783,9 +805,10 @@ function FormikCustomInput({ name, type, step, placeholder, onChange, disabled,
|
|
|
783
805
|
clearTimeout(debounceRef.current ?? void 0);
|
|
784
806
|
const current = localValue;
|
|
785
807
|
if (current === void 0 || current === null) return;
|
|
786
|
-
|
|
808
|
+
const text = current.toString();
|
|
809
|
+
let val = text;
|
|
787
810
|
if (type === "number") {
|
|
788
|
-
const parsed = parseFloat(
|
|
811
|
+
const parsed = parseFloat(text);
|
|
789
812
|
if (Number.isNaN(parsed)) val = void 0;
|
|
790
813
|
else if (min !== void 0 && parsed < min) val = min;
|
|
791
814
|
else if (max !== void 0 && parsed > max) val = max;
|
|
@@ -797,11 +820,13 @@ function FormikCustomInput({ name, type, step, placeholder, onChange, disabled,
|
|
|
797
820
|
const displayValue = isPassword && localValue === defaultValue ? "" : localValue ?? "";
|
|
798
821
|
const resolvedType = isPassword ? showPassword ? "text" : "password" : type === "string" ? "text" : type;
|
|
799
822
|
const input = /* @__PURE__ */ jsx("input", {
|
|
823
|
+
...controlProps,
|
|
800
824
|
"data-1p-ignore": true,
|
|
801
825
|
className: cx("w-full", disabled && "disabled", invalid && "invalid", isPassword && "pr-8"),
|
|
802
826
|
name,
|
|
803
827
|
value: displayValue,
|
|
804
828
|
type: resolvedType,
|
|
829
|
+
"aria-required": required || void 0,
|
|
805
830
|
disabled,
|
|
806
831
|
placeholder,
|
|
807
832
|
minLength,
|
|
@@ -832,6 +857,8 @@ function FormikCustomInput({ name, type, step, placeholder, onChange, disabled,
|
|
|
832
857
|
var DEBOUNCE_MS$1 = 500;
|
|
833
858
|
function FormikNumericInput({ name, placeholder, onChange, disabled, min, max, invalid = false }) {
|
|
834
859
|
const [field] = useField(name);
|
|
860
|
+
const required = useFieldRequired();
|
|
861
|
+
const controlProps = useFieldControlProps();
|
|
835
862
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
836
863
|
const [localValue, setLocalValue] = useState(field.value);
|
|
837
864
|
const isFocused = useRef(false);
|
|
@@ -856,10 +883,12 @@ function FormikNumericInput({ name, placeholder, onChange, disabled, min, max, i
|
|
|
856
883
|
flush(val);
|
|
857
884
|
};
|
|
858
885
|
return /* @__PURE__ */ jsx(NumericFormat, {
|
|
886
|
+
...controlProps,
|
|
859
887
|
"data-1p-ignore": true,
|
|
860
888
|
className: cx("w-full", disabled && "disabled", invalid && "invalid"),
|
|
861
889
|
name,
|
|
862
|
-
value: localValue,
|
|
890
|
+
...localValue === void 0 ? {} : { value: localValue },
|
|
891
|
+
"aria-required": required || void 0,
|
|
863
892
|
thousandSeparator: ",",
|
|
864
893
|
decimalScale: 20,
|
|
865
894
|
allowNegative: true,
|
|
@@ -984,7 +1013,9 @@ function BooleanField(props) {
|
|
|
984
1013
|
description: field.description,
|
|
985
1014
|
labelPosition,
|
|
986
1015
|
spaceCompact,
|
|
987
|
-
children: options ? /* @__PURE__ */ jsx(SwitchToggle, {
|
|
1016
|
+
children: ({ id, describedBy }) => options ? /* @__PURE__ */ jsx(SwitchToggle, {
|
|
1017
|
+
id,
|
|
1018
|
+
"aria-describedby": describedBy,
|
|
988
1019
|
onChange: (on) => handleChange(on ? options.onOption : options.offOption),
|
|
989
1020
|
value: value === true || value === options.onOption,
|
|
990
1021
|
yesLabel: displayLabel(options.onOption),
|
|
@@ -992,6 +1023,8 @@ function BooleanField(props) {
|
|
|
992
1023
|
disabled,
|
|
993
1024
|
invalid: missing
|
|
994
1025
|
}) : /* @__PURE__ */ jsx(SwitchToggle, {
|
|
1026
|
+
id,
|
|
1027
|
+
"aria-describedby": describedBy,
|
|
995
1028
|
datatip: field.disabled_message,
|
|
996
1029
|
onChange: handleChange,
|
|
997
1030
|
value: value === true || value === "true",
|
|
@@ -1008,7 +1041,7 @@ function DropdownField(props) {
|
|
|
1008
1041
|
let options = Array.isArray(field.options) && field.options || [];
|
|
1009
1042
|
if (field.depends_on) {
|
|
1010
1043
|
parentValue = field.depends_on;
|
|
1011
|
-
if (!Array.isArray(field.options)) options = field.options[parentValue];
|
|
1044
|
+
if (!Array.isArray(field.options)) options = field.options[parentValue] ?? [];
|
|
1012
1045
|
}
|
|
1013
1046
|
const secondaryField = Array.isArray(field.secondaryField) ? field.secondaryField[0] : field.secondaryField;
|
|
1014
1047
|
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
@@ -1055,9 +1088,12 @@ function TextAreaField(props) {
|
|
|
1055
1088
|
description: field.description,
|
|
1056
1089
|
labelPosition,
|
|
1057
1090
|
spaceCompact,
|
|
1058
|
-
children: /* @__PURE__ */ jsx(Field, {
|
|
1091
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsx(Field, {
|
|
1059
1092
|
className: cx("theme-input h-[82px] w-full rounded leading-4 overflow-y-scroll", disabled && "disabled", missing && "border-red-600 focus:border-red-600 focus:ring-red-500"),
|
|
1060
1093
|
as: "textarea",
|
|
1094
|
+
id,
|
|
1095
|
+
"aria-describedby": describedBy,
|
|
1096
|
+
"aria-required": field.optional ? void 0 : true,
|
|
1061
1097
|
name: field.name,
|
|
1062
1098
|
type: "search",
|
|
1063
1099
|
placeholder: getPlaceholder(field.placeholder, field.default),
|
|
@@ -1091,10 +1127,11 @@ function RangeField(props) {
|
|
|
1091
1127
|
tooltipComponent,
|
|
1092
1128
|
labelPosition,
|
|
1093
1129
|
spaceCompact,
|
|
1094
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
1130
|
+
children: ({ id, labelId }) => /* @__PURE__ */ jsxs("div", {
|
|
1095
1131
|
className: "flex items-center",
|
|
1096
1132
|
children: [/* @__PURE__ */ jsx(Field, {
|
|
1097
1133
|
className: cx("theme-input h-7 w-1/3 mr-5 text-center rounded border text-[14px]", disabled && "disabled"),
|
|
1134
|
+
id,
|
|
1098
1135
|
type: "number",
|
|
1099
1136
|
value: currentValue,
|
|
1100
1137
|
min: field.min,
|
|
@@ -1107,6 +1144,8 @@ function RangeField(props) {
|
|
|
1107
1144
|
name: field.name,
|
|
1108
1145
|
value: currentValue,
|
|
1109
1146
|
type: "range",
|
|
1147
|
+
"aria-labelledby": labelId,
|
|
1148
|
+
"aria-required": field.optional ? void 0 : true,
|
|
1110
1149
|
min: field.min,
|
|
1111
1150
|
max: field.max,
|
|
1112
1151
|
step: field.step || 1,
|
|
@@ -1272,20 +1311,23 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
1272
1311
|
flushToFormik(parsed);
|
|
1273
1312
|
}
|
|
1274
1313
|
};
|
|
1275
|
-
return /* @__PURE__ */
|
|
1314
|
+
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
1276
1315
|
optional: field.optional ?? false,
|
|
1277
1316
|
label,
|
|
1278
1317
|
tooltipComponent,
|
|
1279
1318
|
labelPosition,
|
|
1280
1319
|
spaceCompact: spaceCompact ?? false,
|
|
1281
1320
|
...field.description !== void 0 && { description: field.description },
|
|
1282
|
-
children: [
|
|
1321
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1283
1322
|
!isSentinel && /* @__PURE__ */ jsx("input", {
|
|
1284
1323
|
"data-1p-ignore": true,
|
|
1285
1324
|
className: cx("w-full", disabled && "disabled", (missing || error !== null) && "invalid"),
|
|
1325
|
+
id,
|
|
1326
|
+
"aria-describedby": describedBy,
|
|
1286
1327
|
name,
|
|
1287
1328
|
value: text,
|
|
1288
1329
|
type: "text",
|
|
1330
|
+
"aria-required": field.optional ? void 0 : true,
|
|
1289
1331
|
disabled,
|
|
1290
1332
|
placeholder: field.placeholder ?? "DD-HH:MM:SS",
|
|
1291
1333
|
onChange: handleChange,
|
|
@@ -1309,13 +1351,14 @@ var DurationField_default = memo(function DurationField({ field, label, labelPos
|
|
|
1309
1351
|
children: field.disableLabel
|
|
1310
1352
|
})]
|
|
1311
1353
|
})
|
|
1312
|
-
]
|
|
1354
|
+
] })
|
|
1313
1355
|
});
|
|
1314
1356
|
});
|
|
1315
1357
|
//#endregion
|
|
1316
1358
|
//#region src/form/Fields/RadioField.tsx
|
|
1317
1359
|
function RadioField(props) {
|
|
1318
1360
|
const { field, label, labelPosition, missing, disabled, onChange, tooltipComponent, spaceCompact, setFormDirty } = props;
|
|
1361
|
+
const uid = useId();
|
|
1319
1362
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
1320
1363
|
const handleChange = (val) => {
|
|
1321
1364
|
if (disabled) return;
|
|
@@ -1330,11 +1373,17 @@ function RadioField(props) {
|
|
|
1330
1373
|
tooltipComponent,
|
|
1331
1374
|
labelPosition,
|
|
1332
1375
|
spaceCompact,
|
|
1333
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
1376
|
+
children: ({ labelId, describedBy }) => /* @__PURE__ */ jsx("div", {
|
|
1377
|
+
role: "radiogroup",
|
|
1378
|
+
"aria-labelledby": labelId,
|
|
1379
|
+
"aria-describedby": describedBy,
|
|
1380
|
+
"aria-required": field.optional ? void 0 : true,
|
|
1334
1381
|
className: cx("flex", field.optionLabelPosition === "top" ? "flex-col" : "flex-row"),
|
|
1335
1382
|
children: field.options?.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
1383
|
+
htmlFor: `${uid}-${option}`,
|
|
1336
1384
|
className: "capitalize",
|
|
1337
1385
|
children: [/* @__PURE__ */ jsx(Field, {
|
|
1386
|
+
id: `${uid}-${option}`,
|
|
1338
1387
|
className: cx("theme-input mr-1", disabled && "disabled", missing && "invalid"),
|
|
1339
1388
|
name: field.name,
|
|
1340
1389
|
type: "radio",
|
|
@@ -1382,11 +1431,13 @@ function ColorField(props) {
|
|
|
1382
1431
|
tooltipComponent,
|
|
1383
1432
|
labelPosition,
|
|
1384
1433
|
spaceCompact,
|
|
1385
|
-
children: /* @__PURE__ */ jsx(Field, {
|
|
1434
|
+
children: ({ id }) => /* @__PURE__ */ jsx(Field, {
|
|
1386
1435
|
className: "theme-input h-8 w-18 rounded border border-neutral-400 text-[14px] placeholder:text-xs",
|
|
1436
|
+
id,
|
|
1387
1437
|
name: field.name,
|
|
1388
1438
|
value: fieldState.value || "#fbbf24",
|
|
1389
1439
|
type: "color",
|
|
1440
|
+
"aria-required": field.optional ? void 0 : true,
|
|
1390
1441
|
onChange: handleChange
|
|
1391
1442
|
})
|
|
1392
1443
|
});
|
|
@@ -1406,8 +1457,9 @@ function MultiDropdownField({ field, label, tooltipComponent, labelPosition, spa
|
|
|
1406
1457
|
tooltipComponent,
|
|
1407
1458
|
labelPosition,
|
|
1408
1459
|
spaceCompact,
|
|
1409
|
-
children: disabled ? /* @__PURE__ */ jsx(Field, {
|
|
1460
|
+
children: ({ id }) => disabled ? /* @__PURE__ */ jsx(Field, {
|
|
1410
1461
|
className: "theme-input h-7 w-full rounded border text-[14px] placeholder:text-xs",
|
|
1462
|
+
id,
|
|
1411
1463
|
type: "search",
|
|
1412
1464
|
name: field.name,
|
|
1413
1465
|
disabled: true,
|
|
@@ -1461,26 +1513,28 @@ function CheckboxGroupField({ field, label, labelPosition, missing, disabled, on
|
|
|
1461
1513
|
tooltipComponent,
|
|
1462
1514
|
labelPosition,
|
|
1463
1515
|
spaceCompact,
|
|
1464
|
-
children: /* @__PURE__ */ jsx("
|
|
1465
|
-
|
|
1516
|
+
children: ({ labelId, describedBy }) => /* @__PURE__ */ jsx("fieldset", {
|
|
1517
|
+
"aria-labelledby": labelId,
|
|
1518
|
+
"aria-describedby": describedBy,
|
|
1519
|
+
className: "flex min-w-0 max-w-lg flex-col gap-1",
|
|
1466
1520
|
children: field.options?.map((option) => {
|
|
1467
1521
|
const locked = forced.has(option.value);
|
|
1468
1522
|
const optionDisabled = disabled || locked;
|
|
1469
1523
|
return /* @__PURE__ */ jsxs("label", {
|
|
1470
|
-
className: cx("flex items-start gap-2 rounded px-2 py-1 transition-colors", optionDisabled ? "cursor-not-allowed opacity-60" : "cursor-pointer hover:bg-(--theme-hover) has-[:focus-visible]:bg-(--theme-hover)"),
|
|
1524
|
+
className: cx("-mx-2 flex items-start gap-2.5 rounded-md px-2 py-1.5 transition-colors", optionDisabled ? "cursor-not-allowed opacity-60" : "cursor-pointer hover:bg-(--theme-hover) has-[:focus-visible]:bg-(--theme-hover)"),
|
|
1471
1525
|
children: [/* @__PURE__ */ jsx("input", {
|
|
1472
1526
|
type: "checkbox",
|
|
1473
1527
|
checked: manual.includes(option.value) || locked,
|
|
1474
1528
|
disabled: optionDisabled,
|
|
1475
1529
|
onChange: () => handleToggle(option.value),
|
|
1476
|
-
className: cx("mt-
|
|
1530
|
+
className: cx("mt-px h-4 w-4 rounded accent-(--theme-link)", optionDisabled ? "cursor-not-allowed" : "cursor-pointer", missing && "invalid")
|
|
1477
1531
|
}), /* @__PURE__ */ jsxs("div", {
|
|
1478
|
-
className: "flex flex-col",
|
|
1532
|
+
className: "flex min-w-0 flex-col",
|
|
1479
1533
|
children: [/* @__PURE__ */ jsx("span", {
|
|
1480
|
-
className: "font-medium theme-text",
|
|
1534
|
+
className: "text-sm font-medium leading-tight theme-text",
|
|
1481
1535
|
children: option.label
|
|
1482
1536
|
}), option.description && /* @__PURE__ */ jsx("span", {
|
|
1483
|
-
className: "text-xs theme-muted-text
|
|
1537
|
+
className: "mt-0.5 text-xs leading-snug theme-muted-text",
|
|
1484
1538
|
children: option.description
|
|
1485
1539
|
})]
|
|
1486
1540
|
})]
|
|
@@ -1555,9 +1609,11 @@ function BucketReadOnlyField({ field, disabled, missing, labelPosition, setFormD
|
|
|
1555
1609
|
label: t.readOnly,
|
|
1556
1610
|
description: t.readOnlyDescription,
|
|
1557
1611
|
labelPosition,
|
|
1558
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
1612
|
+
children: ({ id, describedBy }) => /* @__PURE__ */ jsxs("div", {
|
|
1559
1613
|
className: "flex flex-col gap-2",
|
|
1560
1614
|
children: [/* @__PURE__ */ jsx(SwitchToggle, {
|
|
1615
|
+
id,
|
|
1616
|
+
"aria-describedby": describedBy,
|
|
1561
1617
|
onChange: (value) => {
|
|
1562
1618
|
if (disabled) return;
|
|
1563
1619
|
setFieldTouched(field.name, true);
|
|
@@ -1611,30 +1667,41 @@ function Registry(props) {
|
|
|
1611
1667
|
}
|
|
1612
1668
|
//#endregion
|
|
1613
1669
|
//#region src/form/Form.tsx
|
|
1670
|
+
function asSchemaField(value) {
|
|
1671
|
+
return value && typeof value === "object" ? value : null;
|
|
1672
|
+
}
|
|
1673
|
+
function asRecord(value) {
|
|
1674
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1675
|
+
}
|
|
1676
|
+
function flagValue(value, fallback) {
|
|
1677
|
+
return value && (typeof value === "string" || typeof value === "boolean") ? value : fallback;
|
|
1678
|
+
}
|
|
1614
1679
|
/** Applies `$meta` overrides for `labelPosition` / `spaceCompact`. */
|
|
1615
1680
|
function resolveMetaOverrides(options, labelPosition, spaceCompact) {
|
|
1681
|
+
const meta = options?.["$meta"];
|
|
1616
1682
|
return {
|
|
1617
|
-
labelPosition:
|
|
1618
|
-
spaceCompact:
|
|
1683
|
+
labelPosition: meta?.labelPosition ?? labelPosition,
|
|
1684
|
+
spaceCompact: meta?.spaceCompact ?? spaceCompact
|
|
1619
1685
|
};
|
|
1620
1686
|
}
|
|
1621
1687
|
/** Cheap signature of every list's length; gates the expensive collect walk. */
|
|
1622
1688
|
function listLengthsSignature(options, values = {}, prefix = "") {
|
|
1623
1689
|
if (!options || typeof options !== "object") return "";
|
|
1624
1690
|
const parts = [];
|
|
1625
|
-
for (const [fieldName,
|
|
1626
|
-
|
|
1691
|
+
for (const [fieldName, rawField] of Object.entries(options)) {
|
|
1692
|
+
const field = asSchemaField(rawField);
|
|
1693
|
+
if (fieldName === "$meta" || !field) continue;
|
|
1627
1694
|
const fullName = prefix ? `${prefix}${fieldName}` : fieldName;
|
|
1628
1695
|
if (field.type === "list") {
|
|
1629
1696
|
const items = values?.[fieldName];
|
|
1630
1697
|
const len = Array.isArray(items) ? items.length : 0;
|
|
1631
1698
|
parts.push(`${fullName}:${len}`);
|
|
1632
1699
|
const template = field.template || field.options;
|
|
1633
|
-
if (template && Array.isArray(items)) for (let i = 0; i < items.length; i++) parts.push(listLengthsSignature(template, items[i]
|
|
1700
|
+
if (template && Array.isArray(items)) for (let i = 0; i < items.length; i++) parts.push(listLengthsSignature(template, asRecord(items[i]), `${fullName}[${i}].`));
|
|
1634
1701
|
} else if (field.type === "group" || field.type === "object") {
|
|
1635
1702
|
const groupItems = field.items || field.options;
|
|
1636
1703
|
if (groupItems) {
|
|
1637
|
-
const nestedValues = values?.[fieldName]
|
|
1704
|
+
const nestedValues = asRecord(values?.[fieldName]);
|
|
1638
1705
|
parts.push(listLengthsSignature(groupItems, nestedValues, `${fullName}.`));
|
|
1639
1706
|
}
|
|
1640
1707
|
}
|
|
@@ -1645,14 +1712,15 @@ function listLengthsSignature(options, values = {}, prefix = "") {
|
|
|
1645
1712
|
function collectFieldsWithDefaults(options, values = {}, prefix = "") {
|
|
1646
1713
|
const result = [];
|
|
1647
1714
|
if (!options || typeof options !== "object") return result;
|
|
1648
|
-
for (const [fieldName,
|
|
1649
|
-
|
|
1715
|
+
for (const [fieldName, rawField] of Object.entries(options)) {
|
|
1716
|
+
const field = asSchemaField(rawField);
|
|
1717
|
+
if (!field) continue;
|
|
1650
1718
|
if (fieldName === "$meta") continue;
|
|
1651
1719
|
const fullName = prefix ? `${prefix}${fieldName}` : fieldName;
|
|
1652
1720
|
if (field.type === "group" || field.type === "object") {
|
|
1653
1721
|
const groupItems = field.items || field.options;
|
|
1654
1722
|
if (groupItems) {
|
|
1655
|
-
const nestedValues = values?.[fieldName]
|
|
1723
|
+
const nestedValues = asRecord(values?.[fieldName]);
|
|
1656
1724
|
result.push(...collectFieldsWithDefaults(groupItems, nestedValues, `${fullName}.`));
|
|
1657
1725
|
}
|
|
1658
1726
|
continue;
|
|
@@ -1661,7 +1729,7 @@ function collectFieldsWithDefaults(options, values = {}, prefix = "") {
|
|
|
1661
1729
|
const listTemplate = field.template || field.options;
|
|
1662
1730
|
const listValues = values?.[fieldName];
|
|
1663
1731
|
if (listTemplate && Array.isArray(listValues)) for (let i = 0; i < listValues.length; i++) {
|
|
1664
|
-
const itemValues = listValues[i]
|
|
1732
|
+
const itemValues = asRecord(listValues[i]);
|
|
1665
1733
|
result.push(...collectFieldsWithDefaults(listTemplate, itemValues, `${fullName}[${i}].`));
|
|
1666
1734
|
}
|
|
1667
1735
|
continue;
|
|
@@ -1722,8 +1790,10 @@ function DynamicDefaultsSync({ options }) {
|
|
|
1722
1790
|
function GroupHeader({ children, open, setOpen, title }) {
|
|
1723
1791
|
return /* @__PURE__ */ jsxs(SectionHeader, {
|
|
1724
1792
|
className: "flex items-center justify-between pb-1 mb-2 border-b",
|
|
1725
|
-
children: [/* @__PURE__ */ jsxs("
|
|
1726
|
-
|
|
1793
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
1794
|
+
type: "button",
|
|
1795
|
+
"aria-expanded": open,
|
|
1796
|
+
className: cx("w-full flex items-center text-left transform ease-in transition cursor-pointer"),
|
|
1727
1797
|
onClick: () => setOpen((open) => !open),
|
|
1728
1798
|
children: [/* @__PURE__ */ jsx(AngleRightIcon, { className: cx(open && "transform rotate-90 ", "px-1 text-[1.25rem] transition ease-in ") }), /* @__PURE__ */ jsx("span", { children: title })]
|
|
1729
1799
|
}), children]
|
|
@@ -1779,6 +1849,8 @@ function StatusBlock({ status }) {
|
|
|
1779
1849
|
}
|
|
1780
1850
|
function MultiSelectionDropdown({ name, label = "", invalid = false, options: initialOptions = [], setFormDirty, onChange, parentValue }) {
|
|
1781
1851
|
const [field] = useField(name);
|
|
1852
|
+
const required = useFieldRequired();
|
|
1853
|
+
const controlProps = useFieldControlProps();
|
|
1782
1854
|
const { setFieldValue } = useFormikContext();
|
|
1783
1855
|
const options = useMemo(() => {
|
|
1784
1856
|
return initialOptions.map((option) => {
|
|
@@ -1799,6 +1871,7 @@ function MultiSelectionDropdown({ name, label = "", invalid = false, options: in
|
|
|
1799
1871
|
if (onChange) onChange(options);
|
|
1800
1872
|
setFormDirty(true);
|
|
1801
1873
|
};
|
|
1874
|
+
const t = useStrings().common;
|
|
1802
1875
|
const handleRemoveOption = (key) => {
|
|
1803
1876
|
setFieldValue(name, [...field.value.filter((item) => item !== key)]);
|
|
1804
1877
|
if (onChange) onChange(options);
|
|
@@ -1809,7 +1882,9 @@ function MultiSelectionDropdown({ name, label = "", invalid = false, options: in
|
|
|
1809
1882
|
if (prevParent && parentValue && prevParent !== parentValue) setFieldValue(name, []);
|
|
1810
1883
|
}, [parentValue]);
|
|
1811
1884
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CustomListbox, {
|
|
1885
|
+
...controlProps,
|
|
1812
1886
|
options,
|
|
1887
|
+
required,
|
|
1813
1888
|
type: label.toLowerCase(),
|
|
1814
1889
|
handleOptionSelected,
|
|
1815
1890
|
className: "mb-3",
|
|
@@ -1819,9 +1894,12 @@ function MultiSelectionDropdown({ name, label = "", invalid = false, options: in
|
|
|
1819
1894
|
return /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx(Table.Item, {
|
|
1820
1895
|
className: "w-full",
|
|
1821
1896
|
children: option?.label
|
|
1822
|
-
}), /* @__PURE__ */ jsx(Table.Item, { children: /* @__PURE__ */ jsx(
|
|
1823
|
-
|
|
1824
|
-
|
|
1897
|
+
}), /* @__PURE__ */ jsx(Table.Item, { children: /* @__PURE__ */ jsx("button", {
|
|
1898
|
+
type: "button",
|
|
1899
|
+
"aria-label": t.remove,
|
|
1900
|
+
className: "inline-flex bg-transparent p-0 cursor-pointer",
|
|
1901
|
+
onClick: () => handleRemoveOption(option.value),
|
|
1902
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "link mr-4" })
|
|
1825
1903
|
}) })] }, index);
|
|
1826
1904
|
}) : /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs(Table.Item, { children: [
|
|
1827
1905
|
"No ",
|
|
@@ -1848,7 +1926,7 @@ var InputField = React.memo(function InputField({ label, field, setFormDirty, on
|
|
|
1848
1926
|
field: fieldObj,
|
|
1849
1927
|
label,
|
|
1850
1928
|
labelPosition,
|
|
1851
|
-
missing: missingFields.includes(fieldObj.name),
|
|
1929
|
+
missing: missingFields.includes(fieldObj.name ?? ""),
|
|
1852
1930
|
missingFields,
|
|
1853
1931
|
values,
|
|
1854
1932
|
setFormDirty,
|
|
@@ -1901,7 +1979,7 @@ function useFieldParse(optionsField, values, arrayIndex) {
|
|
|
1901
1979
|
}).current;
|
|
1902
1980
|
if (optionsField !== c.lastOptField) {
|
|
1903
1981
|
c.lastOptField = optionsField;
|
|
1904
|
-
c.convertedField = convertToDynamicForm(optionsField);
|
|
1982
|
+
c.convertedField = convertToDynamicForm(asRecord(optionsField));
|
|
1905
1983
|
const { inputDeps, hasExpressions } = extractInputDeps(c.convertedField);
|
|
1906
1984
|
c.inputDeps = inputDeps;
|
|
1907
1985
|
c.hasExpressions = hasExpressions;
|
|
@@ -1934,8 +2012,8 @@ function useFieldParse(optionsField, values, arrayIndex) {
|
|
|
1934
2012
|
}
|
|
1935
2013
|
var FormField = React.memo(function FormField({ id, optionsField, fieldName, values, setFormDirty, setFieldValue, setFieldTouched, parentInfo, labelPosition = "left", missingFields = [], spaceCompact = false, workflowForm = false }) {
|
|
1936
2014
|
const parsedField = useFieldParse(optionsField, values, parentInfo?.arrayIndex);
|
|
1937
|
-
const field = parentInfo ? parsedField : optionsField;
|
|
1938
|
-
if (field === null
|
|
2015
|
+
const field = asSchemaField(parentInfo ? parsedField : optionsField);
|
|
2016
|
+
if (field === null) return null;
|
|
1939
2017
|
const fieldNamePrefix = parentInfo?.fieldNamePrefix || "";
|
|
1940
2018
|
const fieldObj = {
|
|
1941
2019
|
...field,
|
|
@@ -1943,17 +2021,18 @@ var FormField = React.memo(function FormField({ id, optionsField, fieldName, val
|
|
|
1943
2021
|
name: fieldNamePrefix + fieldName,
|
|
1944
2022
|
optional: resolvedFlag(field.optional) ?? field.default !== void 0
|
|
1945
2023
|
};
|
|
1946
|
-
if (!fieldObj
|
|
2024
|
+
if (!fieldObj["name"] || fieldName === "v3") return null;
|
|
1947
2025
|
if (field.hidden === true || !field.type) {
|
|
1948
|
-
if (resolvedFlag(field.ignore) && !workflowForm) deleteFieldByPath(values, fieldObj
|
|
2026
|
+
if (resolvedFlag(field.ignore) && !workflowForm) deleteFieldByPath(values, fieldObj["name"]);
|
|
1949
2027
|
return null;
|
|
1950
2028
|
}
|
|
1951
|
-
if (!field.type && field.options) fieldObj
|
|
2029
|
+
if (!field.type && field.options) fieldObj["type"] = "dropdown";
|
|
1952
2030
|
let onChange;
|
|
1953
2031
|
if (field.one_must_be_true && parentInfo?.onChange) {
|
|
1954
2032
|
const parentOnChange = parentInfo.onChange;
|
|
1955
2033
|
const parentArrayIndex = parentInfo.arrayIndex ?? 0;
|
|
1956
|
-
|
|
2034
|
+
const fieldOptions = fieldObj["options"];
|
|
2035
|
+
onChange = (val) => parentOnChange(fieldName, parentArrayIndex, flagValue(fieldOptions?.["offOption"], false), flagValue(fieldOptions?.["onOption"], true), val);
|
|
1957
2036
|
}
|
|
1958
2037
|
if (field.show_if !== void 0 || field.show_if_not !== void 0) {
|
|
1959
2038
|
let index;
|
|
@@ -1963,18 +2042,18 @@ var FormField = React.memo(function FormField({ id, optionsField, fieldName, val
|
|
|
1963
2042
|
if (field.show_if !== void 0) shouldShowField = !!getParentValue(index, field.show_if, values, "", field);
|
|
1964
2043
|
if (shouldShowField && field.show_if_not !== void 0) shouldShowField = !getParentValue(index, field.show_if_not, values, "", field);
|
|
1965
2044
|
if (!shouldShowField) {
|
|
1966
|
-
if (!workflowForm) deleteFieldByPath(values, fieldObj
|
|
2045
|
+
if (!workflowForm) deleteFieldByPath(values, fieldObj["name"]);
|
|
1967
2046
|
return null;
|
|
1968
2047
|
}
|
|
1969
2048
|
}
|
|
1970
2049
|
if (field.depends_on) {
|
|
1971
|
-
if (parentInfo?.arrayIndex !== void 0) fieldObj
|
|
2050
|
+
if (parentInfo?.arrayIndex !== void 0) fieldObj["depends_on"] = field.depends_on.replace("[index]", `[${parentInfo.arrayIndex}]`);
|
|
1972
2051
|
}
|
|
1973
2052
|
if (field.enable_if && field.disabled === false) {
|
|
1974
2053
|
if (typeof field.enable_if === "string") {
|
|
1975
2054
|
let path = field.enable_if;
|
|
1976
2055
|
if (parentInfo?.arrayIndex !== void 0) path = field.enable_if.replace("[index]", `[${parentInfo.arrayIndex}]`);
|
|
1977
|
-
if (getValueUsingPath(values, path) === false) fieldObj
|
|
2056
|
+
if (getValueUsingPath(values, path) === false) fieldObj["disabled"] = true;
|
|
1978
2057
|
}
|
|
1979
2058
|
}
|
|
1980
2059
|
if (field.type === "group") {
|
|
@@ -1995,7 +2074,7 @@ var FormField = React.memo(function FormField({ id, optionsField, fieldName, val
|
|
|
1995
2074
|
children: /* @__PURE__ */ jsx("div", {
|
|
1996
2075
|
className: "w-full",
|
|
1997
2076
|
children: /* @__PURE__ */ jsx(FieldsFromOptions, {
|
|
1998
|
-
options: field.options,
|
|
2077
|
+
options: field.options ?? {},
|
|
1999
2078
|
setFormDirty,
|
|
2000
2079
|
setFieldValue,
|
|
2001
2080
|
setFieldTouched,
|
|
@@ -2008,41 +2087,43 @@ var FormField = React.memo(function FormField({ id, optionsField, fieldName, val
|
|
|
2008
2087
|
})
|
|
2009
2088
|
})
|
|
2010
2089
|
})
|
|
2011
|
-
}, fieldObj
|
|
2090
|
+
}, fieldObj["name"]);
|
|
2012
2091
|
}
|
|
2013
2092
|
if (typeof field.type === "object" && field.depends_on) {
|
|
2014
2093
|
const parentValue = getValueUsingPath(values, field.depends_on);
|
|
2015
|
-
|
|
2016
|
-
|
|
2094
|
+
const resolvedType = field.type[String(parentValue)];
|
|
2095
|
+
if (!resolvedType) return null;
|
|
2096
|
+
fieldObj["type"] = resolvedType;
|
|
2017
2097
|
}
|
|
2018
2098
|
if (field.type === "range" && field.depends_on) {
|
|
2019
2099
|
const parentValue = getValueUsingPath(values, field.depends_on);
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
fieldObj
|
|
2100
|
+
const { min, max } = field;
|
|
2101
|
+
if (typeof min === "object" && typeof max === "object") {
|
|
2102
|
+
fieldObj["min"] = min[String(parentValue)];
|
|
2103
|
+
fieldObj["max"] = max[String(parentValue)];
|
|
2023
2104
|
}
|
|
2024
2105
|
}
|
|
2025
2106
|
if (field.resetOnChange) {
|
|
2026
2107
|
const parentValue = getValueUsingPath(values, field.resetOnChange);
|
|
2027
2108
|
const prevParentValue = field.prevParentValue;
|
|
2028
|
-
if (prevParentValue !== void 0 && prevParentValue !== parentValue) deleteFieldByPath(values, fieldObj
|
|
2109
|
+
if (prevParentValue !== void 0 && prevParentValue !== parentValue) deleteFieldByPath(values, fieldObj["name"]);
|
|
2029
2110
|
field.prevParentValue = parentValue;
|
|
2030
2111
|
}
|
|
2031
|
-
if (field.secondaryField) if (Array.isArray(field.secondaryField)) fieldObj
|
|
2032
|
-
else fieldObj
|
|
2112
|
+
if (field.secondaryField) if (Array.isArray(field.secondaryField)) fieldObj["secondaryField"] = field.secondaryField.map((secondaryField) => fieldNamePrefix + secondaryField);
|
|
2113
|
+
else fieldObj["secondaryField"] = fieldNamePrefix + field.secondaryField;
|
|
2033
2114
|
return /* @__PURE__ */ jsx("div", {
|
|
2034
2115
|
className: cx("flex w-full", labelPosition === "left" ? "mb-[15px]" : "mb-[5px]"),
|
|
2035
2116
|
children: /* @__PURE__ */ jsx(InputField, {
|
|
2036
2117
|
field: fieldObj,
|
|
2037
|
-
label: fieldObj
|
|
2118
|
+
label: fieldObj["label"],
|
|
2038
2119
|
setFormDirty,
|
|
2039
2120
|
setFieldValue,
|
|
2040
2121
|
setFieldTouched,
|
|
2041
2122
|
values,
|
|
2042
|
-
currentValue: getValueUsingPath(values, fieldObj
|
|
2123
|
+
currentValue: getValueUsingPath(values, fieldObj["name"]),
|
|
2043
2124
|
onChange,
|
|
2044
|
-
disabled: fieldObj
|
|
2045
|
-
computeOn: parentInfo?.computeOn || fieldObj
|
|
2125
|
+
disabled: Boolean(fieldObj["disabled"]),
|
|
2126
|
+
computeOn: parentInfo?.computeOn || fieldObj["computeOn"],
|
|
2046
2127
|
labelPosition,
|
|
2047
2128
|
missingFields,
|
|
2048
2129
|
spaceCompact,
|
|
@@ -2141,7 +2222,7 @@ function DynamicForm({ formJSONs: options = {}, reinitialize = false, initialVal
|
|
|
2141
2222
|
onReset: () => {
|
|
2142
2223
|
setFormDirty(false);
|
|
2143
2224
|
},
|
|
2144
|
-
innerRef: formikRef,
|
|
2225
|
+
...formikRef ? { innerRef: formikRef } : {},
|
|
2145
2226
|
children: ({ values }) => /* @__PURE__ */ jsx(Form, {
|
|
2146
2227
|
className: "w-full text-sm",
|
|
2147
2228
|
children: /* @__PURE__ */ jsx(DynamicFormContent, {
|
|
@@ -2173,15 +2254,15 @@ function DropdownWrapper({ options, onChange, fieldObj, setFormDirty, invalid =
|
|
|
2173
2254
|
loading,
|
|
2174
2255
|
setFormDirty,
|
|
2175
2256
|
options,
|
|
2176
|
-
disabled: disabled ?? fieldObj.disabled
|
|
2257
|
+
disabled: disabled ?? Boolean(fieldObj.disabled),
|
|
2177
2258
|
placeholder: getPlaceholder(fieldObj.placeholder, typeof fieldObj.default === "string" ? fieldObj.default : void 0),
|
|
2178
|
-
name: fieldObj.name,
|
|
2259
|
+
name: fieldObj.name ?? "",
|
|
2179
2260
|
ariaLabel: fieldObj.label,
|
|
2180
2261
|
parentValue: fieldObj.parentValue,
|
|
2181
2262
|
secondaryField: fieldObj.secondaryField,
|
|
2182
2263
|
resetOnChange: fieldObj.resetOnChange,
|
|
2183
2264
|
value: fieldObj.value,
|
|
2184
|
-
autoselect: fieldObj.autoselect,
|
|
2265
|
+
autoselect: fieldObj.autoselect === void 0 ? void 0 : Boolean(fieldObj.autoselect),
|
|
2185
2266
|
allowCustomValue: allowCustomValue ?? fieldObj.allowCustomValue,
|
|
2186
2267
|
customValueLabel: fieldObj.customValueLabel,
|
|
2187
2268
|
currentValue,
|
|
@@ -2193,6 +2274,8 @@ function DropdownWrapper({ options, onChange, fieldObj, setFormDirty, invalid =
|
|
|
2193
2274
|
//#region src/form/SpecialTypes/FormikMultiSelectDropdown.tsx
|
|
2194
2275
|
function FormikMultiSelectDropdown({ name, options, setFormDirty, onChange, disabled = false, loading = false, invalid = false, placeholder, compareBy }) {
|
|
2195
2276
|
const [field] = useField(name);
|
|
2277
|
+
const required = useFieldRequired();
|
|
2278
|
+
const labelledByProps = useFieldLabelledByProps();
|
|
2196
2279
|
const { setFieldValue, setFieldTouched } = useFormikContext();
|
|
2197
2280
|
const handleChange = (next) => {
|
|
2198
2281
|
setFieldValue(name, next);
|
|
@@ -2201,8 +2284,10 @@ function FormikMultiSelectDropdown({ name, options, setFormDirty, onChange, disa
|
|
|
2201
2284
|
onChange?.(next);
|
|
2202
2285
|
};
|
|
2203
2286
|
return /* @__PURE__ */ jsx(MultiSelectDropdown, {
|
|
2287
|
+
...labelledByProps,
|
|
2204
2288
|
textBoxClassName: invalid ? "invalid" : void 0,
|
|
2205
2289
|
options,
|
|
2290
|
+
required,
|
|
2206
2291
|
value: Array.isArray(field.value) ? field.value : [],
|
|
2207
2292
|
onChange: handleChange,
|
|
2208
2293
|
disabled,
|
|
@@ -2230,8 +2315,8 @@ function resolvePwString(raw, options, fallbackUsername, opts) {
|
|
|
2230
2315
|
}
|
|
2231
2316
|
} else if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
|
|
2232
2317
|
const obj = raw;
|
|
2233
|
-
if (typeof obj
|
|
2234
|
-
const parts = obj
|
|
2318
|
+
if (typeof obj["uri"] === "string" && obj["uri"].startsWith("pw://")) {
|
|
2319
|
+
const parts = obj["uri"].slice(5).split("/");
|
|
2235
2320
|
if (parts.length === 1 && parts[0]) {
|
|
2236
2321
|
inputForm = "shorthand";
|
|
2237
2322
|
name = parts[0];
|
|
@@ -2241,19 +2326,19 @@ function resolvePwString(raw, options, fallbackUsername, opts) {
|
|
|
2241
2326
|
owner = parts[0];
|
|
2242
2327
|
name = parts[1];
|
|
2243
2328
|
}
|
|
2244
|
-
} else if (typeof obj
|
|
2245
|
-
name = obj
|
|
2246
|
-
const ownerVal = typeof obj
|
|
2247
|
-
if (obj
|
|
2329
|
+
} else if (typeof obj["name"] === "string") {
|
|
2330
|
+
name = obj["name"];
|
|
2331
|
+
const ownerVal = typeof obj["user"] === "string" ? obj["user"] : typeof obj["namespace"] === "string" ? obj["namespace"] : void 0;
|
|
2332
|
+
if (obj["type"] === "managed-cluster" || !ownerVal) {
|
|
2248
2333
|
inputForm = "shorthand";
|
|
2249
2334
|
owner = fallbackUsername;
|
|
2250
2335
|
} else {
|
|
2251
2336
|
inputForm = "full";
|
|
2252
2337
|
owner = ownerVal;
|
|
2253
2338
|
}
|
|
2254
|
-
} else if (typeof obj
|
|
2339
|
+
} else if (typeof obj["id"] === "string" && obj["id"]) {
|
|
2255
2340
|
inputForm = "shorthand";
|
|
2256
|
-
name = obj
|
|
2341
|
+
name = obj["id"];
|
|
2257
2342
|
owner = fallbackUsername;
|
|
2258
2343
|
}
|
|
2259
2344
|
}
|
|
@@ -2303,4 +2388,4 @@ function ResourceOptionIcon({ imageUrl, fallbackIcon, alt, variant = "success",
|
|
|
2303
2388
|
});
|
|
2304
2389
|
}
|
|
2305
2390
|
//#endregion
|
|
2306
|
-
export { DropdownWrapper, DynamicDefaultsSync, DynamicForm, FLEX_MAX_DURATION_RANGE, FLEX_WAIT_TIME_RANGE, FieldRegistryContext, FieldWrapper, FieldsFromOptions, FormikCustomDropdown_default as FormikCustomDropdown, FormikCustomInput, FormikMultiSelectDropdown, FormikNumericInput, GroupHeader, MultiSelectionDropdown, NumberField, Registry, ResourceOptionIcon, STANDARD_MAX_DURATION_RANGE, StatusBlock, applySecondaryField, collectFieldsWithDefaults, collectPartitionDurationIssues, enforceOneMustBeTrue, findSecondaryOption, findSelfReferencingFieldNames, flattenGroups, formatSecondsAsSlurmDuration, getInstanceTypesForForm, getInvalidDurationPaths, getPlaceholder, impureSetValueFromPath, initializeValues, parseSlurmDuration, resolveMetaOverrides, resolvePwString, resolvePwValue, resolvedFlag, setDurationValidity, useParsedOpts };
|
|
2391
|
+
export { DropdownWrapper, DynamicDefaultsSync, DynamicForm, FLEX_MAX_DURATION_RANGE, FLEX_WAIT_TIME_RANGE, FieldProvider, FieldRegistryContext, FieldWrapper, FieldsFromOptions, FormikCustomDropdown_default as FormikCustomDropdown, FormikCustomInput, FormikMultiSelectDropdown, FormikNumericInput, GroupHeader, MultiSelectionDropdown, NumberField, Registry, ResourceOptionIcon, STANDARD_MAX_DURATION_RANGE, StatusBlock, applySecondaryField, collectFieldsWithDefaults, collectPartitionDurationIssues, enforceOneMustBeTrue, findSecondaryOption, findSelfReferencingFieldNames, flattenGroups, formatSecondsAsSlurmDuration, getInstanceTypesForForm, getInvalidDurationPaths, getPlaceholder, impureSetValueFromPath, initializeValues, parseSlurmDuration, resolveMetaOverrides, resolvePwString, resolvePwValue, resolvedFlag, setDurationValidity, useFieldControlProps, useFieldLabelledByProps, useFieldRequired, useParsedOpts };
|