@tai42/studio-sdk 22.2.0 → 22.4.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 (57) hide show
  1. package/dist/guards.d.ts +6 -0
  2. package/dist/guards.d.ts.map +1 -1
  3. package/dist/guards.js +8 -0
  4. package/dist/guards.js.map +1 -1
  5. package/dist/hooks/useApi.d.ts +7 -0
  6. package/dist/hooks/useApi.d.ts.map +1 -1
  7. package/dist/schema-form/SchemaForm.d.ts +4 -1
  8. package/dist/schema-form/SchemaForm.d.ts.map +1 -1
  9. package/dist/schema-form/SchemaForm.js.map +1 -1
  10. package/dist/schema-form/classify.js +3 -3
  11. package/dist/schema-form/classify.js.map +1 -1
  12. package/dist/schema-form/default-value.js +5 -4
  13. package/dist/schema-form/default-value.js.map +1 -1
  14. package/dist/schema-form/field-model.d.ts +3 -3
  15. package/dist/schema-form/field-model.d.ts.map +1 -1
  16. package/dist/schema-form/field-node.d.ts +1 -0
  17. package/dist/schema-form/field-node.d.ts.map +1 -1
  18. package/dist/schema-form/field-node.js +2 -1
  19. package/dist/schema-form/field-node.js.map +1 -1
  20. package/dist/schema-form/multiselect-field.d.ts +1 -1
  21. package/dist/schema-form/object-fields.d.ts +1 -0
  22. package/dist/schema-form/object-fields.d.ts.map +1 -1
  23. package/dist/schema-form/object-fields.js +4 -3
  24. package/dist/schema-form/object-fields.js.map +1 -1
  25. package/dist/schema-form/record-field.d.ts.map +1 -1
  26. package/dist/schema-form/record-field.js +4 -2
  27. package/dist/schema-form/record-field.js.map +1 -1
  28. package/dist/schema-form/string-field.js +2 -2
  29. package/dist/schema-form/string-field.js.map +1 -1
  30. package/dist/schema-form/union-field.d.ts.map +1 -1
  31. package/dist/schema-form/union-field.js +3 -8
  32. package/dist/schema-form/union-field.js.map +1 -1
  33. package/dist/schema-form/union.js +1 -1
  34. package/dist/schema-form/union.js.map +1 -1
  35. package/dist/schema-form/validate.d.ts +14 -1
  36. package/dist/schema-form/validate.d.ts.map +1 -1
  37. package/dist/schema-form/validate.js +99 -45
  38. package/dist/schema-form/validate.js.map +1 -1
  39. package/dist/schema-form/visibility.d.ts +0 -12
  40. package/dist/schema-form/visibility.d.ts.map +1 -1
  41. package/dist/schema-form/visibility.js +14 -1
  42. package/dist/schema-form/visibility.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/guards.ts +12 -0
  45. package/src/schema-form/SchemaForm.tsx +4 -2
  46. package/src/schema-form/classify.ts +3 -3
  47. package/src/schema-form/default-value.ts +5 -4
  48. package/src/schema-form/field-model.ts +3 -3
  49. package/src/schema-form/field-node.tsx +4 -3
  50. package/src/schema-form/multiselect-field.tsx +1 -1
  51. package/src/schema-form/object-fields.tsx +8 -7
  52. package/src/schema-form/record-field.tsx +4 -2
  53. package/src/schema-form/string-field.tsx +2 -2
  54. package/src/schema-form/union-field.tsx +5 -6
  55. package/src/schema-form/union.ts +1 -1
  56. package/src/schema-form/validate.ts +127 -46
  57. package/src/schema-form/visibility.ts +4 -3
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * The single evaluator for a property's `visibleWhen` predicate — a static,
3
- * declarative field-visibility rule (scope B). The renderer (`ObjectFields`) and the
3
+ * declarative field-visibility rule. The renderer (`ObjectFields`) and the
4
4
  * validator both call it so a field shown by the form is exactly the field validated at
5
5
  * submit, and a hidden field is neither rendered nor required. It reads only sibling
6
- * values already in the object; it never calls a consumer handler (that is scope A).
6
+ * values already in the object; it never calls a consumer handler.
7
7
  *
8
8
  * A malformed predicate degrades to VISIBLE: the send-time server validation rejects a
9
9
  * malformed predicate loudly, so one never reaches a well-formed render, and showing a
10
10
  * field is the safe non-hiding default (a hidden-by-accident required field would dead-
11
11
  * end a form).
12
12
  */
13
+ import { ownValue } from '../guards';
13
14
  import type { JsonSchema } from './types';
14
15
 
15
16
  function isRecord(value: unknown): value is Record<string, unknown> {
@@ -33,7 +34,7 @@ function isEmptyValue(value: unknown): boolean {
33
34
  export function isFieldVisible(schema: JsonSchema, values: Record<string, unknown>): boolean {
34
35
  const predicate: unknown = schema.visibleWhen;
35
36
  if (!isRecord(predicate) || typeof predicate.field !== 'string') return true;
36
- const current = values[predicate.field];
37
+ const current = ownValue(values, predicate.field);
37
38
 
38
39
  const inList = predicate.in;
39
40
  const hasEquals = 'equals' in predicate;