@teselagen/ui 0.3.85 → 0.4.2

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/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.3.85",
3
+ "version": "0.4.2",
4
4
  "main": "./src/index.js",
5
5
  "exports": {
6
6
  ".": {
7
7
  "import": "./index.es.js",
8
8
  "require": "./index.cjs.js"
9
- }
9
+ },
10
+ "./style.css": "./style.css"
10
11
  },
11
12
  "dependencies": {
12
13
  "@teselagen/file-utils": "0.3.16",
@@ -18,6 +19,7 @@
18
19
  "@teselagen/react-table": "6.10.16",
19
20
  "bluebird": "3.7.2",
20
21
  "buffer": "5.7.1",
22
+ "classnames": "^2.3.2",
21
23
  "color": "^3.2.1",
22
24
  "copy-to-clipboard": "^3.3.1",
23
25
  "dayjs": "^1.10.4",
@@ -28,7 +28,10 @@ export function validateTableWideErrors({
28
28
  });
29
29
  }
30
30
  const displayNameMap = {};
31
+ const fieldUpperToPath = {};
32
+
31
33
  forEach(schema.fields, f => {
34
+ fieldUpperToPath[f.path.toUpperCase()] = f.path;
32
35
  displayNameMap[f.path] = f.displayName || startCase(camelCase(f.path));
33
36
  });
34
37
  function getDisplayName(path) {
@@ -80,6 +83,28 @@ export function validateTableWideErrors({
80
83
  });
81
84
  });
82
85
  }
86
+
87
+ const requireIfs = [];
88
+ schema.fields.forEach(col => {
89
+ const { path, requireIf } = col;
90
+ if (requireIf) {
91
+ const requireIfPath = fieldUpperToPath[requireIf.toUpperCase()];
92
+ requireIfs.push([requireIfPath, path]);
93
+ }
94
+ });
95
+ requireIfs.forEach(([requireIfPath, path]) => {
96
+ entities.forEach(entity => {
97
+ const requireIfVal = getCellVal(entity, requireIfPath);
98
+ const pathVal = getCellVal(entity, path);
99
+ if (requireIfVal && !pathVal) {
100
+ const cellId = `${getIdOrCodeOrIndex(entity)}:${path}`;
101
+ newCellValidate[cellId] = {
102
+ message: `This field is required if ${displayNameMap[requireIfPath]} is present`,
103
+ _isTableWideError: true
104
+ };
105
+ }
106
+ });
107
+ });
83
108
  if (schema.requireAllOrNone) {
84
109
  (isArray(schema.requireAllOrNone[0])
85
110
  ? schema.requireAllOrNone
@@ -148,8 +148,8 @@ function UploaderInner({
148
148
  }) {
149
149
  let dropzoneDisabled = _disabled;
150
150
  let _accept = __accept;
151
- //on component did mount
152
151
  const validateAgainstSchemaStore = useRef(new ValidateAgainstSchema());
152
+ const [acceptLoading, setAcceptLoading] = useState();
153
153
  const [resolvedAccept, setResolvedAccept] = useState();
154
154
  if (resolvedAccept) {
155
155
  _accept = resolvedAccept;
@@ -157,16 +157,19 @@ function UploaderInner({
157
157
  const isAcceptPromise =
158
158
  __accept?.then ||
159
159
  (Array.isArray(__accept) ? __accept.some(a => a?.then) : false);
160
- const acceptLoading =
161
- !resolvedAccept && isAcceptPromise && `Accept Loading...`;
162
-
160
+ useEffect(() => {
161
+ if (isAcceptPromise) {
162
+ setAcceptLoading(true);
163
+ Promise.allSettled(Array.isArray(__accept) ? __accept : [__accept]).then(
164
+ results => {
165
+ const resolved = flatMap(results, r => r.value);
166
+ setAcceptLoading(false);
167
+ setResolvedAccept(resolved);
168
+ }
169
+ );
170
+ }
171
+ }, [__accept, isAcceptPromise]);
163
172
  if (isAcceptPromise && !resolvedAccept) {
164
- Promise.allSettled(Array.isArray(__accept) ? __accept : [__accept]).then(
165
- results => {
166
- const resolved = flatMap(results, r => r.value);
167
- setResolvedAccept(resolved);
168
- }
169
- );
170
173
  _accept = [];
171
174
  }
172
175
  if (acceptLoading) dropzoneDisabled = true;
@@ -499,7 +502,7 @@ function UploaderInner({
499
502
  className={Classes.TEXT_MUTED}
500
503
  style={{ fontSize: 11, marginBottom: 5 }}
501
504
  >
502
- {advancedAccept ? (
505
+ {advancedAccept && !acceptLoading ? (
503
506
  <div style={{}}>
504
507
  Accepts &nbsp;
505
508
  <span style={{}}>
package/src/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import "@blueprintjs/core/lib/css/blueprint.css";
2
+ import "@blueprintjs/datetime/lib/css/blueprint-datetime.css";
3
+ import "@blueprintjs/icons/lib/css/blueprint-icons.css";
1
4
  import "./style.css";
2
5
  import "./autoTooltip";
3
6
  export { LoadingDots } from "./FormComponents/LoadingDots";