MCPcopy
hub / github.com/angular/angular / disabled

Function disabled

packages/forms/signals/src/api/rules/disabled.ts:42–72  ·  view source on GitHub ↗
(
  path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>,
  configOrLogic?:
    | {when?: string | NoInfer<LogicFn<TValue, boolean | string, TPathKind>>}
    | string
    | NoInfer<LogicFn<TValue, boolean | string, TPathKind>>,
)

Source from the content-addressed store, hash-verified

40): void;
41
42export function disabled<TValue, TPathKind extends PathKind = PathKind.Root>(
43 path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>,
44 configOrLogic?:
45 | {when?: string | NoInfer<LogicFn<TValue, boolean | string, TPathKind>>}
46 | string
47 | NoInfer<LogicFn<TValue, boolean | string, TPathKind>>,
48): void {
49 assertPathIsCurrent(path);
50
51 const pathNode = FieldPathNode.unwrapFieldPath(path);
52
53 let logic: string | LogicFn<TValue, boolean | string, TPathKind> | undefined;
54 if (typeof configOrLogic === 'function' || typeof configOrLogic === 'string') {
55 logic = configOrLogic;
56 } else {
57 logic = configOrLogic?.when;
58 }
59
60 pathNode.builder.addDisabledReasonRule((ctx) => {
61 let result: boolean | string = true;
62 if (typeof logic === 'string') {
63 result = logic;
64 } else if (logic) {
65 result = logic(ctx as FieldContext<TValue, TPathKind>);
66 }
67 if (typeof result === 'string') {
68 return {fieldTree: ctx.fieldTree, message: result};
69 }
70 return result ? {fieldTree: ctx.fieldTree} : undefined;
71 });
72}

Callers 13

TestCmpClass · 0.90
AppClass · 0.90
TestCmpClass · 0.90
TestCmpClass · 0.50
ReadonlyTestCmpClass · 0.50
field_node.spec.tsFile · 0.50
addressSchemaFunction · 0.50
submit.spec.tsFile · 0.50

Calls 3

assertPathIsCurrentFunction · 0.90
unwrapFieldPathMethod · 0.80
addDisabledReasonRuleMethod · 0.45

Tested by 1

addressSchemaFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…