MCPcopy Create free account
hub / github.com/angular/angular / disabled

Function disabled

packages/forms/signals/src/api/rules/disabled.ts:45–75  ·  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

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

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