parseRules()

in src/rules.js [92:129]


	parseRules() {
		const shown = {};
		const computed = {};
		let lastHiddenParent = null;

		for (const { fieldConfig, treePath } of iterateFields(this.config)) {
			let isShown;
			let parentWasHidden;

			if (lastHiddenParent && treePath.startsWith(lastHiddenParent)) {
				isShown = false;
				parentWasHidden = true;
			} else {
				isShown = this.computeShown(fieldConfig, shown);
			}

			shown[fieldConfig.path] = isShown;

			if (!parentWasHidden && !isShown) {
				lastHiddenParent = treePath;
			}

			computed[treePath] = {
				shown: isShown,
			};
		}

		// After the shown property is resolved for all fields, other properties can be computed
		for (const { fieldConfig, treePath } of iterateFields(this.config)) {
			computed[treePath] = {
				...(computed[treePath] || {}),
				disabled: this.computeProperty(properties.DISABLED, !!fieldConfig.disabled, fieldConfig, shown),
				required: this.computeProperty(properties.REQUIRED, !!fieldConfig.required, fieldConfig, shown),
			};
		}

		return computed;
	}