@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.
Files changed (84) hide show
  1. package/dist/chunks/{BareModal-DBa84JZO.js → BareModal-BqroLbZ5.js} +1 -0
  2. package/dist/chunks/{CodePreviewEditor-hwjZof0M.js → CodePreviewEditor-67A_SKgE.js} +1 -1
  3. package/dist/chunks/{CreateModal-DLCC8t_x.js → CreateModal-DoA2WsXf.js} +28 -8
  4. package/dist/chunks/{Monaco-DCwRDrPm.js → Monaco-H56KyEdb.js} +22 -12
  5. package/dist/chunks/{PageHeader-dyoL44ue.js → PageHeader-CxxbidPp.js} +44 -10
  6. package/dist/chunks/{Provider-CfFV-vc5.js → Provider-CbFVFB7O.js} +8 -2
  7. package/dist/chunks/RequiredMark-DfLdYbYZ.js +11 -0
  8. package/dist/chunks/{StatusBadge-P6C2tv7Z.js → StatusBadge-RRUI78iS.js} +4 -4
  9. package/dist/chunks/{SwitchToggle-DcPCXkqL.js → SwitchToggle-DbW0Q__L.js} +49 -32
  10. package/dist/chunks/{Table-ByziK93x.js → Table-CutP1bRt.js} +22 -6
  11. package/dist/chunks/{Tooltip-WgbiC_nd.js → Tooltip-n9w7Tkt1.js} +28 -3
  12. package/dist/chunks/{editor-BH81U5-C.js → editor-BZ9Buwi4.js} +34 -23
  13. package/dist/chunks/lib-DyJvmbzj.js +256 -0
  14. package/dist/chunks/{list-CWVR3dfZ.js → list-CBZpAYP7.js} +35 -15
  15. package/dist/components/Breadcrumbs.d.ts +9 -0
  16. package/dist/components/CollapsiblePanel.d.ts +4 -4
  17. package/dist/components/CreateModal.d.ts +8 -8
  18. package/dist/components/Dropdown.d.ts +5 -3
  19. package/dist/components/Input.d.ts +1 -1
  20. package/dist/components/Listbox.d.ts +7 -4
  21. package/dist/components/Loader.d.ts +1 -1
  22. package/dist/components/MultiSelect.d.ts +8 -5
  23. package/dist/components/PageHeader.d.ts +4 -3
  24. package/dist/components/Pagination.d.ts +2 -2
  25. package/dist/components/Provider.d.ts +9 -3
  26. package/dist/components/RequiredMark.d.ts +1 -0
  27. package/dist/components/SettingRow.d.ts +1 -1
  28. package/dist/components/SwitchToggle.d.ts +3 -2
  29. package/dist/components/Table.d.ts +5 -3
  30. package/dist/components/Tooltip.d.ts +7 -1
  31. package/dist/components/dropdownUtils.d.ts +6 -6
  32. package/dist/editor/FormCodePanel.d.ts +3 -3
  33. package/dist/editor/Monaco.d.ts +2 -2
  34. package/dist/editor/index.js +1 -1
  35. package/dist/file-explorer/FileExplorer.d.ts +2 -2
  36. package/dist/file-explorer/helpers.d.ts +2 -2
  37. package/dist/file-explorer/index.js +46 -18
  38. package/dist/file-explorer/lib/fileExplorer.d.ts +1 -1
  39. package/dist/file-explorer/lib/types.d.ts +21 -21
  40. package/dist/form/FieldWrapper.d.ts +6 -1
  41. package/dist/form/Fields/ResourceOptionIcon.d.ts +1 -1
  42. package/dist/form/Fields/StepField.d.ts +1 -1
  43. package/dist/form/Form.d.ts +28 -27
  44. package/dist/form/SpecialTypes/DropdownWrapper.d.ts +16 -3
  45. package/dist/form/SpecialTypes/FormikCustomDropdown.d.ts +11 -11
  46. package/dist/form/SpecialTypes/FormikCustomInput.d.ts +12 -10
  47. package/dist/form/SpecialTypes/FormikMultiSelectDropdown.d.ts +1 -1
  48. package/dist/form/SpecialTypes/FormikNumericInput.d.ts +2 -2
  49. package/dist/form/Wizard/WizardContainer.d.ts +1 -1
  50. package/dist/form/Wizard/WizardStepContent.d.ts +2 -2
  51. package/dist/form/Wizard/types.d.ts +21 -14
  52. package/dist/form/Wizard/utils.d.ts +1 -1
  53. package/dist/form/fieldContext.d.ts +19 -0
  54. package/dist/form/index.d.ts +2 -1
  55. package/dist/form/index.js +191 -106
  56. package/dist/form/lib.d.ts +3 -3
  57. package/dist/form/types/fieldComponentTypes.d.ts +2 -2
  58. package/dist/form/useParsedOpts.d.ts +1 -1
  59. package/dist/form/utils/getParentValue.d.ts +3 -1
  60. package/dist/form/utils/getValueUsingPath.d.ts +1 -1
  61. package/dist/form/utils/pwResolver.d.ts +4 -4
  62. package/dist/icons.d.ts +8 -8
  63. package/dist/icons.js +4 -4
  64. package/dist/index.d.ts +4 -3
  65. package/dist/index.js +51 -21
  66. package/dist/list/ActionToolbar.d.ts +4 -4
  67. package/dist/list/HoverCard.d.ts +3 -1
  68. package/dist/list/ListPage.d.ts +3 -3
  69. package/dist/list/ListTable.d.ts +1 -1
  70. package/dist/list/RowContextMenu.d.ts +20 -20
  71. package/dist/list/index.js +2 -2
  72. package/dist/logviewer/index.js +24 -7
  73. package/dist/styles/theme.css +6 -6
  74. package/dist/styles.css +1 -1
  75. package/dist/theme/index.js +4 -3
  76. package/dist/workflow/AnnotationBanner.d.ts +2 -1
  77. package/dist/workflow/DependencyGraph.d.ts +15 -3
  78. package/dist/workflow/JobSummary.d.ts +2 -25
  79. package/dist/workflow/MatrixGroup.d.ts +3 -2
  80. package/dist/workflow/TreeView.d.ts +1 -32
  81. package/dist/workflow/index.js +235 -138
  82. package/dist/workflow/types.d.ts +48 -0
  83. package/package.json +2 -6
  84. package/dist/chunks/lib-DTgL8klR.js +0 -191
@@ -0,0 +1,48 @@
1
+ import type { MatrixGroup, TStatus } from '@parallelworks/workflow-parser';
2
+ export interface WorkflowSubworkflow {
3
+ jobs?: Record<string, WorkflowJob>;
4
+ image?: string;
5
+ type?: string;
6
+ }
7
+ export interface WorkflowAnnotation {
8
+ type?: 'error' | 'warning' | 'notice';
9
+ message?: string;
10
+ title?: string;
11
+ file?: string;
12
+ line?: number;
13
+ id?: string;
14
+ }
15
+ export interface WorkflowStep {
16
+ name?: string;
17
+ status: TStatus;
18
+ run?: string;
19
+ uses?: string;
20
+ image?: string;
21
+ cleanup?: string;
22
+ linkedStep?: string;
23
+ startedAt?: string;
24
+ completedAt?: string;
25
+ annotations?: WorkflowAnnotation[];
26
+ subworkflow?: WorkflowSubworkflow | undefined;
27
+ }
28
+ export interface WorkflowMatrixMeta {
29
+ originaljob: string;
30
+ index: number;
31
+ totalingroup: number;
32
+ groupjobs: string[];
33
+ values: Record<string, unknown>;
34
+ failfast: boolean;
35
+ maxparallel: number;
36
+ }
37
+ export interface WorkflowJob {
38
+ status: TStatus;
39
+ steps: WorkflowStep[];
40
+ cleanup?: WorkflowStep[];
41
+ needs?: string[];
42
+ if?: boolean | string;
43
+ startedAt?: string;
44
+ completedAt?: string;
45
+ _matrix?: WorkflowMatrixMeta;
46
+ _matrixGroup?: MatrixGroup;
47
+ }
48
+ export declare function isJobRecord(value: unknown): value is Record<string, WorkflowJob>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/ui",
3
- "version": "0.12.1",
3
+ "version": "0.14.0",
4
4
  "description": "Shared UI foundation for Parallel Works packages: theme contract, icons, and core primitives",
5
5
  "license": "MIT",
6
6
  "author": "Parallel Works <support@parallelworks.com>",
@@ -127,11 +127,7 @@
127
127
  "check-types": "tsc --noEmit",
128
128
  "test": "vitest run",
129
129
  "lint:package": "publint --strict",
130
- "verify:pack": "node scripts/verify-pack.mjs",
131
- "check-types:nuia": "node scripts/check-tsc-ratchet.mjs tsconfig.nuia.json scripts/nuia-baseline.json noUncheckedIndexedAccess",
132
- "check-types:exact-optional": "node scripts/check-tsc-ratchet.mjs tsconfig.exact-optional.json scripts/exact-optional-baseline.json exactOptionalPropertyTypes",
133
- "check-types:index-access": "node scripts/check-tsc-ratchet.mjs tsconfig.index-access.json scripts/index-access-baseline.json noPropertyAccessFromIndexSignature",
134
- "lint:explicit-any": "node scripts/check-explicit-any-ratchet.mjs"
130
+ "verify:pack": "node scripts/verify-pack.mjs"
135
131
  },
136
132
  "main": "./dist/index.js",
137
133
  "types": "./dist/index.d.ts"
@@ -1,191 +0,0 @@
1
- import cx from "classnames";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/form/FieldWrapper.tsx
4
- function FieldWrapper({ label, tooltipComponent, description, labelPosition = "left", spaceCompact = false, optional = false, children }) {
5
- return /* @__PURE__ */ jsxs("div", {
6
- className: cx("flex w-full", labelPosition === "left" ? "items-start" : "items-left flex-col"),
7
- children: [/* @__PURE__ */ jsxs("div", {
8
- className: cx("relative", labelPosition === "left" ? "form-label" : "form-label-top", spaceCompact && "form-label-compact"),
9
- children: [
10
- label,
11
- !optional && /* @__PURE__ */ jsx("span", { children: "*" }),
12
- tooltipComponent
13
- ]
14
- }), /* @__PURE__ */ jsxs("div", {
15
- className: "w-full",
16
- children: [children, description && /* @__PURE__ */ jsx("div", {
17
- className: "text-xs theme-muted-text mt-1 leading-relaxed",
18
- children: description
19
- })]
20
- })]
21
- });
22
- }
23
- //#endregion
24
- //#region src/form/utils/secondaryField.ts
25
- function findSecondaryOption(options, value) {
26
- for (const candidate of options) {
27
- if (!candidate || typeof candidate !== "object") continue;
28
- const option = candidate;
29
- if (option.value === value) return option;
30
- if (Array.isArray(option.options)) {
31
- const nestedOption = findSecondaryOption(option.options, value);
32
- if (nestedOption) return nestedOption;
33
- }
34
- }
35
- }
36
- function applySecondaryField(secondaryField, secondaryValue, setFieldValue) {
37
- if (secondaryField === void 0 || secondaryValue === void 0) return;
38
- const fields = Array.isArray(secondaryField) ? secondaryField : [secondaryField];
39
- const values = Array.isArray(secondaryValue) ? secondaryValue : [secondaryValue];
40
- fields.forEach((field, index) => {
41
- setFieldValue(field, values[index]);
42
- });
43
- }
44
- //#endregion
45
- //#region src/form/lib.ts
46
- /**
47
- * Drops a schema flag the expression parser could not resolve. workflow.schema.json types
48
- * `optional`/`hidden`/`ignore` as ["string", "boolean"], so a flag whose expression depends
49
- * on something unavailable at form-render time (a list `[index]` outside a row, `needs.`,
50
- * `env.`, a secret `var.`) arrives as the raw `${{…}}` string. That string is truthy, which
51
- * inverts each flag's documented `false` default. Returning undefined lets the caller apply
52
- * that default instead of reading an expression it never evaluated as "yes".
53
- */
54
- function resolvedFlag(value) {
55
- return typeof value === "string" && value.includes("${{") ? void 0 : value;
56
- }
57
- function enforceOneMustBeTrue(items, options, promoteIndex) {
58
- if (items.length === 0) return items;
59
- const clampedIndex = Math.max(0, Math.min(promoteIndex, items.length - 1));
60
- const oneMustBeTrueFields = Object.keys(options).filter((key) => typeof options[key] === "object" && options[key] !== null && "one_must_be_true" in options[key] && options[key].one_must_be_true);
61
- for (const fieldKey of oneMustBeTrueFields) {
62
- const fieldSchema = options[fieldKey];
63
- if (typeof fieldSchema === "object" && fieldSchema && "options" in fieldSchema) {
64
- const opts = fieldSchema.options;
65
- const trueOption = typeof opts === "object" && opts && !Array.isArray(opts) && "onOption" in opts ? opts.onOption || true : true;
66
- if (!items.some((item) => item[fieldKey] === trueOption)) items[clampedIndex][fieldKey] = trueOption;
67
- }
68
- }
69
- return items;
70
- }
71
- function flattenGroups(schema) {
72
- if (!schema) return {};
73
- let flattenedFields = {};
74
- Object.keys(schema).forEach((key) => {
75
- if (schema[key].type === "group") {
76
- const flattenedGroup = flattenGroups(schema[key].options);
77
- flattenedFields = {
78
- ...flattenedFields,
79
- ...flattenedGroup
80
- };
81
- } else if (schema[key].type === "object") {
82
- const flattenedGroup = flattenGroups(schema[key].options);
83
- flattenedFields = {
84
- ...flattenedFields,
85
- [key]: flattenedGroup
86
- };
87
- } else flattenedFields[key] = schema[key];
88
- });
89
- return flattenedFields;
90
- }
91
- /**Not a pure function. Edits 'obj' passed into function */
92
- function impureSetValueFromPath(obj, path, value) {
93
- const pathArray = path.split(".");
94
- if (pathArray.length === 1) {
95
- obj[pathArray[0]] = value;
96
- return;
97
- }
98
- let current = obj;
99
- for (let i = 0; i < pathArray.length - 1; i++) {
100
- const segment = pathArray[i];
101
- const arrayMatch = segment.match(/^(.+)\[(\d+)\]$/);
102
- if (arrayMatch) {
103
- const key = arrayMatch[1];
104
- const index = Number(arrayMatch[2]);
105
- if (!current[key]) current[key] = [];
106
- if (!current[key][index]) current[key][index] = {};
107
- current = current[key][index];
108
- } else {
109
- if (!current[segment]) current[segment] = {};
110
- current = current[segment];
111
- }
112
- }
113
- current[pathArray[pathArray.length - 1]] = value;
114
- }
115
- function initializeValues(options, srcData = {}, ignoreDefaultStrings = false) {
116
- if (!options) return;
117
- const data = structuredClone(srcData);
118
- return Object.keys(options).reduce((acc, field) => {
119
- if (field.startsWith("$")) return acc;
120
- if (options[field].type === "group") {
121
- const values = initializeValues(options[field].options, data);
122
- if (!values) return acc;
123
- Object.keys(values).forEach((key) => {
124
- acc[key] = data[key] ?? values[key];
125
- });
126
- return acc;
127
- }
128
- if (options[field].type === "step") {
129
- if (options.$meta?.wizard?.flatten !== false) {
130
- const values = initializeValues(options[field].options, data);
131
- if (!values) return acc;
132
- Object.keys(values).forEach((key) => {
133
- acc[key] = data[key] ?? values[key];
134
- });
135
- } else acc[field] = initializeValues(options[field].options, data[field] || {});
136
- return acc;
137
- }
138
- if (options[field].type === "object") {
139
- acc[field] = initializeValues(options[field].options, data[field] || {});
140
- return acc;
141
- }
142
- if (options[field].type === "list") {
143
- if (options[field].options === "string") {
144
- acc[field] = Array.isArray(data[field]) ? [...data[field]] : [];
145
- return acc;
146
- }
147
- const arr = [];
148
- if (data[field]) for (let i = 0; i < data[field].length; i++) arr.push(initializeValues(options[field].options, data[field][i] || {}));
149
- acc[field] = arr;
150
- return acc;
151
- }
152
- if (data[field] !== void 0) {
153
- acc[field] = data[field];
154
- if ((options[field].type === "dropdown" || options[field].type === "storage") && options[field].secondaryField && options[field].options && Array.isArray(options[field].options)) {
155
- const option = findSecondaryOption(options[field].options, data[field]);
156
- applySecondaryField(options[field].secondaryField, option?.secondaryValue, (secondaryField, secondaryValue) => {
157
- if (!(options[field].type === "storage" && Object.prototype.hasOwnProperty.call(options, secondaryField) && srcData[secondaryField] !== void 0)) impureSetValueFromPath(acc, secondaryField, secondaryValue);
158
- });
159
- }
160
- return acc;
161
- }
162
- if (options[field].type === "label") return acc;
163
- if (options[field].optional && options[field].default === void 0) return acc;
164
- acc[field] = "";
165
- if (options[field].autoselect) acc[field] = void 0;
166
- if (options[field].type === "boolean") if (options[field].options?.offOption && options[field].options?.onOption) acc[field] = options[field].options.offOption;
167
- else acc[field] = false;
168
- if (options[field].type === "dropdown") {
169
- if (options[field].options && Array.isArray(options[field].options) && options[field].options.length > 0) acc[field] = options[field].options[0].value;
170
- if (options[field].type === "dropdown" && options[field].secondaryField && options[field].options && Array.isArray(options[field].options)) {
171
- const option = options[field].options.find((option) => option.value === data[field]);
172
- const secondaryField = Array.isArray(options[field].secondaryField) ? options[field].secondaryField : [options[field].secondaryField];
173
- const secondaryValue = Array.isArray(option?.secondaryValue) ? option?.secondaryValue : [option?.secondaryValue];
174
- secondaryField.forEach((field, index) => {
175
- impureSetValueFromPath(data, field, secondaryValue[index]);
176
- impureSetValueFromPath(acc, field, secondaryValue[index]);
177
- });
178
- }
179
- }
180
- if (options[field].type === "multi-dropdown" || options[field].type === "checkbox-group") acc[field] = [];
181
- if (options[field].default !== void 0) {
182
- const dflt = options[field].default;
183
- const isPwResource = typeof dflt === "string" && dflt.startsWith("pw://");
184
- acc[field] = options[field].type === "string" || ignoreDefaultStrings && !isPwResource && (options[field].type === "textarea" || options[field].type === "compute-clusters" || options[field].type === "compute-resources") ? "" : dflt;
185
- }
186
- if (options[field].prefillDefault && options[field].default !== void 0) acc[field] = options[field].default;
187
- return acc;
188
- }, data);
189
- }
190
- //#endregion
191
- export { resolvedFlag as a, FieldWrapper as c, initializeValues as i, flattenGroups as n, applySecondaryField as o, impureSetValueFromPath as r, findSecondaryOption as s, enforceOneMustBeTrue as t };